This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH, RFC] Add support for choosing disassembler cpu in GDB for POWER.
On 10/10/16 7:08 PM, Pedro Alves wrote:
A command that works for all architectures, like your original
"set disassembler-cpu" seemingly would be (ignoring implementation
details). Maybe "set disassembler-cpu" could be an alias for
"set $current_arch disassembler-cpu". GDB would then only need to store
a disassemble option string for each possible arch, and the alias would just
need to map the current arch's cpu to the right option string variable.
It doesn't look like set_disassembler_cpu() is passed the gdbarch, so
is there some global variable that it could use to determine what the
current arch is? That said, even if I do have it, wouldn't we need
to store the set/show commands in the gdbarch so that they can be
All the information to build this should be in opcodes, I think. Even
for "help show disassembler-cpu", it should be possible for gdb to ask
opcodes to print a description of each possible option,
since "objdump --help" does it. Bonus points for hooking that to
a completer for "set disassembler-cpu <tab>". :-)
The objdump --help output comes from opcodes/ppc-dis.c's
print_ppc_disassembler_options(FILE *stream). I actually tried
to call that from show_disassembler_cpu(), but the "file" pointer
it's passed is of type "struct ui_file *file" which looks to be
a black box, so I'm not sure how I can extract a "FILE *" pointer
out of that.
I don't know how to set up a completer and I don't see one.
Do you know of an example in the code I could look at/copy?
BTW, AFAICS, objdump's -M isn't really only about "cpu".
"objdump --help" on an --enable-targets=all build of binutils
shows -M options that are not cpu options. "set disassembler-options"
would probably be a better name for this.
I'm fine going with whatever option name people prefer. If you want
"disassembler-options" instead of just "disassembler", ok, but shouldn't
ARM be renamed then as well if it uses this mechanism?