public class StackTrace extends Object
Modifier and Type | Class and Description |
---|---|
static class |
StackTrace.Element
Class to wrap up a stack frame element
|
(package private) static class |
StackTrace.InternalStackTraceElement
A stack trace element that contains additional debugging information,
namely machine code offsets and byte code indexes.
|
Modifier and Type | Field and Description |
---|---|
private int[] |
compiledMethods
The compiled method ids of the stack trace.
|
private int[] |
instructionOffsets
The offset of the instruction within the compiled method
|
private static int |
lastTraceIndex
Index of the last stack trace; only used to support VM.VerboseStackTracePeriod
|
private static boolean |
PRINT_INTERNAL_STACK_TRACE
Prints an internal stack trace for every stack trace obtained via
getStackTrace(Throwable) . |
Constructor and Description |
---|
StackTrace()
Create a trace for the call stack of the current thread
|
StackTrace(RVMThread rvmThread)
Constructs a stack trace.
|
Modifier and Type | Method and Description |
---|---|
private void |
assertThreadBlockedOrCurrent(RVMThread rvmThread) |
private StackTrace.Element[] |
buildStackTrace(int first,
int last) |
private int |
countFrames(int first,
int last)
Count number of stack frames including those inlined by the opt compiler
|
private int |
countFramesUninterruptible(RVMThread stackTraceThread)
Walk the stack counting the number of stack frames encountered.
|
private StackTrace.Element |
createOptStackTraceElement(RVMMethod m,
int ln,
Offset mcOffset,
int bci) |
private StackTrace.Element |
createStandardStackTraceElement(CompiledMethod cm,
int off) |
private int |
firstRealMethod()
Finds the first non-VM method in the stack trace.
|
private int |
firstRealMethod(Throwable cause)
Find the first non-VM method/exception initializer method in the stack
trace.
|
private CompiledMethod |
getCompiledMethod(int element) |
StackTrace.Element[] |
getStackTrace(Throwable cause) |
private int |
lastRealMethod(int first)
Find the first non-VM method at the end of the stack trace
|
private void |
recordFramesUninterruptible(RVMThread stackTraceThread)
Walk the stack recording the stack frames encountered
The stack being walked is our stack, so code is Uninterrupible to stop the
stack moving.
|
private int |
removeStackTraceFrames(int element)
Removes all frames from the StackTrace class (i.e. this class) from
the stack trace by skipping them.
|
StackTrace.Element[] |
stackTraceNoException(int framesToSkip)
Gets a stack trace at the current point in time, assuming the thread didn't
throw any exception.
|
private static final boolean PRINT_INTERNAL_STACK_TRACE
getStackTrace(Throwable)
. The internal stack trace
has machine code offsets and bytecode index information for methods.private final int[] compiledMethods
private final int[] instructionOffsets
private static int lastTraceIndex
public StackTrace()
public StackTrace(RVMThread rvmThread)
Note: no inlining directives here because they aren't necessary for correctness. This class removes all frames belonging to its methods.
rvmThread
- the thread whose stack is examined. It is the caller's
responsibility to block that thread if required.private void assertThreadBlockedOrCurrent(RVMThread rvmThread)
private int countFramesUninterruptible(RVMThread stackTraceThread)
stackTraceThread
- the thread whose stack is walkedprivate void recordFramesUninterruptible(RVMThread stackTraceThread)
stackTraceThread
- the thread whose stack is walkedprivate CompiledMethod getCompiledMethod(int element)
public StackTrace.Element[] getStackTrace(Throwable cause)
cause
- the throwable that caused the stack traceprivate StackTrace.Element createStandardStackTraceElement(CompiledMethod cm, int off)
private StackTrace.Element createOptStackTraceElement(RVMMethod m, int ln, Offset mcOffset, int bci)
private StackTrace.Element[] buildStackTrace(int first, int last)
private int countFrames(int first, int last)
first
- the first compiled method to look fromlast
- the last compiled method to look toprivate int firstRealMethod(Throwable cause)
cause
- the cause of generating the stack trace marking the end of the
frames to elideprivate int firstRealMethod()
firstRealMethod(Throwable)
: it is only necessary to skip
frames from this class.private int removeStackTraceFrames(int element)
Note: Callers must update all data relating to the element index themselves.
element
- the element indexprivate int lastRealMethod(int first)
first
- the first real method of the stack tracepublic StackTrace.Element[] stackTraceNoException(int framesToSkip)
framesToSkip
- count of frames to skip. Note: frames from this class are always
skipped and thus not included in the count. For example, if the caller were
foo()
and you wanted to skip foo
's frame, you would pass
1
.