[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-debug-dev] Residual CDT hacks
|
This is the yearly update of my residual CDT hacks :-)
Things are looking pretty good. Currently all I do is to tweak the GDB
console:
- Bring back the (gdb) prompt
- Recover some lost GDB output
- Silence commands that are issued by CDT
--
Øyvind Harboe
http://www.zylin.com
### Eclipse Workspace Patch 1.0
#P org.eclipse.cdt.debug.mi.core
Index: mi/org/eclipse/cdt/debug/mi/core/output/MIConst.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/output/MIConst.java,v
retrieving revision 1.6
diff -u -r1.6 MIConst.java
--- mi/org/eclipse/cdt/debug/mi/core/output/MIConst.java 23 Jun 2005 16:00:59 -0000 1.6
+++ mi/org/eclipse/cdt/debug/mi/core/output/MIConst.java 14 Mar 2006 12:09:48 -0000
@@ -65,7 +65,7 @@
buffer.append('\\');
}
- return buffer.toString();
+ return buffer.toString().replaceAll("\\r\\n", "\n");
}
public String toString() {
Index: mi/org/eclipse/cdt/debug/mi/core/output/MIParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/output/MIParser.java,v
retrieving revision 1.7
diff -u -r1.7 MIParser.java
--- mi/org/eclipse/cdt/debug/mi/core/output/MIParser.java 23 Jun 2005 16:00:59 -0000 1.7
+++ mi/org/eclipse/cdt/debug/mi/core/output/MIParser.java 14 Mar 2006 12:09:48 -0000
@@ -131,7 +131,13 @@
if (token.charAt(0) == '^') {
token.deleteCharAt(0);
rr = processMIResultRecord(token, id);
- } else if (startsWith(token, primaryPrompt)) {
+ } else if (!token.toString().startsWith(primaryPrompt)) {
+ /* we want to process the primary prompt as well to get it printed.. */
+ MIOOBRecord band = processMIOOBRecord(token, id);
+ if (band != null) {
+ oobs.add(band);
+ }
+ } else if (startsWith(token, primaryPrompt)) {
//break; // Do nothing.
} else {
MIOOBRecord band = processMIOOBRecord(token, id);
@@ -246,7 +252,7 @@
} else {
// Badly format MI line, just pass it to the user as target stream
MIStreamRecord stream = new MITargetStreamOutput();
- stream.setCString(buffer.toString() + "\n"); //$NON-NLS-1$
+ stream.setCString(buffer.toString()); //$NON-NLS-1$
oob = stream;
}
return oob;
Index: mi/org/eclipse/cdt/debug/mi/core/RxThread.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/RxThread.java,v
retrieving revision 1.9
diff -u -r1.9 RxThread.java
--- mi/org/eclipse/cdt/debug/mi/core/RxThread.java 6 Mar 2006 19:47:30 -0000 1.9
+++ mi/org/eclipse/cdt/debug/mi/core/RxThread.java 14 Mar 2006 12:09:48 -0000
@@ -92,6 +92,19 @@
}
setPrompt(line);
processMIOutput(line + "\n"); //$NON-NLS-1$
+ if (inPrimaryPrompt()) {
+ if (!session.silent())
+ {
+ OutputStream console = session.getConsolePipe();
+ if (console!=null)
+ {
+ console.write(line.getBytes());
+ console.flush();
+ }
+ }
+ session.processedPrompt();
+ }
+
}
} catch (IOException e) {
//e.printStackTrace();
@@ -168,6 +181,8 @@
if (rr != null) {
int id = rr.getToken();
Command cmd = rxQueue.removeCommand(id);
+
+ session.retireCmd(cmd);
// Clear the accumulate oobList on each new Result Command
// response.
@@ -320,6 +335,24 @@
}
} else if (async instanceof MIStatusAsyncOutput) {
// Nothing done .. but what about +download??
+ // This is meant for the gdb console.
+ OutputStream log = session.getLogPipe();
+ if (log != null) {
+ MIStatusAsyncOutput out = (MIStatusAsyncOutput) async;
+ for (int i=0; i<out.getMIResults().length; i++) {
+ String str = out.getMIResults()[i].getVariable();
+ if (str != null) {
+ try {
+ log.write((str + "\n").getBytes());
+ log.flush();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+
+
+
} else if (async instanceof MINotifyAsyncOutput) {
// Nothing
}
@@ -327,6 +360,7 @@
void processMIOOBRecord(MIStreamRecord stream) {
if (stream instanceof MIConsoleStreamOutput) {
+ if (!session.silent()) {
OutputStream console = session.getConsolePipe();
if (console != null) {
MIConsoleStreamOutput out = (MIConsoleStreamOutput) stream;
@@ -340,11 +374,13 @@
} catch (IOException e) {
}
}
+ }
}
// Accumulate the Console Stream Output response for parsing.
// Some commands will put valuable info in the Console Stream.
oobList.add(stream);
} else if (stream instanceof MITargetStreamOutput) {
+ if (true/*!session.silent()*/) {
OutputStream target = session.getMIInferior().getPipedOutputStream();
if (target != null) {
MITargetStreamOutput out = (MITargetStreamOutput) stream;
@@ -356,12 +392,29 @@
} catch (IOException e) {
}
}
+ } else {
+ /* dump to GDB console as a fallback... */
+ OutputStream console = session.getConsolePipe();
+ if (console != null) {
+ MITargetStreamOutput out = (MITargetStreamOutput) stream;
+ String str = out.getString();
+ // Process the console stream too.
+ if (str != null) {
+ try {
+ console.write(str.getBytes());
+ console.flush();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
}
// Accumulate the Target Stream Output response for parsing.
// Some commands, e.g. 'monitor' will put valuable info in the Console Stream.
// This fixes bug 119370.
oobList.add(stream);
} else if (stream instanceof MILogStreamOutput) {
+ if (!session.silent()) {
// This is meant for the gdb console.
OutputStream log = session.getLogPipe();
if (log != null) {
@@ -374,11 +427,34 @@
} catch (IOException e) {
}
}
+ }
}
// Accumulate the Log Stream Output response for parsing.
// Some commands will put valuable info in the Log Stream.
oobList.add(stream);
- }
+ } else
+ {
+ try
+ {
+ MIStreamRecord out = (MIStreamRecord) stream;
+ /* unknown type, just dump output to console */
+ if (!session.silent()) {
+ OutputStream console = session.getConsolePipe();
+ if (console != null) {
+ String str = out.getString();
+ if (str != null) {
+ try {
+ console.write(str.getBytes());
+ console.flush();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+ } catch (RuntimeException e)
+ {
+ }
+ }
}
/**
Index: mi/org/eclipse/cdt/debug/mi/core/SessionProcess.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/SessionProcess.java,v
retrieving revision 1.7
diff -u -r1.7 SessionProcess.java
--- mi/org/eclipse/cdt/debug/mi/core/SessionProcess.java 27 Jun 2005 15:24:55 -0000 1.7
+++ mi/org/eclipse/cdt/debug/mi/core/SessionProcess.java 14 Mar 2006 12:09:48 -0000
@@ -92,11 +92,13 @@
cmd = new RawCommand(str);
} else if (session.useExecConsole() && str.length() > 0
&& !CLIProcessor.isSteppingOperation(str)) {
+ // FIX!!! Does not work on my GDB for "load"
CommandFactory factory = session.getCommandFactory();
cmd = factory.createMIInterpreterExecConsole(str);
} else {
cmd = new CLICommand(str);
}
+ cmd.setSilent(false);
try {
// Do not wait around for the answer.
session.postCommand(cmd, -1);
Index: mi/org/eclipse/cdt/debug/mi/core/MISession.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MISession.java,v
retrieving revision 1.14
diff -u -r1.14 MISession.java
--- mi/org/eclipse/cdt/debug/mi/core/MISession.java 25 Jan 2006 19:18:46 -0000 1.14
+++ mi/org/eclipse/cdt/debug/mi/core/MISession.java 14 Mar 2006 12:09:48 -0000
@@ -806,4 +806,44 @@
}
}
+ private Command inflightCmd;
+ private boolean showOutput=true; // show first command
+ /**
+ * Set this cmd as in flight
+ *
+ * @param console
+ */
+ public void inflightConsoleCmd(Command cmd) {
+ inflightCmd=cmd;
+ showOutput=showOutput||!cmd.isSilent();
+ }
+
+ /**
+ * @param cmd
+ */
+ public void retireCmd(Command cmd) {
+ if (inflightCmd!=null&&cmd!=null) {
+ if (cmd.getToken()==inflightCmd.getToken()) {
+ inflightCmd=null;
+ } else {
+ int x=0;
+ }
+ }
+ }
+
+ /**
+ * Are we in silent mode?
+ *
+ * @return
+ */
+ public boolean silent() {
+ return !showOutput;
+ }
+
+ public void processedPrompt()
+ {
+ showOutput=false;
+ }
+
+
}
Index: mi/org/eclipse/cdt/debug/mi/core/TxThread.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/TxThread.java,v
retrieving revision 1.5
diff -u -r1.5 TxThread.java
--- mi/org/eclipse/cdt/debug/mi/core/TxThread.java 23 Jun 2005 16:01:00 -0000 1.5
+++ mi/org/eclipse/cdt/debug/mi/core/TxThread.java 14 Mar 2006 12:09:48 -0000
@@ -71,6 +71,7 @@
} else if (cmd instanceof MIInterpreterExecConsole) {
cli.processStateChanges((MIInterpreterExecConsole)cmd);
}
+ session.inflightConsoleCmd(cmd);
// shove in the pipe
if (out != null) {
Index: mi/org/eclipse/cdt/debug/mi/core/command/Command.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/Command.java,v
retrieving revision 1.3
diff -u -r1.3 Command.java
--- mi/org/eclipse/cdt/debug/mi/core/command/Command.java 23 Jun 2005 16:00:59 -0000 1.3
+++ mi/org/eclipse/cdt/debug/mi/core/command/Command.java 14 Mar 2006 12:09:48 -0000
@@ -104,4 +104,20 @@
throw new MIException(mesg, details);
}
+ private boolean silent = true;
+
+ /**
+ * @return Returns the silent.
+ */
+ public boolean isSilent() {
+ return silent;
+ }
+
+ /**
+ * @param silent The silent to set.
+ */
+ public void setSilent(boolean silent) {
+ this.silent = silent;
+ }
+
}