debugging - Can I set a breakpoint on 'memory access' in GDB? -
i running application through gdb , want set breakpoint time specific variable accessed / changed. there method doing this? interested in other ways monitor variable in c/c++ see if/when changes.
watch breaks on write, rwatch let break on read, , awatch let break on read/write.
you can set read watchpoints on memory locations:
gdb$ rwatch *0xfeedface hardware read watchpoint 2: *0xfeedface
but 1 limitation applies rwatch , awatch commands; can't use gdb variables in expressions:
gdb$ rwatch $ebx+0xec1a04f expression cannot implemented read/access watchpoint.
so have expand them yourself:
gdb$ print $ebx $13 = 0x135700 gdb$ rwatch *0x135700+0xec1a04f hardware read watchpoint 3: *0x135700 + 0xec1a04f gdb$ c hardware read watchpoint 3: *0x135700 + 0xec1a04f value = 0xec34daf 0x9527d6e7 in objc_msgsend ()
edit: oh, , way. need either hardware or software support. software slower. find out if os supports hardware watchpoints can see can-use-hw-watchpoints environment setting.
gdb$ show can-use-hw-watchpoints debugger's willingness use watchpoint hardware 1.
Comments
Post a Comment