Skip to content

Commit

Permalink
Fix LLVM debug information at the beginning of a function.
Browse files Browse the repository at this point in the history
  • Loading branch information
rschatz committed Apr 20, 2020
1 parent 4520ef4 commit c81c81c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ public Map<LLVMSourceSymbol, Object> getLocalVariables(Frame frame, Node node) {
}
current = current.getParent();
}
return null;
/*
* If `node` is not a child of a basic block, we are stopped before entering the dispatch
* loop. Treat this as if we're stopped at the first statement of the first block.
*/
return getLocalVariablesForIndex(frame, 0, 0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
import com.oracle.truffle.api.dsl.TypeSystemReference;
import com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode;
import com.oracle.truffle.api.instrumentation.StandardTags.StatementTag;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.RootNode;
Expand Down Expand Up @@ -198,14 +199,21 @@ public static boolean isAutoDerefHandle(LLVMLanguage language, long addr) {

/**
* Get the closest parent of {@code node} with the given type, or {@code null} is no node in the
* parent chain has the given type.
* parent chain has the given type. This method will also look into wrapped parents, returning
* the delegate node if it has the given type.
*/
public static <T extends Node> T getParent(Node node, Class<T> clazz) {
Node current = node;
while (current != null) {
if (clazz.isInstance(current)) {
return clazz.cast(current);
}
if (current instanceof WrapperNode) {
Node delegate = ((WrapperNode) current).getDelegateNode();
if (clazz.isInstance(delegate)) {
return clazz.cast(delegate);
}
}
current = current.getParent();
}
return null;
Expand Down

0 comments on commit c81c81c

Please sign in to comment.