use of org.ballerinalang.util.debugger.Debugger in project ballerina by ballerina-lang.
the class TesterinaFunction method invoke.
/**
* Invokes a ballerina test function, in blocking mode.
*
* @param args function arguments
*/
public BValue[] invoke(BValue[] args) {
WorkerExecutionContext ctx = new WorkerExecutionContext(programFile);
Debugger debugger = new Debugger(programFile);
initDebugger(programFile, debugger);
return BLangFunctions.invokeCallable(bFunction, ctx, args);
}
use of org.ballerinalang.util.debugger.Debugger 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;
}
use of org.ballerinalang.util.debugger.Debugger in project ballerina by ballerina-lang.
the class BLangProgramRunner method runMain.
public static void runMain(ProgramFile programFile, String[] args) {
if (!programFile.isMainEPAvailable()) {
throw new BallerinaException("main function not found in '" + programFile.getProgramFilePath() + "'");
}
PackageInfo mainPkgInfo = programFile.getEntryPackage();
if (mainPkgInfo == null) {
throw new BallerinaException("main function not found in '" + programFile.getProgramFilePath() + "'");
}
Debugger debugger = new Debugger(programFile);
initDebugger(programFile, debugger);
boolean distributedTxEnabled = CompilerUtils.isDistributedTransactionsEnabled();
programFile.setDistributedTransactionEnabled(distributedTxEnabled);
FunctionInfo mainFuncInfo = getMainFunction(mainPkgInfo);
try {
BLangFunctions.invokeEntrypointCallable(programFile, mainPkgInfo, mainFuncInfo, extractMainArgs(args));
} finally {
if (debugger.isDebugEnabled()) {
debugger.notifyExit();
}
BLangFunctions.invokeVMUtilFunction(mainPkgInfo.getStopFunctionInfo());
}
}
use of org.ballerinalang.util.debugger.Debugger in project ballerina by ballerina-lang.
the class BLangProgramRunner method runService.
public static void runService(ProgramFile programFile) {
if (!programFile.isServiceEPAvailable()) {
throw new BallerinaException("no services found in '" + programFile.getProgramFilePath() + "'");
}
// Get the service package
PackageInfo servicesPackage = programFile.getEntryPackage();
if (servicesPackage == null) {
throw new BallerinaException("no services found in '" + programFile.getProgramFilePath() + "'");
}
Debugger debugger = new Debugger(programFile);
initDebugger(programFile, debugger);
boolean distributedTxEnabled = CompilerUtils.isDistributedTransactionsEnabled();
programFile.setDistributedTransactionEnabled(distributedTxEnabled);
// Invoke package init function
BLangFunctions.invokePackageInitFunction(servicesPackage.getInitFunctionInfo());
BLangFunctions.invokeVMUtilFunction(servicesPackage.getStartFunctionInfo());
}
use of org.ballerinalang.util.debugger.Debugger in project ballerina by ballerina-lang.
the class BRunUtil method invokePackageInit.
/**
* Invoke package init function.
*
* @param compileResult CompileResult instance
* @param packageName Name of the package to invoke
*/
protected static void invokePackageInit(CompileResult compileResult, String packageName) {
if (compileResult.getErrorCount() > 0) {
throw new IllegalStateException(compileResult.toString());
}
ProgramFile programFile = compileResult.getProgFile();
PackageInfo packageInfo = programFile.getPackageInfo(packageName);
WorkerExecutionContext context = new WorkerExecutionContext(programFile);
Debugger debugger = new Debugger(programFile);
programFile.setDebugger(debugger);
compileResult.setContext(context);
BLangFunctions.invokePackageInitFunction(packageInfo.getInitFunctionInfo(), context);
}
Aggregations