aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Jung Bauermann <thiago.bauermann@linaro.org>2024-04-19 03:02:46 -0300
committerThiago Jung Bauermann <thiago.bauermann@linaro.org>2024-04-24 13:20:42 -0300
commitf5ef12c3f1af890dcdc6dc54f5ea58a05c6cf65a (patch)
tree2255c7343e93dedcce69a1ec23016e8d7cdd4178
parentf908b93b48634083338eed5183ac519db8925b38 (diff)
downloadbinutils-f5ef12c3f1af890dcdc6dc54f5ea58a05c6cf65a.zip
binutils-f5ef12c3f1af890dcdc6dc54f5ea58a05c6cf65a.tar.gz
binutils-f5ef12c3f1af890dcdc6dc54f5ea58a05c6cf65a.tar.bz2
gdb/testsuite: Add libc_has_debug_info require helper
Factor the test for libc debug info out of gdb.base/relativedebug.exp to a new procedure. Also, change the "info sharedlibrary" test to explicitly detect when libc has debug info. Approved-by: Kevin Buettner <kevinb@redhat.com>
-rw-r--r--gdb/testsuite/gdb.base/relativedebug.exp13
-rw-r--r--gdb/testsuite/lib/gdb.exp56
2 files changed, 57 insertions, 12 deletions
diff --git a/gdb/testsuite/gdb.base/relativedebug.exp b/gdb/testsuite/gdb.base/relativedebug.exp
index bf8d768..f882a5c 100644
--- a/gdb/testsuite/gdb.base/relativedebug.exp
+++ b/gdb/testsuite/gdb.base/relativedebug.exp
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-require {!target_info exists gdb,nosignals}
+require {!target_info exists gdb,nosignals} libc_has_debug_info
standard_testfile .c
@@ -28,17 +28,6 @@ clean_restart ${binfile}
runto_main
-set test "info sharedlibrary"
-gdb_test_multiple $test $test {
- -re ".*\(\\*\)\[^\r\n\]*/libc\.so.*$gdb_prompt $" {
- # Skip the test below if libc doesn't have debug info.
- unsupported "libc doesn't have debug info"
- return -1
- }
- -re ".*$gdb_prompt $" {
- }
-}
-
# pause () -> SIGALRM -> handler () -> abort ()
gdb_test "continue" "Program received signal SIGABRT.*"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index cbd37fd..1e26937 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3699,6 +3699,62 @@ proc support_displaced_stepping {} {
return 0
}
+# Return 1 if GDB can find the libc debug info, or 0 and a reason string if it
+# can't. This procedure is meant to be called by the require procedure.
+gdb_caching_proc libc_has_debug_info {} {
+ global srcdir subdir gdb_prompt inferior_exited_re
+
+ set me "libc_has_debug_info"
+
+ # Compile a test program.
+ set src {
+ #include <stdio.h>
+
+ int main (void) {
+ printf ("Hello, world!\n");
+ return 0;
+ }
+ }
+ if {![gdb_simple_compile $me $src executable {debug}]} {
+ return [list 0 "failed to compile test program"]
+ }
+
+ # No error message, compilation succeeded so now run it via gdb.
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load "$obj"
+ runto_main
+ set test "info sharedlibrary libc.so"
+ gdb_test_multiple $test $test {
+ -re ".*\(\\*\)\[^\r\n\]*/libc\.so.*$gdb_prompt $" {
+ # Matched the "(*)" in the "Syms Read" columns which means:
+ # "(*): Shared library is missing debugging information."
+ verbose -log "$me: libc doesn't have debug info"
+ set libc_has_debug_info 0
+ set message "libc doesn't have debug info"
+ }
+ -re ".*Yes\[ \t\]+\[^\r\n\]*/libc\.so.*$gdb_prompt $" {
+ verbose -log "$me: libc has debug info"
+ set libc_has_debug_info 1
+ }
+ default {
+ set libc_has_debug_info 0
+ set message "libc not found in the inferior"
+ }
+ }
+ gdb_exit
+ remote_file build delete $obj
+
+ verbose "$me: returning $libc_has_debug_info" 2
+ if { $libc_has_debug_info } {
+ return $libc_has_debug_info
+ } else {
+ return [list $libc_has_debug_info $message]
+ }
+}
+
# Run a test on the target to see if it supports vmx hardware. Return 1 if so,
# 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.