Class CallStack
java.lang.Object
org.eclipse.tracecompass.incubator.callstack.core.flamechart.CallStack
Represents the actual callstack for one element. The callstack is a stack of
calls, whether function calls, executions, sub-routines that have a certain
depth and where durations at each depth is in the form of a reverse pyramid,
ie, a call at level n+1 will have start_n+1 >= start_n and end_n+1
<= end_n.
TODO: Is that true? the reverse pyramid?
- Author:
- Geneviève Bastien
-
Constructor Summary
ConstructorDescriptionCallStack
(ITmfStateSystem ss, List<Integer> quarks, ICallStackElement element, CallStackHostUtils.IHostIdProvider hostIdProvider, @Nullable CallStackSeries.IThreadIdProvider threadIdProvider) Constructor -
Method Summary
Modifier and TypeMethodDescriptionboolean
getCallListAtDepth
(int depth, long startTime, long endTime, long resolution, org.eclipse.core.runtime.IProgressMonitor monitor) Get the list of calls at a given depthint
getCurrentDepth
(long time) Get the depth of this callstack, at the time of query.long
Get the end time of this callstack@Nullable Object
getExtraAttribute
(String name, long time) Callstacks may save extra attributes in the state system.getFunctionFromInterval
(ITmfStateInterval callInterval) Transforms a state interval from the state system into aICalledFunction
.@Nullable HostThread
Get the uniqueHostThread
for this callstack.@Nullable HostThread
getHostThread
(long time) Get the ID of the thread running this callstack at time t.getKernelStatuses
(ICalledFunction function, Collection<Long> times) Get the kernel statuses that span a given functionint
Get the maximum depth of this callstack@Nullable ITmfStateInterval
getNextDepth
(long time, boolean forward) Get the next depth of this callstack, from the selected time.@Nullable ICalledFunction
getNextFunction
(long time, int depth) Get the function call at a given depth that either begins or ends after the requested time.@Nullable ICalledFunction
getNextFunction
(long time, int depth, @Nullable ICalledFunction parent, IHostModel model, long start, long end) Get the next function call after or including the requested time.getQuarkAtDepth
(int depth) Get the quark for a given depthlong
Get the start time of this callstackint
getSymbolKeyAt
(long time) Get the symbol key for this callstack at a given timeint
getThreadId
(long time) Get the ID of the thread running this callstack at time t.int
hashCode()
boolean
Get whether this callstack has kernel statuses availableboolean
Return whether the TID is variable through time for this callstack or if it fixedvoid
iterateOverCallStack
(long startTime, long endTime, Consumer<ICalledFunction> consumer) Iterate over the callstack in a depth-first mannertoString()
void
updateAttributes
(List<Integer> subAttributes) Update the quarks list.
-
Constructor Details
-
CallStack
public CallStack(ITmfStateSystem ss, List<Integer> quarks, ICallStackElement element, CallStackHostUtils.IHostIdProvider hostIdProvider, @Nullable CallStackSeries.IThreadIdProvider threadIdProvider) Constructor- Parameters:
ss
- The state system containing the callstackquarks
- The quarks corresponding to each of the depth levelselement
- The element this callstack belongs tohostIdProvider
- The provider of the host ID for this callstackthreadIdProvider
- The provider of the thread ID for this callstack
-
-
Method Details
-
getMaxDepth
public int getMaxDepth()Get the maximum depth of this callstack- Returns:
- The maximum depth of the callstack
-
getCallListAtDepth
public List<ICalledFunction> getCallListAtDepth(int depth, long startTime, long endTime, long resolution, org.eclipse.core.runtime.IProgressMonitor monitor) Get the list of calls at a given depth- Parameters:
depth
- The requested depthstartTime
- The start of the period for which to get the call listendTime
- The end of the period for which to get the call listresolution
- The resolution of the calls. TODO: what is a resolution?monitor
- The progress monitor to follow the progress of this query- Returns:
- The list of called functions at this depth
-
getQuarkAtDepth
Get the quark for a given depth- Parameters:
depth
- The requested depth- Returns:
- Get the quark for the function at a given depth
-
getNextFunction
Get the function call at a given depth that either begins or ends after the requested time.- Parameters:
time
- The time to querydepth
- The depth of the requested function- Returns:
- The next function call at this level
-
getNextFunction
public @Nullable ICalledFunction getNextFunction(long time, int depth, @Nullable ICalledFunction parent, IHostModel model, long start, long end) Get the next function call after or including the requested time. To get the function after a previous function was retrieved, theIHTInterval.getEnd()
can be used for the requested time.- Parameters:
time
- The time of the requestdepth
- The depth FIXME: with the parent, do we need depth?parent
- The parent function callmodel
- The operating system model to retrieve extra information. FIXME: Since we have the host ID, the model may not be necessarystart
- The time of the start of the function. If the function starts earlier, this time will be used as start time.end
- The time of the end of the function. If the function ends later, this time will be used as end time.- Returns:
- The next function call
-
getNextDepth
Get the next depth of this callstack, from the selected time. This function is used to navigate the callstack forward or backward- Parameters:
time
- The reference time from which to calculate the next depthforward
- Iftrue
, the returned depth is the next depth after the requested time, otherwise, it will return the next depth before.- Returns:
- The interval whose value is a number referring to the next depth (or
null if the stack is empty at this time), or
null
if there is no next depth to this callstack
-
getCurrentDepth
public int getCurrentDepth(long time) Get the depth of this callstack, at the time of query.- Parameters:
time
- The reference time from which to calculate the next depth- Returns:
- The depth of the callstack at the time of query. If there is no value, it will return 0
-
iterateOverCallStack
Iterate over the callstack in a depth-first manner- Parameters:
startTime
- The start time of the iterationendTime
- The end time of the iterationconsumer
- The consumer to consume the function calls
-
getSymbolKeyAt
public int getSymbolKeyAt(long time) Get the symbol key for this callstack at a given time- Parameters:
time
- The time of query- Returns:
- The symbol key or
CallStackElement.DEFAULT_SYMBOL_KEY
if not available
-
updateAttributes
Update the quarks list. Only the quarks at positions higher than the size of the quarks will be copied in the list. The ones currently present should not change.- Parameters:
subAttributes
- The new complete list of attributes
-
getThreadId
public int getThreadId(long time) Get the ID of the thread running this callstack at time t. This method is used in conjunction with other trace data to get the time spent on the CPU for this call.- Parameters:
time
- The time of query- Returns:
- The thread ID or
-1
if not available.
-
getHostThread
Get the ID of the thread running this callstack at time t. This method is used in conjunction with other trace data to get the time spent on the CPU for this call.- Parameters:
time
- The time of query- Returns:
- The thread ID or
-1
if not available.
-
getHostThread
Get the uniqueHostThread
for this callstack. This returns a value only if the TID is not variable in time _and_ it is defined- Returns:
- The
HostThread
that spans this callstack ornull
if TID is variable or it is not defined.
-
isTidVariable
public boolean isTidVariable()Return whether the TID is variable through time for this callstack or if it fixed- Returns:
true
if the TID may vary during the trace or if it is fixed and can be cached.
-
getStartTime
public long getStartTime()Get the start time of this callstack- Returns:
- The start time of the callstack
-
getEndTime
public long getEndTime()Get the end time of this callstack- Returns:
- The end time of the callstack
-
getExtraAttribute
Callstacks may save extra attributes in the state system. By convention, these attributes will be located in the parent attribute of the callstack, under their given name and its value will be queried by this method at a given time. Extra attributes can be used for instance for some callstacks to save the CPU on which they were running at the beginning of a function call. This CPU can then be cross-referenced with other trace data to retrieve the thread ID.- Parameters:
name
- The name of the extra attribute to gettime
- The time at which to query- Returns:
- The value of attribute at the requested time
-
hasKernelStatuses
public boolean hasKernelStatuses()Get whether this callstack has kernel statuses available- Returns:
true
if kernel statuses are available for this callstack
-
getKernelStatuses
public Iterable<ProcessStatusInterval> getKernelStatuses(ICalledFunction function, Collection<Long> times) Get the kernel statuses that span a given function- Parameters:
function
- The function for which to get the kernel statusestimes
- The times at which to query kernel statuses. An empty collection will return all intervals.- Returns:
- An iterator over the kernel status. The iterator can be empty is statuses are not available or if the function is outside the range of the available data.
-
getFunctionFromInterval
Transforms a state interval from the state system into aICalledFunction
. The function allows to retrieve data from this function, for instance, the thread ID, the symbol provider, etc. Note: It is the responsibility of the caller to make sure that the interval does not have a null-value, otherwise, a NullPointerException will be thrown.- Parameters:
callInterval
- The state interval- Returns:
- An
ICalledFunction
object, with its fields resolved
-
hashCode
public int hashCode() -
equals
-
toString
-