authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-06-13 02:18:01+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-12 18:24:21-07:00
log4b7c1e5c300c471618c9b12646247ef887a3a576
tree9f7d8b2a18cabf822324291e5fba4eb82dcf8dc5
parentff35a180dd1b55d601c862f6a1bc14e3d6dbf25c

tools: add LLDB pretty printer for InternPool.NullTerminatedString


1 files changed, 19 insertions(+), 0 deletions(-)

tools/lldb_pretty_printers.py+19
......@@ -478,6 +478,24 @@ class InternPool_Index_SynthProvider:
478478 except: return -1
479479 def get_child_at_index(self, index): return (self.tag, self.data, self.trailing)[index] if index in range(3) else None
480480
481def InternPool_NullTerminatedString_SummaryProvider(value, _=None):
482 try:
483 ip = InternPool_Find(value.thread)
484 if not ip: return
485 items = ip.GetChildMemberWithName('string_bytes').GetChildMemberWithName('items')
486 b = bytearray()
487 i = 0
488 while True:
489 x = items.GetChildAtIndex(value.unsigned + i).GetValueAsUnsigned()
490 if x == 0: break
491 b.append(x)
492 i += 1
493 s = b.decode(encoding='utf8', errors='backslashreplace')
494 s1 = s if s.isprintable() else ''.join((c if c.isprintable() else '\\x%02x' % ord(c) for c in s))
495 return '"%s"' % s1
496 except:
497 pass
498
481499def type_Type_pointer(payload):
482500 pointee_type = payload.GetChildMemberWithName('pointee_type')
483501 sentinel = payload.GetChildMemberWithName('sentinel').GetChildMemberWithName('child')
......@@ -690,6 +708,7 @@ def __lldb_init_module(debugger, _=None):
690708 add(debugger, category='zig.stage2', type='Module.Decl::Module.Decl.Index', synth=True)
691709 add(debugger, category='zig.stage2', type='Module.LazySrcLoc', identifier='zig_TaggedUnion', synth=True)
692710 add(debugger, category='zig.stage2', type='InternPool.Index', synth=True)
711 add(debugger, category='zig.stage2', type='InternPool.NullTerminatedString', summary=True)
693712 add(debugger, category='zig.stage2', type='InternPool.Key', identifier='zig_TaggedUnion', synth=True)
694713 add(debugger, category='zig.stage2', type='InternPool.Key.Int.Storage', identifier='zig_TaggedUnion', synth=True)
695714 add(debugger, category='zig.stage2', type='InternPool.Key.ErrorUnion.Value', identifier='zig_TaggedUnion', synth=True)