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:
parent
dc302bdd60
commit
cf2832ceab
1 changed files with 41 additions and 12 deletions
|
@ -7,9 +7,12 @@ package org.eclipse.cdt.debug.mi.core;
|
|||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
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.IStreamsProxy;
|
||||
|
||||
|
@ -21,32 +24,52 @@ public class GDBProcess extends PlatformObject implements IProcess {
|
|||
ILaunch launch;
|
||||
Properties props;
|
||||
GDBStreamsProxy streams;
|
||||
String label;
|
||||
|
||||
public GDBProcess(ILaunch l, MISession s) {
|
||||
public GDBProcess(ILaunch l, MISession s, String n) {
|
||||
launch = l;
|
||||
session = s;
|
||||
props = new Properties();
|
||||
label = n;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.debug.core.model.IProcess#getAttribute(String)
|
||||
*/
|
||||
public String getAttribute(String key) {
|
||||
if (props == null) {
|
||||
return null;
|
||||
}
|
||||
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()
|
||||
*/
|
||||
public int getExitValue() throws DebugException {
|
||||
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()
|
||||
*/
|
||||
public String getLabel() {
|
||||
return "GDB MI Debugger";
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,17 +89,23 @@ public class GDBProcess extends PlatformObject implements IProcess {
|
|||
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)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -84,7 +113,7 @@ public class GDBProcess extends PlatformObject implements IProcess {
|
|||
* @see org.eclipse.debug.core.model.ITerminate#canTerminate()
|
||||
*/
|
||||
public boolean canTerminate() {
|
||||
return true;
|
||||
return !isTerminated();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue