From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21286 invoked by alias); 27 Apr 2016 02:50:28 -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 21014 invoked by uid 89); 27 Apr 2016 02:50:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=FALSE, 1249, 124,9, Hx-languages-length:5007 X-HELO: gproxy9-pub.mail.unifiedlayer.com Received: from gproxy9-pub.mail.unifiedlayer.com (HELO gproxy9-pub.mail.unifiedlayer.com) (69.89.20.122) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Wed, 27 Apr 2016 02:49:50 +0000 Received: (qmail 32649 invoked by uid 0); 27 Apr 2016 02:49:47 -0000 Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy9.mail.unifiedlayer.com with SMTP; 27 Apr 2016 02:49:47 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id nMph1s00Q2f2jeq01MpkRa; Wed, 27 Apr 2016 03:49:44 -0600 X-Authority-Analysis: v=2.1 cv=Maz/5fPf c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=PnD2wP_eR3oA:10 a=_v2sUkyEFrwA:10 a=kziv93cY1bsA:10 a=zstS-IiYAAAA:8 a=Rihykf4IfVimKDb-LcAA:9 a=QGWO8W3Chv-5jg3G:21 a=EaOrkQS4qMPcrw-d:21 Received: from [71.215.116.141] (port=59324 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1avFXs-0002dx-N0; Tue, 26 Apr 2016 20:49:44 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 5/8] Add array start and end strings to generic_val_print_decorations Date: Wed, 27 Apr 2016 02:50:00 -0000 Message-Id: <1461725371-17620-6-git-send-email-tom@tromey.com> In-Reply-To: <1461725371-17620-1-git-send-email-tom@tromey.com> References: <1461725371-17620-1-git-send-email-tom@tromey.com> X-Identified-User: {36111:box522.bluehost.com:elynrobi:tromey.com} {sentby:smtp auth 71.215.116.141 authed with tom+tromey.com} X-SW-Source: 2016-04/txt/msg00565.txt.bz2 For Rust value-printing, I wanted to use generic_val_print_array, but I also wanted to control the starting and ending strings. This patch adds new strings to generic_val_print_decorations, updates generic_val_print_array to use them, and updates all the existing instances of generic_val_print_decorations. 2016-04-26 Tom Tromey * valprint.h (struct generic_val_print_array) : New fields. * valprint.c (generic_val_print_array): Add "decorations" parameter. Use "array_start", "array_end". (generic_val_print) : Update. * p-valprint.c (p_decorations): Update. * m2-valprint.c (m2_decorations): Update. * f-valprint.c (f_decorations): Update. * c-valprint.c (c_decorations): Update. --- gdb/ChangeLog | 12 ++++++++++++ gdb/c-valprint.c | 4 +++- gdb/f-valprint.c | 2 ++ gdb/m2-valprint.c | 4 +++- gdb/p-valprint.c | 4 +++- gdb/valprint.c | 16 +++++++++------- gdb/valprint.h | 4 ++++ 7 files changed, 36 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ab137ca..7fc99f7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,17 @@ 2016-04-26 Tom Tromey + * valprint.h (struct generic_val_print_array) : New fields. + * valprint.c (generic_val_print_array): Add "decorations" + parameter. Use "array_start", "array_end". + (generic_val_print) : Update. + * p-valprint.c (p_decorations): Update. + * m2-valprint.c (m2_decorations): Update. + * f-valprint.c (f_decorations): Update. + * c-valprint.c (c_decorations): Update. + +2016-04-26 Tom Tromey + * selftest.h: New file. * selftest.c: New file. * maint.c: Include selftest.h. diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 62552ec..75dae19 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -124,7 +124,9 @@ static const struct generic_val_print_decorations c_decorations = " * I", "true", "false", - "void" + "void", + "{", + "}" }; /* Print a pointer based on the type of its target. diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 71bd2c3..1264737 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -203,6 +203,8 @@ static const struct generic_val_print_decorations f_decorations = ".TRUE.", ".FALSE.", "VOID", + "{", + "}" }; /* See val_print for a description of the various parameters of this diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index 73fbdfe..2d3a32f 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -301,7 +301,9 @@ static const struct generic_val_print_decorations m2_decorations = " * I", "TRUE", "FALSE", - "void" + "void", + "{", + "}" }; /* See val_print for a description of the various parameters of this diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 72dc6fd..3e840d8 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -49,7 +49,9 @@ static const struct generic_val_print_decorations p_decorations = " * I", "true", "false", - "void" + "void", + "{", + "}" }; /* See val_print for a description of the various parameters of this diff --git a/gdb/valprint.c b/gdb/valprint.c index 720942b..cea69f3 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -407,10 +407,12 @@ print_unpacked_pointer (struct type *type, struct type *elttype, static void generic_val_print_array (struct type *type, const gdb_byte *valaddr, - int embedded_offset, CORE_ADDR address, - struct ui_file *stream, int recurse, - const struct value *original_value, - const struct value_print_options *options) + int embedded_offset, CORE_ADDR address, + struct ui_file *stream, int recurse, + const struct value *original_value, + const struct value_print_options *options, + const struct + generic_val_print_decorations *decorations) { struct type *unresolved_elttype = TYPE_TARGET_TYPE (type); struct type *elttype = check_typedef (unresolved_elttype); @@ -427,11 +429,11 @@ generic_val_print_array (struct type *type, const gdb_byte *valaddr, print_spaces_filtered (2 + 2 * recurse, stream); } - fprintf_filtered (stream, "{"); + fputs_filtered (decorations->array_start, stream); val_print_array_elements (type, valaddr, embedded_offset, address, stream, recurse, original_value, options, 0); - fprintf_filtered (stream, "}"); + fputs_filtered (decorations->array_end, stream); } else { @@ -851,7 +853,7 @@ generic_val_print (struct type *type, const gdb_byte *valaddr, { case TYPE_CODE_ARRAY: generic_val_print_array (type, valaddr, embedded_offset, address, stream, - recurse, original_value, options); + recurse, original_value, options, decorations); break; case TYPE_CODE_MEMBERPTR: diff --git a/gdb/valprint.h b/gdb/valprint.h index 1a83cb5..451b5fe 100644 --- a/gdb/valprint.h +++ b/gdb/valprint.h @@ -186,6 +186,10 @@ struct generic_val_print_decorations /* What to print when we see TYPE_CODE_VOID. */ const char *void_name; + + /* Array start and end strings. */ + const char *array_start; + const char *array_end; }; -- 2.5.5