public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] disassemble support start,+length format
@ 2010-04-08 15:09 crquan
  2010-04-09  2:16 ` Hui Zhu
                   ` (3 more replies)
  0 siblings, 4 replies; 25+ messages in thread
From: crquan @ 2010-04-08 15:09 UTC (permalink / raw)
  To: gdb-patches

From: CHENG Renquan <rqcheng@smu.edu.sg>

add new support for disassemble by "start,+length" format

 gdb/cli/cli-cmds.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

--- gdb/cli/cli-cmds.c.orig	2010-01-18 14:25:22.000000000 +0800
+++ gdb/cli/cli-cmds.c	2010-04-08 23:06:25.816107001 +0800
@@ -1045,8 +1045,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.  */
@@ -1117,8 +1118,16 @@ disassemble_command (char *arg, int from
   else
     {
       /* Two arguments.  */
+      int incl_flag = 0;
+
       low = pc;
+      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);
@@ -1546,7 +1555,8 @@ Default is the function surrounding the 
 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);

--
git v1.7.0.4, rqcheng at smu edu sg

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-04-08 15:09 [PATCH] disassemble support start,+length format crquan
@ 2010-04-09  2:16 ` Hui Zhu
  2010-04-15  7:44 ` crquan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 25+ messages in thread
From: Hui Zhu @ 2010-04-09  2:16 UTC (permalink / raw)
  To: crquan; +Cc: gdb-patches, Joel Brobecker, Eli Zaretskii

Cool.  I like this patch.

I think what we need a changelog like:
2010-04-08  H.J. Lu  <hongjiu.lu@intel.com>

	* i387-tdep.c (i387_collect_xsave): Replace abort with
	internal_error.

And we need update this change to doc in doc/gdb.texinfo and new entry in NEWS.

Thanks,
Hui

On Thu, Apr 8, 2010 at 23:14,  <crquan@gmail.com> wrote:
> From: CHENG Renquan <rqcheng@smu.edu.sg>
>
> add new support for disassemble by "start,+length" format
>
>  gdb/cli/cli-cmds.c |   16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
>
> --- gdb/cli/cli-cmds.c.orig     2010-01-18 14:25:22.000000000 +0800
> +++ gdb/cli/cli-cmds.c  2010-04-08 23:06:25.816107001 +0800
> @@ -1045,8 +1045,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.  */
> @@ -1117,8 +1118,16 @@ disassemble_command (char *arg, int from
>   else
>     {
>       /* Two arguments.  */
> +      int incl_flag = 0;
> +
>       low = pc;
> +      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);
> @@ -1546,7 +1555,8 @@ Default is the function surrounding the
>  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);
>
> --
> git v1.7.0.4, rqcheng at smu edu sg
>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH] disassemble support start,+length format
  2010-04-08 15:09 [PATCH] disassemble support start,+length format crquan
  2010-04-09  2:16 ` Hui Zhu
@ 2010-04-15  7:44 ` crquan
  2010-04-15 17:08   ` Eli Zaretskii
  2010-04-16  1:36 ` crquan
  2010-04-20 18:43 ` crquan
  3 siblings, 1 reply; 25+ messages in thread
From: crquan @ 2010-04-15  7:44 UTC (permalink / raw)
  To: gdb-patches, Tom Tromey; +Cc: Hui Zhu, Joel Brobecker, Eli Zaretskii

From: CHENG Renquan <rqcheng@smu.edu.sg>

add new support for disassemble by "start,+length" format;

update ChangeLog,NEWS,doc/gdb.texinfo accordingly.

BTW, I found two disassemble Changes in GDB 7.0 in NEWS, separated in two
paragraphs, so I merged them into one.

 gdb-7.1.50.20100415/gdb/ChangeLog       |    8 +++++++-
 gdb-7.1.50.20100415/gdb/NEWS            |   13 ++++++++-----
 gdb-7.1.50.20100415/gdb/cli/cli-cmds.c  |   18 +++++++++++++++---
 gdb-7.1.50.20100415/gdb/doc/gdb.texinfo |   28 ++++++++++++++++++++++++++--
 4 files changed, 56 insertions(+), 11 deletions(-)

Index: gdb-7.1.50.20100415/gdb/ChangeLog
===================================================================
--- gdb-7.1.50.20100415.orig/gdb/ChangeLog
+++ gdb-7.1.50.20100415/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-15  CHENG Renquan <rqcheng@smu.edu.sg>
+
+	* gdb/cli/cli-cmds.c (disassemble_command): Add support of disassemble
+	"start,+length" form of arguments.
+	* gdb/doc/gdb.texinfo: Update disassemble description and add new
+	examples.
+
 2010-04-14  Daniel Jacobowitz  <dan@codesourcery.com>
 	    Pedro Alves  <pedro@codesourcery.com>
 
@@ -62,7 +69,6 @@
 	* python/py-value.c (valpy_cast, valpy_length, valpy_getitem)
 	(valpy_richcompare, valpy_int, valpy_long, valpy_float): Likewise.
 
-
 2010-04-14  Phil Muldoon  <pmuldoon@redhat.com>
 
 	PR python/11381
Index: gdb-7.1.50.20100415/gdb/NEWS
===================================================================
--- gdb-7.1.50.20100415.orig/gdb/NEWS
+++ gdb-7.1.50.20100415/gdb/NEWS
@@ -44,6 +44,11 @@ regular breakpoints.
 
 ARM Symbian			arm*-*-symbianelf*
 
+* Changed commands
+
+disassemble
+  The disassemble command now supports "start,+length" form of two arguments.
+
 *** Changes in GDB 7.1
 
 * C++ Improvements
@@ -339,8 +344,9 @@ or the "condition" command is available.
 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
 
@@ -432,9 +438,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: gdb-7.1.50.20100415/gdb/cli/cli-cmds.c
===================================================================
--- gdb-7.1.50.20100415.orig/gdb/cli/cli-cmds.c
+++ gdb-7.1.50.20100415/gdb/cli/cli-cmds.c
@@ -1047,8 +1047,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.  */
@@ -1119,8 +1120,18 @@ disassemble_command (char *arg, int from
   else
     {
       /* Two arguments.  */
+      int incl_flag = 0;
       low = pc;
+      while (*arg == ' ' || *arg == '\t')
+	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);
@@ -1548,7 +1559,8 @@ Default is the function surrounding the 
 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: gdb-7.1.50.20100415/gdb/doc/gdb.texinfo
===================================================================
--- gdb-7.1.50.20100415.orig/gdb/doc/gdb.texinfo
+++ gdb-7.1.50.20100415/gdb/doc/gdb.texinfo
@@ -6550,8 +6550,19 @@ command is a program counter value; @val
 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}.
@@ -6603,6 +6614,19 @@ 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 main,+20
+Dump of assembler code from 0x450670 to 0x450684:
+   0x0000000000450670 <main+0>:	 48 83 ec 28	sub    $0x28,%rsp
+   0x0000000000450674 <main+4>:	 48 c7 04 24 00 00 00 00	movq   $0x0,(%rsp)
+   0x000000000045067c <main+12>:	 89 3c 24	mov    %edi,(%rsp)
+   0x000000000045067f <main+15>:	 48 89 e7	mov    %rsp,%rdi
+   0x0000000000450682 <main+18>:	 48 c7 44 24 10 00 00 00 00	movq   $0x0,0x10(%rsp)
+End of assembler dump.
+@end smallexample
+
 Some architectures have more than one commonly-used set of instruction
 mnemonics or other syntax.
 
--
git v1.7.0.5, rqcheng at smu edu sg

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-04-15  7:44 ` crquan
@ 2010-04-15 17:08   ` Eli Zaretskii
  2010-04-15 17:14     ` Nathan Froyd
  0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2010-04-15 17:08 UTC (permalink / raw)
  To: crquan; +Cc: gdb-patches, tromey, teawater, brobecker

> From: crquan@gmail.com
> Cc: Hui Zhu <teawater@gmail.com>,
> 	Joel Brobecker <brobecker@adacore.com>,
> 	Eli Zaretskii <eliz@gnu.org>
> Date: Thu, 15 Apr 2010 15:50:36 +0800
> 
> add new support for disassemble by "start,+length" format;
> 
> update ChangeLog,NEWS,doc/gdb.texinfo accordingly.
> BTW, I found two disassemble Changes in GDB 7.0 in NEWS, separated in two
> paragraphs, so I merged them into one.

Thanks.

>  gdb-7.1.50.20100415/gdb/ChangeLog       |    8 +++++++-
>  gdb-7.1.50.20100415/gdb/NEWS            |   13 ++++++++-----
>  gdb-7.1.50.20100415/gdb/cli/cli-cmds.c  |   18 +++++++++++++++---
>  gdb-7.1.50.20100415/gdb/doc/gdb.texinfo |   28 ++++++++++++++++++++++++++--
>  4 files changed, 56 insertions(+), 11 deletions(-)

Please also add an entry in gdb/doc/ChangeLog regarding the changes in
gdb/doc/gdb.texinfo.

> +@smallexample
> +(gdb) disas /r main,+20
> +Dump of assembler code from 0x450670 to 0x450684:
> +   0x0000000000450670 <main+0>:	 48 83 ec 28	sub    $0x28,%rsp
> +   0x0000000000450674 <main+4>:	 48 c7 04 24 00 00 00 00	movq   $0x0,(%rsp)
> +   0x000000000045067c <main+12>:	 89 3c 24	mov    %edi,(%rsp)
> +   0x000000000045067f <main+15>:	 48 89 e7	mov    %rsp,%rdi
> +   0x0000000000450682 <main+18>:	 48 c7 44 24 10 00 00 00 00	movq   $0x0,0x10(%rsp)
> +End of assembler dump.
> +@end smallexample

This is okay, but any line inside @smallexample block that is longer
than 72 characters will overflow the page margins in the printed
version of the manual.  So could you perhaps select an example with
shorter lines?

Okay with that change.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-04-15 17:08   ` Eli Zaretskii
@ 2010-04-15 17:14     ` Nathan Froyd
  2010-04-15 17:38       ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Nathan Froyd @ 2010-04-15 17:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: crquan, gdb-patches, tromey, teawater, brobecker

On Thu, Apr 15, 2010 at 08:08:26PM +0300, Eli Zaretskii wrote:
> > +@smallexample
> > +(gdb) disas /r main,+20
> > +Dump of assembler code from 0x450670 to 0x450684:
> > +   0x0000000000450670 <main+0>:	 48 83 ec 28	sub    $0x28,%rsp
> > +   0x0000000000450674 <main+4>:	 48 c7 04 24 00 00 00 00	movq   $0x0,(%rsp)
> > +   0x000000000045067c <main+12>:	 89 3c 24	mov    %edi,(%rsp)
> > +   0x000000000045067f <main+15>:	 48 89 e7	mov    %rsp,%rdi
> > +   0x0000000000450682 <main+18>:	 48 c7 44 24 10 00 00 00 00	movq   $0x0,0x10(%rsp)
> > +End of assembler dump.
> > +@end smallexample
> 
> This is okay, but any line inside @smallexample block that is longer
> than 72 characters will overflow the page margins in the printed
> version of the manual.  So could you perhaps select an example with
> shorter lines?

Disassembling x86 code, rather than x86-64 code, would help out quite a bit.

-Nathan

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-04-15 17:14     ` Nathan Froyd
@ 2010-04-15 17:38       ` Eli Zaretskii
  0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2010-04-15 17:38 UTC (permalink / raw)
  To: Nathan Froyd; +Cc: crquan, gdb-patches, tromey, teawater, brobecker

> Date: Thu, 15 Apr 2010 10:14:32 -0700
> From: Nathan Froyd <froydnj@codesourcery.com>
> Cc: crquan@gmail.com, gdb-patches@sourceware.org, tromey@redhat.com, 	teawater@gmail.com, brobecker@adacore.com
> 
> On Thu, Apr 15, 2010 at 08:08:26PM +0300, Eli Zaretskii wrote:
> > > +@smallexample
> > > +(gdb) disas /r main,+20
> > > +Dump of assembler code from 0x450670 to 0x450684:
> > > +   0x0000000000450670 <main+0>:	 48 83 ec 28	sub    $0x28,%rsp
> > > +   0x0000000000450674 <main+4>:	 48 c7 04 24 00 00 00 00	movq   $0x0,(%rsp)
> > > +   0x000000000045067c <main+12>:	 89 3c 24	mov    %edi,(%rsp)
> > > +   0x000000000045067f <main+15>:	 48 89 e7	mov    %rsp,%rdi
> > > +   0x0000000000450682 <main+18>:	 48 c7 44 24 10 00 00 00 00	movq   $0x0,0x10(%rsp)
> > > +End of assembler dump.
> > > +@end smallexample
> > 
> > This is okay, but any line inside @smallexample block that is longer
> > than 72 characters will overflow the page margins in the printed
> > version of the manual.  So could you perhaps select an example with
> > shorter lines?
> 
> Disassembling x86 code, rather than x86-64 code, would help out quite a bit.

Right, but even in this example, only the 2 movq instructions present
a problem.  The other instructions are okay.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH] disassemble support start,+length format
  2010-04-08 15:09 [PATCH] disassemble support start,+length format crquan
  2010-04-09  2:16 ` Hui Zhu
  2010-04-15  7:44 ` crquan
@ 2010-04-16  1:36 ` crquan
  2010-04-20 15:43   ` Tom Tromey
  2010-04-20 18:43 ` crquan
  3 siblings, 1 reply; 25+ messages in thread
From: crquan @ 2010-04-16  1:36 UTC (permalink / raw)
  To: gdb-patches, Tom Tromey, Eli Zaretskii, Nathan Froyd
  Cc: Hui Zhu, Joel Brobecker

From: CHENG Renquan <rqcheng@smu.edu.sg>

add new support for disassemble by "start,+length" format;

update ChangeLog,NEWS,doc/gdb.texinfo accordingly.

BTW, I found two disassemble Changes in GDB 7.0 in NEWS, separated in two
paragraphs, so I merged them into one.

 gdb/ChangeLog       |    8 +++++++-
 gdb/NEWS            |   13 ++++++++-----
 gdb/cli/cli-cmds.c  |   18 +++++++++++++++---
 gdb/doc/gdb.texinfo |   27 +++++++++++++++++++++++++--
 gdb/doc/ChangeLog   |    5 +++++
 5 files changed, 60 insertions(+), 11 deletions(-)

Index: gdb-7.1.50.20100415/gdb/ChangeLog
===================================================================
--- gdb-7.1.50.20100415.orig/gdb/ChangeLog
+++ gdb-7.1.50.20100415/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-15  CHENG Renquan <rqcheng@smu.edu.sg>
+
+	* gdb/cli/cli-cmds.c (disassemble_command): Add support of disassemble
+	"start,+length" form of arguments.
+	* gdb/doc/gdb.texinfo: Update disassemble description of two forms of
+	arguments, and add new example to demonstrate the new form.
+
 2010-04-14  Daniel Jacobowitz  <dan@codesourcery.com>
 	    Pedro Alves  <pedro@codesourcery.com>
 
@@ -62,7 +69,6 @@
 	* python/py-value.c (valpy_cast, valpy_length, valpy_getitem)
 	(valpy_richcompare, valpy_int, valpy_long, valpy_float): Likewise.
 
-
 2010-04-14  Phil Muldoon  <pmuldoon@redhat.com>
 
 	PR python/11381
Index: gdb-7.1.50.20100415/gdb/NEWS
===================================================================
--- gdb-7.1.50.20100415.orig/gdb/NEWS
+++ gdb-7.1.50.20100415/gdb/NEWS
@@ -44,6 +44,11 @@ regular breakpoints.
 
 ARM Symbian			arm*-*-symbianelf*
 
+* Changed commands
+
+disassemble
+  The disassemble command now supports "start,+length" form of two arguments.
+
 *** Changes in GDB 7.1
 
 * C++ Improvements
@@ -339,8 +344,9 @@ or the "condition" command is available.
 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
 
@@ -432,9 +438,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: gdb-7.1.50.20100415/gdb/cli/cli-cmds.c
===================================================================
--- gdb-7.1.50.20100415.orig/gdb/cli/cli-cmds.c
+++ gdb-7.1.50.20100415/gdb/cli/cli-cmds.c
@@ -1047,8 +1047,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.  */
@@ -1119,8 +1120,18 @@ disassemble_command (char *arg, int from
   else
     {
       /* Two arguments.  */
+      int incl_flag = 0;
       low = pc;
+      while (*arg == ' ' || *arg == '\t')
+	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);
@@ -1548,7 +1559,8 @@ Default is the function surrounding the 
 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: gdb-7.1.50.20100415/gdb/doc/gdb.texinfo
===================================================================
--- gdb-7.1.50.20100415.orig/gdb/doc/gdb.texinfo
+++ gdb-7.1.50.20100415/gdb/doc/gdb.texinfo
@@ -6550,8 +6550,19 @@ command is a program counter value; @val
 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}.
@@ -6603,6 +6614,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.
 
Index: gdb-7.1.50.20100415/gdb/doc/ChangeLog
===================================================================
--- gdb-7.1.50.20100415.orig/gdb/doc/ChangeLog
+++ gdb-7.1.50.20100415/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2010-04-16  CHENG Renquan <rqcheng@smu.edu.sg>
+
+	* gdb.texinfo (Disassemble Command): Update description of two forms
+	of arguments, and add new example to demonstrate the new form.
+
 2010-04-14  Phil Muldoon  <pmuldoon@redhat.com>
 
 	* gdb.texinfo (Pretty Printing): Document behaviour when to_string

--
git v1.7.0.5, rqcheng at smu edu sg

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-04-16  1:36 ` crquan
@ 2010-04-20 15:43   ` Tom Tromey
  0 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2010-04-20 15:43 UTC (permalink / raw)
  To: crquan; +Cc: gdb-patches, Eli Zaretskii, Nathan Froyd, Hui Zhu, Joel Brobecker

>>>>> ">" == Cheng Renquan <crquan@gmail.com> writes:

>> +2010-04-15  CHENG Renquan <rqcheng@smu.edu.sg>
>> +
>> +	* gdb/cli/cli-cmds.c (disassemble_command): Add support of disassemble
>> +	"start,+length" form of arguments.
>> +	* gdb/doc/gdb.texinfo: Update disassemble description of two forms of
>> +	arguments, and add new example to demonstrate the new form.

A couple notes on the ChangeLog entry.

First, file names should be relative to the directory holding the
ChangeLog file.  So, the leading "gdb/" should be removed.

Second, doc/ has its own ChangeLog, so you don't need an entry for it in
gdb/ChangeLog.

Third, the NEWS change should be mentioned.

This patch is ok with those updates, once your paperwork is all done.
Be sure to let us know when that happens.

Tom

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH] disassemble support start,+length format
  2010-04-08 15:09 [PATCH] disassemble support start,+length format crquan
                   ` (2 preceding siblings ...)
  2010-04-16  1:36 ` crquan
@ 2010-04-20 18:43 ` crquan
  2010-04-30 14:21   ` Hui Zhu
  2010-07-09  2:53   ` crquan
  3 siblings, 2 replies; 25+ messages in thread
From: crquan @ 2010-04-20 18:43 UTC (permalink / raw)
  To: gdb-patches, Tom Tromey, Eli Zaretskii, Nathan Froyd
  Cc: Hui Zhu, Joel Brobecker

From: CHENG Renquan <rqcheng@smu.edu.sg>

add new support for disassemble by "start,+length" format;

update ChangeLog,NEWS,doc/gdb.texinfo accordingly.

BTW, I found two disassemble Changes in GDB 7.0 in NEWS, separated in two
paragraphs, so I merged them into one.

 gdb/ChangeLog       |    8 ++++++++
 gdb/NEWS            |   13 ++++++++-----
 gdb/cli/cli-cmds.c  |   18 +++++++++++++++---
 gdb/doc/ChangeLog   |    5 +++++
 gdb/doc/gdb.texinfo |   27 +++++++++++++++++++++++++--
 5 files changed, 61 insertions(+), 10 deletions(-)

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.11645
diff -u -p -r1.11645 ChangeLog
--- gdb/ChangeLog	20 Apr 2010 17:33:13 -0000	1.11645
+++ gdb/ChangeLog	20 Apr 2010 18:26:10 -0000
@@ -1,3 +1,11 @@
+2010-04-21  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-04-20  Tom Tromey  <tromey@redhat.com>
 
 	* dwarf2-frame.c (decode_frame_entry_1): Handle CIE version 4.
Index: gdb/NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.373
diff -u -p -r1.373 NEWS
--- gdb/NEWS	19 Apr 2010 00:48:43 -0000	1.373
+++ gdb/NEWS	20 Apr 2010 18:26:13 -0000
@@ -76,6 +76,11 @@ regular breakpoints.
 
 ARM Symbian			arm*-*-symbianelf*
 
+* Changed commands
+
+disassemble
+  The disassemble command now supports "start,+length" form of two arguments.
+
 *** Changes in GDB 7.1
 
 * C++ Improvements
@@ -371,8 +376,9 @@ or the "condition" command is available.
 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
 
@@ -464,9 +470,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: gdb/cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.101
diff -u -p -r1.101 cli-cmds.c
--- gdb/cli/cli-cmds.c	15 Apr 2010 17:45:52 -0000	1.101
+++ gdb/cli/cli-cmds.c	20 Apr 2010 18:26:15 -0000
@@ -1105,8 +1105,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.  */
@@ -1177,8 +1178,18 @@ disassemble_command (char *arg, int from
   else
     {
       /* Two arguments.  */
+      int incl_flag = 0;
       low = pc;
+      while (*arg == ' ' || *arg == '\t')
+	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);
@@ -1610,7 +1621,8 @@ Default is the function surrounding the 
 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: gdb/doc/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/doc/ChangeLog,v
retrieving revision 1.1051
diff -u -p -r1.1051 ChangeLog
--- gdb/doc/ChangeLog	19 Apr 2010 01:08:25 -0000	1.1051
+++ gdb/doc/ChangeLog	20 Apr 2010 18:26:19 -0000
@@ -1,3 +1,8 @@
+2010-04-21  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-04-19  Pedro Alves  <pedro@codesourcery.com>
 
 	PR breakpoints/8554.
Index: gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.708
diff -u -p -r1.708 gdb.texinfo
--- gdb/doc/gdb.texinfo	19 Apr 2010 00:48:44 -0000	1.708
+++ gdb/doc/gdb.texinfo	20 Apr 2010 18:26:40 -0000
@@ -6576,8 +6576,19 @@ command is a program counter value; @val
 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}.
@@ -6629,6 +6640,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.
 
--
git v1.7.0.5, rqcheng at smu edu sg

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-04-20 18:43 ` crquan
@ 2010-04-30 14:21   ` Hui Zhu
  2010-07-09  2:53   ` crquan
  1 sibling, 0 replies; 25+ messages in thread
From: Hui Zhu @ 2010-04-30 14:21 UTC (permalink / raw)
  To: crquan
  Cc: gdb-patches, Tom Tromey, Eli Zaretskii, Nathan Froyd, Joel Brobecker

On Wed, Apr 21, 2010 at 02:39,  <crquan@gmail.com> wrote:
> From: CHENG Renquan <rqcheng@smu.edu.sg>
>
> add new support for disassemble by "start,+length" format;
>
> update ChangeLog,NEWS,doc/gdb.texinfo accordingly.
>
> BTW, I found two disassemble Changes in GDB 7.0 in NEWS, separated in two
> paragraphs, so I merged them into one.
>
>  gdb/ChangeLog       |    8 ++++++++
>  gdb/NEWS            |   13 ++++++++-----
>  gdb/cli/cli-cmds.c  |   18 +++++++++++++++---
>  gdb/doc/ChangeLog   |    5 +++++
>  gdb/doc/gdb.texinfo |   27 +++++++++++++++++++++++++--
>  5 files changed, 61 insertions(+), 10 deletions(-)
>
> Index: gdb/ChangeLog
> ===================================================================
> RCS file: /cvs/src/src/gdb/ChangeLog,v
> retrieving revision 1.11645
> diff -u -p -r1.11645 ChangeLog
> --- gdb/ChangeLog       20 Apr 2010 17:33:13 -0000      1.11645
> +++ gdb/ChangeLog       20 Apr 2010 18:26:10 -0000
> @@ -1,3 +1,11 @@
> +2010-04-21  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-04-20  Tom Tromey  <tromey@redhat.com>
>
>        * dwarf2-frame.c (decode_frame_entry_1): Handle CIE version 4.
> Index: gdb/NEWS
> ===================================================================
> RCS file: /cvs/src/src/gdb/NEWS,v
> retrieving revision 1.373
> diff -u -p -r1.373 NEWS
> --- gdb/NEWS    19 Apr 2010 00:48:43 -0000      1.373
> +++ gdb/NEWS    20 Apr 2010 18:26:13 -0000
> @@ -76,6 +76,11 @@ regular breakpoints.
>
>  ARM Symbian                    arm*-*-symbianelf*
>
> +* Changed commands
> +
> +disassemble
> +  The disassemble command now supports "start,+length" form of two arguments.
> +
>  *** Changes in GDB 7.1
>
>  * C++ Improvements
> @@ -371,8 +376,9 @@ or the "condition" command is available.
>  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.
>

Do we need change this part?

Thanks,
Hui

>  * Process record and replay
>
> @@ -464,9 +470,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: gdb/cli/cli-cmds.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
> retrieving revision 1.101
> diff -u -p -r1.101 cli-cmds.c
> --- gdb/cli/cli-cmds.c  15 Apr 2010 17:45:52 -0000      1.101
> +++ gdb/cli/cli-cmds.c  20 Apr 2010 18:26:15 -0000
> @@ -1105,8 +1105,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.  */
> @@ -1177,8 +1178,18 @@ disassemble_command (char *arg, int from
>   else
>     {
>       /* Two arguments.  */
> +      int incl_flag = 0;
>       low = pc;
> +      while (*arg == ' ' || *arg == '\t')
> +       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);
> @@ -1610,7 +1621,8 @@ Default is the function surrounding the
>  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: gdb/doc/ChangeLog
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/ChangeLog,v
> retrieving revision 1.1051
> diff -u -p -r1.1051 ChangeLog
> --- gdb/doc/ChangeLog   19 Apr 2010 01:08:25 -0000      1.1051
> +++ gdb/doc/ChangeLog   20 Apr 2010 18:26:19 -0000
> @@ -1,3 +1,8 @@
> +2010-04-21  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-04-19  Pedro Alves  <pedro@codesourcery.com>
>
>        PR breakpoints/8554.
> Index: gdb/doc/gdb.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
> retrieving revision 1.708
> diff -u -p -r1.708 gdb.texinfo
> --- gdb/doc/gdb.texinfo 19 Apr 2010 00:48:44 -0000      1.708
> +++ gdb/doc/gdb.texinfo 20 Apr 2010 18:26:40 -0000
> @@ -6576,8 +6576,19 @@ command is a program counter value; @val
>  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}.
> @@ -6629,6 +6640,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.
>
> --
> git v1.7.0.5, rqcheng at smu edu sg
>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH] disassemble support start,+length format
  2010-04-20 18:43 ` crquan
  2010-04-30 14:21   ` Hui Zhu
@ 2010-07-09  2:53   ` crquan
  2010-07-09  8:23     ` Eli Zaretskii
  2010-07-09 11:32     ` crquan
  1 sibling, 2 replies; 25+ messages in thread
From: crquan @ 2010-07-09  2:53 UTC (permalink / raw)
  To: gdb-patches, Tom Tromey, Eli Zaretskii, Nathan Froyd
  Cc: Hui Zhu, Joel Brobecker, CHENG Renquan

From: CHENG Renquan <rqcheng@smu.edu.sg>

add new support for disassemble by "start,+length" format;

update ChangeLog,NEWS,doc/gdb.texinfo accordingly.

BTW, I found two disassemble Changes in GDB 7.0 in NEWS, separated in two
paragraphs, so I merged them into one.

 gdb/NEWS            |   13 ++++++++-----
 gdb/cli/cli-cmds.c  |   18 +++++++++++++++---
 gdb/doc/gdb.texinfo |   27 +++++++++++++++++++++++++--
 gdb/ChangeLog       |    8 ++++++++
 gdb/doc/ChangeLog   |    5 +++++
 5 files changed, 61 insertions(+), 10 deletions(-)

---
rebased onto snapshot 2010-07-09.

Index: gdb-7.2.50.20100708/gdb/NEWS
===================================================================
--- gdb-7.2.50.20100708.orig/gdb/NEWS
+++ gdb-7.2.50.20100708/gdb/NEWS
@@ -3,6 +3,11 @@
 
 *** Changes since GDB 7.2
 
+* Changed commands
+
+disassemble
+  The disassemble command now supports "start,+length" form of two arguments.
+
 *** Changes in GDB 7.1
 
 * C++ Improvements:
@@ -518,8 +523,9 @@ or the "condition" command is available.
 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
 
@@ -611,9 +617,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: gdb-7.2.50.20100708/gdb/cli/cli-cmds.c
===================================================================
--- gdb-7.2.50.20100708.orig/gdb/cli/cli-cmds.c
+++ gdb-7.2.50.20100708/gdb/cli/cli-cmds.c
@@ -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
   else
     {
       /* Two arguments.  */
+      int incl_flag = 0;
       low = pc;
+      while (*arg == ' ' || *arg == '\t')
+	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
 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: gdb-7.2.50.20100708/gdb/doc/gdb.texinfo
===================================================================
--- gdb-7.2.50.20100708.orig/gdb/doc/gdb.texinfo
+++ gdb-7.2.50.20100708/gdb/doc/gdb.texinfo
@@ -6736,8 +6736,19 @@ command is a program counter value; @val
 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}.
@@ -6789,6 +6800,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.
 
Index: gdb-7.2.50.20100708/gdb/ChangeLog
===================================================================
--- gdb-7.2.50.20100708.orig/gdb/ChangeLog
+++ gdb-7.2.50.20100708/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2010-07-09  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-07  Joel Brobecker  <brobecker@adacore.com>
 
 	* NEWS: Create a new section for the next release branch.
Index: gdb-7.2.50.20100708/gdb/doc/ChangeLog
===================================================================
--- gdb-7.2.50.20100708.orig/gdb/doc/ChangeLog
+++ gdb-7.2.50.20100708/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2010-07-09  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-01  Pedro Alves  <pedro@codesourcery.com>
 
 	* gdb.texinfo (Create and Delete Tracepoints): Add more index

--
git v1.7.1.1

CHENG Renquan
38 St Thomas Walk, Singapore 238118      http://crquan.fedorapeople.org

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-07-09  2:53   ` crquan
@ 2010-07-09  8:23     ` Eli Zaretskii
  2010-07-09 11:32     ` crquan
  1 sibling, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2010-07-09  8:23 UTC (permalink / raw)
  To: crquan; +Cc: gdb-patches, tromey, froydnj, teawater, brobecker, rqcheng

> From: crquan@gmail.com
> Cc: Hui Zhu <teawater@gmail.com>, Joel Brobecker <brobecker@adacore.com>, CHENG Renquan <rqcheng@smu.edu.sg>
> Date: Fri,  9 Jul 2010 10:53:19 +0800
> 
> From: CHENG Renquan <rqcheng@smu.edu.sg>
> 
> add new support for disassemble by "start,+length" format;

Thanks.

> Index: gdb-7.2.50.20100708/gdb/NEWS
> ===================================================================
> --- gdb-7.2.50.20100708.orig/gdb/NEWS
> +++ gdb-7.2.50.20100708/gdb/NEWS

This part is okay.

> +      while (*arg == ' ' || *arg == '\t')

What's wrong with isspace?

> Index: gdb-7.2.50.20100708/gdb/doc/gdb.texinfo
> ===================================================================
> --- gdb-7.2.50.20100708.orig/gdb/doc/gdb.texinfo
> +++ gdb-7.2.50.20100708/gdb/doc/gdb.texinfo

This part is also okay, with a single comment:

> @@ -6736,8 +6736,19 @@ command is a program counter value; @val
>  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:

I believe the previous line that begins with "arguments" should be
removed.

Thanks.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH] disassemble support start,+length format
  2010-07-09  2:53   ` crquan
  2010-07-09  8:23     ` Eli Zaretskii
@ 2010-07-09 11:32     ` crquan
  2010-07-11 11:53       ` Hui Zhu
  2010-07-27 16:04       ` Joel Brobecker
  1 sibling, 2 replies; 25+ messages in thread
From: crquan @ 2010-07-09 11:32 UTC (permalink / raw)
  To: Eli Zaretskii, gdb-patches, Tom Tromey, Nathan Froyd
  Cc: Hui Zhu, Joel Brobecker

From: CHENG Renquan <rqcheng@smu.edu.sg>

add new support for disassemble by "start,+length" format;

update ChangeLog,NEWS,doc/gdb.texinfo accordingly.

BTW, I found two disassemble Changes in GDB 7.0 in NEWS, separated in two
paragraphs, so I merged them into one.

 gdb/ChangeLog       |    8 ++++++++
 gdb/NEWS            |   13 ++++++++-----
 gdb/cli/cli-cmds.c  |   18 +++++++++++++++---
 gdb/doc/ChangeLog   |    5 +++++
 gdb/doc/gdb.texinfo |   28 +++++++++++++++++++++++++---
 5 files changed, 61 insertions(+), 11 deletions(-)

---
rebased onto cvs latest today 2010-07-09.

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.11979
diff -u -p -r1.11979 ChangeLog
--- gdb/ChangeLog	9 Jul 2010 02:39:57 -0000	1.11979
+++ gdb/ChangeLog	9 Jul 2010 11:23:30 -0000
@@ -1,3 +1,11 @@
+2010-07-09  CHENG Renquan  <rqcheng@smu.edu.sg>
+
+	* 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".
+	* cli/cli-cmds.c (disassemble_command): Add support of disassemble
+	"start,+length" form of arguments.
+
 2010-07-09  Hui Zhu  <teawater@gmail.com>
 
 	* source.c (print_source_lines_base): Add check for noprint.
Index: gdb/NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.392
diff -u -p -r1.392 NEWS
--- gdb/NEWS	8 Jul 2010 15:41:56 -0000	1.392
+++ gdb/NEWS	9 Jul 2010 11:23:31 -0000
@@ -184,6 +184,11 @@ strace FN | FILE:LINE | *ADDR | -m MARKE
   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,
@@ -518,8 +523,9 @@ or the "condition" command is available.
 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
 
@@ -611,9 +617,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: gdb/cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.104
diff -u -p -r1.104 cli-cmds.c
--- gdb/cli/cli-cmds.c	17 May 2010 19:28:12 -0000	1.104
+++ gdb/cli/cli-cmds.c	9 Jul 2010 11:23:31 -0000
@@ -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
   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 
 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: gdb/doc/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/doc/ChangeLog,v
retrieving revision 1.1083
diff -u -p -r1.1083 ChangeLog
--- gdb/doc/ChangeLog	1 Jul 2010 17:40:04 -0000	1.1083
+++ gdb/doc/ChangeLog	9 Jul 2010 11:23:31 -0000
@@ -1,3 +1,8 @@
+2010-07-09  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-01  Pedro Alves  <pedro@codesourcery.com>
 
 	* gdb.texinfo (Create and Delete Tracepoints): Add more index
Index: gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.737
diff -u -p -r1.737 gdb.texinfo
--- gdb/doc/gdb.texinfo	1 Jul 2010 17:40:04 -0000	1.737
+++ gdb/doc/gdb.texinfo	9 Jul 2010 11:23:32 -0000
@@ -6735,9 +6735,19 @@ program counter of the selected frame.  
 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}.
@@ -6789,6 +6799,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.
 
--
git v1.7.1.1

CHENG Renquan
38 St Thomas Walk, Singapore 238118      http://crquan.fedorapeople.org

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-07-09 11:32     ` crquan
@ 2010-07-11 11:53       ` Hui Zhu
  2010-07-11 17:28         ` Cheng Renquan
  2010-07-27 16:04       ` Joel Brobecker
  1 sibling, 1 reply; 25+ messages in thread
From: Hui Zhu @ 2010-07-11 11:53 UTC (permalink / raw)
  To: crquan
  Cc: Eli Zaretskii, gdb-patches, Tom Tromey, Nathan Froyd, Joel Brobecker

On Fri, Jul 9, 2010 at 19:35,  <crquan@gmail.com> wrote:
> From: CHENG Renquan <rqcheng@smu.edu.sg>
>
> add new support for disassemble by "start,+length" format;
>
> update ChangeLog,NEWS,doc/gdb.texinfo accordingly.
>
> BTW, I found two disassemble Changes in GDB 7.0 in NEWS, separated in two
> paragraphs, so I merged them into one.

We are in 7.2 now.  So I think you need add new entry for them.

Thanks,
Hui

>
>  gdb/ChangeLog       |    8 ++++++++
>  gdb/NEWS            |   13 ++++++++-----
>  gdb/cli/cli-cmds.c  |   18 +++++++++++++++---
>  gdb/doc/ChangeLog   |    5 +++++
>  gdb/doc/gdb.texinfo |   28 +++++++++++++++++++++++++---
>  5 files changed, 61 insertions(+), 11 deletions(-)
>
> ---
> rebased onto cvs latest today 2010-07-09.
>
> Index: gdb/ChangeLog
> ===================================================================
> RCS file: /cvs/src/src/gdb/ChangeLog,v
> retrieving revision 1.11979
> diff -u -p -r1.11979 ChangeLog
> --- gdb/ChangeLog       9 Jul 2010 02:39:57 -0000       1.11979
> +++ gdb/ChangeLog       9 Jul 2010 11:23:30 -0000
> @@ -1,3 +1,11 @@
> +2010-07-09  CHENG Renquan  <rqcheng@smu.edu.sg>
> +
> +       * 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".
> +       * cli/cli-cmds.c (disassemble_command): Add support of disassemble
> +       "start,+length" form of arguments.
> +
>  2010-07-09  Hui Zhu  <teawater@gmail.com>
>
>        * source.c (print_source_lines_base): Add check for noprint.
> Index: gdb/NEWS
> ===================================================================
> RCS file: /cvs/src/src/gdb/NEWS,v
> retrieving revision 1.392
> diff -u -p -r1.392 NEWS
> --- gdb/NEWS    8 Jul 2010 15:41:56 -0000       1.392
> +++ gdb/NEWS    9 Jul 2010 11:23:31 -0000
> @@ -184,6 +184,11 @@ strace FN | FILE:LINE | *ADDR | -m MARKE
>   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,
> @@ -518,8 +523,9 @@ or the "condition" command is available.
>  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
>
> @@ -611,9 +617,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: gdb/cli/cli-cmds.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
> retrieving revision 1.104
> diff -u -p -r1.104 cli-cmds.c
> --- gdb/cli/cli-cmds.c  17 May 2010 19:28:12 -0000      1.104
> +++ gdb/cli/cli-cmds.c  9 Jul 2010 11:23:31 -0000
> @@ -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
>   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
>  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: gdb/doc/ChangeLog
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/ChangeLog,v
> retrieving revision 1.1083
> diff -u -p -r1.1083 ChangeLog
> --- gdb/doc/ChangeLog   1 Jul 2010 17:40:04 -0000       1.1083
> +++ gdb/doc/ChangeLog   9 Jul 2010 11:23:31 -0000
> @@ -1,3 +1,8 @@
> +2010-07-09  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-01  Pedro Alves  <pedro@codesourcery.com>
>
>        * gdb.texinfo (Create and Delete Tracepoints): Add more index
> Index: gdb/doc/gdb.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
> retrieving revision 1.737
> diff -u -p -r1.737 gdb.texinfo
> --- gdb/doc/gdb.texinfo 1 Jul 2010 17:40:04 -0000       1.737
> +++ gdb/doc/gdb.texinfo 9 Jul 2010 11:23:32 -0000
> @@ -6735,9 +6735,19 @@ program counter of the selected frame.
>  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}.
> @@ -6789,6 +6799,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.
>
> --
> git v1.7.1.1
>
> CHENG Renquan
> 38 St Thomas Walk, Singapore 238118      http://crquan.fedorapeople.org
>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-07-11 11:53       ` Hui Zhu
@ 2010-07-11 17:28         ` Cheng Renquan
  0 siblings, 0 replies; 25+ messages in thread
From: Cheng Renquan @ 2010-07-11 17:28 UTC (permalink / raw)
  To: Hui Zhu; +Cc: Eli Zaretskii, gdb-patches

On Sun, Jul 11, 2010 at 7:52 PM, Hui Zhu <teawater@gmail.com> wrote:
> On Fri, Jul 9, 2010 at 19:35,  <crquan@gmail.com> wrote:
>> From: CHENG Renquan <rqcheng@smu.edu.sg>
>>
>> add new support for disassemble by "start,+length" format;
>>
>> update ChangeLog,NEWS,doc/gdb.texinfo accordingly.
>>
>> BTW, I found two disassemble Changes in GDB 7.0 in NEWS, separated in two
>> paragraphs, so I merged them into one.
>
> We are in 7.2 now.  So I think you need add new entry for them.

Is 7.2 released? seems close to?
http://www.gnu.org/software/gdb/download/
http://ftp.gnu.org/gnu/gdb/

I have added this in entries "Changes in GDB 7.2" in NEWS, this makes
sense if this patch can be applied before 7.2 released; if cannot,
then should be moved into "Changes since GDB 7.2";

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-07-09 11:32     ` crquan
  2010-07-11 11:53       ` Hui Zhu
@ 2010-07-27 16:04       ` Joel Brobecker
  1 sibling, 0 replies; 25+ messages in thread
From: Joel Brobecker @ 2010-07-27 16:04 UTC (permalink / raw)
  To: crquan; +Cc: Eli Zaretskii, gdb-patches, Tom Tromey, Nathan Froyd, Hui Zhu

> +2010-07-09  CHENG Renquan  <rqcheng@smu.edu.sg>
> +
> +	* 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".
> +	* cli/cli-cmds.c (disassemble_command): Add support of disassemble
> +	"start,+length" form of arguments.
> +

Approved head and 7.2 branch. Can you commit ASAP?

-- 
Joel

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-04-10 21:01 crquan
  2010-04-10 21:16 ` Eli Zaretskii
  2010-04-10 21:23 ` Cheng Renquan
@ 2010-04-13 23:29 ` Tom Tromey
  2 siblings, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2010-04-13 23:29 UTC (permalink / raw)
  To: crquan; +Cc: gdb-patches, Hui Zhu, Joel Brobecker, Eli Zaretskii

>>>>> ">" == Cheng Renquan <crquan@gmail.com> writes:

>>      {
>>        /* Two arguments.  */
>> +      int incl_flag = 0;
>>        low = pc;
>> +      if (arg[0] == '+')
>> +      {

This still looks wrong.  The brace should be 2 spaces in from the 'if'.

Also this doesn't skip whitespace before the '+'.

Tom

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-04-10 21:01 crquan
  2010-04-10 21:16 ` Eli Zaretskii
@ 2010-04-10 21:23 ` Cheng Renquan
  2010-04-13 23:29 ` Tom Tromey
  2 siblings, 0 replies; 25+ messages in thread
From: Cheng Renquan @ 2010-04-10 21:23 UTC (permalink / raw)
  To: gdb-patches, Tom Tromey; +Cc: Hui Zhu, Joel Brobecker, Eli Zaretskii

On Sun, Apr 11, 2010 at 5:01 AM, Cheng <crquan@gmail.com> wrote:
> Index: gdb/cli/cli-cmds.c
[...]
> @@ -1119,8 +1120,16 @@ disassemble_command (char *arg, int from
>   else
>     {
>       /* Two arguments.  */
> +      int incl_flag = 0;
>       low = pc;
> +      if (arg[0] == '+')
> +      {
> +       ++arg;
> +       incl_flag = 1;
> +      }
>       high = parse_and_eval_address (arg);
> +      if (incl_flag)
> +       high += low;
This should satisfy GNU Coding Standards well,

On Fri, Apr 9, 2010 at 6:27 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> OK, I really know little about texinfo writing; Thanks,
>
> That's fine, I'm here to help ;-)
>
> Thanks for working on this.

I think there to add one disassemble example in the info file may be
better, but haven't figured out how to preview such a texinfo file,
the make process seems not touch it or use it to generate another
file?

suseuser@linux-orm5:~/src/gdb-trunk/src> info -f gdb/doc/gdb.texinfo
info: Cannot find node `Top'.

On Sat, Apr 10, 2010 at 2:14 AM, Tom Tromey <tromey@redhat.com> wrote:
>>> From: CHENG Renquan <rqcheng@smu.edu.sg>
>>> add new support for disassemble by "start,+length" format;
>
> Do you have a copyright assignment in place?
> If not, let me know and I can get you started.

Not yet, you may mean a signed agreement to GNU FSF? I was formerly
asked to sign one when posting a patch to GNU wget last year, but
still don't get further messages there, I wonder if softcopy of
signment is accepted? please help get me restarted since this gdb
patch, thanks,

-- 
Cheng Renquan (程任全), from Singapore

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-04-10 21:01 crquan
@ 2010-04-10 21:16 ` Eli Zaretskii
  2010-04-10 21:23 ` Cheng Renquan
  2010-04-13 23:29 ` Tom Tromey
  2 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2010-04-10 21:16 UTC (permalink / raw)
  To: crquan; +Cc: gdb-patches, tromey, teawater, brobecker

> From: crquan@gmail.com
> Cc: Hui Zhu <teawater@gmail.com>, Joel Brobecker <brobecker@adacore.com>, Eli Zaretskii <eliz@gnu.org>
> Date: Sun, 11 Apr 2010 05:01:07 +0800
> 
> add new support for disassemble by "start,+length" format;
> 
> and updated ChangeLog,NEWS,doc/gdb.texinfo, accordingly.

Don't forget an entry to gdb/doc/ChangeLog documenting the change in
gdb.texinfo.

> BTW, I found two disassemble Changes in GDB 7.0 in NEWS, separated in two
> paragraphs, so I merged them into one paragraph.

Thanks.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH] disassemble support start,+length format
@ 2010-04-10 21:01 crquan
  2010-04-10 21:16 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: crquan @ 2010-04-10 21:01 UTC (permalink / raw)
  To: gdb-patches, Tom Tromey; +Cc: Hui Zhu, Joel Brobecker, Eli Zaretskii

From: CHENG Renquan <rqcheng@smu.edu.sg>

add new support for disassemble by "start,+length" format;

and updated ChangeLog,NEWS,doc/gdb.texinfo, accordingly.

BTW, I found two disassemble Changes in GDB 7.0 in NEWS, separated in two
paragraphs, so I merged them into one paragraph.

Signed-off-by: CHENG Renquan <rqcheng@smu.edu.sg>
Reviewed-by: Eli Zaretskii <eliz@gnu.org>
Reviewed-by: Tom Tromey <tromey@redhat.com>

 gdb/ChangeLog       |    5 +++++
 gdb/NEWS            |   13 ++++++++-----
 gdb/cli/cli-cmds.c  |   16 +++++++++++++---
 gdb/doc/gdb.texinfo |   16 +++++++++++++---
 4 files changed, 39 insertions(+), 11 deletions(-)

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.11603
diff -u -p -r1.11603 ChangeLog
--- gdb/ChangeLog	9 Apr 2010 20:46:39 -0000	1.11603
+++ gdb/ChangeLog	10 Apr 2010 19:23:58 -0000
@@ -1,3 +1,8 @@
+2010-04-09  CHENG Renquan <rqcheng@smu.edu.sg>
+
+	* gdb/cli/cli-cmds.c (disassemble_command): disassemble add support
+	"start,+length" format
+
 2010-04-09  Stan Shebs  <stan@codesourcery.com>
 
 	* tracepoint.c (trace_status_mi): Report frames created.
Index: gdb/NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.369
diff -u -p -r1.369 NEWS
--- gdb/NEWS	9 Apr 2010 15:26:54 -0000	1.369
+++ gdb/NEWS	10 Apr 2010 19:24:01 -0000
@@ -44,6 +44,11 @@ regular breakpoints.
 
 ARM Symbian			arm*-*-symbianelf*
 
+* Changed commands
+
+disassemble
+  The disassemble command now supports "start,+length" form of two arguments.
+
 *** Changes in GDB 7.1
 
 * C++ Improvements
@@ -339,8 +344,9 @@ or the "condition" command is available.
 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
 
@@ -432,9 +438,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: gdb/cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.100
diff -u -p -r1.100 cli-cmds.c
--- gdb/cli/cli-cmds.c	9 Apr 2010 03:00:58 -0000	1.100
+++ gdb/cli/cli-cmds.c	10 Apr 2010 19:24:02 -0000
@@ -1047,8 +1047,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.  */
@@ -1119,8 +1120,16 @@ disassemble_command (char *arg, int from
   else
     {
       /* Two arguments.  */
+      int incl_flag = 0;
       low = pc;
+      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);
@@ -1548,7 +1557,8 @@ Default is the function surrounding the 
 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: gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.703
diff -u -p -r1.703 gdb.texinfo
--- gdb/doc/gdb.texinfo	9 Apr 2010 20:46:40 -0000	1.703
+++ gdb/doc/gdb.texinfo	10 Apr 2010 19:24:25 -0000
@@ -6549,9 +6549,19 @@ program counter of the selected frame.  
 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}.

--
git v1.7.0.4, rqcheng at smu edu sg

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-04-09  4:11 crquan
  2010-04-09  8:22 ` Eli Zaretskii
@ 2010-04-09 18:14 ` Tom Tromey
  1 sibling, 0 replies; 25+ messages in thread
From: Tom Tromey @ 2010-04-09 18:14 UTC (permalink / raw)
  To: crquan; +Cc: gdb-patches, Hui Zhu, Joel Brobecker, Eli Zaretskii

>>>>> ">" == crquan  <crquan@gmail.com> writes:

>> From: CHENG Renquan <rqcheng@smu.edu.sg>
>> add new support for disassemble by "start,+length" format;

Do you have a copyright assignment in place?
If not, let me know and I can get you started.

>>        /* Two arguments.  */
>> +      int incl_flag = 0;
>> +
>>        low = pc;

I think you should skip whitespace here.

>> +      if (arg[0] == '+') {

The brace placement is wrong here.  See the GNU Coding Standards, or
existing code in that function.

Otherwise this seems reasonable to me.

Tom

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-04-09  9:35   ` Cheng Renquan
@ 2010-04-09 10:29     ` Eli Zaretskii
  0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2010-04-09 10:29 UTC (permalink / raw)
  To: Cheng Renquan; +Cc: gdb-patches, teawater, brobecker

> From: Cheng Renquan <crquan@gmail.com>
> Date: Fri, 9 Apr 2010 17:34:48 +0800
> Cc: gdb-patches@sourceware.org, teawater@gmail.com, brobecker@adacore.com
> 
> OK, I really know little about texinfo writing; Thanks,

That's fine, I'm here to help ;-)

Thanks for working on this.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-04-09  8:22 ` Eli Zaretskii
@ 2010-04-09  9:35   ` Cheng Renquan
  2010-04-09 10:29     ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Cheng Renquan @ 2010-04-09  9:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches, teawater, brobecker

On Fri, Apr 9, 2010 at 4:21 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> -* "disassemble" command with a /r modifier, print the raw instructions
>> -in hex as well as in symbolic form.
>> +* The "disassemble" command with an optional /r modifier, print the raw
>> +instructions in hex as well as in symbolic form; optional /m modifier to
>> +print mixed source+assembly.
>
> Thanks.  But please use the style we use in other NEWS entries.
> Something like "The disassemble command now supports ..." etc.

The previous entries in "Changes in GDB 7.0" already have problems, I
should check,

>
>> +arguments specify a range of addresses, in the form of "start,end" or
>> +"start,+length", stand for [start,end) and [start,start+length), (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).
>
> I suggest to rephrase as follows:
>
>  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).
>
> Note that I used @var{start},@var{end}}, instead of using double
> quotes (which is generally a no-no in Texinfo sources).

OK, I really know little about texinfo writing; Thanks,

-- 
Cheng Renquan (程任全), from Singapore

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] disassemble support start,+length format
  2010-04-09  4:11 crquan
@ 2010-04-09  8:22 ` Eli Zaretskii
  2010-04-09  9:35   ` Cheng Renquan
  2010-04-09 18:14 ` Tom Tromey
  1 sibling, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2010-04-09  8:22 UTC (permalink / raw)
  To: crquan; +Cc: gdb-patches, teawater, brobecker

> From: crquan@gmail.com
> Cc: Joel Brobecker <brobecker@adacore.com>,
> 	Eli Zaretskii <eliz@gnu.org>
> Date: Fri,  9 Apr 2010 12:16:55 +0800
> 
> +* Changed commands
> +
> +disassemble
> +  The disassemble command, add "start,+length" form of two arguments support.
> +
>  *** Changes in GDB 7.1
>  
>  * C++ Improvements
> @@ -334,8 +339,9 @@ or the "condition" command is available.
>  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 with an optional /r modifier, print the raw
> +instructions in hex as well as in symbolic form; optional /m modifier to
> +print mixed source+assembly.

Thanks.  But please use the style we use in other NEWS entries.
Something like "The disassemble command now supports ..." etc.

> +arguments specify a range of addresses, in the form of "start,end" or
> +"start,+length", stand for [start,end) and [start,start+length), (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).

I suggest to rephrase as follows:

  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).

Note that I used @var{start},@var{end}}, instead of using double
quotes (which is generally a no-no in Texinfo sources).

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH] disassemble support start,+length format
@ 2010-04-09  4:11 crquan
  2010-04-09  8:22 ` Eli Zaretskii
  2010-04-09 18:14 ` Tom Tromey
  0 siblings, 2 replies; 25+ messages in thread
From: crquan @ 2010-04-09  4:11 UTC (permalink / raw)
  To: gdb-patches, Hui Zhu; +Cc: Joel Brobecker, Eli Zaretskii

From: CHENG Renquan <rqcheng@smu.edu.sg>

add new support for disassemble by "start,+length" format;

ChangeLog,NEWS,doc/gdb.texinfo udpated, accordingly.

BTW, I found two disassemble Changes in GDB 7.0 in NEWS, separated in two
paragraphs, so I merged them into one paragraph.

 gdb/ChangeLog       |    5 +++++
 gdb/NEWS            |   13 ++++++++-----
 gdb/cli/cli-cmds.c  |   16 +++++++++++++---
 gdb/doc/gdb.texinfo |    8 +++++---
 4 files changed, 31 insertions(+), 11 deletions(-)

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.11594
diff -u -p -r1.11594 ChangeLog
--- gdb/ChangeLog	9 Apr 2010 03:00:56 -0000	1.11594
+++ gdb/ChangeLog	9 Apr 2010 03:51:39 -0000
@@ -1,3 +1,8 @@
+2010-04-09  CHENG Renquan <rqcheng@smu.edu.sg>
+
+	* gdb/cli/cli-cmds.c (disassemble_command): disassemble add support
+	"start,+length" format
+
 2010-04-08  Stan Shebs  <stan@codesourcery.com>
 	    Pedro Alves  <pedro@codesourcery.com>
 
Index: gdb/NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.367
diff -u -p -r1.367 NEWS
--- gdb/NEWS	1 Apr 2010 14:11:22 -0000	1.367
+++ gdb/NEWS	9 Apr 2010 03:51:40 -0000
@@ -39,6 +39,11 @@ regular breakpoints.
 
 ARM Symbian			arm*-*-symbianelf*
 
+* Changed commands
+
+disassemble
+  The disassemble command, add "start,+length" form of two arguments support.
+
 *** Changes in GDB 7.1
 
 * C++ Improvements
@@ -334,8 +339,9 @@ or the "condition" command is available.
 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 with an optional /r modifier, print the raw
+instructions in hex as well as in symbolic form; optional /m modifier to
+print mixed source+assembly.
 
 * Process record and replay
 
@@ -427,9 +433,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: gdb/cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.100
diff -u -p -r1.100 cli-cmds.c
--- gdb/cli/cli-cmds.c	9 Apr 2010 03:00:58 -0000	1.100
+++ gdb/cli/cli-cmds.c	9 Apr 2010 03:51:40 -0000
@@ -1047,8 +1047,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.  */
@@ -1119,8 +1120,16 @@ disassemble_command (char *arg, int from
   else
     {
       /* Two arguments.  */
+      int incl_flag = 0;
+
       low = pc;
+      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);
@@ -1548,7 +1557,8 @@ Default is the function surrounding the 
 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: gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.699
diff -u -p -r1.699 gdb.texinfo
--- gdb/doc/gdb.texinfo	9 Apr 2010 03:00:58 -0000	1.699
+++ gdb/doc/gdb.texinfo	9 Apr 2010 03:51:44 -0000
@@ -6549,9 +6549,11 @@ program counter of the selected frame.  
 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, in the form of "start,end" or
+"start,+length", stand for [start,end) and [start,start+length), (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).
 
 The argument(s) can be any expression yielding a numeric value, such as
 @samp{0x32c4}, @samp{&main+10} or @samp{$pc - 8}.

--
git v1.7.0.4, rqcheng at smu edu sg

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2010-07-27 16:04 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-08 15:09 [PATCH] disassemble support start,+length format crquan
2010-04-09  2:16 ` Hui Zhu
2010-04-15  7:44 ` crquan
2010-04-15 17:08   ` Eli Zaretskii
2010-04-15 17:14     ` Nathan Froyd
2010-04-15 17:38       ` Eli Zaretskii
2010-04-16  1:36 ` crquan
2010-04-20 15:43   ` Tom Tromey
2010-04-20 18:43 ` crquan
2010-04-30 14:21   ` Hui Zhu
2010-07-09  2:53   ` crquan
2010-07-09  8:23     ` Eli Zaretskii
2010-07-09 11:32     ` crquan
2010-07-11 11:53       ` Hui Zhu
2010-07-11 17:28         ` Cheng Renquan
2010-07-27 16:04       ` Joel Brobecker
2010-04-09  4:11 crquan
2010-04-09  8:22 ` Eli Zaretskii
2010-04-09  9:35   ` Cheng Renquan
2010-04-09 10:29     ` Eli Zaretskii
2010-04-09 18:14 ` Tom Tromey
2010-04-10 21:01 crquan
2010-04-10 21:16 ` Eli Zaretskii
2010-04-10 21:23 ` Cheng Renquan
2010-04-13 23:29 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).