You can use the command info line
to map source lines to program
addresses (and vice versa), and the command disassemble
to display
a range of addresses as machine instructions. When run under GNU Emacs
mode, the info line
command now causes the arrow to point to the
line specified. Also, info line
prints addresses in symbolic form as
well as hex.
info line linespec
list
command (see section Printing source lines).
For example, we can use info line
to discover the location of
the object code for the first line of function
m4_changequote
:
(gdb) info line m4_changecom Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350.
We can also inquire (using *addr
as the form for
linespec) what source line covers a particular address:
(gdb) info line *0x63ff Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404.
After info line
, the default address for the x
command
is changed to the starting address of the line, so that `x/i' is
sufficient to begin examining the machine code (see section Examining memory). Also, this address is saved as the value of the
convenience variable $_
(see section Convenience variables).
disassemble
We can use disassemble
to inspect the object code
range shown in the last info line
example (the example
shows SPARC machine instructions):
(gdb) disas 0x63e4 0x6404 Dump of assembler code from 0x63e4 to 0x6404: 0x63e4 <builtin_init+5340>: ble 0x63f8 <builtin_init+5360> 0x63e8 <builtin_init+5344>: sethi %hi(0x4c00), %o0 0x63ec <builtin_init+5348>: ld [%i1+4], %o0 0x63f0 <builtin_init+5352>: b 0x63fc <builtin_init+5364> 0x63f4 <builtin_init+5356>: ld [%o0+4], %o0 0x63f8 <builtin_init+5360>: or %o0, 0x1a4, %o0 0x63fc <builtin_init+5364>: call 0x9288 <path_search> 0x6400 <builtin_init+5368>: nop End of assembler dump.
set assembly-language instruction-set
disassemble
or x/i
commands. It is useful for architectures that
have more than one native instruction set.
Currently it is only defined for the Intel x86 family. You can set instruction-set
to either i386
or i8086
. The default is i386
.
Go to the first, previous, next, last section, table of contents.