This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: breakpoint instruction isn't shown in disassemble or examine (x) commands?


gdb will always hide the breakpoint trap from you, and show you the instruction that is actually going to be run when you get to that pc instead. This is on purpose, it would be very confusing, and not at all helpful, for folks to see trap instructions showing up in their disassembly.

Is there some reason, other than curiosity, the leads you to want to see the trap there?

If you are just curious, try running gdb with:

(gdb) set debug target 1

You can see gdb copy out the actual instruction and lay down the traps, and lots of other things you may or may not want to know about...

Jim

On Sep 29, 2004, at 11:36 PM, gdb-digest-help@sources.redhat.com wrote:



Hi,

I am trying to understand the inner workings of a debugger and I found
a gdb behaviour that puzzles me.

I understand that if I set a software breakpoint (as opposed to
an hw breakpoint), gdb will insert an architecture-dependent instruction
in the .text section that will cause an exception, that will be handled
by gdb.


I am using gdb 6.1.1 on FreeBSD i386, so looking at the gdb source,
the i386 has the breakpoint instruction 0xcc.

I tought of doing something like (in various incantations):

(gdb) disassemble foo
(gdb) break foo
(gdb) disassemble foo

and was expecting of seeing the 0xcc instruction in the output of
the second disassemble command; instead the output is the same
as the first disassemble. Same results with the x command.
It seems that gdb wants to "protect" me from seing that the executable
is changed?

Finally I came up with a function that scans the .text section of
the same program (a sort of very naive debugger detector)
and hex dumps it. I ran the same program with and without
breakpoint and my scan function works as expected: when the breakpoint is
set I see it in the hex dump.


So somehow I have my sanity back, but the question remains: how
can I see the breakpoint instruction from gdb itself?

thanks
marco
--
panic("The moon has moved again.");



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]