mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Added Event dispatching for the MI parser.
This commit is contained in:
parent
fb8ec5c2d4
commit
385d59ed68
27 changed files with 824 additions and 99 deletions
|
@ -2,6 +2,7 @@ package org.eclipse.cdt.debug.mi.core;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.Observable;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.mi.core.command.Command;
|
import org.eclipse.cdt.debug.mi.core.command.Command;
|
||||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||||
|
@ -11,7 +12,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class MISession {
|
public class MISession extends Observable {
|
||||||
|
|
||||||
InputStream inChannel;
|
InputStream inChannel;
|
||||||
OutputStream outChannel;
|
OutputStream outChannel;
|
||||||
|
@ -30,6 +31,12 @@ public class MISession {
|
||||||
|
|
||||||
MIParser parser;
|
MIParser parser;
|
||||||
|
|
||||||
|
long cmdTimeout = 0000; // 20 * 1000 (~ 20 secs);
|
||||||
|
|
||||||
|
final int STOPPED = 0;
|
||||||
|
final int RUNNING = 1;
|
||||||
|
int state = STOPPED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor.
|
* The constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -95,20 +102,63 @@ public class MISession {
|
||||||
parser = p;
|
parser = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* postCommand(cmd, 20 secs)
|
||||||
|
*/
|
||||||
|
public void postCommand(Command cmd) throws MIException {
|
||||||
|
postCommand(cmd, cmdTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommandTimeout(long timeout) {
|
||||||
|
cmdTimeout = timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCommandTimeout() {
|
||||||
|
return cmdTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void postCommand(Command cmd) {
|
public void postCommand(Command cmd, long timeout) throws MIException {
|
||||||
|
|
||||||
|
if (!txThread.isAlive()) {
|
||||||
|
throw new MIException("TxThread terminated");
|
||||||
|
}
|
||||||
txQueue.addCommand(cmd);
|
txQueue.addCommand(cmd);
|
||||||
synchronized (cmd) {
|
synchronized (cmd) {
|
||||||
try {
|
// RxThread will set the MIOutput on the cmd
|
||||||
// FIXME: missing the predicate
|
// when the response arrive.
|
||||||
cmd.wait();
|
while (cmd.getMIOutput() == null) {
|
||||||
} catch (InterruptedException e) {
|
try {
|
||||||
|
cmd.wait(timeout);
|
||||||
|
break; // Timeout or Notify
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isStopped() {
|
||||||
|
return state == STOPPED;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRunning() {
|
||||||
|
return state == RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setStopped() {
|
||||||
|
state = STOPPED;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setRunning() {
|
||||||
|
state = RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDirty() {
|
||||||
|
setChanged();
|
||||||
|
}
|
||||||
|
|
||||||
Queue getTxQueue() {
|
Queue getTxQueue() {
|
||||||
return txQueue;
|
return txQueue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,25 @@ package org.eclipse.cdt.debug.mi.core;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.mi.core.command.Command;
|
import org.eclipse.cdt.debug.mi.core.command.Command;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIAsyncRecord;
|
import org.eclipse.cdt.debug.mi.core.event.EventThread;
|
||||||
|
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.MISignalEvent;
|
||||||
|
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.output.MIConst;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIOOBRecord;
|
import org.eclipse.cdt.debug.mi.core.output.MIOOBRecord;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIResult;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
|
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIValue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
@ -19,7 +32,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
|
||||||
|
|
||||||
public class RxThread extends Thread {
|
public class RxThread extends Thread {
|
||||||
|
|
||||||
MISession session;
|
final MISession session;
|
||||||
|
|
||||||
public RxThread(MISession s) {
|
public RxThread(MISession s) {
|
||||||
super("MI RX Thread");
|
super("MI RX Thread");
|
||||||
|
@ -29,7 +42,7 @@ public class RxThread extends Thread {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the response, parse the output, dispatch for OOB
|
* Get the response, parse the output, dispatch for OOB
|
||||||
* search for the corresponding token in rxQueue.
|
* search for the corresponding token in rxQueue for the ResultRecord.
|
||||||
*/
|
*/
|
||||||
public void run () {
|
public void run () {
|
||||||
BufferedReader reader =
|
BufferedReader reader =
|
||||||
|
@ -40,6 +53,7 @@ public class RxThread extends Thread {
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
if (line.startsWith("(gdb)")) {
|
if (line.startsWith("(gdb)")) {
|
||||||
|
// discard termination
|
||||||
processMIOutput(buffer.toString());
|
processMIOutput(buffer.toString());
|
||||||
buffer = new StringBuffer();
|
buffer = new StringBuffer();
|
||||||
} else {
|
} else {
|
||||||
|
@ -52,14 +66,29 @@ public class RxThread extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for the command in the RxQueue, set the MIOutput
|
||||||
|
* and notify() the other end.
|
||||||
|
* Any OOBs are consider like event and dipatch to the
|
||||||
|
* listeners/observers in different thread.
|
||||||
|
*/
|
||||||
void processMIOutput(String buffer) {
|
void processMIOutput(String buffer) {
|
||||||
MIOutput response = session.parse(buffer);
|
MIOutput response = session.parse(buffer);
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
|
List list = new ArrayList();
|
||||||
Queue rxQueue = session.getRxQueue();
|
Queue rxQueue = session.getRxQueue();
|
||||||
|
|
||||||
// Notify any command waiting for a ResultRecord.
|
// Notify any command waiting for a ResultRecord.
|
||||||
MIResultRecord rr = response.getMIResultRecord();
|
MIResultRecord rr = response.getMIResultRecord();
|
||||||
if (rr != null) {
|
if (rr != null) {
|
||||||
|
// Check if the state changed.
|
||||||
|
String state = rr.getResultClass();
|
||||||
|
if ("running".equals(state)) {
|
||||||
|
session.setRunning();
|
||||||
|
} else {
|
||||||
|
session.setStopped();
|
||||||
|
}
|
||||||
|
|
||||||
int id = rr.geToken();
|
int id = rr.geToken();
|
||||||
Command cmd = rxQueue.removeCommand(id);
|
Command cmd = rxQueue.removeCommand(id);
|
||||||
if (cmd != null) {
|
if (cmd != null) {
|
||||||
|
@ -68,25 +97,126 @@ public class RxThread extends Thread {
|
||||||
cmd.notifyAll();
|
cmd.notifyAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Some result record contains informaton specific to oob.
|
||||||
|
// This will happen when CLI-Command is use, for example
|
||||||
|
// doing "run" will block and return a breakpointhit
|
||||||
|
processMIOOBRecord(rr, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
// A command may wait on a specific oob, like breakpointhit
|
// Process OOBs
|
||||||
MIOOBRecord[] oobs = response.getMIOOBRecords();
|
MIOOBRecord[] oobs = response.getMIOOBRecords();
|
||||||
for (int i = 0; i < oobs.length; i++) {
|
for (int i = 0; i < oobs.length; i++) {
|
||||||
if (oobs[i] instanceof MIAsyncRecord) {
|
processMIOOBRecord(oobs[i], list);
|
||||||
int id = ((MIAsyncRecord)oobs[i]).getToken();
|
}
|
||||||
Command cmd = rxQueue.removeCommand(id);
|
|
||||||
if (cmd != null) {
|
MIEvent[] events = (MIEvent[])list.toArray(new MIEvent[list.size()]);
|
||||||
cmd.setMIOutput(response);
|
if (events.length > 0) {
|
||||||
cmd.notifyAll();
|
Thread eventTread = new EventThread(session, events);
|
||||||
}
|
eventTread.start();
|
||||||
}
|
|
||||||
processMIOOBRecord(oobs[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void processMIOOBRecord(MIOOBRecord oob) {
|
/**
|
||||||
// Dispatch a thread to deal with the listeners.
|
* Dispatch a thread to deal with the listeners.
|
||||||
|
*/
|
||||||
|
void processMIOOBRecord(MIOOBRecord oob, List list) {
|
||||||
|
if (oob instanceof MIExecAsyncOutput) {
|
||||||
|
MIExecAsyncOutput exec = (MIExecAsyncOutput)oob;
|
||||||
|
|
||||||
|
// Change of state.
|
||||||
|
String state = exec.getAsyncClass();
|
||||||
|
if ("stopped".equals(state)) {
|
||||||
|
session.setStopped();
|
||||||
|
}
|
||||||
|
|
||||||
|
MIResult[] results = exec.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
if (var.equals("reason")) {
|
||||||
|
if (value instanceof MIConst) {
|
||||||
|
String reason = ((MIConst)value).getString();
|
||||||
|
MIEvent e = createEvent(reason, exec);
|
||||||
|
if (e != null) {
|
||||||
|
list.add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatch a thread to deal with the listeners.
|
||||||
|
*/
|
||||||
|
void processMIOOBRecord(MIResultRecord rr, List list) {
|
||||||
|
MIResult[] results = rr.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
if (var.equals("reason")) {
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
if (value instanceof MIConst) {
|
||||||
|
String reason = ((MIConst)value).getString();
|
||||||
|
MIEvent event = createEvent(reason, rr);
|
||||||
|
if (event != null) {
|
||||||
|
list.add(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MIEvent createEvent(String reason, MIExecAsyncOutput exec) {
|
||||||
|
return createEvent(reason, null, exec);
|
||||||
|
}
|
||||||
|
|
||||||
|
MIEvent createEvent(String reason, MIResultRecord rr) {
|
||||||
|
return createEvent(reason, rr, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
MIEvent createEvent(String reason, MIResultRecord rr, MIExecAsyncOutput exec) {
|
||||||
|
MIEvent event = null;
|
||||||
|
if ("breakpoint-hit".equals(reason)) {
|
||||||
|
if (exec != null) {
|
||||||
|
event = new MIBreakpointEvent(exec);
|
||||||
|
} else if (rr != null) {
|
||||||
|
event = new MIBreakpointEvent(rr);
|
||||||
|
}
|
||||||
|
} else if ("watchpoint-trigger".equals(reason)) {
|
||||||
|
if (exec != null) {
|
||||||
|
event = new MIWatchpointEvent(exec);
|
||||||
|
} else if (rr != null) {
|
||||||
|
event = new MIWatchpointEvent(rr);
|
||||||
|
}
|
||||||
|
} else if ("end-stepping-range".equals(reason)) {
|
||||||
|
if (exec != null) {
|
||||||
|
event = new MIStepEvent(exec);
|
||||||
|
} else if (rr != null) {
|
||||||
|
event = new MIStepEvent(rr);
|
||||||
|
}
|
||||||
|
} else if ("signal-received".equals(reason)) {
|
||||||
|
if (exec != null) {
|
||||||
|
event = new MISignalEvent(exec);
|
||||||
|
} else if (rr != null) {
|
||||||
|
event = new MISignalEvent(rr);
|
||||||
|
}
|
||||||
|
} else if ("location-reached".equals(reason)) {
|
||||||
|
if (exec != null) {
|
||||||
|
event = new MISignalEvent(exec);
|
||||||
|
} else if (rr != null) {
|
||||||
|
event = new MISignalEvent(rr);
|
||||||
|
}
|
||||||
|
} else if ("function-finished".equals(reason)) {
|
||||||
|
if (exec != null) {
|
||||||
|
event = new MIFunctionFinishedEvent(exec);
|
||||||
|
} else if (rr != null) {
|
||||||
|
event = new MIFunctionFinishedEvent(rr);
|
||||||
|
}
|
||||||
|
} else if ("exited-normally".equals(reason)) {
|
||||||
|
event = new MIExitEvent();
|
||||||
|
}
|
||||||
|
return event;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,36 +23,32 @@ public class TxThread extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run () {
|
public void run () {
|
||||||
while (true) {
|
try {
|
||||||
Command cmd = null;
|
while (true) {
|
||||||
Queue txQueue = session.getTxQueue();
|
Command cmd = null;
|
||||||
// The removeCommand will block until a command is available.
|
Queue txQueue = session.getTxQueue();
|
||||||
try {
|
// removeCommand() will block until a command is available.
|
||||||
cmd = txQueue.removeCommand();
|
|
||||||
} catch (Exception e) {
|
|
||||||
//e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// The command is then:
|
|
||||||
// - given a Id/token
|
|
||||||
// - shove in the pipe
|
|
||||||
// - Remove from the TxQueue
|
|
||||||
// - Move to the RxQueue
|
|
||||||
if (cmd != null) {
|
|
||||||
OutputStream out = session.getChannelOutputStream();
|
|
||||||
cmd.setToken(token);
|
|
||||||
//System.out.println("Tx " + cmd.toString());
|
|
||||||
try {
|
try {
|
||||||
String str = cmd.toString();
|
cmd = txQueue.removeCommand();
|
||||||
out.write(str.getBytes());
|
} catch (Exception e) {
|
||||||
out.flush();
|
|
||||||
} catch (IOException e) {
|
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
}
|
}
|
||||||
Queue rxQueue = session.getRxQueue();
|
|
||||||
rxQueue.addCommand(cmd);
|
if (cmd != null) {
|
||||||
token++;
|
// Give the command a token and increment.
|
||||||
|
cmd.setToken(token++);
|
||||||
|
// shove in the pipe
|
||||||
|
String str = cmd.toString();
|
||||||
|
OutputStream out = session.getChannelOutputStream();
|
||||||
|
out.write(str.getBytes());
|
||||||
|
out.flush();
|
||||||
|
// Move to the RxQueue
|
||||||
|
Queue rxQueue = session.getRxQueue();
|
||||||
|
rxQueue.addCommand(cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
//e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,10 @@ package org.eclipse.cdt.debug.mi.core.command;
|
||||||
*/
|
*/
|
||||||
public class MIExecRun extends MICommand
|
public class MIExecRun extends MICommand
|
||||||
{
|
{
|
||||||
|
public MIExecRun() {
|
||||||
|
super("-exec-run");
|
||||||
|
}
|
||||||
|
|
||||||
public MIExecRun(String[] args) {
|
public MIExecRun(String[] args) {
|
||||||
super("-exec-run", args);
|
super("-exec-run", args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.event;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.mi.core.MISession;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class EventThread extends Thread {
|
||||||
|
|
||||||
|
final MISession session;
|
||||||
|
final MIEvent[] events;
|
||||||
|
|
||||||
|
public EventThread(MISession s, MIEvent[] evts) {
|
||||||
|
super("MI Event Thread");
|
||||||
|
session = s;
|
||||||
|
events = evts;
|
||||||
|
setDaemon(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*/
|
||||||
|
public void run () {
|
||||||
|
session.setDirty();
|
||||||
|
session.notifyObservers(events);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,27 +1,34 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.output;
|
package org.eclipse.cdt.debug.mi.core.event;
|
||||||
|
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIConst;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIFrame;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIResult;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MITuple;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ^done,reason="breakpoint-hit",bkptno="1",thread-id="0",frame={addr="0x08048468",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbffff18c"}],file="hello.c",line="4"}
|
* ^done,reason="breakpoint-hit",bkptno="1",thread-id="0",frame={addr="0x08048468",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbffff18c"}],file="hello.c",line="4"}
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MIBreakHitInfo {
|
public class MIBreakpointEvent extends MIEvent {
|
||||||
|
|
||||||
int bkptno;
|
int bkptno;
|
||||||
int threadId;
|
int threadId;
|
||||||
MIFrame frame;
|
MIFrame frame;
|
||||||
String file = "";
|
|
||||||
int line;
|
|
||||||
MIExecAsyncOutput exec;
|
MIExecAsyncOutput exec;
|
||||||
MIResultRecord rr;
|
MIResultRecord rr;
|
||||||
|
|
||||||
public MIBreakHitInfo(MIExecAsyncOutput record) {
|
public MIBreakpointEvent(MIExecAsyncOutput record) {
|
||||||
exec = record;
|
exec = record;
|
||||||
|
parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MIBreakHitInfo(MIResultRecord record) {
|
public MIBreakpointEvent(MIResultRecord record) {
|
||||||
rr = record;
|
rr = record;
|
||||||
|
parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBreakNumber() {
|
public int getBreakNumber() {
|
||||||
|
@ -36,12 +43,12 @@ public class MIBreakHitInfo {
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFile() {
|
public String toString() {
|
||||||
return file;
|
StringBuffer buffer = new StringBuffer();
|
||||||
}
|
buffer.append("number=").append(bkptno).append('\n');
|
||||||
|
buffer.append("thread-id=").append(threadId).append('\n');
|
||||||
public int getLine() {
|
buffer.append(frame.toString());
|
||||||
return line;
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse () {
|
void parse () {
|
||||||
|
@ -62,25 +69,18 @@ public class MIBreakHitInfo {
|
||||||
|
|
||||||
if (var.equals("bkptno")) {
|
if (var.equals("bkptno")) {
|
||||||
try {
|
try {
|
||||||
bkptno = Integer.parseInt(str);
|
bkptno = Integer.parseInt(str.trim());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("thread-id")) {
|
} else if (var.equals("thread-id")) {
|
||||||
try {
|
try {
|
||||||
threadId = Integer.parseInt(str);
|
threadId = Integer.parseInt(str.trim());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("frame")) {
|
} else if (var.equals("frame")) {
|
||||||
if (value instanceof MITuple) {
|
if (value instanceof MITuple) {
|
||||||
frame = new MIFrame((MITuple)value);
|
frame = new MIFrame((MITuple)value);
|
||||||
}
|
}
|
||||||
} else if (var.equals("file")) {
|
|
||||||
file = str;
|
|
||||||
} else if (var.equals("line")) {
|
|
||||||
try {
|
|
||||||
line = Integer.parseInt(str);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public abstract class MIEvent {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.event;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* *stopped,reason="exited-normally"
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MIExitEvent extends MIEvent {
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.event;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIConst;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIFrame;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIResult;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MITuple;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* *stopped,reason="function-finished",thread-id="0",frame={addr="0x0804855a",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbffff18c"}],file="hello.c",line="17"},gdb-result-var="$1",return-value="10"
|
||||||
|
*/
|
||||||
|
public class MIFunctionFinishedEvent extends MIEvent {
|
||||||
|
|
||||||
|
String gdbResult = "";
|
||||||
|
String returnValue = "";
|
||||||
|
int threadId;
|
||||||
|
MIFrame frame;
|
||||||
|
|
||||||
|
MIExecAsyncOutput exec;
|
||||||
|
MIResultRecord rr;
|
||||||
|
|
||||||
|
public MIFunctionFinishedEvent(MIExecAsyncOutput record) {
|
||||||
|
exec = record;
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIFunctionFinishedEvent(MIResultRecord record) {
|
||||||
|
rr = record;
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGDBResultVar() {
|
||||||
|
return gdbResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReturnValue() {
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getThreadId() {
|
||||||
|
return threadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIFrame getFrame() {
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("gdb-result-var=" + gdbResult + "\n");;
|
||||||
|
buffer.append("return-value=" + returnValue + "\n");
|
||||||
|
buffer.append("thread-id=").append(threadId).append('\n');
|
||||||
|
buffer.append(frame.toString());
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse () {
|
||||||
|
MIResult[] results = null;
|
||||||
|
if (exec != null) {
|
||||||
|
results = exec.getMIResults();
|
||||||
|
} else if (rr != null) {
|
||||||
|
results = rr.getMIResults();
|
||||||
|
}
|
||||||
|
if (results != null) {
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
String str = "";
|
||||||
|
if (value instanceof MIConst) {
|
||||||
|
str = ((MIConst)value).getString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var.equals("gdb-result-var")) {
|
||||||
|
gdbResult = str;
|
||||||
|
} else if (var.equals("return-value")) {
|
||||||
|
returnValue = str;
|
||||||
|
} else if (var.equals("thread-id")) {
|
||||||
|
try {
|
||||||
|
threadId = Integer.parseInt(str.trim());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("frame")) {
|
||||||
|
if (value instanceof MITuple) {
|
||||||
|
frame = new MIFrame((MITuple)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.event;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIConst;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIFrame;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIResult;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MITuple;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* *stopped,reason="location-reached",thread-id="0",frame={addr="0x0804858e",func="main2",args=[],file="hello.c",line="27"}
|
||||||
|
*/
|
||||||
|
public class MILocationReachedEvent extends MIEvent {
|
||||||
|
|
||||||
|
int threadId;
|
||||||
|
MIFrame frame;
|
||||||
|
|
||||||
|
MIExecAsyncOutput exec;
|
||||||
|
MIResultRecord rr;
|
||||||
|
|
||||||
|
public MILocationReachedEvent(MIExecAsyncOutput record) {
|
||||||
|
exec = record;
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MILocationReachedEvent(MIResultRecord record) {
|
||||||
|
rr = record;
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getThreadId() {
|
||||||
|
return threadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIFrame getFrame() {
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("thread-id=").append(threadId).append('\n');
|
||||||
|
buffer.append(frame.toString());
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse () {
|
||||||
|
MIResult[] results = null;
|
||||||
|
if (exec != null) {
|
||||||
|
results = exec.getMIResults();
|
||||||
|
} else if (rr != null) {
|
||||||
|
results = rr.getMIResults();
|
||||||
|
}
|
||||||
|
if (results != null) {
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
String str = "";
|
||||||
|
if (value instanceof MIConst) {
|
||||||
|
str = ((MIConst)value).getString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var.equals("thread-id")) {
|
||||||
|
try {
|
||||||
|
threadId = Integer.parseInt(str.trim());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("frame")) {
|
||||||
|
if (value instanceof MITuple) {
|
||||||
|
frame = new MIFrame((MITuple)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.event;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIConst;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIFrame;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIResult;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MITuple;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* *stopped,reason="signal-received",signal-name="SIGINT",signal-meaning="Interrupt",thread-id="0",frame={addr="0x400e18e1",func="__libc_nanosleep",args=[],file="__libc_nanosleep",line="-1"}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MISignalEvent extends MIEvent {
|
||||||
|
|
||||||
|
String sigName = "";
|
||||||
|
String sigMeaning = "";
|
||||||
|
int threadId;
|
||||||
|
MIFrame frame;
|
||||||
|
|
||||||
|
MIExecAsyncOutput exec;
|
||||||
|
MIResultRecord rr;
|
||||||
|
|
||||||
|
public MISignalEvent(MIExecAsyncOutput record) {
|
||||||
|
exec = record;
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MISignalEvent(MIResultRecord record) {
|
||||||
|
rr = record;
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSignalName() {
|
||||||
|
return sigName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSignalMeaning() {
|
||||||
|
return sigMeaning;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getThreadId() {
|
||||||
|
return threadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIFrame getFrame() {
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("signal-name=" + sigName + "\n");;
|
||||||
|
buffer.append("signal-meaning=" + sigMeaning + "\n");;
|
||||||
|
buffer.append("thread-id=").append(threadId).append('\n');
|
||||||
|
buffer.append(frame.toString());
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse () {
|
||||||
|
MIResult[] results = null;
|
||||||
|
if (exec != null) {
|
||||||
|
results = exec.getMIResults();
|
||||||
|
} else if (rr != null) {
|
||||||
|
results = rr.getMIResults();
|
||||||
|
}
|
||||||
|
if (results != null) {
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
String str = "";
|
||||||
|
if (value instanceof MIConst) {
|
||||||
|
str = ((MIConst)value).getString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var.equals("signal-name")) {
|
||||||
|
sigName = str;
|
||||||
|
} else if (var.equals("signal-meaning")) {
|
||||||
|
sigMeaning = str;
|
||||||
|
} else if (var.equals("thread-id")) {
|
||||||
|
try {
|
||||||
|
threadId = Integer.parseInt(str.trim());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else if (var.equals("frame")) {
|
||||||
|
if (value instanceof MITuple) {
|
||||||
|
frame = new MIFrame((MITuple)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.event;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIConst;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIFrame;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIResult;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MITuple;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* *stopped,reason="end-stepping-range",thread-id="0",frame={addr="0x08048538",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbffff18c"}],file="hello.c",line="13"}
|
||||||
|
*/
|
||||||
|
public class MIStepEvent extends MIEvent {
|
||||||
|
|
||||||
|
int threadId;
|
||||||
|
MIFrame frame;
|
||||||
|
|
||||||
|
MIExecAsyncOutput exec;
|
||||||
|
MIResultRecord rr;
|
||||||
|
|
||||||
|
public MIStepEvent(MIExecAsyncOutput record) {
|
||||||
|
exec = record;
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIStepEvent(MIResultRecord record) {
|
||||||
|
rr = record;
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getThreadId() {
|
||||||
|
return threadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIFrame getFrame() {
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("thread-id=").append(threadId).append('\n');
|
||||||
|
buffer.append(frame.toString());
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse () {
|
||||||
|
MIResult[] results = null;
|
||||||
|
if (exec != null) {
|
||||||
|
results = exec.getMIResults();
|
||||||
|
} else if (rr != null) {
|
||||||
|
results = rr.getMIResults();
|
||||||
|
}
|
||||||
|
if (results != null) {
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
|
||||||
|
if (var.equals("thread-id")) {
|
||||||
|
if (value instanceof MIConst) {
|
||||||
|
String str = ((MIConst)value).getString();
|
||||||
|
try {
|
||||||
|
threadId = Integer.parseInt(str.trim());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (var.equals("frame")) {
|
||||||
|
if (value instanceof MITuple) {
|
||||||
|
frame = new MIFrame((MITuple)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,149 @@
|
||||||
|
package org.eclipse.cdt.debug.mi.core.event;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIConst;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIFrame;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIResult;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MITuple;
|
||||||
|
import org.eclipse.cdt.debug.mi.core.output.MIValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* *stopped,reason="watchpoint-trigger",wpt={number="2",exp="i"},value={old="0",new="1"},thread-id="0",frame={addr="0x08048534",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbffff18c"}],file="hello.c",line="10"}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MIWatchpointEvent extends MIEvent {
|
||||||
|
|
||||||
|
int number;
|
||||||
|
String exp = "";
|
||||||
|
String oldValue = "";
|
||||||
|
String newValue = "";
|
||||||
|
int threadId;
|
||||||
|
MIFrame frame;
|
||||||
|
|
||||||
|
MIExecAsyncOutput exec;
|
||||||
|
MIResultRecord rr;
|
||||||
|
|
||||||
|
public MIWatchpointEvent(MIExecAsyncOutput record) {
|
||||||
|
exec = record;
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIWatchpointEvent(MIResultRecord record) {
|
||||||
|
rr = record;
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumber() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExpression() {
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOldValue() {
|
||||||
|
return oldValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNewValue() {
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getThreadId() {
|
||||||
|
return threadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MIFrame getFrame() {
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("number=").append(number).append('\n');
|
||||||
|
buffer.append("expression=" + exp + "\n");
|
||||||
|
;
|
||||||
|
buffer.append("old=" + oldValue + "\n");
|
||||||
|
buffer.append("new=" + newValue + "\n");
|
||||||
|
buffer.append("thread-id=").append(threadId).append('\n');
|
||||||
|
buffer.append(frame.toString());
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse() {
|
||||||
|
MIResult[] results = null;
|
||||||
|
if (exec != null) {
|
||||||
|
results = exec.getMIResults();
|
||||||
|
} else if (rr != null) {
|
||||||
|
results = rr.getMIResults();
|
||||||
|
}
|
||||||
|
if (results != null) {
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
|
||||||
|
if (var.equals("wpt")) {
|
||||||
|
if (value instanceof MITuple) {
|
||||||
|
parseWPT((MITuple) value);
|
||||||
|
}
|
||||||
|
} else if (var.equals("value")) {
|
||||||
|
if (value instanceof MITuple) {
|
||||||
|
parseValue((MITuple) value);
|
||||||
|
}
|
||||||
|
} else if (var.equals("thread-id")) {
|
||||||
|
if (value instanceof MIConst) {
|
||||||
|
String str = ((MIConst) value).getString();
|
||||||
|
try {
|
||||||
|
threadId = Integer.parseInt(str.trim());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (var.equals("frame")) {
|
||||||
|
if (value instanceof MITuple) {
|
||||||
|
frame = new MIFrame((MITuple) value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void parseWPT(MITuple tuple) {
|
||||||
|
MIResult[] results = tuple.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
|
||||||
|
if (var.equals("number")) {
|
||||||
|
if (value instanceof MIConst) {
|
||||||
|
String str = ((MIConst) value).getString();
|
||||||
|
try {
|
||||||
|
number = Integer.parseInt(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (var.equals("exp")) {
|
||||||
|
if (value instanceof MIConst) {
|
||||||
|
exp = ((MIConst) value).getString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void parseValue(MITuple tuple) {
|
||||||
|
MIResult[] results = tuple.getMIResults();
|
||||||
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
String var = results[i].getVariable();
|
||||||
|
MIValue value = results[i].getMIValue();
|
||||||
|
String str = "";
|
||||||
|
if (value instanceof MIConst) {
|
||||||
|
str = ((MIConst) value).getString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (var.equals("old")) {
|
||||||
|
oldValue = str;
|
||||||
|
} else if (var.equals("new")) {
|
||||||
|
newValue = str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -77,21 +77,21 @@ public class MIAsm {
|
||||||
|
|
||||||
if (var.equals("address")) {
|
if (var.equals("address")) {
|
||||||
try {
|
try {
|
||||||
address = Long.decode(str).longValue();
|
address = Long.decode(str.trim()).longValue();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("func-name")) {
|
} else if (var.equals("func-name")) {
|
||||||
func = str;
|
func = str;
|
||||||
} else if (var.equals("offset")) {
|
} else if (var.equals("offset")) {
|
||||||
try {
|
try {
|
||||||
offset = Long.decode(str).longValue();
|
offset = Long.decode(str.trim()).longValue();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("inst")) {
|
} else if (var.equals("inst")) {
|
||||||
inst = str;
|
inst = str;
|
||||||
} else if (var.equals("line")) {
|
} else if (var.equals("line")) {
|
||||||
try {
|
try {
|
||||||
line = Integer.parseInt(str);
|
line = Integer.parseInt(str.trim());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("file")) {
|
} else if (var.equals("file")) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class MIBreakPoint {
|
||||||
|
|
||||||
if (var.equals("number")) {
|
if (var.equals("number")) {
|
||||||
try {
|
try {
|
||||||
number = Integer.parseInt(str);
|
number = Integer.parseInt(str.trim());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("type")) {
|
} else if (var.equals("type")) {
|
||||||
|
@ -82,7 +82,7 @@ public class MIBreakPoint {
|
||||||
enabled = str.equals("y");
|
enabled = str.equals("y");
|
||||||
} else if (var.equals("addr")) {
|
} else if (var.equals("addr")) {
|
||||||
try {
|
try {
|
||||||
address = Long.decode(str).longValue();
|
address = Long.decode(str.trim()).longValue();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("func")) {
|
} else if (var.equals("func")) {
|
||||||
|
@ -91,12 +91,12 @@ public class MIBreakPoint {
|
||||||
file = str;
|
file = str;
|
||||||
} else if (var.equals("line")) {
|
} else if (var.equals("line")) {
|
||||||
try {
|
try {
|
||||||
line = Integer.parseInt(str);
|
line = Integer.parseInt(str.trim());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("times")) {
|
} else if (var.equals("times")) {
|
||||||
try {
|
try {
|
||||||
times = Integer.parseInt(str);
|
times = Integer.parseInt(str.trim());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("what") || var.equals("exp")) {
|
} else if (var.equals("what") || var.equals("exp")) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class MIDataListChangedRegistersInfo extends MIInfo {
|
||||||
for (int i = 0; i < aList.size(); i++) {
|
for (int i = 0; i < aList.size(); i++) {
|
||||||
String str = (String)aList.get(i);
|
String str = (String)aList.get(i);
|
||||||
try {
|
try {
|
||||||
registers[i] = Integer.parseInt(str);
|
registers[i] = Integer.parseInt(str.trim());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,37 +110,37 @@ public class MIDataReadMemoryInfo extends MIInfo {
|
||||||
|
|
||||||
if (var.equals("addr")) {
|
if (var.equals("addr")) {
|
||||||
try {
|
try {
|
||||||
addr = Long.decode(str).longValue();
|
addr = Long.decode(str.trim()).longValue();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("nr-bytes")) {
|
} else if (var.equals("nr-bytes")) {
|
||||||
try {
|
try {
|
||||||
numBytes = Long.decode(str).longValue();
|
numBytes = Long.decode(str.trim()).longValue();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("total-bytes")) {
|
} else if (var.equals("total-bytes")) {
|
||||||
try {
|
try {
|
||||||
totalBytes = Long.decode(str).longValue();
|
totalBytes = Long.decode(str.trim()).longValue();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("next-row")) {
|
} else if (var.equals("next-row")) {
|
||||||
try {
|
try {
|
||||||
nextRow = Long.decode(str).longValue();
|
nextRow = Long.decode(str.trim()).longValue();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("prev-row")) {
|
} else if (var.equals("prev-row")) {
|
||||||
try {
|
try {
|
||||||
prevRow = Long.decode(str).longValue();
|
prevRow = Long.decode(str.trim()).longValue();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("next-page")) {
|
} else if (var.equals("next-page")) {
|
||||||
try {
|
try {
|
||||||
nextPage = Long.decode(str).longValue();
|
nextPage = Long.decode(str.trim()).longValue();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("prev-page")) {
|
} else if (var.equals("prev-page")) {
|
||||||
try {
|
try {
|
||||||
prevPage = Long.decode(str).longValue();
|
prevPage = Long.decode(str.trim()).longValue();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("memory")) {
|
} else if (var.equals("memory")) {
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class MIFrame {
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
buffer.append(',');
|
buffer.append(',');
|
||||||
}
|
}
|
||||||
buffer.append("{name=\"" + args[i].getName());
|
buffer.append("{name=\"" + args[i].getName() + "\"");
|
||||||
buffer.append(",value=\"" + args[i].getValue() + "}");
|
buffer.append(",value=\"" + args[i].getValue() + "\"}");
|
||||||
}
|
}
|
||||||
buffer.append(']');
|
buffer.append(']');
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
|
@ -58,12 +58,12 @@ public class MIFrame {
|
||||||
|
|
||||||
if (var.equals("level")) {
|
if (var.equals("level")) {
|
||||||
try {
|
try {
|
||||||
level = Integer.parseInt(str);
|
level = Integer.parseInt(str.trim());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("addr")) {
|
} else if (var.equals("addr")) {
|
||||||
try {
|
try {
|
||||||
addr = Long.decode(str).longValue();
|
addr = Long.decode(str.trim()).longValue();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("func")) {
|
} else if (var.equals("func")) {
|
||||||
|
@ -72,7 +72,7 @@ public class MIFrame {
|
||||||
file = str;
|
file = str;
|
||||||
} else if (var.equals("line")) {
|
} else if (var.equals("line")) {
|
||||||
try {
|
try {
|
||||||
line = Integer.parseInt(str);
|
line = Integer.parseInt(str.trim());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("args")) {
|
} else if (var.equals("args")) {
|
||||||
|
|
|
@ -30,9 +30,15 @@ public class MIList extends MIValue {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append('[');
|
buffer.append('[');
|
||||||
for (int i = 0; i < results.length; i++) {
|
for (int i = 0; i < results.length; i++) {
|
||||||
|
if (i != 0) {
|
||||||
|
buffer.append(',');
|
||||||
|
}
|
||||||
buffer.append(results[i].toString());
|
buffer.append(results[i].toString());
|
||||||
}
|
}
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
if (i != 0) {
|
||||||
|
buffer.append(',');
|
||||||
|
}
|
||||||
buffer.append(values[i].toString());
|
buffer.append(values[i].toString());
|
||||||
}
|
}
|
||||||
buffer.append(']');
|
buffer.append(']');
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class MIMemory {
|
||||||
|
|
||||||
if (var.equals("addr")) {
|
if (var.equals("addr")) {
|
||||||
try {
|
try {
|
||||||
addr = Long.decode(str).longValue();
|
addr = Long.decode(str.trim()).longValue();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
} else if (var.equals("data")) {
|
} else if (var.equals("data")) {
|
||||||
|
@ -72,7 +72,7 @@ public class MIMemory {
|
||||||
if (values[i] instanceof MIConst) {
|
if (values[i] instanceof MIConst) {
|
||||||
String str = ((MIConst)values[i]).getString();
|
String str = ((MIConst)values[i]).getString();
|
||||||
try {
|
try {
|
||||||
data[i] = Long.decode(str).longValue();
|
data[i] = Long.decode(str.trim()).longValue();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
data[i] = 0;
|
data[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ public class MIOutput {
|
||||||
if (rr != null) {
|
if (rr != null) {
|
||||||
buffer.append(rr.toString());
|
buffer.append(rr.toString());
|
||||||
}
|
}
|
||||||
buffer.append(terminator + "\n");
|
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,6 +261,7 @@ public class MIParser {
|
||||||
result.setMIValue(value);
|
result.setMIValue(value);
|
||||||
} else {
|
} else {
|
||||||
result.setVariable(buffer.toString());
|
result.setVariable(buffer.toString());
|
||||||
|
result.setMIValue(new MIConst()); // Empty string:???
|
||||||
buffer.setLength(0);
|
buffer.setLength(0);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -76,8 +76,8 @@ public class MIRegisterValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int reg = Integer.parseInt(aName);
|
int reg = Integer.parseInt(aName.trim());
|
||||||
long val = Long.decode(aValue).longValue();
|
long val = Long.decode(aValue.trim()).longValue();
|
||||||
arg = new MIRegisterValue(reg, val);
|
arg = new MIRegisterValue(reg, val);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,17 @@ public class MIResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append(variable);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
return variable + "=" + value.toString();
|
String v = value.toString();
|
||||||
|
buffer.append('=');
|
||||||
|
if (v.charAt(0) == '[' || v.charAt(0) =='{') {
|
||||||
|
buffer.append(v);
|
||||||
|
} else {
|
||||||
|
buffer.append("\"" + value.toString() + "\"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return variable;
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class MIStackInfoDepthInfo extends MIInfo {
|
||||||
if (val instanceof MIConst) {
|
if (val instanceof MIConst) {
|
||||||
String str = ((MIConst)val).getString();
|
String str = ((MIConst)val).getString();
|
||||||
try {
|
try {
|
||||||
depth = Integer.parseInt(str);
|
depth = Integer.parseInt(str.trim());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class MIThreadListIdsInfo extends MIInfo {
|
||||||
if (value instanceof MIConst) {
|
if (value instanceof MIConst) {
|
||||||
String str = ((MIConst)value).getString();
|
String str = ((MIConst)value).getString();
|
||||||
try {
|
try {
|
||||||
threadIds[i] = Integer.parseInt(str);
|
threadIds[i] = Integer.parseInt(str.trim());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class MIThreadSelectInfo extends MIInfo {
|
||||||
if (value instanceof MIConst) {
|
if (value instanceof MIConst) {
|
||||||
String str = ((MIConst)value).getString();
|
String str = ((MIConst)value).getString();
|
||||||
try {
|
try {
|
||||||
threadId = Integer.parseInt(str);
|
threadId = Integer.parseInt(str.trim());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue