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

Implement getAdapter and more fixes.

This commit is contained in:
Alain Magloire 2002-10-22 04:48:02 +00:00
parent dc302bdd60
commit cf2832ceab

View file

@ -7,9 +7,12 @@ package org.eclipse.cdt.debug.mi.core;
import java.util.Properties; import java.util.Properties;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.IStreamsProxy; import org.eclipse.debug.core.model.IStreamsProxy;
@ -21,32 +24,52 @@ public class GDBProcess extends PlatformObject implements IProcess {
ILaunch launch; ILaunch launch;
Properties props; Properties props;
GDBStreamsProxy streams; GDBStreamsProxy streams;
String label;
public GDBProcess(ILaunch l, MISession s) { public GDBProcess(ILaunch l, MISession s, String n) {
launch = l; launch = l;
session = s; session = s;
props = new Properties(); label = n;
} }
/** /**
* @see org.eclipse.debug.core.model.IProcess#getAttribute(String) * @see org.eclipse.debug.core.model.IProcess#getAttribute(String)
*/ */
public String getAttribute(String key) { public String getAttribute(String key) {
if (props == null) {
return null;
}
return props.getProperty(key); return props.getProperty(key);
} }
/**
* @see org.eclipse.debug.core.model.IProcess#setAttribute(String, String)
*/
public void setAttribute(String key, String value) {
if (props == null) {
props = new Properties();
}
props.setProperty(key, value);
}
/** /**
* @see org.eclipse.debug.core.model.IProcess#getExitValue() * @see org.eclipse.debug.core.model.IProcess#getExitValue()
*/ */
public int getExitValue() throws DebugException { public int getExitValue() throws DebugException {
return session.getMIProcess().exitValue(); try {
return session.getMIProcess().exitValue();
} catch (IllegalThreadStateException e) {
IStatus status = new Status(IStatus.ERROR,
MIPlugin.getUniqueIdentifier(), 1, "process not terminated", e);
throw new DebugException(status);
}
} }
/** /**
* @see org.eclipse.debug.core.model.IProcess#getLabel() * @see org.eclipse.debug.core.model.IProcess#getLabel()
*/ */
public String getLabel() { public String getLabel() {
return "GDB MI Debugger"; return label;
} }
/** /**
@ -66,17 +89,23 @@ public class GDBProcess extends PlatformObject implements IProcess {
return streams; return streams;
} }
/**
* @see org.eclipse.debug.core.model.IProcess#setAttribute(String, String)
*/
public void setAttribute(String key, String value) {
props.setProperty(key, value);
}
/** /**
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
*/ */
public Object getAdapter(Class adapter) { public Object getAdapter(Class adapter) {
if (adapter.equals(IProcess.class)) {
return this;
}
if (adapter.equals(IDebugTarget.class)) {
ILaunch launch = getLaunch();
IDebugTarget[] targets = launch.getDebugTargets();
for (int i = 0; i < targets.length; i++) {
if (this.equals(targets[i].getProcess())) {
return targets[i];
}
}
return null;
}
return super.getAdapter(adapter); return super.getAdapter(adapter);
} }
@ -84,7 +113,7 @@ public class GDBProcess extends PlatformObject implements IProcess {
* @see org.eclipse.debug.core.model.ITerminate#canTerminate() * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
*/ */
public boolean canTerminate() { public boolean canTerminate() {
return true; return !isTerminated();
} }
/** /**