Search in sources :

Example 1 with LLVMSourceType

use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType in project graal by oracle.

the class DebugExprDereferenceNode method getMemberAndType.

@TruffleBoundary
private Pair<Object, DebugExprType> getMemberAndType(Object executedPointerNode) {
    if (executedPointerNode == null) {
        throw DebugExprException.create(this, "debugObject to dereference is null");
    }
    try {
        LLVMDebuggerValue llvmDebuggerValue = (LLVMDebuggerValue) executedPointerNode;
        Object metaObj = llvmDebuggerValue.resolveMetaObject();
        DebugExprType pointerType = DebugExprType.getTypeFromSymbolTableMetaObject(metaObj);
        if (!pointerType.isPointer()) {
            throw DebugExprException.create(this, llvmDebuggerValue + " is no pointer");
        }
        LLVMSourcePointerType llvmSourcePointerType = (LLVMSourcePointerType) metaObj;
        LLVMSourceType llvmSourceType = llvmSourcePointerType.getBaseType();
        LLVMDebugObject llvmPointerObject = (LLVMDebugObject) executedPointerNode;
        Object llvmPointerValue = llvmPointerObject.getValue();
        Builder builder = CommonNodeFactory.createDebugDeclarationBuilder();
        LLVMDebugValue dereferencedValue = builder.build(llvmPointerValue);
        LLVMDebugObject llvmDebugObject = LLVMDebugObject.create(llvmSourceType, 0L, dereferencedValue, null);
        DebugExprType type = pointerType.getInnerType();
        return Pair.create(type.parse(llvmDebugObject), type);
    } catch (ClassCastException e) {
    // throw cast exception of executedPointerNode (2 lines below)
    }
    throw DebugExprException.create(this, executedPointerNode + " cannot be casted to pointer ");
}
Also used : DebugExprType(com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType) LLVMDebugObject(com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugObject) Builder(com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugValue.Builder) LLVMDebuggerValue(com.oracle.truffle.llvm.runtime.debug.LLVMDebuggerValue) LLVMDebugObject(com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugObject) LLVMSourcePointerType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourcePointerType) LLVMDebugValue(com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugValue) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 2 with LLVMSourceType

use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType in project graal by oracle.

the class DebugExprTypeofNode method getLLVMSourceType.

@Specialization
public LLVMSourceType getLLVMSourceType(VirtualFrame frame) {
    NodeLibrary nodeLibrary = NodeLibrary.getUncached();
    InteropLibrary interopLibrary = InteropLibrary.getUncached();
    try {
        LLVMDebuggerValue entries = (LLVMDebuggerValue) nodeLibrary.getScope(location, frame, false);
        if (interopLibrary.isMemberReadable(entries, name)) {
            Object member = interopLibrary.readMember(entries, name);
            LLVMDebuggerValue ldv = (LLVMDebuggerValue) member;
            Object metaObj = ldv.resolveMetaObject();
            return (LLVMSourceType) metaObj;
        }
    } catch (ClassCastException e) {
        // OR metaObj is no primitive type
        throw DebugExprException.create(this, "\"%s\" cannot be casted to a LLVMDebuggerValue", name);
    } catch (UnsupportedMessageException e) {
        // should only happen if hasMembers == false
        throw DebugExprException.symbolNotFound(this, name, null);
    } catch (UnknownIdentifierException e) {
        throw DebugExprException.symbolNotFound(this, e.getUnknownIdentifier(), null);
    }
    return LLVMSourceType.UNKNOWN;
}
Also used : NodeLibrary(com.oracle.truffle.api.interop.NodeLibrary) UnsupportedMessageException(com.oracle.truffle.api.interop.UnsupportedMessageException) UnknownIdentifierException(com.oracle.truffle.api.interop.UnknownIdentifierException) InteropLibrary(com.oracle.truffle.api.interop.InteropLibrary) LLVMDebuggerValue(com.oracle.truffle.llvm.runtime.debug.LLVMDebuggerValue) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 3 with LLVMSourceType

use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType in project graal by oracle.

the class LLVMGlobal method getInteropType.

public LLVMInteropType getInteropType(LLVMContext context) {
    if (!interopTypeCached) {
        CompilerDirectives.transferToInterpreterAndInvalidate();
        LLVMSourceType sourceType = sourceSymbol != null ? sourceSymbol.getType() : null;
        interopType = context.getLanguage().getInteropType(sourceType);
        interopTypeCached = true;
    }
    return interopType;
}
Also used : LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType)

Example 4 with LLVMSourceType

use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType in project graal by oracle.

the class CommonNodeFactory method asDebuggerIRValue.

private static Object asDebuggerIRValue(Object llvmType, Object value, DataLayout dataLayout) {
    final Type type;
    if (llvmType instanceof Type) {
        type = (Type) llvmType;
    } else {
        return null;
    }
    // e.g. debugger symbols
    if (type instanceof MetaType) {
        return null;
    }
    final LLVMSourceType sourceType = LLVMSourceTypeFactory.resolveType(type, dataLayout);
    if (sourceType == null) {
        return null;
    }
    // after frame-nulling the actual vector length does not correspond to the type anymore
    if (value instanceof LLVMVector && ((LLVMVector) value).getLength() == 0) {
        return null;
    }
    // after frame-nulling the actual bitsize does not correspond to the type anymore
    if (value instanceof LLVMIVarBit && ((LLVMIVarBit) value).getBitSize() == 0) {
        return null;
    }
    final LLVMDebugValue debugValue = createDebugValueBuilder().build(value);
    if (debugValue == LLVMDebugValue.UNAVAILABLE) {
        return null;
    }
    return LLVMDebugObject.create(sourceType, 0L, debugValue, null);
}
Also used : VariableBitWidthType(com.oracle.truffle.llvm.runtime.types.VariableBitWidthType) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) MetaType(com.oracle.truffle.llvm.runtime.types.MetaType) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType) LLVMInteropType(com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType) ForeignToLLVMType(com.oracle.truffle.llvm.runtime.interop.convert.ForeignToLLVM.ForeignToLLVMType) Type(com.oracle.truffle.llvm.runtime.types.Type) LLVMVector(com.oracle.truffle.llvm.runtime.vector.LLVMVector) LLVMDebugValue(com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugValue) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType) MetaType(com.oracle.truffle.llvm.runtime.types.MetaType)

Example 5 with LLVMSourceType

use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType in project graal by oracle.

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.type.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.type.LLVMSourceType)

Aggregations

LLVMSourceType (com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType)17 LLVMSourceLocation (com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation)5 LLVMSourceFunctionType (com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType)5 MDBaseNode (com.oracle.truffle.llvm.parser.metadata.MDBaseNode)4 LLVMSourceStaticMemberType (com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceStaticMemberType)4 MDString (com.oracle.truffle.llvm.parser.metadata.MDString)3 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)3 LLVMSourcePointerType (com.oracle.truffle.llvm.runtime.debug.type.LLVMSourcePointerType)3 ArrayList (java.util.ArrayList)3 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)2 MDCompositeType (com.oracle.truffle.llvm.parser.metadata.MDCompositeType)2 MDGlobalVariable (com.oracle.truffle.llvm.parser.metadata.MDGlobalVariable)2 MDGlobalVariableExpression (com.oracle.truffle.llvm.parser.metadata.MDGlobalVariableExpression)2 MDLocalVariable (com.oracle.truffle.llvm.parser.metadata.MDLocalVariable)2 MDNode (com.oracle.truffle.llvm.parser.metadata.MDNode)2 MDSubprogram (com.oracle.truffle.llvm.parser.metadata.MDSubprogram)2 MDValue (com.oracle.truffle.llvm.parser.metadata.MDValue)2 MetadataValueList (com.oracle.truffle.llvm.parser.metadata.MetadataValueList)2 FunctionDefinition (com.oracle.truffle.llvm.parser.model.functions.FunctionDefinition)2 FunctionParameter (com.oracle.truffle.llvm.parser.model.functions.FunctionParameter)2