forked from OSchip/llvm-project
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.
This commit is contained in:
parent
38c366e467
commit
baa820c510
|
@ -27,8 +27,8 @@ llvm::StringRef StringRef = "bar";
|
|||
// Should test std::string in Twine too, but it's currently broken because I
|
||||
// don't know how to add 'str' and 'gdb.LazyString' (can't figure out any way to
|
||||
// string-ify LazyString).
|
||||
//std::string String = "foo";
|
||||
llvm::Twine TempTwine = llvm::Twine(3) + StringRef;
|
||||
std::string String = "foo";
|
||||
llvm::Twine TempTwine = llvm::Twine(String) + StringRef;
|
||||
llvm::Twine Twine = TempTwine + "baz";
|
||||
llvm::PointerIntPair<int *, 1> PointerIntPair(IntPtr, 1);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ p SmallString
|
|||
# CHECK: "bar"
|
||||
p StringRef
|
||||
|
||||
# CHECK: "3barbaz"
|
||||
# CHECK: "foobarbaz"
|
||||
p Twine
|
||||
|
||||
# CHECK: llvm::StringMap with 2 elements = {["foo"] = 123, ["bar"] = 456}
|
||||
|
|
|
@ -271,7 +271,7 @@ class TwinePrinter:
|
|||
# register the LazyString type, so we can't check
|
||||
# "type(s) == gdb.LazyString".
|
||||
if 'LazyString' in type(s).__name__:
|
||||
s = s.value().address.string()
|
||||
s = s.value().string()
|
||||
|
||||
else:
|
||||
print(('No pretty printer for {} found. The resulting Twine ' +
|
||||
|
|
Loading…
Reference in New Issue