News for hackers. Stuff that matters.
Re:Things you can do with a debugger but not with print debu... by yakshaving_jgt on Tuesday September 09, 2025 @10:32PM (#45192438)
Is there somewhere where this approach is described in more detail?
Re:Things you can do with a debugger but not with print debu... by lock1 on Wednesday September 10, 2025 @12:04AM (#45193109)
Search for "watchpoint debugging". Usually in most garbage-collected environments, it just observes & breaks on symbols though, not raw addresses.

Vscode (or an editor with ADP support) supports unconditional breakpoints, watchpoints, and logpoints (observe & log values to the debug console).

Re:Things you can do with a debugger but not with print debu... by SAI_Peregrinus on Wednesday September 10, 2025 @11:39AM (#45199303)
What watchpoints observe depends on the device & environment. E.g. for ARM Cortex-M MCUs, the (optional but very common) Data Watchpoint and Trace Unit (DWT) provides 1 or 4 watchpoints by using hardware comparators. They operate on raw addresses, since they work at the machine code level. They issue a debug interrupt when the comparator matches the address & operation (read/write), which the debug probe (J-Link, ST-Link, or other such probe) detects & forwards to the debugger (GDB, LLDB, etc.). Hardware watchpoints are extremely useful for debugging memory corruption in embedded systems, since they bypass the code running on the device under test entirely.
Re:Things you can do with a debugger but not with print debu... by jesse__ on Wednesday September 10, 2025 @01:39AM (#45193740)
Very roughly, hardware watchpoints are memory addresses you ask the processor to issue an "event" for when they're read from, written to, or executed. This event is processed by the kernel, and passed through to the debugger, which breaks execution of the program on the instruction that issued the read/write/exec.

A concrete use case for this is catching memory corruption. If your program corrupts a known piece of memory, just set a hardware watchpoint on that memory address and BOOM, the debugger breaks execution on exactly the line that's responsible for the corruption. It's a fucking godsend sometimes.