Commit | Line | Data |
---|---|---|
c5a57081 | 1 | # Copyright (C) 2010-2012 Free Software Foundation, Inc. |
c17a9e46 HZ |
2 | |
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. | |
7 | # | |
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. | |
12 | # | |
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/>. | |
15 | ||
3a3dad98 JK |
16 | if [target_info exists use_gdb_stub] { |
17 | return 0 | |
18 | } | |
19 | ||
c17a9e46 HZ |
20 | load_lib gdb-python.exp |
21 | ||
20c168b5 KP |
22 | set libfile "py-events-shlib" |
23 | set libsrc $srcdir/$subdir/$libfile.c | |
24 | set lib_sl $objdir/$subdir/$libfile.so | |
25 | set lib_opts debug | |
26 | ||
c17a9e46 HZ |
27 | set testfile "py-events" |
28 | set srcfile ${testfile}.c | |
29 | set binfile ${objdir}/${subdir}/${testfile} | |
20c168b5 | 30 | set exec_opts [list debug shlib=$lib_sl] |
c17a9e46 HZ |
31 | set pyfile ${srcdir}/${subdir}/${testfile}.py |
32 | ||
4c93b1db | 33 | if [get_compiler_info] { |
c17a9e46 HZ |
34 | return -1 |
35 | } | |
36 | ||
20c168b5 KP |
37 | if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" |
38 | || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} { | |
39 | untested "Could not compile either $libsrc or $srcdir/$subdir/$srcfile." | |
40 | return -1 | |
41 | } | |
42 | ||
43 | # Start with a fresh gdb. | |
44 | clean_restart ${testfile} | |
45 | ||
c17a9e46 HZ |
46 | if { [skip_python_tests] } { continue } |
47 | ||
48 | gdb_test_no_output "python execfile ('${pyfile}')" "" | |
49 | ||
20c168b5 KP |
50 | gdb_test "Test_Newobj_Events" "New ObjectFile Event tester registered." "Register new objfile event handler" |
51 | ||
52 | gdb_breakpoint "main" {temporary} | |
53 | ||
54 | gdb_test "run" ".*event type: new_objfile.*new objfile name.*" "New objfile notification" | |
c17a9e46 | 55 | |
cb6be26b KP |
56 | gdb_test_no_output "set detach-on-fork off" "" |
57 | ||
c17a9e46 HZ |
58 | gdb_test "Test_Events" "Event testers registered." |
59 | ||
6839b47f | 60 | gdb_breakpoint "first" |
c17a9e46 HZ |
61 | gdb_breakpoint "first" |
62 | ||
63 | # Test continue event and breakpoint stop event | |
64 | gdb_test "continue" ".*event type: continue.* | |
65 | .*event type: stop.* | |
66 | .*stop reason: breakpoint.* | |
6839b47f | 67 | .*first breakpoint number: 2.* |
c17a9e46 | 68 | .*breakpoint number: 2.* |
6839b47f | 69 | .*breakpoint number: 3.* |
c17a9e46 HZ |
70 | all threads stopped" |
71 | ||
2ca0b532 PA |
72 | # Test that when "step N" trips on a breakpoint, we get a stop event |
73 | # with breakpoint stop reason. | |
74 | gdb_breakpoint "do_nothing" | |
75 | gdb_test "step 3" ".*event type: continue.* | |
76 | .*event type: stop.* | |
77 | .*stop reason: breakpoint.* | |
78 | .*first breakpoint number: 4.* | |
79 | .*breakpoint number: 4.* | |
80 | all threads stopped" | |
81 | ||
82 | delete_breakpoints | |
83 | ||
c17a9e46 HZ |
84 | #test exited event. |
85 | gdb_test "continue" ".*event type: continue.* | |
86 | .*event type: exit.* | |
cb6be26b | 87 | .*exit code: 12.* |
2e8265fd TT |
88 | .*exit inf: 1.* |
89 | dir ok: True.*" "Inferior 1 terminated." | |
cb6be26b KP |
90 | |
91 | gdb_test "inferior 2" ".*Switching to inferior 2.*" | |
92 | gdb_test "continue" ".*event type: continue.* | |
93 | .*event type: exit.* | |
94 | .*exit code: 12.* | |
2e8265fd TT |
95 | .*exit inf: 2.* |
96 | dir ok: True.*" "Inferior 2 terminated." |