[PATCH] Make -e optional for -data-disassemble
Brett Lee
brett.lee.nps@gmail.com
Tue Apr 3 00:31:00 GMT 2012
Thanks. I've attached the updated patch with 3 separate ChangeLog files.
I have not signed any copyright paperwork for gdb. Can you email me
the forms, so I can sign and fax them back?
Sincerely,
Brett Lee
On Mon, Mar 26, 2012 at 1:18 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Brett" == Brett Lee <brett.lee.nps@gmail.com> writes:
>
> Brett> Sorry, I forgot to add the [PATCH] prefix in the subject.
>
> The patch looks good to me.
>
> Do you have your copyright assignment paperwork in place?
>
> Brett> 2012-03-09 Brett Lee <brett.lee.nps@gmail.com>
>
> Brett> * mi-cmd-disas.c (mi_cmd_disassemble): Allow -s option without
> Brett> -e option. Automatically stops at the end of the function
> Brett> containing the start address or displays an error if the address
> Brett> is not inside any function.
>
> Brett> * mi-disassemble.exp (test_disassembly_only): Added test case
> Brett> for -data-disassemble with only -s option.
>
> Brett> * gdb.texinfo: Updated documentation for -data-disassemble to
> Brett> explain and demonstrate the use case with only the -s option.
>
> FYI, these each have to go in separate ChangeLog files.
>
> Tom
-------------- next part --------------
2012-03-09 Brett Lee <brett.lee.nps@gmail.com>
* mi-cmd-disas.c (mi_cmd_disassemble): Allow -s option without
-e option. Automatically stops at the end of the function
containing the start address or displays an error if the address
is not inside any function.
-------------- next part --------------
2012-03-09 Brett Lee <brett.lee.nps@gmail.com>
* gdb.texinfo: Updated documentation for -data-disassemble to
explain and demonstrate the use case with only the -s option.
-------------- next part --------------
2012-03-09 Brett Lee <brett.lee.nps@gmail.com>
* mi-disassemble.exp (test_disassembly_only): Added test case
for -data-disassemble with only -s option.
-------------- next part --------------
--- ./gdb/mi/mi-cmd-disas.c~ 2012-03-14 20:00:23.000000000 -0700
+++ ./gdb/mi/mi-cmd-disas.c 2012-03-16 20:23:29.000000000 -0700
@@ -35,6 +35,12 @@
or:
+ START-ADDRESS: address to start the disassembly at.
+ (Automatically stops at the end of the function containing
+ START-ADDRESS.)
+
+ or:
+
FILENAME: The name of the file where we want disassemble from.
LINE: The line around which we want to disassemble. It will
disassemble the function that contins that line.
@@ -128,18 +134,24 @@
argv += oind;
argc -= oind;
+ if (start_seen && !end_seen && !file_seen && !line_seen && !num_seen)
+ {
+ if (!find_pc_partial_function (low, NULL, NULL, &high))
+ error (_("-data-disassemble: "
+ "No function contains specified address"));
+ else
+ end_seen = 1;
+ }
+
/* Allow only filename + linenum (with how_many which is not
required) OR start_addr + end_addr. */
if (!((line_seen && file_seen && num_seen && !start_seen && !end_seen)
|| (line_seen && file_seen && !num_seen && !start_seen && !end_seen)
- || (!line_seen && !file_seen && !num_seen && start_seen && end_seen)))
- error (_("-data-disassemble: Usage: ( [-f filename -l linenum [-n "
- "howmany]] | [-s startaddr -e endaddr]) [--] mode."));
-
- if (argc != 1)
+ || (!line_seen && !file_seen && !num_seen && start_seen && end_seen))
+ || argc != 1)
error (_("-data-disassemble: Usage: [-f filename -l linenum "
- "[-n howmany]] [-s startaddr -e endaddr] [--] mode."));
+ "[-n howmany]] [-s startaddr [-e endaddr]] [--] mode."));
mode = atoi (argv[0]);
if (mode < 0 || mode > 3)
-------------- next part --------------
--- gdb/doc/gdb.texinfo~ 2012-03-14 20:00:23.000000000 -0700
+++ gdb/doc/gdb.texinfo 2012-03-16 20:18:58.000000000 -0700
@@ -29472,7 +29472,7 @@
@smallexample
-data-disassemble
- [ -s @var{start-addr} -e @var{end-addr} ]
+ [ -s @var{start-addr} [ -e @var{end-addr} ] ]
| [ -f @var{filename} -l @var{linenum} [ -n @var{lines} ] ]
-- @var{mode}
@end smallexample
@@ -29484,7 +29484,8 @@
@item @var{start-addr}
is the beginning address (or @code{$pc})
@item @var{end-addr}
-is the end address
+is the end address. If this is omitted, then disassembly stops at the
+end of the function containing @var{start-addr}.
@item @var{filename}
is the name of the file to disassemble
@item @var{linenum}
@@ -29544,6 +29545,21 @@
(gdb)
@end smallexample
+@smallexample
+(gdb)
+-data-disassemble -s $pc -- 0
+^done,
+asm_insns=[
+@{address="0x000107c0",func-name="main",offset="4",
+inst="mov 2, %o0"@},
+@{address="0x000107c4",func-name="main",offset="8",
+inst="sethi %hi(0x11800), %o2"@},
+[@dots{}]
+@{address="0x0001081c",func-name="main",offset="96",inst="ret "@},
+@{address="0x00010820",func-name="main",offset="100",inst="restore "@}]
+(gdb)
+@end smallexample
+
Disassemble the whole @code{main} function. Line 32 is part of
@code{main}.
-------------- next part --------------
--- ./gdb/testsuite/gdb.mi/mi-disassemble.exp~ 2012-03-14 20:00:25.000000000 -0700
+++ ./gdb/testsuite/gdb.mi/mi-disassemble.exp 2012-03-16 20:15:31.000000000 -0700
@@ -58,6 +58,11 @@
mi_gdb_test "222-data-disassemble -f basics.c -l $line_main_body -- 0" \
"222\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"0\",inst=\".*\"\},.*,\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}\\\]" \
"data-disassemble file & line, assembly only"
+
+ mi_gdb_test "print/x \$pc" "" ""
+ mi_gdb_test "333-data-disassemble -s \$pc -- 0" \
+ "333\\^done,asm_insns=\\\[\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\},\{address=\"$hex\",func-name=\"main\",offset=\"$decimal\",inst=\".*\"\}.*\]" \
+ "data-disassemble from pc to end of function"
}
proc test_disassembly_with_opcodes {} {
More information about the Gdb-patches
mailing list