From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 68A77398640B for ; Thu, 17 Nov 2022 11:38:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 68A77398640B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668685095; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=spalav899JQFBl0fggnmLQIxIf4zejim7//0z5ao560=; b=a0OrfYFShJ+1LVD/7qi0XXwZ5aNfnXdIH0FSHv84cwzbo20brvNbD1Y7Pa4khpaMubfrqf 4BAq4jnSHIg1ivZekixOI33q3IBW5ATNrbrqY/Fdq1wKW0XyvoOr0fMCu2Ve7eo1Wkze7Q P7zTuRbNaapKPToZJcAgVh4FLITuDqU= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-371-Kh6_BhmwNQ2qGTWbXbc5Og-1; Thu, 17 Nov 2022 06:38:14 -0500 X-MC-Unique: Kh6_BhmwNQ2qGTWbXbc5Og-1 Received: by mail-wm1-f71.google.com with SMTP id c1-20020a7bc001000000b003cfe40fca79so209566wmb.6 for ; Thu, 17 Nov 2022 03:38:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=spalav899JQFBl0fggnmLQIxIf4zejim7//0z5ao560=; b=4Vq0q5iwe8T0dUjocpvG9/oaKaufsq7/Q1d6HFpYT54cof9ECE7jUz91wr2d8Zo8ZL jpbk4nkswd8fdcJ53JOPveoxjd3pxquDMiaIvnZkKHARoNZkRbyCa7yfnvHqFx0TdC99 sTyJj7PwMR+aBKWq6RyzKKUnBYBCtMRvSJHruWtiYNERwYk+tF4XlMiI9ufyLS/+tHBv j6gLUTRxTft9D0a0XryTKgyaOD4v7BEl/iDss5lAGnS5S3rpOBUlVwoyhkEXydMroI5E 82ropWiSm0K/mB2LZnHzjvXbLCETz/yOncn5iYgihuVmR985QHhDWRDy4ri3QHlCUNcx Iq7Q== X-Gm-Message-State: ANoB5pn+BJsVQzrO/REoO4cxmukuWrjP0CPR50FrRW3A06Ym2ZmAmtqv FUYaI4W3qej8f68ag1xMJuuMpqbj0IPPu4JkSz4jCy6E+dbHyXPxoZJumoJfCwZWcBn4BEpsthL 4sOIoUb9QUxYb0KqQp42PlZqOHu8FkrXjM3rkUzOSqw61mwmXtUvJ6YUxp3iVAoyD1Ou68nN31g == X-Received: by 2002:adf:f612:0:b0:22e:5d66:dc5d with SMTP id t18-20020adff612000000b0022e5d66dc5dmr1229682wrp.175.1668685092732; Thu, 17 Nov 2022 03:38:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Cf8+eYh/n7ZmU1cJwko4xFkXAEGdFO1A7B/Jps62Am4500+xmMz3up1nit3mcWiViItFYJQ== X-Received: by 2002:adf:f612:0:b0:22e:5d66:dc5d with SMTP id t18-20020adff612000000b0022e5d66dc5dmr1229666wrp.175.1668685092538; Thu, 17 Nov 2022 03:38:12 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id o18-20020a05600c4fd200b003cfa26c410asm5962681wmq.20.2022.11.17.03.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 03:38:12 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Tom Tromey , Andrew Burgess Subject: [PATCHv2 2/2] gdb/testsuite: fix gdb.debuginfod/fetch_src_and_symbols.exp with Clang Date: Thu, 17 Nov 2022 11:38:06 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: <87wn7uuakv.fsf@tromey.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. The problem appears to be with Clang's generated line table. The test source looks like this: int main() { asm ("main_label: .globl main_label"); return 0; } 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. However, with Clang 9.0.2, I see GDB stop on the 'asm' line. 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. 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. 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. --- 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/testsuite/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 . */ +volatile int global_var = 0; + /* Dummy main function. */ 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/testsuite/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\\. .*" # GDB should now find the executable file. clean_restart -- 2.25.4