Monday, November 12, 2007

Hardware watchpoint in GDB

For some reason, the synatax for setting a hardware watchpoint in GDB is impossible to find in google. Or rather, there are misleading instructions on how to set the watchpoint. The instructions you'll find say "watch for when variable x gets changed by writing 'watch x'". But this never solves a memory corruption bug. At least for me.

This post is for my own purposes. I never want to waste 10 minutes searching for the proper syntax again.

Let's say I know that location 0xABCD1234 is getting corrupted.

Then the gdb command is:

> watch *((int*) 0xABCD1234)

2 comments:

Clietzsche said...

I set a watchpoint on your mom's hardware last night.

Clietzsche said...

... talk about a corrupted memory!