[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] [Head:applied] Frame work to deferred Breakpoint (2/2)
|
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.183
diff -u -r1.183 ChangeLog
--- ChangeLog 7 Oct 2003 18:30:31 -0000 1.183
+++ ChangeLog 18 Oct 2003 01:19:06 -0000
@@ -1,3 +1,23 @@
+2003-10-17 Alain Magloire
+
+ Put the framework to deal with deferred breakpoint.
+
+ * src/org/eclipse/cdt/debug/mi/core/cdi/event/ResumeEvent.java
+ Deal with MIRunningEvent.RETURN.
+ * src/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java
+ Check if MIBreakpoint is null first.
+ * src/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java
+ Check if MIWathchpoint is null first.
+ * src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java
+ Implement Deferred Breakpoint
+ * src/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java
+ Implement Deferred Breakpoint
+ * src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java
+ Enable deferredBreakpoint.
+ * src/org/eclipse/cdt/debug/mi/core/CygwinDebugger.java
+ Enable deferredBreakpoint.
+
+
2003-10-07 Mikhail Khodjaiants
All methods of 'IRuntimeOptions' should throw CDI exceptions in case of failure.
Index: src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java,v
retrieving revision 1.6
diff -u -r1.6 CygwinGDBDebugger.java
--- src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java 30 Sep 2003 01:59:10 -0000 1.6
+++ src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java 18 Oct 2003 01:19:06 -0000
@@ -33,11 +33,21 @@
protected void initializeLibraries(ILaunchConfiguration config, Session session) throws CDIException {
try {
- ICDISharedLibraryManager mgr = session.getSharedLibraryManager();
- if (mgr instanceof SharedLibraryManager) {
+ ICDISharedLibraryManager manager = session.getSharedLibraryManager();
+ if (manager instanceof SharedLibraryManager) {
+ SharedLibraryManager mgr = (SharedLibraryManager)manager;
boolean stopOnSolibEvents = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, false);
try {
- ((SharedLibraryManager)mgr).setStopOnSolibEvents(stopOnSolibEvents);
+ mgr.setStopOnSolibEvents(stopOnSolibEvents);
+ // By default, we provide with the capability of deferred breakpoints
+ // And we set setStopOnSolib events for them(but they should not see the dll events ).
+ //
+ // If the user explicitly set stopOnSolibEvents well it probably
+ // means that they wanted to see those events so do no do deferred breakpoints.
+ if (!stopOnSolibEvents) {
+ mgr.setStopOnSolibEvents(true);
+ mgr.setDeferredBreakpoint(true);
+ }
} catch (CDIException e) {
// Ignore this error
// it seems to be a real problem on many gdb platform
@@ -45,11 +55,11 @@
}
List p = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST);
if (p.size() > 0) {
- String[] oldPaths = mgr.getSharedLibraryPaths();
+ String[] oldPaths = manager.getSharedLibraryPaths();
String[] paths = new String[oldPaths.length + p.size()];
System.arraycopy((String[])p.toArray(new String[p.size()]), 0, paths, 0, p.size());
System.arraycopy(oldPaths, 0, paths, p.size(), oldPaths.length);
- mgr.setSharedLibraryPaths(paths);
+ manager.setSharedLibraryPaths(paths);
}
} catch (CoreException e) {
throw new CDIException("Error initializing shared library options: " + e.getMessage());
@@ -77,6 +87,7 @@
// We ignore this exception, for example
// on GNU/Linux the new-console is an error.
}
+ initializeLibraries(config, session);
return session;
}
@@ -88,6 +99,7 @@
Session session =
(Session) super.createAttachSession(config, exe, pid);
session.getMISession().setCommandFactory(commandFactory);
+ initializeLibraries(config, session);
return session;
}
@@ -99,6 +111,7 @@
Session session =
(Session) super.createCoreSession(config, exe, corefile);
session.getMISession().setCommandFactory(commandFactory);
+ initializeLibraries(config, session);
return session;
}
}
Index: src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java,v
retrieving revision 1.18
diff -u -r1.18 GDBDebugger.java
--- src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java 11 Sep 2003 17:44:35 -0000 1.18
+++ src/org/eclipse/cdt/debug/mi/core/GDBDebugger.java 18 Oct 2003 01:19:06 -0000
@@ -24,13 +24,24 @@
protected void initializeLibraries(ILaunchConfiguration config, Session session) throws CDIException {
try {
- ICDISharedLibraryManager mgr = session.getSharedLibraryManager();
- if (mgr instanceof SharedLibraryManager) {
+ ICDISharedLibraryManager manager = session.getSharedLibraryManager();
+ if (manager instanceof SharedLibraryManager) {
+ SharedLibraryManager mgr = (SharedLibraryManager)manager;
boolean autolib = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, false);
boolean stopOnSolibEvents = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, false);
try {
- ((SharedLibraryManager)mgr).setAutoLoadSymbols(autolib);
- ((SharedLibraryManager)mgr).setStopOnSolibEvents(stopOnSolibEvents);
+ mgr.setAutoLoadSymbols(autolib);
+ mgr.setStopOnSolibEvents(stopOnSolibEvents);
+ // The idea is that if the user set autolib, by default
+ // we provide with the capability of deferred breakpoints
+ // And we set setStopOnSolib events for them(but they should not see those things.
+ //
+ // If the user explicitly set stopOnSolibEvents well it probably
+ // means that they wanted to see those events so do no do deferred breakpoints.
+ if (autolib && !stopOnSolibEvents) {
+ mgr.setDeferredBreakpoint(true);
+ mgr.setStopOnSolibEvents(true);
+ }
} catch (CDIException e) {
// Ignore this error
// it seems to be a real problem on many gdb platform
@@ -38,11 +49,11 @@
}
List p = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST);
if (p.size() > 0) {
- String[] oldPaths = mgr.getSharedLibraryPaths();
+ String[] oldPaths = manager.getSharedLibraryPaths();
String[] paths = new String[oldPaths.length + p.size()];
System.arraycopy((String[])p.toArray(new String[p.size()]), 0, paths, 0, p.size());
System.arraycopy(oldPaths, 0, paths, p.size(), oldPaths.length);
- mgr.setSharedLibraryPaths(paths);
+ manager.setSharedLibraryPaths(paths);
}
} catch (CoreException e) {
throw new CDIException("Error initializing shared library options: " + e.getMessage());
Index: src/org/eclipse/cdt/debug/mi/core/RxThread.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/RxThread.java,v
retrieving revision 1.46
diff -u -r1.46 RxThread.java
--- src/org/eclipse/cdt/debug/mi/core/RxThread.java 26 Sep 2003 16:57:53 -0000 1.46
+++ src/org/eclipse/cdt/debug/mi/core/RxThread.java 18 Oct 2003 01:19:06 -0000
@@ -12,9 +12,11 @@
import java.util.List;
import org.eclipse.cdt.debug.mi.core.command.Command;
+import org.eclipse.cdt.debug.mi.core.command.MIExecContinue;
import org.eclipse.cdt.debug.mi.core.command.MIExecFinish;
import org.eclipse.cdt.debug.mi.core.command.MIExecNext;
import org.eclipse.cdt.debug.mi.core.command.MIExecNextInstruction;
+import org.eclipse.cdt.debug.mi.core.command.MIExecReturn;
import org.eclipse.cdt.debug.mi.core.command.MIExecStep;
import org.eclipse.cdt.debug.mi.core.command.MIExecStepInstruction;
import org.eclipse.cdt.debug.mi.core.command.MIExecUntil;
@@ -146,6 +148,10 @@
type = MIRunningEvent.UNTIL;
} else if (cmd instanceof MIExecFinish) {
type = MIRunningEvent.FINISH;
+ } else if (cmd instanceof MIExecReturn) {
+ type = MIRunningEvent.RETURN;
+ } else if (cmd instanceof MIExecContinue) {
+ type = MIRunningEvent.CONTINUE;
} else {
type = MIRunningEvent.CONTINUE;
}
@@ -199,6 +205,7 @@
void processMIOOBRecord(MIOOBRecord oob, List list) {
if (oob instanceof MIAsyncRecord) {
processMIOOBRecord((MIAsyncRecord) oob, list);
+ oobList.clear();
} else if (oob instanceof MIStreamRecord) {
processMIOOBRecord((MIStreamRecord) oob);
}
Index: src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java,v
retrieving revision 1.33
diff -u -r1.33 BreakpointManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java 10 Oct 2003 13:47:59 -0000 1.33
+++ src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java 18 Oct 2003 01:19:06 -0000
@@ -14,6 +14,7 @@
import org.eclipse.cdt.debug.core.cdi.ICDICatchEvent;
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
+import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDICatchpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
@@ -50,12 +51,14 @@
public class BreakpointManager extends SessionObject implements ICDIBreakpointManager {
List breakList;
+ List deferredList;
boolean allowInterrupt;
boolean autoupdate;
public BreakpointManager(Session session) {
super(session);
breakList = Collections.synchronizedList(new ArrayList());
+ deferredList = Collections.synchronizedList(new ArrayList());
allowInterrupt = true;
autoupdate = false;
}
@@ -265,6 +268,8 @@
// Fire ChangedEvent
bp.setMIBreakpoint(newMIBreakpoints[i]);
eventList.add(new MIBreakpointChangedEvent(no));
+ } else {
+ eventList.add(new MIBreakpointCreatedEvent(no));
}
} else {
// add the new breakpoint and fire CreatedEvent
@@ -318,6 +323,14 @@
deleteBreakpoints(new ICDIBreakpoint[] { breakpoint });
}
+ public void deleteFromDeferredList(Breakpoint bkpt) {
+ deferredList.remove(bkpt);
+ }
+
+ public void addToBreakpointList(Breakpoint bkpt) {
+ breakList.add(bkpt);
+ }
+
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#deleteBreakpoints(ICDIBreakpoint[])
*/
@@ -364,6 +377,10 @@
return (ICDIBreakpoint[]) breakList.toArray(new ICDIBreakpoint[0]);
}
+ public ICDIBreakpoint[] getDeferredBreakpoints() throws CDIException {
+ return (ICDIBreakpoint[]) deferredList.toArray(new ICDIBreakpoint[0]);
+ }
+
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#setCatchpoint(int, ICDICatchEvent, String, ICDICondition, boolean)
*/
@@ -377,18 +394,58 @@
*/
public ICDILocationBreakpoint setLocationBreakpoint(int type, ICDILocation location,
ICDICondition condition, String threadId) throws CDIException {
+ return setLocationBreakpoint(type, location, condition, threadId, false);
+ }
+
+ /**
+ * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#setLocationBreakpoint(int, ICDILocation, ICDICondition, boolean, String)
+ */
+ public ICDILocationBreakpoint setLocationBreakpoint(int type, ICDILocation location,
+ ICDICondition condition, String threadId, boolean deferred) throws CDIException {
+
+ Breakpoint bkpt = new Breakpoint(this, type, location, condition, threadId);
+ try {
+ setLocationBreakpoint(bkpt);
+ breakList.add(bkpt);
- boolean hardware = (type == ICDIBreakpoint.HARDWARE);
- boolean temporary = (type == ICDIBreakpoint.TEMPORARY);
+ // Fire a created Event.
+ Session session = (Session)getSession();
+ MISession mi = session.getMISession();
+ mi.fireEvent(new MIBreakpointCreatedEvent(bkpt.getMIBreakpoint().getNumber()));
+ } catch (CDIException e) {
+ if (!deferred) {
+ throw e;
+ } else {
+ Session session = (Session)getSession();
+ ICDISharedLibraryManager sharedMgr = session.getSharedLibraryManager();
+ if (sharedMgr instanceof SharedLibraryManager) {
+ SharedLibraryManager mgr = (SharedLibraryManager)sharedMgr;
+ if (mgr.isDeferredBreakpoint()) {
+ deferredList.add(bkpt);
+ } else {
+ throw e;
+ }
+ }
+ }
+ }
+ return bkpt;
+ }
+
+ MIBreakInsert createMIBreakInsert(Breakpoint bkpt) throws CDIException {
+ boolean hardware = bkpt.isHardware();
+ boolean temporary = bkpt.isTemporary();
String exprCond = null;
int ignoreCount = 0;
StringBuffer line = new StringBuffer();
- if (condition != null) {
+
+ if (bkpt.getCondition() != null) {
+ ICDICondition condition = bkpt.getCondition();
exprCond = condition.getExpression();
ignoreCount = condition.getIgnoreCount();
}
- if (location != null) {
+ if (bkpt.getLocation() != null) {
+ ICDILocation location = bkpt.getLocation();
String file = location.getFile();
String function = location.getFunction();
if (file != null && file.length() > 0) {
@@ -406,13 +463,15 @@
line.append('*').append(location.getAddress());
}
}
+ Session session = (Session)getSession();
+ CommandFactory factory = session.getMISession().getCommandFactory();
+ return factory.createMIBreakInsert(temporary, hardware, exprCond, ignoreCount, line.toString());
+ }
+ public void setLocationBreakpoint (Breakpoint bkpt) throws CDIException {
Session session = (Session)getSession();
boolean state = suspendInferior(session.getCurrentTarget());
- CommandFactory factory = session.getMISession().getCommandFactory();
- MIBreakInsert breakInsert =
- factory.createMIBreakInsert( temporary, hardware, exprCond,
- ignoreCount, line.toString());
+ MIBreakInsert breakInsert = createMIBreakInsert(bkpt);
MIBreakpoint[] points = null;
try {
session.getMISession().postCommand(breakInsert);
@@ -429,13 +488,8 @@
} finally {
resumeInferior(session.getCurrentTarget(), state);
}
- Breakpoint bkpt = new Breakpoint(this, points[0]);
- breakList.add(bkpt);
- // Fire a created Event.
- MISession mi = session.getMISession();
- mi.fireEvent(new MIBreakpointCreatedEvent(bkpt.getMIBreakpoint().getNumber()));
- return bkpt;
+ bkpt.setMIBreakpoint(points[0]);
}
/**
Index: src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java,v
retrieving revision 1.40
diff -u -r1.40 EventManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java 25 Apr 2003 20:50:40 -0000 1.40
+++ src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java 18 Oct 2003 01:19:06 -0000
@@ -23,7 +23,12 @@
import org.eclipse.cdt.debug.core.cdi.ICDIVariableManager;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
+import org.eclipse.cdt.debug.mi.core.MIException;
+import org.eclipse.cdt.debug.mi.core.MISession;
import org.eclipse.cdt.debug.mi.core.cdi.event.ChangedEvent;
import org.eclipse.cdt.debug.mi.core.cdi.event.CreatedEvent;
import org.eclipse.cdt.debug.mi.core.cdi.event.DestroyedEvent;
@@ -32,8 +37,17 @@
import org.eclipse.cdt.debug.mi.core.cdi.event.MemoryChangedEvent;
import org.eclipse.cdt.debug.mi.core.cdi.event.ResumedEvent;
import org.eclipse.cdt.debug.mi.core.cdi.event.SuspendedEvent;
+import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint;
import org.eclipse.cdt.debug.mi.core.cdi.model.MemoryBlock;
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
+import org.eclipse.cdt.debug.mi.core.cdi.model.Thread;
+import org.eclipse.cdt.debug.mi.core.command.Command;
+import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
+import org.eclipse.cdt.debug.mi.core.command.MIExecContinue;
+import org.eclipse.cdt.debug.mi.core.command.MIExecFinish;
+import org.eclipse.cdt.debug.mi.core.command.MIStackInfoDepth;
+import org.eclipse.cdt.debug.mi.core.command.MIStackSelectFrame;
+import org.eclipse.cdt.debug.mi.core.command.MIThreadSelect;
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointChangedEvent;
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointCreatedEvent;
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointDeletedEvent;
@@ -52,6 +66,7 @@
import org.eclipse.cdt.debug.mi.core.event.MIRunningEvent;
import org.eclipse.cdt.debug.mi.core.event.MISharedLibChangedEvent;
import org.eclipse.cdt.debug.mi.core.event.MISharedLibCreatedEvent;
+import org.eclipse.cdt.debug.mi.core.event.MISharedLibEvent;
import org.eclipse.cdt.debug.mi.core.event.MISharedLibUnloadedEvent;
import org.eclipse.cdt.debug.mi.core.event.MISignalChangedEvent;
import org.eclipse.cdt.debug.mi.core.event.MIStoppedEvent;
@@ -60,6 +75,8 @@
import org.eclipse.cdt.debug.mi.core.event.MIVarChangedEvent;
import org.eclipse.cdt.debug.mi.core.event.MIVarCreatedEvent;
import org.eclipse.cdt.debug.mi.core.event.MIVarDeletedEvent;
+import org.eclipse.cdt.debug.mi.core.output.MIInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIStackInfoDepthInfo;
/**
*/
@@ -67,6 +84,8 @@
List list = Collections.synchronizedList(new ArrayList(1));
List tokenList = new ArrayList(1);
+ MIRunningEvent lastRunningEvent;
+ Command lastUserCommand = null;
/**
* Process the event from MI, do any state work on the CDI,
@@ -80,10 +99,12 @@
if (ignoreEventToken(miEvent.getToken())) {
// Ignore the event if it is on the ignore list.
} else if (miEvent instanceof MIStoppedEvent) {
- processSuspendedEvent((MIStoppedEvent)miEvent);
- cdiList.add(new SuspendedEvent(session, miEvent));
+ if (processSuspendedEvent((MIStoppedEvent)miEvent)) {
+ cdiList.add(new SuspendedEvent(session, miEvent));
+ }
} else if (miEvent instanceof MIRunningEvent) {
- cdiList.add(new ResumedEvent(session, (MIRunningEvent)miEvent));
+ if (processRunningEvent((MIRunningEvent)miEvent))
+ cdiList.add(new ResumedEvent(session, (MIRunningEvent)miEvent));
} else if (miEvent instanceof MIChangedEvent) {
if (miEvent instanceof MIVarChangedEvent) {
cdiList.add(new ChangedEvent(session, (MIVarChangedEvent)miEvent));
@@ -238,24 +259,36 @@
* Alse the variable and the memory needs to be updated and events
* fired for changes.
*/
- void processSuspendedEvent(MIStoppedEvent stopped) {
+ boolean processSuspendedEvent(MIStoppedEvent stopped) {
Session session = (Session)getSession();
ICDITarget currentTarget = session.getCurrentTarget();
- // Set the current thread.
+
+ if (processSharedLibEvent(stopped)) {
+ // Event was consumed by the shared lib processing bailout
+ return false;
+ }
+
int threadId = threadId = stopped.getThreadId();
if (currentTarget instanceof Target) {
- ((Target)currentTarget).updateState(threadId);
+ Target cTarget = (Target)currentTarget;
+ cTarget.updateState(threadId);
+ try {
+ cTarget.getCurrentThread().getCurrentStackFrame();
+ } catch (CDIException e1) {
+ //e1.printStackTrace();
+ }
}
+
// Update the managers.
// For the Variable/Expression Managers call only the updateManager.
ICDIVariableManager varMgr = session.getVariableManager();
ICDIExpressionManager expMgr = session.getExpressionManager();
ICDIRegisterManager regMgr = session.getRegisterManager();
ICDIMemoryManager memMgr = session.getMemoryManager();
- ICDISharedLibraryManager libMgr = session.getSharedLibraryManager();
ICDIBreakpointManager bpMgr = session.getBreakpointManager();
ICDISignalManager sigMgr = session.getSignalManager();
ICDISourceManager srcMgr = session.getSourceManager();
+ ICDISharedLibraryManager libMgr = session.getSharedLibraryManager();
try {
if (varMgr.isAutoUpdate()) {
varMgr.update();
@@ -269,29 +302,191 @@
if (memMgr.isAutoUpdate()) {
memMgr.update();
}
- if (libMgr.isAutoUpdate()) {
- libMgr.update();
- }
if (bpMgr.isAutoUpdate()) {
bpMgr.update();
}
if (sigMgr.isAutoUpdate()) {
sigMgr.update();
}
+ if (libMgr.isAutoUpdate()) {
+ libMgr.update();
+ }
if (srcMgr.isAutoUpdate()) {
srcMgr.update();
}
} catch (CDIException e) {
//System.out.println(e);
}
+ return true;
+ }
+
+ /**
+ * If the deferredBreakpoint processing is set
+ * catch the shared-lib-event go to the last known
+ * stackframe and try to finish.
+ * Save the last user command and issue it again.
+ * @param stopped
+ * @return
+ */
+ boolean processSharedLibEvent(MIStoppedEvent stopped) {
+ Session session = (Session)getSession();
+ MISession mi = session.getMISession();
+
+ ICDITarget currentTarget = session.getCurrentTarget();
+ ICDISharedLibraryManager libMgr = session.getSharedLibraryManager();
+ SharedLibraryManager mgr = null;
+
+ if (libMgr instanceof SharedLibraryManager) {
+ mgr = (SharedLibraryManager)libMgr;
+ }
+
+ if (mgr !=null && mgr.isDeferredBreakpoint()) {
+ if (stopped instanceof MISharedLibEvent) {
+ // Check if we have a new library loaded
+ List eventList = null;
+ try {
+ eventList = mgr.updateState();
+ } catch (CDIException e3) {
+ eventList = Collections.EMPTY_LIST;
+ }
+ // A new Libraries loaded, try to set the breakpoints.
+ if (eventList.size() > 0) {
+ boolean breakpointSet = false;
+ ICDIBreakpointManager manager = session.getBreakpointManager();
+ if (manager instanceof BreakpointManager) {
+ BreakpointManager bpMgr = (BreakpointManager)manager;
+ ICDIBreakpoint bpoints[] = null;
+ try {
+ bpoints = bpMgr.getDeferredBreakpoints();
+ } catch (CDIException e) {
+ bpoints = new ICDIBreakpoint[0];
+ }
+ for (int i = 0; i < bpoints.length; i++) {
+ if (bpoints[i] instanceof Breakpoint) {
+ Breakpoint bkpt = (Breakpoint)bpoints[i];
+ try {
+ bpMgr.setLocationBreakpoint(bkpt);
+ bpMgr.deleteFromDeferredList(bkpt);
+ bpMgr.addToBreakpointList(bkpt);
+ eventList.add(new MIBreakpointCreatedEvent(bkpt.getMIBreakpoint().getNumber()));
+ } catch (CDIException e) {
+ }
+ }
+ }
+ }
+ MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]);
+ mi.fireEvents(events);
+ }
+ CommandFactory factory = mi.getCommandFactory();
+ int type = (lastRunningEvent == null) ? MIRunningEvent.CONTINUE : lastRunningEvent.getType();
+ if (lastUserCommand == null) {
+ switch (type) {
+ case MIRunningEvent.NEXT:
+ lastUserCommand = factory.createMIExecNext();
+ break;
+ case MIRunningEvent.NEXTI:
+ lastUserCommand = factory.createMIExecNextInstruction();
+ break;
+ case MIRunningEvent.STEP:
+ lastUserCommand = factory.createMIExecStep();
+ break;
+ case MIRunningEvent.STEPI:
+ lastUserCommand = factory.createMIExecStepInstruction();
+ break;
+ case MIRunningEvent.FINISH:
+ lastUserCommand = factory.createMIExecFinish();
+ break;
+ case MIRunningEvent.RETURN:
+ lastUserCommand = factory.createMIExecReturn();
+ break;
+ case MIRunningEvent.CONTINUE: {
+ MIExecContinue cont = factory.createMIExecContinue();
+ try {
+ mi.postCommand(cont);
+ MIInfo info = cont.getMIInfo();
+ if (info == null) {
+ // throw new CDIException("Target is not responding");
+ }
+ } catch (MIException e) {
+ // throw new MI2CDIException(e);
+ }
+ return true; // for the continue bailout early no need to the stuff below
+ }
+ }
+ }
+
+ int miLevel = 0;
+ int tid = 0;
+ ICDIThread currentThread = null;
+ try {
+ currentThread = currentTarget.getCurrentThread();
+ } catch (CDIException e1) {
+ }
+ if (currentThread instanceof Thread) {
+ tid = ((Thread)currentThread).getId();
+ }
+ ICDIStackFrame frame = null;
+ try {
+ frame = currentThread.getCurrentStackFrame();
+ } catch (CDIException e2) {
+ }
+ int count = 0;
+ try {
+ MIStackInfoDepth depth = factory.createMIStackInfoDepth();
+ mi.postCommand(depth);
+ MIStackInfoDepthInfo info = depth.getMIStackInfoDepthInfo();
+ if (info == null) {
+ //throw new CDIException("No answer");
+ }
+ count = info.getDepth();
+ } catch (MIException e) {
+ //throw new MI2CDIException(e);
+ //System.out.println(e);
+ }
+ if (frame != null) {
+ // Fortunately the ICDIStackFrame store the level
+ // in ascending level the higher the stack the higher the level
+ // GDB does the opposite the highest stack is 0.
+ // This allow us to do some calculation, in figure out the
+ // level of the old stack. The -1 is because gdb level is zero-based
+ miLevel = count - frame.getLevel() - 1;
+ }
+ if (tid > 0) {
+ MIThreadSelect selectThread = factory.createMIThreadSelect(tid);
+ try {
+ mi.postCommand(selectThread);
+ } catch (MIException e) {
+ }
+ }
+ if (miLevel > 0) {
+ MIStackSelectFrame selectFrame = factory.createMIStackSelectFrame(miLevel);
+ MIExecFinish finish = factory.createMIExecFinish();
+ try {
+ mi.postCommand(selectFrame);
+ mi.postCommand(finish);
+ } catch (MIException e) {
+ }
+ }
+ return true;
+ } else if (lastUserCommand != null) {
+ Command cmd = lastUserCommand;
+ lastUserCommand = null;
+ try {
+ mi.postCommand(cmd);
+ } catch (MIException e) {
+ }
+ return true;
+ }
+ }
+ return false;
}
/**
* Do any processing of before a running event.
*/
- void processRunningEvent() {
- //Target target = getCSession().getCTarget();
- //target.clearState();
+ boolean processRunningEvent(MIRunningEvent running) {
+ lastRunningEvent = running;
+ return true;
}
Index: src/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java,v
retrieving revision 1.13
diff -u -r1.13 SharedLibraryManager.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java 29 Aug 2003 20:50:45 -0000 1.13
+++ src/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java 18 Oct 2003 01:19:06 -0000
@@ -7,6 +7,7 @@
package org.eclipse.cdt.debug.mi.core.cdi;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.cdt.debug.core.cdi.CDIException;
@@ -41,6 +42,7 @@
List sharedList;
boolean autoupdate;
+ boolean isDeferred;
public SharedLibraryManager (Session session) {
super(session);
@@ -71,13 +73,21 @@
*/
public void update() throws CDIException {
Session session = (Session)getSession();
+ MISession mi = session.getMISession();
+ List eventList = updateState();
+ MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]);
+ mi.fireEvents(events);
+ }
+
+ public List updateState() throws CDIException {
+ Session session = (Session)getSession();
ICDIConfiguration conf = session.getConfiguration();
if (!conf.supportsSharedLibrary()) {
- return; // Bail out early;
+ return Collections.EMPTY_LIST; // Bail out early;
}
MIShared[] miLibs = getMIShareds();
- List eventList = new ArrayList(miLibs.length);
+ ArrayList eventList = new ArrayList(miLibs.length);
for (int i = 0; i < miLibs.length; i++) {
ICDISharedLibrary sharedlib = getSharedLibrary(miLibs[i].getName());
if (sharedlib != null) {
@@ -107,9 +117,7 @@
eventList.add(new MISharedLibUnloadedEvent(oldlibs[i].getFileName()));
}
}
- MISession mi = session.getMISession();
- MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]);
- mi.fireEvents(events);
+ return eventList;
}
public boolean hasSharedLibChanged(ICDISharedLibrary lib, MIShared miLib) {
@@ -131,6 +139,14 @@
}
}
return null;
+ }
+
+ public void setDeferredBreakpoint (boolean set) {
+ isDeferred = set;
+ }
+
+ public boolean isDeferredBreakpoint() {
+ return isDeferred;
}
/**
Index: src/org/eclipse/cdt/debug/mi/core/cdi/event/ResumedEvent.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/event/ResumedEvent.java,v
retrieving revision 1.2
diff -u -r1.2 ResumedEvent.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/event/ResumedEvent.java 27 Jan 2003 03:09:05 -0000 1.2
+++ src/org/eclipse/cdt/debug/mi/core/cdi/event/ResumedEvent.java 18 Oct 2003 01:19:06 -0000
@@ -58,13 +58,11 @@
cdiType = ICDIResumedEvent.STEP_INTO_INSTRUCTION;
break;
+ case MIRunningEvent.RETURN:
case MIRunningEvent.FINISH:
cdiType = ICDIResumedEvent.STEP_RETURN;
break;
- //MIRunningEvent.UNTIL:
- //cdiType = ICDIResumedEvent.STEP_UNTIL;
- //break;
}
return cdiType;
}
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java,v
retrieving revision 1.4
diff -u -r1.4 Breakpoint.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java 29 Jan 2003 00:25:28 -0000 1.4
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java 18 Oct 2003 01:19:06 -0000
@@ -7,6 +7,7 @@
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager;
import org.eclipse.cdt.debug.mi.core.cdi.Condition;
@@ -21,6 +22,17 @@
ICDICondition condition;
MIBreakpoint miBreakpoint;
BreakpointManager mgr;
+ int type;
+ String tid;
+
+ public Breakpoint(BreakpointManager m, int kind, ICDILocation loc, ICDICondition cond, String threadId) {
+ super(m.getSession().getCurrentTarget());
+ mgr = m;
+ type = kind;
+ location = loc;
+ condition = cond;
+ tid = threadId;
+ }
public Breakpoint(BreakpointManager m, MIBreakpoint miBreak) {
super(m.getSession().getCurrentTarget());
@@ -39,13 +51,17 @@
condition = null;
}
+ public boolean isDeferred() {
+ return (miBreakpoint == null);
+ }
+
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#getCondition()
*/
public ICDICondition getCondition() throws CDIException {
if (condition == null) {
- condition = new Condition(miBreakpoint.getIgnoreCount(),
- miBreakpoint.getCondition());
+ if (miBreakpoint != null)
+ condition = new Condition(miBreakpoint.getIgnoreCount(), miBreakpoint.getCondition());
}
return condition;
}
@@ -54,28 +70,36 @@
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#getThreadId()
*/
public String getThreadId() throws CDIException {
- return miBreakpoint.getThreadId();
+ if (miBreakpoint != null)
+ return miBreakpoint.getThreadId();
+ return tid;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#isEnabled()
*/
public boolean isEnabled() throws CDIException {
- return miBreakpoint.isEnabled();
+ if (miBreakpoint != null)
+ return miBreakpoint.isEnabled();
+ return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#isHardware()
*/
public boolean isHardware() {
- return miBreakpoint.isHardware();
+ if (miBreakpoint != null)
+ return miBreakpoint.isHardware();
+ return (type == ICDIBreakpoint.HARDWARE);
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#isTemporary()
*/
public boolean isTemporary() {
- return miBreakpoint.isTemporary();
+ if (miBreakpoint != null)
+ return miBreakpoint.isTemporary();
+ return (type == ICDIBreakpoint.TEMPORARY);
}
/**
@@ -104,11 +128,16 @@
*/
public ICDILocation getLocation() throws CDIException {
if (location == null) {
- location = new Location (miBreakpoint.getFile(),
+ if (miBreakpoint != null)
+ location = new Location (miBreakpoint.getFile(),
miBreakpoint.getFunction(),
miBreakpoint.getLine(),
miBreakpoint.getAddress());
}
return location;
+ }
+
+ public void setLocation(ICDILocation loc) {
+ location = loc;
}
}
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java,v
retrieving revision 1.8
diff -u -r1.8 StackFrame.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java 23 May 2003 16:04:20 -0000 1.8
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java 18 Oct 2003 01:19:06 -0000
@@ -58,7 +58,7 @@
level = l;
}
- MIFrame getMIFrame() {
+ public MIFrame getMIFrame() {
return frame;
}
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java,v
retrieving revision 1.8
diff -u -r1.8 Thread.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java 6 May 2003 16:04:13 -0000 1.8
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java 18 Oct 2003 01:19:06 -0000
@@ -40,7 +40,7 @@
id = threadId;
}
- int getId() {
+ public int getId() {
return id;
}
@@ -51,6 +51,13 @@
public String toString() {
return Integer.toString(id);
+ }
+
+ public void updateState() {
+ try {
+ getCurrentStackFrame();
+ } catch (CDIException e) {
+ }
}
public ICDIStackFrame getCurrentStackFrame() throws CDIException {
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java,v
retrieving revision 1.1
diff -u -r1.1 Watchpoint.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java 9 Jan 2003 03:46:22 -0000 1.1
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java 18 Oct 2003 01:19:06 -0000
@@ -6,6 +6,7 @@
package org.eclipse.cdt.debug.mi.core.cdi.model;
import org.eclipse.cdt.debug.core.cdi.CDIException;
+import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint;
import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager;
import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint;
@@ -14,6 +15,15 @@
*/
public class Watchpoint extends Breakpoint implements ICDIWatchpoint {
+ int watchType;
+ String what;
+
+ public Watchpoint(BreakpointManager m, String expression, int type, int wType, ICDICondition cond) {
+ super(m, type, null, cond, "");
+ watchType = wType;
+ what = expression;
+ }
+
public Watchpoint(BreakpointManager m, MIBreakpoint miBreak) {
super(m, miBreak);
}
@@ -22,21 +32,30 @@
* @see org.eclipse.cdt.debug.core.cdi.ICDIWatchpoint#getWatchExpression()
*/
public String getWatchExpression() throws CDIException {
- return getMIBreakpoint().getWhat();
+ MIBreakpoint miPoint = getMIBreakpoint();
+ if (miPoint != null)
+ return getMIBreakpoint().getWhat();
+ return what;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIWatchpoint#isReadType()
*/
public boolean isReadType() {
- return getMIBreakpoint().isReadWatchpoint() || getMIBreakpoint().isAccessWatchpoint();
+ MIBreakpoint miPoint = getMIBreakpoint();
+ if (miPoint != null)
+ return getMIBreakpoint().isReadWatchpoint() || getMIBreakpoint().isAccessWatchpoint();
+ return ((watchType & ICDIWatchpoint.READ) == ICDIWatchpoint.READ);
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIWatchpoint#isWriteType()
*/
public boolean isWriteType() {
- return getMIBreakpoint().isAccessWatchpoint() || getMIBreakpoint().isWriteWatchpoint();
+ MIBreakpoint miPoint = getMIBreakpoint();
+ if (miPoint != null)
+ return getMIBreakpoint().isAccessWatchpoint() || getMIBreakpoint().isWriteWatchpoint();
+ return ((watchType & ICDIWatchpoint.WRITE) == ICDIWatchpoint.WRITE);
}
}
Index: src/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java,v
retrieving revision 1.6
diff -u -r1.6 MIRunningEvent.java
--- src/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java 26 Oct 2002 20:26:45 -0000 1.6
+++ src/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java 18 Oct 2003 01:19:07 -0000
@@ -20,6 +20,7 @@
public static final int STEPI = 4;
public static final int FINISH = 5;
public static final int UNTIL = 6;
+ public static final int RETURN = 7;
int type;
Index: src/org/eclipse/cdt/debug/mi/core/output/MIBreakpoint.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIBreakpoint.java,v
retrieving revision 1.2
diff -u -r1.2 MIBreakpoint.java
--- src/org/eclipse/cdt/debug/mi/core/output/MIBreakpoint.java 28 Jan 2003 19:54:13 -0000 1.2
+++ src/org/eclipse/cdt/debug/mi/core/output/MIBreakpoint.java 18 Oct 2003 01:19:07 -0000
@@ -72,6 +72,10 @@
return number;
}
+ public void setNumber(int num) {
+ number = num;
+ }
+
public String getType() {
return type;
}
@@ -84,7 +88,7 @@
return isWpt;
}
- public void setWatcpoint(boolean w) {
+ public void setWatchpoint(boolean w) {
isWpt = w;
}