Author Topic: DebuggerGDB : Watches' tree view help  (Read 3374 times)

Offline drev

  • Multiple posting newcomer
  • *
  • Posts: 21
DebuggerGDB : Watches' tree view help
« on: April 21, 2010, 10:36:34 am »
Hi,
I'd like to add some watches to the debuggerGDB treeview, but as a child of a given wxTreeItem, is that possible ?
thanks

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11899
    • Travis build status
Re: DebuggerGDB : Watches' tree view help
« Reply #1 on: April 21, 2010, 10:40:17 am »
No it is not possible, watches are added only at the root.
What do you want to achieve, exactly?

(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 drev

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: DebuggerGDB : Watches' tree view help
« Reply #2 on: April 21, 2010, 11:36:53 am »
The idea is to auto-dereference a pointer
when a pointer is found when GDB send it's output, I add a child (a dot)
Then, the tree is populated and there is a + to expand (dereference) the pointer

Code: [Select]
class GdbCmd_InfoLocals : public DebuggerCmd
{
        DebuggerTree* m_pDTree;
    public:
        /** @param tree The tree to display the locals. */
        GdbCmd_InfoLocals(DebuggerDriver* driver, DebuggerTree* dtree)
            : DebuggerCmd(driver),
            m_pDTree(dtree)
        {
            m_Cmd << _T("info locals");
        }
        void ParseOutput(const wxString& output)
        {
            wxArrayString lines = GetArrayFromString(output, _T('\n'));
            wxString locals;
            locals << _T("Local variables = {");
            for (unsigned int i = 0; i < lines.GetCount(); ++i){
                if(lines[i].Contains(_T("0x")))
                {
                    locals << lines[i] << _T(" = {.}");
                }
                else
                {
                    locals << lines[i];
                }

                locals << _T(',');
            }
            locals << _T("}") << _T('\n');
            m_pDTree->BuildTree(0, locals, wsfGDB);
        }
};


Code: [Select]
void DebuggerTree::OnTreeExpand(wxTreeEvent& event)
{
    wxTreeItemIdValue cookie;
    wxTreeItemId currentTreeItem = event.GetItem();
    wxTreeItemId firstChildTreeItem = m_pTree->GetFirstChild(currentTreeItem, cookie);
    DebuggerDriver* pDriver = m_pDebugger->GetState().GetDriver();

    if(m_pTree->GetItemText(firstChildTreeItem) == wxT(".")){
        m_pTree->SetItemText(firstChildTreeItem, _T('*') + m_pTree->GetItemText(currentTreeItem).BeforeFirst(_T('=')));
        GdbCmd_Output *cmd = new GdbCmd_Output(pDriver, this, _T("*") + TreeItemToPath(firstChildTreeItem));
        pDriver->QueueCommand(cmd)
        NotifyForChangedWatches();
    }
}


I created a new command

Code: [Select]
       class GdbCmd_Output : public DebuggerCmd
        {
                DebuggerTree* m_pDTree;
                wxString m_Variable;
            public:
                /** @param tree The tree to display. */
                GdbCmd_Output(DebuggerDriver* driver, DebuggerTree* dtree, wxString variable)
                    : DebuggerCmd(driver),
                    m_pDTree(dtree),
                    m_Variable(variable)
                {
                    m_Cmd << _T("output ") + variable;
                }
                void ParseOutput(const wxString& output)
                {
                    wxArrayString lines = GetArrayFromString(output, _T('\n'));
                    wxString locals;
                    locals << output;

                    m_pDTree->ParseEntry(entry, watch, locals, -1);

                    //m_pDTree->BuildTree(0, output, wsfGDB);      //TODO append output to the wxTreeItem that matches m_Variable
                }
        };

This is a first implementation of the idea, I don't know if it will possible in the future to have an auto-dereference feature, because there are a lot of problems (ex : Multiple dereference like StructPointer1.StructPointer2.StructPointer3, since a auto-dereference is a 'child' of a pointer in the tree, we must ignore some nodes to auto dereference StructPointer3.
Maybe by populating the struct WatchTreeEntry first and refresh the tree after, but I did not understand how to use that struct.


« Last Edit: April 21, 2010, 11:50:02 am by drev »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11899
    • Travis build status
Re: DebuggerGDB : Watches' tree view help
« Reply #3 on: April 21, 2010, 01:01:18 pm »
This is a gdb problem, because I've seen it do the auto dereference thing for some variable/members
Also gdb does it automatically if it is run in GDB/mi mode.
This mode is implemented in my gdb-mi plugin.

See the thread about the debugger branch:
http://forums.codeblocks.org/index.php/topic,10908.0.html

I've not looked at your patch, because the DebuggerTree is gone in the new branch
and there is no point in doing anything to fix it (except fixing crashes).
It is replaced by a wxPropGrid control...
(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 drev

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: DebuggerGDB : Watches' tree view help
« Reply #4 on: April 21, 2010, 01:13:16 pm »
okey, I did not know there was another debugger plugin in development,
anyway I understand more how CB works.
Solved