From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1176 invoked by alias); 8 Jul 2013 17:30:39 -0000 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 Received: (qmail 1165 invoked by uid 89); 8 Jul 2013 17:30:39 -0000 X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from mms3.broadcom.com (HELO mms3.broadcom.com) (216.31.210.19) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 08 Jul 2013 17:30:38 +0000 Received: from [10.9.208.55] by mms3.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Mon, 08 Jul 2013 10:21:03 -0700 X-Server-Uuid: B86B6450-0931-4310-942E-F00ED04CA7AF Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS07.corp.ad.broadcom.com (10.9.208.55) with Microsoft SMTP Server (TLS) id 14.1.438.0; Mon, 8 Jul 2013 10:30:30 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.1.438.0; Mon, 8 Jul 2013 10:30:30 -0700 Received: from [10.177.73.66] (unknown [10.177.73.66]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id A8029F2DEA for ; Mon, 8 Jul 2013 10:30:17 -0700 (PDT) Message-ID: <51DAF728.4040309@broadcom.com> Date: Mon, 08 Jul 2013 17:30:00 -0000 From: "Andrew Burgess" User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: "gdb-patches@sourceware.org" Subject: [PATCH] [1/2] Add new 'z' format for print command Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-07/txt/msg00235.txt.bz2 The MI code for displaying registers currently supports a special case 'r' format that displays the register in 'raw' form, this is hexadecimal, zero padded to the size of the register. Having this as a special case in the MI code causes problems with optimized out registers, which I tried addressing in a patch here: http://sourceware.org/ml/gdb-patches/2013-07/msg00193.html Pedro pointed out that I could do better, so, this patch introduces a new 'z' format within the core value printing code that displays scalars using zero padded hexadecimal. I've mentioned this in the docs and added a test for the new format. In patch [2/2] I'll change the MI code to make use of this new 'z' formatter. OK to apply? Thanks, Andrew gdb/ChangeLog 2013-07-08 Andrew Burgess * printcmd.c (print_scalar_formatted): Add new 'z' formatter. gdb/docs/ChangeLog 2013-07-08 Andrew Burgess * gdb.texinfo (Output Formats): Mention the new 'z' formatter. gdb/testsuite/ChangeLog 2013-07-08 Andrew Burgess * gdb.base/printcmds.exp (test_print_int_arrays): Add tests for x, z, o, and t output formats. * gdb.base/display.exp: Use 'k' as an undefined format now that 'z' is defined. diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 99d4dba..f34d18b 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -533,6 +533,10 @@ print_scalar_formatted (const void *valaddr, struct type *type, } break; + case 'z': + print_hex_chars (stream, valaddr, len, byte_order); + break; + default: error (_("Undefined output format \"%c\"."), options->format); } diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index fae54e4..c5d7754 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -8517,6 +8517,11 @@ Without this format, @value{GDBN} displays pointers to and arrays of strings. Single-byte members of a vector are displayed as an integer array. +@item z +Like @samp{x} formatting, the integer is printed as hexadecimal, but +leading zeros are printed to pad the value to the size of the integer +type. + @item r @cindex raw printing Print using the @samp{raw} formatting. By default, @value{GDBN} will diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp index 5db84cc..9a0b1dd 100644 --- a/gdb/testsuite/gdb.base/display.exp +++ b/gdb/testsuite/gdb.base/display.exp @@ -168,7 +168,7 @@ gdb_test "printf \"%p\\n\", 1" "0x1" # play with "print", too # -gdb_test "print/z j" ".*Undefined output format.*" +gdb_test "print/k j" ".*Undefined output format.*" gdb_test "print/d j" " = 0\[\\r\\n\]+" "debug test output 1" gdb_test "print/r j" " = 0\[\\r\\n\]+" "debug test output 1a" gdb_test "print/x j" " = 0x0\[\\r\\n\]+" "debug test output 2" diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp index 0597ab0..4883fd5 100644 --- a/gdb/testsuite/gdb.base/printcmds.exp +++ b/gdb/testsuite/gdb.base/printcmds.exp @@ -587,6 +587,16 @@ proc test_print_int_arrays {} { " = {{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}" gdb_test_escape_braces "p int4dim" \ " = {{{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}}" + + # Some checks for various output formats. + gdb_test_escape_braces "p/x int4dim" \ + " = {{{{0x0, 0x1}, {0x2, 0x3}, {0x4, 0x5}}, {{0x6, 0x7}, {0x8, 0x9}, {0xa, 0xb}}}}" + gdb_test_escape_braces "p/z int4dim" \ + " = {{{{0x0+0, 0x0+1}, {0x0+2, 0x0+3}, {0x0+4, 0x0+5}}, {{0x0+6, 0x0+7}, {0x0+8, 0x0+9}, {0x0+a, 0x0+b}}}}" + gdb_test_escape_braces "p/o int4dim" \ + " = {{{{0, 01}, {02, 03}, {04, 05}}, {{06, 07}, {010, 011}, {012, 013}}}}" + gdb_test_escape_braces "p/t int4dim" \ + " = {{{{0, 1}, {10, 11}, {100, 101}}, {{110, 111}, {1000, 1001}, {1010, 1011}}}}" } proc test_print_typedef_arrays {} {