1 # Test reading debug information from in object files.
3 if { [skip_hp_tests] } { continue }
5 if { ![istarget "hppa*-*-hpux*"] } {
6 verbose "HPUX test ignored for non-hppa targets."
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
17 # Create and source the file that provides information about the compiler
18 # used to compile the test case.
19 if [get_compiler_info ${binfile}] {
23 if {!$hp_aCC_compiler && !$hp_cc_compiler} {
27 if { [gdb_compile "${toolssubdir}/test-objdbg.cc" "${objdbgdir}/test-objdbg.o" object "debug c++ {additional_flags=-I${toolssubdir} +objdebug}"] != "" } {
32 if { [gdb_compile "${srcsubdir}/x1.cc" "${objdbgdir}/x1.o" object "debug c++ {additional_flags=-I${srcsubdir} +objdebug}"] != "" } {
33 perror "Couldn't compile x1.cc"
37 if { [gdb_compile "${srcsubdir}/x2.cc" "${objdbgdir}/x2.o" object "debug c++ {additional_flags=-I${srcsubdir} +objdebug}"] != "" } {
38 perror "Couldn't compile x2.cc"
42 if { [gdb_compile "${srcsubdir}/x3.cc" "${objdbgdir}/x3.o" object "debug c++ {additional_flags=-I${srcsubdir} +objdebug}"] != "" } {
43 perror "Couldn't compile x3.cc"
47 if { [gdb_compile "${objdbgdir}/x1.o ${objdbgdir}/x2.o ${objdbgdir}/x3.o" "${binfile}0" executable "debug c++ {additional_flags=-I${srcsubdir} +objdebug}"] != "" } {
48 perror "Couldn't compile ${binfile}0"
52 if {[gdb_compile "${objdbgdir}/x3.o ${objdbgdir}/x2.o ${objdbgdir}/x1.o" "${binfile}1" executable "debug c++ {additional_flags=-I${srcsubdir} +objdebug}"] != "" } {
53 perror "Couldn't compile ${binfile}1"
57 # Test two executables. The first has x1.cc linked first, the second
58 # has x3.cc linked first. The difference is that in the first one,
59 # the Info<PP> instantiation from x1.cc is taken, in the second, its
62 for {set filenum 0} {$filenum < 2} {incr filenum 1} {
64 # Lets test some commons
65 # Need to restart each to make sure objects are not loaded
66 # Also cross check the address with what is actually in the
67 # object file (call the executable ${symaddrfile} to retrieve the
70 set exec_output [lindex [remote_exec build "${symaddrfile} ${binfile}${filenum} acomm"] 1]
71 regsub -all "\[\r\n\]" ${exec_output} "" exec_output
75 gdb_reinitialize_dir ${srcsubdir}
76 gdb_load ${binfile}${filenum}
77 gdb_test "p &acomm" "..* = \\(int \[*\]\\) 0x${exec_output}.*"
81 gdb_reinitialize_dir ${srcsubdir}
82 gdb_load ${binfile}${filenum}
83 gdb_test "b main" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file ..*/x1.cc, line 20."
84 gdb_test "run" "Starting program:.*Breakpoint \[0-9\]+, main .*/x1.cc:20.*20.*acomm.*=.*1.*"
86 gdb_test "p acomm" ".* = 1.*"
87 gdb_test "p &acomm" "..* = \\(int \[*\]\\) 0x${exec_output}.*"
89 # Step through each line.
90 # Do this three times.
91 # First round: Test that things are okay after printing commons
93 # Second round: Restart gdb and make sure we can walk through
94 # Third round: Do NOT restrart gdb to verify that the debug information
95 # was not messed up by loading additional object files from
96 # the first run through.
97 for {set i 0} {$i < 3} {incr i 1} {
101 gdb_reinitialize_dir ${srcsubdir}
102 gdb_load ${binfile}${filenum}
106 "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file ..*/x1.cc, line 20."
110 "Starting program:.*Breakpoint \[0-9\]+, main .*/x1.cc:20.*"
111 gdb_test "s 1" "21.*"
113 gdb_test "s 1" "Info<PP>::p .*/x3.h:11.*"
114 gdb_test "s 1" "PP::print .*/x2.cc:8.*"
115 gdb_test "s 1" ".*9.*"
116 gdb_test "s 1" "Info<PP>::p .*/x3.h:12.*"
117 gdb_test "s 1" "main .*/x1.cc:22.*"
118 gdb_test "s 1" "foo .*/x3.cc:5.*"
119 gdb_test "s 1" "Info<PP>::p .*/x3.h:11.*"
120 gdb_test "s 1" "PP::print .*/x2.cc:8.*"
121 gdb_test "s 1" ".*9.*"
122 gdb_test "s 1" "Info<PP>::p .*/x3.h:12.*"
123 gdb_test "s 1" "foo .*/x3.cc:6.*"
124 gdb_test "s 1" "Info<QQ>::p .*/x3.h:11.*"
125 gdb_test "s 1" "QQ::print .*/x2.cc:13.*"
126 gdb_test "s 1" ".*14.*"
127 gdb_test "s 1" "Info<QQ>::p .*/x3.h:12.*"
128 gdb_test "s 1" "foo .*/x3.cc:7.*"
129 gdb_test "s 1" "main .*/x1.cc:24.*"
130 gdb_test "s 1" ".*25.*"
131 if [istarget "hppa64-*-*"] {
132 gdb_test "s 1" "0x\[0-9a-f\]+ in .*"
135 gdb_test "s 1" "0x\[0-9a-f\]+ in _start .*"
136 gdb_continue_to_end "" "s 1"
140 # Test various ptypes, and combinations of them
141 # Test things multiple times in each set to make sure that the debug
142 # information did not get messed up.
146 gdb_reinitialize_dir ${srcsubdir}
147 gdb_load ${binfile}${filenum}
148 gdb_test "ptype QQ" "type = (class |)QQ {..*void print( |)..*}.*"
149 gdb_test "ptype PP" "type = (class |)PP {..*void print( |)..*}.*"
150 gdb_test "ptype QQ" "type = (class |)QQ {..*void print( |)..*}.*"
154 gdb_reinitialize_dir ${srcsubdir}
155 gdb_load ${binfile}${filenum}
156 gdb_test "ptype PP" "type = (class |)PP {..*void print( |)..*}.*"
157 gdb_test "ptype QQ" "type = (class |)QQ {..*void print( |)..*}.*"
158 gdb_test "ptype PP" "type = (class |)PP {..*void print( |)..*}.*"
162 gdb_reinitialize_dir ${srcsubdir}
163 gdb_load ${binfile}${filenum}
164 gdb_test "ptype Info<QQ>" "type = (class |)Info<QQ> {..*void p( |)..*}.*"
165 gdb_test "ptype Info<PP>" "type = (class |)Info<PP> {..*void p( |)..*}.*"
166 gdb_test "ptype Info<QQ>" "type = (class |)Info<QQ> {..*void p( |)..*}.*"
170 gdb_reinitialize_dir ${srcsubdir}
171 gdb_load ${binfile}${filenum}
172 gdb_test "ptype Info<PP>" "type = (class |)Info<PP> {..*void p( |)..*}.*"
173 gdb_test "ptype Info<QQ>" "type = (class |)Info<QQ> {..*void p( |)..*}.*"
174 gdb_test "ptype Info<PP>" "type = (class |)Info<PP> {..*void p( |)..*}.*"
178 gdb_reinitialize_dir ${srcsubdir}
179 gdb_load ${binfile}${filenum}
180 gdb_test "ptype Info" "type = template <..*> (class |)Info {..*}.*"
181 gdb_test "ptype Info<PP>" "type = (class |)Info<PP> {..*void p( |)..*}.*"
182 gdb_test "ptype Info<QQ>" "type = (class |)Info<QQ> {..*void p( |)..*}.*"
183 gdb_test "ptype Info" "type = template <..*> (class |)Info {..*}.*"
187 gdb_reinitialize_dir ${srcsubdir}
188 gdb_load ${binfile}${filenum}
189 gdb_test "ptype class QQ" "type = (class |)QQ {..*void print( |)..*}.*"
190 gdb_test "ptype class PP" "type = (class |)PP {..*void print( |)..*}.*"
191 gdb_test "ptype class QQ" "type = (class |)QQ {..*void print( |)..*}.*"
195 gdb_reinitialize_dir ${srcsubdir}
196 gdb_load ${binfile}${filenum}
197 gdb_test "ptype class PP" "type = (class |)PP {..*void print( |)..*}.*"
198 gdb_test "ptype class QQ" "type = (class |)QQ {..*void print( |)..*}.*"
199 gdb_test "ptype class PP" "type = (class |)PP {..*void print( |)..*}.*"
203 gdb_reinitialize_dir ${srcsubdir}
204 gdb_load ${binfile}${filenum}
205 gdb_test "ptype class Info<QQ>" \
206 "type = (class |)Info<QQ> {..*void p( |)..*}.*"
207 gdb_test "ptype class Info<PP>" \
208 "type = (class |)Info<PP> {..*void p( |)..*}.*"
209 gdb_test "ptype class Info<QQ>" \
210 "type = (class |)Info<QQ> {..*void p( |)..*}.*"
214 gdb_reinitialize_dir ${srcsubdir}
215 gdb_load ${binfile}${filenum}
216 gdb_test "ptype class Info<PP>" \
217 "type = (class |)Info<PP> {..*void p( |)..*}.*"
218 gdb_test "ptype class Info<QQ>" \
219 "type = (class |)Info<QQ> {..*void p( |)..*}.*"
220 gdb_test "ptype class Info<PP>" \
221 "type = (class |)Info<PP> {..*void p( |)..*}.*"