Search in sources :

Example 6 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(MDGlobalVariable mdGlobal) {
    final LLVMSourceType type = resolve(mdGlobal.getType());
    parsedTypes.put(mdGlobal, type);
    if (mdGlobal.getStaticMemberDeclaration() != MDVoidNode.INSTANCE && mdGlobal.getVariable() instanceof MDValue) {
        final LLVMSourceType declType = resolve(mdGlobal.getStaticMemberDeclaration());
        final SymbolImpl symbol = ((MDValue) mdGlobal.getVariable()).getValue();
        if (declType instanceof LLVMSourceStaticMemberType) {
            staticMembers.put((LLVMSourceStaticMemberType) declType, symbol);
        }
    }
}
Also used : SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) MDValue(com.oracle.truffle.llvm.parser.metadata.MDValue) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType) LLVMSourceStaticMemberType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceStaticMemberType)

Example 7 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(MDString mdString) {
    final MDCompositeType referencedType = metadata.identifyType(mdString.getString());
    if (referencedType != null) {
        final LLVMSourceType type = resolve(referencedType);
        parsedTypes.put(mdString, type);
    }
}
Also used : LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType) MDCompositeType(com.oracle.truffle.llvm.parser.metadata.MDCompositeType)

Example 8 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(MDSubprogram mdSubprogram) {
    // 'this' parameter of thunk methods is missing in the debug info, thus fix here.
    LLVMSourceType llvmSourceType = resolve(mdSubprogram.getType());
    if (Flags.THUNK.isSetIn(mdSubprogram.getFlags())) {
        SymbolImpl symbol = MDValue.getIfInstance(mdSubprogram.getFunction());
        if (symbol != null && symbol instanceof FunctionDefinition) {
            FunctionDefinition function = (FunctionDefinition) symbol;
            final DataLayout dataLayout = LLVMLanguage.get(null).getDefaultDataLayout();
            LLVMSourceType llvmSourceReturnType = LLVMSourceTypeFactory.resolveType(function.getType().getReturnType(), dataLayout);
            List<LLVMSourceType> typeList = new ArrayList<>();
            typeList.add(llvmSourceReturnType);
            for (FunctionParameter fp : function.getParameters()) {
                LLVMSourceType parameterSourceType = LLVMSourceTypeFactory.resolveType(fp.getType(), dataLayout);
                typeList.add(parameterSourceType);
            }
            llvmSourceType = new LLVMSourceFunctionType(typeList);
        }
    }
    parsedTypes.put(mdSubprogram, llvmSourceType);
}
Also used : DataLayout(com.oracle.truffle.llvm.runtime.datalayout.DataLayout) SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) ArrayList(java.util.ArrayList) FunctionDefinition(com.oracle.truffle.llvm.parser.model.functions.FunctionDefinition) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType) LLVMSourceFunctionType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType) FunctionParameter(com.oracle.truffle.llvm.parser.model.functions.FunctionParameter)

Example 9 with LLVMSourceType

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

the class DebugInfoFunctionProcessor method initSourceFunction.

private void initSourceFunction(FunctionDefinition function, Source bitcodeSource) {
    final MDBaseNode debugInfo = getDebugInfo(function);
    LLVMSourceLocation scope = null;
    LLVMSourceFunctionType type = null;
    if (debugInfo != null) {
        scope = cache.buildLocation(debugInfo);
        LLVMSourceType actualType = cache.parseType(debugInfo);
        if (actualType instanceof LLVMSourceFunctionType) {
            type = (LLVMSourceFunctionType) actualType;
        }
    }
    if (scope == null) {
        final String sourceText = String.format("%s:%s", bitcodeSource.getName(), function.getName());
        final Source irSource = Source.newBuilder("llvm", sourceText, sourceText).mimeType(DIScopeBuilder.getMimeType(null)).build();
        final SourceSection simpleSection = irSource.createSection(1);
        scope = LLVMSourceLocation.createBitcodeFunction(function.getName(), simpleSection);
    }
    final SourceFunction sourceFunction = new SourceFunction(scope, type);
    function.setSourceFunction(sourceFunction);
}
Also used : MDBaseNode(com.oracle.truffle.llvm.parser.metadata.MDBaseNode) LLVMSourceLocation(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType) SourceSection(com.oracle.truffle.api.source.SourceSection) LLVMSourceFunctionType(com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceFunctionType) Source(com.oracle.truffle.api.source.Source)

Example 10 with LLVMSourceType

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

the class DebugInfoCache method getSourceSymbol.

LLVMSourceSymbol getSourceSymbol(MDBaseNode mdVariable, boolean isStatic) {
    LLVMSourceSymbol lookup = parsedVariables.get(mdVariable);
    if (lookup != null) {
        return lookup;
    }
    LLVMSourceLocation location = scopeBuilder.buildLocation(mdVariable);
    final LLVMSourceType type = typeExtractor.parseType(mdVariable);
    final String varName = MDNameExtractor.getName(mdVariable);
    final LLVMSourceSymbol symbol = LLVMSourceSymbol.create(varName, location, type, isStatic);
    parsedVariables.put(mdVariable, symbol);
    if (location != null) {
        // this is currently the line/column where the symbol was declared, we want the
        // scope
        location = location.getParent();
    }
    if (location != null) {
        location.addSymbol(symbol);
    }
    return symbol;
}
Also used : LLVMSourceSymbol(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceSymbol) LLVMSourceLocation(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation) 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