1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

implementing CDI.

This commit is contained in:
Alain Magloire 2002-08-09 04:14:33 +00:00
parent e49c3ff3d6
commit fa45945774
14 changed files with 385 additions and 115 deletions

View file

@ -0,0 +1,102 @@
package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICCondition;
import org.eclipse.cdt.debug.core.cdi.ICLocation;
import org.eclipse.cdt.debug.core.cdi.ICLocationBreakpoint;
import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint;
/**
* @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 Breakpoint extends SessionObject implements ICLocationBreakpoint {
int type;
ICLocation location;
ICCondition condition;
String threadId = "";
boolean enabled = false;
MIBreakPoint miBreakPoint;
public Breakpoint(BreakpointManager mgr, MIBreakPoint miBreak) {
super((Session)mgr.getSession());
miBreakPoint = miBreak;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#getCondition()
*/
public ICCondition getCondition() throws CDIException {
return condition;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#getThreadId()
*/
public String getThreadId() throws CDIException {
return threadId;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isEnabled()
*/
public boolean isEnabled() throws CDIException {
return enabled;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isHardware()
*/
public boolean isHardware() {
return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isTemporary()
*/
public boolean isTemporary() {
return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#setCondition(ICCondition)
*/
public void setCondition(ICCondition condition) throws CDIException {
this.condition = condition;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#setEnabled(boolean)
*/
public void setEnabled(boolean enable) throws CDIException {
/*
if (enable == false && enabled == true) {
if (miBreak != null) {
MICommand cmd = new MIBreakDisable(miBreak.getNumber());
}
} else if (enable == true && enabled == false) {
if (miBreak != null) {
MICommand cmd = new MIBreakEnable(miBreak.getNumber());
} else {
MIBreakInsert cmd = new MIBreakInsert();
miSession.postCommand(cmd);
miBreak = cmd.getBreakInsertInfo();
}
}
enabled = enable;
*/
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICLocationBreakpoint#getLocation()
*/
public ICLocation getLocation() throws CDIException {
return location;
}
}

View file

@ -5,6 +5,9 @@
*/
package org.eclipse.cdt.debug.mi.core.cdi;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICBreakpoint;
import org.eclipse.cdt.debug.core.cdi.ICBreakpointManager;
@ -13,27 +16,30 @@ import org.eclipse.cdt.debug.core.cdi.ICCatchpoint;
import org.eclipse.cdt.debug.core.cdi.ICCondition;
import org.eclipse.cdt.debug.core.cdi.ICLocation;
import org.eclipse.cdt.debug.core.cdi.ICLocationBreakpoint;
import org.eclipse.cdt.debug.core.cdi.ICSession;
import org.eclipse.cdt.debug.core.cdi.ICWatchpoint;
import org.eclipse.cdt.debug.mi.core.MISession;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIBreakInsert;
import org.eclipse.cdt.debug.mi.core.output.MIBreakInsertInfo;
import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint;
/**
*
*/
public class BreakpointManager implements ICBreakpointManager {
public class BreakpointManager extends SessionObject implements ICBreakpointManager {
MISession session;
ICBreakpoint[] breakpoints = new ICBreakpoint[0];
List breakList;
public BreakpointManager(MISession s) {
session = s;
public BreakpointManager(Session session) {
super(session);
breakList = new ArrayList(1);
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#deleteAllBreakpoints()
*/
public void deleteAllBreakpoints() throws CDIException {
deleteBreakpoints(breakpoints);
deleteBreakpoints(getBreakpoints());
}
/**
@ -46,23 +52,14 @@ public class BreakpointManager implements ICBreakpointManager {
/**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#deleteBreakpoints(ICBreakpoint[])
*/
public void deleteBreakpoints(ICBreakpoint[] breakpoints)
throws CDIException {
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#getBreakpoint(String)
*/
public ICBreakpoint getBreakpoint(String breakpointId)
throws CDIException {
return null;
public void deleteBreakpoints(ICBreakpoint[] breakpoints) throws CDIException {
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#getBreakpoints()
*/
public ICBreakpoint[] getBreakpoints() throws CDIException {
return breakpoints;
return (ICBreakpoint[])breakList.toArray(new ICBreakpoint[breakList.size()]);
}
/**
@ -88,7 +85,45 @@ public class BreakpointManager implements ICBreakpointManager {
boolean enabled,
String threadId)
throws CDIException {
return null;
boolean hardware = type == ICBreakpoint.HARDWARE;
boolean temporary = type == ICBreakpoint.TEMPORARY;
String exprCond = condition.getExpression();
int ignoreCount = condition.getIgnoreCount();
String line = "";
if (location.getFile() != null) {
line = location.getFile().getPath() + ":";
if (location.getFunction() != null) {
line += location.getFunction();
} else {
line += Integer.toString(location.getLineNumber());
}
} else {
line = "*" + Long.toString(location.getAddress());
}
Session s = (Session)getSession();
CommandFactory factory = s.getMISession().getCommandFactory();
MIBreakInsert breakInsert = factory.createMIBreakInsert(temporary, hardware,
exprCond, ignoreCount, line);
MIBreakPoint[] points = null;
try {
MIBreakInsertInfo info = breakInsert.getMIBreakInsertInfo();
if (info == null) {
//throw new CDIException();
}
points = info.getBreakPoints();
if (points == null || points.length == 0) {
//throw new CDIException();
}
} catch (MIException e) {
// throw new CDIException(e);
}
Breakpoint bkpt= new Breakpoint(this, points[0]);
breakList.add(bkpt);
return bkpt;
}
/**
@ -103,11 +138,4 @@ public class BreakpointManager implements ICBreakpointManager {
throws CDIException {
return null;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICSessionObject#getSession()
*/
public ICSession getSession() {
return null;
}
}

View file

@ -18,7 +18,6 @@ import org.eclipse.cdt.debug.core.cdi.model.ICRegisterGroup;
import org.eclipse.cdt.debug.core.cdi.model.ICSharedLibrary;
import org.eclipse.cdt.debug.core.cdi.model.ICTarget;
import org.eclipse.cdt.debug.core.cdi.model.ICThread;
import org.eclipse.cdt.debug.mi.core.MISession;
/**
* @author alain
@ -28,12 +27,10 @@ import org.eclipse.cdt.debug.mi.core.MISession;
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class CTarget implements ICTarget {
public class CTarget extends SessionObject implements ICTarget {
MISession session;
public CTarget(MISession s) {
session = s;
public CTarget(Session session) {
super(session);
}
/**
@ -106,13 +103,6 @@ public class CTarget implements ICTarget {
return null;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#getSession()
*/
public ICSession getSession() {
return null;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#getSharedLibraries()
*/

View file

@ -0,0 +1,99 @@
package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration;
/**
* @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 DebugConfiguration implements ICDebugConfiguration {
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration#supportsBreakpoints()
*/
public boolean supportsBreakpoints() {
return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration#supportsDisconnect()
*/
public boolean supportsDisconnect() {
return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration#supportsExpressionEvaluation()
*/
public boolean supportsExpressionEvaluation() {
return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration#supportsInstructionStepping()
*/
public boolean supportsInstructionStepping() {
return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration#supportsMemoryModification()
*/
public boolean supportsMemoryModification() {
return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration#supportsMemoryRetrieval()
*/
public boolean supportsMemoryRetrieval() {
return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration#supportsRegisterModification()
*/
public boolean supportsRegisterModification() {
return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration#supportsRegisters()
*/
public boolean supportsRegisters() {
return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration#supportsRestart()
*/
public boolean supportsRestart() {
return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration#supportsStepping()
*/
public boolean supportsStepping() {
return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration#supportsSuspendResume()
*/
public boolean supportsSuspendResume() {
return false;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration#supportsTerminate()
*/
public boolean supportsTerminate() {
return false;
}
}

View file

@ -8,7 +8,6 @@ package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.ICEventManager;
import org.eclipse.cdt.debug.core.cdi.ICSession;
import org.eclipse.cdt.debug.core.cdi.event.ICEventListener;
import org.eclipse.cdt.debug.mi.core.MISession;
/**
* @author alain
@ -18,12 +17,10 @@ import org.eclipse.cdt.debug.mi.core.MISession;
* To enable and disable the creation oEventManagerts go to
* Window>Preferences>Java>Code Generation.
*/
public class EventManager implements ICEventManager {
public class EventManager extends SessionObject implements ICEventManager {
MISession session;
public EventManager(MISession s) {
session = s;
public EventManager(Session session) {
super(session);
}
/**
@ -38,11 +35,4 @@ public class EventManager implements ICEventManager {
public void removeEventListener(ICEventListener listener) {
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICSessionObject#getSession()
*/
public ICSession getSession() {
return null;
}
}

View file

@ -9,7 +9,6 @@ import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICExpressionManager;
import org.eclipse.cdt.debug.core.cdi.ICSession;
import org.eclipse.cdt.debug.core.cdi.model.ICExpression;
import org.eclipse.cdt.debug.mi.core.MISession;
/**
* @author alain
@ -19,12 +18,10 @@ import org.eclipse.cdt.debug.mi.core.MISession;
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class ExpressionManager implements ICExpressionManager {
public class ExpressionManager extends SessionObject implements ICExpressionManager {
MISession session;
public ExpressionManager(MISession s) {
session = s;
public ExpressionManager(Session session) {
super(session);
}
/**
@ -61,11 +58,4 @@ public class ExpressionManager implements ICExpressionManager {
throws CDIException {
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICSessionObject#getSession()
*/
public ICSession getSession() {
return null;
}
}

View file

@ -9,7 +9,6 @@ import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICMemoryManager;
import org.eclipse.cdt.debug.core.cdi.ICSession;
import org.eclipse.cdt.debug.core.cdi.model.ICMemoryBlock;
import org.eclipse.cdt.debug.mi.core.MISession;
/**
* @author alain
@ -19,12 +18,10 @@ import org.eclipse.cdt.debug.mi.core.MISession;
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class MemoryManager implements ICMemoryManager {
public class MemoryManager extends SessionObject implements ICMemoryManager {
MISession session;
public MemoryManager(MISession s) {
session = s;
public MemoryManager(Session session) {
super(session);
}
/**
@ -66,11 +63,4 @@ public class MemoryManager implements ICMemoryManager {
throws CDIException {
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICSessionObject#getSession()
*/
public ICSession getSession() {
return null;
}
}

View file

@ -0,0 +1,35 @@
package org.eclipse.cdt.debug.mi.core.cdi;
import java.util.Properties;
import org.eclipse.cdt.debug.core.cdi.ICRuntimeOptions;
/**
* @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 RuntimeOptions implements ICRuntimeOptions {
/**
* @see org.eclipse.cdt.debug.core.cdi.ICRuntimeOptions#setArguments(String)
*/
public void setArguments(String args) {
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICRuntimeOptions#setEnvironment(Properties)
*/
public void setEnvironment(Properties props) {
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICRuntimeOptions#setWorkingDirectory(String)
*/
public void setWorkingDirectory(String wd) {
}
}

View file

@ -14,6 +14,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDebugConfiguration;
import org.eclipse.cdt.debug.core.cdi.ICEventManager;
import org.eclipse.cdt.debug.core.cdi.ICExpressionManager;
import org.eclipse.cdt.debug.core.cdi.ICMemoryManager;
import org.eclipse.cdt.debug.core.cdi.ICRuntimeOptions;
import org.eclipse.cdt.debug.core.cdi.ICSession;
import org.eclipse.cdt.debug.core.cdi.ICSignalManager;
import org.eclipse.cdt.debug.core.cdi.ICSourceManager;
@ -23,7 +24,7 @@ import org.eclipse.cdt.debug.mi.core.MISession;
/**
* @see org.eclipse.cdt.debug.core.cdi.ICSession
*/
public class CSession implements ICSession {
public class Session implements ICSession {
Properties props;
MISession session;
@ -35,16 +36,20 @@ public class CSession implements ICSession {
SourceManager sourceManager;
CTarget ctarget;
public CSession(MISession s) {
public Session(MISession s) {
session = s;
props = new Properties();
breakpointManager = new BreakpointManager(session);
eventManager = new EventManager(session);
expressionManager = new ExpressionManager(session);
memoryManager = new MemoryManager(session);
signalManager = new SignalManager(session);
sourceManager = new SourceManager(session);
ctarget = new CTarget(session);
breakpointManager = new BreakpointManager(this);
eventManager = new EventManager(this);
expressionManager = new ExpressionManager(this);
memoryManager = new MemoryManager(this);
signalManager = new SignalManager(this);
sourceManager = new SourceManager(this);
ctarget = new CTarget(this);
}
MISession getMISession() {
return session;
}
/**
@ -128,7 +133,13 @@ public class CSession implements ICSession {
* @see org.eclipse.cdt.debug.core.cdi.ICSuration()
*/
public ICDebugConfiguration getConfiguration() {
return null;
return new DebugConfiguration();
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICSession#getRuntimeOptions()
*/
public ICRuntimeOptions getRuntimeOptions() {
return new RuntimeOptions();
}
}

View file

@ -0,0 +1,28 @@
package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.ICSession;
import org.eclipse.cdt.debug.core.cdi.ICSessionObject;
/**
* @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 SessionObject implements ICSessionObject {
Session session;
public SessionObject (Session session) {
this.session = session;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICSessionObject#getSession()
*/
public ICSession getSession() {
return session;
}
}

View file

@ -9,7 +9,6 @@ import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICSession;
import org.eclipse.cdt.debug.core.cdi.ICSignal;
import org.eclipse.cdt.debug.core.cdi.ICSignalManager;
import org.eclipse.cdt.debug.mi.core.MISession;
/**
* @author alain
@ -19,12 +18,10 @@ import org.eclipse.cdt.debug.mi.core.MISession;
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class SignalManager implements ICSignalManager {
public class SignalManager extends SessionObject implements ICSignalManager {
MISession session;
public SignalManager(MISession s) {
session = s;
public SignalManager(Session session) {
super(session);
}
/**
@ -34,11 +31,4 @@ public class SignalManager implements ICSignalManager {
return null;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICSessionObject#getSession()
*/
public ICSession getSession() {
return null;
}
}

View file

@ -10,7 +10,6 @@ import java.io.File;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICSession;
import org.eclipse.cdt.debug.core.cdi.ICSourceManager;
import org.eclipse.cdt.debug.mi.core.MISession;
/**
* @author alain
@ -20,12 +19,10 @@ import org.eclipse.cdt.debug.mi.core.MISession;
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class SourceManager implements ICSourceManager {
public class SourceManager extends SessionObject implements ICSourceManager {
MISession session;
public SourceManager(MISession s) {
session = s;
public SourceManager(Session session) {
super(session);
}
/**
@ -47,11 +44,4 @@ public class SourceManager implements ICSourceManager {
public void set(File[] directories) throws CDIException {
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICSessionObject#getSession()
*/
public ICSession getSession() {
return null;
}
}

View file

@ -103,6 +103,10 @@ public class MIBreakInsert extends MICommand
setParameters(new String[]{line});
}
public MIBreakInsertInfo getMIBreakInsertInfo() throws MIException {
return (MIBreakInsertInfo)getMIInfo();
}
public MIInfo getMIInfo() throws MIException {
MIInfo info = null;
MIOutput out = getMIOutput();

View file

@ -7,6 +7,12 @@ package org.eclipse.cdt.debug.mi.core.output;
/**
* Contain info about the GDB/MI breakpoint info.
* -break-insert -t -c 2 main
* ^done,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",cond="2",times="0"}
* (gdb)
* -break-insert -h -i 2 main
* ^done,bkpt={number="2",type="hw breakpoint",disp="keep",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",times="0",ignore="2"}
* (gdb)
*/
public class MIBreakPoint {
@ -20,6 +26,8 @@ public class MIBreakPoint {
int line;
int times;
String what = "";
String cond = "";
int ignore;
public MIBreakPoint(MITuple tuple) {
parse(tuple);
@ -65,6 +73,14 @@ public class MIBreakPoint {
return what;
}
public int getIgnoreCount() {
return ignore;
}
public String getCondition() {
return cond;
}
void parse(MITuple tuple) {
MIResult[] results = tuple.getMIResults();
for (int i = 0; i < results.length; i++) {
@ -107,6 +123,13 @@ public class MIBreakPoint {
}
} else if (var.equals("what") || var.equals("exp")) {
what = str;
} else if (var.equals("ignore")) {
try {
ignore = Integer.parseInt(str.trim());
} catch (NumberFormatException e) {
}
} else if (var.equals("cond")) {
cond = str;
}
}
}