Hi. Replies are inlined.
On Feb 28, 2012, at 7:55 AM, Nino Kettlitz wrote:
> 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),
Since you're only really producing one child value, it looks like you may want
to provide a summary for the wstring instead of synthetic children.
> 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
>
You are trying to bind a synthetic children provider to *every*
std::basic_string<T>? Why?
Again, I think a summary for std::wstring (and std::basic_string<wchar_t>)
would be enough for the purpose.
> frame variable aWideStringVector
>
> gives me
>
> (vector<std::basic_string<wchar_t>, std::allocator<std::basic_string<wchar_t>
> > >) aWideStringVector = {
> }
>
What version of LLDB are you using? (LLDB has a "version" command you can use)
This looks like an issue with the built-in synthetic children provider for
class std::vector.
In order to test *your* wstring provider, you should have a single variable of
type std::wstring and try to "frame variable" that one variable. Here, your
entry point is the synthetic children provider for std::vector.
> 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"
>
again, what you're doing here is asking the std::vector synthetic children
provider (built into LLDB) to provide you with child at index 0 - your wstring
provider is not being invoked at this moment.
> Am I doing something wrong?
> Is it in general a good idea to debug a std::wstring with synthetic children?
>
1) Probably not - if you're using a recent version of LLDB then this issue
might need further testing. Otherwise, it seems a good idea to retry this with
TOT
2) Again, I would just use a summary string provider. On LLDB TOT, the attached
Python file (which is a very slightly modified version of what you sent) works
well in providing a summary for std::wstring
(lldb) command script import wstring.py
(lldb) type summary add --python-function wstring.wstring_summary std::wstring
(lldb) frame variable
(std::wstring) foo = hello world
> thanks,
> Nino
> <wstring.py>_______________________________________________
> lldb-dev mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
import lldb
def wstring_summary (wstring, dict):
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;
return s
_______________________________________________
lldb-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev