News for hackers. Stuff that matters.
Re:Local Variables as Accidental Breadcrumbs for Faster Debu... by josephg on Thursday October 10, 2024 @10:16PM (#41805436)
Nice! I’ll add that to my bag of debugging tricks. Because, It’s 2024 and conditional breakpoints still don’t fire consistently in my language / ide of choice. But this always works great:

    if i == 6 {
        println!(“xxx”); // breakpoint set here in my ide
    }
The breakpoint always fires, and unlike an assert I can run the program forward from there to see why i == 6 (or whatever) is problematic.

In JavaScript / typescript you can also just write “debugger;” in the code and it’ll break on that line when a debugger is attached. I wish more languages supported that.

Re:Local Variables as Accidental Breadcrumbs for Faster Debu... by zahlman on Friday October 11, 2024 @04:36AM (#41807528)
Python supports something analogous since 3.7 (https://docs.python.org/3/library/functions.html#breakpoint). (Before that, you could put a breakpoint in the code using the standard library `pdb.set_trace()`, but you couldn't "detach" the debugger with an environment variable - only by monkey-patching the `set_trace` name.)