* cli/cli-cmds.c (disassemble_command): Add support of disassemble
authorCheng Renquan <crq@sourceware.org>
Tue, 27 Jul 2010 20:33:40 +0000 (20:33 +0000)
committerCheng Renquan <crq@sourceware.org>
Tue, 27 Jul 2010 20:33:40 +0000 (20:33 +0000)
"start,+length" form of arguments.

gdb/ChangeLog
gdb/NEWS
gdb/cli/cli-cmds.c
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo

index 1907943..008c2b3 100644 (file)
@@ -1,3 +1,11 @@
+2010-07-28  CHENG Renquan  <rqcheng@smu.edu.sg>
+
+       * cli/cli-cmds.c (disassemble_command): Add support of disassemble
+       "start,+length" form of arguments.
+       * NEWS: Add "Changed commands" (disassemble) section for "Changes
+       since GDB 7.1"; and merge two separated paragraphs of disassemble
+       description in "Changes in GDB 7.0".
+
 2010-07-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * top.c (input_from_terminal_p): Return 0 on BATCH_FLAG.
index 47f1c13..6748449 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -192,6 +192,11 @@ strace FN | FILE:LINE | *ADDR | -m MARKER_ID
   Define a static tracepoint by probing a marker at the given
   function, line, address, or marker ID.
 
+* Changed commands
+
+disassemble
+  The disassemble command now supports "start,+length" form of two arguments.
+
 * Python scripting
 
 ** GDB now provides a new directory location, called the python directory,
@@ -541,8 +546,9 @@ or the "condition" command is available.  GDB sends the condition to
 the target for evaluation using the same bytecode format as is used
 for tracepoint actions.
 
-* "disassemble" command with a /r modifier, print the raw instructions
-in hex as well as in symbolic form.
+* The disassemble command now supports: an optional /r modifier, print the
+raw instructions in hex as well as in symbolic form, and an optional /m
+modifier to print mixed source+assembly.
 
 * Process record and replay
 
@@ -634,9 +640,6 @@ qXfer:siginfo:write
   packet that permited the stub to pass a process id was removed.
   Remote servers should use the `T' stop reply packet instead.
 
-* The "disassemble" command now supports an optional /m modifier to print mixed
-source+assembly.
-
 * GDB now supports multiple function calling conventions according to the
 DWARF-2 DW_AT_calling_convention function attribute.
   
index 16506d1..e5df8f5 100644 (file)
@@ -1108,8 +1108,9 @@ disassemble_current_function (int flags)
        - dump the assembly code for the function of the current pc
      disassemble [/mr] addr
        - dump the assembly code for the function at ADDR
-     disassemble [/mr] low high
-       - dump the assembly code in the range [LOW,HIGH)
+     disassemble [/mr] low,high
+     disassemble [/mr] low,+length
+       - dump the assembly code in the range [LOW,HIGH), or [LOW,LOW+length)
 
    A /m modifier will include source code with the assembly.
    A /r modifier will include raw instructions in hex with the assembly.  */
@@ -1180,8 +1181,18 @@ disassemble_command (char *arg, int from_tty)
   else
     {
       /* Two arguments.  */
+      int incl_flag = 0;
       low = pc;
+      while (isspace (*arg))
+       arg++;
+      if (arg[0] == '+')
+       {
+         ++arg;
+         incl_flag = 1;
+       }
       high = parse_and_eval_address (arg);
+      if (incl_flag)
+       high += low;
     }
 
   print_disassembly (gdbarch, name, low, high, flags);
@@ -1615,7 +1626,8 @@ 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 instructions in hex are included.\n\
 With a single argument, the function surrounding that address is dumped.\n\
-Two arguments (separated by a comma) are taken as a range of memory to dump."));
+Two arguments (separated by a comma) are taken as a range of memory to dump,\n\
+  in the form of \"start,end\", or \"start,+length\"."));
   set_cmd_completer (c, location_completer);
   if (xdb_commands)
     add_com_alias ("va", "disassemble", class_xdb, 0);
index 8c249ef..8d3e265 100644 (file)
@@ -1,3 +1,8 @@
+2010-07-28  CHENG Renquan  <rqcheng@smu.edu.sg>
+
+       * gdb.texinfo (Machine Code): Update description of two forms of
+       arguments, and add new example to demonstrate the new form.
+
 2010-07-27  Phil Muldoon  <pmuldoon@redhat.com>
 
        * gdb.texinfo (Values From Inferior): Add value inferior function
index fa583aa..dfd6ffa 100644 (file)
@@ -6742,9 +6742,19 @@ program counter of the selected frame.  A single argument to this
 command is a program counter value; @value{GDBN} dumps the function
 surrounding this value.  When two arguments are given, they should
 be separated by a comma, possibly surrounded by whitespace.  The
-arguments specify a range of addresses (first inclusive, second exclusive)
-to dump.  In that case, the name of the function is also printed (since
-there could be several functions in the given range).
+arguments specify a range of addresses to dump, in one of two forms:
+
+@table @code
+@item @var{start},@var{end}
+the addresses from @var{start} (inclusive) to @var{end} (exclusive)
+@item @var{start},+@var{length}
+the addresses from @var{start} (inclusive) to
+@code{@var{start}+@var{length}} (exclusive).
+@end table
+
+@noindent
+When 2 arguments are specified, the name of the function is also
+printed (since there could be several functions in the given range).
 
 The argument(s) can be any expression yielding a numeric value, such as
 @samp{0x32c4}, @samp{&main+10} or @samp{$pc - 8}.
@@ -6796,6 +6806,18 @@ Dump of assembler code for function main:
 End of assembler dump.
 @end smallexample
 
+Here is another example showing raw instructions in hex for AMD x86-64,
+
+@smallexample
+(gdb) disas /r 0x400281,+10
+Dump of assembler code from 0x400281 to 0x40028b:
+   0x0000000000400281:  38 36  cmp    %dh,(%rsi)
+   0x0000000000400283:  2d 36 34 2e 73 sub    $0x732e3436,%eax
+   0x0000000000400288:  6f     outsl  %ds:(%rsi),(%dx)
+   0x0000000000400289:  2e 32 00       xor    %cs:(%rax),%al
+End of assembler dump.
+@end smallexample
+
 Some architectures have more than one commonly-used set of instruction
 mnemonics or other syntax.