public class ThreadInfo extends InfoObject implements Iterable<StackFrame>, Comparable<ThreadInfo>, Restorable<ThreadInfo>
Modifier and Type | Class and Description |
---|---|
protected class |
ThreadInfo.InvokedStackIterator |
protected class |
ThreadInfo.StackIterator |
static class |
ThreadInfo.State |
Modifier and Type | Field and Description |
---|---|
protected ApplicationContext |
appCtx |
protected int |
attributes |
protected ClassInfo |
ci |
protected int |
executedInstructions
counter for executed instructions along current transition
|
protected int |
id |
protected boolean |
logInstruction
store the last executed insn in the path
|
protected Instruction |
nextPc
the next insn to enter (null prior to execution)
|
protected int |
objRef |
protected ExceptionInfo |
pendingException |
protected gov.nasa.jpf.vm.ThreadInfo.SUTExceptionRequest |
pendingSUTExceptionRequest
a listener or peer request for throwing an exception into the SUT, to be processed in executeInstruction
|
protected DirectCallStackFrame |
returnedDirectCall
the last returned direct call frame
|
protected boolean |
skipInstruction
shall we skip the next insn
|
protected int |
stackDepth |
protected int |
targetRef |
protected ThreadData |
threadData |
protected int |
tlIdx |
protected StackFrame |
top |
annotations, attr
Modifier | Constructor and Description |
---|---|
protected |
ThreadInfo(VM vm,
int id,
ApplicationContext appCtx)
mainThread ctor called by the VM.
|
protected |
ThreadInfo(VM vm,
int objRef,
int groupRef,
int runnableRef,
int nameRef,
ThreadInfo parent)
the ctor for all explicitly (bytecode) created threads.
|
Modifier and Type | Method and Description |
---|---|
void |
advancePC() |
boolean |
atMethod(String mname) |
boolean |
atPosition(int position) |
boolean |
atReturn() |
void |
breakTransition()
this is a version that unconditionally breaks the current transition
without really adding choices.
|
void |
breakTransition(boolean isTerminator)
this breaks the current transition with a CG that forces an end state (i.e.
|
protected Instruction |
callUncaughtHandler(ExceptionInfo xi)
this explicitly models the standard ThreadGroup.uncaughtException(), but we want
to save us a roundtrip if that's the only handler we got.
|
protected Instruction |
callUncaughtHandler(ExceptionInfo xi,
int handlerRef,
String id) |
protected void |
checkAssertion(boolean cond,
String failMsg) |
void |
checkConsistency(boolean isStore)
only for debugging purposes
|
boolean |
checkPorFieldBoundary() |
void |
clearPendingException()
watch out - just clearing it might cause an infinite loop
if we don't drop frames and/or advance the pc
|
Object |
clone() |
int |
compareTo(ThreadInfo that)
Comparison for sorting based on index.
|
protected int |
computeId(int objRef) |
int |
countStackFrames()
Returns the number of stack frames.
|
Instruction |
createAndThrowException(ClassInfo ci,
String details)
Creates and throws an exception.
|
Instruction |
createAndThrowException(String cname)
Creates an exception and throws it.
|
Instruction |
createAndThrowException(String cname,
String details) |
int |
createStackTraceElements(int[] snapshot)
turn a snapshot into an JPF array of StackTraceElements, which means
a lot of objects.
|
void |
dumpStoringData(IntVector v)
Returns the information necessary to store.
|
void |
enter()
note - this assumes the stackframe of the method to enter is already initialized and on top (pushed)
|
Instruction |
executeInstruction()
Execute next instruction.
|
Instruction |
executeInstructionHidden()
enter instruction hidden from any listeners, and do not
record it in the path
|
void |
executeMethodAtomic(StackFrame frame)
Executes a method call.
|
void |
executeMethodHidden(StackFrame frame)
enter method atomically, but also hide it from listeners and do NOT add
executed instructions to the path.
|
protected void |
executeTransition(SystemState ss)
enter instructions until there is none left or somebody breaks
the transition (e.g.
|
boolean |
exit()
this should only be called from the top half of the last DIRECTCALLRETURN of
a thread.
|
ApplicationContext |
getApplicationContext() |
ElementInfo |
getBlockedObject(MethodInfo mi,
boolean isBeforeCall,
boolean isModifiable) |
Memento<ThreadInfo> |
getCachedMemento() |
int |
getCalleeThis(int size)
Returns the this pointer of the callee from the stack.
|
int |
getCalleeThis(MethodInfo mi)
Returns the this pointer of the callee from the stack.
|
StackFrame |
getCallerStackFrame() |
StackFrame |
getCallerStackFrame(int offset) |
ClassInfo |
getClassInfo()
Returns the class information.
|
ClassInfo |
getClassInfo(int objref) |
static ThreadInfo |
getCurrentThread() |
ElementInfo |
getElementInfo(int ref) |
MethodInfo |
getEntryMethod() |
MJIEnv |
getEnv() |
int |
getExecutedInstructions()
get the number of instructions executed in the current transition.
|
ClassInfo |
getExecutingClassInfo()
return the ClassInfo of the topmost stackframe that is not a direct call
|
int |
getGlobalId()
this is our internal, search global id that is used for the
canonical root set
|
protected int |
getGlobalUncaughtHandler() |
HandlerContext |
getHandlerContextFor(ClassInfo ciException)
this is basically a side-effect free version of throwException to determine if a given
exception will be handled.
|
Heap |
getHeap() |
int |
getId()
path local unique id for live threads.
|
protected int |
getInstanceUncaughtHandler() |
List<StackFrame> |
getInvokedStackFrames()
returns StackFrames which have been entered through a corresponding
invoke instruction (in top first order)
|
StackFrame |
getLastInvokedStackFrame() |
StackFrame |
getLastNonSyntheticStackFrame() |
int |
getLine()
Returns the line number of the program counter of the top stack frame.
|
int |
getLockCount()
Returns the number of locks in the last wait.
|
int[] |
getLockedObjectReferences() |
List<ElementInfo> |
getLockedObjects() |
ElementInfo |
getLockObject() |
int |
getLockRef() |
Memento<ThreadInfo> |
getMemento() |
Memento<ThreadInfo> |
getMemento(MementoFactory factory) |
MJIEnv |
getMJIEnv() |
ElementInfo |
getModifiableElementInfo(int ref) |
StackFrame |
getModifiableFrame(StackFrame frame)
this replaces all frames up from 'frame' to 'top' with modifiable ones.
|
StackFrame |
getModifiableLastNonSyntheticStackFrame() |
ElementInfo |
getModifiableThreadObject() |
StackFrame |
getModifiableTopFrame()
Returns a clone of the top stack frame.
|
String |
getName() |
Instruction |
getNextPC() |
Instruction |
getPC()
Returns the program counter of the top stack frame.
|
ExceptionInfo |
getPendingException() |
int |
getPriority() |
DirectCallStackFrame |
getReturnedDirectCall() |
int |
getRunnableRef()
Returns the object reference of the target.
|
int[] |
getSnapshot(int xObjRef)
get a stack snapshot that consists of an array of {mthId,pc} pairs.
|
List<StackFrame> |
getStack()
Deprecated.
- use Iterable
|
int |
getStackDepth() |
StackFrame |
getStackFrameExecuting(Instruction insn,
int offset)
note that we don't provide a modifiable version of this.
|
String |
getStackTrace()
get the current stack trace of this thread
this is called during creation of a Throwable, hence we should skip
all throwable ctors in here
<2do> this is only a partial solution,since we don't catch exceptionHandlers
in Throwable ctors yet
|
ThreadInfo.State |
getState()
Returns the current status of the thread.
|
String |
getStateDescription() |
String |
getStateName() |
SystemClassLoaderInfo |
getSystemClassLoaderInfo() |
int |
getThis()
Returns the pointer to the object reference of the executing method
|
ElementInfo |
getThisElementInfo() |
protected int |
getThreadGroupRef() |
protected int |
getThreadGroupUncaughtHandler(int grpRef) |
ElementInfo |
getThreadObject() |
ClassInfo |
getThreadObjectClassInfo() |
int |
getThreadObjectRef()
Returns the object reference.
|
StackFrame |
getTopFrame()
Returns the top stack frame.
|
MethodInfo |
getTopFrameMethodInfo()
returns the current method in the top stack frame, which is always a
bytecode method (executed by JPF)
|
VM |
getVM() |
boolean |
hasBeenStarted() |
boolean |
hasChanged() |
boolean |
hasDataChanged() |
void |
hash(HashData hd) |
boolean |
hasLockedObjects() |
boolean |
hasOtherNonDaemonRunnables() |
boolean |
hasOtherRunnables() |
boolean |
hasReturnedFromDirectCall() |
boolean |
hasReturnedFromDirectCall(String directCallId) |
boolean |
hasStackChanged() |
boolean |
hasUncaughtHandler()
is there any UncaughHandler in effect for this thread?
NOTE - this doesn't check if we are already executing one (i.e.
|
boolean |
holdsLock(ElementInfo ei) |
protected void |
initFields(VM vm) |
protected void |
initReferenceFields(int objRef,
int groupRef,
int runnableRef,
int nameRef) |
void |
interrupt() |
Iterable<StackFrame> |
invokedStackFrames() |
boolean |
isAlive()
An alive thread is anything but TERMINATED or NEW
|
boolean |
isBlocked() |
boolean |
isBlockedOrNotified() |
boolean |
isCalleeThis(ElementInfo r) |
boolean |
isClinitOnStack(ClassInfo ci) |
boolean |
isCtorOnStack(int objRef) |
boolean |
isCurrentThread() |
boolean |
isDaemon() |
boolean |
isExecutingAtomically() |
boolean |
isFirstStepInsn()
answers if is this the first instruction within the current transition.
|
boolean |
isInCtor() |
boolean |
isInCurrentThreadList() |
boolean |
isInNativeMethod() |
boolean |
isInstructionSkipped() |
boolean |
isInterrupted(boolean resetStatus) |
boolean |
isNew() |
boolean |
isNotified() |
boolean |
isPostExec()
is this after calling Instruction.enter()
used by instructions and listeners
|
boolean |
isPreExec()
to be used from methods called from listeners, to find out if we are in a
pre- or post-exec notification
|
boolean |
isRunnable()
Returns true if this thread is either RUNNING or UNBLOCKED
|
boolean |
isSleeping() |
boolean |
isStopped() |
boolean |
isSuspended() |
boolean |
isTerminated() |
boolean |
isThis(ElementInfo ei) |
boolean |
isTimedOut() |
boolean |
isTimeoutRunnable() |
boolean |
isTimeoutWaiting() |
boolean |
isUnblocked() |
protected boolean |
isUncaughtHandlerOnStack() |
boolean |
isWaiting() |
Iterator<StackFrame> |
iterator() |
void |
leave()
note - this assumes the stackframe is still on top (not yet popped)
|
protected void |
markTdChanged() |
protected void |
markTfChanged(StackFrame frame) |
protected void |
markUnchanged() |
int |
mixinExecutionStateHash(int h) |
StackFrame |
popAndGetModifiableTopFrame() |
StackFrame |
popDirectCallFrame()
removing DirectCallStackFrames is a bit different (only happens from
DIRECTCALLRETURN insns)
|
void |
popFrame()
Removes a stack frame
|
protected StackFrame |
popUncaughtHandlerFrame() |
void |
printPendingExceptionOn(PrintWriter pw) |
void |
printStackContent()
Prints the content of the stack
|
void |
printStackTrace()
Prints current stacktrace information
|
void |
printStackTrace(int objRef) |
void |
printStackTrace(PrintWriter pw,
int objRef)
the reason why this is kind of duplicated (there is also a StackFrame.getPositionInfo)
is that this might be working off a StackTraceElement[] that is created when the exception
is created.
|
protected void |
processPendingSUTExceptionRequest() |
void |
pushFrame(StackFrame frame)
Adds a new stack frame for a new called method.
|
void |
reExecuteInstruction() |
void |
requestSUTException(String exceptionClsName,
String details) |
void |
reschedule(boolean forceBreak)
request a reschedule no matter what the next insn is
Note this unconditionally creates and registers a ThreadCG, even if there is
only one runnable thread (ourself).
|
void |
resetLockRef()
thread is not blocked anymore
needs to be public since we have to use it from INVOKECLINIT (during call skipping)
|
void |
resetTimedOut() |
ClassInfo |
resolveReferencedClass(String clsName) |
void |
restoreThreadData(ThreadData td) |
boolean |
resume()
unset suspension status
|
void |
setCachedMemento(Memento<ThreadInfo> memento) |
void |
setLockCount(int l)
Sets the number of locks held at the time of a wait.
|
boolean |
setNextPC(Instruction insn)
explicitly set the next insn to enter.
|
void |
setPC(Instruction pc)
Sets the program counter of the top stack frame.
|
void |
setPriority(int newPrio) |
void |
setRunning() |
void |
setSleeping() |
void |
setState(ThreadInfo.State newStatus)
Updates the status of the thread.
|
void |
setStopped(int throwableRef) |
void |
setTerminated() |
void |
setTimedOut() |
void |
setTopFrame(StackFrame frame)
replace the top frame - this is a dangerous method that should only
be used from Restoreres and to restore operators and locals in post-execution notifications
to their pre-execution contents
|
void |
skipInstruction()
Deprecated.
|
void |
skipInstruction(Instruction nextInsn)
skip the next bytecode.
|
void |
skipInstructionLogging() |
boolean |
suspend()
set suspension status
|
protected ThreadData |
threadDataClone()
Returns a clone of the thread data.
|
Instruction |
throwException(int exceptionObjRef)
unwind stack frames until we find a matching handler for the exception object
|
String |
toString() |
protected void |
unwindTo(StackFrame newTopFrame) |
protected StackFrame |
unwindToFirstFrame() |
boolean |
useBreakOnExposure() |
boolean |
usePor() |
boolean |
usePorFieldBoundaries() |
boolean |
usePorSyncDetection() |
boolean |
useUnsharedInit() |
boolean |
willBeRunnable() |
boolean |
willReExecuteInstruction() |
boolean |
yield() |
addAnnotation, addAttr, attrIterator, attrIterator, getAnnotation, getAnnotations, getAttr, getAttr, getDeclaredAnnotations, getNextAttr, hasAnnotations, hasAttr, hasAttr, hasAttrValue, removeAttr, replaceAttr, setAnnotations, setAttr
protected ExceptionInfo pendingException
protected ThreadData threadData
protected StackFrame top
protected int stackDepth
protected int tlIdx
protected ApplicationContext appCtx
protected int id
protected int objRef
protected ClassInfo ci
protected int targetRef
protected int attributes
protected int executedInstructions
protected boolean skipInstruction
protected gov.nasa.jpf.vm.ThreadInfo.SUTExceptionRequest pendingSUTExceptionRequest
protected boolean logInstruction
protected DirectCallStackFrame returnedDirectCall
protected Instruction nextPc
protected ThreadInfo(VM vm, int id, ApplicationContext appCtx)
protected ThreadInfo(VM vm, int objRef, int groupRef, int runnableRef, int nameRef, ThreadInfo parent)
protected int computeId(int objRef)
protected void initFields(VM vm)
protected void initReferenceFields(int objRef, int groupRef, int runnableRef, int nameRef)
public Memento<ThreadInfo> getMemento(MementoFactory factory)
getMemento
in interface Restorable<ThreadInfo>
public Memento<ThreadInfo> getMemento()
public Memento<ThreadInfo> getCachedMemento()
public void setCachedMemento(Memento<ThreadInfo> memento)
public static ThreadInfo getCurrentThread()
public boolean isExecutingAtomically()
public boolean holdsLock(ElementInfo ei)
public VM getVM()
public boolean isFirstStepInsn()
public int getExecutedInstructions()
public boolean isPreExec()
public boolean usePor()
public boolean usePorFieldBoundaries()
public boolean useBreakOnExposure()
public boolean usePorSyncDetection()
public boolean useUnsharedInit()
public void setState(ThreadInfo.State newStatus)
public ThreadInfo.State getState()
public boolean isRunnable()
public boolean willBeRunnable()
public boolean isNew()
public boolean isTimeoutRunnable()
public boolean isTimedOut()
public boolean isTimeoutWaiting()
public void setTimedOut()
public void setTerminated()
public void resetTimedOut()
public void setSleeping()
public boolean isSleeping()
public void setRunning()
public void setStopped(int throwableRef)
public boolean isCurrentThread()
public boolean isInCurrentThreadList()
public boolean isAlive()
public boolean isWaiting()
public boolean isNotified()
public boolean isUnblocked()
public boolean isBlocked()
public boolean isTerminated()
public boolean isBlockedOrNotified()
public boolean isStopped()
public boolean isInNativeMethod()
public boolean hasBeenStarted()
public String getStateName()
public Iterator<StackFrame> iterator()
iterator
in interface Iterable<StackFrame>
public Iterable<StackFrame> invokedStackFrames()
@Deprecated public List<StackFrame> getStack()
public List<StackFrame> getInvokedStackFrames()
public int getStackDepth()
public MethodInfo getEntryMethod()
public StackFrame getCallerStackFrame(int offset)
public StackFrame getLastInvokedStackFrame()
public StackFrame getLastNonSyntheticStackFrame()
public StackFrame getModifiableLastNonSyntheticStackFrame()
public int getCalleeThis(MethodInfo mi)
public int getCalleeThis(int size)
public ClassInfo getClassInfo(int objref)
public boolean isCalleeThis(ElementInfo r)
public ApplicationContext getApplicationContext()
public SystemClassLoaderInfo getSystemClassLoaderInfo()
public ClassInfo getClassInfo()
public MJIEnv getEnv()
public boolean isInterrupted(boolean resetStatus)
public int getId()
public int getGlobalId()
public void resetLockRef()
public int getLockRef()
public ElementInfo getLockObject()
public int getLine()
public boolean suspend()
public boolean resume()
public boolean isSuspended()
public void setLockCount(int l)
public int getLockCount()
public List<ElementInfo> getLockedObjects()
public boolean hasLockedObjects()
public int[] getLockedObjectReferences()
public MethodInfo getTopFrameMethodInfo()
public ClassInfo getExecutingClassInfo()
public boolean isInCtor()
public boolean isCtorOnStack(int objRef)
public boolean isClinitOnStack(ClassInfo ci)
public String getName()
public int getThreadObjectRef()
public ElementInfo getThreadObject()
public ElementInfo getModifiableThreadObject()
public void setPC(Instruction pc)
public void advancePC()
public Instruction getPC()
public Instruction getNextPC()
public String getStackTrace()
public void dumpStoringData(IntVector v)
public int getRunnableRef()
public int getThis()
public ElementInfo getThisElementInfo()
public boolean isThis(ElementInfo ei)
public boolean atMethod(String mname)
public boolean atPosition(int position)
public boolean atReturn()
public int countStackFrames()
public int[] getSnapshot(int xObjRef)
public int createStackTraceElements(int[] snapshot)
public void printStackTrace(int objRef)
public void printPendingExceptionOn(PrintWriter pw)
public void printStackTrace(PrintWriter pw, int objRef)
protected void processPendingSUTExceptionRequest()
public Instruction createAndThrowException(ClassInfo ci, String details)
public Instruction createAndThrowException(String cname)
public Instruction createAndThrowException(String cname, String details)
protected void executeTransition(SystemState ss) throws JPFException
JPFException
public Instruction executeInstruction()
public Instruction executeInstructionHidden()
public boolean isPostExec()
public void reExecuteInstruction()
public boolean willReExecuteInstruction()
public void skipInstruction(Instruction nextInsn)
@Deprecated public void skipInstruction()
public boolean isInstructionSkipped()
public void skipInstructionLogging()
public boolean setNextPC(Instruction insn)
public void executeMethodAtomic(StackFrame frame)
public void executeMethodHidden(StackFrame frame)
public Heap getHeap()
public ElementInfo getElementInfo(int ref)
public ElementInfo getModifiableElementInfo(int ref)
public ElementInfo getBlockedObject(MethodInfo mi, boolean isBeforeCall, boolean isModifiable)
public void enter()
public void leave()
public boolean exit()
public void hash(HashData hd)
public void interrupt()
public void setTopFrame(StackFrame frame)
public void pushFrame(StackFrame frame)
public void popFrame()
public StackFrame popAndGetModifiableTopFrame()
public StackFrame popDirectCallFrame()
public boolean hasReturnedFromDirectCall()
public boolean hasReturnedFromDirectCall(String directCallId)
public DirectCallStackFrame getReturnedDirectCall()
public String getStateDescription()
public ClassInfo getThreadObjectClassInfo()
public void printStackContent()
public void printStackTrace()
public HandlerContext getHandlerContextFor(ClassInfo ciException)
public Instruction throwException(int exceptionObjRef)
public boolean hasUncaughtHandler()
protected Instruction callUncaughtHandler(ExceptionInfo xi)
protected boolean isUncaughtHandlerOnStack()
protected int getInstanceUncaughtHandler()
protected int getThreadGroupRef()
protected int getThreadGroupUncaughtHandler(int grpRef)
protected int getGlobalUncaughtHandler()
protected Instruction callUncaughtHandler(ExceptionInfo xi, int handlerRef, String id)
protected StackFrame popUncaughtHandlerFrame()
protected void unwindTo(StackFrame newTopFrame)
protected StackFrame unwindToFirstFrame()
public ExceptionInfo getPendingException()
public void clearPendingException()
protected ThreadData threadDataClone()
public void restoreThreadData(ThreadData td)
public void reschedule(boolean forceBreak)
public void breakTransition()
public boolean yield()
public void breakTransition(boolean isTerminator)
public boolean checkPorFieldBoundary()
public boolean hasOtherRunnables()
public boolean hasOtherNonDaemonRunnables()
protected void markUnchanged()
protected void markTfChanged(StackFrame frame)
protected void markTdChanged()
public StackFrame getCallerStackFrame()
public int mixinExecutionStateHash(int h)
public boolean hasDataChanged()
public boolean hasStackChanged()
public boolean hasChanged()
public StackFrame getModifiableTopFrame()
public StackFrame getTopFrame()
public StackFrame getModifiableFrame(StackFrame frame)
public StackFrame getStackFrameExecuting(Instruction insn, int offset)
public boolean isDaemon()
public MJIEnv getMJIEnv()
public void setPriority(int newPrio)
public int getPriority()
public int compareTo(ThreadInfo that)
compareTo
in interface Comparable<ThreadInfo>
public void checkConsistency(boolean isStore)
protected void checkAssertion(boolean cond, String failMsg)