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 | if $tracelevel then { |
21 | strace $tracelevel | |
22 | } | |
23 | ||
24 | load_lib gdb-python.exp | |
25 | ||
20c168b5 KP |
26 | set libfile "py-events-shlib" |
27 | set libsrc $srcdir/$subdir/$libfile.c | |
28 | set lib_sl $objdir/$subdir/$libfile.so | |
29 | set lib_opts debug | |
30 | ||
c17a9e46 HZ |
31 | set testfile "py-events" |
32 | set srcfile ${testfile}.c | |
33 | set binfile ${objdir}/${subdir}/${testfile} | |
20c168b5 | 34 | set exec_opts [list debug shlib=$lib_sl] |
c17a9e46 HZ |
35 | set pyfile ${srcdir}/${subdir}/${testfile}.py |
36 | ||
20c168b5 | 37 | if [get_compiler_info ${binfile}] { |
c17a9e46 HZ |
38 | return -1 |
39 | } | |
40 | ||
20c168b5 KP |
41 | if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" |
42 | || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} { | |
43 | untested "Could not compile either $libsrc or $srcdir/$subdir/$srcfile." | |
44 | return -1 | |
45 | } | |
46 | ||
47 | # Start with a fresh gdb. | |
48 | clean_restart ${testfile} | |
49 | ||
c17a9e46 HZ |
50 | if { [skip_python_tests] } { continue } |
51 | ||
52 | gdb_test_no_output "python execfile ('${pyfile}')" "" | |
53 | ||
20c168b5 KP |
54 | gdb_test "Test_Newobj_Events" "New ObjectFile Event tester registered." "Register new objfile event handler" |
55 | ||
56 | gdb_breakpoint "main" {temporary} | |
57 | ||
58 | gdb_test "run" ".*event type: new_objfile.*new objfile name.*" "New objfile notification" | |
c17a9e46 | 59 | |
cb6be26b KP |
60 | gdb_test_no_output "set detach-on-fork off" "" |
61 | ||
c17a9e46 HZ |
62 | gdb_test "Test_Events" "Event testers registered." |
63 | ||
6839b47f | 64 | gdb_breakpoint "first" |
c17a9e46 HZ |
65 | gdb_breakpoint "first" |
66 | ||
67 | # Test continue event and breakpoint stop event | |
68 | gdb_test "continue" ".*event type: continue.* | |
69 | .*event type: stop.* | |
70 | .*stop reason: breakpoint.* | |
6839b47f | 71 | .*first breakpoint number: 2.* |
c17a9e46 | 72 | .*breakpoint number: 2.* |
6839b47f | 73 | .*breakpoint number: 3.* |
c17a9e46 HZ |
74 | all threads stopped" |
75 | ||
76 | #test exited event. | |
77 | gdb_test "continue" ".*event type: continue.* | |
78 | .*event type: exit.* | |
cb6be26b KP |
79 | .*exit code: 12.* |
80 | .*exit inf: 1.*" "Inferior 1 terminated." | |
81 | ||
82 | gdb_test "inferior 2" ".*Switching to inferior 2.*" | |
83 | gdb_test "continue" ".*event type: continue.* | |
84 | .*event type: exit.* | |
85 | .*exit code: 12.* | |
86 | .*exit inf: 2.*" "Inferior 2 terminated." |