3 ms·
I agree with what you're saying here. However, when things start getting seriously weird, an assembly language debugger can be invaluable. For example, if your
by ekidd 16y ago
I agree with what you're saying here. However, when things start getting seriously weird, an assembly language debugger can be invaluable.
For example, if your C compiler is generating bad code, or if you've violated some low-level assumption, it's hard to figure out what's going on by inspecting the source code. Sooner or later, the high-level abstractions break, and there's nothing you can do except single-step through the code that's going wrong.
I once found a bug in MSVC++ while compiling Quake 2. The compiler was performing a tail-call optimization, but it hadn't noticed that Carmack had stored a pointer to a local variable in a global variable. The stack frame was overwritten while the variable was still live, causing weird stuff to go wrong. This is not the kind of bug that you can quickly find by staring at C code. :-)
- tonyarkles 16y agoThese are great edge cases, but certainly not the common case. I think, in general, people jump to a debugger well before they're ready to actually understand what the debugger is telling them. This turns into a random walk through the source and ends up being a pretty big waste of time, compared to actually reading and understanding what's going on. That being said, I'm planning on using gdb this afternoon to debug an x86 (16-bit) bootloader I wrote 4 years ago. It was part of a class project, and the prof ended up using it as example code. I think there are subtle bugs in it though...