run copyright.sh for 2011.
[external/binutils.git] / gdb / testsuite / gdb.hp / gdb.aCC / optimize.exp
1 # Copyright (C) 1998, 2007, 2008, 2009, 2010, 2011
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
16
17 # optimize.exp -- Expect script for testing apps compiled with -O
18
19 # There is no DOC support for gdb yet, return 0 for now.
20 return 0
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 if { [skip_hp_tests] } then { continue }
33
34 set testfile optimize
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
37
38 if [get_compiler_info ${binfile}] {
39     return -1;
40 }
41
42  
43 if { $gcc_compiled } then { continue }
44
45
46 # Vanilla -O, which is the same as +O2
47 #
48 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug optimize=+O2}] != "" } {
49      untested optimize.exp
50      return -1
51 }
52
53
54 gdb_exit
55 gdb_start
56 gdb_reinitialize_dir $srcdir/$subdir
57
58 send_gdb "file $binfile\n"
59 gdb_expect {
60     -re ".*no debugging symbols found.*$gdb_prompt $" {
61         fail "Didn't find debug symbols; CHFts23488" 
62     }
63     -re ".*No header section (PXDB data).*$gdb_prompt $" {
64         fail "pointless warning"
65     }
66     -re ".*done.*$gdb_prompt $" {
67         pass "load debug symbols"
68     }
69     timeout { fail "timeout on file" }
70 }
71
72 # Two lines at the same place after opt.
73 #
74 gdb_test "b 28"   ".*"
75 gdb_test "b 26"   ".*also set at.*" "same line"
76
77 gdb_test "b 47"   ".*"
78 gdb_test "b 48"   ".*also set at.*" "same line"
79
80 gdb_test "tb main" ".*"
81
82 set old_timeout $timeout
83 set timeout [expr "$timeout + 200"]
84 send_gdb "r\n"
85 gdb_expect {
86     -re ".*No header section (PXDB data).*$gdb_prompt $" {
87         fail "pointless warning"
88     }
89     -re ".*main.*2\[12].*$gdb_prompt $" {
90         # All the lines before line 21 or 22 are 
91         # evaporated by the compiler.
92         # 
93         pass "hit main"
94     }
95     -re ".*$gdb_prompt $" {
96         fail "didn't hit main"
97     }
98     timeout { fail "timeout on run" }
99 }
100 set timeout $old_timeout
101
102 gdb_test "c" ".*Breakpoint 1.*33.*"
103 gdb_test "c" ".*51.*"
104 gdb_test "cle" ".*Deleted breakpoints.*" "set 2, so del 2"
105
106 gdb_test "b callee" ".*"
107 gdb_test "c" ".*callee.*" "hit called rtn"
108
109 gdb_exit
110
111 # +O4, don't use -g
112 #
113 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {optimize=+O4}] != "" } {
114      untested optimize.exp
115      return -1
116 }
117
118 gdb_start
119 gdb_reinitialize_dir $srcdir/$subdir
120
121 send_gdb "file $binfile\n"
122 gdb_expect {
123     -re ".*no debugging symbols found.*$gdb_prompt $" {
124         pass "Didn't find debug symbols, as expected"
125     }
126     -re ".*No header section (PXDB data).*$gdb_prompt $" {
127         fail "pointless warning"
128     }
129     -re ".*done.*$gdb_prompt $" {
130         fail "Somehow found debug symbols--make this a pass?"
131     }
132     timeout { fail "timeout on file" }
133 }
134
135 gdb_test "b main"   ".*"
136 gdb_test "b callee" ".*"
137 gdb_test "r"        ".*Breakpoint 1.*main.*"
138 gdb_test "si 3"     ".*main.*" "steps"
139 gdb_test "x/4i \$pc" ".*main.*main+4.*main+8.*"
140 gdb_test "c"        ".*callee.*" "hit bp"
141 gdb_test "disas"    ".*callee.*callee+4.*callee+12.*"
142 gdb_test "si"       ".*callee.*"
143 gdb_test "fin"      ".*Run till exit.*main.*" "finish"
144 gdb_test "x/i \$pc" ".*main+.*" "back in main"
145 gdb_exit
146
147 #remote_exec build "rm -f ${binfile}"
148 return 0