[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-patch] Patch for GDB exitcode
|
>
> This message is in MIME format. The first part should be readable text,
> while the remaining parts are likely unreadable without MIME-aware tools.
> Send mail to mime@xxxxxxxxxxxxxxxxxxxxxxxxxxxx for more info.
>
> --26610376-1221770325-1034095631=:9132
> Content-Type: TEXT/PLAIN; charset=US-ASCII
>
> Hi,
>
> org.eclipse.cdt.debug.mi.commands.MIGDBShowExitCode is currently using an
> improperly-defined command to get at the exit code of the inferior. "show
> convenience" returns a list of all the installed convenience variables.
> It does not take any arguments.
>
> Instead, use -data-evaluate-expression to get at $_exitcode. This patch
> modifies MIGDBShowExitCode.java and MIGDBShowExitCodeInfo.java to use this
> route.
>
Ok, I see what you are doing.
I've modified your patch to let the command MIGDBShowExitCode
extends MIDataEvaluateExpression also. I think you probably forgot
to implement MIGDBShowExitCodeInfo.getCode().
Done in patch below.
Patch Applied.
> (BTW, is there a way for eclipse to generate a patch against multiple
> files at once? Whenever I have more than one file selected, the
> Team->Create Patch... option is disabled.)
>
Not that I know of, you can doit on the folder above(not exacly what you want 8(
========================================================================
Index: src/org/eclipse/cdt/debug/mi/core/command/MIGDBShowExitCode.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIGDBShowExitCode.java,v
retrieving revision 1.1
diff -u -r1.1 MIGDBShowExitCode.java
--- src/org/eclipse/cdt/debug/mi/core/command/MIGDBShowExitCode.java 12 Aug 2002 03:16:56 -0000 1.1
+++ src/org/eclipse/cdt/debug/mi/core/command/MIGDBShowExitCode.java 8 Oct 2002 19:11:37 -0000
@@ -13,19 +13,22 @@
/**
*
- * -gdb-show
+ *-data-evaluate-expression $_exitcode
+ * ^done,value="10"
*
- * Show the current value of a GDB variable.
+ * Show the current value of a $_exitcode
*
*/
-public class MIGDBShowExitCode extends MIGDBShow {
+public class MIGDBShowExitCode extends MIDataEvaluateExpression {
+
public MIGDBShowExitCode() {
- super(new String[] { "convenience", "$_exitcode" });
+ super("$_exitcode");
}
public MIGDBShowExitCodeInfo getMIGDBShowExitCodeInfo() throws MIException {
return (MIGDBShowExitCodeInfo)getMIInfo();
}
+
public MIInfo getMIInfo() throws MIException {
MIInfo info = null;
MIOutput out = getMIOutput();
Index: src/org/eclipse/cdt/debug/mi/core/output/MIGDBShowExitCodeInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIGDBShowExitCodeInfo.java,v
retrieving revision 1.1
diff -u -r1.1 MIGDBShowExitCodeInfo.java
--- src/org/eclipse/cdt/debug/mi/core/output/MIGDBShowExitCodeInfo.java 12 Aug 2002 03:16:56 -0000 1.1
+++ src/org/eclipse/cdt/debug/mi/core/output/MIGDBShowExitCodeInfo.java 8 Oct 2002 19:11:37 -0000
@@ -11,44 +11,24 @@
/**
* GDB/MI show parsing.
* (gdb)
- * -gdb-show convenience $_exitcode
- * ~"$_exitcode = 0"
- * ~"\n"
- * ^done
+ * -data-evaluate-expression $_exitcode
+ * ^done,value="10"
+ * (gdb)
*/
-public class MIGDBShowExitCodeInfo extends MIInfo {
-
- int code;
+public class MIGDBShowExitCodeInfo extends MIDataEvaluateExpressionInfo {
public MIGDBShowExitCodeInfo(MIOutput o) {
super(o);
- parse();
}
public int getCode() {
+ int code = 0;
+ String exp = getExpression();
+ try {
+ code = Integer.parseInt(exp);
+ } catch (NumberFormatException e) {
+ }
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) {
- }
- }
- }
- }
- }
- }
- }
}