mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
We should treat Watchpoint Trigger and Scope like two separte
events.
This commit is contained in:
parent
2b119fa9e9
commit
ba07b4e743
7 changed files with 137 additions and 27 deletions
|
@ -27,7 +27,8 @@ import org.eclipse.cdt.debug.mi.core.event.MIRunningEvent;
|
|||
import org.eclipse.cdt.debug.mi.core.event.MISignalEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MISteppingRangeEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIStoppedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointScopeEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointTriggerEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIAsyncRecord;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIConsoleStreamOutput;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIConst;
|
||||
|
@ -311,9 +312,15 @@ MIPlugin.getDefault().debugLog(line);
|
|||
}
|
||||
} else if ("watchpoint-trigger".equals(reason)) {
|
||||
if (exec != null) {
|
||||
event = new MIWatchpointEvent(exec);
|
||||
event = new MIWatchpointTriggerEvent(exec);
|
||||
} else if (rr != null) {
|
||||
event = new MIWatchpointEvent(rr);
|
||||
event = new MIWatchpointTriggerEvent(rr);
|
||||
}
|
||||
} else if ("watchpoint-scope".equals(reason)) {
|
||||
if (exec != null) {
|
||||
event = new MIWatchpointScopeEvent(exec);
|
||||
} else if (rr != null) {
|
||||
event = new MIWatchpointScopeEvent(rr);
|
||||
}
|
||||
} else if ("end-stepping-range".equals(reason)) {
|
||||
if (exec != null) {
|
||||
|
|
|
@ -27,7 +27,8 @@ import org.eclipse.cdt.debug.mi.core.event.MISteppingRangeEvent;
|
|||
import org.eclipse.cdt.debug.mi.core.event.MIStoppedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIThreadExitEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIVarChangedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointScopeEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointTriggerEvent;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -108,8 +109,11 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
|
|||
if (event instanceof MIBreakpointEvent) {
|
||||
MIBreakpointEvent breakEvent = (MIBreakpointEvent) event;
|
||||
threadId = breakEvent.getThreadId();
|
||||
} else if (event instanceof MIWatchpointEvent) {
|
||||
MIWatchpointEvent watchEvent = (MIWatchpointEvent) event;
|
||||
} else if (event instanceof MIWatchpointTriggerEvent) {
|
||||
MIWatchpointTriggerEvent watchEvent = (MIWatchpointTriggerEvent) event;
|
||||
threadId = watchEvent.getThreadId();
|
||||
} else if (event instanceof MIWatchpointScopeEvent) {
|
||||
MIWatchpointScopeEvent watchEvent = (MIWatchpointScopeEvent) event;
|
||||
threadId = watchEvent.getThreadId();
|
||||
} else if (event instanceof MISteppingRangeEvent) {
|
||||
MISteppingRangeEvent rangeEvent = (MISteppingRangeEvent) event;
|
||||
|
|
|
@ -5,18 +5,17 @@
|
|||
*/
|
||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDISessionObject;
|
||||
import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MILocationReachedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MISignalEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MISteppingRangeEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointScopeEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointTriggerEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -34,8 +33,10 @@ public class SuspendedEvent implements ICDISuspendedEvent {
|
|||
public ICDISessionObject getReason() {
|
||||
if (event instanceof MIBreakpointEvent) {
|
||||
return new BreakpointHit(session, (MIBreakpointEvent)event);
|
||||
} else if (event instanceof MIWatchpointEvent) {
|
||||
return new WatchpointTrigger(session, (MIWatchpointEvent)event);
|
||||
} else if (event instanceof MIWatchpointTriggerEvent) {
|
||||
return new WatchpointTrigger(session, (MIWatchpointTriggerEvent)event);
|
||||
} else if (event instanceof MIWatchpointScopeEvent) {
|
||||
return new WatchpointScope(session, (MIWatchpointScopeEvent)event);
|
||||
} else if (event instanceof MISteppingRangeEvent) {
|
||||
return new EndSteppingRange(session);
|
||||
} else if (event instanceof MISignalEvent) {
|
||||
|
|
|
@ -7,21 +7,15 @@ package org.eclipse.cdt.debug.mi.core.cdi;
|
|||
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointScope;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointScopeEvent;
|
||||
|
||||
/**
|
||||
* @author alain
|
||||
*
|
||||
* To change this generated comment edit the template variable "typecomment":
|
||||
* Window>Preferences>Java>Templates.
|
||||
* To enable and disable the creation of type comments go to
|
||||
* Window>Preferences>Java>Code Generation.
|
||||
*/
|
||||
public class WatchpointScope extends SessionObject implements ICDIWatchpointScope {
|
||||
|
||||
MIWatchpointEvent watchEvent;
|
||||
MIWatchpointScopeEvent watchEvent;
|
||||
|
||||
public WatchpointScope(CSession session, MIWatchpointEvent e) {
|
||||
public WatchpointScope(CSession session, MIWatchpointScopeEvent e) {
|
||||
super(session);
|
||||
watchEvent = e;
|
||||
}
|
||||
|
|
|
@ -6,14 +6,18 @@
|
|||
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointTrigger;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointTriggerEvent;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class WatchpointTrigger extends WatchpointScope implements ICDIWatchpointTrigger {
|
||||
public class WatchpointTrigger extends SessionObject implements ICDIWatchpointTrigger {
|
||||
|
||||
public WatchpointTrigger(CSession session, MIWatchpointEvent e) {
|
||||
super(session, e);
|
||||
MIWatchpointTriggerEvent watchEvent;
|
||||
|
||||
public WatchpointTrigger(CSession session, MIWatchpointTriggerEvent e) {
|
||||
super(session);
|
||||
watchEvent = e;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,4 +34,17 @@ public class WatchpointTrigger extends WatchpointScope implements ICDIWatchpoint
|
|||
return watchEvent.getOldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIWatchpointTrigger#getWatchpoint()
|
||||
*/
|
||||
public ICDIWatchpoint getWatchpoint() {
|
||||
int number = watchEvent.getNumber();
|
||||
// Ask the breakpointManager for the breakpoint
|
||||
BreakpointManager mgr = (BreakpointManager)getCSession().getBreakpointManager();
|
||||
// We need to return the same object as the reason.
|
||||
Watchpoint point = mgr.getWatchpoint(number);
|
||||
// FIXME: if point ==null ??? Create a new breakpoint ?
|
||||
return point;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.mi.core.event;
|
||||
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIConst;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIFrame;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIResult;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MITuple;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIValue;
|
||||
|
||||
/**
|
||||
* *stopped,reason="watchpoint-trigger",wpt={number="2",exp="i"},value={old="0",new="1"},thread-id="0",frame={addr="0x08048534",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbffff18c"}],file="hello.c",line="10"}
|
||||
*
|
||||
*/
|
||||
public class MIWatchpointScopeEvent extends MIStoppedEvent {
|
||||
|
||||
int number;
|
||||
int threadId;
|
||||
MIFrame frame;
|
||||
|
||||
MIExecAsyncOutput exec;
|
||||
MIResultRecord rr;
|
||||
|
||||
public MIWatchpointScopeEvent(MIExecAsyncOutput record) {
|
||||
exec = record;
|
||||
parse();
|
||||
}
|
||||
|
||||
public MIWatchpointScopeEvent(MIResultRecord record) {
|
||||
rr = record;
|
||||
parse();
|
||||
}
|
||||
|
||||
public int getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public int getThreadId() {
|
||||
return threadId;
|
||||
}
|
||||
|
||||
public MIFrame getFrame() {
|
||||
return frame;
|
||||
}
|
||||
|
||||
void parse() {
|
||||
MIResult[] results = null;
|
||||
if (exec != null) {
|
||||
results = exec.getMIResults();
|
||||
} else if (rr != null) {
|
||||
results = rr.getMIResults();
|
||||
}
|
||||
if (results != null) {
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
String var = results[i].getVariable();
|
||||
MIValue value = results[i].getMIValue();
|
||||
|
||||
if (var.equals("wpnum")) {
|
||||
if (value instanceof MIConst) {
|
||||
String str = ((MIConst) value).getString();
|
||||
try {
|
||||
number = Integer.parseInt(str.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
} else if (var.equals("thread-id")) {
|
||||
if (value instanceof MIConst) {
|
||||
String str = ((MIConst) value).getString();
|
||||
try {
|
||||
threadId = Integer.parseInt(str.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
} else if (var.equals("frame")) {
|
||||
if (value instanceof MITuple) {
|
||||
frame = new MIFrame((MITuple) value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIValue;
|
|||
* *stopped,reason="watchpoint-trigger",wpt={number="2",exp="i"},value={old="0",new="1"},thread-id="0",frame={addr="0x08048534",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbffff18c"}],file="hello.c",line="10"}
|
||||
*
|
||||
*/
|
||||
public class MIWatchpointEvent extends MIStoppedEvent {
|
||||
public class MIWatchpointTriggerEvent extends MIStoppedEvent {
|
||||
|
||||
int number;
|
||||
String exp = "";
|
||||
|
@ -29,12 +29,12 @@ public class MIWatchpointEvent extends MIStoppedEvent {
|
|||
MIExecAsyncOutput exec;
|
||||
MIResultRecord rr;
|
||||
|
||||
public MIWatchpointEvent(MIExecAsyncOutput record) {
|
||||
public MIWatchpointTriggerEvent(MIExecAsyncOutput record) {
|
||||
exec = record;
|
||||
parse();
|
||||
}
|
||||
|
||||
public MIWatchpointEvent(MIResultRecord record) {
|
||||
public MIWatchpointTriggerEvent(MIResultRecord record) {
|
||||
rr = record;
|
||||
parse();
|
||||
}
|
Loading…
Add table
Reference in a new issue