Search in sources :

Example 1 with MDBaseNode

use of com.oracle.truffle.llvm.parser.metadata.MDBaseNode in project sulong by graalvm.

the class DebugInfoModuleProcessor method processModule.

public static void processModule(ModelModule irModel, Source bitcodeSource, MetadataValueList metadata) {
    MDUpgrade.perform(metadata);
    final DebugInfoCache cache = new DebugInfoCache(metadata, irModel.getSourceStaticMembers());
    final Map<LLVMSourceSymbol, SymbolImpl> globals = irModel.getSourceGlobals();
    final Map<LLVMSourceStaticMemberType, SymbolImpl> staticMembers = irModel.getSourceStaticMembers();
    irModel.accept(new SymbolProcessor(cache, bitcodeSource, globals, staticMembers));
    final MDBaseNode cuNode = metadata.getNamedNode(MDNamedNode.COMPILEUNIT_NAME);
    final MetadataProcessor mdParser = new MetadataProcessor(cache, globals, staticMembers);
    if (cuNode != null) {
        cuNode.accept(mdParser);
    }
    irModel.setFunctionProcessor(new DebugInfoFunctionProcessor(cache));
}
Also used : SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) LLVMSourceSymbol(com.oracle.truffle.llvm.runtime.debug.LLVMSourceSymbol) MDBaseNode(com.oracle.truffle.llvm.parser.metadata.MDBaseNode) LLVMSourceStaticMemberType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceStaticMemberType)

Example 2 with MDBaseNode

use of com.oracle.truffle.llvm.parser.metadata.MDBaseNode in project sulong by graalvm.

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(sourceText).mimeType(DIScopeBuilder.getMimeType(null)).name(sourceText).build();
        final SourceSection simpleSection = irSource.createSection(1);
        scope = LLVMSourceLocation.createBitcodeFunction(function.getName(), simpleSection);
    }
    final SourceFunction sourceFunction = new SourceFunction(scope, type);
    function.setSourceFunction(sourceFunction);
    for (SourceVariable local : sourceFunction.getVariables()) {
        local.processFragments();
    }
}
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.LLVMSourceType) SourceSection(com.oracle.truffle.api.source.SourceSection) LLVMSourceFunctionType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceFunctionType) Source(com.oracle.truffle.api.source.Source)

Example 3 with MDBaseNode

use of com.oracle.truffle.llvm.parser.metadata.MDBaseNode in project sulong by graalvm.

the class DebugInfoGenerator method getSourceFunctionName.

public static String getSourceFunctionName(FunctionDefinition function) {
    if (function.hasAttachedMetadata()) {
        final MDBaseNode attachment = function.getMetadataAttachment(MDKind.DBG_NAME);
        if (attachment != null) {
            final DIVisitor visitor = new DIVisitor();
            attachment.accept(visitor);
            return visitor.getFunctionName();
        }
    }
    return null;
}
Also used : MDBaseNode(com.oracle.truffle.llvm.parser.metadata.MDBaseNode)

Aggregations

MDBaseNode (com.oracle.truffle.llvm.parser.metadata.MDBaseNode)3 Source (com.oracle.truffle.api.source.Source)1 SourceSection (com.oracle.truffle.api.source.SourceSection)1 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)1 LLVMSourceFunctionType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceFunctionType)1 LLVMSourceStaticMemberType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceStaticMemberType)1 LLVMSourceSymbol (com.oracle.truffle.llvm.runtime.debug.LLVMSourceSymbol)1 LLVMSourceType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceType)1 LLVMSourceLocation (com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation)1