From: Simon Marchi Date: Mon, 16 Jun 2025 19:32:59 +0000 (-0400) Subject: gdb/testsuite: check that "info shared" and "info linker-namespaces" before running... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f9fca5aa58340fe3cedb3fdb742030690403a518;p=thirdparty%2Fbinutils-gdb.git gdb/testsuite: check that "info shared" and "info linker-namespaces" before running don't crash While writing my solib_ops C++ification series, I broke this, and it didn't seem to be caught by the testsuite. Add a test for those. The exact message for "info linker-namespaces" varies depending on the solib_ops of the target architecture (whether ops->num_active_namespaces is nullptr or not). For now, just accept any message (a crash will still be caught). A later patch in this series will make the message consistent and update this test. Change-Id: I6bce2ff317447bbf321fc9cbd2d42c3dcea0c683 Approved-By: Pedro Alves --- diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp index 94b4a6e50bc..e95732a5bbb 100644 --- a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp @@ -169,6 +169,11 @@ proc_with_prefix test_conv_vars {} { proc test_info_linker_namespaces {} { clean_restart $::binfile + # Check that "info linker-namespaces" while the inferior is not running + # doesn't crash. + gdb_test "info linker-namespaces" "" \ + "info linker-namespaces before running" + if { ![runto_main] } { return } diff --git a/gdb/testsuite/gdb.base/info-shared.exp b/gdb/testsuite/gdb.base/info-shared.exp index 6f1b2d6af7e..e81b28e27a5 100644 --- a/gdb/testsuite/gdb.base/info-shared.exp +++ b/gdb/testsuite/gdb.base/info-shared.exp @@ -79,6 +79,9 @@ proc check_info_shared { test expect1 expect2 } { } } +# Check that "info shared" before running doesn't crash. +check_info_shared "info sharedlibrary before running" 0 0 + # Start the inferior, and check neither of the libraries are loaded at # the start. if ![runto_main] {