简体   繁体   中英

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.

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, eg

watch *(char**)$ebp     or
watch *(void**)$ebp
set output-radix 16

Please refer to this answer How to make gdb print out all values in hexadecimal mode? You can set all types of prints happening due to gdb (may it be because of breakpoints, watchpoints, or your custom prints) will have hex-format.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM