Patch #1625 2006-11-05 15:03
cripes
Notify all debuggers of breakpoint changes and text changes- Download
- 1625-Notify_all_deb.patch (5.2 KB)
Index: src/sdk/cbeditor.cpp
===================================================================
--- src/sdk/cbeditor.cpp (revision 3196)
+++ src/sdk/cbeditor.cpp (working copy)
@@ -1447,21 +1447,31 @@
return false;
}
- // set this once; the debugger won't change without a restart
- static cbDebuggerPlugin* debugger = 0;
- if (!debugger)
+// Notify debugger plugins
+ PluginsArray arr = Manager::Get()->GetPluginManager()->GetOffersFor(ptDebugger);
+ if (!arr.GetCount())
+ return false;
+ bool accepted=false;
+ for(size_t i=0;i<arr.GetCount();i++)
{
- PluginsArray arr = Manager::Get()->GetPluginManager()->GetOffersFor(ptDebugger);
- if (!arr.GetCount())
- return false;
- debugger = (cbDebuggerPlugin*)arr[0];
+ cbDebuggerPlugin* debugger = (cbDebuggerPlugin*)arr[i];
if (!debugger)
- return false;
+ continue; //kinda scary if this isn't a debugger? perhaps this should be a logged error??
+ if (debugger->AddBreakpoint(m_Filename, line))
+ {
+ accepted=true;
+ }
}
-
- if (debugger->AddBreakpoint(m_Filename, line))
+// If at least one breakpoint changed, return true
+// (could still cause problems if one debugger previously responded to add but another
+// now responds to remove of that bp - hopefully the debuggers are coded sufficiently well
+// that this doesn't happen)
+ if(accepted)
+ {
MarkerToggle(BREAKPOINT_MARKER, line);
- return true;
+ return true;
+ }
+ return false;
}
bool cbEditor::RemoveBreakpoint(int line, bool notifyDebugger)
@@ -1477,21 +1487,26 @@
return false;
}
- // set this once; the debugger won't change without a restart
- static cbDebuggerPlugin* debugger = 0;
- if (!debugger)
+ PluginsArray arr = Manager::Get()->GetPluginManager()->GetOffersFor(ptDebugger);
+ if (!arr.GetCount())
+ return false;
+ bool accepted=false;
+ for(size_t i=0;i<arr.GetCount();i++)
{
- PluginsArray arr = Manager::Get()->GetPluginManager()->GetOffersFor(ptDebugger);
- if (!arr.GetCount())
- return false;
- debugger = (cbDebuggerPlugin*)arr[0];
+ cbDebuggerPlugin* debugger = (cbDebuggerPlugin*)arr[i];
if (!debugger)
- return false;
+ continue; //kinda scary if this isn't a debugger? perhaps this should be a logged error??
+ if (debugger->RemoveBreakpoint(m_Filename, line))
+ {
+ accepted=true;
+ }
}
-
- if (debugger->RemoveBreakpoint(m_Filename, line))
+ if(accepted)
+ {
MarkerToggle(BREAKPOINT_MARKER, line);
- return true;
+ return true;
+ }
+ return false;
}
void cbEditor::ToggleBreakpoint(int line, bool notifyDebugger)
@@ -1507,17 +1522,24 @@
PluginsArray arr = Manager::Get()->GetPluginManager()->GetOffersFor(ptDebugger);
if (!arr.GetCount())
return;
- cbDebuggerPlugin* debugger = (cbDebuggerPlugin*)arr[0];
- if (HasBreakpoint(line))
+ bool toggle=false;
+ for(size_t i=0;i<arr.GetCount();i++)
{
- if (debugger->RemoveBreakpoint(m_Filename, line))
- MarkerToggle(BREAKPOINT_MARKER, line);
+ cbDebuggerPlugin* debugger = (cbDebuggerPlugin*)arr[i];
+ if (HasBreakpoint(line))
+ {
+ if (debugger->RemoveBreakpoint(m_Filename, line))
+ toggle=true;
+ }
+ else
+ {
+ if (debugger->AddBreakpoint(m_Filename, line))
+ toggle=true;
+ }
}
- else
- {
- if (debugger->AddBreakpoint(m_Filename, line))
- MarkerToggle(BREAKPOINT_MARKER, line);
- }
+ if(toggle)
+ MarkerToggle(BREAKPOINT_MARKER, line);
+ return;
}
bool cbEditor::HasBreakpoint(int line) const
@@ -2255,23 +2277,18 @@
m_pData->SetLineNumberColWidth();
}
- // get hold of debugger plugin
- static cbDebuggerPlugin* debugger = 0;
- // because the debugger plugin will *not* change throughout the
- // program's lifetime, we can speed things up by keeping it in a static
- // local variable...
- if (!debugger)
+ // NB: I don't think polling for each debugger every time will slow things down enough
+ // to worry about unless there are automated tasks that call this routine regularly
+ PluginsArray arr = Manager::Get()->GetPluginManager()->GetOffersFor(ptDebugger);
+ int startline = m_pControl->LineFromPosition(event.GetPosition());
+ if (!arr.GetCount())
+ return;
+ for(size_t i=0;i<arr.GetCount();i++)
{
- PluginsArray arr = Manager::Get()->GetPluginManager()->GetOffersFor(ptDebugger);
- if (arr.GetCount())
- debugger = (cbDebuggerPlugin*)arr[0];
+ cbDebuggerPlugin* debugger = (cbDebuggerPlugin*)arr[i];
+ debugger->Edito
download for full patch...
History
dmoore 2006-11-07 21:02
I've added this patch so that the editor now notifies all debugger plugins that have been loaded into the environment of debug relevant changes (specifically breakpoint changes, and insert/deletion of text that moves breakpoints). Currently, there is only one debugger plugin installed with codeblocks so this change will not visibly impact current users. However, I have a prototype Python debugger that I will submit in the next few weeks that requires this patch.
That is, a second debugger will only receives messages:
a) the GDB debugger is disabled; or
b) this patch is installed.
cripes 2006-11-09 08:50
damn - i put up a faulty patch. this version is correct
dmoore 2006-11-15 21:41
update - added two methods to cbeditor class to report all breakpoints.
mandrav 2007-04-12 11:55
Patch applied, thank you.