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