mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +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() {
|
||||
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();
|
||||
|
|
|
@ -11,44 +11,24 @@ import java.util.List;
|
|||
/**
|
||||
* 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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue