From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id A81033947417 for ; Mon, 31 Aug 2020 08:47:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A81033947417 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 85877B5A8; Mon, 31 Aug 2020 08:47:47 +0000 (UTC) Subject: Re: [committed][gdb/testsuite] Add gdb.base/eh_return.exp From: Tom de Vries To: Luis Machado , gdb-patches@sourceware.org References: <20200816113123.GA29297@delia> <3583b056-388d-86b4-c213-e7b09e30ab89@suse.de> <7a8cc2a5-ea23-31c9-51d5-e81b6d0a2069@suse.de> Autocrypt: addr=tdevries@suse.de; keydata= xsBNBF0ltCcBCADDhsUnMMdEXiHFfqJdXeRvgqSEUxLCy/pHek88ALuFnPTICTwkf4g7uSR7 HvOFUoUyu8oP5mNb4VZHy3Xy8KRZGaQuaOHNhZAT1xaVo6kxjswUi3vYgGJhFMiLuIHdApoc u5f7UbV+egYVxmkvVLSqsVD4pUgHeSoAcIlm3blZ1sDKviJCwaHxDQkVmSsGXImaAU+ViJ5l CwkvyiiIifWD2SoOuFexZyZ7RUddLosgsO0npVUYbl6dEMq2a5ijGF6/rBs1m3nAoIgpXk6P TCKlSWVW6OCneTaKM5C387972qREtiArTakRQIpvDJuiR2soGfdeJ6igGA1FZjU+IsM5ABEB AAHNH1RvbSBkZSBWcmllcyA8dGRldnJpZXNAc3VzZS5kZT7CwKsEEwEIAD4WIQSsnSe5hKbL MK1mGmjuhV2rbOJEoAUCXSW0JwIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAh CRDuhV2rbOJEoBYhBK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fOWJ26IOCoPnSVUvKPEOH9dv+sNy7jyBsP5QxeTqwxC/1ZtNS DUCSFQjqA6bEGwM22dP8OUY6SC94x1G81A9/xbtm9LQxKm0EiDH8KBMLfQ== Message-ID: <36fa451b-fcb5-85e9-19d9-ccac81610417@suse.de> Date: Mon, 31 Aug 2020 10:47:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <7a8cc2a5-ea23-31c9-51d5-e81b6d0a2069@suse.de> Content-Type: multipart/mixed; boundary="------------BF599A075E3BE0E223D4BDB1" Content-Language: en-US X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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-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: , X-List-Received-Date: Mon, 31 Aug 2020 08:47:15 -0000 This is a multi-part message in MIME format. --------------BF599A075E3BE0E223D4BDB1 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 8/27/20 1:14 AM, Tom de Vries wrote: > On 8/26/20 8:02 PM, Tom de Vries wrote: >> On 8/26/20 7:20 PM, Luis Machado wrote: >>> On 8/16/20 8:31 AM, Tom de Vries wrote: >>>> Hi, >>>> >>>> In PR25350, an internal error was reported: >>>> ... >>>> (gdb) break *eh2+0x7e >>>> Breakpoint 1 at 0x13e2: file small.c, line 38. >>>> (gdb) run >>>> Starting program: a.out >>>> [Thread debugging using libthread_db enabled] >>>> Using host libthread_db library "/usr/lib/libthread_db.so.1". >>>> >>>> Breakpoint 1, 0x00005555555553e2 in eh2 ( >>>> frame.c:558: internal-error: frame_id get_frame_id(frame_info*): \ >>>>    Assertion `stashed' failed. >>>> A problem internal to GDB has been detected, >>>> further debugging may prove unreliable. >>>> ... >>>> >>>> The internal error does not reproduce after recent commit 547ce8f00b >>>> "[gdb/backtrace] Fix printing of fortran string args". >>>> >>>> Add the corresponding test-case as regression test, given that the >>>> code is >>>> rather atypical. >>>> >>>> Tested on x86_64-linux. >>> >>> This doesn't work so well on aarch64-linux because the breakpoint >>> location from before running the program doesn't exists after running >>> it. Things get relocated. >>> >> >> Right, I don't think that's architecture-related. >> >> I'm running into the same issue on x86_64-linux with target board >> unix/-fPIE/-pie. >> >>> -- >>> >>> (gdb) break *0x000000000000099c^M >>> Breakpoint 1 at 0x99c: file >>> /home/luis.machado/work/tcwg/build/binutils-gdb-master/gdb/testsuite/../../../../repos/binutils-gdb/gdb/testsuite/gdb.base/eh_return.c, >>> line 54.^M >>> (gdb) PASS: gdb.base/eh_return.exp: setting breakpoint at >>> *0x000000000000099c >>> run ^M >>> Starting program: >>> /home/luis.machado/work/tcwg/build/binutils-gdb-master/gdb/testsuite/outputs/gdb.base/eh_return/eh_return >>> ^M >>> Warning:^M >>> Cannot insert breakpoint 1.^M >>> Cannot access memory at address 0x99c^M >>> ^M >>> (gdb) FAIL: gdb.base/eh_return.exp: hit breakpoint >>> >>> -- >>> >>> Shouldn't we insert a breakpoint after the relocation has happened? >> >> As I mentioned in the test-case: >> ... >> # The assert did not reproduce when running to main, and continuing to >> # the breakpoint, so instead, run to the breakpoint. >> ... >> So I'm afraid that's not going to work. >> >>> Or >>> add the breakpoint to a symbolic reference? >> >> Yeah, that might work. If not, we'll have to restrict this to no-pie. > > So, I tried this using: > ... > $ git diff > diff --git a/gdb/testsuite/gdb.base/eh_return.c > b/gdb/testsuite/gdb.base/eh_ret > urn.c > index 80eea9c783..ba8c1c51aa 100644 > --- a/gdb/testsuite/gdb.base/eh_return.c > +++ b/gdb/testsuite/gdb.base/eh_return.c > @@ -51,6 +51,8 @@ eh2 (void *p) > { > eh2a (val, val, val, val, val, val, val, val, p); > __builtin_eh_return (0, p); > + here: > + (void)0; > } > > > diff --git a/gdb/testsuite/gdb.base/eh_return.exp > b/gdb/testsuite/gdb.base/eh_r > eturn.exp > index e38398ed37..182b2ed86d 100644 > --- a/gdb/testsuite/gdb.base/eh_return.exp > +++ b/gdb/testsuite/gdb.base/eh_return.exp > @@ -22,23 +22,9 @@ if {[prepare_for_testing "failed to prepare" > clean_restart ${binfile} > > -gdb_breakpoint "*$address" message > +gdb_breakpoint "eh2:here" message > > # The assert did not reproduce when running to main, and continuing to the > # breakpoint, so instead, run to the breakpoint. > ... > > But then we run into another internal-error while setting the > breakpoint, see PR25067: > ... > src/gdb/linespec.c:3233: internal-error: void decode_line_full(const > event_location*, int, program_space*, symtab*, int, linespec_result*, > const char*, const char*): Assertion `result.size () == 1 || > canonical->pre_expanded' failed.^M > A problem internal to GDB has been detected,^M > further debugging may prove unreliable.^M > ... > Something I didn't realize when trying this out: __builtin_eh_return is a noreturn builtin, so adding a label after it doesn't work. So I've gone with nopie. Committed as attached. Thanks, - Tom --------------BF599A075E3BE0E223D4BDB1 Content-Type: text/x-patch; charset=UTF-8; name="0001-gdb-testsuite-Add-nopie-to-gdb.base-eh_return.exp.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0001-gdb-testsuite-Add-nopie-to-gdb.base-eh_return.exp.patch" [gdb/testsuite] Add nopie to gdb.base/eh_return.exp When running test-case gdb.base/eh_return.exp with target board unix/-fPIE/-pie, we run into: ... (gdb) break *0x88e^M Breakpoint 1 at 0x88e: file eh_return.c, line 54.^M (gdb) PASS: gdb.base/eh_return.exp: setting breakpoint at *0x88e run ^M Starting program: eh_return ^M Warning:^M Cannot insert breakpoint 1.^M Cannot access memory at address 0x88e^M ^M (gdb) FAIL: gdb.base/eh_return.exp: hit breakpoint ... The problem is that gdb does not support setting breakpoints on unrelocated addresses. Fix this by using nopie for the test-case. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-08-31 Tom de Vries * gdb.base/eh_return.exp: Use nopie. --- gdb/testsuite/gdb.base/eh_return.exp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.base/eh_return.exp b/gdb/testsuite/gdb.base/eh_return.exp index e38398ed37..78a4af4b0c 100644 --- a/gdb/testsuite/gdb.base/eh_return.exp +++ b/gdb/testsuite/gdb.base/eh_return.exp @@ -18,7 +18,8 @@ standard_testfile -if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { +if {[prepare_for_testing "failed to prepare" $testfile $srcfile \ + {debug nopie}]} { return -1 } --------------BF599A075E3BE0E223D4BDB1--