Search in sources :

Example 1 with DebugContext

use of org.ballerinalang.util.debugger.DebugContext in project ballerina by ballerina-lang.

the class CPU method debug.

/**
 * Method to calculate and detect debug points when the instruction point is given.
 */
private static boolean debug(WorkerExecutionContext ctx) {
    Debugger debugger = ctx.programFile.getDebugger();
    if (!debugger.isClientSessionActive()) {
        return false;
    }
    DebugContext debugContext = ctx.getDebugContext();
    if (debugContext.isWorkerPaused()) {
        debugContext.setWorkerPaused(false);
        return false;
    }
    LineNumberInfo currentExecLine = debugger.getLineNumber(ctx.callableUnitInfo.getPackageInfo().getPkgPath(), ctx.ip);
    /*
         Below if check stops hitting the same debug line again and again in case that single line has
         multctx.iple instructions.
         */
    if (currentExecLine.equals(debugContext.getLastLine())) {
        return false;
    }
    if (debugPointCheck(ctx, currentExecLine, debugger)) {
        return true;
    }
    switch(debugContext.getCurrentCommand()) {
        case RESUME:
            /*
                 In case of a for loop, need to clear the last hit line, so that, same line can get hit again.
                 */
            debugContext.clearLastDebugLine();
            break;
        case STEP_IN:
        case STEP_OVER:
            debugHit(ctx, currentExecLine, debugger);
            return true;
        case STEP_OUT:
            break;
        default:
            debugger.notifyExit();
            debugger.stopDebugging();
    }
    return false;
}
Also used : Debugger(org.ballerinalang.util.debugger.Debugger) LineNumberInfo(org.ballerinalang.util.codegen.LineNumberInfo) DebugContext(org.ballerinalang.util.debugger.DebugContext)

Example 2 with DebugContext

use of org.ballerinalang.util.debugger.DebugContext in project ballerina by ballerina-lang.

the class WorkerExecutionContext method initDebugger.

private void initDebugger() {
    if (!programFile.getDebugger().isDebugEnabled()) {
        return;
    }
    if (parent == null) {
        this.debugContext = new DebugContext();
        this.programFile.getDebugger().addWorkerContext(this);
        return;
    }
    DebugContext parentCtx = parent.getDebugContext();
    if (parentCtx == null || parentCtx.getCurrentCommand() == DebugCommand.RESUME || parentCtx.getCurrentCommand() == DebugCommand.STEP_OVER || parentCtx.getCurrentCommand() == DebugCommand.STEP_OUT) {
        this.debugContext = new DebugContext();
    } else if (parentCtx.getCurrentCommand() == DebugCommand.STEP_IN) {
        this.debugContext = new DebugContext(DebugCommand.STEP_IN);
    }
    this.programFile.getDebugger().addWorkerContext(this);
}
Also used : DebugContext(org.ballerinalang.util.debugger.DebugContext)

Aggregations

DebugContext (org.ballerinalang.util.debugger.DebugContext)2 LineNumberInfo (org.ballerinalang.util.codegen.LineNumberInfo)1 Debugger (org.ballerinalang.util.debugger.Debugger)1