This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Add a new modifier /c to "disassemble" command to make it output binary code
- From: Tom Tromey <tromey at redhat dot com>
- To: Hui Zhu <teawater at gmail dot com>
- Cc: gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Thu, 09 Jul 2009 11:42:32 -0600
- Subject: Re: Add a new modifier /c to "disassemble" command to make it output binary code
- References: <daef60380907082335j78b9ae35jaf552124a65022a3@mail.gmail.com>
- Reply-to: tromey at redhat dot com
>>>>> ">" == Hui Zhu <teawater@gmail.com> writes:
>> 2009-07-09 Hui Zhu <teawater@gmail.com>
>> * cli/cli-cmds.c (disassemble_command): Add a new modifier /c
>> to "disassemble" command to make it output binary code.
>> (init_cli_cmds): Ditto.
>> (print_disassembly): Add a new argument "code" to make sure
>> output binary code or not.
>> (disassemble_current_function): Ditto.
>> * mi/mi-cmd-disas.c (mi_cmd_disassemble): Ditto.
>> * stack.c (gdb_disassembly_stub): Ditto.
>> * disasm.h (gdb_disassembly): Ditto.
>> * disasm.c (do_mixed_source_and_assembly): Ditto.
>> (do_mixed_source_and_assembly): Ditto.
>> (do_assembly_only): Ditto.
>> (gdb_disassembly): Ditto.
>> (dump_insns): Output the binary code if "code" is true.
I think this patch looks good.
>> static void
>> print_disassembly (struct gdbarch *gdbarch, const char *name,
>> - CORE_ADDR low, CORE_ADDR high, int mixed)
>> + CORE_ADDR low, CORE_ADDR high, int mixed, int code)
I'm slightly more of a fan of the "flags" approach, so that we can
easily add more flags later if we want. But it isn't a big deal.
>> +With a /c modifier, binary code are included.\n\
I think this would be better as:
With a /c modifier, print the instruction in hex as well as
in symbolic form.
(This is what the objdump documentation says, and I think it is
clearer, by virtue of being more explicit.)
>> + ui_out_message (uiout, 0, " %02x", (unsigned)data);
I wasn't sure about ui_out_message, and reading the internals docs was
not really enlightening on the subject. I guess it is probably ok,
but if somebody else knows for sure, I'd like to be better informed.
I think this also needs a change to NEWS. We mention disassemble/m
there, we ought to mention /c as well.
Please fix the help text; and after a doc review, if nobody has
responded about the ui_out_message thing, I will approve this.
Tom