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):
charType = lookupType("wchar_t")
else:
charType = templateArgument(baseType, 0)
repType = lookupType("%s::_Rep" % baseType).pointer()
rep = (data.cast(repType) - 1).dereference()
size = rep['_M_length']
alloc = rep['_M_capacity']
check(rep['_M_refcount'] >= -1) # Can be -1 accoring to docs.
# We can't lookup the std::string::_Rep type without crashing LLDB,
# so hard-code assumption on member position
# struct { size_type _M_length, size_type _M_capacity, int _M_refcount; }
sizePtr = data.cast(lookupType("size_t").pointer())
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)
p = gdb.Value(data.cast(charType.pointer()))
p = data.cast(charType.pointer())
# Override "std::basic_string<...>
if str(charType) == "char":
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