3 ms·
So apparently a lot of people seem to equate debuggers with single-stepping through code. You can pry my debugger from my cold-dead hands, but I don't even kno
by aidenn0 8y ago
So apparently a lot of people seem to equate debuggers with single-stepping through code.
You can pry my debugger from my cold-dead hands, but I don't even know how to step through code in my favorite debugger[1].
In my opinion, the only right way to fix a bug is to build a mental model of the code, and a debugger is a massive force multiplier in doing so. For any code that wasn't written by me in the past 6 months or so, the code itself is a mystery and while reading the code is a big aid in understanding how it works, it can also mislead you. In particular there is a class of bugs that are when how the code actually works diverges from how the author thinks the code works. A good author will structure the code to guide a reader into how the code works, but when the author was mistaken, this can be very misleading (in particular I will actively avoid reading comments when I know there is a bug in the code, because comments are the one part of code that are never tested).
Another way of putting it: The source code is very good for telling you how the program is intended to operate, and a debugger is very good for telling you how the program actually operates.
1: I'm sure it's listed how somewhere here, but I've never felt the need for it: https://common-lisp.net/project/slime/doc/html/Debugger.html https://common-lisp.net/project/slime/doc/html/Debugger.html
- weavie 8y ago> but I don't even know how to step through code in my favorite debugger If your lisp supports it, pressing 's' in sldb should do it.
- sopooneo 8y agoI'm going to expose my ignorance here, but other than stepping through code, how would you use a debugger? Just to get stack traces and variables values at a specific break point?
- aidenn0 8y agoA few examples off the top of my head: 1. Instrument the code in one way or another. At the simplest level, many debuggers can log each function call. 2. Change the definition of functions while the system is running. Most highly dynamic languages will let you do this. I'm told that there are C IDEs that can do this too though (modulo inlining anyways). 3. Change the timing characteristics of the program; if a race condition is suspected, ordering can be forced through the use of thread-local breakpoints, for example. 4. Inject specific data. Have a function called under normal operating conditions and modify some or all of its parameters. Think instant unit-test, but no need to mock anything.