java.lang.Object
org.eclipse.tracecompass.incubator.callstack.core.flamechart.CallStack

public class CallStack extends Object
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 Details

  • 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 depth
      startTime - The start of the period for which to get the call list
      endTime - The end of the period for which to get the call list
      resolution - 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

      public Integer getQuarkAtDepth(int depth)
      Get the quark for a given depth
      Parameters:
      depth - The requested depth
      Returns:
      Get the quark for the function at a given depth
    • getNextFunction

      public @Nullable ICalledFunction getNextFunction(long time, int depth)
      Get the function call at a given depth that either begins or ends after the requested time.
      Parameters:
      time - The time to query
      depth - 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, the IHTInterval.getEnd() can be used for the requested time.
      Parameters:
      time - The time of the request
      depth - The depth FIXME: with the parent, do we need depth?
      parent - The parent function call
      model - The operating system model to retrieve extra information. FIXME: Since we have the host ID, the model may not be necessary
      start - 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

      public @Nullable ITmfStateInterval getNextDepth(long time, boolean forward)
      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 depth
      forward - If true, 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

      public void iterateOverCallStack(long startTime, long endTime, Consumer<ICalledFunction> consumer)
      Iterate over the callstack in a depth-first manner
      Parameters:
      startTime - The start time of the iteration
      endTime - The end time of the iteration
      consumer - 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

      public void updateAttributes(List<Integer> subAttributes)
      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

      public @Nullable HostThread getHostThread(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

      public @Nullable HostThread getHostThread()
      Get the unique HostThread 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 or null 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

      public @Nullable Object getExtraAttribute(String name, long time)
      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 get
      time - 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 statuses
      times - 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

      public ICalledFunction getFunctionFromInterval(ITmfStateInterval callInterval)
      Transforms a state interval from the state system into a ICalledFunction. 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()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object