|
42 | 42 |
|
43 | 43 | import re |
44 | 44 | import sys |
| 45 | +import os |
45 | 46 |
|
46 | 47 | # A helper class which checks that a sequence of lines of output |
47 | 48 | # from a gdb command matches a sequence of per-line regular |
@@ -139,10 +140,16 @@ def test(): |
139 | 140 | # n.b. can only get back here with one match |
140 | 141 | match = matches[0] |
141 | 142 | major = int(match.group(1)) |
142 | | - # may need this if 8.x and 9.x get patched |
143 | | - # minor = int(match.group(2)) |
144 | | - # printing object data requires gdb 10+ |
145 | | - can_print_data = major > 9 |
| 143 | + minor = int(match.group(2)) |
| 144 | + # printing object data requires a patched gdb |
| 145 | + # once the patch is in we can check for a suitable |
| 146 | + # range of major.minor versions |
| 147 | + # for now we use an env setting |
| 148 | + print("Found gdb version %s.%s"%(major, minor)) |
| 149 | + # can_print_data = major > 10 or (major == 10 and minor > 1) |
| 150 | + can_print_data = False |
| 151 | + if os.environ.get('GDB_CAN_PRINT', '') == 'True': |
| 152 | + can_print_data = True |
146 | 153 |
|
147 | 154 | if not can_print_data: |
148 | 155 | print("Warning: cannot test printing of objects!") |
@@ -182,12 +189,13 @@ def test(): |
182 | 189 | exec_string = execute("print /x *(('java.lang.String[]' *)$rdi)") |
183 | 190 | checker = Checker("print String[] args", |
184 | 191 | [r"%s = {"%(wildcard_pattern), |
185 | | - r"%s<_arrhdrA> = {"%(spaces_pattern), |
| 192 | + r"%s<java.lang.Object> = {"%(spaces_pattern), |
| 193 | + r"%s<_objhdr> = {"%(spaces_pattern), |
186 | 194 | r"%shub = %s,"%(spaces_pattern, address_pattern), |
187 | | - r"%sidHash = %s,"%(spaces_pattern, address_pattern), |
188 | | - r"%slen = 0x0"%(spaces_pattern), |
189 | | - r"%s},"%(spaces_pattern), |
| 195 | + r"%sidHash = %s"%(spaces_pattern, address_pattern), |
| 196 | + r"%s}, <No data fields>}, "%(spaces_pattern), |
190 | 197 | r"%smembers of java\.lang\.String\[\]:"%(spaces_pattern), |
| 198 | + r"%slen = 0x0,"%(spaces_pattern), |
191 | 199 | r"%sdata = %s"%(spaces_pattern, address_pattern), |
192 | 200 | "}"]) |
193 | 201 |
|
@@ -225,7 +233,7 @@ def test(): |
225 | 233 | # ensure we can dereference static fields |
226 | 234 | exec_string = execute("print 'java.math.BigDecimal'::BIG_TEN_POWERS_TABLE->data[3]->mag->data[0]") |
227 | 235 | checker = Checker("print static field value contents", |
228 | | - r"%s = 1000\$"%(wildcard_pattern)) |
| 236 | + r"%s = 1000"%(wildcard_pattern)) |
229 | 237 | checker.check(exec_string, skip_fails=False) |
230 | 238 |
|
231 | 239 | # look up PrintStream.println methods |
@@ -308,13 +316,12 @@ def test(): |
308 | 316 | checker = Checker('ptype _objhdr', rexp) |
309 | 317 | checker.check(exec_string, skip_fails=True) |
310 | 318 |
|
311 | | - exec_string = execute("ptype _arrhdrA") |
312 | | - rexp = [r"type = struct _arrhdrA {", |
313 | | - r"%sjava\.lang\.Class \*hub;"%(spaces_pattern), |
314 | | - r"%sint idHash;"%(spaces_pattern), |
| 319 | + exec_string = execute("ptype 'java.lang.String[]'") |
| 320 | + rexp = [r"type = class java.lang.String\[\] : public java.lang.Object {", |
315 | 321 | r"%sint len;"%(spaces_pattern), |
| 322 | + r"%sjava\.lang\.String \*data\[0\];"%(spaces_pattern), |
316 | 323 | r"}"] |
317 | | - checker = Checker('ptype _objhdr', rexp) |
| 324 | + checker = Checker('ptype String[]', rexp) |
318 | 325 | checker.check(exec_string, skip_fails=True) |
319 | 326 |
|
320 | 327 | # run a backtrace |
|
0 commit comments