mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Base on a patch from Keith Seitz to use MIDataEvaluateExpression
to get the return value instead of MIGDBSet class.
This commit is contained in:
parent
cb369c6fcc
commit
bf16d50fda
2 changed files with 17 additions and 34 deletions
|
@ -13,19 +13,22 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* -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() {
|
public MIGDBShowExitCode() {
|
||||||
super(new String[] { "convenience", "$_exitcode" });
|
super("$_exitcode");
|
||||||
}
|
}
|
||||||
|
|
||||||
public MIGDBShowExitCodeInfo getMIGDBShowExitCodeInfo() throws MIException {
|
public MIGDBShowExitCodeInfo getMIGDBShowExitCodeInfo() throws MIException {
|
||||||
return (MIGDBShowExitCodeInfo)getMIInfo();
|
return (MIGDBShowExitCodeInfo)getMIInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MIInfo getMIInfo() throws MIException {
|
public MIInfo getMIInfo() throws MIException {
|
||||||
MIInfo info = null;
|
MIInfo info = null;
|
||||||
MIOutput out = getMIOutput();
|
MIOutput out = getMIOutput();
|
||||||
|
|
|
@ -11,44 +11,24 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* GDB/MI show parsing.
|
* GDB/MI show parsing.
|
||||||
* (gdb)
|
* (gdb)
|
||||||
* -gdb-show convenience $_exitcode
|
* -data-evaluate-expression $_exitcode
|
||||||
* ~"$_exitcode = 0"
|
* ^done,value="10"
|
||||||
* ~"\n"
|
* (gdb)
|
||||||
* ^done
|
|
||||||
*/
|
*/
|
||||||
public class MIGDBShowExitCodeInfo extends MIInfo {
|
public class MIGDBShowExitCodeInfo extends MIDataEvaluateExpressionInfo {
|
||||||
|
|
||||||
int code;
|
|
||||||
|
|
||||||
public MIGDBShowExitCodeInfo(MIOutput o) {
|
public MIGDBShowExitCodeInfo(MIOutput o) {
|
||||||
super(o);
|
super(o);
|
||||||
parse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCode() {
|
public int getCode() {
|
||||||
|
int code = 0;
|
||||||
|
String exp = getExpression();
|
||||||
|
try {
|
||||||
|
code = Integer.parseInt(exp);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
return code;
|
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) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue