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