Author Topic: Debugger: GDB Parsing error  (Read 4715 times)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Debugger: GDB Parsing error
« on: January 28, 2016, 01:26:34 am »
Hi, i try to debug some wxWidgets code and get a parsing error.
Debugger output:
Code
[debug]> output *str
[debug]{<wxStringBase> = {static npos = 4294967295, m_pchData = 0x75225a4 L'/' <repeats 43 times>, "\\n//\\n", '/' <repeats 43 times>}, <No data fields>}>>>>>>cb_gdb:

as output in the watch window i get:
Code
*str                          | Parsing GDB output failed for '*str'!
 + <wxStringBase>   |
      npos                   | 4294967295

greetings

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Debugger: GDB Parsing error
« Reply #1 on: January 28, 2016, 01:32:58 am »
If you use the GDB pretty printer for wx, it will just print the string content.It is just an workaround of this issue.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debugger: GDB Parsing error
« Reply #2 on: January 28, 2016, 09:24:19 am »
Thanks I'll look at it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Debugger: GDB Parsing error
« Reply #3 on: January 28, 2016, 01:05:04 pm »
minimal example to reproduce:
Code
wxString tmp = _T("///////////////////////////////\\n// \\n/////////////////////////");
just watch tmp and you will get the error described above.

If you use the GDB pretty printer for wx, it will just print the string content.It is just an workaround of this issue.
I don't know why, but my pretty printers are not working... I think i have messed somehow wx2.9(3.0) printers and wx2.8 printers. They are registered, but not working
Code
class wxStringPrinter:
    def __init__(self, val):
        self.val = val

    def to_string(self):
        try:
            return self.val['m_pchData']
        except:
            return self.val['m_impl']['_M_dataplus']['_M_p']

    def display_hint(self):
        return 'string'

greetings

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Debugger: GDB Parsing error
« Reply #4 on: January 28, 2016, 02:25:36 pm »
Thanks I'll look at it.
IMHO this is different depending on whether you are targeting wx30 or wx28... So please be careful not to break the other version.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debugger: GDB Parsing error
« Reply #5 on: January 28, 2016, 09:21:25 pm »
Don't worry. The fix should be version agnostic.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debugger: GDB Parsing error
« Reply #6 on: January 28, 2016, 11:41:15 pm »
Fixed in svn.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Debugger: GDB Parsing error
« Reply #7 on: January 30, 2016, 08:35:08 am »
This is what I used pretty printer for wxString:
Code
class wxStringPrinter:

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

    def to_string(self):
        ret = ""
        wx29 = 0
        try:
            # wx-28 has m_pchData
            self.val['m_pchData']
        except Exception:
            wx29 = 1

        try:
            if wx29:
                # return "wx29+ string"
                dataAsCharPointer = self.val['m_impl']['_M_dataplus']['_M_p']
            else:
                dataAsCharPointer = self.val['m_pchData']
                # return "wx28 string"
            ret = dataAsCharPointer
        except Exception:
            # swallow the exception and return empty string
            pass
        return ret

    def display_hint (self):
        return 'wxString'

It works fine for both wx 2.8 and wx 3.x. :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Debugger: GDB Parsing error
« Reply #8 on: January 30, 2016, 09:45:54 pm »
strangely this is not working for me....

anyway if i find time i will investigate, i think the whole python stuff does not work here (if i add a print command in the scripts it gets printed, so the interpreter is working)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debugger: GDB Parsing error
« Reply #9 on: January 30, 2016, 10:45:34 pm »
Have my fix eradicated the parsing error?
For the printers are you sure you've disabled the watch scripts in the debugger settings?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Debugger: GDB Parsing error
« Reply #10 on: January 31, 2016, 02:50:26 pm »
Have my fix eradicated the parsing error?
For the printers are you sure you've disabled the watch scripts in the debugger settings?
Yes your fix is working. And yes i have disabled the scripts in the debugger settings. On c::b site all is working, but on the gdb site something is going wrong... anyway, this is OT

thank you and greetings