diff options
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 121 |
2 files changed, 118 insertions, 9 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 5b3d9a1..806dac4 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,9 @@ +2015-08-14 Doug Evans <xdje42@gmail.com> + + * gdb.texinfo (Machine Code): Update docs for mixed source/assembly + disassembly. + (GDB/MI Data Manipulation): Update docs for new disassembly modes. + 2015-08-11 Keith Seitz <keiths@redhat.com> * gdb.texinfo (Thread-Specific Breakpoints, Printing Source Lines): diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index c64c7a1..c876ed6 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -8098,11 +8098,12 @@ Variables}). @cindex listing machine instructions @item disassemble @itemx disassemble /m +@itemx disassemble /s @itemx disassemble /r This specialized command dumps a range of memory as machine instructions. It can also print mixed source+disassembly by specifying -the @code{/m} modifier and print the raw instructions in hex as well as -in symbolic form by specifying the @code{/r}. +the @code{/m} or @code{/s} modifier and print the raw instructions in hex +as well as in symbolic form by specifying the @code{/r} modifier. 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; @value{GDBN} dumps the function @@ -8146,8 +8147,9 @@ Dump of assembler code from 0x32c4 to 0x32e4: End of assembler dump. @end smallexample -Here is an example showing mixed source+assembly for Intel x86, when the -program is stopped just after function prologue: +Here is an example showing mixed source+assembly for Intel x86 +with @code{/m} or @code{/s}, when the program is stopped just after +function prologue in a non-optimized function with no inline code. @smallexample (@value{GDBP}) disas /m main @@ -8172,6 +8174,96 @@ Dump of assembler code for function main: End of assembler dump. @end smallexample +The @code{/m} option is deprecated as its output is not useful when +there is either inlined code or re-ordered code. +The @code{/s} option is the preferred choice. +Here is an example for AMD x86-64 showing the difference between +@code{/m} output and @code{/s} output. +This example has one inline function defined in a header file, +and the code is compiled with @samp{-O2} optimization. +Note how the @code{/m} output is missing the disassembly of +several instructions that are present in the @code{/s} output. + +@file{foo.h}: + +@smallexample +int +foo (int a) +@{ + if (a < 0) + return a * 2; + if (a == 0) + return 1; + return a + 10; +@} +@end smallexample + +@file{foo.c}: + +@smallexample +#include "foo.h" +volatile int x, y; +int +main () +@{ + x = foo (y); + return 0; +@} +@end smallexample + +@smallexample +(@value{GDBP}) disas /m main +Dump of assembler code for function main: +5 @{ + +6 x = foo (y); + 0x0000000000400400 <+0>: mov 0x200c2e(%rip),%eax # 0x601034 <y> + 0x0000000000400417 <+23>: mov %eax,0x200c13(%rip) # 0x601030 <x> + +7 return 0; +8 @} + 0x000000000040041d <+29>: xor %eax,%eax + 0x000000000040041f <+31>: retq + 0x0000000000400420 <+32>: add %eax,%eax + 0x0000000000400422 <+34>: jmp 0x400417 <main+23> + +End of assembler dump. +(@value{GDBP}) disas /s main +Dump of assembler code for function main: +foo.c: +5 @{ +6 x = foo (y); + 0x0000000000400400 <+0>: mov 0x200c2e(%rip),%eax # 0x601034 <y> + +foo.h: +4 if (a < 0) + 0x0000000000400406 <+6>: test %eax,%eax + 0x0000000000400408 <+8>: js 0x400420 <main+32> + +6 if (a == 0) +7 return 1; +8 return a + 10; + 0x000000000040040a <+10>: lea 0xa(%rax),%edx + 0x000000000040040d <+13>: test %eax,%eax + 0x000000000040040f <+15>: mov $0x1,%eax + 0x0000000000400414 <+20>: cmovne %edx,%eax + +foo.c: +6 x = foo (y); + 0x0000000000400417 <+23>: mov %eax,0x200c13(%rip) # 0x601030 <x> + +7 return 0; +8 @} + 0x000000000040041d <+29>: xor %eax,%eax + 0x000000000040041f <+31>: retq + +foo.h: +5 return a * 2; + 0x0000000000400420 <+32>: add %eax,%eax + 0x0000000000400422 <+34>: jmp 0x400417 <main+23> +End of assembler dump. +@end smallexample + Here is another example showing raw instructions in hex for AMD x86-64, @smallexample @@ -29782,9 +29874,20 @@ displayed; if @var{lines} is higher than the number of lines between @var{start-addr} and @var{end-addr}, only the lines up to @var{end-addr} are displayed. @item @var{mode} -is either 0 (meaning only disassembly), 1 (meaning mixed source and -disassembly), 2 (meaning disassembly with raw opcodes), or 3 (meaning -mixed source and disassembly with raw opcodes). +is one of: +@itemize @bullet +@item 0 disassembly only +@item 1 mixed source and disassembly (deprecated) +@item 2 disassembly with raw opcodes +@item 3 mixed source and disassembly with raw opcodes (deprecated) +@item 4 mixed source and disassembly +@item 5 mixed source and disassembly with raw opcodes +@end itemize + +Modes 1 and 3 are deprecated. The output is ``source centric'' +which hasn't proved useful in practice. +@xref{Machine Code}, for a discussion of the difference between +@code{/m} and @code{/s} output of the @code{disassemble} command. @end table @subsubheading Result @@ -29810,12 +29913,12 @@ The decimal offset in bytes from the start of @samp{func-name}. The text disassembly for this @samp{address}. @item opcodes -This field is only present for mode 2. This contains the raw opcode +This field is only present for modes 2, 3 and 5. This contains the raw opcode bytes for the @samp{inst} field. @end table -For modes 1 and 3 the @samp{asm_insns} list contains tuples named +For modes 1, 3, 4 and 5 the @samp{asm_insns} list contains tuples named @samp{src_and_asm_line}, each of which has the following fields: @table @code |