Search in sources :

Example 1 with LLVMSourceLocation

use of com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation in project sulong by graalvm.

the class LLVMBasicBlockNode method fillStackTrace.

private void fillStackTrace(SulongStackTrace stackTrace, int errorIndex) {
    final LLVMSourceLocation loc = getLastAvailableSourceLocation(errorIndex);
    final LLVMFunctionStartNode f = NodeUtil.findParent(this, LLVMFunctionStartNode.class);
    stackTrace.addStackTraceElement(f.getOriginalName(), loc, f.getName(), f.getBcSource().getName(), blockName());
}
Also used : LLVMFunctionStartNode(com.oracle.truffle.llvm.nodes.func.LLVMFunctionStartNode) LLVMSourceLocation(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation)

Example 2 with LLVMSourceLocation

use of com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation in project sulong by graalvm.

the class LLVMPrintStackTrace method fillStackTrace.

private static void fillStackTrace(SulongStackTrace stackTrace, Node node) {
    LLVMBasicBlockNode block = NodeUtil.findParent(node, LLVMBasicBlockNode.class);
    LLVMFunctionStartNode f = NodeUtil.findParent(node, LLVMFunctionStartNode.class);
    if (block == null || f == null) {
        LLVMIntrinsicExpressionNode intrinsic = NodeUtil.findParent(node, LLVMIntrinsicExpressionNode.class);
        if (intrinsic != null) {
            stackTrace.addStackTraceElement(intrinsic.toString(), null, null);
        }
        return;
    }
    LLVMSourceLocation location = null;
    if (node instanceof LLVMNode && ((LLVMNode) node).getSourceLocation() != null) {
        location = ((LLVMNode) node).getSourceLocation();
    }
    if (location == null) {
        location = block.getSourceLocation();
    }
    if (location != null) {
        stackTrace.addStackTraceElement(f.getOriginalName(), location, f.getBcName(), f.getBcSource().getName(), blockName(block));
        return;
    }
    SourceSection s = node.getSourceSection();
    if (s == null) {
        s = f.getSourceSection();
    }
    if (s == null) {
        stackTrace.addStackTraceElement(f.getBcName(), f.getBcSource().getName(), blockName(block));
    } else {
        location = LLVMSourceLocation.createUnknown(s);
        stackTrace.addStackTraceElement(f.getOriginalName(), location, f.getBcName(), f.getBcSource().getName(), blockName(block));
    }
}
Also used : LLVMFunctionStartNode(com.oracle.truffle.llvm.nodes.func.LLVMFunctionStartNode) LLVMIntrinsicExpressionNode(com.oracle.truffle.llvm.nodes.intrinsics.llvm.LLVMIntrinsicRootNode.LLVMIntrinsicExpressionNode) LLVMBasicBlockNode(com.oracle.truffle.llvm.nodes.base.LLVMBasicBlockNode) LLVMSourceLocation(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation) SourceSection(com.oracle.truffle.api.source.SourceSection) LLVMNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMNode)

Example 3 with LLVMSourceLocation

use of com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation in project sulong by graalvm.

the class DIScopeBuilder method buildLocation.

LLVMSourceLocation buildLocation(MDBaseNode md) {
    if (globalCache.containsKey(md)) {
        return globalCache.get(md);
    } else if (localCache.containsKey(md)) {
        return localCache.get(md);
    }
    final Builder builder = new Builder();
    md.accept(builder);
    final LLVMSourceLocation location = builder.build();
    if (isLocalScope(location)) {
        localCache.put(md, location);
    } else {
        globalCache.put(md, location);
    }
    return location;
}
Also used : LLVMSourceLocation(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation)

Example 4 with LLVMSourceLocation

use of com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation in project sulong by graalvm.

the class DITypeExtractor method visit.

@Override
public void visit(MDBasicType mdType) {
    final String name = MDNameExtractor.getName(mdType.getName());
    final long size = mdType.getSize();
    final long align = mdType.getAlign();
    final long offset = mdType.getOffset();
    LLVMSourceBasicType.Kind kind;
    switch(mdType.getEncoding()) {
        case DW_ATE_ADDRESS:
            kind = LLVMSourceBasicType.Kind.ADDRESS;
            break;
        case DW_ATE_BOOLEAN:
            kind = LLVMSourceBasicType.Kind.BOOLEAN;
            break;
        case DW_ATE_FLOAT:
            kind = LLVMSourceBasicType.Kind.FLOATING;
            break;
        case DW_ATE_SIGNED:
            kind = LLVMSourceBasicType.Kind.SIGNED;
            break;
        case DW_ATE_SIGNED_CHAR:
            kind = LLVMSourceBasicType.Kind.SIGNED_CHAR;
            break;
        case DW_ATE_UNSIGNED:
            kind = LLVMSourceBasicType.Kind.UNSIGNED;
            break;
        case DW_ATE_UNSIGNED_CHAR:
            kind = LLVMSourceBasicType.Kind.UNSIGNED_CHAR;
            break;
        default:
            kind = LLVMSourceBasicType.Kind.UNKNOWN;
            break;
    }
    final LLVMSourceLocation location = scopeBuilder.buildLocation(mdType);
    final LLVMSourceType type = new LLVMSourceBasicType(name, size, align, offset, kind, location);
    parsedTypes.put(mdType, type);
}
Also used : LLVMSourceBasicType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceBasicType) LLVMSourceLocation(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation) MDString(com.oracle.truffle.llvm.parser.metadata.MDString) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceType)

Example 5 with LLVMSourceLocation

use of com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation in project sulong by graalvm.

the class LLVMBitcodeInstructionVisitor method visit.

@Override
public void visit(InvokeInstruction call) {
    final Type targetType = call.getType();
    int argumentCount = getArgumentCount(call.getArgumentCount(), targetType);
    final LLVMExpressionNode[] argNodes = new LLVMExpressionNode[argumentCount];
    final Type[] argTypes = new Type[argumentCount];
    int argIndex = 0;
    argNodes[argIndex] = nodeFactory.createFrameRead(runtime, PointerType.VOID, getStackSlot());
    argTypes[argIndex] = new PointerType(null);
    argIndex++;
    if (targetType instanceof StructureType) {
        argTypes[argIndex] = new PointerType(targetType);
        argNodes[argIndex] = nodeFactory.createAlloca(runtime, targetType);
        argIndex++;
    }
    for (int i = 0; argIndex < argumentCount; i++, argIndex++) {
        argNodes[argIndex] = symbols.resolve(call.getArgument(i));
        argTypes[argIndex] = call.getArgument(i).getType();
        final AttributesGroup paramAttr = call.getParameterAttributesGroup(i);
        if (isByValue(paramAttr)) {
            argNodes[argIndex] = capsuleAddressByValue(argNodes[argIndex], argTypes[argIndex], paramAttr);
        }
    }
    final SymbolImpl target = call.getCallTarget();
    int regularIndex = call.normalSuccessor().getBlockIndex();
    int unwindIndex = call.unwindSuccessor().getBlockIndex();
    List<FrameSlot> normalTo = new ArrayList<>();
    List<FrameSlot> unwindTo = new ArrayList<>();
    List<Type> normalType = new ArrayList<>();
    List<Type> unwindType = new ArrayList<>();
    List<LLVMExpressionNode> normalValue = new ArrayList<>();
    List<LLVMExpressionNode> unwindValue = new ArrayList<>();
    if (blockPhis != null) {
        for (Phi phi : blockPhis) {
            FrameSlot slot = getSlot(phi.getPhiValue().getName());
            LLVMExpressionNode value = symbols.resolve(phi.getValue());
            if (call.normalSuccessor() == phi.getBlock()) {
                normalTo.add(slot);
                normalType.add(phi.getValue().getType());
                normalValue.add(value);
            } else {
                unwindTo.add(slot);
                unwindType.add(phi.getValue().getType());
                unwindValue.add(value);
            }
        }
    }
    LLVMExpressionNode normalPhi = nodeFactory.createPhi(runtime, normalValue.toArray(new LLVMExpressionNode[normalValue.size()]), normalTo.toArray(new FrameSlot[normalTo.size()]), normalType.toArray(Type.EMPTY_ARRAY));
    LLVMExpressionNode unwindPhi = nodeFactory.createPhi(runtime, unwindValue.toArray(new LLVMExpressionNode[unwindValue.size()]), unwindTo.toArray(new FrameSlot[unwindTo.size()]), unwindType.toArray(Type.EMPTY_ARRAY));
    final LLVMSourceLocation source = sourceFunction.getSourceLocation(call);
    LLVMExpressionNode function = nodeFactory.createLLVMBuiltin(runtime, target, argNodes, argCount, null);
    if (function == null) {
        function = symbols.resolve(target);
    }
    LLVMControlFlowNode result = nodeFactory.createFunctionInvoke(runtime, getSlot(call.getName()), function, argNodes, new FunctionType(targetType, argTypes, false), regularIndex, unwindIndex, normalPhi, unwindPhi, source);
    setControlFlowNode(result);
}
Also used : LLVMControlFlowNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMControlFlowNode) FrameSlot(com.oracle.truffle.api.frame.FrameSlot) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) ArrayList(java.util.ArrayList) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) LLVMSourceLocation(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation) Phi(com.oracle.truffle.llvm.parser.LLVMPhiManager.Phi) SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) LLVMConversionType(com.oracle.truffle.llvm.parser.instructions.LLVMConversionType) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType) LLVMArithmeticInstructionType(com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType) Type(com.oracle.truffle.llvm.runtime.types.Type) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) AttributesGroup(com.oracle.truffle.llvm.parser.model.attributes.AttributesGroup) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)

Aggregations

LLVMSourceLocation (com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation)15 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)7 LLVMArithmeticInstructionType (com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType)5 LLVMConversionType (com.oracle.truffle.llvm.parser.instructions.LLVMConversionType)5 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)5 LLVMSourceType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceType)5 AggregateType (com.oracle.truffle.llvm.runtime.types.AggregateType)5 ArrayType (com.oracle.truffle.llvm.runtime.types.ArrayType)5 FunctionType (com.oracle.truffle.llvm.runtime.types.FunctionType)5 PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)5 PrimitiveType (com.oracle.truffle.llvm.runtime.types.PrimitiveType)5 StructureType (com.oracle.truffle.llvm.runtime.types.StructureType)5 Type (com.oracle.truffle.llvm.runtime.types.Type)5 ArrayList (java.util.ArrayList)5 AttributesGroup (com.oracle.truffle.llvm.parser.model.attributes.AttributesGroup)4 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)3 MDString (com.oracle.truffle.llvm.parser.metadata.MDString)3 List (java.util.List)3 SourceSection (com.oracle.truffle.api.source.SourceSection)2 LLVMFunctionStartNode (com.oracle.truffle.llvm.nodes.func.LLVMFunctionStartNode)2