From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from kwanyin.sergiodj.net (kwanyin.sergiodj.net [158.69.185.54]) by sourceware.org (Postfix) with ESMTPS id DD0CF39450E5 for ; Fri, 27 Mar 2020 09:12:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DD0CF39450E5 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [binutils-gdb] Introduce generic_value_print_complex From: gdb-buildbot@sergiodj.net To: gdb-testers@sourceware.org Message-Id: <4f412b6e31369f27725872391a70f0520883701c@gdb-build> Date: Fri, 27 Mar 2020 05:12:26 -0400 X-Spam-Status: No, score=-15.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_CSS, URIBL_CSS_A autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-testers@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-testers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Mar 2020 09:12:31 -0000 *** TEST RESULTS FOR COMMIT 4f412b6e31369f27725872391a70f0520883701c *** commit 4f412b6e31369f27725872391a70f0520883701c Author: Tom Tromey AuthorDate: Fri Mar 13 17:39:52 2020 -0600 Commit: Tom Tromey CommitDate: Fri Mar 13 18:03:41 2020 -0600 Introduce generic_value_print_complex This adds generic_value_print_complex, a value-based analogue of generic_val_print_complex. gdb/ChangeLog 2020-03-13 Tom Tromey * valprint.c (generic_value_print_complex): New function. (generic_value_print): Use it. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c2b0550420..227f9a9a16 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-03-13 Tom Tromey + + * valprint.c (generic_value_print_complex): New function. + (generic_value_print): Use it. + 2020-03-13 Tom Tromey * valprint.c (generic_val_print_float): Don't call diff --git a/gdb/valprint.c b/gdb/valprint.c index f759e0aacb..5bf874eab9 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -966,6 +966,30 @@ generic_val_print_complex (struct type *type, fprintf_filtered (stream, "%s", decorations->complex_suffix); } +/* generic_value_print helper for TYPE_CODE_COMPLEX. */ + +static void +generic_value_print_complex (struct value *val, struct ui_file *stream, + const struct value_print_options *options, + const struct generic_val_print_decorations + *decorations) +{ + fprintf_filtered (stream, "%s", decorations->complex_prefix); + + struct type *type = check_typedef (value_type (val)); + struct value *real_part + = value_from_component (val, TYPE_TARGET_TYPE (type), 0); + value_print_scalar_formatted (real_part, options, 0, stream); + fprintf_filtered (stream, "%s", decorations->complex_infix); + + struct value *imag_part + = value_from_component (val, TYPE_TARGET_TYPE (type), + TYPE_LENGTH (TYPE_TARGET_TYPE (type))); + + value_print_scalar_formatted (imag_part, options, 0, stream); + fprintf_filtered (stream, "%s", decorations->complex_suffix); +} + /* A generic val_print that is suitable for use by language implementations of the la_val_print method. This function can handle most type codes, though not all, notably exception @@ -1206,8 +1230,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, break; case TYPE_CODE_COMPLEX: - generic_val_print_complex (type, 0, stream, - val, options, decorations); + generic_value_print_complex (val, stream, options, decorations); break; case TYPE_CODE_UNION: