From patchwork Thu May 7 17:36:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 6610 Received: (qmail 76485 invoked by alias); 7 May 2015 17:37:04 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 76238 invoked by uid 89); 7 May 2015 17:37:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 May 2015 17:37:01 +0000 Received: from svr-orw-fem-02x.mgc.mentorg.com ([147.34.96.206] helo=SVR-ORW-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YqPjG-0006h6-0Y from Luis_Gustavo@mentor.com for gdb-patches@sourceware.org; Thu, 07 May 2015 10:36:58 -0700 Received: from opsys.world.mentorg.com (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.3.224.2; Thu, 7 May 2015 10:36:57 -0700 From: Luis Machado To: Subject: [PATCH v2 1/3] Add zero-padded hexadecimal format support for varobj's Date: Thu, 7 May 2015 14:36:45 -0300 Message-ID: <1431020207-14371-2-git-send-email-lgustavo@codesourcery.com> In-Reply-To: <1431020207-14371-1-git-send-email-lgustavo@codesourcery.com> References: <1431020207-14371-1-git-send-email-lgustavo@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch changes things so that we can support zero-padded hexadecimal formats for varobj's. The new type is "zero-hexadecimal" and maps to GDB's 'z' print format. Ideally we would share all the formats we currently support with the MI/varobj layer, but this requires a bit more work. Meanwhile, adding a new mapping seems to work. gdb/ChangeLog: 2015-05-07 Luis Machado * gdb/mi/mi-cmd-var.c (mi_parse_format): Handle new "zero-hexadecimal" format. * gdb/varobj.c (varobj_format_string): Add "zero-hexadecimal" entry. (format_code): Add 'z' entry. (varobj_set_display_format): Handle FORMAT_ZHEXADECIMAL. * gdb/varobj.h (varobj_display_formats) : New enum field. --- gdb/mi/mi-cmd-var.c | 4 +++- gdb/varobj.c | 5 +++-- gdb/varobj.h | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index ee0bbc6..5554e3c 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -233,10 +233,12 @@ mi_parse_format (const char *arg) return FORMAT_HEXADECIMAL; else if (strncmp (arg, "octal", len) == 0) return FORMAT_OCTAL; + else if (strncmp (arg, "zero-hexadecimal", len) == 0) + return FORMAT_ZHEXADECIMAL; } error (_("Must specify the format as: \"natural\", " - "\"binary\", \"decimal\", \"hexadecimal\", or \"octal\"")); + "\"binary\", \"decimal\", \"hexadecimal\", \"octal\" or \"zero-hexadecimal\"")); } void diff --git a/gdb/varobj.c b/gdb/varobj.c index b220fd8..2f2939e 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -50,7 +50,7 @@ show_varobjdebug (struct ui_file *file, int from_tty, /* String representations of gdb's format codes. */ char *varobj_format_string[] = - { "natural", "binary", "decimal", "hexadecimal", "octal" }; + { "natural", "binary", "decimal", "hexadecimal", "octal", "zero-hexadecimal" }; /* True if we want to allow Python-based pretty-printing. */ static int pretty_printing = 0; @@ -214,7 +214,7 @@ static struct varobj *varobj_add_child (struct varobj *var, /* Private data */ /* Mappings of varobj_display_formats enums to gdb's format codes. */ -static int format_code[] = { 0, 't', 'd', 'x', 'o' }; +static int format_code[] = { 0, 't', 'd', 'x', 'o', 'z' }; /* Header of the list of root variable objects. */ static struct varobj_root *rootlist; @@ -583,6 +583,7 @@ varobj_set_display_format (struct varobj *var, case FORMAT_DECIMAL: case FORMAT_HEXADECIMAL: case FORMAT_OCTAL: + case FORMAT_ZHEXADECIMAL: var->format = format; break; diff --git a/gdb/varobj.h b/gdb/varobj.h index 8860526..179b2a5 100644 --- a/gdb/varobj.h +++ b/gdb/varobj.h @@ -28,7 +28,8 @@ enum varobj_display_formats FORMAT_BINARY, /* Binary display */ FORMAT_DECIMAL, /* Decimal display */ FORMAT_HEXADECIMAL, /* Hex display */ - FORMAT_OCTAL /* Octal display */ + FORMAT_OCTAL, /* Octal display */ + FORMAT_ZHEXADECIMAL /* Zero padded hexadecimal */ }; enum varobj_type