Go backward to Source Path.
Go up to Source.
Source and machine code
=======================
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'
Print the starting and ending addresses of the compiled code for
source line LINESPEC. You can specify source lines in any of the
ways understood by the `list' command (*note Printing source
lines: List.).
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 Examining memory: Memory.). Also, this address is saved as the value of the convenience
variable `$_' (see Convenience variables: Convenience Vars.).
`disassemble'
This specialized command dumps a range of memory as machine
instructions. The default memory range is the function
surrounding the program counter of the selected frame. A single
argument to this command is a program counter value; GDB dumps the
function surrounding this value. Two arguments specify a range of
addresses (first inclusive, second exclusive) to dump.
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.