mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
more work to get CDI up.
This commit is contained in:
parent
8c0f56fa80
commit
3029910ef5
37 changed files with 1388 additions and 181 deletions
|
@ -4,9 +4,15 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.debug.mi.core;
|
package org.eclipse.cdt.debug.mi.core;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICSession;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.cdi.CSession;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MITargetAttach;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
import org.eclipse.core.runtime.IPluginDescriptor;
|
import org.eclipse.core.runtime.IPluginDescriptor;
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
|
|
||||||
|
@ -39,4 +45,36 @@ public class MIPlugin extends Plugin {
|
||||||
public MISession createMISession(InputStream in, OutputStream out) {
|
public MISession createMISession(InputStream in, OutputStream out) {
|
||||||
return new MISession(in, out);
|
return new MISession(in, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICSession createCSession(String program) throws IOException {
|
||||||
|
String[]args = new String[]{"gdb", "--quiet", "-i", "mi", program};
|
||||||
|
Process gdb = Runtime.getRuntime().exec(args);
|
||||||
|
MISession session = createMISession(gdb.getInputStream(), gdb.getOutputStream());
|
||||||
|
return new CSession(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICSession createCSession(String program, String core) throws IOException {
|
||||||
|
String[]args = new String[]{"gdb", "--quiet", "-i", "mi", program, core};
|
||||||
|
Process gdb = Runtime.getRuntime().exec(args);
|
||||||
|
MISession session = createMISession(gdb.getInputStream(), gdb.getOutputStream());
|
||||||
|
return new CSession(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICSession createCSession(String program, int pid) throws IOException {
|
||||||
|
String[]args = new String[]{"gdb", "--quiet", "-i", "mi", program};
|
||||||
|
Process gdb = Runtime.getRuntime().exec(args);
|
||||||
|
MISession session = createMISession(gdb.getInputStream(), gdb.getOutputStream());
|
||||||
|
try {
|
||||||
|
CommandFactory factory = session.getCommandFactory();
|
||||||
|
MITargetAttach attach = factory.createMITargetAttach(pid);
|
||||||
|
session.postCommand(attach);
|
||||||
|
MIInfo info = attach.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
throw new IOException("Failed to attach");
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new IOException("Failed to attach");
|
||||||
|
}
|
||||||
|
return new CSession(session);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,149 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.CLICommand;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIExecAbort;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIGDBShowExitCode;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIGDBShowExitCodeInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 MIProcess extends Process {
|
||||||
|
|
||||||
|
public final static int SUSPENDED = 1;
|
||||||
|
public final static int RUNNING = 2;
|
||||||
|
public final static int TERMINATED = 3;
|
||||||
|
|
||||||
|
int state = 0;
|
||||||
|
MISession session;
|
||||||
|
OutputStream out;
|
||||||
|
|
||||||
|
MIProcess(MISession mi) {
|
||||||
|
session = mi;
|
||||||
|
out = new OutputStream() {
|
||||||
|
StringBuffer buf = new StringBuffer();
|
||||||
|
public void write(int b) throws IOException {
|
||||||
|
buf.append(b);
|
||||||
|
if (b == '\n') {
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void flush() throws IOException {
|
||||||
|
CLICommand cmd = new CLICommand(buf.toString()) {
|
||||||
|
public void setToken(int token) {
|
||||||
|
// override to do nothing;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
session.postCommand(cmd);
|
||||||
|
} catch (MIException e) {
|
||||||
|
throw new IOException("no mi session");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see java.lang.Process#getOutputStream()
|
||||||
|
*/
|
||||||
|
public OutputStream getOutputStream() {
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see java.lang.Process#getInputStream()
|
||||||
|
*/
|
||||||
|
public InputStream getInputStream() {
|
||||||
|
return session.getTargetStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see java.lang.Process#getErrorStream()
|
||||||
|
*/
|
||||||
|
public InputStream getErrorStream() {
|
||||||
|
// FIXME the same as output??
|
||||||
|
return session.getTargetStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see java.lang.Process#waitFor()
|
||||||
|
*/
|
||||||
|
public int waitFor() throws InterruptedException {
|
||||||
|
if (!isTerminated()) {
|
||||||
|
synchronized (this) {
|
||||||
|
wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return exitValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see java.lang.Process#exitValue()
|
||||||
|
*/
|
||||||
|
public int exitValue() {
|
||||||
|
if (isTerminated()) {
|
||||||
|
CommandFactory factory = session.getCommandFactory();
|
||||||
|
MIGDBShowExitCode code = factory.createMIGDBShowExitCode();
|
||||||
|
try {
|
||||||
|
session.postCommand(code);
|
||||||
|
MIGDBShowExitCodeInfo info = code.getMIGDBShowExitCodeInfo();
|
||||||
|
return info.getCode();
|
||||||
|
} catch (MIException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalThreadStateException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see java.lang.Process#destroy()
|
||||||
|
*/
|
||||||
|
public void destroy() {
|
||||||
|
CommandFactory factory = session.getCommandFactory();
|
||||||
|
MIExecAbort abort = factory.createMIExecAbort();
|
||||||
|
CLICommand yes = new CLICommand("yes") {
|
||||||
|
public void setToken() { }
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
session.postCommand(abort);
|
||||||
|
session.postCommand(yes);
|
||||||
|
} catch (MIException e) {
|
||||||
|
}
|
||||||
|
// Do not wait for answer.
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean isSuspended() {
|
||||||
|
return state == SUSPENDED;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean isRunning() {
|
||||||
|
return state == RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean isTerminated() {
|
||||||
|
return state == TERMINATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setSuspended() {
|
||||||
|
state = SUSPENDED;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setRunning() {
|
||||||
|
state = RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setTerminated() {
|
||||||
|
state = TERMINATED;
|
||||||
|
notifyAll();
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,8 @@ package org.eclipse.cdt.debug.mi.core;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.io.PipedInputStream;
|
||||||
|
import java.io.PipedOutputStream;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.mi.core.command.Command;
|
import org.eclipse.cdt.debug.mi.core.command.Command;
|
||||||
|
@ -31,9 +33,12 @@ public class MISession extends Observable {
|
||||||
Queue txQueue;
|
Queue txQueue;
|
||||||
Queue rxQueue;
|
Queue rxQueue;
|
||||||
|
|
||||||
OutputStream consoleStream = null;
|
PipedInputStream miInPipe;
|
||||||
OutputStream targetStream = null;
|
PipedOutputStream miOutPipe;
|
||||||
OutputStream logStream = null;
|
PipedInputStream targetInPipe;
|
||||||
|
PipedOutputStream targetOutPipe;
|
||||||
|
PipedInputStream logInPipe;
|
||||||
|
PipedOutputStream logOutPipe;
|
||||||
|
|
||||||
CommandFactory factory;
|
CommandFactory factory;
|
||||||
|
|
||||||
|
@ -41,10 +46,7 @@ public class MISession extends Observable {
|
||||||
|
|
||||||
long cmdTimeout = 10000; // 10 * 1000 (~ 10 secs);
|
long cmdTimeout = 10000; // 10 * 1000 (~ 10 secs);
|
||||||
|
|
||||||
final int STOPPED = 0;
|
MIProcess process;
|
||||||
final int RUNNING = 1;
|
|
||||||
final int SUSPENDED = 1;
|
|
||||||
int state = STOPPED;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the gdb session.
|
* Create the gdb session.
|
||||||
|
@ -63,48 +65,40 @@ public class MISession extends Observable {
|
||||||
rxThread = new RxThread(this);
|
rxThread = new RxThread(this);
|
||||||
txThread.start();
|
txThread.start();
|
||||||
rxThread.start();
|
rxThread.start();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
try {
|
||||||
* Set Console Stream.
|
miOutPipe = new PipedOutputStream();
|
||||||
*/
|
miInPipe = new PipedInputStream(miOutPipe);
|
||||||
public void setConsoleStream(OutputStream console) {
|
targetOutPipe = new PipedOutputStream();
|
||||||
consoleStream = console;
|
targetInPipe = new PipedInputStream(targetOutPipe);
|
||||||
|
logOutPipe = new PipedOutputStream();
|
||||||
|
logInPipe = new PipedInputStream(logOutPipe);
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
process = new MIProcess(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get Console Stream.
|
* get Console Stream.
|
||||||
*/
|
*/
|
||||||
OutputStream getConsoleStream() {
|
public InputStream getMIStream() {
|
||||||
return consoleStream;
|
return miInPipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Target Stream.
|
|
||||||
*/
|
|
||||||
public void setTargetStream(OutputStream target) {
|
|
||||||
targetStream = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Target Stream.
|
* Get Target Stream.
|
||||||
*/
|
*/
|
||||||
OutputStream getTargetStream() {
|
public InputStream getTargetStream() {
|
||||||
return targetStream;
|
return targetInPipe;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Log Stream
|
|
||||||
*/
|
|
||||||
public void setLogStream(OutputStream log) {
|
|
||||||
logStream = log;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Log Stream
|
* Get Log Stream
|
||||||
*/
|
*/
|
||||||
OutputStream getLogStream() {
|
public InputStream getLogStream() {
|
||||||
return logStream;
|
return logInPipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,6 +173,10 @@ public class MISession extends Observable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MIProcess getMIProcess() {
|
||||||
|
return process;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isTerminated() {
|
public boolean isTerminated() {
|
||||||
return (!txThread.isAlive() || !rxThread.isAlive());
|
return (!txThread.isAlive() || !rxThread.isAlive());
|
||||||
}
|
}
|
||||||
|
@ -188,6 +186,8 @@ public class MISession extends Observable {
|
||||||
*/
|
*/
|
||||||
public void terminate() {
|
public void terminate() {
|
||||||
|
|
||||||
|
process.destroy();
|
||||||
|
|
||||||
// Closing the channel will kill the RxThread.
|
// Closing the channel will kill the RxThread.
|
||||||
try {
|
try {
|
||||||
inChannel.close();
|
inChannel.close();
|
||||||
|
@ -199,7 +199,8 @@ public class MISession extends Observable {
|
||||||
outChannel.close();
|
outChannel.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
outChannel = null; // This is needed to stop the txThread.
|
// This is __needed__ to stop the txThread.
|
||||||
|
outChannel = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (txThread.isAlive()) {
|
if (txThread.isAlive()) {
|
||||||
|
@ -218,53 +219,6 @@ public class MISession extends Observable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The session is in STOPPED state.
|
|
||||||
* It means the 'run/-exec-run' command was not issued.
|
|
||||||
* Or the program exited, via a signal or normally.
|
|
||||||
* It is not the same as gdb/MI *stopped async-class
|
|
||||||
* gdb/MI stopped means suspended here.
|
|
||||||
*/
|
|
||||||
public boolean isStopped() {
|
|
||||||
return state == STOPPED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The session is in SUSPENDED state.
|
|
||||||
* State after hitting a breakpoint or after attach.
|
|
||||||
*/
|
|
||||||
public boolean isSuspended() {
|
|
||||||
return state == SUSPENDED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The session is in RUNNING state.
|
|
||||||
*/
|
|
||||||
public boolean isRunning() {
|
|
||||||
return state == RUNNING;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the state STOPPED.
|
|
||||||
*/
|
|
||||||
public void setStopped() {
|
|
||||||
state = STOPPED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the state SUSPENDED.
|
|
||||||
*/
|
|
||||||
public void setSuspended() {
|
|
||||||
state = SUSPENDED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the state STOPPED.
|
|
||||||
*/
|
|
||||||
public void setRunning() {
|
|
||||||
state = RUNNING;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify the observers of new MI OOB events.
|
* Notify the observers of new MI OOB events.
|
||||||
*/
|
*/
|
||||||
|
@ -273,6 +227,19 @@ public class MISession extends Observable {
|
||||||
super.notifyObservers(arg);
|
super.notifyObservers(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OutputStream getConsolePipe() {
|
||||||
|
return miOutPipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputStream getTargetPipe() {
|
||||||
|
return targetOutPipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputStream getLogPipe() {
|
||||||
|
return logOutPipe;
|
||||||
|
}
|
||||||
|
|
||||||
Queue getTxQueue() {
|
Queue getTxQueue() {
|
||||||
return txQueue;
|
return txQueue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ 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.MIEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIExitEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIExitEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MISignalEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MISignalEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIStepEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIStepEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
|
||||||
|
@ -70,12 +71,18 @@ public class RxThread extends Thread {
|
||||||
// discard termination
|
// discard termination
|
||||||
processMIOutput(buffer.toString());
|
processMIOutput(buffer.toString());
|
||||||
buffer = new StringBuffer();
|
buffer = new StringBuffer();
|
||||||
|
} else if (line.startsWith(MITargetStreamOutput.startTag)) {
|
||||||
|
// Process Target output immediately.
|
||||||
|
processMIOutput(line + "\n");
|
||||||
} else {
|
} else {
|
||||||
buffer.append(line).append('\n');
|
buffer.append(line).append('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
MIEvent event = new MIExitEvent();
|
||||||
|
Thread eventTread = new EventThread(session, new MIEvent[]{event});
|
||||||
|
eventTread.start();
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,9 +105,9 @@ public class RxThread extends Thread {
|
||||||
// Check if the state changed.
|
// Check if the state changed.
|
||||||
String state = rr.getResultClass();
|
String state = rr.getResultClass();
|
||||||
if ("running".equals(state)) {
|
if ("running".equals(state)) {
|
||||||
session.setRunning();
|
session.getMIProcess().setRunning();
|
||||||
} else if ("exit".equals(state)) {
|
} else if ("exit".equals(state)) {
|
||||||
session.setStopped();
|
session.getMIProcess().setTerminated();
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = rr.geToken();
|
int id = rr.geToken();
|
||||||
|
@ -149,7 +156,7 @@ public class RxThread extends Thread {
|
||||||
// Change of state.
|
// Change of state.
|
||||||
String state = exec.getAsyncClass();
|
String state = exec.getAsyncClass();
|
||||||
if ("stopped".equals(state)) {
|
if ("stopped".equals(state)) {
|
||||||
session.setSuspended();
|
session.getMIProcess().setSuspended();
|
||||||
}
|
}
|
||||||
|
|
||||||
MIResult[] results = exec.getMIResults();
|
MIResult[] results = exec.getMIResults();
|
||||||
|
@ -175,7 +182,7 @@ public class RxThread extends Thread {
|
||||||
|
|
||||||
void processMIOOBRecord(MIStreamRecord stream) {
|
void processMIOOBRecord(MIStreamRecord stream) {
|
||||||
if (stream instanceof MIConsoleStreamOutput) {
|
if (stream instanceof MIConsoleStreamOutput) {
|
||||||
OutputStream console = session.getConsoleStream();
|
OutputStream console = session.getConsolePipe();
|
||||||
if (console != null) {
|
if (console != null) {
|
||||||
MIConsoleStreamOutput out = (MIConsoleStreamOutput)stream;
|
MIConsoleStreamOutput out = (MIConsoleStreamOutput)stream;
|
||||||
String str = out.getString();
|
String str = out.getString();
|
||||||
|
@ -188,7 +195,7 @@ public class RxThread extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (stream instanceof MITargetStreamOutput) {
|
} else if (stream instanceof MITargetStreamOutput) {
|
||||||
OutputStream target = session.getTargetStream();
|
OutputStream target = session.getTargetPipe();
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
MITargetStreamOutput out = (MITargetStreamOutput)stream;
|
MITargetStreamOutput out = (MITargetStreamOutput)stream;
|
||||||
String str = out.getString();
|
String str = out.getString();
|
||||||
|
@ -201,7 +208,7 @@ public class RxThread extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (stream instanceof MILogStreamOutput) {
|
} else if (stream instanceof MILogStreamOutput) {
|
||||||
OutputStream log = session.getLogStream();
|
OutputStream log = session.getLogPipe();
|
||||||
if (log != null) {
|
if (log != null) {
|
||||||
MILogStreamOutput out = (MILogStreamOutput)stream;
|
MILogStreamOutput out = (MILogStreamOutput)stream;
|
||||||
String str = out.getString();
|
String str = out.getString();
|
||||||
|
@ -252,45 +259,39 @@ public class RxThread extends Thread {
|
||||||
} else if (rr != null) {
|
} else if (rr != null) {
|
||||||
event = new MIBreakpointEvent(rr);
|
event = new MIBreakpointEvent(rr);
|
||||||
}
|
}
|
||||||
session.setSuspended();
|
|
||||||
} else if ("watchpoint-trigger".equals(reason)) {
|
} else if ("watchpoint-trigger".equals(reason)) {
|
||||||
if (exec != null) {
|
if (exec != null) {
|
||||||
event = new MIWatchpointEvent(exec);
|
event = new MIWatchpointEvent(exec);
|
||||||
} else if (rr != null) {
|
} else if (rr != null) {
|
||||||
event = new MIWatchpointEvent(rr);
|
event = new MIWatchpointEvent(rr);
|
||||||
}
|
}
|
||||||
session.setSuspended();
|
|
||||||
} else if ("end-stepping-range".equals(reason)) {
|
} else if ("end-stepping-range".equals(reason)) {
|
||||||
if (exec != null) {
|
if (exec != null) {
|
||||||
event = new MIStepEvent(exec);
|
event = new MIStepEvent(exec);
|
||||||
} else if (rr != null) {
|
} else if (rr != null) {
|
||||||
event = new MIStepEvent(rr);
|
event = new MIStepEvent(rr);
|
||||||
}
|
}
|
||||||
session.setSuspended();
|
|
||||||
} else if ("signal-received".equals(reason)) {
|
} else if ("signal-received".equals(reason)) {
|
||||||
if (exec != null) {
|
if (exec != null) {
|
||||||
event = new MISignalEvent(exec);
|
event = new MISignalEvent(exec);
|
||||||
} else if (rr != null) {
|
} else if (rr != null) {
|
||||||
event = new MISignalEvent(rr);
|
event = new MISignalEvent(rr);
|
||||||
}
|
}
|
||||||
session.setStopped();
|
|
||||||
} else if ("location-reached".equals(reason)) {
|
} else if ("location-reached".equals(reason)) {
|
||||||
if (exec != null) {
|
if (exec != null) {
|
||||||
event = new MISignalEvent(exec);
|
event = new MISignalEvent(exec);
|
||||||
} else if (rr != null) {
|
} else if (rr != null) {
|
||||||
event = new MISignalEvent(rr);
|
event = new MISignalEvent(rr);
|
||||||
}
|
}
|
||||||
session.setSuspended();
|
|
||||||
} else if ("function-finished".equals(reason)) {
|
} else if ("function-finished".equals(reason)) {
|
||||||
if (exec != null) {
|
if (exec != null) {
|
||||||
event = new MIFunctionFinishedEvent(exec);
|
event = new MIFunctionFinishedEvent(exec);
|
||||||
} else if (rr != null) {
|
} else if (rr != null) {
|
||||||
event = new MIFunctionFinishedEvent(rr);
|
event = new MIFunctionFinishedEvent(rr);
|
||||||
}
|
}
|
||||||
session.setSuspended();
|
|
||||||
} else if ("exited-normally".equals(reason)) {
|
} else if ("exited-normally".equals(reason)) {
|
||||||
event = new MIExitEvent();
|
session.getMIProcess().setTerminated();
|
||||||
session.setStopped();
|
event = new MIInferiorExitEvent();
|
||||||
}
|
}
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ public class TxThread extends Thread {
|
||||||
public TxThread(MISession s) {
|
public TxThread(MISession s) {
|
||||||
super("MI TX Thread");
|
super("MI TX Thread");
|
||||||
session = s;
|
session = s;
|
||||||
|
// start at one, zero is special means no token.
|
||||||
token = 1;
|
token = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,9 +50,13 @@ public class TxThread extends Thread {
|
||||||
OutputStream out = session.getChannelOutputStream();
|
OutputStream out = session.getChannelOutputStream();
|
||||||
out.write(str.getBytes());
|
out.write(str.getBytes());
|
||||||
out.flush();
|
out.flush();
|
||||||
// Move to the RxQueue
|
// Move to the RxQueue only if we have
|
||||||
Queue rxQueue = session.getRxQueue();
|
// a valid token, this is to permit input(HACK!)
|
||||||
rxQueue.addCommand(cmd);
|
// or commands that do not want to wait for responses.
|
||||||
|
if (cmd.getToken() > 0) {
|
||||||
|
Queue rxQueue = session.getRxQueue();
|
||||||
|
rxQueue.addCommand(cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICArgument;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICObject;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICTarget;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICValue;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIArg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 Argument implements ICArgument {
|
||||||
|
|
||||||
|
MIArg arg;
|
||||||
|
|
||||||
|
public Argument(MIArg a) {
|
||||||
|
arg = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICVariable#getName()
|
||||||
|
*/
|
||||||
|
public String getName() throws CDIException {
|
||||||
|
return arg.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICVariable#getValue()
|
||||||
|
*/
|
||||||
|
public ICValue getValue() throws CDIException {
|
||||||
|
return new Value(arg.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICVariable#hasValueChanged()
|
||||||
|
*/
|
||||||
|
public boolean hasValueChanged() throws CDIException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICVariable#setValue(ICValue)
|
||||||
|
*/
|
||||||
|
public void setValue(ICValue value) throws CDIException {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICVariable#setValue(String)
|
||||||
|
*/
|
||||||
|
public void setValue(String expression) throws CDIException {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getCDITarget()
|
||||||
|
*/
|
||||||
|
public ICTarget getCDITarget() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getId()
|
||||||
|
*/
|
||||||
|
public String getId() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getParent()
|
||||||
|
*/
|
||||||
|
public ICObject getParent() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICVariable#getTypeName()
|
||||||
|
*/
|
||||||
|
public String getTypeName() throws CDIException {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,12 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICCatchEvent;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICCatchpoint;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICCondition;
|
import org.eclipse.cdt.debug.core.cdi.ICCondition;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICLocation;
|
import org.eclipse.cdt.debug.core.cdi.ICLocation;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICLocationBreakpoint;
|
import org.eclipse.cdt.debug.core.cdi.ICLocationBreakpoint;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICWatchpoint;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICInstruction;
|
import org.eclipse.cdt.debug.core.cdi.model.ICInstruction;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint;
|
import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint;
|
||||||
|
|
||||||
|
@ -15,11 +18,11 @@ import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint;
|
||||||
* To enable and disable the creation of type comments go to
|
* To enable and disable the creation of type comments go to
|
||||||
* Window>Preferences>Java>Code Generation.
|
* Window>Preferences>Java>Code Generation.
|
||||||
*/
|
*/
|
||||||
public class Breakpoint extends SessionObject implements ICLocationBreakpoint {
|
public class Breakpoint extends SessionObject implements ICLocationBreakpoint,
|
||||||
|
ICCatchpoint, ICWatchpoint {
|
||||||
|
|
||||||
ICLocation location;
|
ICLocation location;
|
||||||
ICCondition condition;
|
ICCondition condition;
|
||||||
String threadId = "";
|
|
||||||
MIBreakPoint miBreakPoint;
|
MIBreakPoint miBreakPoint;
|
||||||
BreakpointManager mgr;
|
BreakpointManager mgr;
|
||||||
|
|
||||||
|
@ -60,7 +63,7 @@ public class Breakpoint extends SessionObject implements ICLocationBreakpoint {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#getThreadId()
|
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#getThreadId()
|
||||||
*/
|
*/
|
||||||
public String getThreadId() throws CDIException {
|
public String getThreadId() throws CDIException {
|
||||||
return threadId;
|
return miBreakPoint.getThreadId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,14 +77,14 @@ public class Breakpoint extends SessionObject implements ICLocationBreakpoint {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isHardware()
|
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isHardware()
|
||||||
*/
|
*/
|
||||||
public boolean isHardware() {
|
public boolean isHardware() {
|
||||||
return miBreakPoint.getType().startsWith("hw");
|
return miBreakPoint.isHardware();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isTemporary()
|
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isTemporary()
|
||||||
*/
|
*/
|
||||||
public boolean isTemporary() {
|
public boolean isTemporary() {
|
||||||
return miBreakPoint.getDisposition().equals("del");
|
return miBreakPoint.isTemporary();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,4 +155,32 @@ public class Breakpoint extends SessionObject implements ICLocationBreakpoint {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICCatchpoint#getEvent()
|
||||||
|
*/
|
||||||
|
public ICCatchEvent getEvent() throws CDIException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICWatchpoint#getWatchExpression()
|
||||||
|
*/
|
||||||
|
public String getWatchExpression() throws CDIException {
|
||||||
|
return miBreakPoint.getWhat();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICWatchpoint#isReadType()
|
||||||
|
*/
|
||||||
|
public boolean isReadType() {
|
||||||
|
return miBreakPoint.isReadWatchpoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICWatchpoint#isWriteType()
|
||||||
|
*/
|
||||||
|
public boolean isWriteType() {
|
||||||
|
return miBreakPoint.isAccessWatchpoint();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,14 @@ import org.eclipse.cdt.debug.core.cdi.ICLocationBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICWatchpoint;
|
import org.eclipse.cdt.debug.core.cdi.ICWatchpoint;
|
||||||
import org.eclipse.cdt.debug.mi.core.MIException;
|
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.CommandFactory;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIBreakDelete;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIBreakDisable;
|
import org.eclipse.cdt.debug.mi.core.command.MIBreakDisable;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIBreakEnable;
|
import org.eclipse.cdt.debug.mi.core.command.MIBreakEnable;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIBreakInsert;
|
import org.eclipse.cdt.debug.mi.core.command.MIBreakInsert;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIBreakWatch;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIBreakInsertInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIBreakInsertInfo;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint;
|
import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIBreakWatchInfo;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,11 +59,35 @@ public class BreakpointManager extends SessionObject implements ICBreakpointMana
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#deleteBreakpoints(ICBreakpoint[])
|
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#deleteBreakpoints(ICBreakpoint[])
|
||||||
*/
|
*/
|
||||||
public void deleteBreakpoints(ICBreakpoint[] breakpoints) throws CDIException {
|
public void deleteBreakpoints(ICBreakpoint[] breakpoints) throws CDIException {
|
||||||
|
int[] numbers = new int[breakpoints.length];
|
||||||
|
for (int i = 0; i < numbers.length; i++) {
|
||||||
|
if (breakpoints[i] instanceof Breakpoint
|
||||||
|
&& breakList.contains(breakpoints[i])) {
|
||||||
|
numbers[i] = ((Breakpoint)breakpoints[i]).getMIBreakPoint().getNumber();
|
||||||
|
} else {
|
||||||
|
//throw new CDIException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CSession s = getCSession();
|
||||||
|
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||||
|
MIBreakDelete breakDelete = factory.createMIBreakDelete(numbers);
|
||||||
|
try {
|
||||||
|
s.getMISession().postCommand(breakDelete);
|
||||||
|
MIInfo info = breakDelete.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
//throw new CDIException();
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
// throw new CDIException(e);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < breakpoints.length; i++) {
|
||||||
|
breakList.remove(breakpoints[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableBreakpoint(ICBreakpoint breakpoint) throws CDIException {
|
public void enableBreakpoint(ICBreakpoint breakpoint) throws CDIException {
|
||||||
int number = 0;
|
int number = 0;
|
||||||
if (breakpoint instanceof Breakpoint) {
|
if (breakpoint instanceof Breakpoint && breakList.contains(breakpoint)) {
|
||||||
number = ((Breakpoint)breakpoint).getMIBreakPoint().getNumber();
|
number = ((Breakpoint)breakpoint).getMIBreakPoint().getNumber();
|
||||||
} else {
|
} else {
|
||||||
//throw new CDIException();
|
//throw new CDIException();
|
||||||
|
@ -82,7 +109,7 @@ public class BreakpointManager extends SessionObject implements ICBreakpointMana
|
||||||
|
|
||||||
public void disableBreakpoint(ICBreakpoint breakpoint) throws CDIException {
|
public void disableBreakpoint(ICBreakpoint breakpoint) throws CDIException {
|
||||||
int number = 0;
|
int number = 0;
|
||||||
if (breakpoint instanceof Breakpoint) {
|
if (breakpoint instanceof Breakpoint && breakList.contains(breakpoint)) {
|
||||||
number = ((Breakpoint)breakpoint).getMIBreakPoint().getNumber();
|
number = ((Breakpoint)breakpoint).getMIBreakPoint().getNumber();
|
||||||
} else {
|
} else {
|
||||||
// throw new CDIException();
|
// throw new CDIException();
|
||||||
|
@ -114,6 +141,7 @@ public class BreakpointManager extends SessionObject implements ICBreakpointMana
|
||||||
*/
|
*/
|
||||||
public ICCatchpoint setCatchpoint(int type, ICCatchEvent event, String expression,
|
public ICCatchpoint setCatchpoint(int type, ICCatchEvent event, String expression,
|
||||||
ICCondition condition) throws CDIException {
|
ICCondition condition) throws CDIException {
|
||||||
|
// throw new CDIException();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +204,29 @@ public class BreakpointManager extends SessionObject implements ICBreakpointMana
|
||||||
*/
|
*/
|
||||||
public ICWatchpoint setWatchpoint(int type, int watchType, String expression,
|
public ICWatchpoint setWatchpoint(int type, int watchType, String expression,
|
||||||
ICCondition condition) throws CDIException {
|
ICCondition condition) throws CDIException {
|
||||||
return null;
|
boolean access = (type == ICWatchpoint.WRITE);
|
||||||
|
boolean read = (type == ICWatchpoint.READ);
|
||||||
|
|
||||||
|
CSession s = getCSession();
|
||||||
|
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||||
|
MIBreakWatch breakWatch = factory.createMIBreakWatch(access, read, expression);
|
||||||
|
MIBreakPoint[] points = null;
|
||||||
|
try {
|
||||||
|
s.getMISession().postCommand(breakWatch);
|
||||||
|
MIBreakWatchInfo info = breakWatch.getMIBreakWatchInfo();
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,10 @@ public class CSession implements ICSession {
|
||||||
return new ICTarget[]{ctarget};
|
return new ICTarget[]{ctarget};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICTarget getCTarget() {
|
||||||
|
return ctarget;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICSession#isTerminated()
|
* @see org.eclipse.cdt.debug.core.cdi.ICSession#isTerminated()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,7 +9,6 @@ import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICSession;
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICExpression;
|
import org.eclipse.cdt.debug.core.cdi.model.ICExpression;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICGlobalVariable;
|
import org.eclipse.cdt.debug.core.cdi.model.ICGlobalVariable;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICMemoryBlock;
|
import org.eclipse.cdt.debug.core.cdi.model.ICMemoryBlock;
|
||||||
|
@ -18,6 +17,20 @@ 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.ICSharedLibrary;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICTarget;
|
import org.eclipse.cdt.debug.core.cdi.model.ICTarget;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICThread;
|
import org.eclipse.cdt.debug.core.cdi.model.ICThread;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICValue;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||||
|
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.MIExecInterrupt;
|
||||||
|
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.MIExecRun;
|
||||||
|
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.MITargetDetach;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author alain
|
* @author alain
|
||||||
|
@ -37,6 +50,18 @@ public class CTarget extends SessionObject implements ICTarget {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#disconnect()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#disconnect()
|
||||||
*/
|
*/
|
||||||
public void disconnect() throws CDIException {
|
public void disconnect() throws CDIException {
|
||||||
|
MISession mi = getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MITargetDetach detach = factory.createMITargetDetach();
|
||||||
|
try {
|
||||||
|
mi.postCommand(detach);
|
||||||
|
MIInfo info = detach.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
// throw new CDIException();
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
//throw new CDIException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,6 +83,18 @@ public class CTarget extends SessionObject implements ICTarget {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#finish()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#finish()
|
||||||
*/
|
*/
|
||||||
public void finish() throws CDIException {
|
public void finish() throws CDIException {
|
||||||
|
MISession mi = getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIExecFinish finish = factory.createMIExecFinish();
|
||||||
|
try {
|
||||||
|
mi.postCommand(finish);
|
||||||
|
MIInfo info = finish.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
// throw new CDIException();
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
//throw new CDIException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,27 +109,27 @@ public class CTarget extends SessionObject implements ICTarget {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#getErrorStream()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#getErrorStream()
|
||||||
*/
|
*/
|
||||||
public InputStream getErrorStream() {
|
public InputStream getErrorStream() {
|
||||||
return null;
|
return getCSession().getMISession().getMIProcess().getErrorStream();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#getGlobalVariables()
|
|
||||||
*/
|
|
||||||
public ICGlobalVariable[] getGlobalVariables() throws CDIException {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#getInputStream()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#getInputStream()
|
||||||
*/
|
*/
|
||||||
public InputStream getInputStream() {
|
public InputStream getInputStream() {
|
||||||
return null;
|
return getCSession().getMISession().getMIProcess().getInputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#getOutputStream()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#getOutputStream()
|
||||||
*/
|
*/
|
||||||
public OutputStream getOutputStream() {
|
public OutputStream getOutputStream() {
|
||||||
|
return getCSession().getMISession().getMIProcess().getOutputStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#getGlobalVariables()
|
||||||
|
*/
|
||||||
|
public ICGlobalVariable[] getGlobalVariables() throws CDIException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +144,7 @@ public class CTarget extends SessionObject implements ICTarget {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#getSharedLibraries()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#getSharedLibraries()
|
||||||
*/
|
*/
|
||||||
public ICSharedLibrary[] getSharedLibraries() throws CDIException {
|
public ICSharedLibrary[] getSharedLibraries() throws CDIException {
|
||||||
return null;
|
return new ICSharedLibrary[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,76 +172,165 @@ public class CTarget extends SessionObject implements ICTarget {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#isStepping()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#isStepping()
|
||||||
*/
|
*/
|
||||||
public boolean isStepping() {
|
public boolean isStepping() {
|
||||||
return false;
|
return getCSession().getMISession().getMIProcess().isRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#isSuspended()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#isSuspended()
|
||||||
*/
|
*/
|
||||||
public boolean isSuspended() {
|
public boolean isSuspended() {
|
||||||
return false;
|
return getCSession().getMISession().getMIProcess().isSuspended();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#isTerminated()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#isTerminated()
|
||||||
*/
|
*/
|
||||||
public boolean isTerminated() {
|
public boolean isTerminated() {
|
||||||
return false;
|
return getCSession().getMISession().getMIProcess().isTerminated();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#restart()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#restart()
|
||||||
*/
|
*/
|
||||||
public void restart() throws CDIException {
|
public void restart() throws CDIException {
|
||||||
|
MISession mi = getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIExecRun run = factory.createMIExecRun(new String[0]);
|
||||||
|
try {
|
||||||
|
mi.postCommand(run);
|
||||||
|
MIInfo info = run.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
// throw new CDIException();
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
//throw new CDIException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#resume()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#resume()
|
||||||
*/
|
*/
|
||||||
public void resume() throws CDIException {
|
public void resume() throws CDIException {
|
||||||
|
MISession mi = getCSession().getMISession();
|
||||||
|
if (mi.getMIProcess().isSuspended()) {
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIExecContinue cont = factory.createMIExecContinue();
|
||||||
|
try {
|
||||||
|
mi.postCommand(cont);
|
||||||
|
MIInfo info = cont.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
// throw new CDIException();
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
//throw new CDIException(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
restart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#stepInto()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#stepInto()
|
||||||
*/
|
*/
|
||||||
public void stepInto() throws CDIException {
|
public void stepInto() throws CDIException {
|
||||||
|
MISession mi = getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIExecStep step = factory.createMIExecStep();
|
||||||
|
try {
|
||||||
|
mi.postCommand(step);
|
||||||
|
MIInfo info = step.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
// throw new CDIException();
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
//throw new CDIException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#stepIntoInstruction()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#stepIntoInstruction()
|
||||||
*/
|
*/
|
||||||
public void stepIntoInstruction() throws CDIException {
|
public void stepIntoInstruction() throws CDIException {
|
||||||
|
MISession mi = getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIExecStepInstruction stepi = factory.createMIExecStepInstruction();
|
||||||
|
try {
|
||||||
|
mi.postCommand(stepi);
|
||||||
|
MIInfo info = stepi.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
// throw new CDIException();
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
//throw new CDIException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#stepOver()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#stepOver()
|
||||||
*/
|
*/
|
||||||
public void stepOver() throws CDIException {
|
public void stepOver() throws CDIException {
|
||||||
|
MISession mi = getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIExecNext next = factory.createMIExecNext();
|
||||||
|
try {
|
||||||
|
mi.postCommand(next);
|
||||||
|
MIInfo info = next.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
// throw new CDIException();
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
//throw new CDIException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#stepOverInstruction()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#stepOverInstruction()
|
||||||
*/
|
*/
|
||||||
public void stepOverInstruction() throws CDIException {
|
public void stepOverInstruction() throws CDIException {
|
||||||
|
MISession mi = getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIExecNextInstruction nexti = factory.createMIExecNextInstruction();
|
||||||
|
try {
|
||||||
|
mi.postCommand(nexti);
|
||||||
|
MIInfo info = nexti.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
// throw new CDIException();
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
//throw new CDIException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#suspend()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#suspend()
|
||||||
*/
|
*/
|
||||||
public void suspend() throws CDIException {
|
public void suspend() throws CDIException {
|
||||||
|
MISession mi = getCSession().getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIExecInterrupt interrupt = factory.createMIExecInterrupt();
|
||||||
|
try {
|
||||||
|
mi.postCommand(interrupt);
|
||||||
|
MIInfo info = interrupt.getMIInfo();
|
||||||
|
if (info == null) {
|
||||||
|
// throw new CDIException();
|
||||||
|
}
|
||||||
|
} catch (MIException e) {
|
||||||
|
//throw new CDIException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#terminate()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#terminate()
|
||||||
*/
|
*/
|
||||||
public void terminate() throws CDIException {
|
public void terminate() throws CDIException {
|
||||||
|
getCSession().getMISession().getMIProcess().destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getCDITarget()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getCDITarget()
|
||||||
*/
|
*/
|
||||||
public ICTarget getCDITarget() {
|
public ICTarget getCDITarget() {
|
||||||
return null;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -221,4 +347,20 @@ public class CTarget extends SessionObject implements ICTarget {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#evaluateExpressionToString(String)
|
||||||
|
*/
|
||||||
|
public String evaluateExpressionToString(String expressionText)
|
||||||
|
throws CDIException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICTarget#evaluateExpressionToValue(String)
|
||||||
|
*/
|
||||||
|
public ICValue evaluateExpressionToValue(String expressionText)
|
||||||
|
throws CDIException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.event.ICEvent;
|
||||||
|
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.MIExitEvent;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent;
|
||||||
|
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.MIStepEvent;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 EventAdapter {
|
||||||
|
|
||||||
|
public static ICEvent getCEvent(final CSession session, final MIEvent miEvent) {
|
||||||
|
if (miEvent instanceof MIBreakpointEvent) {
|
||||||
|
return new SuspendedEvent(session, (MIBreakpointEvent)miEvent);
|
||||||
|
} else if (miEvent instanceof MIInferiorExitEvent) {
|
||||||
|
} else if (miEvent instanceof MIExitEvent) {
|
||||||
|
} else if (miEvent instanceof MIFunctionFinishedEvent) {
|
||||||
|
} else if (miEvent instanceof MILocationReachedEvent) {
|
||||||
|
} else if (miEvent instanceof MISignalEvent) {
|
||||||
|
} else if (miEvent instanceof MIStepEvent) {
|
||||||
|
} else if (miEvent instanceof MIWatchpointEvent) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,9 +5,16 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Observable;
|
||||||
|
import java.util.Observer;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICEventManager;
|
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.core.cdi.event.ICEventListener;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author alain
|
* @author alain
|
||||||
|
@ -19,6 +26,21 @@ import org.eclipse.cdt.debug.core.cdi.event.ICEventListener;
|
||||||
*/
|
*/
|
||||||
public class EventManager extends SessionObject implements ICEventManager {
|
public class EventManager extends SessionObject implements ICEventManager {
|
||||||
|
|
||||||
|
Map map = Collections.synchronizedMap(new HashMap());
|
||||||
|
|
||||||
|
class CDIObserver implements Observer {
|
||||||
|
ICEventListener listener;
|
||||||
|
public CDIObserver(ICEventListener l) {
|
||||||
|
listener = l;
|
||||||
|
}
|
||||||
|
public void update(Observable o, Object args) {
|
||||||
|
MIEvent[] events = (MIEvent[])args;
|
||||||
|
for (int i = 0; i < events.length; i++) {
|
||||||
|
// listener.handleDebugEvent(new CEventAdapter(events[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public EventManager(CSession session) {
|
public EventManager(CSession session) {
|
||||||
super(session);
|
super(session);
|
||||||
}
|
}
|
||||||
|
@ -27,12 +49,20 @@ public class EventManager extends SessionObject implements ICEventManager {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICEventManager#addEventListener(ICEventListener)
|
* @see org.eclipse.cdt.debug.core.cdi.ICEventManager#addEventListener(ICEventListener)
|
||||||
*/
|
*/
|
||||||
public void addEventListener(ICEventListener listener) {
|
public void addEventListener(ICEventListener listener) {
|
||||||
|
CDIObserver cdiObserver = new CDIObserver(listener);
|
||||||
|
map.put(listener, cdiObserver);
|
||||||
|
MISession session = getCSession().getMISession();
|
||||||
|
session.addObserver(cdiObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICEventManager#removeEventListener(ICEventListener)
|
* @see org.eclipse.cdt.debug.core.cdi.ICEventManager#removeEventListener(ICEventListener)
|
||||||
*/
|
*/
|
||||||
public void removeEventListener(ICEventListener listener) {
|
public void removeEventListener(ICEventListener listener) {
|
||||||
|
CDIObserver cdiObserver = (CDIObserver)map.remove(listener);
|
||||||
|
if (cdiObserver != null) {
|
||||||
|
MISession session = getCSession().getMISession();
|
||||||
|
session.deleteObserver(cdiObserver);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICExpression;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICObject;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICTarget;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 Expression implements ICExpression {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICExpression#getExpressionText()
|
||||||
|
*/
|
||||||
|
public String getExpressionText() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICExpression#getValue()
|
||||||
|
*/
|
||||||
|
public ICValue getValue() throws CDIException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getCDITarget()
|
||||||
|
*/
|
||||||
|
public ICTarget getCDITarget() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getId()
|
||||||
|
*/
|
||||||
|
public String getId() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getParent()
|
||||||
|
*/
|
||||||
|
public ICObject getParent() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICLocation;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICInstruction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 Location implements ICLocation {
|
||||||
|
|
||||||
|
long addr;
|
||||||
|
String file = "";
|
||||||
|
String function = "";
|
||||||
|
int line;
|
||||||
|
|
||||||
|
public Location(String f, String fnct, int l, long a) {
|
||||||
|
file = f;
|
||||||
|
function = fnct;
|
||||||
|
line = l;
|
||||||
|
addr = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICLocation#getAddress()
|
||||||
|
*/
|
||||||
|
public long getAddress() {
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICLocation#getFile()
|
||||||
|
*/
|
||||||
|
public String getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICLocation#getFunction()
|
||||||
|
*/
|
||||||
|
public String getFunction() {
|
||||||
|
return function;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICLocation#getInstructions()
|
||||||
|
*/
|
||||||
|
public ICInstruction[] getInstructions() throws CDIException {
|
||||||
|
return new ICInstruction[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICLocation#getInstructions(int)
|
||||||
|
*/
|
||||||
|
public ICInstruction[] getInstructions(int maxCount) throws CDIException {
|
||||||
|
return new ICInstruction[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.ICLocation#getLineNumber()
|
||||||
|
*/
|
||||||
|
public int getLineNumber() {
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,107 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICLocation;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICArgument;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICObject;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICStackFrame;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICTarget;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICVariable;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.command.MIStackListLocals;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIArg;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIFrame;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIStackListLocalsInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 StackFrame implements ICStackFrame {
|
||||||
|
|
||||||
|
CSession session;
|
||||||
|
MIFrame frame;
|
||||||
|
|
||||||
|
public StackFrame(CSession s, MIFrame f) {
|
||||||
|
session = s;
|
||||||
|
frame = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICStackFrame#getArguments()
|
||||||
|
*/
|
||||||
|
public ICArgument[] getArguments() throws CDIException {
|
||||||
|
MIArg[] args = frame.getArgs();
|
||||||
|
ICArgument[] cargs = new ICArgument[args.length];
|
||||||
|
for (int i = 0; i < cargs.length; i++) {
|
||||||
|
cargs[i] = new Argument(args[i]);
|
||||||
|
}
|
||||||
|
return cargs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICStackFrame#getLocalVariables()
|
||||||
|
*/
|
||||||
|
public ICVariable[] getLocalVariables() throws CDIException {
|
||||||
|
MIArg[] args = null;
|
||||||
|
ICVariable[] variables = null;
|
||||||
|
MISession mi = session.getMISession();
|
||||||
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
MIStackListLocals locals = factory.createMIStackListLocals(true);
|
||||||
|
try {
|
||||||
|
mi.postCommand(locals);
|
||||||
|
MIStackListLocalsInfo info = locals.getMIStackListLocalsInfo();
|
||||||
|
if (info == null) {
|
||||||
|
// throw new CDIException();
|
||||||
|
}
|
||||||
|
args = info.getLocals();
|
||||||
|
|
||||||
|
} catch (MIException e) {
|
||||||
|
//throw new CDIException(e);
|
||||||
|
}
|
||||||
|
if (args != null) {
|
||||||
|
variables = new ICVariable[args.length];
|
||||||
|
for (int i = 0; i < variables.length; i++) {
|
||||||
|
variables[i] = new Variable(args[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
variables = new ICVariable[0];
|
||||||
|
}
|
||||||
|
return variables;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICStackFrame#getLocation()
|
||||||
|
*/
|
||||||
|
public ICLocation getLocation() {
|
||||||
|
return new Location(frame.getFile(), frame.getFunction(),
|
||||||
|
frame.getLine(), frame.getAddress());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getCDITarget()
|
||||||
|
*/
|
||||||
|
public ICTarget getCDITarget() {
|
||||||
|
return session.getCTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getId()
|
||||||
|
*/
|
||||||
|
public String getId() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getParent()
|
||||||
|
*/
|
||||||
|
public ICObject getParent() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICLocation;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.ICSessionObject;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.event.ICEvent;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.event.ICSuspendedEvent;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICArgument;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICObject;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICStackFrame;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICTarget;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICVariable;
|
||||||
|
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.MIExitEvent;
|
||||||
|
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.MIStepEvent;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 SuspendedEvent implements ICSuspendedEvent {
|
||||||
|
|
||||||
|
MIBreakpointEvent event;
|
||||||
|
CSession session;
|
||||||
|
|
||||||
|
public SuspendedEvent(CSession s, MIBreakpointEvent e) {
|
||||||
|
session = s;
|
||||||
|
event = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICSessionObject getReason() {
|
||||||
|
return new SessionObject(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICStackFrame getStackFrame() {
|
||||||
|
return new StackFrame(session, event.getMIFrame());
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.event.ICEvent#getSource()
|
||||||
|
*/
|
||||||
|
public ICObject getSource() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICObject;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICTarget;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICValue;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICVariable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 Value implements ICValue {
|
||||||
|
|
||||||
|
String val = "";
|
||||||
|
|
||||||
|
public Value(String s) {
|
||||||
|
val = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICValue#getTypeName()
|
||||||
|
*/
|
||||||
|
public String getTypeName() throws CDIException {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICValue#getValueString()
|
||||||
|
*/
|
||||||
|
public String getValueString() throws CDIException {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICValue#getVariables()
|
||||||
|
*/
|
||||||
|
public ICVariable[] getVariables() throws CDIException {
|
||||||
|
return new ICVariable[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getCDITarget()
|
||||||
|
*/
|
||||||
|
public ICTarget getCDITarget() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getId()
|
||||||
|
*/
|
||||||
|
public String getId() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getParent()
|
||||||
|
*/
|
||||||
|
public ICObject getParent() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICObject;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICTarget;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICValue;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICVariable;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIArg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 Variable implements ICVariable {
|
||||||
|
|
||||||
|
MIArg arg;
|
||||||
|
|
||||||
|
public Variable(MIArg a) {
|
||||||
|
arg = a;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICVariable#getName()
|
||||||
|
*/
|
||||||
|
public String getName() throws CDIException {
|
||||||
|
return arg.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICVariable#getTypeName()
|
||||||
|
*/
|
||||||
|
public String getTypeName() throws CDIException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICVariable#getValue()
|
||||||
|
*/
|
||||||
|
public ICValue getValue() throws CDIException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICVariable#hasValueChanged()
|
||||||
|
*/
|
||||||
|
public boolean hasValueChanged() throws CDIException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICVariable#setValue(ICValue)
|
||||||
|
*/
|
||||||
|
public void setValue(ICValue value) throws CDIException {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICVariable#setValue(String)
|
||||||
|
*/
|
||||||
|
public void setValue(String expression) throws CDIException {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getCDITarget()
|
||||||
|
*/
|
||||||
|
public ICTarget getCDITarget() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getId()
|
||||||
|
*/
|
||||||
|
public String getId() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICObject#getParent()
|
||||||
|
*/
|
||||||
|
public ICObject getParent() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -27,8 +27,15 @@ public class CLICommand extends Command
|
||||||
* @return the text representation of this command
|
* @return the text representation of this command
|
||||||
*/
|
*/
|
||||||
public String toString(){
|
public String toString(){
|
||||||
if (operation.endsWith("\n"))
|
String str = null;
|
||||||
return operation;
|
int t = getToken();
|
||||||
return operation + "\n";
|
if (t > 0) {
|
||||||
|
str = Integer.toString(t) + " " + operation;
|
||||||
|
} else {
|
||||||
|
str = operation;
|
||||||
|
}
|
||||||
|
if (str.endsWith("\n"))
|
||||||
|
return str;
|
||||||
|
return str + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,10 @@ public class CommandFactory {
|
||||||
return new MIEnvironmentPWD();
|
return new MIEnvironmentPWD();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MIExecAbort createMIExecAbort() {
|
||||||
|
return new MIExecAbort();
|
||||||
|
}
|
||||||
|
|
||||||
public MIExecArguments createMIExecArguments(String[] args) {
|
public MIExecArguments createMIExecArguments(String[] args) {
|
||||||
return new MIExecArguments(args);
|
return new MIExecArguments(args);
|
||||||
}
|
}
|
||||||
|
@ -158,6 +162,10 @@ public class CommandFactory {
|
||||||
return new MIGDBShow(params);
|
return new MIGDBShow(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MIGDBShowExitCode createMIGDBShowExitCode() {
|
||||||
|
return new MIGDBShowExitCode();
|
||||||
|
}
|
||||||
|
|
||||||
public MIStackInfoDepth createMIStackInfoDepth(int depth) {
|
public MIStackInfoDepth createMIStackInfoDepth(int depth) {
|
||||||
return new MIStackInfoDepth(depth);
|
return new MIStackInfoDepth(depth);
|
||||||
}
|
}
|
||||||
|
@ -182,6 +190,10 @@ public class CommandFactory {
|
||||||
return new MIStackSelectFrame(frameNum);
|
return new MIStackSelectFrame(frameNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MITargetAttach createMITargetAttach(int pid) {
|
||||||
|
return new MITargetAttach(pid);
|
||||||
|
}
|
||||||
|
|
||||||
public MITargetDetach createMITargetDetach() {
|
public MITargetDetach createMITargetDetach() {
|
||||||
return new MITargetDetach();
|
return new MITargetDetach();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,10 @@ public class MIBreakWatch extends MICommand
|
||||||
setParameters(new String[]{expr});
|
setParameters(new String[]{expr});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MIBreakWatchInfo getMIBreakWatchInfo() throws MIException {
|
||||||
|
return (MIBreakWatchInfo)getMIInfo();
|
||||||
|
}
|
||||||
|
|
||||||
public MIInfo getMIInfo() throws MIException {
|
public MIInfo getMIInfo() throws MIException {
|
||||||
MIInfo info = null;
|
MIInfo info = null;
|
||||||
MIOutput out = getMIOutput();
|
MIOutput out = getMIOutput();
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.debug.mi.core.command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* -exec-finish
|
||||||
|
*
|
||||||
|
* Asynchronous command. Resumes the execution of the inferior program
|
||||||
|
* until the current function is exited. Displays the results returned by
|
||||||
|
* the function.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MIExecAbort extends CLICommand
|
||||||
|
{
|
||||||
|
public MIExecAbort() {
|
||||||
|
super("kill");
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,8 +18,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||||
* Show the current value of a GDB variable.
|
* Show the current value of a GDB variable.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MIGDBShow extends MICommand
|
public class MIGDBShow extends MICommand {
|
||||||
{
|
|
||||||
public MIGDBShow(String[] params) {
|
public MIGDBShow(String[] params) {
|
||||||
super("-gdb-show", params);
|
super("-gdb-show", params);
|
||||||
}
|
}
|
||||||
|
@ -34,5 +33,5 @@ public class MIGDBShow extends MICommand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.debug.mi.core.command;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.mi.core.MIException;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIGDBShowExitCodeInfo;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* -gdb-show
|
||||||
|
*
|
||||||
|
* Show the current value of a GDB variable.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MIGDBShowExitCode extends MIGDBShow {
|
||||||
|
public MIGDBShowExitCode() {
|
||||||
|
super(new String[] { "convenience", "$_exitcode" });
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIGDBShowExitCodeInfo getMIGDBShowExitCodeInfo() throws MIException {
|
||||||
|
return (MIGDBShowExitCodeInfo)getMIInfo();
|
||||||
|
}
|
||||||
|
public MIInfo getMIInfo() throws MIException {
|
||||||
|
MIInfo info = null;
|
||||||
|
MIOutput out = getMIOutput();
|
||||||
|
if (out != null) {
|
||||||
|
info = new MIGDBShowExitCodeInfo(out);
|
||||||
|
if (info.isError()) {
|
||||||
|
throw new MIException(info.getErrorMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,10 @@ public class MIStackListLocals extends MICommand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MIStackListLocalsInfo getMIStackListLocalsInfo() throws MIException {
|
||||||
|
return (MIStackListLocalsInfo)getMIInfo();
|
||||||
|
}
|
||||||
|
|
||||||
public MIInfo getMIInfo() throws MIException {
|
public MIInfo getMIInfo() throws MIException {
|
||||||
MIInfo info = null;
|
MIInfo info = null;
|
||||||
MIOutput out = getMIOutput();
|
MIOutput out = getMIOutput();
|
||||||
|
|
|
@ -14,9 +14,9 @@ package org.eclipse.cdt.debug.mi.core.command;
|
||||||
* Attach to a process PID or a file FILE outside of GDB.
|
* Attach to a process PID or a file FILE outside of GDB.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MITargetAttach extends MICommand
|
public class MITargetAttach extends CLICommand
|
||||||
{
|
{
|
||||||
public MITargetAttach(int pid) {
|
public MITargetAttach(int pid) {
|
||||||
super("-target-attach", new String[]{Integer.toString(pid)});
|
super("attach " + Integer.toString(pid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class MIBreakpointEvent extends MIEvent {
|
||||||
return threadId;
|
return threadId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MIFrame getFrame() {
|
public MIFrame getMIFrame() {
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,7 @@ package org.eclipse.cdt.debug.mi.core.event;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* *stopped,reason="exited-normally"
|
* Gdb Session terminated.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class MIExitEvent extends MIEvent {
|
public class MIExitEvent extends MIEvent {
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.event;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* *stopped,reason="exited-normally"
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MIInferiorExitEvent extends MIEvent {
|
||||||
|
}
|
|
@ -12,6 +12,12 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* -break-insert main
|
* -break-insert main
|
||||||
* ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x08048468",func="main",file="hello.c",line="4",times="0"}
|
* ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x08048468",func="main",file="hello.c",line="4",times="0"}
|
||||||
|
* -break-insert -a p
|
||||||
|
* ^done,hw-awpt={number="2",exp="p"}
|
||||||
|
* -break-watch -r p
|
||||||
|
* ^done,hw-rwpt={number="4",exp="p"}
|
||||||
|
* -break-watch p
|
||||||
|
* ^done,wpt={number="6",exp="p"}
|
||||||
*/
|
*/
|
||||||
public class MIBreakInsertInfo extends MIInfo {
|
public class MIBreakInsertInfo extends MIInfo {
|
||||||
|
|
||||||
|
@ -26,11 +32,28 @@ public class MIBreakInsertInfo extends MIInfo {
|
||||||
MIResult[] results = rr.getMIResults();
|
MIResult[] results = rr.getMIResults();
|
||||||
for (int i = 0; i < results.length; i++) {
|
for (int i = 0; i < results.length; i++) {
|
||||||
String var = results[i].getVariable();
|
String var = results[i].getVariable();
|
||||||
|
MIValue val = results[i].getMIValue();
|
||||||
|
MIBreakPoint bpt = null;
|
||||||
if (var.equals("bkpt")) {
|
if (var.equals("bkpt")) {
|
||||||
MIValue val = results[i].getMIValue();
|
|
||||||
if (val instanceof MITuple) {
|
if (val instanceof MITuple) {
|
||||||
aList.add(new MIBreakPoint((MITuple)val));
|
bpt = new MIBreakPoint((MITuple)val);
|
||||||
|
bpt.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
} else if (var.equals("hw-awpt")) {
|
||||||
|
if (val instanceof MITuple) {
|
||||||
|
bpt = new MIBreakPoint((MITuple)val);
|
||||||
|
bpt.setAccessWatchpoint(true);
|
||||||
|
bpt.setEnabled(true);
|
||||||
|
}
|
||||||
|
} else if (var.equals("hw-rwpt")) {
|
||||||
|
if (val instanceof MITuple) {
|
||||||
|
bpt = new MIBreakPoint((MITuple)val);
|
||||||
|
bpt.setReadWatchpoint(true);
|
||||||
|
bpt.setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bpt != null) {
|
||||||
|
aList.add(bpt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ import java.util.List;
|
||||||
* A -break-list result-record is the form:
|
* A -break-list result-record is the form:
|
||||||
* <pre>
|
* <pre>
|
||||||
* ^done,BreakpointTable={nr_rows="1",nr_cols="6",hdr=[..],body=[brkpt={},brkpt={}]}
|
* ^done,BreakpointTable={nr_rows="1",nr_cols="6",hdr=[..],body=[brkpt={},brkpt={}]}
|
||||||
|
*-break-list
|
||||||
|
^done,BreakpointTable={nr_rows="6",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",times="0"},bkpt={number="2",type="breakpoint",disp="del",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",times="0"},bkpt={number="3",type="breakpoint",disp="keep",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",cond="1",times="0"},bkpt={number="4",type="hw breakpoint",disp="keep",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",times="0"},bkpt={number="5",type="breakpoint",disp="keep",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",thread="0",thread="0",times="0"},bkpt={number="6",type="breakpoint",disp="keep",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",thread="1",thread="1",times="0"}]}
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class MIBreakListInfo extends MIInfo {
|
public class MIBreakListInfo extends MIInfo {
|
||||||
|
|
|
@ -7,12 +7,40 @@ package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contain info about the GDB/MI breakpoint info.
|
* Contain info about the GDB/MI breakpoint info.
|
||||||
* -break-insert -t -c 2 main
|
*<ul>
|
||||||
* ^done,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",cond="2",times="0"}
|
* <li>
|
||||||
* (gdb)
|
* -break-insert main
|
||||||
* -break-insert -h -i 2 main
|
* ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",times="0"}
|
||||||
* ^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)
|
||||||
* (gdb)
|
* </li>
|
||||||
|
* <li>
|
||||||
|
* -break-insert -t main
|
||||||
|
* ^done,bkpt={number="2",type="breakpoint",disp="del",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",times="0"}
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
* -break-insert -c 1 main
|
||||||
|
^done,bkpt={number="3",type="breakpoint",disp="keep",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",cond="1",times="0"}
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
* -break-insert -h main
|
||||||
|
* ^done,bkpt={number="4",type="hw breakpoint",disp="keep",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",times="0"}
|
||||||
|
* <li>
|
||||||
|
* -break-insert -p 0 main
|
||||||
|
* ^done,bkpt={number="5",type="breakpoint",disp="keep",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",thread="0",thread="0",times="0"}
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
* -break-insert -a p
|
||||||
|
* ^done,hw-awpt={number="2",exp="p"}
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
* -break-watch -r p
|
||||||
|
* ^done,hw-rwpt={number="4",exp="p"}
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
* -break-watch p
|
||||||
|
* ^done,wpt={number="6",exp="p"}
|
||||||
|
* </li>
|
||||||
|
*</ul>
|
||||||
*/
|
*/
|
||||||
public class MIBreakPoint {
|
public class MIBreakPoint {
|
||||||
|
|
||||||
|
@ -24,11 +52,16 @@ public class MIBreakPoint {
|
||||||
String func = "";
|
String func = "";
|
||||||
String file = "";
|
String file = "";
|
||||||
int line;
|
int line;
|
||||||
|
String cond = "";
|
||||||
int times;
|
int times;
|
||||||
String what = "";
|
String what = "";
|
||||||
String cond = "";
|
String threadId = "";
|
||||||
int ignore;
|
int ignore;
|
||||||
|
|
||||||
|
boolean isWpt;
|
||||||
|
boolean isAWpt;
|
||||||
|
boolean isRWpt;
|
||||||
|
|
||||||
public MIBreakPoint(MITuple tuple) {
|
public MIBreakPoint(MITuple tuple) {
|
||||||
parse(tuple);
|
parse(tuple);
|
||||||
}
|
}
|
||||||
|
@ -41,6 +74,40 @@ public class MIBreakPoint {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isHardware() {
|
||||||
|
return getType().startsWith("hw") || isWatchpoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTemporary() {
|
||||||
|
return getDisposition().equals("del");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWatchpoint() {
|
||||||
|
return isWpt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWatcpoint(boolean w) {
|
||||||
|
isWpt = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAccessWatchpoint() {
|
||||||
|
return isAWpt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccessWatchpoint(boolean a) {
|
||||||
|
isWpt = a;
|
||||||
|
isAWpt = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isReadWatchpoint() {
|
||||||
|
return isRWpt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReadWatchpoint(boolean r) {
|
||||||
|
isWpt = r;
|
||||||
|
isRWpt = r;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDisposition() {
|
public String getDisposition() {
|
||||||
return disp;
|
return disp;
|
||||||
}
|
}
|
||||||
|
@ -85,6 +152,10 @@ public class MIBreakPoint {
|
||||||
return cond;
|
return cond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getThreadId() {
|
||||||
|
return threadId;
|
||||||
|
}
|
||||||
|
|
||||||
void parse(MITuple tuple) {
|
void parse(MITuple tuple) {
|
||||||
MIResult[] results = tuple.getMIResults();
|
MIResult[] results = tuple.getMIResults();
|
||||||
for (int i = 0; i < results.length; i++) {
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
@ -115,6 +186,8 @@ public class MIBreakPoint {
|
||||||
func = str;
|
func = str;
|
||||||
} else if (var.equals("file")) {
|
} else if (var.equals("file")) {
|
||||||
file = str;
|
file = str;
|
||||||
|
} else if (var.equals("thread")) {
|
||||||
|
threadId = str;
|
||||||
} else if (var.equals("line")) {
|
} else if (var.equals("line")) {
|
||||||
try {
|
try {
|
||||||
line = Integer.parseInt(str.trim());
|
line = Integer.parseInt(str.trim());
|
||||||
|
|
|
@ -5,50 +5,14 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.debug.mi.core.output;
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.mi.core.command.MIBreakInsert;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* -break-watch buf
|
* -break-watch buf
|
||||||
* ^done,wpt={number="2",exp="buf"}
|
* ^done,wpt={number="2",exp="buf"}
|
||||||
*/
|
*/
|
||||||
public class MIBreakWatchInfo extends MIInfo {
|
public class MIBreakWatchInfo extends MIBreakInsertInfo {
|
||||||
|
|
||||||
MIBreakPoint[] watchpoints = null;
|
|
||||||
|
|
||||||
public MIBreakWatchInfo(MIOutput rr) {
|
public MIBreakWatchInfo(MIOutput rr) {
|
||||||
super(rr);
|
super(rr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MIBreakPoint[] getBreakpoints () {
|
|
||||||
if (watchpoints == null) {
|
|
||||||
parse();
|
|
||||||
}
|
|
||||||
return watchpoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void parse() {
|
|
||||||
List aList = new ArrayList(1);
|
|
||||||
if (isDone()) {
|
|
||||||
MIOutput out = getMIOutput();
|
|
||||||
MIResultRecord rr = out.getMIResultRecord();
|
|
||||||
if (rr != null) {
|
|
||||||
MIResult[] results = rr.getMIResults();
|
|
||||||
for (int i = 0; i < results.length; i++) {
|
|
||||||
String var = results[i].getVariable();
|
|
||||||
if (var.equals("wpt")) {
|
|
||||||
MIValue val = results[i].getMIValue();
|
|
||||||
if (val instanceof MITuple) {
|
|
||||||
aList.add(new MIBreakPoint((MITuple)val));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
watchpoints = (MIBreakPoint[])aList.toArray(new MIBreakPoint[aList.size()]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ public class MIFrame {
|
||||||
|
|
||||||
int level;
|
int level;
|
||||||
long addr;
|
long addr;
|
||||||
String func;
|
String func = "";
|
||||||
String file;
|
String file = "";
|
||||||
int line;
|
int line;
|
||||||
MIArg[] args = new MIArg[0];
|
MIArg[] args = new MIArg[0];
|
||||||
|
|
||||||
|
@ -24,10 +24,22 @@ public class MIFrame {
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
public String getFunction() {
|
public String getFunction() {
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLine() {
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getAddress() {
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
public int getLevel() {
|
public int getLevel() {
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GDB/MI show parsing.
|
||||||
|
* (gdb)
|
||||||
|
* -gdb-show convenience $_exitcode
|
||||||
|
* ~"$_exitcode = 0"
|
||||||
|
* ~"\n"
|
||||||
|
* ^done
|
||||||
|
*/
|
||||||
|
public class MIGDBShowExitCodeInfo extends MIInfo {
|
||||||
|
|
||||||
|
int code;
|
||||||
|
|
||||||
|
public MIGDBShowExitCodeInfo(MIOutput o) {
|
||||||
|
super(o);
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse() {
|
||||||
|
if (isDone()) {
|
||||||
|
MIOutput out = getMIOutput();
|
||||||
|
MIOOBRecord[] oobs = out.getMIOOBRecords();
|
||||||
|
for (int i = 0; i < oobs.length; i++) {
|
||||||
|
if (oobs[i] instanceof MIConsoleStreamOutput) {
|
||||||
|
MIStreamRecord cons = (MIStreamRecord)oobs[i];
|
||||||
|
String str = cons.getString();
|
||||||
|
if (str.startsWith("$_exitcode")) {
|
||||||
|
int j = str.indexOf('=');
|
||||||
|
if (j != -1) {
|
||||||
|
String sub = str.substring(j + 1).trim();
|
||||||
|
try {
|
||||||
|
code = Integer.parseInt(sub);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,8 @@ package org.eclipse.cdt.debug.mi.core.output;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GDB/MI stack list locals parsing.
|
* GDB/MI stack list locals parsing.
|
||||||
|
* -stack-list-locals 1
|
||||||
|
* ^done,locals=[{name="p",value="0x8048600 \"ghislaine\""},{name="buf",value="\"'\", 'x' <repeats 24 times>, \"i,xxxxxxxxx\", 'a' <repeats 24 times>"},{name="buf2",value="\"\\\"?'\\\\()~\""},{name="buf3",value="\"alain\""},{name="buf4",value="\"\\t\\t\\n\\f\\r\""},{name="i",value="0"}]
|
||||||
*/
|
*/
|
||||||
public class MIStackListLocalsInfo extends MIInfo {
|
public class MIStackListLocalsInfo extends MIInfo {
|
||||||
|
|
||||||
|
|
|
@ -8,4 +8,6 @@ package org.eclipse.cdt.debug.mi.core.output;
|
||||||
* @see MIStreamRecord
|
* @see MIStreamRecord
|
||||||
*/
|
*/
|
||||||
public class MITargetStreamOutput extends MIStreamRecord {
|
public class MITargetStreamOutput extends MIStreamRecord {
|
||||||
|
|
||||||
|
public static final String startTag = "@";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue