Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
DebuggerGDB : Watches' tree view help
(1/1)
drev:
Hi,
I'd like to add some watches to the debuggerGDB treeview, but as a child of a given wxTreeItem, is that possible ?
thanks
oBFusCATed:
No it is not possible, watches are added only at the root.
What do you want to achieve, exactly?
drev:
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: ---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);
}
};
--- End code ---
--- Code: ---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();
}
}
--- End code ---
I created a new command
--- Code: --- 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
}
};
--- End code ---
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.
oBFusCATed:
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...
drev:
okey, I did not know there was another debugger plugin in development,
anyway I understand more how CB works.
Solved
Navigation
[0] Message Index
Go to full version