Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm working on Swift interpreter and the codebase is fairly difficult to debug. There's a lot of reused bits. So if you put a debug point somewhere trying to capture one behavior, odds are that that line will run 10 times for other work before the relevant part uses it.

So I tend to write a LOT of print statements that flush of debug variables right before I where I want to debug. Then I set a conditional breakpoint so that I can have the logs "stop" right where I want the program to.

Example:

// debug print

let someValueICareAbout = variable...

print(someValueICareAbout)

print("") <- conditional debug point here "if someValueICareAbout == 3"

I think it's technically still "print debugging", because I'm only using the debugger to stop the program so I get a chance to read my output.



Why not just add an action to the conditional breakpoint that prints the value?


I’m usually constructing those values just for that one-off test. They aren’t there at runtime.

It’s an AST interpreter so sometimes I want to see the value of something that’s 5 properties away inside a syntax node




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: