From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iqijKXZKL2FkOAAAWB0awg (envelope-from ) for ; Wed, 01 Sep 2021 05:40:06 -0400 Received: by simark.ca (Postfix, from userid 112) id 3B4F01EE21; Wed, 1 Sep 2021 05:40:06 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 27F5E1E813 for ; Wed, 1 Sep 2021 05:39:59 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 415283857C5B for ; Wed, 1 Sep 2021 09:39:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 415283857C5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1630489198; bh=kRdX1ujXTSTo2bjbLnmn6BVi2XKVAS63NJTKRqHmIbU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=RQOz9YZ86/Q5Zguz2D7Eg70L5FvalGSGDZgYDD04ntXcjb9gzDfVx9aqZZ/zppo8Y /d5jGDkFrFQXVsRwG8WGHkXbu3vcWfVkYkbfAgglFe6pavw27QVDMhT6/iy7kXmkY9 sLfpiYY7c+oqy1OIY1ip4AuktywvAFH7h6JHPiNA= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 4A1E4385841D for ; Wed, 1 Sep 2021 09:39:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4A1E4385841D Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7A72B1FED5; Wed, 1 Sep 2021 09:39:29 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 6234C1396A; Wed, 1 Sep 2021 09:39:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id t6jfFlFKL2EMHQAAGKfGzw (envelope-from ); Wed, 01 Sep 2021 09:39:29 +0000 Date: Wed, 1 Sep 2021 11:39:27 +0200 To: gdb-patches@sourceware.org Subject: [committed, master + 11][gdb/testsuite] Fix gdb.fortran/call-no-debug.exp symbol search Message-ID: <20210901093926.GA13388@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, On openSUSE Tumbleweed I ran into: ... (gdb) ptype outstring_func.part^M No symbol "outstring_func" in current context.^M (gdb) FAIL: gdb.fortran/call-no-debug.exp: ptype outstring_func.part ... while on openSUSE Leap 15.2 I have instead: ... (gdb) ptype string_func_^M type = ()^M (gdb) PASS: gdb.fortran/call-no-debug.exp: ptype string_func_ ... The difference is caused by the result for "info function string_func", which is this for the latter: ... (gdb) info function string_func^M All functions matching regular expression "string_func":^M ^M Non-debugging symbols:^M 0x000000000040089c string_func_^M ... but this for the former: ... (gdb) info function string_func^M All functions matching regular expression "string_func":^M ^M Non-debugging symbols:^M 0x00000000004012bb string_func_^M 0x00007ffff7bac5b0 outstring_func.part^M 0x00007ffff7bb1a00 outstring_func.part^M ... The extra symbols are part of glibc: ... $ nm /lib64/libc.so.6 | grep string_func 00000000000695b0 t outstring_func.part.0 000000000006ea00 t outstring_func.part.0 ... If glibc debug info is installed, we get instead: ... (gdb) info function string_func^M All functions matching regular expression "string_func":^M ^M File /usr/src/debug/glibc-2.33-9.1.x86_64/stdio-common/vfprintf-internal.c:^M 236: static int outstring_func(int, size_t, const unsigned int *, FILE *);^M ^M File vfprintf-internal.c:^M 236: static int outstring_func(int, size_t, const unsigned char *, FILE *);^M ^M Non-debugging symbols:^M 0x00000000004012bb string_func_^M ... and the FAIL doesn't trigger. Fix this by calling "info function string_func" before starting the exec, such that only symbols of the exec are taken into account. Tested on x86_64-linux. Committed to trunk. Thanks, - Tom [gdb/testsuite] Fix gdb.fortran/call-no-debug.exp symbol search gdb/testsuite/ChangeLog: 2021-09-01 Tom de Vries * gdb.fortran/call-no-debug.exp: Avoid shared lib symbols for find_mangled_name calls. --- gdb/testsuite/gdb.fortran/call-no-debug.exp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gdb/testsuite/gdb.fortran/call-no-debug.exp b/gdb/testsuite/gdb.fortran/call-no-debug.exp index 82bf32c82c7..a5e982533fd 100644 --- a/gdb/testsuite/gdb.fortran/call-no-debug.exp +++ b/gdb/testsuite/gdb.fortran/call-no-debug.exp @@ -28,11 +28,6 @@ if {[prepare_for_testing_full "failed to prepare" \ return -1 } -if ![fortran_runto_main] { - untested "could not run to main" - return -1 -} - # Find a possibly mangled version of NAME, a function we want to call # that has no debug information available. We hope that the mangled # version of NAME contains the pattern NAME, and so we use 'info @@ -67,12 +62,22 @@ proc find_mangled_name { name } { return $symbol_name } +# Sample before before starting the exec, in order to avoid picking up symbols +# from shared libs. +set some_func [find_mangled_name "some_func"] +set string_func [find_mangled_name "string_func"] + +if ![fortran_runto_main] { + untested "could not run to main" + return -1 +} + # Call the function SOME_FUNC, that takes a single integer and returns # an integer. As the function has no debug information then we have # to pass the integer argument as '&1' so that GDB will send the # address of an integer '1' (as Fortran arguments are pass by # reference). -set symbol_name [find_mangled_name "some_func"] +set symbol_name $some_func if { $symbol_name == "" } { untested "couldn't find suitable name for 'some_func'" } else { @@ -91,7 +96,7 @@ if { $symbol_name == "" } { # The compiled program is expecting the address of the string, so we # prefix that argument with '&', but the artificial length parameter # is pass by value, so there's no need for '&' in that case. -set symbol_name [find_mangled_name "string_func"] +set symbol_name $string_func if { $symbol_name == "" } { untested "couldn't find suitable name for 'string_func'" } else {