From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72346 invoked by alias); 26 Feb 2015 15:46:08 -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 72333 invoked by uid 89); 26 Feb 2015 15:46:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg21.ericsson.net Received: from usevmg21.ericsson.net (HELO usevmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 26 Feb 2015 15:46:05 +0000 Received: from EUSAAHC008.ericsson.se (Unknown_Domain [147.117.188.96]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id 1E.CC.25146.C2FDEE45; Thu, 26 Feb 2015 09:54:04 +0100 (CET) Received: from elx1123rzr-fp.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.96) with Microsoft SMTP Server (TLS) id 14.3.210.2; Thu, 26 Feb 2015 10:46:03 -0500 From: Antoine Tremblay To: CC: , Antoine Tremblay Subject: [PATCH v2] Fix print of value type in a corner case of finish Date: Thu, 26 Feb 2015 15:46:00 -0000 Message-ID: <1424965559-12032-1-git-send-email-antoine.tremblay@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2015-02/txt/msg00764.txt.bz2 When doing finish in a function, if gdb fails to return a value, gdb also fails at printing the value type if this type is a struct. For example : (gdb) fin .... Value returned has type: . Cannot determine contents This patch fixes this by calling type_to_string to print the type so that we can support these types. This patch returns the following example output : (gdb) fin .... Value returned has type: struct test. Cannot determine contents Also, this patch modifies structs.exp to check that we return the correct type. gdb/ChangeLog: * gdb/infcmd.c (print_return_value): use type_to_string to print type. gdb/testsuite/ChangeLog: * gdb.base/structs.exp: Check for correct struct on finish. --- gdb/infcmd.c | 8 +++++++- gdb/testsuite/gdb.base/structs.exp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 9a1fb8d..3737b8f 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1607,10 +1607,16 @@ print_return_value (struct value *function, struct type *value_type) } else { + struct cleanup *oldchain; + char *type_name; + + type_name = type_to_string (value_type); + oldchain = make_cleanup (xfree, type_name); ui_out_text (uiout, "Value returned has type: "); - ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type)); + ui_out_field_string (uiout, "return-type", type_name); ui_out_text (uiout, "."); ui_out_text (uiout, " Cannot determine contents\n"); + do_cleanups (oldchain); } } diff --git a/gdb/testsuite/gdb.base/structs.exp b/gdb/testsuite/gdb.base/structs.exp index 927e3b8..5d94a41 100644 --- a/gdb/testsuite/gdb.base/structs.exp +++ b/gdb/testsuite/gdb.base/structs.exp @@ -428,7 +428,7 @@ proc test_struct_returns { n } { -re "Value returned is .*${gdb_prompt} $" { pass "${test}" } - -re "Cannot determine contents.*${gdb_prompt} $" { + -re "Value returned has type: struct struct$n. Cannot determine contents.*${gdb_prompt} $" { # Expected bad value. For the moment this is ok. set finish_value_known 0 pass "${test}" -- 1.7.9.5