]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/mi: new options for -data-disassemble command
authorAndrew Burgess <aburgess@redhat.com>
Thu, 23 Jun 2022 13:49:55 +0000 (14:49 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Sun, 2 Oct 2022 10:58:28 +0000 (11:58 +0100)
commit08f406e9a1e3b83d0778493cb219075bbae7bb59
tree398a06f209c2011a1166fd604a016ba071da87ac
parent924272f2bf5e398412473b14041f84397293c3d3
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.
gdb/doc/gdb.texinfo
gdb/mi/mi-cmd-disas.c
gdb/testsuite/gdb.mi/mi-disassemble.exp