1 # Copyright 2011-2024 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 load_lib mi-support.exp
19 require allow_shlib_tests
21 standard_testfile solib-main.c solib-lib.c
23 set libname "solib-lib"
24 set srcfile_lib ${srcdir}/${subdir}/$srcfile2
25 set binfile_lib [standard_output_file ${libname}.so]
26 set lib_flags [list debug]
28 set srcfile_main ${srcdir}/${subdir}/$srcfile
29 set bin_flags [list debug shlib=${binfile_lib}]
31 if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
32 || [gdb_compile ${srcfile_main} ${binfile} executable $bin_flags] != "" } {
33 untested "failed to compile"
37 if {[mi_clean_restart $binfile]} {
41 mi_load_shlibs $binfile_lib
43 proc_with_prefix test_stop_on_solib_events {} {
44 mi_gdb_test "777-gdb-set stop-on-solib-events 1" "777\\^done" \
45 "set stop-on-solib-events"
47 # We use "run" rather than "-exec-run" here in order to test that CLI
48 # commands still cause the correct MI output to be generated.
51 # Also test that the CLI solib event note is output.
52 set test "CLI prints solib event"
54 -re "~\"Stopped due to shared library event \\(no libraries added or removed\\)\\\\n" {
58 fail "$test (timeout)"
62 mi_expect_stop solib-event .* .* .* .* .* "check for solib event"
64 # Unset solib events to avoid interfering with other tests.
65 mi_gdb_test "778-gdb-set stop-on-solib-events 0" "778\\^done" \
66 "unset stop-on-solib-events"
69 proc_with_prefix test_file_list_shared_libraries {} {
75 mi_gdb_test "222-file-list-shared-libraries" \
76 "222\\^done,shared-libraries=\\\[\{id=\".*${libname}.so\",target-name=\".*${libname}.so\",host-name=\".*${libname}.so\",symbols-loaded=\"1\",thread-group=\".*\",ranges=\\\[\{from=\".*\",to=\".*\"\}]\}]" \
77 "get the list of shared libraries"
80 test_stop_on_solib_events
81 test_file_list_shared_libraries