]>
Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 2004, 2007 Free Software Foundation, Inc. |
f9a7572a FF |
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 2 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, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-gdb@gnu.org | |
19 | ||
20 | # This file is part of the gdb testsuite. | |
21 | ||
22 | # Tests for PR:1558. Hits breakpoint at main after function called | |
23 | # from main. | |
24 | ||
25 | if $tracelevel { | |
26 | strace $tracelevel | |
27 | } | |
28 | ||
29 | set prms_id 0 | |
30 | set bug_id 0 | |
31 | ||
32 | if ![istarget "sh-*-*"] then { | |
33 | verbose "Skipping SH breakpoint test." | |
34 | return | |
35 | } | |
36 | ||
37 | set testfile "gdb1558" | |
38 | set srcfile ${testfile}.c | |
39 | set binfile ${objdir}/${subdir}/${testfile} | |
40 | # Note we have to compile WITH optimization and WITHOUT debugging information to expose the bug. | |
41 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {"additional_flags=-O2"}] != "" } { | |
b60f0898 JB |
42 | untested gdb1558.exp |
43 | return -1 | |
f9a7572a FF |
44 | } |
45 | ||
46 | gdb_exit | |
47 | gdb_start | |
48 | gdb_reinitialize_dir $srcdir/$subdir | |
49 | gdb_load ${binfile} | |
50 | ||
51 | gdb_test "b main" "Breakpoint 1.*" "set breakpoint at main" | |
52 | gdb_test "b sub1" "Breakpoint 2.*" "set breakpoint at sub1" | |
53 | gdb_test "b sub2" "Breakpoint 3.*" "set breakpoint at sub2" | |
54 | ||
55 | # We can't use "runto_main" because that is exactly the problem | |
56 | # we are trying to detect, stopping somewhere before main. | |
57 | ||
58 | gdb_run_cmd | |
59 | ||
60 | gdb_expect 30 { | |
61 | -re "Breakpoint 1.*main .*$gdb_prompt $" { | |
62 | pass "Hits breakpoint at main after function called from main" | |
63 | } | |
64 | -re "Breakpoint 2.*sub1 .*$gdb_prompt $" { | |
65 | kfail "gdb/1558" "Hits breakpoint at main after function called from main" | |
66 | } | |
67 | -re "$gdb_prompt $" { | |
68 | fail "Hits breakpoint at main after function called from main" | |
69 | } | |
70 | timeout { | |
71 | fail "Hits breakpoint at main after function called from main (timeout)" | |
72 | } | |
73 | } |