use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class KernelThreadInformationProvider method getStatusIntervalsForThread.
/**
* Get the status intervals for a given thread with a resolution
*
* @param module
* The kernel analysis instance to run this method on
* @param threadId
* The ID of the thread to get the intervals for
* @param start
* The start time of the requested range
* @param end
* The end time of the requested range
* @param resolution
* The resolution or the minimal time between the requested
* intervals. If interval times are smaller than resolution, only
* the first interval is returned, the others are ignored.
* @param monitor
* A progress monitor for this task
* @return The list of status intervals for this thread, an empty list is
* returned if either the state system is {@code null} or the quark
* is not found
*/
public static List<ITmfStateInterval> getStatusIntervalsForThread(KernelAnalysisModule module, Integer threadId, long start, long end, long resolution, IProgressMonitor monitor) {
ITmfStateSystem ss = module.getStateSystem();
if (ss == null) {
return Collections.emptyList();
}
try {
int threadQuark = ss.getQuarkAbsolute(Attributes.THREADS, threadId.toString());
List<ITmfStateInterval> statusIntervals = StateSystemUtils.queryHistoryRange(ss, threadQuark, Math.max(start, ss.getStartTime()), Math.min(end - 1, ss.getCurrentEndTime()), resolution, monitor);
return statusIntervals;
} catch (AttributeNotFoundException | StateSystemDisposedException | TimeRangeException e) {
// Do Nothing
}
return Collections.emptyList();
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class KernelThreadInformationProvider method getThreadOnCpu.
/**
* Get the ID of the thread running on the CPU at time ts
*
* TODO: This method may later be replaced by an aspect, when the aspect can
* resolve to something that is not an event
*
* @param module
* The kernel analysis instance to run this method on
* @param cpuId
* The CPU number the process is running on
* @param ts
* The timestamp at which we want the running process
* @return The TID of the thread running on CPU cpuId at time ts or
* {@code null} if either no thread is running or we do not know.
*/
@Nullable
public static Integer getThreadOnCpu(KernelAnalysisModule module, long cpuId, long ts) {
ITmfStateSystem ss = module.getStateSystem();
if (ss == null) {
return null;
}
try {
int cpuQuark = ss.getQuarkAbsolute(Attributes.CPUS, Long.toString(cpuId), Attributes.CURRENT_THREAD);
ITmfStateInterval interval = ss.querySingleState(ts, cpuQuark);
ITmfStateValue val = interval.getStateValue();
if (val.getType().equals(Type.INTEGER)) {
return val.unboxInt();
}
} catch (AttributeNotFoundException | StateSystemDisposedException | TimeRangeException e) {
}
return null;
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class KernelThreadInformationProvider method getParentPid.
/**
* Get the parent process ID of a thread
*
* @param module
* The kernel analysis instance to run this method on
* @param threadId
* The thread ID of the process for which to get the parent
* @param ts
* The timestamp at which to get the parent
* @return The parent PID or {@code null} if the PPID is not found.
*/
@Nullable
public static Integer getParentPid(KernelAnalysisModule module, Integer threadId, long ts) {
ITmfStateSystem ss = module.getStateSystem();
if (ss == null) {
return null;
}
Integer ppidNode;
try {
ppidNode = ss.getQuarkAbsolute(Attributes.THREADS, threadId.toString(), Attributes.PPID);
ITmfStateInterval ppidInterval = ss.querySingleState(ts, ppidNode);
ITmfStateValue ppidValue = ppidInterval.getStateValue();
if (ppidValue.getType().equals(Type.INTEGER)) {
return Integer.valueOf(ppidValue.unboxInt());
}
} catch (AttributeNotFoundException | StateSystemDisposedException | TimeRangeException e) {
}
return null;
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class TidAnalysisModule method getThreadOnCpuAtTime.
/**
* Gets the current thread ID on a given CPU for a given time
*
* @param cpu
* the CPU
* @param time
* the time in nanoseconds
* @return the current TID at the time on the CPU or {@code null} if not
* known
*/
@Nullable
public Integer getThreadOnCpuAtTime(int cpu, long time) {
ITmfStateSystem stateSystem = getStateSystem();
if (stateSystem == null || time < stateSystem.getStartTime()) {
return null;
}
Integer tid = null;
// Query at time - 1, because at the boundary (sched_switches), the "thread on
// CPU" should be the previous thread, not the next one (as LTTng contexts and
// perf traces show).
long queryTime = Math.max(time - 1, stateSystem.getStartTime());
try {
int cpuQuark = stateSystem.optQuarkAbsolute(Integer.toString(cpu));
if (cpuQuark == ITmfStateSystem.INVALID_ATTRIBUTE) {
return null;
}
ITmfStateInterval state = fCache.get(cpuQuark);
if (state == null || !state.intersects(queryTime)) {
state = stateSystem.querySingleState(queryTime, cpuQuark);
fCache.put(cpuQuark, state);
}
Object value = state.getValue();
if (value instanceof Integer) {
tid = (Integer) value;
}
} catch (StateSystemDisposedException | TimeRangeException e) {
Activator.getDefault().logError(NonNullUtils.nullToEmptyString(e.getMessage()), e);
}
return tid;
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException in project tracecompass by tracecompass.
the class IOStateSystemSegmentStore method getIntersectingElements.
@Override
@NonNull
public Iterable<@NonNull ISegment> getIntersectingElements(long start, long end) {
long startTime = Math.max(start, fStateSystem.getStartTime());
long endTime = Math.min(end, fStateSystem.getCurrentEndTime());
if (startTime > endTime) {
return Collections.emptySet();
}
List<@NonNull ISegment> segments = new ArrayList<>();
try {
for (ITmfStateInterval interval : fStateSystem.query2D(fSegmentQuarks.keySet(), startTime, endTime)) {
RequestIntervalSegment segment = RequestIntervalSegment.create(interval, fSegmentQuarks.get(interval.getAttribute()));
if (segment != null) {
segments.add(segment);
}
}
} catch (IndexOutOfBoundsException | TimeRangeException | StateSystemDisposedException e1) {
// Nothing to do
}
return segments;
}
Aggregations