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;
}
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);
}
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));
}
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;
}
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);
}
}
Aggregations