Author Topic: Help How do you get GDB to "p (cast) *pointer?  (Read 11734 times)

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Help How do you get GDB to "p (cast) *pointer?
« on: December 09, 2005, 04:38:58 pm »
I'm trying to run down some of the crashes in the RC3 wxKeybinder code.
In the following example (at bottom) GDB refuses to "p (wxMenuItem) *m_pItem" even though it knows about the structure.

How can I dump the object of "m_pItem->".

I've read the G*#!@D#!@B documentation twice. GDB can be so frustrating
at times.
 
Code
(gdb) frame 2
#2  0x0044d5c6 in wxMenuCmd::Update (this=0x1e3e798)
    at src/wxKeyBinder/src/menuutils.cpp:78
78           strText = m_pItem->GetText();
Current language:  auto; currently c++
(gdb) l
73              //Pecan 01
74              // CodeBlocks contains filenames in menuitems
75              // which contain "\\" that look like accelerators
76              // and hotkeys that crash GetLabel()
77          wxString strText("");
78           strText = m_pItem->GetText();
79              if (strText.Contains(_T("\\\\")))
80                return ;
81
82              wxString str = m_pItem->GetLabel();
(gdb) p this
$1 = (wxMenuCmd * const) 0x1e3e798
(gdb) p *this
$2 = {<wxCmd> = {_vptr$wxCmd = 0x4b32ac, m_keyShortcut = {{
        _vptr$wxKeyBind = 0x4b3294, m_nFlags = -1, m_nKeyCode = -1}, {
        _vptr$wxKeyBind = 0x4b3294, m_nFlags = -1, m_nKeyCode = -1}, {
        _vptr$wxKeyBind = 0x4b3294, m_nFlags = -1, m_nKeyCode = -1}},
    m_nShortcuts = 0, m_strName = {<wxStringBase> = {static npos = 4294967295,
        m_pchData = 0x1e3518c "1 CodeBlocks-NewBuild.cbp"}, <No data fields>},
    m_strDescription = {<wxStringBase> = {static npos = 4294967295,
        m_pchData = 0x104cfbcc ""}, <No data fields>}, m_nId = 520,
    static m_arrCmdType = 0x4b5d00, static m_nCmdTypes = 1},
  m_pItem = 0x16eca88, static m_pMenuBar = 0x165b008}
(gdb) p m_pItem
$3 = (struct wxMenuItem *) 0x16eca88
(gdb) p *m_pItem
$4 = <incomplete type>
(gdb) p (wxMenuItem) *m_pItem
No symbol "wxMenuItem" in current context.
(gdb) p (wxMenuItem) *0x16eca88
No symbol "wxMenuItem" in current context.
(gdb)

thanks
Pecan

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Help How do you get GDB to "p (cast) *pointer?
« Reply #1 on: December 09, 2005, 10:19:43 pm »
Pecan: You can compile the SVN head version, it has improved the built-in debugger interface A LOT.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: Help How do you get GDB to "p (cast) *pointer?
« Reply #2 on: December 10, 2005, 04:48:26 pm »
Rick, a little help here..

So, from a cmd window with the path set to ...\devel,
I started codeblocks.exe.
It starts and loads the plugin to be tested.
I load the project and the source files open.
I set a breakpoint.
I look in Task Mgr for the PID
I menu->debug->attach to PID

codeblocks is now frozen. Cant even activate the menus.
Task Manger cant even kill c::b. I have to reboot the system.

WinXpSp2 1/2 gig, 1.9 ghz M processor.

AND, worst of all, the Mass in C Minor is hosed with some
female screaming to the top of her MayWests.

thanks
Pecan


Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Help How do you get GDB to "p (cast) *pointer?
« Reply #3 on: December 10, 2005, 04:56:43 pm »
So, from a cmd window with the path set to ...\devel,
I started codeblocks.exe.
It starts and loads the plugin to be tested.
I load the project and the source files open.
I set a breakpoint.
I look in Task Mgr for the PID
I menu->debug->attach to PID

codeblocks is now frozen. Cant even activate the menus.
Task Manger cant even kill c::b. I have to reboot the system.

You realize you should do that from a separate instance of Code::Blocks, right :shock:? Having a process debug itself is pretty much a recipy for deadlock...

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: Help How do you get GDB to "p (cast) *pointer?
« Reply #4 on: December 10, 2005, 05:16:17 pm »
Oh, no I did not realize that...

Ok, so does that mean I have to have two
codeblocks running.  Im still confused (a congenital state for me).

Which one has the plugin running and which one has the source?

thanks
pecan

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Help How do you get GDB to "p (cast) *pointer?
« Reply #5 on: December 10, 2005, 05:26:49 pm »
Ok, so does that mean I have to have two
codeblocks running.  Im still confused (a congenital state for me).

Which one has the plugin running and which one has the source?

Open the source in output\codeblocks.exe and load the plugin in devel\codeblocks.exe.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: Help How do you get GDB to "p (cast) *pointer?
« Reply #6 on: December 10, 2005, 06:09:05 pm »
Urxae

thanks for the tips. I got it to start debugging. But then
got into some loop with a codeblocks messagekBox constantly
poping up saying:

"DebuggerTree::BeginUpdateTree() while already in update block."

Can't get past it. Have to kill the ...\output\codeblocks with the
Task Manager.

Oh, well.... Its new code...

I'll have to live with GDB for the moment to get the plugin
running I guess.

thanks for all the help
pecan