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