wxWidgets SyntheticChildrenProviders

CodeLite installation/troubleshooting forum
PBNeves
CodeLite Curious
Posts: 5
Joined: Wed Apr 14, 2021 2:36 pm
Genuine User: Yes
IDE Question: C++
Contact:

wxWidgets SyntheticChildrenProviders

Post by PBNeves »

Hi,
How is the most used way to inspect/debug values in wxWidgets classes such wxArrayString?
There are any SyntheticChildrenProviders to use with LLDB debugger and Codelite IDE? I've searched for it without results, and I've struggled to build one without success...
Thanks in advance

DavidGH
CodeLite Plugin
Posts: 819
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

Re: wxWidgets SyntheticChildrenProviders

Post by DavidGH »

Hi,

Is there a particular reason why you want to use lldb? CodeLite does support it; but I personally find gdb to be a better debugger.

And, as you say, lldb can't 'see' wxArrayString contents. Gdb can, though, using a python pretty-printer:

DebuggerTipGdb.png

There are any SyntheticChildrenProviders to use with LLDB debugger and Codelite IDE? I've searched for it without results, and I've struggled to build one without success...

Not AFAIK. But maybe looking at how a gdb pretty-printer does it would help. wxWidgets now supplies one (in misc/gdb/print.py) but CodeLite still provides one from before then; its wxArrayString section is:

Code: Select all

class wxArrayString:
    class _iterator:
        def __init__ (self, items, item_count):
            self.items = items
            self.item_count = item_count
            self.count = 0

    def __iter__(self):
        return self

    def next(self):
        count = self.count
        self.count = self.count + 1
        if count >= self.item_count or count > 5000: # Even 5000 gives a noticeable pause
            raise StopIteration
        try:
            # Try the wx >=2.9 way first
            elt = '"' + self.items[count]['_M_dataplus']['_M_p'].string() + '"'
        except Exception:
            # The wx2.8 way
            elt = self.items[count]
        return ('[%d]' % count, elt)

     # Python3 version
    def __next__(self):
        return self.next()

def __init__(self, val):
    self.val = val

def children(self):
    return self._iterator(self.val['m_pItems'], self.val['m_nCount'])

def to_string(self):
    # Ideal would be to return e.g. "wxArrayInt", but how to find the type?
    return "wxArrayString"

def display_hint(self):
    return 'array'

Regards,

David

You do not have the required permissions to view the files attached to this post.
PBNeves
CodeLite Curious
Posts: 5
Joined: Wed Apr 14, 2021 2:36 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: wxWidgets SyntheticChildrenProviders

Post by PBNeves »

Is there a particular reason why you want to use lldb?

Yes there is.
The reason why I mentioned wxArrayString is just because it is only an entry point for my problem. I have a more complex classes that uses wxArrayString and what I need is the ability to "see" while debugging the content of that classes. The LLDB seems to use a more easy way to accomplish this because if I define a pretty print for a type it will work in every struct/class that uses it and regardless to be a pointer or a reference. If I use GDB and pretty printers I will have to define a printer for which class and redefine all of his members and if is a pointer redefine it as well.
The problem with LLDB SyntheticChildrenProviders is that it will use Python and I'm not comfortable with it and I believe that this need is not only mine and perhaps someone had developed SyntheticChildrenProvider to wxWidgets classes that can share.
Best regards,
Pedro

DavidGH
CodeLite Plugin
Posts: 819
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

Re: wxWidgets SyntheticChildrenProviders

Post by DavidGH »

If I use GDB and pretty printers I will have to define a printer for which class and redefine all of his members and if is a pointer redefine it as well.

Are you sure you will need to do that? CodeLite's current gdb pretty-printer can 'see' into a class with a wxArrayString member(s) and show its contents.

Or do I misunderstand the situation?

PBNeves
CodeLite Curious
Posts: 5
Joined: Wed Apr 14, 2021 2:36 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: wxWidgets SyntheticChildrenProviders

Post by PBNeves »

CodeLite's current gdb pretty-printer can 'see' into a class with a wxArrayString member(s) and show its contents.

Image
As you can see the class RegistoSqlite has a wxArrayString member and the dgb debugger can't see its values.
Am I missing some configuration?
Note: I'm new to Codelite. I usually use Netbeans and gdb. I've only tried Codelite to test de LLDB features.

Regards,
Pedro,

You do not have the required permissions to view the files attached to this post.
DavidGH
CodeLite Plugin
Posts: 819
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

Re: wxWidgets SyntheticChildrenProviders

Post by DavidGH »

It works for me:

DebuggerTipArray.png

Do you have pretty-printers set? See Settings > gdb settings: Startup commands.
Are they loaded successfully? Tick 'Enable full debugger logging' in Settings > gdb settings: Misc, debug the program, then read the Output pane. Amongst the cruft you should see lines like:
DEBUG>>from wx import register_wx_printers
DEBUG>>register_wx_printers (None)
DEBUG>>end

and

DEBUG>>00000061-enable-pretty-printing
Debug session started successfully!

You do not have the required permissions to view the files attached to this post.
PBNeves
CodeLite Curious
Posts: 5
Joined: Wed Apr 14, 2021 2:36 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: wxWidgets SyntheticChildrenProviders

Post by PBNeves »

Thank you David.
It's working because Testing::barArrStr is not a pointer. If it is a pointer it will stop working.
I think this is a big disadvantage of GDB, because in LLDB the variable format will apply to pointers to, as it is said in https://lldb.llvm.org/use/variable.html#summary-strings, and in GDB you will have to do two pretty printers. One for a variable type and another to its pointer.
What I feel strange is that this question seems to be only a problem from my own and someone hasn't solved it yet!
Regards,
Pedro

DavidGH
CodeLite Plugin
Posts: 819
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

Re: wxWidgets SyntheticChildrenProviders

Post by DavidGH »

Ah, I see what you mean. I'll have a go at fixing the pretty-printer.

Meanwhile, there's an ugly workaround: when the breakpoint is hit, you can temporarily alter the code (in this case, prepending a * to m_testing.barArrStr) to dereference the pointer, after which at least the debuggertip will work correctly.

DebuggerTip.png

Alternatively you can add a Watch for the dereferenced pointer:

Watch.png
You do not have the required permissions to view the files attached to this post.
PBNeves
CodeLite Curious
Posts: 5
Joined: Wed Apr 14, 2021 2:36 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: wxWidgets SyntheticChildrenProviders

Post by PBNeves »

Ok.
Thanks

Post Reply