[PATCH] D94431: Avoid fragile type lookups in GDB pretty printer
Moritz Sichert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 22 05:57:59 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb46545542b30: Avoid fragile type lookups in GDB pretty printer (authored by MoritzS).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94431/new/
https://reviews.llvm.org/D94431
Files:
llvm/utils/gdb-scripts/prettyprinters.py
Index: llvm/utils/gdb-scripts/prettyprinters.py
===================================================================
--- llvm/utils/gdb-scripts/prettyprinters.py
+++ llvm/utils/gdb-scripts/prettyprinters.py
@@ -211,7 +211,7 @@
it = self.val['TheTable']
end = (it + self.val['NumBuckets'])
value_ty = self.val.type.template_argument(0)
- entry_ty = gdb.lookup_type('llvm::StringMapEntry<{}>'.format(value_ty.name))
+ entry_base_ty = gdb.lookup_type('llvm::StringMapEntryBase')
tombstone = gdb.parse_and_eval('llvm::StringMapImpl::TombstoneIntVal');
while it != end:
@@ -220,15 +220,17 @@
it = it + 1
continue
- entry_ptr = it_deref.cast(entry_ty.pointer())
+ entry_ptr = it_deref.cast(entry_base_ty.pointer())
entry = entry_ptr.dereference()
str_len = entry['keyLength']
- str_data = (entry_ptr + 1).cast(gdb.lookup_type('char').const().pointer())
+ value_ptr = (entry_ptr + 1).cast(value_ty.pointer())
+ str_data = (entry_ptr + 1).cast(gdb.lookup_type('uintptr_t')) + max(value_ty.sizeof, entry_base_ty.alignof)
+ str_data = str_data.cast(gdb.lookup_type('char').const().pointer())
string_ref = gdb.Value(struct.pack('PN', int(str_data), int(str_len)), gdb.lookup_type('llvm::StringRef'))
yield 'key', string_ref
- value = entry['second']
+ value = value_ptr.dereference()
yield 'value', value
it = it + 1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94431.318503.patch
Type: text/x-patch
Size: 1446 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210122/f8367fc3/attachment.bin>
More information about the llvm-commits
mailing list