From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id A56D5384F490; Fri, 18 Nov 2022 11:46:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A56D5384F490 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668772007; bh=RXB2TCdYzjXBMXmfP2lHkdJMP6m8MzIKgdYInajzo6w=; h=From:To:Subject:Date:From; b=GDOOBlF4N5pI+W6fum866QU93YT/6zH4TCh63xkiJCO6dLb6xhsZb/Y2CaOw57Aqf oqLboXGB6d/F75UA1durghcHMHaUSQeD+suP2cSQuSBlgUVNxzcAHfcDo1/M6WJuIZ veOtlIfySbPj/gSJEyu3Ddxz1ubwSAkZaVoCYEFE= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: fix gdb.debuginfod/fetch_src_and_symbols.exp with Clang X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 59d6ca65f5e29a110be55f5057c710e29527e229 X-Git-Newrev: e86741b65ba9a614054241c0be45efb04484e320 Message-Id: <20221118114647.A56D5384F490@sourceware.org> Date: Fri, 18 Nov 2022 11:46:47 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3De86741b65ba9= a614054241c0be45efb04484e320 commit e86741b65ba9a614054241c0be45efb04484e320 Author: Andrew Burgess Date: Fri Nov 11 15:58:45 2022 +0000 gdb/testsuite: fix gdb.debuginfod/fetch_src_and_symbols.exp with Clang =20 The gdb.debuginfod/fetch_src_and_symbols.exp test is showing a single failure when run with some older versions of Clang, e.g. 9.0.1. =20 The problem appears to be with Clang's generated line table. The test source looks like this: =20 int main() { asm ("main_label: .globl main_label"); return 0; } =20 In GDB, when we 'start', we expect to stop at the 'return 0;' line. This is the behaviour when the compiler is gcc, or later versions of Clang. =20 However, with Clang 9.0.2, I see GDB stop on the 'asm' line. =20 In this commit I'll fix this issue by placing a breakpoint on the return line, and then using gdb_continue_to_breakpoint to ensure we have stopped in the correct place. =20 Of course, using gdb_continue_to_breakpoint will only work if we are not already stopped at the breakpoint location, so I've added some filler work before the 'return 0;' line. With this done we can use gdb_continue_to_breakpoint in all cases. =20 As a result of adding the new filler work, one of the later tests, that used the 'list' command, no longer see the correct expected output (the top line of the source file is no longer included in the output). I've fixed this by listing a known specific line, the test is checking that GDB managed to find the source file, it doesn't matter which source line we list, as long as we can list something. Diff: --- gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.c | 5 ++++- gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.c b/gdb/tes= tsuite/gdb.debuginfod/fetch_src_and_symbols.c index 412bd53edda..7215e3c6484 100644 --- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.c +++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.c @@ -15,11 +15,14 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . = */ =20 +volatile int global_var =3D 0; + /* Dummy main function. */ =20 int main() { asm ("main_label: .globl main_label"); - return 0; + ++global_var; + return 0; /* Breakpoint here. */ } diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/t= estsuite/gdb.debuginfod/fetch_src_and_symbols.exp index 8b3c2cf709e..e95526a069f 100644 --- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp +++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp @@ -161,6 +161,10 @@ proc_with_prefix no_url { } { if ![runto_main] { return -1 } + + gdb_breakpoint [gdb_get_line_number "Breakpoint here"] + gdb_continue_to_breakpoint "stop at last line of main" + gdb_test "generate-core-file $::corefile" "Saved corefile $::corefile"= \ "file [file tail $::corefile] gen" file rename -force ${binfile}2 $debugdir @@ -217,7 +221,8 @@ proc_with_prefix local_url { } { gdb_test_no_output "set substitute-path $outputdir /dev/null" \ "set substitute-path" gdb_test "br main" "Breakpoint 1 at.*file.*" - gdb_test "l" ".*This program is distributed in the hope.*" + set lineno [gdb_get_line_number "Breakpoint here"] + gdb_test "list $lineno" "return 0;\[^\r\n\]+Breakpoint here\\. .*" =20 # GDB should now find the executable file. clean_restart