From: crquan@gmail.com
To: Eli Zaretskii <eliz@gnu.org>,
gdb-patches@sourceware.org, Tom Tromey <tromey@redhat.com>,
Nathan Froyd <froydnj@codesourcery.com>
Cc: Hui Zhu <teawater@gmail.com>, Joel Brobecker <brobecker@adacore.com>
Subject: [PATCH] disassemble support start,+length format
Date: Fri, 09 Jul 2010 11:32:00 -0000 [thread overview]
Message-ID: <1278675336-2822-1-git-send-email-crquan@gmail.com> (raw)
In-Reply-To: <1278643999-4237-1-git-send-email-crquan@gmail.com>
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
next prev parent reply other threads:[~2010-07-09 11:32 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-08 15:09 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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1278675336-2822-1-git-send-email-crquan@gmail.com \
--to=crquan@gmail.com \
--cc=brobecker@adacore.com \
--cc=eliz@gnu.org \
--cc=froydnj@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=teawater@gmail.com \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox