Writing a debugger from scratch: Breakpoints
1–10 of 56 posts
Re: Writing a debugger from scratch: Breakpoints
#2Re: Writing a debugger from scratch: Breakpoints
#3Re: Writing a debugger from scratch: Breakpoints
#4Great article, thanks - one question I couldn't see answered there is, what do you do when you want to set more than four breakpoints at once?
Re: Writing a debugger from scratch: Breakpoints
#5Really nice read. Does anyone know any other good articles or videos about how to write a debugger?
--
1: https://github.com/munificent/craftinginterpreters/issues/92...
Re: Writing a debugger from scratch: Breakpoints
#6Great article, thanks - one question I couldn't see answered there is, what do you do when you want to set more than four breakpoints at once?
Basically you overwrite the instruction you want to break at with a breakpoint instruction (e.g. int 3 on x86). This will cause the process to trap and the OS will then let the debugger process know about out somehow, e.g. via the SIGTRAP signal on Unix.
The debugger then replaces the int 3 opcode (which is a single byte conveniently) with the first byte of the original instruction so that the execution can continue.
Re: Writing a debugger from scratch: Breakpoints
#7Really nice read. Does anyone know any other good articles or videos about how to write a debugger?
I learned a lot.
Re: Writing a debugger from scratch: Breakpoints
#8Really nice read. Does anyone know any other good articles or videos about how to write a debugger?
I like "Advanced Windows Debugging" by Mario Hewardt and Daniel Pravat.
Re: Writing a debugger from scratch: Breakpoints
#9Great article, thanks - one question I couldn't see answered there is, what do you do when you want to set more than four breakpoints at once?
You use software breakpoints. Basically you overwrite the instruction you want to break at with a breakpoint instruction (e.g. int 3 on x86). This will cause the process to trap and the OS will then let the debugger process know about out somehow, e.g. via the SIGTRAP signal on Unix. The debugger then replaces the int 3 opcode (which is a single byte conveniently) with the first byte of the original instruction so th…
In a trivial example, the breaking instruction could be a jump to itself, which you’d expect to immediately break into the debugger again.
I thought the debugger had to emulate the instruction instead, but it’s not like I’ve ever implemented one…
Re: Writing a debugger from scratch: Breakpoints
#10Really nice read. Does anyone know any other good articles or videos about how to write a debugger?