Home | History | Annotate | Line # | Download | only in gdb.mi
mi-solib.exp revision 1.7
      1  1.7  christos # Copyright 2011-2017 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.1  christos if {[skip_shlib_tests]} {
     20  1.7  christos     untested "skipping shared library tests"
     21  1.1  christos     return -1
     22  1.1  christos }
     23  1.1  christos 
     24  1.1  christos gdb_exit
     25  1.1  christos if [mi_gdb_start] {
     26  1.1  christos     continue
     27  1.1  christos }
     28  1.1  christos 
     29  1.1  christos standard_testfile solib-main.c solib-lib.c
     30  1.1  christos 
     31  1.1  christos set libname "solib-lib"
     32  1.1  christos set srcfile_lib ${srcdir}/${subdir}/$srcfile2
     33  1.1  christos set binfile_lib [standard_output_file ${libname}.so]
     34  1.1  christos set lib_flags [list debug]
     35  1.1  christos 
     36  1.1  christos set srcfile_main ${srcdir}/${subdir}/$srcfile
     37  1.1  christos set bin_flags [list debug shlib=${binfile_lib}]
     38  1.1  christos 
     39  1.1  christos if [get_compiler_info] {
     40  1.1  christos     return -1
     41  1.1  christos }
     42  1.1  christos 
     43  1.1  christos if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
     44  1.1  christos      || [gdb_compile ${srcfile_main} ${binfile} executable $bin_flags] != "" } {
     45  1.7  christos   untested "failed to compile"
     46  1.1  christos   return -1
     47  1.1  christos }
     48  1.1  christos 
     49  1.1  christos mi_delete_breakpoints
     50  1.1  christos mi_gdb_reinitialize_dir $srcdir/$subdir
     51  1.1  christos mi_gdb_load ${binfile}
     52  1.1  christos 
     53  1.1  christos mi_load_shlibs $binfile_lib
     54  1.1  christos 
     55  1.7  christos proc_with_prefix test_stop_on_solib_events {} {
     56  1.7  christos     mi_gdb_test "777-gdb-set stop-on-solib-events 1" "777\\^done" \
     57  1.7  christos 	"set stop-on-solib-events"
     58  1.7  christos 
     59  1.7  christos     # We use "run" rather than "-exec-run" here in order to test that CLI
     60  1.7  christos     # commands still cause the correct MI output to be generated.
     61  1.7  christos     mi_run_with_cli
     62  1.7  christos 
     63  1.7  christos     # Also test that the CLI solib event note is output.
     64  1.7  christos     set test "CLI prints solib event"
     65  1.7  christos     gdb_expect {
     66  1.7  christos 	-re "~\"Stopped due to shared library event \\(no libraries added or removed\\)\\\\n" {
     67  1.7  christos 	    pass "$test"
     68  1.7  christos 	}
     69  1.7  christos 	timeout {
     70  1.7  christos 	    fail "$test (timeout)"
     71  1.7  christos 	}
     72  1.7  christos     }
     73  1.7  christos 
     74  1.7  christos     mi_expect_stop solib-event .* .* .* .* .* "check for solib event"
     75  1.1  christos 
     76  1.7  christos     # Unset solib events to avoid interfering with other tests.
     77  1.7  christos     mi_gdb_test "778-gdb-set stop-on-solib-events 0" "778\\^done" \
     78  1.7  christos 	"unset stop-on-solib-events"
     79  1.7  christos }
     80  1.7  christos 
     81  1.7  christos proc_with_prefix test_file_list_shared_libraries {} {
     82  1.7  christos     global libname
     83  1.7  christos     global binfile
     84  1.7  christos 
     85  1.7  christos     mi_continue_to main
     86  1.7  christos 
     87  1.7  christos     mi_gdb_test "222-file-list-shared-libraries" \
     88  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=\".*\"\}]\}]" \
     89  1.7  christos 	"get the list of shared libraries"
     90  1.1  christos }
     91  1.3  christos 
     92  1.7  christos test_stop_on_solib_events
     93  1.7  christos test_file_list_shared_libraries
     94