From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19477 invoked by alias); 20 Apr 2010 18:43:27 -0000 Received: (qmail 19441 invoked by uid 22791); 20 Apr 2010 18:43:24 -0000 X-SWARE-Spam-Status: No, hits=0.1 required=5.0 tests=BAYES_20,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,TW_QC,TW_RQ X-Spam-Check-By: sourceware.org Received: from fg-out-1718.google.com (HELO fg-out-1718.google.com) (72.14.220.153) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Apr 2010 18:43:18 +0000 Received: by fg-out-1718.google.com with SMTP id e12so2595759fga.12 for ; Tue, 20 Apr 2010 11:43:15 -0700 (PDT) Received: by 10.223.16.84 with SMTP id n20mr1241755faa.94.1271788868073; Tue, 20 Apr 2010 11:41:08 -0700 (PDT) Received: from localhost.localdomain (bb121-7-132-34.singnet.com.sg [121.7.132.34]) by mx.google.com with ESMTPS id 1sm2982006fks.24.2010.04.20.11.41.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 20 Apr 2010 11:41:06 -0700 (PDT) From: crquan@gmail.com To: gdb-patches@sourceware.org, Tom Tromey , Eli Zaretskii , Nathan Froyd Cc: Hui Zhu , Joel Brobecker Subject: [PATCH] disassemble support start,+length format Date: Tue, 20 Apr 2010 18:43:00 -0000 Message-Id: <1271788793-26862-1-git-send-email-crquan@gmail.com> In-Reply-To: <1270739689-28732-1-git-send-email-crquan@gmail.com> References: <1270739689-28732-1-git-send-email-crquan@gmail.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00624.txt.bz2 From: CHENG Renquan 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 + + * 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 * 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 + + * 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 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