Debugger creation tutorial

debugging

Solution

Writing a debugger is no trivial task and it requires intimate knowledge both in the underlying platform you're working with and the language you're writing a debugger for.

Some articles I've came across in the past I found particular helpful on the subject:

- Eli Bendersky's "How debuggers work". I found this to be pretty helpful thanks to its thoroughness. He covers all the important parts of what a debugger does, how it works and how it accomplishes this under the hood. He even covers quite a bit on using dwarf debug format to help annotate a debug session, a subject matter that's hard to come by given its lack of accessible documentation. Even though he covers this in a *nix-like platform, many of the concepts he describes are still just as applicable under Windows.

- DebugInfo.com DEBUGGING API EXAMPLES. If you're intending to work on win32 platform then you'll find the examples here useful. This one shows actual examples of how you can use the win32 debugging api to create a process that can "act" like a debugger. It contains examples on how to launch the debuggee or attach to a running process and handling debug events generated from the debug api.

- MobDebug. This is a remote lua debugger implemented in pure lua in ~1.4kloc. This complement's deivid's answer on the ruby debugger. Many times it's helpful to see an actual implementation of a debugger even if it isn't for a low level language. This may be an easier place to start to get an overall view of what the debugger has to do without getting bogged down with all the lower level details you'll have to deal with in a "bare-metal" language.

- pydbg. A windows debugger written in python using the debugging API below.

- jewdbg. Another windows debugger written in python. A bit smaller than pydbg and not as feature rounded but great if you're looking for an example implementation to learn from.

- MSDN Debugging API. Primary reference & documentation for the basic debugging primitives and building blocks provided by windows. If developing your own debugger for windows you'll need many of the things provided here.

Problem

Where can I find good tutorial for design and developing of a debugger? I searched trough, but I found only a few general articles about this topic. I need to know more in details: how its attached to an application, how and where in memory it sets a breakpoint, how it reads a stack trace? Also, I'm interested in general design of a debugger.

Original source