Search in sources :

Example 1 with LLVMDebuggerValue

use of com.oracle.truffle.llvm.runtime.debug.LLVMDebuggerValue 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 LLVMDebuggerValue

use of com.oracle.truffle.llvm.runtime.debug.LLVMDebuggerValue 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 LLVMDebuggerValue

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

the class DebugExprObjectMemberNode method findMemberAndType.

private Pair<Object, DebugExprType> findMemberAndType(Object baseMember) {
    InteropLibrary library = InteropLibrary.getFactory().getUncached();
    if (baseMember != null && library.isMemberExisting(baseMember, fieldName)) {
        try {
            Object member = library.readMember(baseMember, fieldName);
            LLVMDebuggerValue ldv = (LLVMDebuggerValue) member;
            Object metaObj = ldv.resolveMetaObject();
            DebugExprType type = DebugExprType.getTypeFromSymbolTableMetaObject(metaObj);
            return Pair.create(member, type);
        } catch (UnsupportedMessageException e1) {
            throw DebugExprException.symbolNotFound(this, fieldName, baseMember);
        } catch (UnknownIdentifierException e1) {
            throw DebugExprException.symbolNotFound(this, e1.getUnknownIdentifier(), baseMember);
        } catch (ClassCastException e1) {
            throw DebugExprException.symbolNotFound(this, fieldName, baseMember);
        }
    }
    throw DebugExprException.symbolNotFound(this, fieldName, baseMember);
}
Also used : DebugExprType(com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType) 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)

Example 4 with LLVMDebuggerValue

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

the class DebugExprVarNode method findMemberAndType.

private Pair<Object, DebugExprType> findMemberAndType(VirtualFrame frameValue) {
    NodeLibrary nodeLibrary = NodeLibrary.getUncached();
    InteropLibrary interopLibrary = InteropLibrary.getUncached();
    try {
        LLVMDebuggerValue entries = (LLVMDebuggerValue) nodeLibrary.getScope(location, frameValue, true);
        if (interopLibrary.isMemberReadable(entries, name)) {
            Object member = interopLibrary.readMember(entries, name);
            LLVMDebuggerValue ldv = (LLVMDebuggerValue) member;
            Object metaObj = ldv.resolveMetaObject();
            DebugExprType type = DebugExprType.getTypeFromSymbolTableMetaObject(metaObj);
            return Pair.create(member, type);
        }
    } 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);
    }
    // not found: no exception is thrown as this node might be a function name
    return Pair.create(null, DebugExprType.getVoidType());
}
Also used : NodeLibrary(com.oracle.truffle.api.interop.NodeLibrary) DebugExprType(com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType) 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)

Aggregations

LLVMDebuggerValue (com.oracle.truffle.llvm.runtime.debug.LLVMDebuggerValue)4 InteropLibrary (com.oracle.truffle.api.interop.InteropLibrary)3 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)3 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)3 DebugExprType (com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType)3 NodeLibrary (com.oracle.truffle.api.interop.NodeLibrary)2 LLVMSourceType (com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType)2 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 Specialization (com.oracle.truffle.api.dsl.Specialization)1 LLVMSourcePointerType (com.oracle.truffle.llvm.runtime.debug.type.LLVMSourcePointerType)1 LLVMDebugObject (com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugObject)1 LLVMDebugValue (com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugValue)1 Builder (com.oracle.truffle.llvm.runtime.debug.value.LLVMDebugValue.Builder)1