| /* |
| * (c) Copyright QNX Software Systems Ltd. 2002. |
| * All Rights Reserved. |
| * |
| */ |
| package org.eclipse.cdt.debug.mi.core.event; |
| |
| import org.eclipse.cdt.debug.mi.core.output.MIConst; |
| import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; |
| import org.eclipse.cdt.debug.mi.core.output.MIFrame; |
| import org.eclipse.cdt.debug.mi.core.output.MIResult; |
| import org.eclipse.cdt.debug.mi.core.output.MIResultRecord; |
| import org.eclipse.cdt.debug.mi.core.output.MITuple; |
| import org.eclipse.cdt.debug.mi.core.output.MIValue; |
| |
| /** |
| * *stopped,reason="signal-received",signal-name="SIGINT",signal-meaning="Interrupt",thread-id="0",frame={addr="0x400e18e1",func="__libc_nanosleep",args=[],file="__libc_nanosleep",line="-1"} |
| * |
| */ |
| public class MISignalEvent extends MIStoppedEvent { |
| |
| String sigName = ""; |
| String sigMeaning = ""; |
| |
| public MISignalEvent(MIExecAsyncOutput async) { |
| super(async); |
| parse(); |
| } |
| |
| public MISignalEvent(MIResultRecord record) { |
| super(record); |
| parse(); |
| } |
| |
| public String getName() { |
| return sigName; |
| } |
| |
| public String getMeaning() { |
| return sigMeaning; |
| } |
| |
| public String toString() { |
| StringBuffer buffer = new StringBuffer(); |
| buffer.append("signal-name=" + sigName + "\n"); |
| buffer.append("signal-meaning=" + sigMeaning + "\n"); |
| buffer.append("thread-id=").append(getThreadId()).append('\n'); |
| MIFrame f = getFrame(); |
| if (f != null) { |
| buffer.append(f.toString()); |
| } |
| return buffer.toString(); |
| } |
| |
| void parse () { |
| MIExecAsyncOutput exec = getMIExecAsyncOutput(); |
| MIResultRecord rr = getMIResultRecord(); |
| |
| MIResult[] results = null; |
| if (exec != null) { |
| results = exec.getMIResults(); |
| } else if (rr != null) { |
| results = rr.getMIResults(); |
| } |
| if (results != null) { |
| for (int i = 0; i < results.length; i++) { |
| String var = results[i].getVariable(); |
| MIValue value = results[i].getMIValue(); |
| String str = ""; |
| if (value instanceof MIConst) { |
| str = ((MIConst)value).getString(); |
| } |
| |
| if (var.equals("signal-name")) { |
| sigName = str; |
| } else if (var.equals("signal-meaning")) { |
| sigMeaning = str; |
| } else if (var.equals("thread-id")) { |
| try { |
| int id = Integer.parseInt(str.trim()); |
| setThreadId(id); |
| } catch (NumberFormatException e) { |
| } |
| } else if (var.equals("frame")) { |
| if (value instanceof MITuple) { |
| MIFrame f = new MIFrame((MITuple)value); |
| setFrame(f); |
| } |
| } |
| } |
| } |
| } |
| } |