This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Debug code in data section in gdb
Tao Zhang <zhangtao@cc.gatech.edu> writes:
> Yeah, I understand GDB will modify the code at the address of a
> breakpoint. I can break the program just before the execution jump to the
> code copied from somewhere. Then I set a breakpoint at the beginning of
> the copied code. It still won't work. Another thing is I see the code is
> same as the original code. My question is whether I can see the GDB modified
> instruction by disassemble the memory ? When and How gdb modifies the
> instruction?
GDB inserts breakpoints just before resuming the inferior (debuggee)
and removes them all each time the inferior stops. When you
disassemble, the inferior is stopped, so you won't see GDB's
breakpoint.
You said your inferior was running "without an OS", so I assume you're
communicating with it via the GDB remote protocol. Have you tried
"set debug remote 1" to see exactly what GDB and your inferior are
saying to each other? In particular, you should be able to see GDB
writing the breakpoint instruction, after reading the original
contents, and then restoring the original contents when the inferior
stops.