Search in sources :

Example 11 with CommandProcessException

use of com.oracle.truffle.tools.chromeinspector.server.CommandProcessException 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);
}
Also used : CommandProcessException(com.oracle.truffle.tools.chromeinspector.server.CommandProcessException) Script(com.oracle.truffle.tools.chromeinspector.types.Script) Breakpoint(com.oracle.truffle.api.debug.Breakpoint) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) Params(com.oracle.truffle.tools.chromeinspector.commands.Params) SourceSection(com.oracle.truffle.api.source.SourceSection) Location(com.oracle.truffle.tools.chromeinspector.types.Location)

Aggregations

CommandProcessException (com.oracle.truffle.tools.chromeinspector.server.CommandProcessException)11 Params (com.oracle.truffle.tools.chromeinspector.commands.Params)9 JSONObject (org.json.JSONObject)9 Breakpoint (com.oracle.truffle.api.debug.Breakpoint)5 GuestLanguageException (com.oracle.truffle.tools.chromeinspector.TruffleExecutionContext.GuestLanguageException)5 NoSuspendedThreadException (com.oracle.truffle.tools.chromeinspector.TruffleExecutionContext.NoSuspendedThreadException)5 DebugValue (com.oracle.truffle.api.debug.DebugValue)4 RemoteObject (com.oracle.truffle.tools.chromeinspector.types.RemoteObject)4 Script (com.oracle.truffle.tools.chromeinspector.types.Script)4 JSONArray (org.json.JSONArray)3 TruffleException (com.oracle.truffle.api.TruffleException)2 Source (com.oracle.truffle.api.source.Source)2 SourceSection (com.oracle.truffle.api.source.SourceSection)2 CallFrame (com.oracle.truffle.tools.chromeinspector.types.CallFrame)2 Location (com.oracle.truffle.tools.chromeinspector.types.Location)2 DebugScope (com.oracle.truffle.api.debug.DebugScope)1 SuspendedEvent (com.oracle.truffle.api.debug.SuspendedEvent)1 Result (com.oracle.truffle.tools.chromeinspector.commands.Result)1 Event (com.oracle.truffle.tools.chromeinspector.events.Event)1 URISyntaxException (java.net.URISyntaxException)1