1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

new file to parse "info program"

This commit is contained in:
Alain Magloire 2003-04-24 15:20:45 +00:00
parent e5747c7de9
commit db78b5ea0e
2 changed files with 110 additions and 0 deletions

View file

@ -0,0 +1,40 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.mi.core.command;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.cdt.debug.mi.core.output.MIInfoProgramInfo;
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
/**
*
* info threads
*
*/
public class MIInfoProgram extends CLICommand
{
public MIInfoProgram() {
super("info program");
}
public MIInfoProgramInfo getMIInfoProgramInfo() throws MIException {
return (MIInfoProgramInfo)getMIInfo();
}
public MIInfo getMIInfo() throws MIException {
MIInfo info = null;
MIOutput out = getMIOutput();
if (out != null) {
info = new MIInfoProgramInfo(out);
if (info.isError()) {
throw new MIException(info.getErrorMsg());
}
}
return info;
}
}

View file

@ -0,0 +1,70 @@
/*
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
package org.eclipse.cdt.debug.mi.core.output;
import java.util.StringTokenizer;
/**
* GDB/MI info program parsing.
(gdb)
info program
&"info program\n"
~"\tUsing the running image of child process 21301.\n"
~"Program stopped at 0x804853f.\n"
~"It stopped at breakpoint 1.\n"
~"Type \"info stack\" or \"info registers\" for more information.\n"
^done
(gdb)
*/
public class MIInfoProgramInfo extends MIInfo {
int pid;
public MIInfoProgramInfo(MIOutput out) {
super(out);
parse();
}
public int getPID() {
return pid;
}
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();
// We are interested in the signal info
parseLine(str);
}
}
}
}
void parseLine(String str) {
if (str != null && str.length() > 0) {
str = str.replace('.', ' ');
str = str.trim();
if (str.startsWith("Using")) {
StringTokenizer st = new StringTokenizer(str);
while (st.hasMoreTokens()) {
String s = st.nextToken();
if (Character.isDigit(s.charAt(0))) {
try {
pid = Integer.decode(s).intValue();
break;
} catch (NumberFormatException e) {
}
}
}
}
}
}
}