public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 5/6] gdb/testsuite: fix gdb.debuginfod/fetch_src_and_symbols.exp with Clang
Date: Fri, 11 Nov 2022 16:36:24 +0000	[thread overview]
Message-ID: <d7e057da40d721d3ba37f9e7008186909dee7a09.1668184173.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1668184173.git.aburgess@redhat.com>

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.

I propose adding some code to the test script to step GDB onto the
next line if we stop on the 'asm' line.  With this change in place, I
now see the test fully passing with Clang 9.0.1 and 15.0.2, as well as
with gcc.
---
 .../gdb.debuginfod/fetch_src_and_symbols.exp  | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
index b57b3201cf7..cebaa435102 100644
--- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
+++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
@@ -161,6 +161,27 @@ proc_with_prefix no_url { } {
     if ![runto_main] {
 	return -1
     }
+
+    # Some older versions of Clang (e.g. 9.0.1) were observed stopped
+    # at the 'asm' line rather than the 'return' line in main.c.  This
+    # messes up some of the expected patterns later in the test.
+    set rtn_lineno [gdb_get_line_number "return 0;"]
+    set prev_lineno [expr $rtn_lineno - 1]
+    gdb_test_multiple "info line" "" {
+	-wrap -re "\r\nLine ${prev_lineno} of .*" {
+	    gdb_test "step"
+	    pass $gdb_test_name
+	}
+	-wrap -re "\r\nLine ${rtn_lineno} of .*" {
+	    pass $gdb_test_name
+	}
+	-wrap -re "\r\nLine ${::decimal} of .*" {
+	    # Not sure what line this stopped on, but later tests are
+	    # probably going to fail.
+	    fail $gdb_test_name
+	}
+    }
+
     gdb_test "generate-core-file $::corefile" "Saved corefile $::corefile" \
 	"file [file tail $::corefile] gen"
     file rename -force ${binfile}2 $debugdir
-- 
2.25.4


  parent reply	other threads:[~2022-11-11 16:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-11 16:36 [PATCH 0/6] The DWARF assembler and Clang Andrew Burgess
2022-11-11 16:36 ` [PATCH 1/6] gdb/testsuite: don't avoid DWARF assembler tests with Clang Andrew Burgess
2022-11-11 16:36 ` [PATCH 2/6] gdb/testsuite: fix gdb.trace/unavailable-dwarf-piece.exp " Andrew Burgess
2022-11-16 14:41   ` Bruno Larsen
2022-11-17 11:06     ` Andrew Burgess
2022-12-12 17:55   ` Tom Tromey
2022-12-13 15:39     ` Andrew Burgess
2022-11-11 16:36 ` [PATCH 3/6] gdb/testsuite: fix gdb.compile/compile-ops.exp with clang Andrew Burgess
2022-11-16 16:27   ` Tom Tromey
2022-11-11 16:36 ` [PATCH 4/6] gdb/testsuite: add (and use) a new build-id compile option Andrew Burgess
2022-11-11 16:36 ` Andrew Burgess [this message]
2022-11-16 16:29   ` [PATCH 5/6] gdb/testsuite: fix gdb.debuginfod/fetch_src_and_symbols.exp with Clang Tom Tromey
2022-11-17 11:38     ` [PATCHv2 0/2] Fix " Andrew Burgess
2022-11-17 11:38       ` [PATCHv2 1/2] gdb/testsuite: rename source file gdb.debuginfod/main.c Andrew Burgess
2022-11-17 11:38       ` [PATCHv2 2/2] gdb/testsuite: fix gdb.debuginfod/fetch_src_and_symbols.exp with Clang Andrew Burgess
2022-11-17 19:29       ` [PATCHv2 0/2] Fix " Tom Tromey
2022-11-11 16:36 ` [PATCH 6/6] gdb/testsuite: rewrite gdb.cp/call-method-register.exp with dwarf assembler Andrew Burgess
2022-11-16 11:59   ` Lancelot SIX
2022-11-16 16:32 ` [PATCH 0/6] The DWARF assembler and Clang Tom Tromey
2022-11-18 11:48   ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d7e057da40d721d3ba37f9e7008186909dee7a09.1668184173.git.aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).