use of org.ballerinalang.util.debugger.dto.VariableDTO 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;
}
use of org.ballerinalang.util.debugger.dto.VariableDTO in project ballerina by ballerina-lang.
the class DebugMsgUtil method parseVarList.
private static void parseVarList(List<VariableDTO> vars, JsonGenerator gen) throws IOException {
if (vars == null) {
gen.writeNull();
return;
}
gen.writeStartArray();
for (VariableDTO v : vars) {
parseVar(v, gen);
}
gen.writeEndArray();
}
Aggregations