How Debuggers Work: Algorithms, Data Structures and Architecture by Jonathan B. Rosenberg
I’ve recently become interested in using the debugging API of the CLR, so I thought this book might be a useful read. The first thing to note is that this book is fairly old. Published in 1996 it covers 32 bit Windows and Java as if they are new technologies, and hence misses the improvements to their debugging interfaces from the last ten years.
That said, the book is a great introduction to how debuggers do their stuff, and covers beautifully the hardware support that some processors offer to the debugger, and why you might not want to use this hardware support. The book is written from the point of view of someone who has written a debugger, and covers the difficulties that the author of a debugger will face when dealing with optimising compilers and chips that have optimisation features such as delay slots in their branches.
A large swathe of material is covered, including how the debugger can deal with multithreaded applications (which were the future when the book was written). I thought that the chapter on compiler optimisations and how the debugger can try to map optimised code back to the initial source was really good – in particular, a given source line can map to multiple disparate sections of the final machine code, and the debugger has to deal with this.
The only thing I didn’t find useful in the book was the algorithms that the author gives all over the place. The text gives enough detail to put the algorithms together oneself, and I found that they just disturbed the flow.
For a good overview of the low level implementation of debuggers I recommend this book, which can be obtained fairly cheaply second hand.