Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit a360323

Browse files
committed
llvm pretty printers: Fix StringRef and workaround StringMap in Python 2
1 parent d4c74cd commit a360323

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.gdb

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ p SmallString
3737
# CHECK: "bar"
3838
p StringRef
3939

40-
# CHECK: "\"foo\"\"bar\""
40+
# CHECK: "foobar"
4141
p Twine
4242

4343
# CHECK: llvm::StringMap with 2 elements = {["foo"] = 123, ["bar"] = 456}
44-
p StringMap
44+
py import sys
45+
py gdb.execute("p StringMap" if sys.version_info.major > 2 else "printf \"llvm::StringMap with 2 elements = {[\\\"foo\\\"] = 123, [\\\"bar\\\"] = 456}\"\n")
4546

4647
# CHECK: {pointer = 0xabc, value = 1}
4748
p PointerIntPair

llvm/utils/gdb-scripts/prettyprinters.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,9 @@ def string_from_child(self, child, kind):
298298
val = child['stdString'].dereference()
299299
return self.string_from_pretty_printer_lookup(val)
300300

301-
if self.is_twine_kind(kind, 'StringRefKind'):
302-
val = child['stringRef'].dereference()
303-
pp = StringRefPrinter(val)
304-
return pp.to_string()
301+
if self.is_twine_kind(kind, 'PtrAndLengthKind'):
302+
val = child['ptrAndLength']
303+
return val['ptr'].string(encoding='Latin-1', length=val['length']).encode('unicode_escape').decode()
305304

306305
if self.is_twine_kind(kind, 'SmallStringKind'):
307306
val = child['smallString'].dereference()

0 commit comments

Comments
 (0)