public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bruno Larsen <blarsen@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v5 1/7] gdb/testsuite: Add a proc to test where compiler links the epilogue
Date: Wed, 14 Sep 2022 15:14:21 +0200	[thread overview]
Message-ID: <20220914131427.269689-2-blarsen@redhat.com> (raw)
In-Reply-To: <20220914131427.269689-1-blarsen@redhat.com>

Different compilers link the epilogue of functions to different lines.
As an example, gcc links it to the closing brace of the function,
whereas clang links it to the last statement of the function.  This
difference is important for the testsuite, since the where GDB will land
after a step can be wildly different.  Where possible, this dependency
should be side-stepped in the testsuite, but it isn't always possible,
so this commit adds a gdb_caching_proc that is able to detect where the
epilogue is linked, so tests can react accordingly.
---

Andrew OK'd this patch previously, but there was no patches that
required it, so I held off on pushing it

 gdb/testsuite/lib/gdb.exp | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 0f6bb20b49c..68536b00f14 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -8872,5 +8872,37 @@ proc gdb_step_until { regexp {test_name ""} {max_steps 10} } {
     }
 }
 
+# Check if the compiler emits epilogue information associated
+# with the closing brace or with the last statement line.
+#
+# This proc restarts GDB
+#
+# Returns True if it is associated with the closing brace,
+# False if it is the last statement
+gdb_caching_proc have_epilogue_line_info {
+
+    set main {
+	int
+	main ()
+	{
+	    return 0;
+	}
+    }
+    if {![gdb_simple_compile "simple_program" $main]} {
+	 return False
+    }
+
+    clean_restart $obj
+
+    gdb_test_multiple "info line 6" "epilogue test" {
+	-re -wrap ".*starts at address.*and ends at.*" {
+	    return True
+	}
+	-re -wrap ".*" {
+	    return False
+	}
+    }
+}
+
 # Always load compatibility stuff.
 load_lib future.exp
-- 
2.37.3


  reply	other threads:[~2022-09-14 13:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14 13:14 [PATCH v5 0/7] Clean gdb.base when testing with clang Bruno Larsen
2022-09-14 13:14 ` Bruno Larsen [this message]
2022-09-14 13:14 ` [PATCH v5 2/7] Change gdb.base/skip-solib.exp deal with lack of epilogue information Bruno Larsen
2022-09-14 13:14 ` [PATCH v5 3/7] gdb/testsuite: fix testing gdb.base/skip-inline.exp with clang Bruno Larsen
2022-09-14 13:14 ` [PATCH v5 4/7] gdb/testsuite: fix gdb.base/msym-bp-shl when running with Clang Bruno Larsen
2022-09-14 13:14 ` [PATCH v5 5/7] fix gdb.base/jit-elf.exp when testing with clang Bruno Larsen
2022-09-14 13:14 ` [PATCH v5 6/7] gdb.base/skip.exp: Use finish to exit functions Bruno Larsen
2022-09-14 13:14 ` [PATCH v5 7/7] gdb/testsuite: Add test to step through function epilogue Bruno Larsen
2022-09-21 16:05 ` [PATCH v5 0/7] Clean gdb.base when testing with clang Tom Tromey
2022-09-22  9:05   ` Bruno Larsen

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=20220914131427.269689-2-blarsen@redhat.com \
    --to=blarsen@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).