1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 16:56:04 +02:00

2004-11-07 Alain Magloire

Support for MIInterpreterExec
This commit is contained in:
Alain Magloire 2004-11-08 04:17:02 +00:00
parent 60a0f4fa81
commit d44dbb5d43
10 changed files with 151 additions and 9 deletions

View file

@ -1,3 +1,6 @@
2004-11-07 Alain Magloire
Support for MIInterpreterExec
2004-11-03 Alain Magloire 2004-11-03 Alain Magloire
Partial fix for 77435 Partial fix for 77435
* cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java * cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java

View file

@ -331,7 +331,12 @@ public class BreakpointManager extends Manager {
if (hasBreakpointChanged(miBps[j], allMIBreakpoints[i])) { if (hasBreakpointChanged(miBps[j], allMIBreakpoints[i])) {
miBps[j] = allMIBreakpoints[i]; miBps[j] = allMIBreakpoints[i];
bp.setEnabled0(allMIBreakpoints[i].isEnabled()); bp.setEnabled0(allMIBreakpoints[i].isEnabled());
// FIXME: do the conditions also. // FIXME: We have a problem if the thread id change.
ICDICondition oldCond = bp.getCondition();
String[] tids = oldCond.getThreadIds();
Condition newCondition = new Condition(allMIBreakpoints[i].getIgnoreCount(),
allMIBreakpoints[i].getCondition(), tids);
bp.setCondition0(newCondition);
// Fire ChangedEvent // Fire ChangedEvent
eventList.add(new MIBreakpointChangedEvent(miSession, no)); eventList.add(new MIBreakpointChangedEvent(miSession, no));
} }
@ -345,8 +350,13 @@ public class BreakpointManager extends Manager {
} else if (allMIBreakpoints[i].isTemporary()) { } else if (allMIBreakpoints[i].isTemporary()) {
type = ICDIBreakpoint.TEMPORARY; type = ICDIBreakpoint.TEMPORARY;
} }
String[] tids = null;
String tid = allMIBreakpoints[i].getThreadId();
if (tid != null && tid.length() > 0) {
tids = new String[] { tid };
}
Condition condition = new Condition(allMIBreakpoints[i].getIgnoreCount(), Condition condition = new Condition(allMIBreakpoints[i].getIgnoreCount(),
allMIBreakpoints[i].getCondition(), new String[] {allMIBreakpoints[i].getThreadId()}); allMIBreakpoints[i].getCondition(), tids);
if (allMIBreakpoints[i].isWatchpoint()) { if (allMIBreakpoints[i].isWatchpoint()) {
int watchType = 0; int watchType = 0;

View file

@ -65,7 +65,10 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint {
if (miBreakpoints != null && miBreakpoints.length > 0) { if (miBreakpoints != null && miBreakpoints.length > 0) {
List list = new ArrayList(miBreakpoints.length); List list = new ArrayList(miBreakpoints.length);
for (int i = 0; i < miBreakpoints.length; i++) { for (int i = 0; i < miBreakpoints.length; i++) {
list.add(miBreakpoints[i].getThreadId()); String tid = miBreakpoints[i].getThreadId();
if (tid != null && tid.length() > 0) {
list.add(miBreakpoints[i].getThreadId());
}
} }
String[] tids = (String[]) list.toArray(new String[list.size()]); String[] tids = (String[]) list.toArray(new String[list.size()]);
int icount = miBreakpoints[0].getIgnoreCount(); int icount = miBreakpoints[0].getIgnoreCount();

View file

@ -12,6 +12,7 @@
package org.eclipse.cdt.debug.mi.core; package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.command.CLICommand; import org.eclipse.cdt.debug.mi.core.command.CLICommand;
import org.eclipse.cdt.debug.mi.core.command.MIInterpreterExecConsole;
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointChangedEvent; import org.eclipse.cdt.debug.mi.core.event.MIBreakpointChangedEvent;
import org.eclipse.cdt.debug.mi.core.event.MIDetachedEvent; import org.eclipse.cdt.debug.mi.core.event.MIDetachedEvent;
import org.eclipse.cdt.debug.mi.core.event.MIEvent; import org.eclipse.cdt.debug.mi.core.event.MIEvent;
@ -36,6 +37,17 @@ public class CLIProcessor {
*/ */
void process(CLICommand cmd) { void process(CLICommand cmd) {
String operation = cmd.getOperation().trim(); String operation = cmd.getOperation().trim();
process(cmd.getToken(), operation);
}
void process(MIInterpreterExecConsole exec) {
String[] operations = exec.getParameters();
if (operations != null && operations.length > 0) {
process(exec.getToken(), operations[0]);
}
}
void process(int token, String operation) {
// Get the command name. // Get the command name.
int indx = operation.indexOf(' '); int indx = operation.indexOf(' ');
if (indx != -1) { if (indx != -1) {
@ -50,7 +62,7 @@ public class CLIProcessor {
if (type != -1) { if (type != -1) {
// if it was a step instruction set state running // if it was a step instruction set state running
session.getMIInferior().setRunning(); session.getMIInferior().setRunning();
MIEvent event = new MIRunningEvent(session, cmd.getToken(), type); MIEvent event = new MIRunningEvent(session, token, type);
session.fireEvent(event); session.fireEvent(event);
} else if (isSettingBreakpoint(operation) || } else if (isSettingBreakpoint(operation) ||
isSettingWatchpoint(operation) || isSettingWatchpoint(operation) ||
@ -65,7 +77,7 @@ public class CLIProcessor {
} else if (isDetach(operation)) { } else if (isDetach(operation)) {
// if it was a "detach" command change the state. // if it was a "detach" command change the state.
session.getMIInferior().setDisconnected(); session.getMIInferior().setDisconnected();
MIEvent event = new MIDetachedEvent(session, cmd.getToken()); MIEvent event = new MIDetachedEvent(session, token);
session.fireEvent(event); session.fireEvent(event);
} }
} }

View file

@ -24,6 +24,7 @@ import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIExecInterrupt; import org.eclipse.cdt.debug.mi.core.command.MIExecInterrupt;
import org.eclipse.cdt.debug.mi.core.command.MIGDBExit; import org.eclipse.cdt.debug.mi.core.command.MIGDBExit;
import org.eclipse.cdt.debug.mi.core.command.MIGDBSet; import org.eclipse.cdt.debug.mi.core.command.MIGDBSet;
import org.eclipse.cdt.debug.mi.core.command.MIInterpreterExecConsole;
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.MIGDBExitEvent; import org.eclipse.cdt.debug.mi.core.event.MIGDBExitEvent;
import org.eclipse.cdt.debug.mi.core.output.MIOutput; import org.eclipse.cdt.debug.mi.core.output.MIOutput;
@ -51,6 +52,7 @@ public class MISession extends Observable {
public final static int CORE = 2; public final static int CORE = 2;
boolean terminated; boolean terminated;
boolean useInterpreterExecConsole;
// hold the type of the session(post-mortem, attach etc ..) // hold the type of the session(post-mortem, attach etc ..)
int sessionType; int sessionType;
@ -149,11 +151,20 @@ public class MISession extends Observable {
MIGDBSet width = new MIGDBSet(new String[]{"width", "0"}); //$NON-NLS-1$ //$NON-NLS-2$ MIGDBSet width = new MIGDBSet(new String[]{"width", "0"}); //$NON-NLS-1$ //$NON-NLS-2$
postCommand(width, launchTimeout); postCommand(width, launchTimeout);
confirm.getMIInfo(); width.getMIInfo();
MIGDBSet height = new MIGDBSet(new String[]{"height", "0"}); //$NON-NLS-1$ //$NON-NLS-2$ MIGDBSet height = new MIGDBSet(new String[]{"height", "0"}); //$NON-NLS-1$ //$NON-NLS-2$
postCommand(height, launchTimeout); postCommand(height, launchTimeout);
confirm.getMIInfo(); height.getMIInfo();
try {
MIInterpreterExecConsole echo = new MIInterpreterExecConsole("echo"); //$NON-NLS-1$
postCommand(echo, launchTimeout);
echo.getMIInfo();
useInterpreterExecConsole = true;
} catch (MIException e) {
//
}
} catch (MIException exc) { } catch (MIException exc) {
// Kill the Transmition thread. // Kill the Transmition thread.
@ -246,6 +257,10 @@ public class MISession extends Observable {
sessionType = type; sessionType = type;
} }
public boolean useExecConsole() {
return useInterpreterExecConsole;
}
/** /**
* The debug session is a program being debug. * The debug session is a program being debug.
*/ */

View file

@ -15,6 +15,8 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import org.eclipse.cdt.debug.mi.core.command.CLICommand; import org.eclipse.cdt.debug.mi.core.command.CLICommand;
import org.eclipse.cdt.debug.mi.core.command.Command;
import org.eclipse.cdt.debug.mi.core.command.MIInterpreterExecConsole;
/** /**
*/ */
@ -74,8 +76,13 @@ public class SessionProcess extends Process {
public void post() throws IOException { public void post() throws IOException {
// Throw away the newline. // Throw away the newline.
String str = buf.toString().trim(); String str = buf.toString().trim();
CLICommand cmd = new CLICommand(str);
buf.setLength(0); buf.setLength(0);
Command cmd = null;
if (session.useExecConsole() && str.length() > 0) {
cmd = new MIInterpreterExecConsole(str);
} else {
cmd = new CLICommand(str);
}
try { try {
session.postCommand(cmd); session.postCommand(cmd);
} catch (MIException e) { } catch (MIException e) {

View file

@ -16,6 +16,7 @@ import java.io.OutputStream;
import org.eclipse.cdt.debug.mi.core.command.CLICommand; import org.eclipse.cdt.debug.mi.core.command.CLICommand;
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.MIInterpreterExecConsole;
/** /**
* Transmission command thread blocks on the command Queue * Transmission command thread blocks on the command Queue
@ -65,6 +66,8 @@ public class TxThread extends Thread {
// Process the Command line to recognise patterns we may need to fire event. // Process the Command line to recognise patterns we may need to fire event.
if (cmd instanceof CLICommand) { if (cmd instanceof CLICommand) {
cli.process((CLICommand)cmd); cli.process((CLICommand)cmd);
} else if (cmd instanceof MIInterpreterExecConsole) {
cli.process((MIInterpreterExecConsole)cmd);
} }
// shove in the pipe // shove in the pipe

View file

@ -0,0 +1,39 @@
/**********************************************************************
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.mi.core.command;
/**
* MIInterpreterExec
*
* -interpreter-exec
*
* -interpreter-exec interpreter command
*
* Execute the specified command in the given interpreter.
*
* -interpreter-exec console "break main"
* &"During symbol reading, couldn't parse type; debugger out of date?.\n"
* &"During symbol reading, bad structure-type format.\n"
* ~"Breakpoint 1 at 0x8074fc6: file ../../src/gdb/main.c, line 743.\n"
* ^done
*
*/
public class MIInterpreterExec extends MICommand {
/**
* @param oper
*/
public MIInterpreterExec(String interpreter, String cmd) {
super("-interpreter-exec", new String[]{interpreter}, new String[] {cmd}); //$NON-NLS-1$
}
}

View file

@ -0,0 +1,27 @@
/**********************************************************************
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.mi.core.command;
/**
* MIInterpreterExecConsole
*/
public class MIInterpreterExecConsole extends MIInterpreterExec {
/**
* @param interpreter
* @param cmd
*/
public MIInterpreterExecConsole(String cmd) {
super("console", cmd); //$NON-NLS-1$
}
}

View file

@ -46,7 +46,12 @@ public class MIConst extends MIValue {
} }
} else { } else {
if (escape) { if (escape) {
buffer.append(isoC(c)); if (isIsoCSpecialChar(c)) {
buffer.append(isoC(c));
} else {
buffer.append('\\');
buffer.append(c);
}
} else { } else {
buffer.append(c); buffer.append(c);
} }
@ -96,4 +101,22 @@ public class MIConst extends MIValue {
} }
return s; return s;
} }
private static boolean isIsoCSpecialChar(char c) {
switch (c) {
case '"':
case '\'':
case '?':
case 'a':
case 'b':
case 'f':
case 'n':
case 'r':
case 't':
case 'v':
return true;
}
return false;
}
} }