Search code examples
cdebugginggdbbreakpointswatchpoint

GNU GDB: customize watchpoint output format


Every time a watchpoint is modified GDB will print the old value and the new value. However, sometimes I don't want to print the value in the default decimal integer format: for instance, if I'm watching *(unsigned*)$ebp to debug a possible stack overflow (wow, SO...), the value is nonsense unless displayed in hexadecimal format (like p/x when printing something).

Is it possible to set the display format for a particular watchpoint? Thanks.


Solution

  • Is it possible to set the display format for a particular watchpoint?

    If you want the watchpoint to print in hex, set it as watch of a pointer, e.g.

    watch *(char**)$ebp     or
    watch *(void**)$ebp