import gdb-1999-08-16 snapshot
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.hp / gdb.objdbg / objdbg01.exp
1 # Test reading debug information from in object files.
2
3 if { [skip_hp_tests] } { continue }
4
5 if { ![istarget "hppa*-*-hpux*"] } {
6 verbose "HPUX test ignored for non-hppa targets."
7 return 0
8 }
9
10 set testfile "test"
11 set srcsubdir ${srcdir}/${subdir}/objdbg01
12 set toolssubdir ${srcdir}/${subdir}/tools
13 set objdbgdir ${objdir}/${subdir}/objdbg01
14 set binfile ${objdbgdir}/${testfile}
15 set symaddrfile ${toolssubdir}/symaddr
16
17 if { [gdb_compile "${toolssubdir}/test-objdbg.cc" "${objdbgdir}/test-objdbg.o" object "debug c++ {additional_flags=-I${toolssubdir} +objdebug}"] != "" } {
18 gdb_suppress_entire_file "WARNING: +objdebug option is not supported in this compiler version, test ignored."
19 }
20
21 if { [gdb_compile "${srcsubdir}/x1.cc" "${objdbgdir}/x1.o" object "debug c++ {additional_flags=-I${srcsubdir} +objdebug}"] != "" } {
22 perror "Couldn't compile x1.cc"
23 return -1
24 }
25
26 if { [gdb_compile "${srcsubdir}/x2.cc" "${objdbgdir}/x2.o" object "debug c++ {additional_flags=-I${srcsubdir} +objdebug}"] != "" } {
27 perror "Couldn't compile x2.cc"
28 return -1
29 }
30
31 if { [gdb_compile "${srcsubdir}/x3.cc" "${objdbgdir}/x3.o" object "debug c++ {additional_flags=-I${srcsubdir} +objdebug}"] != "" } {
32 perror "Couldn't compile x3.cc"
33 return -1
34 }
35
36 if { [gdb_compile "${objdbgdir}/x1.o ${objdbgdir}/x2.o ${objdbgdir}/x3.o" "${binfile}0" executable "debug c++ {additional_flags=-I${srcsubdir} +objdebug}"] != "" } {
37 perror "Couldn't compile ${binfile}0"
38 return -1
39 }
40
41 if {[gdb_compile "${objdbgdir}/x3.o ${objdbgdir}/x2.o ${objdbgdir}/x1.o" "${binfile}1" executable "debug c++ {additional_flags=-I${srcsubdir} +objdebug}"] != "" } {
42 perror "Couldn't compile ${binfile}1"
43 return -1
44 }
45
46 # Test two executables. The first has x1.cc linked first, the second
47 # has x3.cc linked first. The difference is that in the first one,
48 # the Info<PP> instantiation from x1.cc is taken, in the second, its
49 # from x3.cc.
50
51 for {set filenum 0} {$filenum < 2} {incr filenum 1} {
52
53 # Lets test some commons
54 # Need to restart each to to make sure objects are not loaded
55 # Also cross check the address with what is actually in the
56 # object file (call the executable ${symaddrfile} to retrieve the
57 # information).
58
59 set exec_output [lindex [remote_exec build "${symaddrfile} ${binfile}${filenum} acomm"] 1]
60 regsub -all "\[\r\n\]" ${exec_output} "" exec_output
61
62 gdb_exit
63 gdb_start
64 gdb_reinitialize_dir ${srcsubdir}
65 gdb_load ${binfile}${filenum}
66 gdb_test "p &acomm" "..* = \\(int \[*\]\\) 0x${exec_output}.*"
67
68 gdb_exit
69 gdb_start
70 gdb_reinitialize_dir ${srcsubdir}
71 gdb_load ${binfile}${filenum}
72 gdb_test "b main" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file ..*/x1.cc, line 20."
73 gdb_test "run" "Starting program:.*Breakpoint \[0-9\]+, main .*/x1.cc:20.*20.*acomm.*=.*1.*"
74 gdb_test "s 1" "21.*"
75 gdb_test "p acomm" ".* = 1.*"
76 gdb_test "p &acomm" "..* = \\(int \[*\]\\) 0x${exec_output}.*"
77
78 # Step through each line.
79 # Do this three times.
80 # First round: Test that things are okay after printing commons
81 # above.
82 # Second round: Restart gdb and make sure we can walk through
83 # Third round: Do NOT restrart gdb to verify that the debug information
84 # was not messed up by loading additional object files from
85 # the first run through.
86 for {set i 0} {$i < 3} {incr i 1} {
87 if $i==1 then {
88 gdb_exit
89 gdb_start
90 gdb_reinitialize_dir ${srcsubdir}
91 gdb_load ${binfile}${filenum}
92 }
93 if $i!=2 then {
94 gdb_test "b main" \
95 "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file ..*/x1.cc, line 20."
96 }
97 if $i!=0 then {
98 gdb_test "run" \
99 "Starting program:.*Breakpoint \[0-9\]+, main .*/x1.cc:20.*"
100 gdb_test "s 1" "21.*"
101 }
102 gdb_test "s 1" "Info<PP>::p .*/x3.h:11.*"
103 gdb_test "s 1" "PP::print .*/x2.cc:8.*"
104 gdb_test "s 1" ".*9.*"
105 gdb_test "s 1" "Info<PP>::p .*/x3.h:12.*"
106 gdb_test "s 1" "main .*/x1.cc:22.*"
107 gdb_test "s 1" "foo .*/x3.cc:5.*"
108 gdb_test "s 1" "Info<PP>::p .*/x3.h:11.*"
109 gdb_test "s 1" "PP::print .*/x2.cc:8.*"
110 gdb_test "s 1" ".*9.*"
111 gdb_test "s 1" "Info<PP>::p .*/x3.h:12.*"
112 gdb_test "s 1" "foo .*/x3.cc:6.*"
113 gdb_test "s 1" "Info<QQ>::p .*/x3.h:11.*"
114 gdb_test "s 1" "QQ::print .*/x2.cc:13.*"
115 gdb_test "s 1" ".*14.*"
116 gdb_test "s 1" "Info<QQ>::p .*/x3.h:12.*"
117 gdb_test "s 1" "foo .*/x3.cc:7.*"
118 gdb_test "s 1" "main .*/x1.cc:24.*"
119 gdb_test "s 1" ".*25.*"
120 if [istarget "hppa2.0w-*-*"] {
121 gdb_test "s 1" "0x\[0-9a-f\]+ in .*"
122 gdb_test "c" ".*Program exited normally.*"
123 } else {
124 gdb_test "s 1" "0x\[0-9a-f\]+ in _start .*"
125 gdb_test "s 1" ".*Program exited normally.*"
126 }
127 }
128
129 # Test various ptypes, and combinations of them
130 # Test things multiple times in each set to make sure that the debug
131 # information did not get messed up.
132
133 gdb_exit
134 gdb_start
135 gdb_reinitialize_dir ${srcsubdir}
136 gdb_load ${binfile}${filenum}
137 gdb_test "ptype QQ" "type = (class |)QQ {..*void print( |)..*}.*"
138 gdb_test "ptype PP" "type = (class |)PP {..*void print( |)..*}.*"
139 gdb_test "ptype QQ" "type = (class |)QQ {..*void print( |)..*}.*"
140
141 gdb_exit
142 gdb_start
143 gdb_reinitialize_dir ${srcsubdir}
144 gdb_load ${binfile}${filenum}
145 gdb_test "ptype PP" "type = (class |)PP {..*void print( |)..*}.*"
146 gdb_test "ptype QQ" "type = (class |)QQ {..*void print( |)..*}.*"
147 gdb_test "ptype PP" "type = (class |)PP {..*void print( |)..*}.*"
148
149 gdb_exit
150 gdb_start
151 gdb_reinitialize_dir ${srcsubdir}
152 gdb_load ${binfile}${filenum}
153 gdb_test "ptype Info<QQ>" "type = (class |)Info<QQ> {..*void p( |)..*}.*"
154 gdb_test "ptype Info<PP>" "type = (class |)Info<PP> {..*void p( |)..*}.*"
155 gdb_test "ptype Info<QQ>" "type = (class |)Info<QQ> {..*void p( |)..*}.*"
156
157 gdb_exit
158 gdb_start
159 gdb_reinitialize_dir ${srcsubdir}
160 gdb_load ${binfile}${filenum}
161 gdb_test "ptype Info<PP>" "type = (class |)Info<PP> {..*void p( |)..*}.*"
162 gdb_test "ptype Info<QQ>" "type = (class |)Info<QQ> {..*void p( |)..*}.*"
163 gdb_test "ptype Info<PP>" "type = (class |)Info<PP> {..*void p( |)..*}.*"
164
165 gdb_exit
166 gdb_start
167 gdb_reinitialize_dir ${srcsubdir}
168 gdb_load ${binfile}${filenum}
169 gdb_test "ptype Info" "type = template <..*> (class |)Info {..*}.*"
170 gdb_test "ptype Info<PP>" "type = (class |)Info<PP> {..*void p( |)..*}.*"
171 gdb_test "ptype Info<QQ>" "type = (class |)Info<QQ> {..*void p( |)..*}.*"
172 gdb_test "ptype Info" "type = template <..*> (class |)Info {..*}.*"
173
174 gdb_exit
175 gdb_start
176 gdb_reinitialize_dir ${srcsubdir}
177 gdb_load ${binfile}${filenum}
178 gdb_test "ptype class QQ" "type = (class |)QQ {..*void print( |)..*}.*"
179 gdb_test "ptype class PP" "type = (class |)PP {..*void print( |)..*}.*"
180 gdb_test "ptype class QQ" "type = (class |)QQ {..*void print( |)..*}.*"
181
182 gdb_exit
183 gdb_start
184 gdb_reinitialize_dir ${srcsubdir}
185 gdb_load ${binfile}${filenum}
186 gdb_test "ptype class PP" "type = (class |)PP {..*void print( |)..*}.*"
187 gdb_test "ptype class QQ" "type = (class |)QQ {..*void print( |)..*}.*"
188 gdb_test "ptype class PP" "type = (class |)PP {..*void print( |)..*}.*"
189
190 gdb_exit
191 gdb_start
192 gdb_reinitialize_dir ${srcsubdir}
193 gdb_load ${binfile}${filenum}
194 gdb_test "ptype class Info<QQ>" \
195 "type = (class |)Info<QQ> {..*void p( |)..*}.*"
196 gdb_test "ptype class Info<PP>" \
197 "type = (class |)Info<PP> {..*void p( |)..*}.*"
198 gdb_test "ptype class Info<QQ>" \
199 "type = (class |)Info<QQ> {..*void p( |)..*}.*"
200
201 gdb_exit
202 gdb_start
203 gdb_reinitialize_dir ${srcsubdir}
204 gdb_load ${binfile}${filenum}
205 gdb_test "ptype class Info<PP>" \
206 "type = (class |)Info<PP> {..*void p( |)..*}.*"
207 gdb_test "ptype class Info<QQ>" \
208 "type = (class |)Info<QQ> {..*void p( |)..*}.*"
209 gdb_test "ptype class Info<PP>" \
210 "type = (class |)Info<PP> {..*void p( |)..*}.*"
211 }
212
This page took 0.045949 seconds and 4 git commands to generate.