tmf: Make Callstack View pass timestamps and PIDs to symbol provider
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Tue, 5 Apr 2016 19:34:31 +0000 (15:34 -0400)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Wed, 27 Apr 2016 22:15:27 +0000 (18:15 -0400)
Now that the Callstack analysis and view track the PIDs of each
function entry/exit, it can pass them along with the timesteamps
to the symbol providers, so that provider implementations making
use of the new methods can resolve symbols in the view too.

Also add proper comparison logic for ProcessEntries, they can use
numerical comparaison of the PID they now carry.

Change-Id: I7404ab4b893878dbdd8e526a646014739cfbe228
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/69970
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackEntry.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackPresentationProvider.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackView.java

index c388cd232ce92d24eb03482957c055077e974581..74a5f5dee693d1be73ec296aa00c1fa2e7da3e68 100644 (file)
@@ -28,6 +28,7 @@ public class CallStackEntry extends TimeGraphEntry {
 
     private final int fQuark;
     private final int fStackLevel;
+    private final int fProcessId;
     private final ITmfTrace fTrace;
     private String fFunctionName;
     private long fFunctionEntryTime;
@@ -43,7 +44,7 @@ public class CallStackEntry extends TimeGraphEntry {
      *            The stack level
      * @param trace
      *            The trace that this view is talking about
-     * @deprecated Use {@link #CallStackEntry(String, int, int, ITmfTrace, ITmfStateSystem)}
+     * @deprecated Use {@link #CallStackEntry(String, int, int, int, ITmfTrace, ITmfStateSystem)}
      */
     @Deprecated
     public CallStackEntry(int quark, int stackLevel, ITmfTrace trace) {
@@ -64,11 +65,42 @@ public class CallStackEntry extends TimeGraphEntry {
      *            The trace that this view is talking about
      * @param ss
      *            The call stack state system
+     * @deprecated Use
+     *             {@link #CallStackEntry(String, int, int, int, ITmfTrace, ITmfStateSystem)}
      */
+    @Deprecated
     public CallStackEntry(String name, int quark, int stackLevel, ITmfTrace trace, @NonNull ITmfStateSystem ss) {
         super(name, 0, 0);
         fQuark = quark;
         fStackLevel = stackLevel;
+        fProcessId = -1;
+        fTrace = trace;
+        fFunctionName = ""; //$NON-NLS-1$
+        fSS = ss;
+    }
+
+    /**
+     * Standard constructor
+     *
+     * @param name
+     *            The parent thread name
+     * @param quark
+     *            The call stack quark
+     * @param stackLevel
+     *            The stack level
+     * @param processId The ID of the process this entry belongs to
+     * @param trace
+     *            The trace that this view is talking about
+     * @param ss
+     *            The call stack state system
+     * @since 2.0
+     */
+    public CallStackEntry(String name, int quark, int stackLevel, int processId,
+            ITmfTrace trace, @NonNull ITmfStateSystem ss) {
+        super(name, 0, 0);
+        fQuark = quark;
+        fStackLevel = stackLevel;
+        fProcessId = processId;
         fTrace = trace;
         fFunctionName = ""; //$NON-NLS-1$
         fSS = ss;
@@ -166,6 +198,16 @@ public class CallStackEntry extends TimeGraphEntry {
         return fStackLevel;
     }
 
+    /**
+     * Retrieve the ID of the process this entry belongs to.
+     *
+     * @return The ID of the process
+     * @since 2.0
+     */
+    public int getProcessId() {
+        return fProcessId;
+    }
+
     /**
      * Retrieve the trace that is associated to this view.
      *
index 4b7f68ab2c75a791fe928d0277aa50de23390069..089be7ef72a16edef1acc75807bb93e826bfb6bb 100644 (file)
@@ -112,7 +112,7 @@ public class CallStackPresentationProvider extends TimeGraphPresentationProvider
             try {
                 ITmfStateValue value = ss.querySingleState(event.getTime(), entry.getQuark()).getStateValue();
                 if (!value.isNull()) {
-                    return fView.getFunctionName(entry.getTrace(), value);
+                    return fView.getFunctionName(entry.getTrace(), entry.getProcessId(), event.getTime(), value);
                 }
             } catch (AttributeNotFoundException e) {
                 Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$
@@ -142,7 +142,7 @@ public class CallStackPresentationProvider extends TimeGraphPresentationProvider
         try {
             ITmfStateValue value = ss.querySingleState(event.getTime(), entry.getQuark()).getStateValue();
             if (!value.isNull()) {
-                String name = fView.getFunctionName(entry.getTrace(), value);
+                String name = fView.getFunctionName(entry.getTrace(), entry.getProcessId(), event.getTime(), value);
                 gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
                 Utils.drawText(gc, name, bounds.x, bounds.y, bounds.width, bounds.height, true, true);
             }
index 229f8746d8aa4ced72e9afaa537336c907ece74f..f218d32a574977ca05d8e33b8be594c831a28d45 100644 (file)
@@ -189,8 +189,15 @@ public class CallStackView extends AbstractTimeGraphView {
 
     private static class ProcessEntry extends TimeGraphEntry {
 
-        public ProcessEntry(String name, long startTime, long endTime) {
+        private final int fProcessId;
+
+        public ProcessEntry(String name, int processId, long startTime, long endTime) {
             super(name, startTime, endTime);
+            fProcessId = processId;
+        }
+
+        public int getProcessId() {
+            return fProcessId;
         }
 
         @Override
@@ -238,6 +245,8 @@ public class CallStackView extends AbstractTimeGraphView {
         public int compare(ITimeGraphEntry o1, ITimeGraphEntry o2) {
             if (o1 instanceof ThreadEntry && o2 instanceof ThreadEntry) {
                 return fThreadComparator.compare(o1, o2);
+            } else if (o1 instanceof ProcessEntry && o2 instanceof ProcessEntry) {
+                return Integer.compare(((ProcessEntry) o1).fProcessId, ((ProcessEntry) o2).fProcessId);
             }
             return 0;
         }
@@ -610,7 +619,9 @@ public class CallStackView extends AbstractTimeGraphView {
                 ProcessEntry processEntry = processEntryMap.get(processQuark);
                 if (processEntry == null) {
                     String name = ss.getAttributeName(processQuark.intValue());
-                    processEntry = new ProcessEntry(name, start, end);
+                    /* The attribute name should already be parseable to integer */
+                    int processId = Integer.parseInt(name);
+                    processEntry = new ProcessEntry(name, processId, start, end);
                     processEntryMap.put(processQuark, processEntry);
                     traceEntry.addChild(processEntry);
                 } else {
@@ -660,7 +671,8 @@ public class CallStackView extends AbstractTimeGraphView {
                         int level = 1;
                         for (int stackLevelQuark : ss.getSubAttributes(callStackQuark, false)) {
                             if (level > threadEntry.getChildren().size()) {
-                                CallStackEntry callStackEntry = new CallStackEntry(threadName, stackLevelQuark, level, trace, ss);
+                                int processId = processEntry.getProcessId();
+                                CallStackEntry callStackEntry = new CallStackEntry(threadName, stackLevelQuark, level, processId, trace, ss);
                                 threadEntry.addChild(callStackEntry);
                             }
                             level++;
@@ -789,6 +801,9 @@ public class CallStackView extends AbstractTimeGraphView {
         }
         for (TimeGraphEntry traceEntry : entryList) {
             for (ITimeGraphEntry processEntry : traceEntry.getChildren()) {
+                /* The entries should all be parseable to an integer. */
+                int pid = Integer.parseInt(processEntry.getName());
+
                 for (ITimeGraphEntry threadEntry : processEntry.getChildren()) {
                     ITmfStateSystem ss = ((ThreadEntry) threadEntry).getStateSystem();
                     if (ss == null) {
@@ -806,7 +821,8 @@ public class CallStackView extends AbstractTimeGraphView {
                         try {
                             ITmfStateInterval stackLevelInterval = ss.querySingleState(time, callStackEntry.getQuark());
                             ITmfStateValue nameValue = stackLevelInterval.getStateValue();
-                            String name = getFunctionName(trace, nameValue);
+
+                            String name = getFunctionName(trace, pid, time, nameValue);
                             callStackEntry.setFunctionName(name);
                             if (name.length() > 0) {
                                 callStackEntry.setFunctionEntryTime(stackLevelInterval.getStartTime());
@@ -826,7 +842,7 @@ public class CallStackView extends AbstractTimeGraphView {
         }
     }
 
-    String getFunctionName(ITmfTrace trace, ITmfStateValue nameValue) {
+    String getFunctionName(ITmfTrace trace, int processId, long timestamp, ITmfStateValue nameValue) {
         long address = Long.MAX_VALUE;
         String name = ""; //$NON-NLS-1$
         try {
@@ -849,7 +865,7 @@ public class CallStackView extends AbstractTimeGraphView {
         if (address != Long.MAX_VALUE) {
             ISymbolProvider provider = fSymbolProviders.get(trace);
             if (provider != null) {
-                String symbol = provider.getSymbolText(address);
+                String symbol = provider.getSymbolText(processId, timestamp, address);
                 if (symbol != null) {
                     name = symbol;
                 }
This page took 0.028112 seconds and 5 git commands to generate.