aboutsummaryrefslogtreecommitdiff
path: root/gdb/doc
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-06-23 14:49:55 +0100
committerAndrew Burgess <aburgess@redhat.com>2022-10-02 11:58:28 +0100
commit08f406e9a1e3b83d0778493cb219075bbae7bb59 (patch)
tree398a06f209c2011a1166fd604a016ba071da87ac /gdb/doc
parent924272f2bf5e398412473b14041f84397293c3d3 (diff)
downloadfsf-binutils-gdb-08f406e9a1e3b83d0778493cb219075bbae7bb59.zip
fsf-binutils-gdb-08f406e9a1e3b83d0778493cb219075bbae7bb59.tar.gz
fsf-binutils-gdb-08f406e9a1e3b83d0778493cb219075bbae7bb59.tar.bz2
gdb/mi: new options for -data-disassemble command
Now that the disassembler has two different strategies for laying out the opcode bytes of an instruction (see /r vs /b for the disassemble command), I wanted to add support for this to the MI disassemble command. Currently the -data-disassemble command takes a single 'mode' value, which currently has 6 different values (0 -> 5), 3 of these modes relate to opcode display. So, clearly I should just add an additional 3 modes to handle the new opcode format, right? No, I didn't think that was a great idea either. So, I wonder, could I adjust the -data-disassemble command in a backward compatible way, that would allow GDB to move away from using the mode value altogether? I think we can. In this commit, I propose adding two new options to -data-disassemble, these are: --opcodes none|bytes|display --source Additionally, I will make the mode optional, and default to mode 0 if no mode value is given. Mode 0 is the simplest, no source code, no opcodes disassembly mode. The two new options are only valid for mode 0, if they are used with any other mode then an error is thrown. The --opcodes option can add opcodes to the result, with 'bytes' being equivalent to 'disassemble /b' and 'display' being 'disassemble /r'. The --source option will enable the /s style source code display, this is equivalent to modes 4 and 5. There is no way, using the new command options to get the now deprecated /m style source code display, that is mode 1 and 3. My hope is that new users of the MI will not use the mode at all, and instead will just use the new options to achieve the output they need. Existing MI users can continue to use the mode, and will not need to be updated to use the new options.
Diffstat (limited to 'gdb/doc')
-rw-r--r--gdb/doc/gdb.texinfo95
1 files changed, 75 insertions, 20 deletions
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index afe29a9..44d87e9 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -34587,7 +34587,9 @@ For details about what an addressable memory unit is,
( -s @var{start-addr} -e @var{end-addr}
| -a @var{addr}
| -f @var{filename} -l @var{linenum} [ -n @var{lines} ] )
- -- @var{mode}
+ [ --opcodes @var{opcodes-mode} ]
+ [ --source ]
+ [ -- @var{mode} ]
@end smallexample
@noindent
@@ -34616,31 +34618,71 @@ specified. If @var{end-addr} is specified as a non-zero value, and
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{opcodes-mode}
+can only be used with @var{mode} 0, and should be one of the following:
+@table @samp
+@item none
+no opcode information will be included in the result.
+
+@item bytes
+opcodes will be included in the result, the opcodes will be formatted
+as for @kbd{disassemble /b}.
+
+@item display
+opcodes will be included in the result, the opcodes will be formatted
+as for @kbd{disassemble /r}.
+@end table
@item @var{mode}
-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
+the use of @var{mode} is deprecated in favour of using the
+@code{--opcodes} and @code{--source} options. When no @var{mode} is
+given, @var{mode} 0 will be assumed. However, the @var{mode} is still
+available for backward compatibility. The @var{mode} should be one of:
+@table @samp
+@item 0
+@emph{disassembly only}, this is the default mode if no mode is
+specified.
+
+@item 1
+@emph{mixed source and disassembly (deprecated)}, it is not possible
+to recreate this mode using @code{--opcodes} and @code{--source}
+options.
+
+@item 2
+@emph{disassembly with raw opcodes}, this mode is equivalent to using
+@var{mode} 0 and passing @code{--opcodes bytes} to the command.
+
+@item 3
+@emph{mixed source and disassembly with raw opcodes (deprecated)}, it
+is not possible to recreate this mode using @code{--opcodes} and
+@code{--source} options.
+
+@item 4
+@emph{mixed source and disassembly}, this mode is equivalent to using
+@var{mode} 0 and passing @code{--source} to the command.
+@item 5
+@emph{mixed source and disassembly with raw opcodes}, this mode is
+equivalent to using @var{mode} 0 and passing @code{--opcodes bytes}
+and @code{--source} to the command.
+@end table
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
+The @code{--source} can only be used with @var{mode} 0. Passing this
+option will include the source code in the disassembly result as if
+@var{mode} 4 or 5 had been used.
+
@subsubheading Result
The result of the @code{-data-disassemble} command will be a list named
-@samp{asm_insns}, the contents of this list depend on the @var{mode}
-used with the @code{-data-disassemble} command.
+@samp{asm_insns}, the contents of this list depend on the options used
+with the @code{-data-disassemble} command.
-For modes 0 and 2 the @samp{asm_insns} list contains tuples with the
-following fields:
+For modes 0 and 2, and when the @code{--source} option is not used, the
+@samp{asm_insns} list contains tuples with the following fields:
@table @code
@item address
@@ -34656,15 +34698,28 @@ 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 modes 2, 3 and 5. This contains the
-raw opcode bytes for the @samp{inst} field. The bytes are formatted
-as single bytes, in hex, in ascending address order, with a single
-space between each byte.
+This field is only present for modes 2, 3 and 5, or when the
+@code{--opcodes} option @samp{bytes} or @samp{display} is used. This
+contains the raw opcode bytes for the @samp{inst} field.
+
+When the @samp{--opcodes} option is not passed to
+@code{-data-disassemble}, or the @samp{bytes} value is passed to
+@samp{--opcodes}, then the bytes are formatted as a series of single
+bytes, in hex, in ascending address order, with a single space between
+each byte. This format is equivalent to the @samp{/b} option being
+used with the @kbd{disassemble} command
+(@pxref{disassemble,,@kbd{disassemble}}).
+When @samp{--opcodes} is passed the value @samp{display} then the bytes
+are formatted in the natural instruction display order. This means
+multiple bytes can be grouped together, and the bytes might be
+byte-swapped. This format is equivalent to the @samp{/r} option being
+used with the @kbd{disassemble} command.
@end table
-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:
+For modes 1, 3, 4 and 5, or when the @code{--source} option is used, the
+@samp{asm_insns} list contains tuples named @samp{src_and_asm_line},
+each of which has the following fields:
@table @code
@item line