1 # Copyright (C) 2010-2012 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 if [target_info exists use_gdb_stub] {
20 load_lib gdb-python.exp
22 set libfile "py-events-shlib"
23 set libsrc $srcdir/$subdir/$libfile.c
24 set lib_sl [standard_output_file $libfile.so]
28 set exec_opts [list debug shlib=$lib_sl]
29 set pyfile ${srcdir}/${subdir}/${testfile}.py
31 if [get_compiler_info] {
35 if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
36 || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} {
37 untested "Could not compile either $libsrc or $srcdir/$subdir/$srcfile."
41 # Start with a fresh gdb.
42 clean_restart ${testfile}
44 if { [skip_python_tests] } { continue }
46 gdb_test_no_output "python exec (open ('${pyfile}').read ())" ""
48 gdb_test "Test_Newobj_Events" "New ObjectFile Event tester registered." "Register new objfile event handler"
50 gdb_breakpoint "main" {temporary}
52 gdb_test "run" ".*event type: new_objfile.*new objfile name.*" "New objfile notification"
54 gdb_test_no_output "set detach-on-fork off" ""
56 gdb_test "Test_Events" "Event testers registered."
58 gdb_breakpoint "first"
59 gdb_breakpoint "first"
61 # Test continue event and breakpoint stop event
62 gdb_test "continue" ".*event type: continue.*
64 .*stop reason: breakpoint.*
65 .*first breakpoint number: 2.*
66 .*breakpoint number: 2.*
67 .*breakpoint number: 3.*
70 # Test that when "step N" trips on a breakpoint, we get a stop event
71 # with breakpoint stop reason.
72 gdb_breakpoint "do_nothing"
73 gdb_test "step 3" ".*event type: continue.*
75 .*stop reason: breakpoint.*
76 .*first breakpoint number: 4.*
77 .*breakpoint number: 4.*
83 gdb_test "continue" ".*event type: continue.*
87 dir ok: True.*" "Inferior 1 terminated."
89 gdb_test "inferior 2" ".*Switching to inferior 2.*"
90 gdb_test "continue" ".*event type: continue.*
94 dir ok: True.*" "Inferior 2 terminated."