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