PINCE icon indicating copy to clipboard operation
PINCE copied to clipboard

Setting chained breakpoints sometimes breaks GDB

Open korcankaraokcu opened this issue 7 years ago • 1 comments

GDB outputs "Could not insert hardware watchpoint" while trying to set chained breakpoints although there's still enough space for more hardware breakpoints. This rarely occurs and it's caused by GDB itself, not a PINCE specific bug.

But fortunately there's a workaround, setting watchpoints manually, one by one. Here are the steps: 1-)Calculate the number of watchpoints needed: The max length for a watchpoint is 8bytes on x64 and 4bytes on x86. Divide the length needed to max length for a breakpoint and the result is the number of breakpoints needed(result+1 if there's a reminder) 2-)Calculate the addresses you should set watchpoint on

For instance, lets say you have a 20byte string at address 0x00400000 on x64, so you must divide 20 to 8, which yields 2. There's a reminder of 4, so the number of breakpoints needed are 3. This means that you must put 3 breakpoints on the addresses 0x00400000(8byte),0x00400008(8byte),0x00400010(4byte)

korcankaraokcu avatar Nov 30 '16 22:11 korcankaraokcu

Probably the most interesting thing about this bug is that GDB doesn't mention about any error while setting breakpoints, but after you make the process continue, you get the "Could not insert hardware watchpoint" error. So, you can't really predict it coming, sadly.

korcankaraokcu avatar Dec 01 '16 14:12 korcankaraokcu

Linked to #191

korcankaraokcu avatar Jun 03 '23 20:06 korcankaraokcu