Skip to content

Commit baa820c

Browse files
committed
Add some support for pretty printing Twines containing std::string in gdb
This isn't perfect, since it doesn't use lazy_string - so if the std::string does contain unprintable characters it might fail, but seems better than nothing & LLVM doesn't generally store binary data in std::strings.
1 parent 38c366e commit baa820c

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ llvm::StringRef StringRef = "bar";
2727
// Should test std::string in Twine too, but it's currently broken because I
2828
// don't know how to add 'str' and 'gdb.LazyString' (can't figure out any way to
2929
// string-ify LazyString).
30-
//std::string String = "foo";
31-
llvm::Twine TempTwine = llvm::Twine(3) + StringRef;
30+
std::string String = "foo";
31+
llvm::Twine TempTwine = llvm::Twine(String) + StringRef;
3232
llvm::Twine Twine = TempTwine + "baz";
3333
llvm::PointerIntPair<int *, 1> PointerIntPair(IntPtr, 1);
3434

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ p SmallString
3737
# CHECK: "bar"
3838
p StringRef
3939

40-
# CHECK: "3barbaz"
40+
# CHECK: "foobarbaz"
4141
p Twine
4242

4343
# CHECK: llvm::StringMap with 2 elements = {["foo"] = 123, ["bar"] = 456}

llvm/utils/gdb-scripts/prettyprinters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def string_from_pretty_printer_lookup(self, val):
271271
# register the LazyString type, so we can't check
272272
# "type(s) == gdb.LazyString".
273273
if 'LazyString' in type(s).__name__:
274-
s = s.value().address.string()
274+
s = s.value().string()
275275

276276
else:
277277
print(('No pretty printer for {} found. The resulting Twine ' +

0 commit comments

Comments
 (0)