def StdStrSummaryProvider(valobj, dict): # type: (SBValue, dict) -> str assert valobj.GetNumChildren() == 2 length = valobj.GetChildMemberWithName("length").GetValueAsUnsigned() data_ptr = valobj.GetChildMemberWithName("data_ptr") start = data_ptr.GetValueAsUnsigned() error = SBError() process = data_ptr.GetProcess() data = process.ReadMemory(start, length, error) if error.Success(): return '"%s"' % data else: return '<error: %s>' % error.GetCString()
def StdStrSummaryProvider(valobj, _dict): # type: (SBValue, dict) -> str length = valobj.GetChildMemberWithName("length").GetValueAsUnsigned() if length == 0: return '""' data_ptr = valobj.GetChildMemberWithName("data_ptr") start = data_ptr.GetValueAsUnsigned() error = SBError() process = data_ptr.GetProcess() data = process.ReadMemory(start, length, error) data = data.decode(encoding='UTF-8') if PY3 else data return '"%s"' % data
def StdStrSummaryProvider(valobj, dict): # type: (SBValue, dict) -> str assert valobj.GetNumChildren() == 2 logger = Logger.Logger() logger >> "[StdStrSummaryProvider] for " + str(valobj.GetName()) length = valobj.GetChildMemberWithName("length").GetValueAsUnsigned() if length == 0: return '""' data_ptr = valobj.GetChildMemberWithName("data_ptr") start = data_ptr.GetValueAsUnsigned() error = SBError() process = data_ptr.GetProcess() data = process.ReadMemory(start, length, error) data = data.decode(encoding='UTF-8') if PY3 else data return '"%s"' % data
def StdFFIStrSummaryProvider(valobj, _dict, is_null_terminated=False): # type: (SBValue, dict, bool) -> str process = valobj.GetProcess() error = SBError() slice_ptr = valobj.GetLoadAddress() if slice_ptr == LLDB_INVALID_ADDRESS: return "" char_ptr_type = valobj.GetTarget().GetBasicType( eBasicTypeChar).GetPointerType() start = valobj.CreateValueFromAddress('start', slice_ptr, char_ptr_type).GetValueAsUnsigned() length = process.ReadPointerFromMemory( slice_ptr + process.GetAddressByteSize(), error) if is_null_terminated: length = length - 1 if length == 0: return '""' data = process.ReadMemory(start, length, error) data = data.decode(encoding='UTF-8') if PY3 else data return '"%s"' % data