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