Search in sources :

Example 6 with BreakPointDTO

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

the class VMDebuggerTest method testStepOut.

@Test(description = "Testing Step Out.")
public void testStepOut() {
    BreakPointDTO[] breakPoints = Util.createBreakNodeLocations(".", FILE, 25);
    List<DebugPoint> debugPoints = new ArrayList<>();
    debugPoints.add(Util.createDebugPoint(".", FILE, 25, STEP_OUT, 1));
    debugPoints.add(Util.createDebugPoint(".", FILE, 42, STEP_OUT, 1));
    debugPoints.add(Util.createDebugPoint(".", FILE, 9, RESUME, 1));
    ExpectedResults expRes = new ExpectedResults(debugPoints, 3);
    VMDebuggerUtil.startDebug("test-src/debugger/test-debug.bal", breakPoints, expRes);
}
Also used : BreakPointDTO(org.ballerinalang.util.debugger.dto.BreakPointDTO) DebugPoint(org.ballerinalang.test.utils.debug.DebugPoint) ArrayList(java.util.ArrayList) ExpectedResults(org.ballerinalang.test.utils.debug.ExpectedResults) Test(org.testng.annotations.Test)

Example 7 with BreakPointDTO

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

the class VMDebuggerTest method testStepOverWhileStmt.

@Test(description = "Testing Step over in WhileStmt.")
public void testStepOverWhileStmt() {
    BreakPointDTO[] breakPoints = Util.createBreakNodeLocations(".", FILE, 12, 13, 19, 21);
    List<DebugPoint> debugPoints = new ArrayList<>();
    debugPoints.add(Util.createDebugPoint(".", FILE, 12, STEP_OVER, 1));
    debugPoints.add(Util.createDebugPoint(".", FILE, 13, RESUME, 5));
    debugPoints.add(Util.createDebugPoint(".", FILE, 19, RESUME, 4));
    debugPoints.add(Util.createDebugPoint(".", FILE, 21, RESUME, 1));
    ExpectedResults expRes = new ExpectedResults(debugPoints, 11);
    VMDebuggerUtil.startDebug("test-src/debugger/test-debug.bal", breakPoints, expRes);
}
Also used : BreakPointDTO(org.ballerinalang.util.debugger.dto.BreakPointDTO) DebugPoint(org.ballerinalang.test.utils.debug.DebugPoint) ArrayList(java.util.ArrayList) ExpectedResults(org.ballerinalang.test.utils.debug.ExpectedResults) Test(org.testng.annotations.Test)

Example 8 with BreakPointDTO

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

the class Util method createBreakNodeLocations.

public static BreakPointDTO[] createBreakNodeLocations(String packagePath, String fileName, int... lineNos) {
    BreakPointDTO[] breakPointDTOS = new BreakPointDTO[lineNos.length];
    int i = 0;
    for (int line : lineNos) {
        breakPointDTOS[i] = new BreakPointDTO(packagePath, fileName, line);
        i++;
    }
    return breakPointDTOS;
}
Also used : BreakPointDTO(org.ballerinalang.util.debugger.dto.BreakPointDTO)

Example 9 with BreakPointDTO

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

the class Debugger method generateDebugHitMessage.

/**
 * Generate debug hit message.
 *
 * @param ctx               Current context.
 * @param currentExecLine   Current execution line.
 * @param workerId          Current thread id.
 * @return  message         To be sent.
 */
private MessageDTO generateDebugHitMessage(WorkerExecutionContext ctx, LineNumberInfo currentExecLine, String workerId) {
    MessageDTO message = new MessageDTO(DebugConstants.CODE_HIT, DebugConstants.MSG_HIT);
    message.setThreadId(workerId);
    BreakPointDTO breakPointDTO = new BreakPointDTO(currentExecLine.getPackageInfo().getPkgPath(), currentExecLine.getFileName(), currentExecLine.getLineNumber());
    message.setLocation(breakPointDTO);
    int callingIp = currentExecLine.getIp();
    String pck = ctx.callableUnitInfo.getPackageInfo().getPkgPath();
    String functionName = ctx.callableUnitInfo.getName();
    LineNumberInfo callingLine = getLineNumber(ctx.callableUnitInfo.getPackageInfo().getPkgPath(), callingIp);
    FrameDTO frameDTO = new FrameDTO(pck, functionName, callingLine.getFileName(), callingLine.getLineNumber());
    message.addFrame(frameDTO);
    LocalVariableAttributeInfo localVarAttrInfo = (LocalVariableAttributeInfo) ctx.workerInfo.getAttributeInfo(AttributeInfo.Kind.LOCAL_VARIABLES_ATTRIBUTE);
    localVarAttrInfo.getLocalVariables().forEach(l -> {
        VariableDTO variableDTO = new VariableDTO(l.getVariableName(), "Local");
        switch(l.getVariableType().getTag()) {
            case TypeTags.INT_TAG:
                variableDTO.setBValue(new BInteger(ctx.workerLocal.longRegs[l.getVariableIndex()]));
                break;
            case TypeTags.FLOAT_TAG:
                variableDTO.setBValue(new BFloat(ctx.workerLocal.doubleRegs[l.getVariableIndex()]));
                break;
            case TypeTags.STRING_TAG:
                variableDTO.setBValue(new BString(ctx.workerLocal.stringRegs[l.getVariableIndex()]));
                break;
            case TypeTags.BOOLEAN_TAG:
                variableDTO.setBValue(new BBoolean(ctx.workerLocal.intRegs[l.getVariableIndex()] == 1));
                break;
            case TypeTags.BLOB_TAG:
                variableDTO.setBValue(new BBlob(ctx.workerLocal.byteRegs[l.getVariableIndex()]));
                break;
            default:
                variableDTO.setBValue(ctx.workerLocal.refRegs[l.getVariableIndex()]);
                break;
        }
        frameDTO.addVariable(variableDTO);
    });
    return message;
}
Also used : BreakPointDTO(org.ballerinalang.util.debugger.dto.BreakPointDTO) BString(org.ballerinalang.model.values.BString) BInteger(org.ballerinalang.model.values.BInteger) BBoolean(org.ballerinalang.model.values.BBoolean) BString(org.ballerinalang.model.values.BString) MessageDTO(org.ballerinalang.util.debugger.dto.MessageDTO) LocalVariableAttributeInfo(org.ballerinalang.util.codegen.attributes.LocalVariableAttributeInfo) VariableDTO(org.ballerinalang.util.debugger.dto.VariableDTO) BFloat(org.ballerinalang.model.values.BFloat) LineNumberInfo(org.ballerinalang.util.codegen.LineNumberInfo) BBlob(org.ballerinalang.model.values.BBlob) FrameDTO(org.ballerinalang.util.debugger.dto.FrameDTO)

Example 10 with BreakPointDTO

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

the class DebugMsgUtil method buildBreakPoints.

private static List<BreakPointDTO> buildBreakPoints(JsonNode node) {
    if (node == null || !node.isArray()) {
        return null;
    }
    List<BreakPointDTO> bPoints = new ArrayList<>();
    for (int i = 0; i < node.size(); i++) {
        JsonNode element = node.get(i);
        BreakPointDTO bPoint = new BreakPointDTO();
        bPoint.setPackagePath(element.get(PACKAGE_PATH) == null ? null : element.get(PACKAGE_PATH).stringValue());
        bPoint.setFileName(element.get(FILE_NAME) == null ? null : element.get(FILE_NAME).stringValue());
        bPoint.setLineNumber(element.get(LINE_NUMBER) == null ? -1 : (int) element.get(LINE_NUMBER).longValue());
        bPoints.add(bPoint);
    }
    return bPoints;
}
Also used : BreakPointDTO(org.ballerinalang.util.debugger.dto.BreakPointDTO) ArrayList(java.util.ArrayList) JsonNode(org.ballerinalang.model.util.JsonNode)

Aggregations

BreakPointDTO (org.ballerinalang.util.debugger.dto.BreakPointDTO)14 ArrayList (java.util.ArrayList)12 DebugPoint (org.ballerinalang.test.utils.debug.DebugPoint)11 ExpectedResults (org.ballerinalang.test.utils.debug.ExpectedResults)11 Test (org.testng.annotations.Test)11 JsonNode (org.ballerinalang.model.util.JsonNode)1 BBlob (org.ballerinalang.model.values.BBlob)1 BBoolean (org.ballerinalang.model.values.BBoolean)1 BFloat (org.ballerinalang.model.values.BFloat)1 BInteger (org.ballerinalang.model.values.BInteger)1 BString (org.ballerinalang.model.values.BString)1 LineNumberInfo (org.ballerinalang.util.codegen.LineNumberInfo)1 LocalVariableAttributeInfo (org.ballerinalang.util.codegen.attributes.LocalVariableAttributeInfo)1 FrameDTO (org.ballerinalang.util.debugger.dto.FrameDTO)1 MessageDTO (org.ballerinalang.util.debugger.dto.MessageDTO)1 VariableDTO (org.ballerinalang.util.debugger.dto.VariableDTO)1