- for (int cpuQuark : cpuQuarks) {\r
- String cpuName = "CPU " + ssq.getAttributeName(cpuQuark);\r
- ResourcesEntry entry = new ResourcesEntry(groupEntry, ctfKernelTrace, cpuName);\r
- try {\r
- int currentThreadQuark = ssq.getQuarkRelative(cpuQuark, Attributes.CURRENT_THREAD);\r
- long resolution = (end - start) / fDisplayWidth;\r
- List<ITmfStateInterval> currentThreadIntervals = ssq.queryHistoryRange(currentThreadQuark, start, end, resolution);\r
- for (ITmfStateInterval currentThreadInterval : currentThreadIntervals) {\r
- if (!currentThreadInterval.getStateValue().isNull() && currentThreadInterval.getStateValue().getType() == 0) {\r
- int currentThread = currentThreadInterval.getStateValue().unboxInt();\r
- long startTime = currentThreadInterval.getStartTime();\r
- long endTime = currentThreadInterval.getEndTime();\r
- entry.addTraceEvent(new TimeEvent(entry, startTime, endTime - startTime));\r
- }\r
+ ResourcesEntry[] cpuEntries = new ResourcesEntry[cpuQuarks.size()];\r
+ for (int i = 0; i < cpuQuarks.size(); i++) {\r
+ int cpuQuark = cpuQuarks.get(i);\r
+ int cpu = Integer.parseInt(ssq.getAttributeName(cpuQuark));\r
+ ResourcesEntry entry = new ResourcesEntry(cpuQuark, ctfKernelTrace, Type.CPU, cpu);\r
+ groupEntry.addChild(entry);\r
+ cpuEntries[i] = entry;\r
+ }\r
+ List<Integer> irqQuarks = ssq.getQuarks(Attributes.RESOURCES, Attributes.IRQS, "*"); //$NON-NLS-1$\r
+ ResourcesEntry[] irqEntries = new ResourcesEntry[irqQuarks.size()];\r
+ for (int i = 0; i < irqQuarks.size(); i++) {\r
+ int irqQuark = irqQuarks.get(i);\r
+ int irq = Integer.parseInt(ssq.getAttributeName(irqQuark));\r
+ ResourcesEntry entry = new ResourcesEntry(irqQuark, ctfKernelTrace, Type.IRQ, irq);\r
+ groupEntry.addChild(entry);\r
+ irqEntries[i] = entry;\r
+ }\r
+ List<Integer> softIrqQuarks = ssq.getQuarks(Attributes.RESOURCES, Attributes.SOFT_IRQS, "*"); //$NON-NLS-1$\r
+ ResourcesEntry[] softIrqEntries = new ResourcesEntry[softIrqQuarks.size()];\r
+ for (int i = 0; i < softIrqQuarks.size(); i++) {\r
+ int softIrqQuark = softIrqQuarks.get(i);\r
+ int softIrq = Integer.parseInt(ssq.getAttributeName(softIrqQuark));\r
+ ResourcesEntry entry = new ResourcesEntry(softIrqQuark, ctfKernelTrace, Type.SOFT_IRQ, softIrq);\r
+ groupEntry.addChild(entry);\r
+ softIrqEntries[i] = entry;\r
+ }\r
+ }\r
+ }\r
+ synchronized (fEntryListSyncObj) {\r
+ fEntryList = (ArrayList<TraceEntry>) entryList.clone();\r
+ }\r
+ refresh(INITIAL_WINDOW_OFFSET);\r
+ for (TraceEntry traceEntry : entryList) {\r
+ CtfKernelTrace ctfKernelTrace = traceEntry.getTrace();\r
+ IStateSystemQuerier ssq = ctfKernelTrace.getStateSystem();\r
+ long startTime = ssq.getStartTime();\r
+ long endTime = ssq.getCurrentEndTime() + 1;\r
+ long resolution = (endTime - startTime) / fDisplayWidth;\r
+ for (ResourcesEntry entry : traceEntry.getChildren()) {\r
+ List<ITimeEvent> eventList = getEventList(entry, startTime, endTime, resolution, false, new NullProgressMonitor());\r
+ entry.setEventList(eventList);\r
+ redraw();\r
+ }\r
+ }\r
+ }\r
+\r
+ private static List<ITimeEvent> getEventList(ResourcesEntry entry,\r
+ long startTime, long endTime, long resolution, boolean includeNull,\r
+ IProgressMonitor monitor) {\r
+ IStateSystemQuerier2 ssq = (IStateSystemQuerier2) entry.getTrace().getStateSystem();\r
+ startTime = Math.max(startTime, ssq.getStartTime());\r
+ endTime = Math.min(endTime, ssq.getCurrentEndTime() + 1);\r
+ if (endTime <= startTime) {\r
+ return null;\r
+ }\r
+ List<ITimeEvent> eventList = null;\r
+ int quark = entry.getQuark();\r
+ try {\r
+ if (entry.getType().equals(Type.CPU)) {\r
+ int statusQuark = ssq.getQuarkRelative(quark, Attributes.STATUS);\r
+ List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, startTime, endTime - 1, resolution, monitor);\r
+ eventList = new ArrayList<ITimeEvent>(statusIntervals.size());\r
+ long lastEndTime = -1;\r
+ for (ITmfStateInterval statusInterval : statusIntervals) {\r
+ if (monitor.isCanceled()) {\r
+ return null;\r
+ }\r
+ int status = statusInterval.getStateValue().unboxInt();\r
+ long time = statusInterval.getStartTime();\r
+ long duration = statusInterval.getEndTime() - time + 1;\r
+ if (!statusInterval.getStateValue().isNull()) {\r
+ if (lastEndTime != time && lastEndTime != -1) {\r
+ eventList.add(new TimeEvent(entry, lastEndTime, time - lastEndTime));\r
+ }\r
+ eventList.add(new ResourcesEvent(entry, time, duration, status));\r
+ lastEndTime = time + duration;\r
+ } else {\r
+ if (includeNull) {\r
+ eventList.add(new ResourcesEvent(entry, time, duration));\r