[utils] Add a lldb data formatter for llvm::SmallString.

Result:

(lldb) p val
(llvm::SmallString<32>) $31 = "patatino"

llvm-svn: 359157
This commit is contained in:
Davide Italiano 2019-04-25 00:03:02 +00:00
parent b1a5d7d5a8
commit 4f88388c0b
1 changed files with 11 additions and 0 deletions

View File

@ -18,6 +18,9 @@ def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand('type summary add -w llvm '
'-F lldbDataFormatters.OptionalSummaryProvider '
'-x "^llvm::Optional<.+>$"')
debugger.HandleCommand('type summary add -w llvm '
'-F lldbDataFormatters.SmallStringSummaryProvider '
'-x "^llvm::SmallString<.+>$"')
# Pretty printer for llvm::SmallVector/llvm::SmallVectorImpl
class SmallVectorSynthProvider:
@ -104,3 +107,11 @@ def OptionalSummaryProvider(valobj, internal_dict):
underlying_type = storage.GetType().GetTemplateArgumentType(0)
storage = storage.GetChildMemberWithName('storage')
return str(storage.Cast(underlying_type))
def SmallStringSummaryProvider(valobj, internal_dict):
num_elements = valobj.GetNumChildren()
res = "\""
for i in range(0, num_elements):
res += valobj.GetChildAtIndex(i).GetValue().strip("'")
res += "\""
return res