mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 18:56:02 +02:00
new file to parse "info program"
This commit is contained in:
parent
e5747c7de9
commit
db78b5ea0e
2 changed files with 110 additions and 0 deletions
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue