]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/testsuite: add gcore_cmd_available predicate proc
authorAndrew Burgess <aburgess@redhat.com>
Tue, 11 Mar 2025 16:42:53 +0000 (16:42 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 6 May 2025 12:06:25 +0000 (13:06 +0100)
Add a new gcore_cmd_available predicate proc that can be used in a
'requires' line, and make use of it in a few tests.

All of the tests I have modified call gdb_gcore_cmd as one of their
first actions and exit if the gcore command is not available, so it
makes sense (I think) to move the gcore command check into a requires
call.

There should be no change in what is actually run after this commit.

gdb/testsuite/gdb.ada/task_switch_in_core.exp
gdb/testsuite/gdb.base/coredump-filter-build-id.exp
gdb/testsuite/gdb.base/gcore.exp
gdb/testsuite/gdb.base/print-symbol-loading.exp
gdb/testsuite/gdb.base/solib-search.exp
gdb/testsuite/gdb.tui/corefile-run.exp
gdb/testsuite/lib/gdb.exp

index 3aafc2b943e818df0cc0258ee1cd28a7bb922409..bded377f0adefe8851228fcd5a4da1356a3cdb13 100644 (file)
@@ -15,7 +15,7 @@
 
 load_lib "ada.exp"
 
-require allow_ada_tests
+require allow_ada_tests gcore_cmd_available
 
 standard_ada_testfile crash
 
index 7594cc2822f93502c1634c623e480d2f35624ffc..eb5b4895b82ff60005630f39cef3fb0f03b21f48 100644 (file)
@@ -28,7 +28,7 @@ if { ![istarget *-*-linux*] } {
     untested "$testfile.exp"
     return -1
 }
-require is_x86_64_m64_target
+require is_x86_64_m64_target gcore_cmd_available
 
 if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug build-id}] } {
     return -1
index 5251e3ffe3fb4297889c86ab1cbb125766bbb0cb..0a9f0991c0ddafa84d737f43f1f18016d11e956f 100644 (file)
@@ -16,6 +16,7 @@
 # This file was written by Michael Snyder (msnyder@redhat.com)
 # This is a test for the gdb command "generate-core-file".
 
+require gcore_cmd_available
 
 standard_testfile
 
index 15f2c19699ad26574e712608791647dbafca71dd..c9e24808f59dcfc243a14974e56f7c6dcc7e6e0c 100644 (file)
@@ -15,7 +15,7 @@
 
 # Test the "print symbol-loading" option.
 
-require allow_shlib_tests
+require allow_shlib_tests gcore_cmd_available
 
 standard_testfile print-symbol-loading-main.c
 set libfile print-symbol-loading-lib
index 2efad18bfdb181318f84313c2ecf60ff384b8397..35b0314d8105d95564981cfbaefa2328848a82fc 100644 (file)
@@ -16,7 +16,7 @@
 # Test solib-search-path, and in the case of solib-svr4.c whether l_addr_p
 # is properly reset when the path is changed.
 
-require allow_shlib_tests
+require allow_shlib_tests gcore_cmd_available
 require {!is_remote target}
 
 # Build "wrong" and "right" versions of the libraries in separate directories.
index 89a48b59a3577b7e1c1b73eb75b6fa8a1d7b79db..657fc83ee92156149c034b6b193ecc719bec2df8 100644 (file)
@@ -18,6 +18,8 @@
 #
 # Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1765117
 
+require gcore_cmd_available
+
 tuiterm_env
 
 standard_testfile tui-layout.c
index ead14bdf49f94fdfc8865255fdec2f79de861ec9..2a5d37c0657dc1bcf495361ead69dc3ecb504d01 100644 (file)
@@ -7007,6 +7007,24 @@ proc gdb_load_cmd { args } {
     return -1
 }
 
+# Return non-zero if 'gcore' command is available.
+gdb_caching_proc gcore_cmd_available { } {
+    gdb_exit
+    gdb_start
+
+    # Does this gdb support gcore?
+    gdb_test_multiple "help gcore" "" {
+       -re -wrap "Undefined command: .*" {
+           return 0
+       }
+       -re -wrap "Save a core file .*" {
+           return 1
+       }
+    }
+
+    return 0
+}
+
 # Invoke "gcore".  CORE is the name of the core file to write.  TEST
 # is the name of the test case.  This will return 1 if the core file
 # was created, 0 otherwise.  If this fails to make a core file because