From 07bb02de7232c7d0974007296540d9887532b952 Mon Sep 17 00:00:00 2001 From: Bruno Larsen Date: Wed, 20 Jul 2022 16:44:28 -0300 Subject: [PATCH] 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. --- 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.30.2