mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
New files.
This commit is contained in:
parent
fdd0895a3d
commit
6a59dca287
3 changed files with 200 additions and 0 deletions
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
*(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.MIInfoSignalsInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||
|
||||
/**
|
||||
*
|
||||
* info threads
|
||||
*
|
||||
*/
|
||||
public class MIInfoSignals extends CLICommand
|
||||
{
|
||||
public MIInfoSignals() {
|
||||
super("info signals");
|
||||
}
|
||||
|
||||
public MIInfoSignals(String name) {
|
||||
super("info signal " + name);
|
||||
}
|
||||
|
||||
public MIInfoSignalsInfo getMIInfoSignalsInfo() throws MIException {
|
||||
return (MIInfoSignalsInfo)getMIInfo();
|
||||
}
|
||||
|
||||
public MIInfo getMIInfo() throws MIException {
|
||||
MIInfo info = null;
|
||||
MIOutput out = getMIOutput();
|
||||
if (out != null) {
|
||||
info = new MIInfoSignalsInfo(out);
|
||||
if (info.isError()) {
|
||||
throw new MIException(info.getErrorMsg());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
package org.eclipse.cdt.debug.mi.core.output;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* GDB/MI signal table parsing.
|
||||
info signals
|
||||
&"info signals\n"
|
||||
~"Signal Stop\tPrint\tPass to program\tDescription\n"
|
||||
~"\n"
|
||||
~"SIGHUP Yes\tYes\tYes\t\tHangup\n"
|
||||
~"SIGINT Yes\tYes\tNo\t\tInterrupt\n"
|
||||
~"SIGQUIT Yes\tYes\tYes\t\tQuit\n"
|
||||
~"SIGILL Yes\tYes\tYes\t\tIllegal instruction\n"
|
||||
~"SIGTRAP Yes\tYes\tNo\t\tTrace/breakpoint trap\n"
|
||||
~"SIGABRT Yes\tYes\tYes\t\tAborted\n"
|
||||
~"SIGEMT Yes\tYes\tYes\t\tEmulation trap\n"
|
||||
*/
|
||||
public class MIInfoSignalsInfo extends MIInfo {
|
||||
|
||||
MISignal[] signals;
|
||||
|
||||
public MIInfoSignalsInfo(MIOutput out) {
|
||||
super(out);
|
||||
parse();
|
||||
}
|
||||
|
||||
public MISignal[] getMISignals() {
|
||||
return signals;
|
||||
}
|
||||
|
||||
void parse() {
|
||||
List aList = new ArrayList();
|
||||
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
|
||||
parseSignal(str.trim(), aList);
|
||||
}
|
||||
}
|
||||
}
|
||||
signals = new MISignal[aList.size()];
|
||||
for (int i = 0; i < aList.size(); i++) {
|
||||
signals[i] = (MISignal)aList.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
void parseSignal(String str, List aList) {
|
||||
if (str.length() > 0) {
|
||||
// Pass the header and th tailer.
|
||||
// ~"Signal Stop\tPrint\tPass to program\tDescription\n"
|
||||
// ~"Use the \"handle\" command to change these tables.\n"
|
||||
if (!str.startsWith("Signal ") && str.startsWith("Use ")) {
|
||||
String signal = "";
|
||||
boolean stop = false;
|
||||
boolean print = false;
|
||||
boolean pass = false;
|
||||
String desc = "";
|
||||
|
||||
StringTokenizer tokenizer = new StringTokenizer(str);
|
||||
for (int i = 0; tokenizer.hasMoreTokens(); i++) {
|
||||
String sub = null;
|
||||
if (i == 3) {
|
||||
sub = tokenizer.nextToken("\n");
|
||||
} else {
|
||||
sub = tokenizer.nextToken();
|
||||
}
|
||||
switch (i) {
|
||||
case 0: // first column is "Signal"
|
||||
signal = sub;
|
||||
break;
|
||||
case 1: // second column is "Stop"
|
||||
stop = getBoolean(sub);
|
||||
break;
|
||||
case 2: // third column is "Print"
|
||||
print = getBoolean(sub);
|
||||
break;
|
||||
case 3: // third column is "Pass to Program"
|
||||
pass = getBoolean(sub);
|
||||
break;
|
||||
case 4: // last column is "Description"
|
||||
desc = sub;
|
||||
break;
|
||||
}
|
||||
}
|
||||
MISignal s = new MISignal(signal, stop, print, pass, desc.trim());
|
||||
aList.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static boolean getBoolean(String value) {
|
||||
if (value != null && value.equalsIgnoreCase("Yes")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
package org.eclipse.cdt.debug.mi.core.output;
|
||||
|
||||
|
||||
/**
|
||||
* GDB/MI shared information
|
||||
*/
|
||||
public class MISignal {
|
||||
|
||||
String signal = "";
|
||||
boolean stop;
|
||||
boolean print;
|
||||
boolean pass;
|
||||
String description = "";
|
||||
|
||||
public MISignal (String name, boolean stp, boolean prnt, boolean ps, String desc) {
|
||||
signal = name;
|
||||
stop = stp;
|
||||
print = prnt;
|
||||
pass = ps;
|
||||
description = desc;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return signal;
|
||||
}
|
||||
|
||||
public boolean isStop() {
|
||||
return stop;
|
||||
}
|
||||
|
||||
public boolean isPrint() {
|
||||
return print;
|
||||
}
|
||||
|
||||
public boolean isPass() {
|
||||
return pass;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue