Debug wxWidgets classes

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
pbneves
Experienced Solver
Experienced Solver
Posts: 86
Joined: Fri Feb 15, 2019 11:37 am

Debug wxWidgets classes

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...
What's the best free IDE to use in Linux with CLANG compiler and LLDB debugger?

Thanks,
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4182
Joined: Sun Jan 03, 2010 5:45 pm

Re: Debug wxWidgets classes

Post by PB »

This may not be really related, but FWIW, wxWidgets ships with GDB pretty printer for some of its classes, including wxArrayString (I have never used it):
https://github.com/wxWidgets/wxWidgets/ ... b/print.py

The CodeLite question would probably be better asked on their forum.
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Debug wxWidgets classes

Post by DavidHart »

Hi,

CodeLite is very happy to use clang. I've used it for my wx program without problems.

As you've probably discovered, it's also happy to use lldb; but I've found that less reliable compared with gdb. And as you say, it can't 'see' wxArrayString contents.

Gdb can see inside an wxArrayString though:
DebuggerTipGdb.png
DebuggerTipGdb.png (45.63 KiB) Viewed 2947 times
As PB said, it uses a python pretty-printer to do so.
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...
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; the 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
pbneves
Experienced Solver
Experienced Solver
Posts: 86
Joined: Fri Feb 15, 2019 11:37 am

Re: Debug wxWidgets classes

Post by pbneves »

Thank you both for your answers.
The reason why I mentioned wxArrayString is just because it is only a 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,
Post Reply