From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3961 invoked by alias); 15 Apr 2010 07:44:42 -0000 Received: (qmail 3938 invoked by uid 22791); 15 Apr 2010 07:44:40 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_SORBS_WEB,TW_OV,TW_QC,TW_RQ X-Spam-Check-By: sourceware.org Received: from mail-gy0-f169.google.com (HELO mail-gy0-f169.google.com) (209.85.160.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 15 Apr 2010 07:44:35 +0000 Received: by gyg4 with SMTP id 4so730588gyg.0 for ; Thu, 15 Apr 2010 00:44:33 -0700 (PDT) Received: by 10.100.233.20 with SMTP id f20mr14207229anh.22.1271317473458; Thu, 15 Apr 2010 00:44:33 -0700 (PDT) Received: from localhost.localdomain ([202.161.43.231]) by mx.google.com with ESMTPS id 8sm369159ywg.57.2010.04.15.00.44.30 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 15 Apr 2010 00:44:32 -0700 (PDT) From: crquan@gmail.com To: gdb-patches@sourceware.org, Tom Tromey Cc: Hui Zhu , Joel Brobecker , Eli Zaretskii Subject: [PATCH] disassemble support start,+length format Date: Thu, 15 Apr 2010 07:44:00 -0000 Message-Id: <1271317836-12963-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/msg00463.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-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 + + * 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 Pedro Alves @@ -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 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 : 48 83 ec 28 sub $0x28,%rsp + 0x0000000000450674 : 48 c7 04 24 00 00 00 00 movq $0x0,(%rsp) + 0x000000000045067c : 89 3c 24 mov %edi,(%rsp) + 0x000000000045067f : 48 89 e7 mov %rsp,%rdi + 0x0000000000450682 : 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