Hi,
are there any Python scripts to debug a std::wstring (i.e.
std::basic_string<int> in osx)?
It would be very useful, especially when debugging a vector of strings
(i.estd::vector< std::wstring >)
After searching a while in the internet I found nothing, so I started to
write my own Python class for generating synthetic children (exactly one
chiled, i.e. the string itself),
but there are several problems I could not solve.
My test programm looks as follows:
std::vector< std::wstring > aWideStringVector;
aWideStringVector.push_back(L"Filter/EQ");
aWideStringVector.push_back(L"Lowpass Filter");
aWideStringVector.push_back(L"Wah Wah");
aWideStringVector.push_back(L"Pitch Shift");
aWideStringVector.push_back(L"Highpass Filter");
aWideStringVector.push_back(L"Bandpass Filter");
I registered the synthetic children class with type synthetic add -x
"^(std::)?basic_string<.+>" --python-class
wstring.StdWStringSynthProvider but
frame variable aWideStringVector
gives me
(vector<std::basic_string<wchar_t>,
std::allocator<std::basic_string<wchar_t> > >) aWideStringVector = {
}
and
frame variable aWideStringVector[0]
gives me
error: array index 0 is not valid for
"(vector<std::basic_string<wchar_t>,
std::allocator<std::basic_string<wchar_t> > >) aWideStringVector"
Am I doing something wrong?
Is it in general a good idea to debug a std::wstring with synthetic
children?
thanks,
Nino
import lldb
class StdWStringSynthProvider:
def __init__(self, valobj, dict):
self.valobj = valobj;
self.update()
def num_children(self):
if self.data != 0:
return 1
else:
return 0
def get_child_index(self,name):
return 0
def get_child_at_index(self,index):
if index != 0:
return None;
else:
s = '';
if self.data != 0:
e = lldb.SBError();
i = 0;
x = self.data.GetPointeeData(i,1).GetSignedInt32(e, 0)
while x != 0:
s = s + chr(x);
i = i + 1;
x = self.data.GetPointeeData(i,1).GetSignedInt32(e, 0)
return self.data.CreateChildAtOffset(s,0,self.data.GetType())
def update(self):
try:
impl = self.valobj.GetChildMemberWithName('_M_dataplus')
self.data = impl.GetChildMemberWithName('_M_p')
self.data_type = self.data.GetPointeeType()
self.data_size = self.data_type.GetByteSize()
except:
pass
def print_wstring (wstring, lldb):
e = lldb.SBError()
_M_dataplus = wstring.GetChildMemberWithName ("_M_dataplus")
_M_p = _M_dataplus.GetChildMemberWithName ("_M_p")
s = '';
if _M_p != 0:
i = 0;
x = _M_p.GetPointeeData(i,1).GetSignedInt32(e, 0)
while x != 0:
x = _M_p.GetPointeeData(i,1).GetSignedInt32(e, 0)
s = s + chr(x);
i = i + 1;
print(s);
_______________________________________________
lldb-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev