Search in sources :

Example 1 with ExceptionDetails

use of com.oracle.truffle.tools.chromeinspector.types.ExceptionDetails in project graal by oracle.

the class InspectorRuntime method fillExceptionDetails.

private void fillExceptionDetails(JSONObject obj, String errorMessage) {
    ExceptionDetails exceptionDetails = new ExceptionDetails(errorMessage);
    obj.put("exceptionDetails", exceptionDetails.createJSON(context));
}
Also used : ExceptionDetails(com.oracle.truffle.tools.chromeinspector.types.ExceptionDetails)

Example 2 with ExceptionDetails

use of com.oracle.truffle.tools.chromeinspector.types.ExceptionDetails in project graal by oracle.

the class InspectorDebugger method evaluateOnCallFrame.

@Override
public Params evaluateOnCallFrame(String callFrameId, String expressionOrig, String objectGroup, boolean includeCommandLineAPI, boolean silent, boolean returnByValue, boolean generatePreview, boolean throwOnSideEffect) throws CommandProcessException {
    if (callFrameId == null) {
        throw new CommandProcessException("A callFrameId required.");
    }
    if (expressionOrig == null) {
        throw new CommandProcessException("An expression required.");
    }
    int frameId;
    try {
        frameId = Integer.parseInt(callFrameId);
    } catch (NumberFormatException ex) {
        throw new CommandProcessException(ex.getLocalizedMessage());
    }
    ConsoleUtilitiesAPI cuAPI;
    if (includeCommandLineAPI) {
        cuAPI = ConsoleUtilitiesAPI.parse(expressionOrig);
    } else {
        cuAPI = null;
    }
    final String expression;
    if (cuAPI != null) {
        expression = cuAPI.getExpression();
    } else {
        expression = expressionOrig;
    }
    JSONObject jsonResult;
    try {
        jsonResult = context.executeInSuspendThread(new SuspendThreadExecutable<JSONObject>() {

            @Override
            public JSONObject executeCommand() throws CommandProcessException {
                if (frameId >= suspendedInfo.getCallFrames().length) {
                    throw new CommandProcessException("Too big callFrameId: " + frameId);
                }
                CallFrame cf = suspendedInfo.getCallFrames()[frameId];
                JSONObject json = new JSONObject();
                if (runSpecialFunctions(expression, cf, json)) {
                    return json;
                }
                DebugValue value = getVarValue(expression, cf);
                if (value == null) {
                    try {
                        value = cf.getFrame().eval(expression);
                        suspendedInfo.refreshFrames();
                    } catch (IllegalStateException ex) {
                    // Not an interactive language
                    }
                }
                if (value == null) {
                    LanguageInfo languageInfo = cf.getFrame().getLanguage();
                    if (languageInfo == null || !languageInfo.isInteractive()) {
                        String errorMessage = getEvalNonInteractiveMessage();
                        ExceptionDetails exceptionDetails = new ExceptionDetails(errorMessage);
                        json.put("exceptionDetails", exceptionDetails.createJSON(context));
                        JSONObject err = new JSONObject();
                        err.putOpt("value", errorMessage);
                        err.putOpt("type", "string");
                        json.put("result", err);
                    }
                }
                if (value != null) {
                    if (cuAPI != null) {
                        value = cuAPI.process(value, breakpointsHandler);
                        if (value == null) {
                            return json;
                        }
                    }
                    RemoteObject ro = new RemoteObject(value, generatePreview, context);
                    context.getRemoteObjectsHandler().register(ro, objectGroup);
                    json.put("result", ro.toJSON());
                }
                return json;
            }

            @Override
            public JSONObject processException(DebugException dex) {
                JSONObject json = new JSONObject();
                InspectorRuntime.fillExceptionDetails(json, dex, context);
                DebugValue exceptionObject = dex.getExceptionObject();
                if (exceptionObject != null) {
                    RemoteObject ro = context.createAndRegister(exceptionObject, generatePreview);
                    json.put("result", ro.toJSON());
                } else {
                    JSONObject err = new JSONObject();
                    err.putOpt("value", dex.getLocalizedMessage());
                    err.putOpt("type", "string");
                    json.put("result", err);
                }
                return json;
            }
        });
    } catch (NoSuspendedThreadException e) {
        jsonResult = new JSONObject();
        JSONObject err = new JSONObject();
        err.putOpt("value", e.getLocalizedMessage());
        jsonResult.put("result", err);
    }
    return new Params(jsonResult);
}
Also used : CommandProcessException(com.oracle.truffle.tools.chromeinspector.server.CommandProcessException) DebugValue(com.oracle.truffle.api.debug.DebugValue) Params(com.oracle.truffle.tools.chromeinspector.commands.Params) ExceptionDetails(com.oracle.truffle.tools.chromeinspector.types.ExceptionDetails) NoSuspendedThreadException(com.oracle.truffle.tools.chromeinspector.InspectorExecutionContext.NoSuspendedThreadException) DebugException(com.oracle.truffle.api.debug.DebugException) Breakpoint(com.oracle.truffle.api.debug.Breakpoint) LanguageInfo(com.oracle.truffle.api.nodes.LanguageInfo) RemoteObject(com.oracle.truffle.tools.chromeinspector.types.RemoteObject) JSONObject(com.oracle.truffle.tools.utils.json.JSONObject) CallFrame(com.oracle.truffle.tools.chromeinspector.types.CallFrame)

Example 3 with ExceptionDetails

use of com.oracle.truffle.tools.chromeinspector.types.ExceptionDetails in project graal by oracle.

the class InspectorRuntime method fillExceptionDetails.

static void fillExceptionDetails(JSONObject obj, DebugException ex, InspectorExecutionContext context) {
    ExceptionDetails exceptionDetails = new ExceptionDetails(ex);
    obj.put("exceptionDetails", exceptionDetails.createJSON(context));
}
Also used : ExceptionDetails(com.oracle.truffle.tools.chromeinspector.types.ExceptionDetails)

Aggregations

ExceptionDetails (com.oracle.truffle.tools.chromeinspector.types.ExceptionDetails)3 Breakpoint (com.oracle.truffle.api.debug.Breakpoint)1 DebugException (com.oracle.truffle.api.debug.DebugException)1 DebugValue (com.oracle.truffle.api.debug.DebugValue)1 LanguageInfo (com.oracle.truffle.api.nodes.LanguageInfo)1 NoSuspendedThreadException (com.oracle.truffle.tools.chromeinspector.InspectorExecutionContext.NoSuspendedThreadException)1 Params (com.oracle.truffle.tools.chromeinspector.commands.Params)1 CommandProcessException (com.oracle.truffle.tools.chromeinspector.server.CommandProcessException)1 CallFrame (com.oracle.truffle.tools.chromeinspector.types.CallFrame)1 RemoteObject (com.oracle.truffle.tools.chromeinspector.types.RemoteObject)1 JSONObject (com.oracle.truffle.tools.utils.json.JSONObject)1