diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-11-14 23:52:19 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-11-14 23:52:19 +0000 |
commit | 1a03b262d0f07d4a3091b0a9b7310100d9bd0aa9 (patch) | |
tree | d9abdd4c9db826e0b222a63373664e334e9ed283 /utils | |
parent | 29a67e8f3adbd433acf271f7be699c50ceb7bdef (diff) |
[utils/ClangDataFormat.py] Add data formatter for StringRef.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168003 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/ClangDataFormat.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/utils/ClangDataFormat.py b/utils/ClangDataFormat.py index 817c0b6056..bde38111d2 100644 --- a/utils/ClangDataFormat.py +++ b/utils/ClangDataFormat.py @@ -23,10 +23,14 @@ import lldb def __lldb_init_module(debugger, internal_dict): debugger.HandleCommand("type summary add -F ClangDataFormat.SourceLocation_summary clang::SourceLocation") + debugger.HandleCommand("type summary add -F ClangDataFormat.StringRef_summary llvm::StringRef") def SourceLocation_summary(srcloc, internal_dict): return SourceLocation(srcloc).summary() +def StringRef_summary(strref, internal_dict): + return StringRef(strref).summary() + class SourceLocation(object): def __init__(self, srcloc): self.srcloc = srcloc @@ -51,6 +55,23 @@ class SourceLocation(object): desc = "%s (offset: %d, %s, %s)" % (self.getPrint(srcmgr_path), self.offset(), "macro" if self.isMacro() else "file", "local" if self.isLocal(srcmgr_path) else "loaded") return desc +class StringRef(object): + def __init__(self, strref): + self.strref = strref + self.Data_value = strref.GetChildAtIndex(0) + self.Length = strref.GetChildAtIndex(1).GetValueAsUnsigned() + + def summary(self): + if self.Length == 0: + return '""' + data = self.Data_value.GetPointeeData(0, self.Length) + error = lldb.SBError() + string = data.ReadRawData(error, 0, data.GetByteSize()) + if error.Fail(): + return None + return '"%s"' % string + + # Key is a (function address, type name) tuple, value is the expression path for # an object with such a type name from inside that function. FramePathMapCache = {} |