Skip to content

Commit c10216d

Browse files
Fix bug in gdb-debughelpers
1 parent 1d7670d commit c10216d

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

substratevm/debug/gdbpy/gdb-debughelpers.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def get_uncompressed_type(cls, t: gdb.Type) -> gdb.Type:
141141
# compressed types only exist for java type which are either struct or union
142142
if t.code != gdb.TYPE_CODE_STRUCT and t.code != gdb.TYPE_CODE_UNION:
143143
return t
144-
result = cls.get_base_class(t) if cls.is_compressed(t) else t
144+
result = cls.get_base_class(t) if (cls.is_compressed(t) and t != cls.hub_type) else t
145145
trace(f'<SVMUtil> - get_uncompressed_type({t}) = {result}')
146146
return result
147147

@@ -177,7 +177,7 @@ def get_compressed_oop(cls, obj: gdb.Value) -> int:
177177
# recreate compressed oop from the object address
178178
# this reverses the uncompress expression from
179179
# com.oracle.objectfile.elf.dwarf.DwarfInfoSectionImpl#writeIndirectOopConversionExpression
180-
is_hub = cls.get_rtt(obj) == cls.hub_type
180+
is_hub = cls.get_basic_type(obj.type) == cls.hub_type
181181
compression_shift = cls.compression_shift
182182
num_reserved_bits = int.bit_count(cls.reserved_bits_mask)
183183
num_alignment_bits = int.bit_count(cls.object_alignment - 1)
@@ -205,6 +205,11 @@ def get_unqualified_type_name(cls, qualified_type_name: str) -> str:
205205

206206
@classmethod
207207
def is_compressed(cls, t: gdb.Type) -> bool:
208+
# for the hub type we always want handle it as compressed as there is no clear distinction in debug info for
209+
# the hub field, and it may always have an expression in the type's data_location attribute
210+
if cls.get_basic_type(t) == cls.hub_type:
211+
return True
212+
208213
type_name = cls.get_basic_type(t).name
209214
if type_name is None:
210215
# fallback to the GDB type printer for t
@@ -363,6 +368,9 @@ def get_classloader_namespace(cls, obj: gdb.Value) -> str:
363368
def get_rtt(cls, obj: gdb.Value) -> gdb.Type:
364369
static_type = cls.get_basic_type(obj.type)
365370

371+
if static_type == cls.hub_type:
372+
return cls.hub_type
373+
366374
# check for interfaces and cast them to Object to make the hub accessible
367375
if cls.get_uncompressed_type(cls.get_basic_type(obj.type)).code == gdb.TYPE_CODE_UNION:
368376
obj = cls.cast_to(obj, cls.object_type)

substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/debug/helper/test_svm_util.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,9 @@ def test_compressed_hub_oop(self):
9696
z_hub = gdb.parse_and_eval('strList.hub')
9797
self.assertNotEqual(int(z_hub), 0)
9898
self.assertTrue(SVMUtil.is_compressed(z_hub.type))
99-
# get the uncompressed value for the hub
99+
# the hub field type does not have an 'uncompressed' type
100+
# we can just check if an absolute address is converted correctly to a compressed oop
100101
hub = z_hub.dereference()
101-
hub = hub.cast(SVMUtil.get_uncompressed_type(hub.type))
102-
self.assertFalse(SVMUtil.is_compressed(hub.type))
103102
self.assertEqual(SVMUtil.get_compressed_oop(hub), int(z_hub))
104103

105104
hub_str = str(hub)

0 commit comments

Comments
 (0)