* Add a new modifier /c to "disassemble" command to make it output binary code
@ 2009-07-09 12:22 Hui Zhu
2009-07-09 19:22 ` Tom Tromey
` (3 more replies)
0 siblings, 4 replies; 16+ messages in thread
From: Hui Zhu @ 2009-07-09 12:22 UTC (permalink / raw)
To: gdb-patches ml
[-- Attachment #1: Type: text/plain, Size: 10117 bytes --]
Hi,
The objdump will output the binary code when it works but gdb not.
I make a patch to add a new modifier /c to "disassemble" command to
make it output binary code.
Please help me review it.
Thanks,
Hui
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.
---
cli/cli-cmds.c | 27 +++++++++++++++++----------
disasm.c | 35 ++++++++++++++++++++++++++---------
disasm.h | 3 ++-
mi/mi-cmd-disas.c | 2 +-
stack.c | 2 +-
5 files changed, 47 insertions(+), 22 deletions(-)
--- a/cli/cli-cmds.c
+++ b/cli/cli-cmds.c
@@ -908,7 +908,7 @@ list_command (char *arg, int from_tty)
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)
{
#if defined(TUI)
if (!tui_is_window_visible (DISASSEM_WIN))
@@ -922,7 +922,7 @@ print_disassembly (struct gdbarch *gdbar
paddress (gdbarch, low), paddress (gdbarch, high));
/* Dump the specified range. */
- gdb_disassembly (gdbarch, uiout, 0, mixed, -1, low, high);
+ gdb_disassembly (gdbarch, uiout, 0, mixed, -1, code, low, high);
printf_filtered ("End of assembler dump.\n");
gdb_flush (gdb_stdout);
@@ -940,7 +940,7 @@ print_disassembly (struct gdbarch *gdbar
MIXED is non-zero to print source with the assembler. */
static void
-disassemble_current_function (int mixed)
+disassemble_current_function (int mixed, int code)
{
struct frame_info *frame;
struct gdbarch *gdbarch;
@@ -961,20 +961,21 @@ disassemble_current_function (int mixed)
#endif
low += gdbarch_deprecated_function_start_offset (gdbarch);
- print_disassembly (gdbarch, name, low, high, mixed);
+ print_disassembly (gdbarch, name, low, high, mixed, code);
}
/* Dump a specified section of assembly code.
Usage:
- disassemble [/m]
+ disassemble [/mc]
- dump the assembly code for the function of the current pc
- disassemble [/m] addr
+ disassemble [/mc] addr
- dump the assembly code for the function at ADDR
- disassemble [/m] low high
+ disassemble [/mc] low high
- dump the assembly code in the range [LOW,HIGH)
- A /m modifier will include source code with the assembly. */
+ A /m modifier will include source code with the assembly.
+ A /c modifier will include binary code with the assembly. */
static void
disassemble_command (char *arg, int from_tty)
@@ -985,9 +986,11 @@ disassemble_command (char *arg, int from
CORE_ADDR pc, pc_masked;
char *space_index;
int mixed_source_and_assembly;
+ int code;
name = NULL;
mixed_source_and_assembly = 0;
+ code = 0;
if (arg && *arg == '/')
{
@@ -1003,6 +1006,9 @@ disassemble_command (char *arg, int from
case 'm':
mixed_source_and_assembly = 1;
break;
+ case 'c':
+ code = 1;
+ break;
default:
error (_("Invalid disassembly modifier."));
}
@@ -1014,7 +1020,7 @@ disassemble_command (char *arg, int from
if (! arg || ! *arg)
{
- disassemble_current_function (mixed_source_and_assembly);
+ disassemble_current_function (mixed_source_and_assembly, code);
return;
}
@@ -1044,7 +1050,7 @@ disassemble_command (char *arg, int from
high = parse_and_eval_address (space_index + 1);
}
- print_disassembly (gdbarch, name, low, high, mixed_source_and_assembly);
+ print_disassembly (gdbarch, name, low, high,
mixed_source_and_assembly, code);
}
static void
@@ -1453,6 +1459,7 @@ With two args if one is empty it stands
Disassemble a specified section of memory.\n\
Default is the function surrounding the pc of the selected frame.\n\
With a /m modifier, source lines are included (if available).\n\
+With a /c modifier, binary code are included.\n\
With a single argument, the function surrounding that address is dumped.\n\
Two arguments are taken as a range of memory to dump."));
set_cmd_completer (c, location_completer);
--- a/disasm.c
+++ b/disasm.c
@@ -88,7 +88,7 @@ static int
dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout,
struct disassemble_info * di,
CORE_ADDR low, CORE_ADDR high,
- int how_many, struct ui_stream *stb)
+ int how_many, int code, struct ui_stream *stb)
{
int num_displayed = 0;
CORE_ADDR pc;
@@ -135,7 +135,23 @@ dump_insns (struct gdbarch *gdbarch, str
xfree (name);
ui_file_rewind (stb->stream);
- pc += gdbarch_print_insn (gdbarch, pc, di);
+ if (code)
+ {
+ CORE_ADDR old_pc = pc;
+ bfd_byte data;
+ int status;
+ pc += gdbarch_print_insn (gdbarch, pc, di);
+ for (;old_pc < pc; old_pc++)
+ {
+ status = (*di->read_memory_func) (old_pc, &data, 1, di);
+ if (status != 0)
+ (*di->memory_error_func) (status, old_pc, di);
+ ui_out_message (uiout, 0, " %02x", (unsigned)data);
+ }
+ ui_out_text (uiout, "\t");
+ }
+ else
+ pc += gdbarch_print_insn (gdbarch, pc, di);
ui_out_field_stream (uiout, "inst", stb);
ui_file_rewind (stb->stream);
do_cleanups (ui_out_chain);
@@ -154,7 +170,7 @@ do_mixed_source_and_assembly (struct gdb
struct linetable_entry *le,
CORE_ADDR low, CORE_ADDR high,
struct symtab *symtab,
- int how_many, struct ui_stream *stb)
+ int how_many, int code, struct ui_stream *stb)
{
int newlines = 0;
struct dis_line_entry *mle;
@@ -278,7 +294,7 @@ do_mixed_source_and_assembly (struct gdb
num_displayed += dump_insns (gdbarch, uiout, di,
mle[i].start_pc, mle[i].end_pc,
- how_many, stb);
+ how_many, code, stb);
/* When we've reached the end of the mle array, or we've seen the last
assembly range for this source line, close out the list/tuple. */
@@ -301,14 +317,15 @@ static void
do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout,
struct disassemble_info * di,
CORE_ADDR low, CORE_ADDR high,
- int how_many, struct ui_stream *stb)
+ int how_many, int code, struct ui_stream *stb)
{
int num_displayed = 0;
struct cleanup *ui_out_chain;
ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns");
- num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, stb);
+ num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many,
+ code, stb);
do_cleanups (ui_out_chain);
}
@@ -357,7 +374,7 @@ void
gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
char *file_string,
int mixed_source_and_assembly,
- int how_many, CORE_ADDR low, CORE_ADDR high)
+ int how_many, int code, CORE_ADDR low, CORE_ADDR high)
{
struct ui_stream *stb = ui_out_stream_new (uiout);
struct cleanup *cleanups = make_cleanup_ui_out_stream_delete (stb);
@@ -379,11 +396,11 @@ gdb_disassembly (struct gdbarch *gdbarch
if (!mixed_source_and_assembly || nlines <= 0
|| symtab == NULL || symtab->linetable == NULL)
- do_assembly_only (gdbarch, uiout, &di, low, high, how_many, stb);
+ do_assembly_only (gdbarch, uiout, &di, low, high, how_many, code, stb);
else if (mixed_source_and_assembly)
do_mixed_source_and_assembly (gdbarch, uiout, &di, nlines, le, low,
- high, symtab, how_many, stb);
+ high, symtab, how_many, code, stb);
do_cleanups (cleanups);
gdb_flush (gdb_stdout);
--- a/disasm.h
+++ b/disasm.h
@@ -25,7 +25,8 @@ struct ui_file;
extern void gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
char *file_string,
int mixed_source_and_assembly,
- int how_many, CORE_ADDR low, CORE_ADDR high);
+ int how_many, int code, CORE_ADDR low,
+ CORE_ADDR high);
/* Print the instruction at address MEMADDR in debugged memory,
on STREAM. Returns the length of the instruction, in bytes,
--- a/mi/mi-cmd-disas.c
+++ b/mi/mi-cmd-disas.c
@@ -156,6 +156,6 @@ mi_cmd_disassemble (char *command, char
gdb_disassembly (gdbarch, uiout,
file_string,
- mixed_source_and_assembly, how_many, low, high);
+ mixed_source_and_assembly, 0, how_many, low, high);
}
--- a/stack.c
+++ b/stack.c
@@ -481,7 +481,7 @@ static void
gdb_disassembly_stub (void *args)
{
struct gdb_disassembly_stub_args *p = args;
- gdb_disassembly (p->gdbarch, uiout, 0, 0, p->how_many, p->low, p->high);
+ gdb_disassembly (p->gdbarch, uiout, 0, 0, 1, p->how_many, p->low, p->high);
}
/* Use TRY_CATCH to catch the exception from the gdb_disassembly
2009-07-09 Hui Zhu <teawater@gmail.com>
* gdb.texinfo (disassemble): Add a new modifier /c
to "disassemble" command to make it output binary code.
---
doc/gdb.texinfo | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/doc/gdb.texinfo
+++ b/doc/gdb.texinfo
@@ -6177,10 +6177,11 @@ Variables}).
@cindex machine instructions
@cindex listing machine instructions
@item disassemble
-@itemx disassemble /m
+@itemx disassemble /mc
This specialized command dumps a range of memory as machine
instructions. It can also print mixed source+disassembly by specifying
-the @code{/m} modifier.
+the @code{/m} modifier and print binary code by specifying
+the @code{/c}.
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
[-- Attachment #2: disassemble-output-code.txt --]
[-- Type: text/plain, Size: 8405 bytes --]
---
cli/cli-cmds.c | 27 +++++++++++++++++----------
disasm.c | 35 ++++++++++++++++++++++++++---------
disasm.h | 3 ++-
mi/mi-cmd-disas.c | 2 +-
stack.c | 2 +-
5 files changed, 47 insertions(+), 22 deletions(-)
--- a/cli/cli-cmds.c
+++ b/cli/cli-cmds.c
@@ -908,7 +908,7 @@ list_command (char *arg, int from_tty)
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)
{
#if defined(TUI)
if (!tui_is_window_visible (DISASSEM_WIN))
@@ -922,7 +922,7 @@ print_disassembly (struct gdbarch *gdbar
paddress (gdbarch, low), paddress (gdbarch, high));
/* Dump the specified range. */
- gdb_disassembly (gdbarch, uiout, 0, mixed, -1, low, high);
+ gdb_disassembly (gdbarch, uiout, 0, mixed, -1, code, low, high);
printf_filtered ("End of assembler dump.\n");
gdb_flush (gdb_stdout);
@@ -940,7 +940,7 @@ print_disassembly (struct gdbarch *gdbar
MIXED is non-zero to print source with the assembler. */
static void
-disassemble_current_function (int mixed)
+disassemble_current_function (int mixed, int code)
{
struct frame_info *frame;
struct gdbarch *gdbarch;
@@ -961,20 +961,21 @@ disassemble_current_function (int mixed)
#endif
low += gdbarch_deprecated_function_start_offset (gdbarch);
- print_disassembly (gdbarch, name, low, high, mixed);
+ print_disassembly (gdbarch, name, low, high, mixed, code);
}
/* Dump a specified section of assembly code.
Usage:
- disassemble [/m]
+ disassemble [/mc]
- dump the assembly code for the function of the current pc
- disassemble [/m] addr
+ disassemble [/mc] addr
- dump the assembly code for the function at ADDR
- disassemble [/m] low high
+ disassemble [/mc] low high
- dump the assembly code in the range [LOW,HIGH)
- A /m modifier will include source code with the assembly. */
+ A /m modifier will include source code with the assembly.
+ A /c modifier will include binary code with the assembly. */
static void
disassemble_command (char *arg, int from_tty)
@@ -985,9 +986,11 @@ disassemble_command (char *arg, int from
CORE_ADDR pc, pc_masked;
char *space_index;
int mixed_source_and_assembly;
+ int code;
name = NULL;
mixed_source_and_assembly = 0;
+ code = 0;
if (arg && *arg == '/')
{
@@ -1003,6 +1006,9 @@ disassemble_command (char *arg, int from
case 'm':
mixed_source_and_assembly = 1;
break;
+ case 'c':
+ code = 1;
+ break;
default:
error (_("Invalid disassembly modifier."));
}
@@ -1014,7 +1020,7 @@ disassemble_command (char *arg, int from
if (! arg || ! *arg)
{
- disassemble_current_function (mixed_source_and_assembly);
+ disassemble_current_function (mixed_source_and_assembly, code);
return;
}
@@ -1044,7 +1050,7 @@ disassemble_command (char *arg, int from
high = parse_and_eval_address (space_index + 1);
}
- print_disassembly (gdbarch, name, low, high, mixed_source_and_assembly);
+ print_disassembly (gdbarch, name, low, high, mixed_source_and_assembly, code);
}
static void
@@ -1453,6 +1459,7 @@ With two args if one is empty it stands
Disassemble a specified section of memory.\n\
Default is the function surrounding the pc of the selected frame.\n\
With a /m modifier, source lines are included (if available).\n\
+With a /c modifier, binary code are included.\n\
With a single argument, the function surrounding that address is dumped.\n\
Two arguments are taken as a range of memory to dump."));
set_cmd_completer (c, location_completer);
--- a/disasm.c
+++ b/disasm.c
@@ -88,7 +88,7 @@ static int
dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout,
struct disassemble_info * di,
CORE_ADDR low, CORE_ADDR high,
- int how_many, struct ui_stream *stb)
+ int how_many, int code, struct ui_stream *stb)
{
int num_displayed = 0;
CORE_ADDR pc;
@@ -135,7 +135,23 @@ dump_insns (struct gdbarch *gdbarch, str
xfree (name);
ui_file_rewind (stb->stream);
- pc += gdbarch_print_insn (gdbarch, pc, di);
+ if (code)
+ {
+ CORE_ADDR old_pc = pc;
+ bfd_byte data;
+ int status;
+ pc += gdbarch_print_insn (gdbarch, pc, di);
+ for (;old_pc < pc; old_pc++)
+ {
+ status = (*di->read_memory_func) (old_pc, &data, 1, di);
+ if (status != 0)
+ (*di->memory_error_func) (status, old_pc, di);
+ ui_out_message (uiout, 0, " %02x", (unsigned)data);
+ }
+ ui_out_text (uiout, "\t");
+ }
+ else
+ pc += gdbarch_print_insn (gdbarch, pc, di);
ui_out_field_stream (uiout, "inst", stb);
ui_file_rewind (stb->stream);
do_cleanups (ui_out_chain);
@@ -154,7 +170,7 @@ do_mixed_source_and_assembly (struct gdb
struct linetable_entry *le,
CORE_ADDR low, CORE_ADDR high,
struct symtab *symtab,
- int how_many, struct ui_stream *stb)
+ int how_many, int code, struct ui_stream *stb)
{
int newlines = 0;
struct dis_line_entry *mle;
@@ -278,7 +294,7 @@ do_mixed_source_and_assembly (struct gdb
num_displayed += dump_insns (gdbarch, uiout, di,
mle[i].start_pc, mle[i].end_pc,
- how_many, stb);
+ how_many, code, stb);
/* When we've reached the end of the mle array, or we've seen the last
assembly range for this source line, close out the list/tuple. */
@@ -301,14 +317,15 @@ static void
do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout,
struct disassemble_info * di,
CORE_ADDR low, CORE_ADDR high,
- int how_many, struct ui_stream *stb)
+ int how_many, int code, struct ui_stream *stb)
{
int num_displayed = 0;
struct cleanup *ui_out_chain;
ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns");
- num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, stb);
+ num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many,
+ code, stb);
do_cleanups (ui_out_chain);
}
@@ -357,7 +374,7 @@ void
gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
char *file_string,
int mixed_source_and_assembly,
- int how_many, CORE_ADDR low, CORE_ADDR high)
+ int how_many, int code, CORE_ADDR low, CORE_ADDR high)
{
struct ui_stream *stb = ui_out_stream_new (uiout);
struct cleanup *cleanups = make_cleanup_ui_out_stream_delete (stb);
@@ -379,11 +396,11 @@ gdb_disassembly (struct gdbarch *gdbarch
if (!mixed_source_and_assembly || nlines <= 0
|| symtab == NULL || symtab->linetable == NULL)
- do_assembly_only (gdbarch, uiout, &di, low, high, how_many, stb);
+ do_assembly_only (gdbarch, uiout, &di, low, high, how_many, code, stb);
else if (mixed_source_and_assembly)
do_mixed_source_and_assembly (gdbarch, uiout, &di, nlines, le, low,
- high, symtab, how_many, stb);
+ high, symtab, how_many, code, stb);
do_cleanups (cleanups);
gdb_flush (gdb_stdout);
--- a/disasm.h
+++ b/disasm.h
@@ -25,7 +25,8 @@ struct ui_file;
extern void gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
char *file_string,
int mixed_source_and_assembly,
- int how_many, CORE_ADDR low, CORE_ADDR high);
+ int how_many, int code, CORE_ADDR low,
+ CORE_ADDR high);
/* Print the instruction at address MEMADDR in debugged memory,
on STREAM. Returns the length of the instruction, in bytes,
--- a/mi/mi-cmd-disas.c
+++ b/mi/mi-cmd-disas.c
@@ -156,6 +156,6 @@ mi_cmd_disassemble (char *command, char
gdb_disassembly (gdbarch, uiout,
file_string,
- mixed_source_and_assembly, how_many, low, high);
+ mixed_source_and_assembly, 0, how_many, low, high);
}
--- a/stack.c
+++ b/stack.c
@@ -481,7 +481,7 @@ static void
gdb_disassembly_stub (void *args)
{
struct gdb_disassembly_stub_args *p = args;
- gdb_disassembly (p->gdbarch, uiout, 0, 0, p->how_many, p->low, p->high);
+ gdb_disassembly (p->gdbarch, uiout, 0, 0, 1, p->how_many, p->low, p->high);
}
/* Use TRY_CATCH to catch the exception from the gdb_disassembly
[-- Attachment #3: disassemble-output-code-doc.txt --]
[-- Type: text/plain, Size: 728 bytes --]
---
doc/gdb.texinfo | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/doc/gdb.texinfo
+++ b/doc/gdb.texinfo
@@ -6177,10 +6177,11 @@ Variables}).
@cindex machine instructions
@cindex listing machine instructions
@item disassemble
-@itemx disassemble /m
+@itemx disassemble /mc
This specialized command dumps a range of memory as machine
instructions. It can also print mixed source+disassembly by specifying
-the @code{/m} modifier.
+the @code{/m} modifier and print binary code by specifying
+the @code{/c}.
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
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: Add a new modifier /c to "disassemble" command to make it output binary code 2009-07-09 12:22 Add a new modifier /c to "disassemble" command to make it output binary code Hui Zhu @ 2009-07-09 19:22 ` Tom Tromey 2009-07-09 19:40 ` Eli Zaretskii 2009-07-11 9:28 ` Hui Zhu 2009-07-09 19:53 ` Add a new modifier /c to "disassemble" command to make it output binary code Eli Zaretskii ` (2 subsequent siblings) 3 siblings, 2 replies; 16+ messages in thread From: Tom Tromey @ 2009-07-09 19:22 UTC (permalink / raw) To: Hui Zhu; +Cc: gdb-patches ml >>>>> ">" == 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 ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Add a new modifier /c to "disassemble" command to make it output binary code 2009-07-09 19:22 ` Tom Tromey @ 2009-07-09 19:40 ` Eli Zaretskii 2009-07-11 9:28 ` Hui Zhu 1 sibling, 0 replies; 16+ messages in thread From: Eli Zaretskii @ 2009-07-09 19:40 UTC (permalink / raw) To: tromey; +Cc: teawater, gdb-patches > Cc: gdb-patches ml <gdb-patches@sourceware.org> > From: Tom Tromey <tromey@redhat.com> > Date: Thu, 09 Jul 2009 11:42:32 -0600 > > I think this also needs a change to NEWS. We mention disassemble/m > there, we ought to mention /c as well. Yes, definitely. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Add a new modifier /c to "disassemble" command to make it output binary code 2009-07-09 19:22 ` Tom Tromey 2009-07-09 19:40 ` Eli Zaretskii @ 2009-07-11 9:28 ` Hui Zhu 2009-07-11 12:42 ` Eli Zaretskii 1 sibling, 1 reply; 16+ messages in thread From: Hui Zhu @ 2009-07-11 9:28 UTC (permalink / raw) To: Tom Tromey, Eli Zaretskii, Michael Snyder, Doug Evans, Mark Kettenis Cc: gdb-patches ml [-- Attachment #1: Type: text/plain, Size: 12655 bytes --] Thanks everybody, 1. I added a argument "flags". It include "DISASSEMBLY_SOURCE" and "DISASSEMBLY_RAW_INSN". 2. I change the introduce to "With a /r modifier, print the instruction in hex as well as in symbolic form." It get from objdump's man. Wish you like it. :) 3. /c changed /r. 4. I have make a patch for testsuite. Please help me review them. Thanks, Hui 2009-07-11 Hui Zhu <teawater@gmail.com> * cli/cli-cmds.c (disassemble_command): Add a new modifier /r to "disassemble" command to print the instruction in hex as well as in symbolic form. (init_cli_cmds): Ditto. (print_disassembly): Change "mixed" to "flags" to translate the behavior of disassemble. (disassemble_current_function): Ditto. * mi/mi-cmd-disas.c (mi_cmd_disassemble): Ditto. * stack.c (gdb_disassembly_stub): Ditto. * disasm.c (do_mixed_source_and_assembly): Ditto. (do_mixed_source_and_assembly): Ditto. (do_assembly_only): Ditto. (gdb_disassembly): Ditto. (dump_insns): print the instruction in hex as well as in symbolic form if DISASSEMBLY_RAW_INSN and flags is true. * disasm.h (DISASSEMBLY_SOURCE): Include source code with the assembly if it and flags is true. (DISASSEMBLY_RAW_INSN): Include instruction in hex with the assembly if it and flags is true. (gdb_disassembly): Update extern. --- cli/cli-cmds.c | 31 ++++++++++++++++++------------- disasm.c | 39 ++++++++++++++++++++++++++++----------- disasm.h | 3 +++ mi/mi-cmd-disas.c | 2 +- stack.c | 4 +++- 5 files changed, 53 insertions(+), 26 deletions(-) --- a/cli/cli-cmds.c +++ b/cli/cli-cmds.c @@ -908,7 +908,7 @@ list_command (char *arg, int from_tty) 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 flags) { #if defined(TUI) if (!tui_is_window_visible (DISASSEM_WIN)) @@ -922,7 +922,7 @@ print_disassembly (struct gdbarch *gdbar paddress (gdbarch, low), paddress (gdbarch, high)); /* Dump the specified range. */ - gdb_disassembly (gdbarch, uiout, 0, mixed, -1, low, high); + gdb_disassembly (gdbarch, uiout, 0, flags, -1, low, high); printf_filtered ("End of assembler dump.\n"); gdb_flush (gdb_stdout); @@ -940,7 +940,7 @@ print_disassembly (struct gdbarch *gdbar MIXED is non-zero to print source with the assembler. */ static void -disassemble_current_function (int mixed) +disassemble_current_function (int flags) { struct frame_info *frame; struct gdbarch *gdbarch; @@ -961,20 +961,21 @@ disassemble_current_function (int mixed) #endif low += gdbarch_deprecated_function_start_offset (gdbarch); - print_disassembly (gdbarch, name, low, high, mixed); + print_disassembly (gdbarch, name, low, high, flags); } /* Dump a specified section of assembly code. Usage: - disassemble [/m] + disassemble [/mr] - dump the assembly code for the function of the current pc - disassemble [/m] addr + disassemble [/mr] addr - dump the assembly code for the function at ADDR - disassemble [/m] low high + disassemble [/mr] low high - dump the assembly code in the range [LOW,HIGH) - A /m modifier will include source code with the assembly. */ + A /m modifier will include source code with the assembly. + A /r modifier will include instruction in hex with the assembly. */ static void disassemble_command (char *arg, int from_tty) @@ -984,10 +985,10 @@ disassemble_command (char *arg, int from char *name; CORE_ADDR pc, pc_masked; char *space_index; - int mixed_source_and_assembly; + int flags; name = NULL; - mixed_source_and_assembly = 0; + flags = 0; if (arg && *arg == '/') { @@ -1001,7 +1002,10 @@ disassemble_command (char *arg, int from switch (*arg++) { case 'm': - mixed_source_and_assembly = 1; + flags |= DISASSEMBLY_SOURCE; + break; + case 'r': + flags |= DISASSEMBLY_RAW_INSN; break; default: error (_("Invalid disassembly modifier.")); @@ -1014,7 +1018,7 @@ disassemble_command (char *arg, int from if (! arg || ! *arg) { - disassemble_current_function (mixed_source_and_assembly); + disassemble_current_function (flags); return; } @@ -1044,7 +1048,7 @@ disassemble_command (char *arg, int from high = parse_and_eval_address (space_index + 1); } - print_disassembly (gdbarch, name, low, high, mixed_source_and_assembly); + print_disassembly (gdbarch, name, low, high, flags); } static void @@ -1454,6 +1458,7 @@ With two args if one is empty it stands Disassemble a specified section of memory.\n\ Default is the function surrounding the pc of the selected frame.\n\ With a /m modifier, source lines are included (if available).\n\ +With a /r modifier, instruction in hex are included.\n\ With a single argument, the function surrounding that address is dumped.\n\ Two arguments are taken as a range of memory to dump.")); set_cmd_completer (c, location_completer); --- a/disasm.c +++ b/disasm.c @@ -88,7 +88,7 @@ static int dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout, struct disassemble_info * di, CORE_ADDR low, CORE_ADDR high, - int how_many, struct ui_stream *stb) + int how_many, int flags, struct ui_stream *stb) { int num_displayed = 0; CORE_ADDR pc; @@ -135,7 +135,23 @@ dump_insns (struct gdbarch *gdbarch, str xfree (name); ui_file_rewind (stb->stream); - pc += gdbarch_print_insn (gdbarch, pc, di); + if (flags & DISASSEMBLY_RAW_INSN) + { + CORE_ADDR old_pc = pc; + bfd_byte data; + int status; + pc += gdbarch_print_insn (gdbarch, pc, di); + for (;old_pc < pc; old_pc++) + { + status = (*di->read_memory_func) (old_pc, &data, 1, di); + if (status != 0) + (*di->memory_error_func) (status, old_pc, di); + ui_out_message (uiout, 0, " %02x", (unsigned)data); + } + ui_out_text (uiout, "\t"); + } + else + pc += gdbarch_print_insn (gdbarch, pc, di); ui_out_field_stream (uiout, "inst", stb); ui_file_rewind (stb->stream); do_cleanups (ui_out_chain); @@ -154,7 +170,7 @@ do_mixed_source_and_assembly (struct gdb struct linetable_entry *le, CORE_ADDR low, CORE_ADDR high, struct symtab *symtab, - int how_many, struct ui_stream *stb) + int how_many, int flags, struct ui_stream *stb) { int newlines = 0; struct dis_line_entry *mle; @@ -278,7 +294,7 @@ do_mixed_source_and_assembly (struct gdb num_displayed += dump_insns (gdbarch, uiout, di, mle[i].start_pc, mle[i].end_pc, - how_many, stb); + how_many, flags, stb); /* When we've reached the end of the mle array, or we've seen the last assembly range for this source line, close out the list/tuple. */ @@ -301,14 +317,15 @@ static void do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout, struct disassemble_info * di, CORE_ADDR low, CORE_ADDR high, - int how_many, struct ui_stream *stb) + int how_many, int flags, struct ui_stream *stb) { int num_displayed = 0; struct cleanup *ui_out_chain; ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns"); - num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, stb); + num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, + flags, stb); do_cleanups (ui_out_chain); } @@ -356,7 +373,7 @@ gdb_disassemble_info (struct gdbarch *gd void gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, char *file_string, - int mixed_source_and_assembly, + int flags, int how_many, CORE_ADDR low, CORE_ADDR high) { struct ui_stream *stb = ui_out_stream_new (uiout); @@ -377,13 +394,13 @@ gdb_disassembly (struct gdbarch *gdbarch nlines = symtab->linetable->nitems; } - if (!mixed_source_and_assembly || nlines <= 0 + if (!(flags & DISASSEMBLY_SOURCE) || nlines <= 0 || symtab == NULL || symtab->linetable == NULL) - do_assembly_only (gdbarch, uiout, &di, low, high, how_many, stb); + do_assembly_only (gdbarch, uiout, &di, low, high, how_many, flags, stb); - else if (mixed_source_and_assembly) + else if (flags & DISASSEMBLY_SOURCE) do_mixed_source_and_assembly (gdbarch, uiout, &di, nlines, le, low, - high, symtab, how_many, stb); + high, symtab, how_many, flags, stb); do_cleanups (cleanups); gdb_flush (gdb_stdout); --- a/disasm.h +++ b/disasm.h @@ -19,6 +19,9 @@ #ifndef DISASM_H #define DISASM_H +#define DISASSEMBLY_SOURCE (0x1 << 0) +#define DISASSEMBLY_RAW_INSN (0x1 << 1) + struct ui_out; struct ui_file; --- a/mi/mi-cmd-disas.c +++ b/mi/mi-cmd-disas.c @@ -156,6 +156,6 @@ mi_cmd_disassemble (char *command, char gdb_disassembly (gdbarch, uiout, file_string, - mixed_source_and_assembly, how_many, low, high); + DISASSEMBLY_SOURCE, how_many, low, high); } --- a/stack.c +++ b/stack.c @@ -481,7 +481,9 @@ static void gdb_disassembly_stub (void *args) { struct gdb_disassembly_stub_args *p = args; - gdb_disassembly (p->gdbarch, uiout, 0, 0, p->how_many, p->low, p->high); + gdb_disassembly (p->gdbarch, uiout, 0, + DISASSEMBLY_SOURCE | DISASSEMBLY_RAW_INSN, p->how_many, + p->low, p->high); } /* Use TRY_CATCH to catch the exception from the gdb_disassembly 2009-07-11 Hui Zhu <teawater@gmail.com> * gdb.texinfo (disassemble): Add a new modifier /r to "disassemble" command to make it print the instruction in hex as well as in symbolic form. --- doc/gdb.texinfo | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/doc/gdb.texinfo +++ b/doc/gdb.texinfo @@ -6178,9 +6178,11 @@ Variables}). @cindex listing machine instructions @item disassemble @itemx disassemble /m +@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. +the @code{/m} modifier and print the instruction in hex as well as in +symbolic form by specifying the @code{/r}. 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 2009-07-11 Hui Zhu <teawater@gmail.com> * gdb.base/help.exp (disassemble): Update expected help text. --- testsuite/gdb.base/help.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/testsuite/gdb.base/help.exp +++ b/testsuite/gdb.base/help.exp @@ -124,7 +124,7 @@ gdb_test "help disable breakpoints" "Dis # test help disable display gdb_test "help disable display" "Disable some expressions to be displayed when program stops\.\[\r\n\]+Arguments are the code numbers of the expressions to stop displaying\.\[\r\n\]+No argument means disable all automatic-display expressions\.\[\r\n\]+Do \"info display\" to see current list of code numbers\." "help disable display" # test help disassemble -gdb_test "help disassemble" "Disassemble a specified section of memory\.\[\r\n\]+Default is the function surrounding the pc of the selected frame\.\[\r\n\]+With a /m modifier, source lines are included \\(if available\\)\.\[\r\n\]+With a single argument, the function surrounding that address is dumped\.\[\r\n\]+Two arguments are taken as a range of memory to dump\." "help disassemble" +gdb_test "help disassemble" "Disassemble a specified section of memory\.\[\r\n\]+Default is the function surrounding the pc of the selected frame\.\[\r\n\]+With a /m modifier, source lines are included \\(if available\\)\.\[\r\n\]+With a /r modifier, instruction in hex are included\.\[\r\n\]+With a single argument, the function surrounding that address is dumped\.\[\r\n\]+Two arguments are taken as a range of memory to dump\." "help disassemble" # test help display gdb_test "help display" "Print value of expression EXP each time the program stops\.\[\r\n\]+/FMT may be used before EXP as in the \"print\" command\.\[\r\n\]+/FMT \"i\" or \"s\" or including a size-letter is allowed,\[\r\n\]+as in the \"x\" command, and then EXP is used to get the address to examine\[\r\n\]+and examining is done as in the \"x\" command\.\[\r\n\]+With no argument, display all currently requested auto-display expressions\.\[\r\n\]+Use \"undisplay\" to cancel display requests previously made\." "help display" # test help do [-- Attachment #2: disassemble-output-code.txt --] [-- Type: text/plain, Size: 8328 bytes --] --- cli/cli-cmds.c | 31 ++++++++++++++++++------------- disasm.c | 39 ++++++++++++++++++++++++++++----------- disasm.h | 3 +++ mi/mi-cmd-disas.c | 2 +- stack.c | 4 +++- 5 files changed, 53 insertions(+), 26 deletions(-) --- a/cli/cli-cmds.c +++ b/cli/cli-cmds.c @@ -908,7 +908,7 @@ list_command (char *arg, int from_tty) 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 flags) { #if defined(TUI) if (!tui_is_window_visible (DISASSEM_WIN)) @@ -922,7 +922,7 @@ print_disassembly (struct gdbarch *gdbar paddress (gdbarch, low), paddress (gdbarch, high)); /* Dump the specified range. */ - gdb_disassembly (gdbarch, uiout, 0, mixed, -1, low, high); + gdb_disassembly (gdbarch, uiout, 0, flags, -1, low, high); printf_filtered ("End of assembler dump.\n"); gdb_flush (gdb_stdout); @@ -940,7 +940,7 @@ print_disassembly (struct gdbarch *gdbar MIXED is non-zero to print source with the assembler. */ static void -disassemble_current_function (int mixed) +disassemble_current_function (int flags) { struct frame_info *frame; struct gdbarch *gdbarch; @@ -961,20 +961,21 @@ disassemble_current_function (int mixed) #endif low += gdbarch_deprecated_function_start_offset (gdbarch); - print_disassembly (gdbarch, name, low, high, mixed); + print_disassembly (gdbarch, name, low, high, flags); } /* Dump a specified section of assembly code. Usage: - disassemble [/m] + disassemble [/mr] - dump the assembly code for the function of the current pc - disassemble [/m] addr + disassemble [/mr] addr - dump the assembly code for the function at ADDR - disassemble [/m] low high + disassemble [/mr] low high - dump the assembly code in the range [LOW,HIGH) - A /m modifier will include source code with the assembly. */ + A /m modifier will include source code with the assembly. + A /r modifier will include instruction in hex with the assembly. */ static void disassemble_command (char *arg, int from_tty) @@ -984,10 +985,10 @@ disassemble_command (char *arg, int from char *name; CORE_ADDR pc, pc_masked; char *space_index; - int mixed_source_and_assembly; + int flags; name = NULL; - mixed_source_and_assembly = 0; + flags = 0; if (arg && *arg == '/') { @@ -1001,7 +1002,10 @@ disassemble_command (char *arg, int from switch (*arg++) { case 'm': - mixed_source_and_assembly = 1; + flags |= DISASSEMBLY_SOURCE; + break; + case 'r': + flags |= DISASSEMBLY_RAW_INSN; break; default: error (_("Invalid disassembly modifier.")); @@ -1014,7 +1018,7 @@ disassemble_command (char *arg, int from if (! arg || ! *arg) { - disassemble_current_function (mixed_source_and_assembly); + disassemble_current_function (flags); return; } @@ -1044,7 +1048,7 @@ disassemble_command (char *arg, int from high = parse_and_eval_address (space_index + 1); } - print_disassembly (gdbarch, name, low, high, mixed_source_and_assembly); + print_disassembly (gdbarch, name, low, high, flags); } static void @@ -1454,6 +1458,7 @@ With two args if one is empty it stands Disassemble a specified section of memory.\n\ Default is the function surrounding the pc of the selected frame.\n\ With a /m modifier, source lines are included (if available).\n\ +With a /r modifier, instruction in hex are included.\n\ With a single argument, the function surrounding that address is dumped.\n\ Two arguments are taken as a range of memory to dump.")); set_cmd_completer (c, location_completer); --- a/disasm.c +++ b/disasm.c @@ -88,7 +88,7 @@ static int dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout, struct disassemble_info * di, CORE_ADDR low, CORE_ADDR high, - int how_many, struct ui_stream *stb) + int how_many, int flags, struct ui_stream *stb) { int num_displayed = 0; CORE_ADDR pc; @@ -135,7 +135,23 @@ dump_insns (struct gdbarch *gdbarch, str xfree (name); ui_file_rewind (stb->stream); - pc += gdbarch_print_insn (gdbarch, pc, di); + if (flags & DISASSEMBLY_RAW_INSN) + { + CORE_ADDR old_pc = pc; + bfd_byte data; + int status; + pc += gdbarch_print_insn (gdbarch, pc, di); + for (;old_pc < pc; old_pc++) + { + status = (*di->read_memory_func) (old_pc, &data, 1, di); + if (status != 0) + (*di->memory_error_func) (status, old_pc, di); + ui_out_message (uiout, 0, " %02x", (unsigned)data); + } + ui_out_text (uiout, "\t"); + } + else + pc += gdbarch_print_insn (gdbarch, pc, di); ui_out_field_stream (uiout, "inst", stb); ui_file_rewind (stb->stream); do_cleanups (ui_out_chain); @@ -154,7 +170,7 @@ do_mixed_source_and_assembly (struct gdb struct linetable_entry *le, CORE_ADDR low, CORE_ADDR high, struct symtab *symtab, - int how_many, struct ui_stream *stb) + int how_many, int flags, struct ui_stream *stb) { int newlines = 0; struct dis_line_entry *mle; @@ -278,7 +294,7 @@ do_mixed_source_and_assembly (struct gdb num_displayed += dump_insns (gdbarch, uiout, di, mle[i].start_pc, mle[i].end_pc, - how_many, stb); + how_many, flags, stb); /* When we've reached the end of the mle array, or we've seen the last assembly range for this source line, close out the list/tuple. */ @@ -301,14 +317,15 @@ static void do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout, struct disassemble_info * di, CORE_ADDR low, CORE_ADDR high, - int how_many, struct ui_stream *stb) + int how_many, int flags, struct ui_stream *stb) { int num_displayed = 0; struct cleanup *ui_out_chain; ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns"); - num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, stb); + num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, + flags, stb); do_cleanups (ui_out_chain); } @@ -356,7 +373,7 @@ gdb_disassemble_info (struct gdbarch *gd void gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, char *file_string, - int mixed_source_and_assembly, + int flags, int how_many, CORE_ADDR low, CORE_ADDR high) { struct ui_stream *stb = ui_out_stream_new (uiout); @@ -377,13 +394,13 @@ gdb_disassembly (struct gdbarch *gdbarch nlines = symtab->linetable->nitems; } - if (!mixed_source_and_assembly || nlines <= 0 + if (!(flags & DISASSEMBLY_SOURCE) || nlines <= 0 || symtab == NULL || symtab->linetable == NULL) - do_assembly_only (gdbarch, uiout, &di, low, high, how_many, stb); + do_assembly_only (gdbarch, uiout, &di, low, high, how_many, flags, stb); - else if (mixed_source_and_assembly) + else if (flags & DISASSEMBLY_SOURCE) do_mixed_source_and_assembly (gdbarch, uiout, &di, nlines, le, low, - high, symtab, how_many, stb); + high, symtab, how_many, flags, stb); do_cleanups (cleanups); gdb_flush (gdb_stdout); --- a/disasm.h +++ b/disasm.h @@ -19,6 +19,9 @@ #ifndef DISASM_H #define DISASM_H +#define DISASSEMBLY_SOURCE (0x1 << 0) +#define DISASSEMBLY_RAW_INSN (0x1 << 1) + struct ui_out; struct ui_file; --- a/mi/mi-cmd-disas.c +++ b/mi/mi-cmd-disas.c @@ -156,6 +156,6 @@ mi_cmd_disassemble (char *command, char gdb_disassembly (gdbarch, uiout, file_string, - mixed_source_and_assembly, how_many, low, high); + DISASSEMBLY_SOURCE, how_many, low, high); } --- a/stack.c +++ b/stack.c @@ -481,7 +481,9 @@ static void gdb_disassembly_stub (void *args) { struct gdb_disassembly_stub_args *p = args; - gdb_disassembly (p->gdbarch, uiout, 0, 0, p->how_many, p->low, p->high); + gdb_disassembly (p->gdbarch, uiout, 0, + DISASSEMBLY_SOURCE | DISASSEMBLY_RAW_INSN, p->how_many, + p->low, p->high); } /* Use TRY_CATCH to catch the exception from the gdb_disassembly [-- Attachment #3: disassemble-output-code-doc.txt --] [-- Type: text/plain, Size: 733 bytes --] --- doc/gdb.texinfo | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/doc/gdb.texinfo +++ b/doc/gdb.texinfo @@ -6178,9 +6178,11 @@ Variables}). @cindex listing machine instructions @item disassemble @itemx disassemble /m +@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. +the @code{/m} modifier and print the instruction in hex as well as in +symbolic form by specifying the @code{/r}. 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 [-- Attachment #4: disassemble-output-code-test.txt --] [-- Type: text/plain, Size: 2017 bytes --] --- testsuite/gdb.base/help.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/testsuite/gdb.base/help.exp +++ b/testsuite/gdb.base/help.exp @@ -124,7 +124,7 @@ gdb_test "help disable breakpoints" "Dis # test help disable display gdb_test "help disable display" "Disable some expressions to be displayed when program stops\.\[\r\n\]+Arguments are the code numbers of the expressions to stop displaying\.\[\r\n\]+No argument means disable all automatic-display expressions\.\[\r\n\]+Do \"info display\" to see current list of code numbers\." "help disable display" # test help disassemble -gdb_test "help disassemble" "Disassemble a specified section of memory\.\[\r\n\]+Default is the function surrounding the pc of the selected frame\.\[\r\n\]+With a /m modifier, source lines are included \\(if available\\)\.\[\r\n\]+With a single argument, the function surrounding that address is dumped\.\[\r\n\]+Two arguments are taken as a range of memory to dump\." "help disassemble" +gdb_test "help disassemble" "Disassemble a specified section of memory\.\[\r\n\]+Default is the function surrounding the pc of the selected frame\.\[\r\n\]+With a /m modifier, source lines are included \\(if available\\)\.\[\r\n\]+With a /r modifier, instruction in hex are included\.\[\r\n\]+With a single argument, the function surrounding that address is dumped\.\[\r\n\]+Two arguments are taken as a range of memory to dump\." "help disassemble" # test help display gdb_test "help display" "Print value of expression EXP each time the program stops\.\[\r\n\]+/FMT may be used before EXP as in the \"print\" command\.\[\r\n\]+/FMT \"i\" or \"s\" or including a size-letter is allowed,\[\r\n\]+as in the \"x\" command, and then EXP is used to get the address to examine\[\r\n\]+and examining is done as in the \"x\" command\.\[\r\n\]+With no argument, display all currently requested auto-display expressions\.\[\r\n\]+Use \"undisplay\" to cancel display requests previously made\." "help display" # test help do ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Add a new modifier /c to "disassemble" command to make it output binary code 2009-07-11 9:28 ` Hui Zhu @ 2009-07-11 12:42 ` Eli Zaretskii 2009-07-11 14:15 ` Hui Zhu 0 siblings, 1 reply; 16+ messages in thread From: Eli Zaretskii @ 2009-07-11 12:42 UTC (permalink / raw) To: Hui Zhu; +Cc: tromey, msnyder, dje, mark.kettenis, gdb-patches > Date: Sat, 11 Jul 2009 16:46:28 +0800 > From: Hui Zhu <teawater@gmail.com> > Cc: gdb-patches ml <gdb-patches@sourceware.org> > > @@ -1454,6 +1458,7 @@ With two args if one is empty it stands > Disassemble a specified section of memory.\n\ > Default is the function surrounding the pc of the selected frame.\n\ > With a /m modifier, source lines are included (if available).\n\ > +With a /r modifier, instruction in hex are included.\n\ With a /r modifier, raw instructions in hex are included. (Use "raw" explicitly to help people remember why there's an `r' in "/r".) > +++ b/doc/gdb.texinfo > @@ -6178,9 +6178,11 @@ Variables}). > @cindex listing machine instructions > @item disassemble > @itemx disassemble /m > +@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. > +the @code{/m} modifier and print the instruction in hex as well as in > +symbolic form by specifying the @code{/r}. and print the raw instructions in hex as well as in symbolic form Again, please use the word "raw" in the text. Also, what about NEWS? didn't we agree that an entry there would be a Good Thing? ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Add a new modifier /c to "disassemble" command to make it output binary code 2009-07-11 12:42 ` Eli Zaretskii @ 2009-07-11 14:15 ` Hui Zhu 2009-07-11 17:54 ` Eli Zaretskii 0 siblings, 1 reply; 16+ messages in thread From: Hui Zhu @ 2009-07-11 14:15 UTC (permalink / raw) To: Eli Zaretskii; +Cc: tromey, msnyder, dje, mark.kettenis, gdb-patches [-- Attachment #1: Type: text/plain, Size: 14481 bytes --] On Sat, Jul 11, 2009 at 17:32, Eli Zaretskii<eliz@gnu.org> wrote: >> Date: Sat, 11 Jul 2009 16:46:28 +0800 >> From: Hui Zhu <teawater@gmail.com> >> Cc: gdb-patches ml <gdb-patches@sourceware.org> >> >> @@ -1454,6 +1458,7 @@ With two args if one is empty it stands >> Disassemble a specified section of memory.\n\ >> Default is the function surrounding the pc of the selected frame.\n\ >> With a /m modifier, source lines are included (if available).\n\ >> +With a /r modifier, instruction in hex are included.\n\ > > With a /r modifier, raw instructions in hex are included. > > (Use "raw" explicitly to help people remember why there's an `r' in > "/r".) > >> +++ b/doc/gdb.texinfo >> @@ -6178,9 +6178,11 @@ Variables}). >> @cindex listing machine instructions >> @item disassemble >> @itemx disassemble /m >> +@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. >> +the @code{/m} modifier and print the instruction in hex as well as in >> +symbolic form by specifying the @code{/r}. > > and print the raw instructions in hex as well as in symbolic form > > Again, please use the word "raw" in the text. > > Also, what about NEWS? didn't we agree that an entry there would be a > Good Thing? > I have add "raw" and "NEWS". Please help me review it. Thanks, Hui 2009-07-11 Hui Zhu <teawater@gmail.com> * cli/cli-cmds.c (disassemble_command): Add a new modifier /r to "disassemble" command to print the raw instruction in hex as well as in symbolic form. (init_cli_cmds): Ditto. (print_disassembly): Change "mixed" to "flags" to translate the behavior of disassemble. (disassemble_current_function): Ditto. * mi/mi-cmd-disas.c (mi_cmd_disassemble): Ditto. * stack.c (gdb_disassembly_stub): Ditto. * disasm.c (do_mixed_source_and_assembly): Ditto. (do_mixed_source_and_assembly): Ditto. (do_assembly_only): Ditto. (gdb_disassembly): Ditto. (dump_insns): print the raw instruction in hex as well as in symbolic form if DISASSEMBLY_RAW_INSN and flags is true. * disasm.h (DISASSEMBLY_SOURCE): Include source code with the assembly if it and flags is true. (DISASSEMBLY_RAW_INSN): Include the raw instruction in hex with the assembly if it and flags is true. (gdb_disassembly): Update extern. * NEWS: Document disassemble/r support. --- NEWS | 3 +++ cli/cli-cmds.c | 31 ++++++++++++++++++------------- disasm.c | 39 ++++++++++++++++++++++++++++----------- disasm.h | 3 +++ mi/mi-cmd-disas.c | 2 +- stack.c | 4 +++- 6 files changed, 56 insertions(+), 26 deletions(-) --- a/NEWS +++ b/NEWS @@ -3,6 +3,9 @@ *** Changes since GDB 6.8 +* "disassemble" command with a /r modifier, print the raw instruction +in hex as well as in symbolic form." + * Process record and replay In a architecture environment that supports ``process record and --- a/cli/cli-cmds.c +++ b/cli/cli-cmds.c @@ -908,7 +908,7 @@ list_command (char *arg, int from_tty) 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 flags) { #if defined(TUI) if (!tui_is_window_visible (DISASSEM_WIN)) @@ -922,7 +922,7 @@ print_disassembly (struct gdbarch *gdbar paddress (gdbarch, low), paddress (gdbarch, high)); /* Dump the specified range. */ - gdb_disassembly (gdbarch, uiout, 0, mixed, -1, low, high); + gdb_disassembly (gdbarch, uiout, 0, flags, -1, low, high); printf_filtered ("End of assembler dump.\n"); gdb_flush (gdb_stdout); @@ -940,7 +940,7 @@ print_disassembly (struct gdbarch *gdbar MIXED is non-zero to print source with the assembler. */ static void -disassemble_current_function (int mixed) +disassemble_current_function (int flags) { struct frame_info *frame; struct gdbarch *gdbarch; @@ -961,20 +961,21 @@ disassemble_current_function (int mixed) #endif low += gdbarch_deprecated_function_start_offset (gdbarch); - print_disassembly (gdbarch, name, low, high, mixed); + print_disassembly (gdbarch, name, low, high, flags); } /* Dump a specified section of assembly code. Usage: - disassemble [/m] + disassemble [/mr] - dump the assembly code for the function of the current pc - disassemble [/m] addr + disassemble [/mr] addr - dump the assembly code for the function at ADDR - disassemble [/m] low high + disassemble [/mr] low high - dump the assembly code in the range [LOW,HIGH) - A /m modifier will include source code with the assembly. */ + A /m modifier will include source code with the assembly. + A /r modifier will include raw instruction in hex with the assembly. */ static void disassemble_command (char *arg, int from_tty) @@ -984,10 +985,10 @@ disassemble_command (char *arg, int from char *name; CORE_ADDR pc, pc_masked; char *space_index; - int mixed_source_and_assembly; + int flags; name = NULL; - mixed_source_and_assembly = 0; + flags = 0; if (arg && *arg == '/') { @@ -1001,7 +1002,10 @@ disassemble_command (char *arg, int from switch (*arg++) { case 'm': - mixed_source_and_assembly = 1; + flags |= DISASSEMBLY_SOURCE; + break; + case 'r': + flags |= DISASSEMBLY_RAW_INSN; break; default: error (_("Invalid disassembly modifier.")); @@ -1014,7 +1018,7 @@ disassemble_command (char *arg, int from if (! arg || ! *arg) { - disassemble_current_function (mixed_source_and_assembly); + disassemble_current_function (flags); return; } @@ -1044,7 +1048,7 @@ disassemble_command (char *arg, int from high = parse_and_eval_address (space_index + 1); } - print_disassembly (gdbarch, name, low, high, mixed_source_and_assembly); + print_disassembly (gdbarch, name, low, high, flags); } static void @@ -1454,6 +1458,7 @@ With two args if one is empty it stands Disassemble a specified section of memory.\n\ Default is the function surrounding the pc of the selected frame.\n\ With a /m modifier, source lines are included (if available).\n\ +With a /r modifier, raw instruction in hex are included.\n\ With a single argument, the function surrounding that address is dumped.\n\ Two arguments are taken as a range of memory to dump.")); set_cmd_completer (c, location_completer); --- a/disasm.c +++ b/disasm.c @@ -88,7 +88,7 @@ static int dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout, struct disassemble_info * di, CORE_ADDR low, CORE_ADDR high, - int how_many, struct ui_stream *stb) + int how_many, int flags, struct ui_stream *stb) { int num_displayed = 0; CORE_ADDR pc; @@ -135,7 +135,23 @@ dump_insns (struct gdbarch *gdbarch, str xfree (name); ui_file_rewind (stb->stream); - pc += gdbarch_print_insn (gdbarch, pc, di); + if (flags & DISASSEMBLY_RAW_INSN) + { + CORE_ADDR old_pc = pc; + bfd_byte data; + int status; + pc += gdbarch_print_insn (gdbarch, pc, di); + for (;old_pc < pc; old_pc++) + { + status = (*di->read_memory_func) (old_pc, &data, 1, di); + if (status != 0) + (*di->memory_error_func) (status, old_pc, di); + ui_out_message (uiout, 0, " %02x", (unsigned)data); + } + ui_out_text (uiout, "\t"); + } + else + pc += gdbarch_print_insn (gdbarch, pc, di); ui_out_field_stream (uiout, "inst", stb); ui_file_rewind (stb->stream); do_cleanups (ui_out_chain); @@ -154,7 +170,7 @@ do_mixed_source_and_assembly (struct gdb struct linetable_entry *le, CORE_ADDR low, CORE_ADDR high, struct symtab *symtab, - int how_many, struct ui_stream *stb) + int how_many, int flags, struct ui_stream *stb) { int newlines = 0; struct dis_line_entry *mle; @@ -278,7 +294,7 @@ do_mixed_source_and_assembly (struct gdb num_displayed += dump_insns (gdbarch, uiout, di, mle[i].start_pc, mle[i].end_pc, - how_many, stb); + how_many, flags, stb); /* When we've reached the end of the mle array, or we've seen the last assembly range for this source line, close out the list/tuple. */ @@ -301,14 +317,15 @@ static void do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout, struct disassemble_info * di, CORE_ADDR low, CORE_ADDR high, - int how_many, struct ui_stream *stb) + int how_many, int flags, struct ui_stream *stb) { int num_displayed = 0; struct cleanup *ui_out_chain; ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns"); - num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, stb); + num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, + flags, stb); do_cleanups (ui_out_chain); } @@ -356,7 +373,7 @@ gdb_disassemble_info (struct gdbarch *gd void gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, char *file_string, - int mixed_source_and_assembly, + int flags, int how_many, CORE_ADDR low, CORE_ADDR high) { struct ui_stream *stb = ui_out_stream_new (uiout); @@ -377,13 +394,13 @@ gdb_disassembly (struct gdbarch *gdbarch nlines = symtab->linetable->nitems; } - if (!mixed_source_and_assembly || nlines <= 0 + if (!(flags & DISASSEMBLY_SOURCE) || nlines <= 0 || symtab == NULL || symtab->linetable == NULL) - do_assembly_only (gdbarch, uiout, &di, low, high, how_many, stb); + do_assembly_only (gdbarch, uiout, &di, low, high, how_many, flags, stb); - else if (mixed_source_and_assembly) + else if (flags & DISASSEMBLY_SOURCE) do_mixed_source_and_assembly (gdbarch, uiout, &di, nlines, le, low, - high, symtab, how_many, stb); + high, symtab, how_many, flags, stb); do_cleanups (cleanups); gdb_flush (gdb_stdout); --- a/disasm.h +++ b/disasm.h @@ -19,6 +19,9 @@ #ifndef DISASM_H #define DISASM_H +#define DISASSEMBLY_SOURCE (0x1 << 0) +#define DISASSEMBLY_RAW_INSN (0x1 << 1) + struct ui_out; struct ui_file; --- a/mi/mi-cmd-disas.c +++ b/mi/mi-cmd-disas.c @@ -156,6 +156,6 @@ mi_cmd_disassemble (char *command, char gdb_disassembly (gdbarch, uiout, file_string, - mixed_source_and_assembly, how_many, low, high); + DISASSEMBLY_SOURCE, how_many, low, high); } --- a/stack.c +++ b/stack.c @@ -481,7 +481,9 @@ static void gdb_disassembly_stub (void *args) { struct gdb_disassembly_stub_args *p = args; - gdb_disassembly (p->gdbarch, uiout, 0, 0, p->how_many, p->low, p->high); + gdb_disassembly (p->gdbarch, uiout, 0, + DISASSEMBLY_SOURCE | DISASSEMBLY_RAW_INSN, p->how_many, + p->low, p->high); } /* Use TRY_CATCH to catch the exception from the gdb_disassembly 2009-07-11 Hui Zhu <teawater@gmail.com> * gdb.texinfo (disassemble): Add a new modifier /r to "disassemble" command to make it print the raw instruction in hex as well as in symbolic form. --- doc/gdb.texinfo | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/doc/gdb.texinfo +++ b/doc/gdb.texinfo @@ -6178,9 +6178,11 @@ Variables}). @cindex listing machine instructions @item disassemble @itemx disassemble /m +@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. +the @code{/m} modifier and print the raw instruction in hex as well as +in symbolic form by specifying the @code{/r}. 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 2009-07-11 Hui Zhu <teawater@gmail.com> * gdb.base/help.exp (disassemble): Update expected help text. --- testsuite/gdb.base/help.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/testsuite/gdb.base/help.exp +++ b/testsuite/gdb.base/help.exp @@ -124,7 +124,7 @@ gdb_test "help disable breakpoints" "Dis # test help disable display gdb_test "help disable display" "Disable some expressions to be displayed when program stops\.\[\r\n\]+Arguments are the code numbers of the expressions to stop displaying\.\[\r\n\]+No argument means disable all automatic-display expressions\.\[\r\n\]+Do \"info display\" to see current list of code numbers\." "help disable display" # test help disassemble -gdb_test "help disassemble" "Disassemble a specified section of memory\.\[\r\n\]+Default is the function surrounding the pc of the selected frame\.\[\r\n\]+With a /m modifier, source lines are included \\(if available\\)\.\[\r\n\]+With a single argument, the function surrounding that address is dumped\.\[\r\n\]+Two arguments are taken as a range of memory to dump\." "help disassemble" +gdb_test "help disassemble" "Disassemble a specified section of memory\.\[\r\n\]+Default is the function surrounding the pc of the selected frame\.\[\r\n\]+With a /m modifier, source lines are included \\(if available\\)\.\[\r\n\]+With a /r modifier, raw instruction in hex are included\.\[\r\n\]+With a single argument, the function surrounding that address is dumped\.\[\r\n\]+Two arguments are taken as a range of memory to dump\." "help disassemble" # test help display gdb_test "help display" "Print value of expression EXP each time the program stops\.\[\r\n\]+/FMT may be used before EXP as in the \"print\" command\.\[\r\n\]+/FMT \"i\" or \"s\" or including a size-letter is allowed,\[\r\n\]+as in the \"x\" command, and then EXP is used to get the address to examine\[\r\n\]+and examining is done as in the \"x\" command\.\[\r\n\]+With no argument, display all currently requested auto-display expressions\.\[\r\n\]+Use \"undisplay\" to cancel display requests previously made\." "help display" # test help do [-- Attachment #2: disassemble-output-code.txt --] [-- Type: text/plain, Size: 8645 bytes --] --- NEWS | 3 +++ cli/cli-cmds.c | 31 ++++++++++++++++++------------- disasm.c | 39 ++++++++++++++++++++++++++++----------- disasm.h | 3 +++ mi/mi-cmd-disas.c | 2 +- stack.c | 4 +++- 6 files changed, 56 insertions(+), 26 deletions(-) --- a/NEWS +++ b/NEWS @@ -3,6 +3,9 @@ *** Changes since GDB 6.8 +* "disassemble" command with a /r modifier, print the raw instruction +in hex as well as in symbolic form." + * Process record and replay In a architecture environment that supports ``process record and --- a/cli/cli-cmds.c +++ b/cli/cli-cmds.c @@ -908,7 +908,7 @@ list_command (char *arg, int from_tty) 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 flags) { #if defined(TUI) if (!tui_is_window_visible (DISASSEM_WIN)) @@ -922,7 +922,7 @@ print_disassembly (struct gdbarch *gdbar paddress (gdbarch, low), paddress (gdbarch, high)); /* Dump the specified range. */ - gdb_disassembly (gdbarch, uiout, 0, mixed, -1, low, high); + gdb_disassembly (gdbarch, uiout, 0, flags, -1, low, high); printf_filtered ("End of assembler dump.\n"); gdb_flush (gdb_stdout); @@ -940,7 +940,7 @@ print_disassembly (struct gdbarch *gdbar MIXED is non-zero to print source with the assembler. */ static void -disassemble_current_function (int mixed) +disassemble_current_function (int flags) { struct frame_info *frame; struct gdbarch *gdbarch; @@ -961,20 +961,21 @@ disassemble_current_function (int mixed) #endif low += gdbarch_deprecated_function_start_offset (gdbarch); - print_disassembly (gdbarch, name, low, high, mixed); + print_disassembly (gdbarch, name, low, high, flags); } /* Dump a specified section of assembly code. Usage: - disassemble [/m] + disassemble [/mr] - dump the assembly code for the function of the current pc - disassemble [/m] addr + disassemble [/mr] addr - dump the assembly code for the function at ADDR - disassemble [/m] low high + disassemble [/mr] low high - dump the assembly code in the range [LOW,HIGH) - A /m modifier will include source code with the assembly. */ + A /m modifier will include source code with the assembly. + A /r modifier will include raw instruction in hex with the assembly. */ static void disassemble_command (char *arg, int from_tty) @@ -984,10 +985,10 @@ disassemble_command (char *arg, int from char *name; CORE_ADDR pc, pc_masked; char *space_index; - int mixed_source_and_assembly; + int flags; name = NULL; - mixed_source_and_assembly = 0; + flags = 0; if (arg && *arg == '/') { @@ -1001,7 +1002,10 @@ disassemble_command (char *arg, int from switch (*arg++) { case 'm': - mixed_source_and_assembly = 1; + flags |= DISASSEMBLY_SOURCE; + break; + case 'r': + flags |= DISASSEMBLY_RAW_INSN; break; default: error (_("Invalid disassembly modifier.")); @@ -1014,7 +1018,7 @@ disassemble_command (char *arg, int from if (! arg || ! *arg) { - disassemble_current_function (mixed_source_and_assembly); + disassemble_current_function (flags); return; } @@ -1044,7 +1048,7 @@ disassemble_command (char *arg, int from high = parse_and_eval_address (space_index + 1); } - print_disassembly (gdbarch, name, low, high, mixed_source_and_assembly); + print_disassembly (gdbarch, name, low, high, flags); } static void @@ -1454,6 +1458,7 @@ With two args if one is empty it stands Disassemble a specified section of memory.\n\ Default is the function surrounding the pc of the selected frame.\n\ With a /m modifier, source lines are included (if available).\n\ +With a /r modifier, raw instruction in hex are included.\n\ With a single argument, the function surrounding that address is dumped.\n\ Two arguments are taken as a range of memory to dump.")); set_cmd_completer (c, location_completer); --- a/disasm.c +++ b/disasm.c @@ -88,7 +88,7 @@ static int dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout, struct disassemble_info * di, CORE_ADDR low, CORE_ADDR high, - int how_many, struct ui_stream *stb) + int how_many, int flags, struct ui_stream *stb) { int num_displayed = 0; CORE_ADDR pc; @@ -135,7 +135,23 @@ dump_insns (struct gdbarch *gdbarch, str xfree (name); ui_file_rewind (stb->stream); - pc += gdbarch_print_insn (gdbarch, pc, di); + if (flags & DISASSEMBLY_RAW_INSN) + { + CORE_ADDR old_pc = pc; + bfd_byte data; + int status; + pc += gdbarch_print_insn (gdbarch, pc, di); + for (;old_pc < pc; old_pc++) + { + status = (*di->read_memory_func) (old_pc, &data, 1, di); + if (status != 0) + (*di->memory_error_func) (status, old_pc, di); + ui_out_message (uiout, 0, " %02x", (unsigned)data); + } + ui_out_text (uiout, "\t"); + } + else + pc += gdbarch_print_insn (gdbarch, pc, di); ui_out_field_stream (uiout, "inst", stb); ui_file_rewind (stb->stream); do_cleanups (ui_out_chain); @@ -154,7 +170,7 @@ do_mixed_source_and_assembly (struct gdb struct linetable_entry *le, CORE_ADDR low, CORE_ADDR high, struct symtab *symtab, - int how_many, struct ui_stream *stb) + int how_many, int flags, struct ui_stream *stb) { int newlines = 0; struct dis_line_entry *mle; @@ -278,7 +294,7 @@ do_mixed_source_and_assembly (struct gdb num_displayed += dump_insns (gdbarch, uiout, di, mle[i].start_pc, mle[i].end_pc, - how_many, stb); + how_many, flags, stb); /* When we've reached the end of the mle array, or we've seen the last assembly range for this source line, close out the list/tuple. */ @@ -301,14 +317,15 @@ static void do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout, struct disassemble_info * di, CORE_ADDR low, CORE_ADDR high, - int how_many, struct ui_stream *stb) + int how_many, int flags, struct ui_stream *stb) { int num_displayed = 0; struct cleanup *ui_out_chain; ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns"); - num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, stb); + num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, + flags, stb); do_cleanups (ui_out_chain); } @@ -356,7 +373,7 @@ gdb_disassemble_info (struct gdbarch *gd void gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, char *file_string, - int mixed_source_and_assembly, + int flags, int how_many, CORE_ADDR low, CORE_ADDR high) { struct ui_stream *stb = ui_out_stream_new (uiout); @@ -377,13 +394,13 @@ gdb_disassembly (struct gdbarch *gdbarch nlines = symtab->linetable->nitems; } - if (!mixed_source_and_assembly || nlines <= 0 + if (!(flags & DISASSEMBLY_SOURCE) || nlines <= 0 || symtab == NULL || symtab->linetable == NULL) - do_assembly_only (gdbarch, uiout, &di, low, high, how_many, stb); + do_assembly_only (gdbarch, uiout, &di, low, high, how_many, flags, stb); - else if (mixed_source_and_assembly) + else if (flags & DISASSEMBLY_SOURCE) do_mixed_source_and_assembly (gdbarch, uiout, &di, nlines, le, low, - high, symtab, how_many, stb); + high, symtab, how_many, flags, stb); do_cleanups (cleanups); gdb_flush (gdb_stdout); --- a/disasm.h +++ b/disasm.h @@ -19,6 +19,9 @@ #ifndef DISASM_H #define DISASM_H +#define DISASSEMBLY_SOURCE (0x1 << 0) +#define DISASSEMBLY_RAW_INSN (0x1 << 1) + struct ui_out; struct ui_file; --- a/mi/mi-cmd-disas.c +++ b/mi/mi-cmd-disas.c @@ -156,6 +156,6 @@ mi_cmd_disassemble (char *command, char gdb_disassembly (gdbarch, uiout, file_string, - mixed_source_and_assembly, how_many, low, high); + DISASSEMBLY_SOURCE, how_many, low, high); } --- a/stack.c +++ b/stack.c @@ -481,7 +481,9 @@ static void gdb_disassembly_stub (void *args) { struct gdb_disassembly_stub_args *p = args; - gdb_disassembly (p->gdbarch, uiout, 0, 0, p->how_many, p->low, p->high); + gdb_disassembly (p->gdbarch, uiout, 0, + DISASSEMBLY_SOURCE | DISASSEMBLY_RAW_INSN, p->how_many, + p->low, p->high); } /* Use TRY_CATCH to catch the exception from the gdb_disassembly [-- Attachment #3: disassemble-output-code-doc.txt --] [-- Type: text/plain, Size: 737 bytes --] --- doc/gdb.texinfo | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/doc/gdb.texinfo +++ b/doc/gdb.texinfo @@ -6178,9 +6178,11 @@ Variables}). @cindex listing machine instructions @item disassemble @itemx disassemble /m +@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. +the @code{/m} modifier and print the raw instruction in hex as well as +in symbolic form by specifying the @code{/r}. 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 [-- Attachment #4: disassemble-output-code-test.txt --] [-- Type: text/plain, Size: 2021 bytes --] --- testsuite/gdb.base/help.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/testsuite/gdb.base/help.exp +++ b/testsuite/gdb.base/help.exp @@ -124,7 +124,7 @@ gdb_test "help disable breakpoints" "Dis # test help disable display gdb_test "help disable display" "Disable some expressions to be displayed when program stops\.\[\r\n\]+Arguments are the code numbers of the expressions to stop displaying\.\[\r\n\]+No argument means disable all automatic-display expressions\.\[\r\n\]+Do \"info display\" to see current list of code numbers\." "help disable display" # test help disassemble -gdb_test "help disassemble" "Disassemble a specified section of memory\.\[\r\n\]+Default is the function surrounding the pc of the selected frame\.\[\r\n\]+With a /m modifier, source lines are included \\(if available\\)\.\[\r\n\]+With a single argument, the function surrounding that address is dumped\.\[\r\n\]+Two arguments are taken as a range of memory to dump\." "help disassemble" +gdb_test "help disassemble" "Disassemble a specified section of memory\.\[\r\n\]+Default is the function surrounding the pc of the selected frame\.\[\r\n\]+With a /m modifier, source lines are included \\(if available\\)\.\[\r\n\]+With a /r modifier, raw instruction in hex are included\.\[\r\n\]+With a single argument, the function surrounding that address is dumped\.\[\r\n\]+Two arguments are taken as a range of memory to dump\." "help disassemble" # test help display gdb_test "help display" "Print value of expression EXP each time the program stops\.\[\r\n\]+/FMT may be used before EXP as in the \"print\" command\.\[\r\n\]+/FMT \"i\" or \"s\" or including a size-letter is allowed,\[\r\n\]+as in the \"x\" command, and then EXP is used to get the address to examine\[\r\n\]+and examining is done as in the \"x\" command\.\[\r\n\]+With no argument, display all currently requested auto-display expressions\.\[\r\n\]+Use \"undisplay\" to cancel display requests previously made\." "help display" # test help do ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Add a new modifier /c to "disassemble" command to make it output binary code 2009-07-11 14:15 ` Hui Zhu @ 2009-07-11 17:54 ` Eli Zaretskii 2009-07-11 17:59 ` Hui Zhu 0 siblings, 1 reply; 16+ messages in thread From: Eli Zaretskii @ 2009-07-11 17:54 UTC (permalink / raw) To: Hui Zhu; +Cc: tromey, msnyder, dje, mark.kettenis, gdb-patches > Date: Sat, 11 Jul 2009 20:09:25 +0800 > From: Hui Zhu <teawater@gmail.com> > Cc: tromey@redhat.com, msnyder@vmware.com, dje@google.com, > mark.kettenis@xs4all.nl, gdb-patches@sourceware.org > > *** Changes since GDB 6.8 > > +* "disassemble" command with a /r modifier, print the raw instruction > +in hex as well as in symbolic form." "instructions", in plural. > + A /r modifier will include raw instruction in hex with the assembly. *= "instruction", in plural. > +With a /r modifier, raw instruction in hex are included.\n\ Same here. > +the @code{/m} modifier and print the raw instruction in hex as well as > +in symbolic form by specifying the @code{/r}. And here. Okay with those corrections. Thanks. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Add a new modifier /c to "disassemble" command to make it output binary code 2009-07-11 17:54 ` Eli Zaretskii @ 2009-07-11 17:59 ` Hui Zhu 2009-07-11 18:16 ` Regression for mi-disassemble.exp [Re: Add a new modifier /c to "disassemble" command to make it output binary code] Jan Kratochvil 0 siblings, 1 reply; 16+ messages in thread From: Hui Zhu @ 2009-07-11 17:59 UTC (permalink / raw) To: Eli Zaretskii; +Cc: tromey, msnyder, dje, mark.kettenis, gdb-patches On Sat, Jul 11, 2009 at 20:42, Eli Zaretskii<eliz@gnu.org> wrote: >> Date: Sat, 11 Jul 2009 20:09:25 +0800 >> From: Hui Zhu <teawater@gmail.com> >> Cc: tromey@redhat.com, msnyder@vmware.com, dje@google.com, >> mark.kettenis@xs4all.nl, gdb-patches@sourceware.org >> >> *** Changes since GDB 6.8 >> >> +* "disassemble" command with a /r modifier, print the raw instruction >> +in hex as well as in symbolic form." > > "instructions", in plural. > >> + A /r modifier will include raw instruction in hex with the assembly. *= > > "instruction", in plural. > >> +With a /r modifier, raw instruction in hex are included.\n\ > > Same here. > >> +the @code{/m} modifier and print the raw instruction in hex as well as >> +in symbolic form by specifying the @code{/r}. > > And here. > > Okay with those corrections. > Fixed and checked-in. Thanks, Hui ^ permalink raw reply [flat|nested] 16+ messages in thread
* Regression for mi-disassemble.exp [Re: Add a new modifier /c to "disassemble" command to make it output binary code] 2009-07-11 17:59 ` Hui Zhu @ 2009-07-11 18:16 ` Jan Kratochvil 2009-07-17 17:09 ` [commit] Fix mi-disassemble.exp regression Ulrich Weigand 0 siblings, 1 reply; 16+ messages in thread From: Jan Kratochvil @ 2009-07-11 18:16 UTC (permalink / raw) To: Hui Zhu; +Cc: Eli Zaretskii, tromey, msnyder, dje, mark.kettenis, gdb-patches Hi Hui, On Sat, 11 Jul 2009 16:15:00 +0200, Hui Zhu wrote: > Fixed and checked-in. this check-in http://sourceware.org/ml/gdb-cvs/2009-07/msg00089.html http://sourceware.org/ml/gdb-cvs/2009-07/msg00092.html 2009-07-11 Hui Zhu <teawater@gmail.com> * cli/cli-cmds.c (disassemble_command): Add a new modifier /r to "disassemble" command to print the raw instructions in hex as well as in symbolic form. (init_cli_cmds): Ditto. (print_disassembly): Change "mixed" to "flags" to translate the behavior of disassemble. (disassemble_current_function): Ditto. * mi/mi-cmd-disas.c (mi_cmd_disassemble): Ditto. * stack.c (gdb_disassembly_stub): Ditto. * disasm.c (do_mixed_source_and_assembly): Ditto. (do_mixed_source_and_assembly): Ditto. (do_assembly_only): Ditto. (gdb_disassembly): Ditto. (dump_insns): print the raw instructions in hex as well as in symbolic form if DISASSEMBLY_RAW_INSN and flags is true. * disasm.h (DISASSEMBLY_SOURCE): Include source code with the assembly if it and flags is true. (DISASSEMBLY_RAW_INSN): Include the raw instructions in hex with the assembly if it and flags is true. (gdb_disassembly): Update extern. * NEWS: Document disassemble/r support. causes a regression on {x86_64,x86_64-32,i686}-fedora11-linux-gnu. +FAIL: gdb.mi/mi-disassemble.exp: data-disassemble from pc to pc+12 assembly only +FAIL: gdb.mi/mi-disassemble.exp: data-disassemble file & line, assembly only +FAIL: gdb.mi/mi-disassemble.exp: data-disassemble file, line, number assembly only +FAIL: gdb.mi/mi-disassemble.exp: data-disassemble file, line, number (zero lines) assembly only +FAIL: gdb.mi/mi-disassemble.exp: data-disassemble file, line, number (more than main lines) assembly only +FAIL: gdb.mi/mi2-disassemble.exp: data-disassemble from pc to pc+12 assembly only +FAIL: gdb.mi/mi2-disassemble.exp: data-disassemble file & line, assembly only +FAIL: gdb.mi/mi2-disassemble.exp: data-disassemble file, line, number assembly only +FAIL: gdb.mi/mi2-disassemble.exp: data-disassemble file, line, number (zero lines) assembly only +FAIL: gdb.mi/mi2-disassemble.exp: data-disassemble file, line, number (more than main lines) assembly only I hope it is reproducible for you, have not checked it much more. Regards, Jan @@ -58240,17 +57869,17 @@ ]+[(]gdb[)] [ ]*) 111-data-disassemble -s $pc -e "$pc + 12" -- 0 -111^done,asm_insns=[{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"}] +111^done,asm_insns=[src_and_asm_line={line="66",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"}]}] (gdb) -PASS: gdb.mi/mi-disassemble.exp: data-disassemble from pc to pc+12 assembly only +FAIL: gdb.mi/mi-disassemble.exp: data-disassemble from pc to pc+12 assembly only Expecting: ^(222-data-disassemble -f basics\.c -l 66 -- 0[ ]+)?(222\^done,asm_insns=\[{address="0x[0-9A-Fa-f]+",func-name="main",offset="0",inst=".*"},.*,{address="0x[0-9A-Fa-f]+",func-name="main",offset="[0-9]+",inst=".*"}\][ ]+[(]gdb[)] [ ]*) 222-data-disassemble -f basics.c -l 66 -- 0 -222^done,asm_insns=[{address="0x00000000004005a0",func-name="main",offset="0",inst="push %rbp"},{address="0x00000000004005a1",func-name="main",offset="1",inst="mov %rsp,%rbp"},{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"},{address="0x00000000004005bb",func-name="main",offset="27",inst="movsd 0x155(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005c3",func-name="main",offset="35",inst="mov $0x4006ff,%esi"},{address="0x00000000004005c8",func-name="main",offset="40",inst="mov $0x2,%edi"},{address="0x00000000004005cd",func-name="main",offset="45",inst="callq 0x400551 <callee1>"},{address="0x00000000004005d2",func-name="main",offset="50",inst="callq 0x40059a <do_nothing>"},{address="0x00000000004005d7",func-name="main",offset="55",inst="mov $0x1,%edi"},{address="0x00000000004005dc",func-name="main",offset="60",inst="callq 0x400578 <callme>"},{address="0x00000000004005e1",func-name="main",offset="65",inst="mov $0x2,%edi"},{address="0x00000000004005e6",func-name="main",offset="70",inst="callq 0x400578 <callme>"},{address="0x00000000004005eb",func-name="main",offset="75",inst="mov $0x0,%eax"},{address="0x00000000004005f0",func-name="main",offset="80",inst="leaveq "},{address="0x00000000004005f1",func-name="main",offset="81",inst="retq "}] +222^done,asm_insns=[src_and_asm_line={line="65",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a0",func-name="main",offset="0",inst="push %rbp"},{address="0x00000000004005a1",func-name="main",offset="1",inst="mov %rsp,%rbp"}]},src_and_asm_line={line="66",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"}]},src_and_asm_line={line="67",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005bb",func-name="main",offset="27",inst="movsd 0x155(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005c3",func-name="main",offset="35",inst="mov $0x4006ff,%esi"},{address="0x00000000004005c8",func-name="main",offset="40",inst="mov $0x2,%edi"},{address="0x00000000004005cd",func-name="main",offset="45",inst="callq 0x400551 <callee1>"}]},src_and_asm_line={line="68",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="69",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005d2",func-name="main",offset="50",inst="callq 0x40059a <do_nothing>"}]},src_and_asm_line={line="70",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="71",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005d7",func-name="main",offset="55",inst="mov $0x1,%edi"},{address="0x00000000004005dc",func-name="main",offset="60",inst="callq 0x400578 <callme>"}]},src_and_asm_line={line="72",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005e1",func-name="main",offset="65",inst="mov $0x2,%edi"},{address="0x00000000004005e6",func-name="main",offset="70",inst="callq 0x400578 <callme>"}]},src_and_asm_line={line="73",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="74",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005eb",func-name="main",offset="75",inst="mov $0x0,%eax"}]},src_and_asm_line={line="75",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005f0",func-name="main",offset="80",inst="leaveq "},{address="0x00000000004005f1",func-name="main",offset="81",inst="retq "}]}] (gdb) -PASS: gdb.mi/mi-disassemble.exp: data-disassemble file & line, assembly only +FAIL: gdb.mi/mi-disassemble.exp: data-disassemble file & line, assembly only Expecting: ^(002-data-disassemble -f basics\.c -l 41 -- 1[ ]+)?(002\^done,asm_insns=\[src_and_asm_line={line="41",file=".*basics.c",line_asm_insn=\[{address="0x[0-9A-Fa-f]+",func-name="callee2",offset="0",inst=".*"}.*\]}.*,src_and_asm_line={line="[0-9]+",file=".*basics.c",line_asm_insn=\[.*{address="0x[0-9A-Fa-f]+",func-name="callee2",offset="[0-9]+",inst=".*"}\]}\][ ]+[(]gdb[)] @@ -58313,25 +57942,25 @@ ]+[(]gdb[)] [ ]*) 222-data-disassemble -f basics.c -l 66 -n 20 -- 0 -222^done,asm_insns=[{address="0x00000000004005a0",func-name="main",offset="0",inst="push %rbp"},{address="0x00000000004005a1",func-name="main",offset="1",inst="mov %rsp,%rbp"},{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"},{address="0x00000000004005bb",func-name="main",offset="27",inst="movsd 0x155(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005c3",func-name="main",offset="35",inst="mov $0x4006ff,%esi"},{address="0x00000000004005c8",func-name="main",offset="40",inst="mov $0x2,%edi"},{address="0x00000000004005cd",func-name="main",offset="45",inst="callq 0x400551 <callee1>"},{address="0x00000000004005d2",func-name="main",offset="50",inst="callq 0x40059a <do_nothing>"},{address="0x00000000004005d7",func-name="main",offset="55",inst="mov $0x1,%edi"},{address="0x00000000004005dc",func-name="main",offset="60",inst="callq 0x400578 <callme>"},{address="0x00000000004005e1",func-name="main",offset="65",inst="mov $0x2,%edi"},{address="0x00000000004005e6",func-name="main",offset="70",inst="callq 0x400578 <callme>"},{address="0x00000000004005eb",func-name="main",offset="75",inst="mov $0x0,%eax"},{address="0x00000000004005f0",func-name="main",offset="80",inst="leaveq "},{address="0x00000000004005f1",func-name="main",offset="81",inst="retq "}] +222^done,asm_insns=[src_and_asm_line={line="65",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a0",func-name="main",offset="0",inst="push %rbp"},{address="0x00000000004005a1",func-name="main",offset="1",inst="mov %rsp,%rbp"}]},src_and_asm_line={line="66",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"}]},src_and_asm_line={line="67",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005bb",func-name="main",offset="27",inst="movsd 0x155(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005c3",func-name="main",offset="35",inst="mov $0x4006ff,%esi"},{address="0x00000000004005c8",func-name="main",offset="40",inst="mov $0x2,%edi"},{address="0x00000000004005cd",func-name="main",offset="45",inst="callq 0x400551 <callee1>"}]},src_and_asm_line={line="68",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="69",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005d2",func-name="main",offset="50",inst="callq 0x40059a <do_nothing>"}]},src_and_asm_line={line="70",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="71",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005d7",func-name="main",offset="55",inst="mov $0x1,%edi"},{address="0x00000000004005dc",func-name="main",offset="60",inst="callq 0x400578 <callme>"}]},src_and_asm_line={line="72",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005e1",func-name="main",offset="65",inst="mov $0x2,%edi"},{address="0x00000000004005e6",func-name="main",offset="70",inst="callq 0x400578 <callme>"}]},src_and_asm_line={line="73",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="74",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005eb",func-name="main",offset="75",inst="mov $0x0,%eax"}]},src_and_asm_line={line="75",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005f0",func-name="main",offset="80",inst="leaveq "},{address="0x00000000004005f1",func-name="main",offset="81",inst="retq "}]}] (gdb) -PASS: gdb.mi/mi-disassemble.exp: data-disassemble file, line, number assembly only +FAIL: gdb.mi/mi-disassemble.exp: data-disassemble file, line, number assembly only Expecting: ^(222-data-disassemble -f basics\.c -l 66 -n 0 -- 0[ ]+)?(222\^done,asm_insns=\[\][ ]+[(]gdb[)] [ ]*) 222-data-disassemble -f basics.c -l 66 -n 0 -- 0 -222^done,asm_insns=[] +222^done,asm_insns=[src_and_asm_line={line="65",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]}] (gdb) -PASS: gdb.mi/mi-disassemble.exp: data-disassemble file, line, number (zero lines) assembly only +FAIL: gdb.mi/mi-disassemble.exp: data-disassemble file, line, number (zero lines) assembly only Expecting: ^(222-data-disassemble -f basics\.c -l 66 -n 50 -- 0[ ]+)?(222\^done,asm_insns=\[{address="0x[0-9A-Fa-f]+",func-name="main",offset="0",inst=".*"},.*,{address="0x[0-9A-Fa-f]+",func-name="main",offset="[0-9]+",inst=".*"}\][ ]+[(]gdb[)] [ ]*) 222-data-disassemble -f basics.c -l 66 -n 50 -- 0 -222^done,asm_insns=[{address="0x00000000004005a0",func-name="main",offset="0",inst="push %rbp"},{address="0x00000000004005a1",func-name="main",offset="1",inst="mov %rsp,%rbp"},{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"},{address="0x00000000004005bb",func-name="main",offset="27",inst="movsd 0x155(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005c3",func-name="main",offset="35",inst="mov $0x4006ff,%esi"},{address="0x00000000004005c8",func-name="main",offset="40",inst="mov $0x2,%edi"},{address="0x00000000004005cd",func-name="main",offset="45",inst="callq 0x400551 <callee1>"},{address="0x00000000004005d2",func-name="main",offset="50",inst="callq 0x40059a <do_nothing>"},{address="0x00000000004005d7",func-name="main",offset="55",inst="mov $0x1,%edi"},{address="0x00000000004005dc",func-name="main",offset="60",inst="callq 0x400578 <callme>"},{address="0x00000000004005e1",func-name="main",offset="65",inst="mov $0x2,%edi"},{address="0x00000000004005e6",func-name="main",offset="70",inst="callq 0x400578 <callme>"},{address="0x00000000004005eb",func-name="main",offset="75",inst="mov $0x0,%eax"},{address="0x00000000004005f0",func-name="main",offset="80",inst="leaveq "},{address="0x00000000004005f1",func-name="main",offset="81",inst="retq "}] +222^done,asm_insns=[src_and_asm_line={line="65",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a0",func-name="main",offset="0",inst="push %rbp"},{address="0x00000000004005a1",func-name="main",offset="1",inst="mov %rsp,%rbp"}]},src_and_asm_line={line="66",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"}]},src_and_asm_line={line="67",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005bb",func-name="main",offset="27",inst="movsd 0x155(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005c3",func-name="main",offset="35",inst="mov $0x4006ff,%esi"},{address="0x00000000004005c8",func-name="main",offset="40",inst="mov $0x2,%edi"},{address="0x00000000004005cd",func-name="main",offset="45",inst="callq 0x400551 <callee1>"}]},src_and_asm_line={line="68",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="69",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005d2",func-name="main",offset="50",inst="callq 0x40059a <do_nothing>"}]},src_and_asm_line={line="70",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="71",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005d7",func-name="main",offset="55",inst="mov $0x1,%edi"},{address="0x00000000004005dc",func-name="main",offset="60",inst="callq 0x400578 <callme>"}]},src_and_asm_line={line="72",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005e1",func-name="main",offset="65",inst="mov $0x2,%edi"},{address="0x00000000004005e6",func-name="main",offset="70",inst="callq 0x400578 <callme>"}]},src_and_asm_line={line="73",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="74",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005eb",func-name="main",offset="75",inst="mov $0x0,%eax"}]},src_and_asm_line={line="75",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005f0",func-name="main",offset="80",inst="leaveq "},{address="0x00000000004005f1",func-name="main",offset="81",inst="retq "}]}] (gdb) -PASS: gdb.mi/mi-disassemble.exp: data-disassemble file, line, number (more than main lines) assembly only +FAIL: gdb.mi/mi-disassemble.exp: data-disassemble file, line, number (more than main lines) assembly only Expecting: ^(print/x \$pc[ ]+)?([ ]+[(]gdb[)] @@ -68148,17 +67774,17 @@ ]+[(]gdb[)] [ ]*) 111-data-disassemble -s $pc -e "$pc + 12" -- 0 -111^done,asm_insns=[{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"}] +111^done,asm_insns=[src_and_asm_line={line="66",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"}]}] (gdb) -PASS: gdb.mi/mi2-disassemble.exp: data-disassemble from pc to pc+12 assembly only +FAIL: gdb.mi/mi2-disassemble.exp: data-disassemble from pc to pc+12 assembly only Expecting: ^(222-data-disassemble -f basics\.c -l 66 -- 0[ ]+)?(222\^done,asm_insns=\[{address="0x[0-9A-Fa-f]+",func-name="main",offset="0",inst=".*"},.*,{address="0x[0-9A-Fa-f]+",func-name="main",offset="[0-9]+",inst=".*"}\][ ]+[(]gdb[)] [ ]*) 222-data-disassemble -f basics.c -l 66 -- 0 -222^done,asm_insns=[{address="0x00000000004005a0",func-name="main",offset="0",inst="push %rbp"},{address="0x00000000004005a1",func-name="main",offset="1",inst="mov %rsp,%rbp"},{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"},{address="0x00000000004005bb",func-name="main",offset="27",inst="movsd 0x155(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005c3",func-name="main",offset="35",inst="mov $0x4006ff,%esi"},{address="0x00000000004005c8",func-name="main",offset="40",inst="mov $0x2,%edi"},{address="0x00000000004005cd",func-name="main",offset="45",inst="callq 0x400551 <callee1>"},{address="0x00000000004005d2",func-name="main",offset="50",inst="callq 0x40059a <do_nothing>"},{address="0x00000000004005d7",func-name="main",offset="55",inst="mov $0x1,%edi"},{address="0x00000000004005dc",func-name="main",offset="60",inst="callq 0x400578 <callme>"},{address="0x00000000004005e1",func-name="main",offset="65",inst="mov $0x2,%edi"},{address="0x00000000004005e6",func-name="main",offset="70",inst="callq 0x400578 <callme>"},{address="0x00000000004005eb",func-name="main",offset="75",inst="mov $0x0,%eax"},{address="0x00000000004005f0",func-name="main",offset="80",inst="leaveq "},{address="0x00000000004005f1",func-name="main",offset="81",inst="retq "}] +222^done,asm_insns=[src_and_asm_line={line="65",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a0",func-name="main",offset="0",inst="push %rbp"},{address="0x00000000004005a1",func-name="main",offset="1",inst="mov %rsp,%rbp"}]},src_and_asm_line={line="66",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"}]},src_and_asm_line={line="67",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005bb",func-name="main",offset="27",inst="movsd 0x155(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005c3",func-name="main",offset="35",inst="mov $0x4006ff,%esi"},{address="0x00000000004005c8",func-name="main",offset="40",inst="mov $0x2,%edi"},{address="0x00000000004005cd",func-name="main",offset="45",inst="callq 0x400551 <callee1>"}]},src_and_asm_line={line="68",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="69",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005d2",func-name="main",offset="50",inst="callq 0x40059a <do_nothing>"}]},src_and_asm_line={line="70",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="71",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005d7",func-name="main",offset="55",inst="mov $0x1,%edi"},{address="0x00000000004005dc",func-name="main",offset="60",inst="callq 0x400578 <callme>"}]},src_and_asm_line={line="72",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005e1",func-name="main",offset="65",inst="mov $0x2,%edi"},{address="0x00000000004005e6",func-name="main",offset="70",inst="callq 0x400578 <callme>"}]},src_and_asm_line={line="73",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="74",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005eb",func-name="main",offset="75",inst="mov $0x0,%eax"}]},src_and_asm_line={line="75",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005f0",func-name="main",offset="80",inst="leaveq "},{address="0x00000000004005f1",func-name="main",offset="81",inst="retq "}]}] (gdb) -PASS: gdb.mi/mi2-disassemble.exp: data-disassemble file & line, assembly only +FAIL: gdb.mi/mi2-disassemble.exp: data-disassemble file & line, assembly only Expecting: ^(002-data-disassemble -f basics\.c -l 41 -- 1[ ]+)?(002\^done,asm_insns=\[src_and_asm_line={line="41",file=".*basics.c",line_asm_insn=\[{address="0x[0-9A-Fa-f]+",func-name="callee2",offset="0",inst=".*"}.*\]}.*,src_and_asm_line={line="[0-9]+",file=".*basics.c",line_asm_insn=\[.*{address="0x[0-9A-Fa-f]+",func-name="callee2",offset="[0-9]+",inst=".*"}\]}\][ ]+[(]gdb[)] @@ -68221,25 +67847,25 @@ ]+[(]gdb[)] [ ]*) 222-data-disassemble -f basics.c -l 66 -n 20 -- 0 -222^done,asm_insns=[{address="0x00000000004005a0",func-name="main",offset="0",inst="push %rbp"},{address="0x00000000004005a1",func-name="main",offset="1",inst="mov %rsp,%rbp"},{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"},{address="0x00000000004005bb",func-name="main",offset="27",inst="movsd 0x155(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005c3",func-name="main",offset="35",inst="mov $0x4006ff,%esi"},{address="0x00000000004005c8",func-name="main",offset="40",inst="mov $0x2,%edi"},{address="0x00000000004005cd",func-name="main",offset="45",inst="callq 0x400551 <callee1>"},{address="0x00000000004005d2",func-name="main",offset="50",inst="callq 0x40059a <do_nothing>"},{address="0x00000000004005d7",func-name="main",offset="55",inst="mov $0x1,%edi"},{address="0x00000000004005dc",func-name="main",offset="60",inst="callq 0x400578 <callme>"},{address="0x00000000004005e1",func-name="main",offset="65",inst="mov $0x2,%edi"},{address="0x00000000004005e6",func-name="main",offset="70",inst="callq 0x400578 <callme>"},{address="0x00000000004005eb",func-name="main",offset="75",inst="mov $0x0,%eax"},{address="0x00000000004005f0",func-name="main",offset="80",inst="leaveq "},{address="0x00000000004005f1",func-name="main",offset="81",inst="retq "}] +222^done,asm_insns=[src_and_asm_line={line="65",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a0",func-name="main",offset="0",inst="push %rbp"},{address="0x00000000004005a1",func-name="main",offset="1",inst="mov %rsp,%rbp"}]},src_and_asm_line={line="66",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"}]},src_and_asm_line={line="67",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005bb",func-name="main",offset="27",inst="movsd 0x155(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005c3",func-name="main",offset="35",inst="mov $0x4006ff,%esi"},{address="0x00000000004005c8",func-name="main",offset="40",inst="mov $0x2,%edi"},{address="0x00000000004005cd",func-name="main",offset="45",inst="callq 0x400551 <callee1>"}]},src_and_asm_line={line="68",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="69",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005d2",func-name="main",offset="50",inst="callq 0x40059a <do_nothing>"}]},src_and_asm_line={line="70",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="71",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005d7",func-name="main",offset="55",inst="mov $0x1,%edi"},{address="0x00000000004005dc",func-name="main",offset="60",inst="callq 0x400578 <callme>"}]},src_and_asm_line={line="72",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005e1",func-name="main",offset="65",inst="mov $0x2,%edi"},{address="0x00000000004005e6",func-name="main",offset="70",inst="callq 0x400578 <callme>"}]},src_and_asm_line={line="73",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="74",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005eb",func-name="main",offset="75",inst="mov $0x0,%eax"}]},src_and_asm_line={line="75",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005f0",func-name="main",offset="80",inst="leaveq "},{address="0x00000000004005f1",func-name="main",offset="81",inst="retq "}]}] (gdb) -PASS: gdb.mi/mi2-disassemble.exp: data-disassemble file, line, number assembly only +FAIL: gdb.mi/mi2-disassemble.exp: data-disassemble file, line, number assembly only Expecting: ^(222-data-disassemble -f basics\.c -l 66 -n 0 -- 0[ ]+)?(222\^done,asm_insns=\[\][ ]+[(]gdb[)] [ ]*) 222-data-disassemble -f basics.c -l 66 -n 0 -- 0 -222^done,asm_insns=[] +222^done,asm_insns=[src_and_asm_line={line="65",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]}] (gdb) -PASS: gdb.mi/mi2-disassemble.exp: data-disassemble file, line, number (zero lines) assembly only +FAIL: gdb.mi/mi2-disassemble.exp: data-disassemble file, line, number (zero lines) assembly only Expecting: ^(222-data-disassemble -f basics\.c -l 66 -n 50 -- 0[ ]+)?(222\^done,asm_insns=\[{address="0x[0-9A-Fa-f]+",func-name="main",offset="0",inst=".*"},.*,{address="0x[0-9A-Fa-f]+",func-name="main",offset="[0-9]+",inst=".*"}\][ ]+[(]gdb[)] [ ]*) 222-data-disassemble -f basics.c -l 66 -n 50 -- 0 -222^done,asm_insns=[{address="0x00000000004005a0",func-name="main",offset="0",inst="push %rbp"},{address="0x00000000004005a1",func-name="main",offset="1",inst="mov %rsp,%rbp"},{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"},{address="0x00000000004005bb",func-name="main",offset="27",inst="movsd 0x155(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005c3",func-name="main",offset="35",inst="mov $0x4006ff,%esi"},{address="0x00000000004005c8",func-name="main",offset="40",inst="mov $0x2,%edi"},{address="0x00000000004005cd",func-name="main",offset="45",inst="callq 0x400551 <callee1>"},{address="0x00000000004005d2",func-name="main",offset="50",inst="callq 0x40059a <do_nothing>"},{address="0x00000000004005d7",func-name="main",offset="55",inst="mov $0x1,%edi"},{address="0x00000000004005dc",func-name="main",offset="60",inst="callq 0x400578 <callme>"},{address="0x00000000004005e1",func-name="main",offset="65",inst="mov $0x2,%edi"},{address="0x00000000004005e6",func-name="main",offset="70",inst="callq 0x400578 <callme>"},{address="0x00000000004005eb",func-name="main",offset="75",inst="mov $0x0,%eax"},{address="0x00000000004005f0",func-name="main",offset="80",inst="leaveq "},{address="0x00000000004005f1",func-name="main",offset="81",inst="retq "}] +222^done,asm_insns=[src_and_asm_line={line="65",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a0",func-name="main",offset="0",inst="push %rbp"},{address="0x00000000004005a1",func-name="main",offset="1",inst="mov %rsp,%rbp"}]},src_and_asm_line={line="66",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005a4",func-name="main",offset="4",inst="movsd 0x16c(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005ac",func-name="main",offset="12",inst="mov $0x4006ff,%esi"},{address="0x00000000004005b1",func-name="main",offset="17",inst="mov $0x2,%edi"},{address="0x00000000004005b6",func-name="main",offset="22",inst="callq 0x400551 <callee1>"}]},src_and_asm_line={line="67",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005bb",func-name="main",offset="27",inst="movsd 0x155(%rip),%xmm0 # 0x400718 <__dso_handle+40>"},{address="0x00000000004005c3",func-name="main",offset="35",inst="mov $0x4006ff,%esi"},{address="0x00000000004005c8",func-name="main",offset="40",inst="mov $0x2,%edi"},{address="0x00000000004005cd",func-name="main",offset="45",inst="callq 0x400551 <callee1>"}]},src_and_asm_line={line="68",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="69",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005d2",func-name="main",offset="50",inst="callq 0x40059a <do_nothing>"}]},src_and_asm_line={line="70",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="71",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005d7",func-name="main",offset="55",inst="mov $0x1,%edi"},{address="0x00000000004005dc",func-name="main",offset="60",inst="callq 0x400578 <callme>"}]},src_and_asm_line={line="72",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005e1",func-name="main",offset="65",inst="mov $0x2,%edi"},{address="0x00000000004005e6",func-name="main",offset="70",inst="callq 0x400578 <callme>"}]},src_and_asm_line={line="73",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[]},src_and_asm_line={line="74",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005eb",func-name="main",offset="75",inst="mov $0x0,%eax"}]},src_and_asm_line={line="75",file="../.././gdb/testsuite/gdb.mi/basics.c",line_asm_insn=[{address="0x00000000004005f0",func-name="main",offset="80",inst="leaveq "},{address="0x00000000004005f1",func-name="main",offset="81",inst="retq "}]}] (gdb) -PASS: gdb.mi/mi2-disassemble.exp: data-disassemble file, line, number (more than main lines) assembly only +FAIL: gdb.mi/mi2-disassemble.exp: data-disassemble file, line, number (more than main lines) assembly only Expecting: ^(print/x \$pc[ ]+)?([ ]+[(]gdb[)] ^ permalink raw reply [flat|nested] 16+ messages in thread
* [commit] Fix mi-disassemble.exp regression 2009-07-11 18:16 ` Regression for mi-disassemble.exp [Re: Add a new modifier /c to "disassemble" command to make it output binary code] Jan Kratochvil @ 2009-07-17 17:09 ` Ulrich Weigand 2009-07-18 5:45 ` Hui Zhu 0 siblings, 1 reply; 16+ messages in thread From: Ulrich Weigand @ 2009-07-17 17:09 UTC (permalink / raw) To: Jan Kratochvil Cc: Hui Zhu, Eli Zaretskii, tromey, msnyder, dje, mark.kettenis, gdb-patches Jan Kratochvil wrote: > On Sat, 11 Jul 2009 16:15:00 +0200, Hui Zhu wrote: > > Fixed and checked-in. > > this check-in > http://sourceware.org/ml/gdb-cvs/2009-07/msg00089.html > http://sourceware.org/ml/gdb-cvs/2009-07/msg00092.html [snip] > causes a regression on {x86_64,x86_64-32,i686}-fedora11-linux-gnu. This is caused by this part of Hui's patch: --- a/mi/mi-cmd-disas.c +++ b/mi/mi-cmd-disas.c @@ -156,6 +156,6 @@ mi_cmd_disassemble (char *command, char gdb_disassembly (gdbarch, uiout, file_string, - mixed_source_and_assembly, how_many, low, high); + DISASSEMBLY_SOURCE, how_many, low, high); } Note how the new code completely ignores the mixed_source_and_assembly flag (which is set from the mixed_mode MI parameter). The following patch fixes this. Tested on powerpc64-linux, committed to mainline. Bye, Ulrich ChangeLog: * mi/mi-cmd-disas.c (mi_cmd_disassemble): Respect mixed_mode flag. Index: gdb/mi/mi-cmd-disas.c =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-cmd-disas.c,v retrieving revision 1.31 diff -u -p -r1.31 mi-cmd-disas.c --- gdb/mi/mi-cmd-disas.c 11 Jul 2009 14:04:23 -0000 1.31 +++ gdb/mi/mi-cmd-disas.c 17 Jul 2009 15:50:06 -0000 @@ -156,6 +156,6 @@ mi_cmd_disassemble (char *command, char gdb_disassembly (gdbarch, uiout, file_string, - DISASSEMBLY_SOURCE, how_many, low, high); - + mixed_source_and_assembly? DISASSEMBLY_SOURCE : 0, + how_many, low, high); } -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [commit] Fix mi-disassemble.exp regression 2009-07-17 17:09 ` [commit] Fix mi-disassemble.exp regression Ulrich Weigand @ 2009-07-18 5:45 ` Hui Zhu 0 siblings, 0 replies; 16+ messages in thread From: Hui Zhu @ 2009-07-18 5:45 UTC (permalink / raw) To: Ulrich Weigand Cc: Jan Kratochvil, Eli Zaretskii, tromey, msnyder, dje, mark.kettenis, gdb-patches Oops, sorry to forget it. Thanks. Hui On Fri, Jul 17, 2009 at 23:59, Ulrich Weigand<uweigand@de.ibm.com> wrote: > Jan Kratochvil wrote: > >> On Sat, 11 Jul 2009 16:15:00 +0200, Hui Zhu wrote: >> > Fixed and checked-in. >> >> this check-in >> http://sourceware.org/ml/gdb-cvs/2009-07/msg00089.html >> http://sourceware.org/ml/gdb-cvs/2009-07/msg00092.html > [snip] >> causes a regression on {x86_64,x86_64-32,i686}-fedora11-linux-gnu. > > This is caused by this part of Hui's patch: > > --- a/mi/mi-cmd-disas.c > +++ b/mi/mi-cmd-disas.c > @@ -156,6 +156,6 @@ mi_cmd_disassemble (char *command, char > > gdb_disassembly (gdbarch, uiout, > file_string, > - mixed_source_and_assembly, how_many, low, high); > + DISASSEMBLY_SOURCE, how_many, low, high); > > } > > Note how the new code completely ignores the mixed_source_and_assembly > flag (which is set from the mixed_mode MI parameter). > > The following patch fixes this. > Tested on powerpc64-linux, committed to mainline. > > Bye, > Ulrich > > ChangeLog: > > * mi/mi-cmd-disas.c (mi_cmd_disassemble): Respect mixed_mode flag. > > Index: gdb/mi/mi-cmd-disas.c > =================================================================== > RCS file: /cvs/src/src/gdb/mi/mi-cmd-disas.c,v > retrieving revision 1.31 > diff -u -p -r1.31 mi-cmd-disas.c > --- gdb/mi/mi-cmd-disas.c 11 Jul 2009 14:04:23 -0000 1.31 > +++ gdb/mi/mi-cmd-disas.c 17 Jul 2009 15:50:06 -0000 > @@ -156,6 +156,6 @@ mi_cmd_disassemble (char *command, char > > gdb_disassembly (gdbarch, uiout, > file_string, > - DISASSEMBLY_SOURCE, how_many, low, high); > - > + mixed_source_and_assembly? DISASSEMBLY_SOURCE : 0, > + how_many, low, high); > } > > > -- > Dr. Ulrich Weigand > GNU Toolchain for Linux on System z and Cell BE > Ulrich.Weigand@de.ibm.com > ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Add a new modifier /c to "disassemble" command to make it output binary code 2009-07-09 12:22 Add a new modifier /c to "disassemble" command to make it output binary code Hui Zhu 2009-07-09 19:22 ` Tom Tromey @ 2009-07-09 19:53 ` Eli Zaretskii 2009-07-09 22:00 ` Michael Snyder 2009-07-09 23:44 ` Doug Evans 3 siblings, 0 replies; 16+ messages in thread From: Eli Zaretskii @ 2009-07-09 19:53 UTC (permalink / raw) To: Hui Zhu; +Cc: gdb-patches > Date: Thu, 9 Jul 2009 14:35:54 +0800 > From: Hui Zhu <teawater@gmail.com> > > +With a /c modifier, binary code are included.\n\ I think you mean "hex dump of machine code", not "binary code". In any case, "binary code is included", in singular, not plural. > -@itemx disassemble /m > +@itemx disassemble /mc Isn't it better to show that the modifiers are independent? Like this: @item disassemble @itemx disassemble /m @itemx disassemble /c > -the @code{/m} modifier. > +the @code{/m} modifier and print binary code by specifying > +the @code{/c}. Again, I think "machine code in hex dump format" is better. Okay with these changes. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Add a new modifier /c to "disassemble" command to make it output binary code 2009-07-09 12:22 Add a new modifier /c to "disassemble" command to make it output binary code Hui Zhu 2009-07-09 19:22 ` Tom Tromey 2009-07-09 19:53 ` Add a new modifier /c to "disassemble" command to make it output binary code Eli Zaretskii @ 2009-07-09 22:00 ` Michael Snyder 2009-07-09 23:44 ` Doug Evans 3 siblings, 0 replies; 16+ messages in thread From: Michael Snyder @ 2009-07-09 22:00 UTC (permalink / raw) To: Hui Zhu; +Cc: gdb-patches ml How about test suites? At a minimum, gdb.base/help.exp probably needs an update. Hui Zhu wrote: > Hi, > > The objdump will output the binary code when it works but gdb not. > I make a patch to add a new modifier /c to "disassemble" command to > make it output binary code. > Please help me review it. > > Thanks, > Hui > > 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. > > --- > cli/cli-cmds.c | 27 +++++++++++++++++---------- > disasm.c | 35 ++++++++++++++++++++++++++--------- > disasm.h | 3 ++- > mi/mi-cmd-disas.c | 2 +- > stack.c | 2 +- > 5 files changed, 47 insertions(+), 22 deletions(-) > > --- a/cli/cli-cmds.c > +++ b/cli/cli-cmds.c > @@ -908,7 +908,7 @@ list_command (char *arg, int from_tty) > > 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) > { > #if defined(TUI) > if (!tui_is_window_visible (DISASSEM_WIN)) > @@ -922,7 +922,7 @@ print_disassembly (struct gdbarch *gdbar > paddress (gdbarch, low), paddress (gdbarch, high)); > > /* Dump the specified range. */ > - gdb_disassembly (gdbarch, uiout, 0, mixed, -1, low, high); > + gdb_disassembly (gdbarch, uiout, 0, mixed, -1, code, low, high); > > printf_filtered ("End of assembler dump.\n"); > gdb_flush (gdb_stdout); > @@ -940,7 +940,7 @@ print_disassembly (struct gdbarch *gdbar > MIXED is non-zero to print source with the assembler. */ > > static void > -disassemble_current_function (int mixed) > +disassemble_current_function (int mixed, int code) > { > struct frame_info *frame; > struct gdbarch *gdbarch; > @@ -961,20 +961,21 @@ disassemble_current_function (int mixed) > #endif > low += gdbarch_deprecated_function_start_offset (gdbarch); > > - print_disassembly (gdbarch, name, low, high, mixed); > + print_disassembly (gdbarch, name, low, high, mixed, code); > } > > /* Dump a specified section of assembly code. > > Usage: > - disassemble [/m] > + disassemble [/mc] > - dump the assembly code for the function of the current pc > - disassemble [/m] addr > + disassemble [/mc] addr > - dump the assembly code for the function at ADDR > - disassemble [/m] low high > + disassemble [/mc] low high > - dump the assembly code in the range [LOW,HIGH) > > - A /m modifier will include source code with the assembly. */ > + A /m modifier will include source code with the assembly. > + A /c modifier will include binary code with the assembly. */ > > static void > disassemble_command (char *arg, int from_tty) > @@ -985,9 +986,11 @@ disassemble_command (char *arg, int from > CORE_ADDR pc, pc_masked; > char *space_index; > int mixed_source_and_assembly; > + int code; > > name = NULL; > mixed_source_and_assembly = 0; > + code = 0; > > if (arg && *arg == '/') > { > @@ -1003,6 +1006,9 @@ disassemble_command (char *arg, int from > case 'm': > mixed_source_and_assembly = 1; > break; > + case 'c': > + code = 1; > + break; > default: > error (_("Invalid disassembly modifier.")); > } > @@ -1014,7 +1020,7 @@ disassemble_command (char *arg, int from > > if (! arg || ! *arg) > { > - disassemble_current_function (mixed_source_and_assembly); > + disassemble_current_function (mixed_source_and_assembly, code); > return; > } > > @@ -1044,7 +1050,7 @@ disassemble_command (char *arg, int from > high = parse_and_eval_address (space_index + 1); > } > > - print_disassembly (gdbarch, name, low, high, mixed_source_and_assembly); > + print_disassembly (gdbarch, name, low, high, > mixed_source_and_assembly, code); > } > > static void > @@ -1453,6 +1459,7 @@ With two args if one is empty it stands > Disassemble a specified section of memory.\n\ > Default is the function surrounding the pc of the selected frame.\n\ > With a /m modifier, source lines are included (if available).\n\ > +With a /c modifier, binary code are included.\n\ > With a single argument, the function surrounding that address is dumped.\n\ > Two arguments are taken as a range of memory to dump.")); > set_cmd_completer (c, location_completer); > --- a/disasm.c > +++ b/disasm.c > @@ -88,7 +88,7 @@ static int > dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout, > struct disassemble_info * di, > CORE_ADDR low, CORE_ADDR high, > - int how_many, struct ui_stream *stb) > + int how_many, int code, struct ui_stream *stb) > { > int num_displayed = 0; > CORE_ADDR pc; > @@ -135,7 +135,23 @@ dump_insns (struct gdbarch *gdbarch, str > xfree (name); > > ui_file_rewind (stb->stream); > - pc += gdbarch_print_insn (gdbarch, pc, di); > + if (code) > + { > + CORE_ADDR old_pc = pc; > + bfd_byte data; > + int status; > + pc += gdbarch_print_insn (gdbarch, pc, di); > + for (;old_pc < pc; old_pc++) > + { > + status = (*di->read_memory_func) (old_pc, &data, 1, di); > + if (status != 0) > + (*di->memory_error_func) (status, old_pc, di); > + ui_out_message (uiout, 0, " %02x", (unsigned)data); > + } > + ui_out_text (uiout, "\t"); > + } > + else > + pc += gdbarch_print_insn (gdbarch, pc, di); > ui_out_field_stream (uiout, "inst", stb); > ui_file_rewind (stb->stream); > do_cleanups (ui_out_chain); > @@ -154,7 +170,7 @@ do_mixed_source_and_assembly (struct gdb > struct linetable_entry *le, > CORE_ADDR low, CORE_ADDR high, > struct symtab *symtab, > - int how_many, struct ui_stream *stb) > + int how_many, int code, struct ui_stream *stb) > { > int newlines = 0; > struct dis_line_entry *mle; > @@ -278,7 +294,7 @@ do_mixed_source_and_assembly (struct gdb > > num_displayed += dump_insns (gdbarch, uiout, di, > mle[i].start_pc, mle[i].end_pc, > - how_many, stb); > + how_many, code, stb); > > /* When we've reached the end of the mle array, or we've seen the last > assembly range for this source line, close out the list/tuple. */ > @@ -301,14 +317,15 @@ static void > do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout, > struct disassemble_info * di, > CORE_ADDR low, CORE_ADDR high, > - int how_many, struct ui_stream *stb) > + int how_many, int code, struct ui_stream *stb) > { > int num_displayed = 0; > struct cleanup *ui_out_chain; > > ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns"); > > - num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, stb); > + num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, > + code, stb); > > do_cleanups (ui_out_chain); > } > @@ -357,7 +374,7 @@ void > gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, > char *file_string, > int mixed_source_and_assembly, > - int how_many, CORE_ADDR low, CORE_ADDR high) > + int how_many, int code, CORE_ADDR low, CORE_ADDR high) > { > struct ui_stream *stb = ui_out_stream_new (uiout); > struct cleanup *cleanups = make_cleanup_ui_out_stream_delete (stb); > @@ -379,11 +396,11 @@ gdb_disassembly (struct gdbarch *gdbarch > > if (!mixed_source_and_assembly || nlines <= 0 > || symtab == NULL || symtab->linetable == NULL) > - do_assembly_only (gdbarch, uiout, &di, low, high, how_many, stb); > + do_assembly_only (gdbarch, uiout, &di, low, high, how_many, code, stb); > > else if (mixed_source_and_assembly) > do_mixed_source_and_assembly (gdbarch, uiout, &di, nlines, le, low, > - high, symtab, how_many, stb); > + high, symtab, how_many, code, stb); > > do_cleanups (cleanups); > gdb_flush (gdb_stdout); > --- a/disasm.h > +++ b/disasm.h > @@ -25,7 +25,8 @@ struct ui_file; > extern void gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, > char *file_string, > int mixed_source_and_assembly, > - int how_many, CORE_ADDR low, CORE_ADDR high); > + int how_many, int code, CORE_ADDR low, > + CORE_ADDR high); > > /* Print the instruction at address MEMADDR in debugged memory, > on STREAM. Returns the length of the instruction, in bytes, > --- a/mi/mi-cmd-disas.c > +++ b/mi/mi-cmd-disas.c > @@ -156,6 +156,6 @@ mi_cmd_disassemble (char *command, char > > gdb_disassembly (gdbarch, uiout, > file_string, > - mixed_source_and_assembly, how_many, low, high); > + mixed_source_and_assembly, 0, how_many, low, high); > > } > --- a/stack.c > +++ b/stack.c > @@ -481,7 +481,7 @@ static void > gdb_disassembly_stub (void *args) > { > struct gdb_disassembly_stub_args *p = args; > - gdb_disassembly (p->gdbarch, uiout, 0, 0, p->how_many, p->low, p->high); > + gdb_disassembly (p->gdbarch, uiout, 0, 0, 1, p->how_many, p->low, p->high); > } > > /* Use TRY_CATCH to catch the exception from the gdb_disassembly > > > 2009-07-09 Hui Zhu <teawater@gmail.com> > > * gdb.texinfo (disassemble): Add a new modifier /c > to "disassemble" command to make it output binary code. > > --- > doc/gdb.texinfo | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > --- a/doc/gdb.texinfo > +++ b/doc/gdb.texinfo > @@ -6177,10 +6177,11 @@ Variables}). > @cindex machine instructions > @cindex listing machine instructions > @item disassemble > -@itemx disassemble /m > +@itemx disassemble /mc > This specialized command dumps a range of memory as machine > instructions. It can also print mixed source+disassembly by specifying > -the @code{/m} modifier. > +the @code{/m} modifier and print binary code by specifying > +the @code{/c}. > 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 > > > ------------------------------------------------------------------------ > > --- > cli/cli-cmds.c | 27 +++++++++++++++++---------- > disasm.c | 35 ++++++++++++++++++++++++++--------- > disasm.h | 3 ++- > mi/mi-cmd-disas.c | 2 +- > stack.c | 2 +- > 5 files changed, 47 insertions(+), 22 deletions(-) > > --- a/cli/cli-cmds.c > +++ b/cli/cli-cmds.c > @@ -908,7 +908,7 @@ list_command (char *arg, int from_tty) > > 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) > { > #if defined(TUI) > if (!tui_is_window_visible (DISASSEM_WIN)) > @@ -922,7 +922,7 @@ print_disassembly (struct gdbarch *gdbar > paddress (gdbarch, low), paddress (gdbarch, high)); > > /* Dump the specified range. */ > - gdb_disassembly (gdbarch, uiout, 0, mixed, -1, low, high); > + gdb_disassembly (gdbarch, uiout, 0, mixed, -1, code, low, high); > > printf_filtered ("End of assembler dump.\n"); > gdb_flush (gdb_stdout); > @@ -940,7 +940,7 @@ print_disassembly (struct gdbarch *gdbar > MIXED is non-zero to print source with the assembler. */ > > static void > -disassemble_current_function (int mixed) > +disassemble_current_function (int mixed, int code) > { > struct frame_info *frame; > struct gdbarch *gdbarch; > @@ -961,20 +961,21 @@ disassemble_current_function (int mixed) > #endif > low += gdbarch_deprecated_function_start_offset (gdbarch); > > - print_disassembly (gdbarch, name, low, high, mixed); > + print_disassembly (gdbarch, name, low, high, mixed, code); > } > > /* Dump a specified section of assembly code. > > Usage: > - disassemble [/m] > + disassemble [/mc] > - dump the assembly code for the function of the current pc > - disassemble [/m] addr > + disassemble [/mc] addr > - dump the assembly code for the function at ADDR > - disassemble [/m] low high > + disassemble [/mc] low high > - dump the assembly code in the range [LOW,HIGH) > > - A /m modifier will include source code with the assembly. */ > + A /m modifier will include source code with the assembly. > + A /c modifier will include binary code with the assembly. */ > > static void > disassemble_command (char *arg, int from_tty) > @@ -985,9 +986,11 @@ disassemble_command (char *arg, int from > CORE_ADDR pc, pc_masked; > char *space_index; > int mixed_source_and_assembly; > + int code; > > name = NULL; > mixed_source_and_assembly = 0; > + code = 0; > > if (arg && *arg == '/') > { > @@ -1003,6 +1006,9 @@ disassemble_command (char *arg, int from > case 'm': > mixed_source_and_assembly = 1; > break; > + case 'c': > + code = 1; > + break; > default: > error (_("Invalid disassembly modifier.")); > } > @@ -1014,7 +1020,7 @@ disassemble_command (char *arg, int from > > if (! arg || ! *arg) > { > - disassemble_current_function (mixed_source_and_assembly); > + disassemble_current_function (mixed_source_and_assembly, code); > return; > } > > @@ -1044,7 +1050,7 @@ disassemble_command (char *arg, int from > high = parse_and_eval_address (space_index + 1); > } > > - print_disassembly (gdbarch, name, low, high, mixed_source_and_assembly); > + print_disassembly (gdbarch, name, low, high, mixed_source_and_assembly, code); > } > > static void > @@ -1453,6 +1459,7 @@ With two args if one is empty it stands > Disassemble a specified section of memory.\n\ > Default is the function surrounding the pc of the selected frame.\n\ > With a /m modifier, source lines are included (if available).\n\ > +With a /c modifier, binary code are included.\n\ > With a single argument, the function surrounding that address is dumped.\n\ > Two arguments are taken as a range of memory to dump.")); > set_cmd_completer (c, location_completer); > --- a/disasm.c > +++ b/disasm.c > @@ -88,7 +88,7 @@ static int > dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout, > struct disassemble_info * di, > CORE_ADDR low, CORE_ADDR high, > - int how_many, struct ui_stream *stb) > + int how_many, int code, struct ui_stream *stb) > { > int num_displayed = 0; > CORE_ADDR pc; > @@ -135,7 +135,23 @@ dump_insns (struct gdbarch *gdbarch, str > xfree (name); > > ui_file_rewind (stb->stream); > - pc += gdbarch_print_insn (gdbarch, pc, di); > + if (code) > + { > + CORE_ADDR old_pc = pc; > + bfd_byte data; > + int status; > + pc += gdbarch_print_insn (gdbarch, pc, di); > + for (;old_pc < pc; old_pc++) > + { > + status = (*di->read_memory_func) (old_pc, &data, 1, di); > + if (status != 0) > + (*di->memory_error_func) (status, old_pc, di); > + ui_out_message (uiout, 0, " %02x", (unsigned)data); > + } > + ui_out_text (uiout, "\t"); > + } > + else > + pc += gdbarch_print_insn (gdbarch, pc, di); > ui_out_field_stream (uiout, "inst", stb); > ui_file_rewind (stb->stream); > do_cleanups (ui_out_chain); > @@ -154,7 +170,7 @@ do_mixed_source_and_assembly (struct gdb > struct linetable_entry *le, > CORE_ADDR low, CORE_ADDR high, > struct symtab *symtab, > - int how_many, struct ui_stream *stb) > + int how_many, int code, struct ui_stream *stb) > { > int newlines = 0; > struct dis_line_entry *mle; > @@ -278,7 +294,7 @@ do_mixed_source_and_assembly (struct gdb > > num_displayed += dump_insns (gdbarch, uiout, di, > mle[i].start_pc, mle[i].end_pc, > - how_many, stb); > + how_many, code, stb); > > /* When we've reached the end of the mle array, or we've seen the last > assembly range for this source line, close out the list/tuple. */ > @@ -301,14 +317,15 @@ static void > do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout, > struct disassemble_info * di, > CORE_ADDR low, CORE_ADDR high, > - int how_many, struct ui_stream *stb) > + int how_many, int code, struct ui_stream *stb) > { > int num_displayed = 0; > struct cleanup *ui_out_chain; > > ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns"); > > - num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, stb); > + num_displayed = dump_insns (gdbarch, uiout, di, low, high, how_many, > + code, stb); > > do_cleanups (ui_out_chain); > } > @@ -357,7 +374,7 @@ void > gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, > char *file_string, > int mixed_source_and_assembly, > - int how_many, CORE_ADDR low, CORE_ADDR high) > + int how_many, int code, CORE_ADDR low, CORE_ADDR high) > { > struct ui_stream *stb = ui_out_stream_new (uiout); > struct cleanup *cleanups = make_cleanup_ui_out_stream_delete (stb); > @@ -379,11 +396,11 @@ gdb_disassembly (struct gdbarch *gdbarch > > if (!mixed_source_and_assembly || nlines <= 0 > || symtab == NULL || symtab->linetable == NULL) > - do_assembly_only (gdbarch, uiout, &di, low, high, how_many, stb); > + do_assembly_only (gdbarch, uiout, &di, low, high, how_many, code, stb); > > else if (mixed_source_and_assembly) > do_mixed_source_and_assembly (gdbarch, uiout, &di, nlines, le, low, > - high, symtab, how_many, stb); > + high, symtab, how_many, code, stb); > > do_cleanups (cleanups); > gdb_flush (gdb_stdout); > --- a/disasm.h > +++ b/disasm.h > @@ -25,7 +25,8 @@ struct ui_file; > extern void gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, > char *file_string, > int mixed_source_and_assembly, > - int how_many, CORE_ADDR low, CORE_ADDR high); > + int how_many, int code, CORE_ADDR low, > + CORE_ADDR high); > > /* Print the instruction at address MEMADDR in debugged memory, > on STREAM. Returns the length of the instruction, in bytes, > --- a/mi/mi-cmd-disas.c > +++ b/mi/mi-cmd-disas.c > @@ -156,6 +156,6 @@ mi_cmd_disassemble (char *command, char > > gdb_disassembly (gdbarch, uiout, > file_string, > - mixed_source_and_assembly, how_many, low, high); > + mixed_source_and_assembly, 0, how_many, low, high); > > } > --- a/stack.c > +++ b/stack.c > @@ -481,7 +481,7 @@ static void > gdb_disassembly_stub (void *args) > { > struct gdb_disassembly_stub_args *p = args; > - gdb_disassembly (p->gdbarch, uiout, 0, 0, p->how_many, p->low, p->high); > + gdb_disassembly (p->gdbarch, uiout, 0, 0, 1, p->how_many, p->low, p->high); > } > > /* Use TRY_CATCH to catch the exception from the gdb_disassembly > > > ------------------------------------------------------------------------ > > --- > doc/gdb.texinfo | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > --- a/doc/gdb.texinfo > +++ b/doc/gdb.texinfo > @@ -6177,10 +6177,11 @@ Variables}). > @cindex machine instructions > @cindex listing machine instructions > @item disassemble > -@itemx disassemble /m > +@itemx disassemble /mc > This specialized command dumps a range of memory as machine > instructions. It can also print mixed source+disassembly by specifying > -the @code{/m} modifier. > +the @code{/m} modifier and print binary code by specifying > +the @code{/c}. > 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 ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Add a new modifier /c to "disassemble" command to make it output binary code 2009-07-09 12:22 Add a new modifier /c to "disassemble" command to make it output binary code Hui Zhu ` (2 preceding siblings ...) 2009-07-09 22:00 ` Michael Snyder @ 2009-07-09 23:44 ` Doug Evans 2009-07-10 9:33 ` Eli Zaretskii 2009-07-10 14:34 ` Mark Kettenis 3 siblings, 2 replies; 16+ messages in thread From: Doug Evans @ 2009-07-09 23:44 UTC (permalink / raw) To: Hui Zhu; +Cc: gdb-patches ml On Wed, Jul 8, 2009 at 11:35 PM, Hui Zhu<teawater@gmail.com> wrote: > Hi, > > The objdump will output the binary code when it works but gdb not. > I make a patch to add a new modifier /c to "disassemble" command to > make it output binary code. > Please help me review it. I like the idea. The option to objdump is --[no-]show-raw-insn. The word "raw" is the mnemonic I use to remember the option name. Hence I wonder if it would be easier for users to remember "disassemble /r" than "disassemble /c". [nit picky, I know] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Add a new modifier /c to "disassemble" command to make it output binary code 2009-07-09 23:44 ` Doug Evans @ 2009-07-10 9:33 ` Eli Zaretskii 2009-07-10 14:34 ` Mark Kettenis 1 sibling, 0 replies; 16+ messages in thread From: Eli Zaretskii @ 2009-07-10 9:33 UTC (permalink / raw) To: Doug Evans; +Cc: teawater, gdb-patches > Date: Thu, 9 Jul 2009 15:00:32 -0700 > From: Doug Evans <dje@google.com> > Cc: gdb-patches ml <gdb-patches@sourceware.org> > > The option to objdump is --[no-]show-raw-insn. > The word "raw" is the mnemonic I use to remember the option name. > Hence I wonder if it would be easier for users to remember > "disassemble /r" than "disassemble /c". Yes, and perhaps have "show raw instructions" somewhere in the text of the manual that describes this. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Add a new modifier /c to "disassemble" command to make it output binary code 2009-07-09 23:44 ` Doug Evans 2009-07-10 9:33 ` Eli Zaretskii @ 2009-07-10 14:34 ` Mark Kettenis 1 sibling, 0 replies; 16+ messages in thread From: Mark Kettenis @ 2009-07-10 14:34 UTC (permalink / raw) To: dje; +Cc: teawater, gdb-patches > Date: Thu, 9 Jul 2009 15:00:32 -0700 > From: Doug Evans <dje@google.com> > > On Wed, Jul 8, 2009 at 11:35 PM, Hui Zhu<teawater@gmail.com> wrote: > > Hi, > > > > The objdump will output the binary code when it works but gdb not. > > I make a patch to add a new modifier /c to "disassemble" command to > > make it output binary code. > > Please help me review it. > > I like the idea. > The option to objdump is --[no-]show-raw-insn. > The word "raw" is the mnemonic I use to remember the option name. > Hence I wonder if it would be easier for users to remember > "disassemble /r" than "disassemble /c". > [nit picky, I know] Actually I think you have a point here. The term "code" is horribly overloaded, so I felt a bit uncomfortable with the fact that the newly added argument to print_disassembly carried that name: >> 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) If people agree with Doug and me that /r is better than /c, can the code be changed to match this? ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2009-07-18 3:04 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-07-09 12:22 Add a new modifier /c to "disassemble" command to make it output binary code Hui Zhu 2009-07-09 19:22 ` Tom Tromey 2009-07-09 19:40 ` Eli Zaretskii 2009-07-11 9:28 ` Hui Zhu 2009-07-11 12:42 ` Eli Zaretskii 2009-07-11 14:15 ` Hui Zhu 2009-07-11 17:54 ` Eli Zaretskii 2009-07-11 17:59 ` Hui Zhu 2009-07-11 18:16 ` Regression for mi-disassemble.exp [Re: Add a new modifier /c to "disassemble" command to make it output binary code] Jan Kratochvil 2009-07-17 17:09 ` [commit] Fix mi-disassemble.exp regression Ulrich Weigand 2009-07-18 5:45 ` Hui Zhu 2009-07-09 19:53 ` Add a new modifier /c to "disassemble" command to make it output binary code Eli Zaretskii 2009-07-09 22:00 ` Michael Snyder 2009-07-09 23:44 ` Doug Evans 2009-07-10 9:33 ` Eli Zaretskii 2009-07-10 14:34 ` Mark Kettenis
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox