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.
This commit is contained in:
Bruno Larsen
2022-07-20 16:44:28 -03:00
parent b59f8a90ba
commit 07bb02de72

View File

@ -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. # Always load compatibility stuff.
load_lib future.exp load_lib future.exp