Commit e5855bec authored by hjk's avatar hjk
Browse files

Debugger: Replace std::string::_Rep lookup with hardcoded value



LLDB crashes on it...

Change-Id: Icd4f0ac2b6297c490fa17dc9bb90012326e25e26
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 8adbabad
...@@ -2150,13 +2150,16 @@ def qdump__std__string(d, value): ...@@ -2150,13 +2150,16 @@ def qdump__std__string(d, value):
charType = lookupType("wchar_t") charType = lookupType("wchar_t")
else: else:
charType = templateArgument(baseType, 0) charType = templateArgument(baseType, 0)
repType = lookupType("%s::_Rep" % baseType).pointer() # We can't lookup the std::string::_Rep type without crashing LLDB,
rep = (data.cast(repType) - 1).dereference() # so hard-code assumption on member position
size = rep['_M_length'] # struct { size_type _M_length, size_type _M_capacity, int _M_refcount; }
alloc = rep['_M_capacity'] sizePtr = data.cast(lookupType("size_t").pointer())
check(rep['_M_refcount'] >= -1) # Can be -1 accoring to docs. size = int(sizePtr[-3])
alloc = int(sizePtr[-2])
refcount = int(sizePtr[-1])
check(refcount >= -1) # Can be -1 accoring to docs.
check(0 <= size and size <= alloc and alloc <= 100*1000*1000) check(0 <= size and size <= alloc and alloc <= 100*1000*1000)
p = gdb.Value(data.cast(charType.pointer())) p = data.cast(charType.pointer())
# Override "std::basic_string<...> # Override "std::basic_string<...>
if str(charType) == "char": if str(charType) == "char":
d.putType("std::string", 1) d.putType("std::string", 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment