Search in sources :

Example 1 with LLVMSourceSymbol

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

the class LLVMSourceScope method toScope.

private static LLVMSourceScope toScope(LLVMSourceLocation scope, LLVMSourceContext context, Node node, SourceSection sourceSection) {
    if (!scope.hasSymbols()) {
        final LLVMSourceScope sourceScope = new LLVMSourceScope(context, node);
        sourceScope.setName(scope.getName());
        return sourceScope;
    }
    final List<LLVMSourceSymbol> symbols = new LinkedList<>();
    final LLVMSourceScope sourceScope = new LLVMSourceScope(context, symbols, node);
    sourceScope.setName(scope.getName());
    for (LLVMSourceSymbol symbol : scope.getSymbols()) {
        if (symbol.isGlobal() || isDeclaredBefore(symbol, sourceSection)) {
            symbols.add(symbol);
        }
    }
    return sourceScope;
}
Also used : LLVMSourceSymbol(com.oracle.truffle.llvm.runtime.debug.LLVMSourceSymbol) LinkedList(java.util.LinkedList)

Example 2 with LLVMSourceSymbol

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

the class LLVMSourceScope method getVariables.

@TruffleBoundary
protected Object getVariables(Frame frame) {
    final Map<String, LLVMDebugObject> vars = new HashMap<>();
    if (frame != null && !symbols.isEmpty()) {
        for (FrameSlot slot : frame.getFrameDescriptor().getSlots()) {
            if (slot.getIdentifier() instanceof LLVMSourceSymbol && frame.getValue(slot) instanceof LLVMDebugValue) {
                final LLVMSourceSymbol symbol = (LLVMSourceSymbol) slot.getIdentifier();
                final LLVMDebugObject value = ((LLVMDebugValue) frame.getValue(slot)).getValue(symbol);
                if (symbols.contains(symbol)) {
                    vars.put(symbol.getName(), value);
                }
            }
        }
    }
    for (LLVMSourceSymbol symbol : symbols) {
        if (!vars.containsKey(symbol.getName())) {
            LLVMDebugValue dbgVal = context.getStatic(symbol);
            if (dbgVal == null) {
                final LLVMFrameValueAccess allocation = context.getFrameValue(symbol);
                if (allocation != null && frame != null) {
                    dbgVal = allocation.getValue(frame);
                }
            }
            if (dbgVal == null) {
                dbgVal = LLVMDebugValue.UNAVAILABLE;
            }
            vars.put(symbol.getName(), dbgVal.getValue(symbol));
        }
    }
    return new LLVMSourceScopeVariables(vars);
}
Also used : LLVMDebugObject(com.oracle.truffle.llvm.runtime.debug.LLVMDebugObject) FrameSlot(com.oracle.truffle.api.frame.FrameSlot) HashMap(java.util.HashMap) LLVMSourceSymbol(com.oracle.truffle.llvm.runtime.debug.LLVMSourceSymbol) LLVMDebugValue(com.oracle.truffle.llvm.runtime.debug.LLVMDebugValue) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 3 with LLVMSourceSymbol

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

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

the class DebugInfoCache method getSourceSymbol.

LLVMSourceSymbol getSourceSymbol(MDBaseNode mdVariable, boolean isGlobal) {
    if (parsedVariables.containsKey(mdVariable)) {
        return parsedVariables.get(mdVariable);
    }
    LLVMSourceLocation location = scopeBuilder.buildLocation(mdVariable);
    final LLVMSourceType type = typeExtractor.parseType(mdVariable);
    final String varName = MDNameExtractor.getName(mdVariable);
    final LLVMSourceSymbol symbol = new LLVMSourceSymbol(varName, location, type, isGlobal);
    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 : LLVMSourceLocation(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation) LLVMSourceSymbol(com.oracle.truffle.llvm.runtime.debug.LLVMSourceSymbol) LLVMSourceType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceType)

Example 5 with LLVMSourceSymbol

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

the class LLVMParserRuntime method getGlobalVariable.

private LLVMExpressionNode getGlobalVariable(LLVMSymbolReadResolver symbolResolver, GlobalValueSymbol global) {
    LLVMSourceSymbol sourceSymbol = null;
    SymbolImpl g = global;
    while (g instanceof GlobalAlias) {
        if (sourceSymbol == null) {
            sourceSymbol = ((GlobalAlias) g).getSourceSymbol();
        }
        g = aliases.get(g);
    }
    if (sourceSymbol == null && g instanceof GlobalValueSymbol) {
        sourceSymbol = ((GlobalValueSymbol) g).getSourceSymbol();
    }
    if (g instanceof GlobalValueSymbol) {
        final GlobalValueSymbol variable = (GlobalValueSymbol) g;
        final LLVMSourceSymbol finalSourceSymbol = sourceSymbol;
        Object globalVariableDescriptor = scope.lookupOrCreateGlobal(variable.getName(), !Linkage.isFileLocal(variable.getLinkage()), () -> {
            final Object globalValue;
            if (global instanceof GlobalVariable) {
                globalValue = nodeFactory.allocateGlobalVariable(this, (GlobalVariable) global, finalSourceSymbol);
            } else if (global instanceof GlobalConstant) {
                globalValue = nodeFactory.allocateGlobalConstant(this, (GlobalConstant) global, finalSourceSymbol);
            } else {
                throw new AssertionError("Cannot allocate global: " + global);
            }
            return globalValue;
        });
        return nodeFactory.createLiteral(this, globalVariableDescriptor, new PointerType(variable.getType()));
    } else {
        return symbolResolver.resolve(g);
    }
}
Also used : SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) GlobalVariable(com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalVariable) GlobalConstant(com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalConstant) LLVMSourceSymbol(com.oracle.truffle.llvm.runtime.debug.LLVMSourceSymbol) GlobalAlias(com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalAlias) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) GlobalValueSymbol(com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol)

Aggregations

LLVMSourceSymbol (com.oracle.truffle.llvm.runtime.debug.LLVMSourceSymbol)6 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)3 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)2 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 MDBaseNode (com.oracle.truffle.llvm.parser.metadata.MDBaseNode)1 MDExpression (com.oracle.truffle.llvm.parser.metadata.MDExpression)1 SourceVariable (com.oracle.truffle.llvm.parser.metadata.debuginfo.SourceVariable)1 GlobalAlias (com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalAlias)1 GlobalConstant (com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalConstant)1 GlobalValueSymbol (com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol)1 GlobalVariable (com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalVariable)1 AllocateInstruction (com.oracle.truffle.llvm.parser.model.symbols.instructions.AllocateInstruction)1 DbgDeclareInstruction (com.oracle.truffle.llvm.parser.model.symbols.instructions.DbgDeclareInstruction)1 DbgValueInstruction (com.oracle.truffle.llvm.parser.model.symbols.instructions.DbgValueInstruction)1 LLVMDebugObject (com.oracle.truffle.llvm.runtime.debug.LLVMDebugObject)1 LLVMDebugValue (com.oracle.truffle.llvm.runtime.debug.LLVMDebugValue)1 LLVMSourceStaticMemberType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceStaticMemberType)1 LLVMSourceType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceType)1 LLVMFrameValueAccess (com.oracle.truffle.llvm.runtime.debug.scope.LLVMFrameValueAccess)1 LLVMSourceLocation (com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation)1