]>
Commit | Line | Data |
---|---|---|
8acc9f48 | 1 | # Copyright (C) 1998-2013 Free Software Foundation, Inc. |
7be570e7 JM |
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 |
7be570e7 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
7be570e7 JM |
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. | |
e22f8b7c | 12 | # |
7be570e7 | 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/>. */ |
7be570e7 | 15 | |
7be570e7 JM |
16 | # optimize.exp -- Expect script for testing apps compiled with -O |
17 | ||
18 | # There is no DOC support for gdb yet, return 0 for now. | |
19 | return 0 | |
20 | ||
21 | global timeout | |
22 | ||
23 | # use this to debug: | |
24 | # | |
25 | #log_user 1 | |
26 | ||
7be570e7 JM |
27 | if { [skip_hp_tests] } then { continue } |
28 | ||
29 | set testfile optimize | |
30 | set srcfile ${testfile}.c | |
31 | set binfile ${objdir}/${subdir}/${testfile} | |
32 | ||
4c93b1db | 33 | if [get_compiler_info] { |
7be570e7 JM |
34 | return -1; |
35 | } | |
36 | ||
37 | ||
38 | if { $gcc_compiled } then { continue } | |
39 | ||
40 | ||
41 | # Vanilla -O, which is the same as +O2 | |
42 | # | |
43 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug optimize=+O2}] != "" } { | |
b60f0898 JB |
44 | untested optimize.exp |
45 | return -1 | |
7be570e7 JM |
46 | } |
47 | ||
48 | ||
49 | gdb_exit | |
50 | gdb_start | |
51 | gdb_reinitialize_dir $srcdir/$subdir | |
52 | ||
53 | send_gdb "file $binfile\n" | |
54 | gdb_expect { | |
55 | -re ".*no debugging symbols found.*$gdb_prompt $" { | |
56 | fail "Didn't find debug symbols; CHFts23488" | |
57 | } | |
58 | -re ".*No header section (PXDB data).*$gdb_prompt $" { | |
59 | fail "pointless warning" | |
60 | } | |
61 | -re ".*done.*$gdb_prompt $" { | |
62 | pass "load debug symbols" | |
63 | } | |
64 | timeout { fail "timeout on file" } | |
65 | } | |
66 | ||
67 | # Two lines at the same place after opt. | |
68 | # | |
69 | gdb_test "b 28" ".*" | |
70 | gdb_test "b 26" ".*also set at.*" "same line" | |
71 | ||
72 | gdb_test "b 47" ".*" | |
73 | gdb_test "b 48" ".*also set at.*" "same line" | |
74 | ||
75 | gdb_test "tb main" ".*" | |
76 | ||
77 | set old_timeout $timeout | |
78 | set timeout [expr "$timeout + 200"] | |
79 | send_gdb "r\n" | |
80 | gdb_expect { | |
81 | -re ".*No header section (PXDB data).*$gdb_prompt $" { | |
82 | fail "pointless warning" | |
83 | } | |
84 | -re ".*main.*2\[12].*$gdb_prompt $" { | |
85 | # All the lines before line 21 or 22 are | |
86 | # evaporated by the compiler. | |
87 | # | |
88 | pass "hit main" | |
89 | } | |
90 | -re ".*$gdb_prompt $" { | |
91 | fail "didn't hit main" | |
92 | } | |
93 | timeout { fail "timeout on run" } | |
94 | } | |
95 | set timeout $old_timeout | |
96 | ||
97 | gdb_test "c" ".*Breakpoint 1.*33.*" | |
98 | gdb_test "c" ".*51.*" | |
99 | gdb_test "cle" ".*Deleted breakpoints.*" "set 2, so del 2" | |
100 | ||
101 | gdb_test "b callee" ".*" | |
102 | gdb_test "c" ".*callee.*" "hit called rtn" | |
103 | ||
104 | gdb_exit | |
105 | ||
106 | # +O4, don't use -g | |
107 | # | |
108 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {optimize=+O4}] != "" } { | |
b60f0898 JB |
109 | untested optimize.exp |
110 | return -1 | |
7be570e7 JM |
111 | } |
112 | ||
113 | gdb_start | |
114 | gdb_reinitialize_dir $srcdir/$subdir | |
115 | ||
116 | send_gdb "file $binfile\n" | |
117 | gdb_expect { | |
118 | -re ".*no debugging symbols found.*$gdb_prompt $" { | |
119 | pass "Didn't find debug symbols, as expected" | |
120 | } | |
121 | -re ".*No header section (PXDB data).*$gdb_prompt $" { | |
122 | fail "pointless warning" | |
123 | } | |
124 | -re ".*done.*$gdb_prompt $" { | |
125 | fail "Somehow found debug symbols--make this a pass?" | |
126 | } | |
127 | timeout { fail "timeout on file" } | |
128 | } | |
129 | ||
130 | gdb_test "b main" ".*" | |
131 | gdb_test "b callee" ".*" | |
132 | gdb_test "r" ".*Breakpoint 1.*main.*" | |
133 | gdb_test "si 3" ".*main.*" "steps" | |
134 | gdb_test "x/4i \$pc" ".*main.*main+4.*main+8.*" | |
135 | gdb_test "c" ".*callee.*" "hit bp" | |
136 | gdb_test "disas" ".*callee.*callee+4.*callee+12.*" | |
137 | gdb_test "si" ".*callee.*" | |
138 | gdb_test "fin" ".*Run till exit.*main.*" "finish" | |
139 | gdb_test "x/i \$pc" ".*main+.*" "back in main" | |
140 | gdb_exit | |
141 | ||
142 | #remote_exec build "rm -f ${binfile}" | |
143 | return 0 |