blob: 696e7f7b290bf1ba807ebd84eaa9ee22d51aa69f [file] [log] [blame]
/*
* (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="watchpoint-trigger",wpt={number="2",exp="i"},value={old="0",new="1"},thread-id="0",frame={addr="0x08048534",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbffff18c"}],file="hello.c",line="10"}
*
*/
public class MIWatchpointScopeEvent extends MIStoppedEvent {
int number;
public MIWatchpointScopeEvent(MIExecAsyncOutput async) {
super(async);
parse();
}
public MIWatchpointScopeEvent(MIResultRecord record) {
super(record);
parse();
}
public int getNumber() {
return number;
}
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();
if (var.equals("wpnum")) {
if (value instanceof MIConst) {
String str = ((MIConst) value).getString();
try {
number = Integer.parseInt(str.trim());
} catch (NumberFormatException e) {
}
}
} else if (var.equals("thread-id")) {
if (value instanceof MIConst) {
String str = ((MIConst) value).getString();
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);
}
}
}
}
}
}