public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb/testsuite: Add a proc to test where compiler links the epilogue
@ 2022-09-22  9:04 Bruno Larsen
  0 siblings, 0 replies; only message in thread
From: Bruno Larsen @ 2022-09-22  9:04 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=07bb02de7232c7d0974007296540d9887532b952

commit 07bb02de7232c7d0974007296540d9887532b952
Author: Bruno Larsen <blarsen@redhat.com>
Date:   Wed Jul 20 16:44:28 2022 -0300

    gdb/testsuite: Add a proc to test where compiler links the epilogue
    
    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.

Diff:
---
 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-22  9:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22  9:04 [binutils-gdb] gdb/testsuite: Add a proc to test where compiler links the epilogue Bruno Larsen

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).