use of com.oracle.truffle.api.debug.Breakpoint in project graal by oracle.
the class BreakpointTest method testBreakSourceSection.
@Test
public void testBreakSourceSection() throws Throwable {
final Source source = testSource("ROOT(STATEMENT, STATEMENT, STATEMENT)\n");
try (DebuggerSession session = startSession()) {
SourceSection sourceSection = getSourceImpl(source).createSection(16, 9);
Breakpoint breakpoint = session.install(Breakpoint.newBuilder(sourceSection).build());
startEval(source);
expectSuspended((SuspendedEvent event) -> {
checkState(event, 1, true, "STATEMENT");
Assert.assertEquals(sourceSection, event.getSourceSection());
assertSame(breakpoint, event.getBreakpoints().iterator().next());
event.prepareContinue();
});
expectDone();
}
}
use of com.oracle.truffle.api.debug.Breakpoint in project graal by oracle.
the class BreakpointsHandler method createOneShotBreakpoint.
void createOneShotBreakpoint(Location location) throws CommandProcessException {
Script script = slh.getScript(location.getScriptId());
if (script == null) {
throw new CommandProcessException("No script with id '" + location.getScriptId() + "'");
}
Breakpoint bp = createBuilder(script.getSource(), location.getLine(), location.getColumn()).oneShot().build();
ds.install(bp);
}
use of com.oracle.truffle.api.debug.Breakpoint in project graal by oracle.
the class BreakpointsHandler method removeBreakpoint.
boolean removeBreakpoint(String idStr) {
boolean bpRemoved = false;
try {
long id = Long.parseLong(idStr);
synchronized (bpIDs) {
Iterator<Map.Entry<Breakpoint, Long>> bpEntryIt = bpIDs.entrySet().iterator();
while (bpEntryIt.hasNext()) {
Map.Entry<Breakpoint, Long> bpEntry = bpEntryIt.next();
if (id == bpEntry.getValue().longValue()) {
Breakpoint bp = bpEntry.getKey();
if (bp != null) {
bp.dispose();
}
bpEntryIt.remove();
bpRemoved = true;
}
}
LoadScriptListener scriptListener = scriptListeners.remove(id);
if (scriptListener != null) {
slh.removeLoadScriptListener(scriptListener);
bpRemoved = true;
}
}
} catch (NumberFormatException nfex) {
}
return bpRemoved;
}
use of com.oracle.truffle.api.debug.Breakpoint in project graal by oracle.
the class BreakpointsHandler method createBreakpoint.
Params createBreakpoint(Location location, String condition) throws CommandProcessException {
Script script = slh.getScript(location.getScriptId());
if (script == null) {
throw new CommandProcessException("No script with id '" + location.getScriptId() + "'");
}
Breakpoint bp = createBuilder(script.getSource(), location.getLine(), location.getColumn()).resolveListener(resolvedHandler).build();
if (condition != null && !condition.isEmpty()) {
bp.setCondition(condition);
}
bp = ds.install(bp);
JSONArray locations = new JSONArray();
long id;
synchronized (bpIDs) {
id = ++lastID;
bpIDs.put(bp, id);
SourceSection section = resolvedBreakpoints.remove(bp);
if (section != null) {
Location resolvedLocation = new Location(location.getScriptId(), section.getStartLine(), section.getStartColumn());
locations.put(resolvedLocation.toJSON());
}
}
JSONObject json = new JSONObject();
json.put("breakpointId", Long.toString(id));
locations.put(location.toJSON());
json.put("locations", locations);
return new Params(json);
}
Aggregations