From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 98173 invoked by alias); 26 Feb 2015 15:18:25 -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 98160 invoked by uid 89); 26 Feb 2015 15:18:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 26 Feb 2015 15:18:23 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1QFIIdP004592 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 26 Feb 2015 10:18:19 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1QFIHgb005216; Thu, 26 Feb 2015 10:18:18 -0500 Message-ID: <54EF3939.2020401@redhat.com> Date: Thu, 26 Feb 2015 15:18:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Antoine Tremblay , gdb-patches@sourceware.org Subject: Re: [PATCH] Fix print of value type in a corner case of finish References: <1424957146-25705-1-git-send-email-antoine.tremblay@ericsson.com> <54EF212E.3020602@redhat.com> <54EF298B.1010906@ericsson.com> In-Reply-To: <54EF298B.1010906@ericsson.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-02/txt/msg00762.txt.bz2 On 02/26/2015 02:11 PM, Antoine Tremblay wrote: > On 02/26/2015 08:35 AM, Pedro Alves wrote: >> It there a way to add a test? > I would need to add a test that's specific to an architecture that does > not support the struct return value... Hmm, AFAICS, it's not that the architecture doesn't support the struct return value, or some kind of memory read error or some such. It's that the ABI returns the object using struct return convention / RETURN_VALUE_STRUCT_CONVENTION: /* Return the value of the result of a function at the end of a 'finish' command/BP. */ struct value * get_return_value (struct value *function, struct type *value_type) { ... switch (gdbarch_return_value (gdbarch, function, value_type, NULL, NULL, NULL)) { ... break; case RETURN_VALUE_STRUCT_CONVENTION: value = NULL; break; I think that we make the test return a big enough structure, we'll hit RETURN_VALUE_STRUCT_CONVENTION on most architectures (but not x86...)? For archs that don't do RETURN_VALUE_STRUCT_CONVENTION, the test could cope, by also passing if GDB manages to extract the real value. In sum, PASS if real value, or at least type. FAIL otherwise. But, ... I'm actually very much surprised we don't test this already. So I did $ grep -rn "\"finish\"" testsuite/ and noticed: ... gdb.base/structs.exp:259:# "finish") and correctly extract/store any corresponding gdb.base/structs.exp:276:# is in three parts: test "return"; test "finish"; check that the two gdb.base/structs.exp:299: # consistency between this and the "finish" case. gdb.base/structs.exp:404: # Check that a "finish" works. gdb.base/structs.exp:427: gdb_test_multiple "finish" "${test}" { gdb.base/structs.exp:467: # Since "finish" works in more cases than "return" (see gdb.base/structs.exp:470: # known implies that the "finish" value is known (but not the ... And lo: set test "finish foo; ${tests}" set finish_value_known 1 gdb_test_multiple "finish" "${test}" { -re "Value returned is .*${gdb_prompt} $" { pass "${test}" } -re "Cannot determine contents.*${gdb_prompt} $" { # Expected bad value. For the moment this is ok. set finish_value_known 0 pass "${test}" } } So the regex here is too lax and missed this bug. Could you tweak it to make sure some type was output? > >> Also please use "const char *" for type_name, so C++ >> doesn't complain. :-) > Humm not sure I understand here since type_to_string returns a char* > that needs to be freed ? > > Converting to const char* would make make_cleanup complain... > > How is C++ complaining ? Oh, nevermind, that was a thinko on my part, sorry. Thanks, Pedro Alves