Hacker News new | past | comments | ask | show | jobs | submit login

> "DEBUG 1", "DEBUG 2"

If you use language expressions that automatically become file/line info, that frees you from juggling unique labels. Then it can be saved into your IDE as a insertable code snippet.

It goes without saying that a real interactive debugger session is even better, but it isn't always convenient or possible.




Sometimes an interactive debugger session will make the issue you are researching not happen -- I don't know of a way of tracking down race conditions that isn't logging everything that happens until I find out which thing happened before which other thing that wasn't supposed to


> Sometimes an interactive debugger session will make the issue you are researching not happen

I still remember the first time that happened to me, I think it had to do with some (not yet diagnosed) race condition on a PHP server between the HTTP requests it served, and the debugger had a side-effect of blocking the next request while I was inspecting the first one.

That reminds me of another thing: Some debuggers allow you to set breakpoints and set them to not suspend or pause execution, but to emits a log-message to the debugger or terminal instead.

Those are an upgrade over print-statements in that:

1. You can't accidentally commit it and it doesn't show up to make your diffs weird

2. You may be able to dynamically change what things it prints out without restarting the program


And the reverse: I change values using breakpoints. So the code runs (because the breakpoint condition is false) but the value is different. Example of breakpoint condition:

(licenseActive = true) != true


yah that may be worth turning on that feature or altering the debug trace during a debug session to see what line comes up, not a bad suggestion. We turn off line traces in general so that the debug logs can be diffed after stripping off variant fields in the log records like object addresses and timestamps. While a project is in development the log line numbers would add a lot of diff noise.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: