1 # Copyright (C) 1998, 2007 Free Software Foundation, Inc.
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.
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.
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. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # optimize.exp -- Expect script for testing apps compiled with -O
22 # There is no DOC support for gdb yet, return 0 for now.
35 if { [skip_hp_tests] } then { continue }
38 set srcfile ${testfile}.c
39 set binfile ${objdir}/${subdir}/${testfile}
41 if [get_compiler_info ${binfile}] {
46 if { $gcc_compiled } then { continue }
49 # Vanilla -O, which is the same as +O2
51 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug optimize=+O2}] != "" } {
59 gdb_reinitialize_dir $srcdir/$subdir
61 send_gdb "file $binfile\n"
63 -re ".*no debugging symbols found.*$gdb_prompt $" {
64 fail "Didn't find debug symbols; CHFts23488"
66 -re ".*No header section (PXDB data).*$gdb_prompt $" {
67 fail "pointless warning"
69 -re ".*done.*$gdb_prompt $" {
70 pass "load debug symbols"
72 timeout { fail "timeout on file" }
75 # Two lines at the same place after opt.
78 gdb_test "b 26" ".*also set at.*" "same line"
81 gdb_test "b 48" ".*also set at.*" "same line"
83 gdb_test "tb main" ".*"
85 set old_timeout $timeout
86 set timeout [expr "$timeout + 200"]
89 -re ".*No header section (PXDB data).*$gdb_prompt $" {
90 fail "pointless warning"
92 -re ".*main.*2\[12].*$gdb_prompt $" {
93 # All the lines before line 21 or 22 are
94 # evaporated by the compiler.
98 -re ".*$gdb_prompt $" {
99 fail "didn't hit main"
101 timeout { fail "timeout on run" }
103 set timeout $old_timeout
105 gdb_test "c" ".*Breakpoint 1.*33.*"
106 gdb_test "c" ".*51.*"
107 gdb_test "cle" ".*Deleted breakpoints.*" "set 2, so del 2"
109 gdb_test "b callee" ".*"
110 gdb_test "c" ".*callee.*" "hit called rtn"
116 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {optimize=+O4}] != "" } {
117 untested optimize.exp
122 gdb_reinitialize_dir $srcdir/$subdir
124 send_gdb "file $binfile\n"
126 -re ".*no debugging symbols found.*$gdb_prompt $" {
127 pass "Didn't find debug symbols, as expected"
129 -re ".*No header section (PXDB data).*$gdb_prompt $" {
130 fail "pointless warning"
132 -re ".*done.*$gdb_prompt $" {
133 fail "Somehow found debug symbols--make this a pass?"
135 timeout { fail "timeout on file" }
138 gdb_test "b main" ".*"
139 gdb_test "b callee" ".*"
140 gdb_test "r" ".*Breakpoint 1.*main.*"
141 gdb_test "si 3" ".*main.*" "steps"
142 gdb_test "x/4i \$pc" ".*main.*main+4.*main+8.*"
143 gdb_test "c" ".*callee.*" "hit bp"
144 gdb_test "disas" ".*callee.*callee+4.*callee+12.*"
145 gdb_test "si" ".*callee.*"
146 gdb_test "fin" ".*Run till exit.*main.*" "finish"
147 gdb_test "x/i \$pc" ".*main+.*" "back in main"
150 #remote_exec build "rm -f ${binfile}"