1
votes

I was just wondering how data breakpoints (aka watchpoint) are created?

I know common breakpoints are made with some special INT3 instruction on x86.

I suppose you can create software watchpoint by scanning the memory regularly.

But from the perspective of writing my own debugger with hardware breakpoints, I can't find anything in the Windows Reference regarding this (only theses two topics on WinDbg 1 2). I didn't look yet on Linux.

Any idea?

Thanks

1
Modern processors have debug hardware built-in. - Martin James

1 Answers

3
votes

On an x86 processor, you set up data breakpoints by using the debug registers on the processor. Debug registers DR0-DR3 store the addresses to watch. That's the reason that Visual Studio is limited to four data breakpoints.