Page 1 of 2

Debugging with GDB - How to get Values

Posted: Sun Sep 12, 2010 8:48 pm
by evstevemd
My App was crashing, so I decided to Debug using GDB. My app Consists of std::Vector and wxArrayString among others.
I can see the two variables but cant poke to see what is inside. I mean the wxString inside array and the stuffs carried in std::vector.
How do I do that? Any tutorial, if I'm missing?

Thanks :D (BTW app is working but I just want to know the how-to)

Re: Debugging with GDB - How to get Values

Posted: Sun Sep 12, 2010 9:57 pm
by eranif
gdb is very limited when it comes to debug complex structures (unlike VC debugger..)

There is no built-in support for this, luckily there is a nice workaround that you can use:

From the menu: 'settings -> debugger settings' and open the tab named 'PreDefined Types'

and add 2 new types:

Code: Select all

Type: wxArrayString
Expression: *($(Variable).m_pItems)@$(Variable).m_nCount
Debugger Command: print

Code: Select all

Type: vector
Expression: *($(Variable)._M_impl._M_start)@$(Variable).size()
Debugger Command: print
And close the dialog.

Now, when debugging, whenever you want to query a wxArrayString or vector, position the mouse on top of the variable you want to query and select from the context menu: 'More watches -> watch as 'vector' (or whatever the actual type is)

You will now have a new entry in the watches table, double click it and you will be able to query it in the regular manner of tree format.

Eran

Re: Debugging with GDB - How to get Values

Posted: Mon Sep 13, 2010 8:16 am
by evstevemd
Thanks Eran,
I'm going to do that!

Re: Debugging with GDB - How to get Values

Posted: Mon Sep 13, 2010 1:05 pm
by evstevemd
Actually the situation is little complex, The Vector holds wxArrayString. I want to be able to examine contents of wxArrayString I wonder why I cannot even see simple wxArrayString using procedure above.

Re: Debugging with GDB - How to get Values

Posted: Mon Sep 13, 2010 1:09 pm
by eranif
Upload the file debuggers.xml (rename it) to this post, and I will have a look.
Also, remember to mention your codelite version and wx version

You should post your local copy of the file (from C:\Document and Settings\User\ApplicatioData\Codelite\config)
Eran

Re: Debugging with GDB - How to get Values

Posted: Mon Sep 13, 2010 1:46 pm
by evstevemd
Where is it living?
I can find debuggers.xml.default and nothing else.
CodeLite: 2.7 (I updated yesterday via SVN) and wxWidgets that comes with CL

Re: Debugging with GDB - How to get Values

Posted: Mon Sep 13, 2010 1:50 pm
by eranif
For Win XP, have a look at my previous post.
Win7, C:\Users\<name>\AppData\codelite (or something like that)

Eran

Re: Debugging with GDB - How to get Values

Posted: Mon Sep 13, 2010 2:01 pm
by evstevemd
Here it is, zipped file

Re: Debugging with GDB - How to get Values

Posted: Mon Sep 13, 2010 2:27 pm
by eranif
evstevemd wrote:I wonder why I cannot even see simple wxArrayString using procedure above.
Have u tried to double click on the entry in the 'Watches' table?

Also, to be able to do the same from the 'Locals' view, you need to enable the option (from 'settings -> debugger settings...'):
'Evaluate items in the 'Locals' view based on the 'PreDefined' types where possible'

Eran

Re: Debugging with GDB - How to get Values

Posted: Mon Sep 13, 2010 2:42 pm
by evstevemd
'Evaluate items in the 'Locals' view based on the 'PreDefined' types where possible'
What do you mean? I don't understand that!