1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Patrick Tasse - Initial API and implementation
11 * Bernd Hufmann - Updated signal handling
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.callstack
;
17 import java
.util
.ArrayList
;
18 import java
.util
.HashMap
;
19 import java
.util
.Iterator
;
20 import java
.util
.List
;
23 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
24 import org
.eclipse
.core
.runtime
.IStatus
;
25 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
26 import org
.eclipse
.core
.runtime
.Status
;
27 import org
.eclipse
.core
.runtime
.jobs
.Job
;
28 import org
.eclipse
.jdt
.annotation
.Nullable
;
29 import org
.eclipse
.jface
.action
.Action
;
30 import org
.eclipse
.jface
.action
.IAction
;
31 import org
.eclipse
.jface
.action
.IStatusLineManager
;
32 import org
.eclipse
.jface
.action
.IToolBarManager
;
33 import org
.eclipse
.jface
.action
.Separator
;
34 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
35 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
36 import org
.eclipse
.jface
.viewers
.DoubleClickEvent
;
37 import org
.eclipse
.jface
.viewers
.IDoubleClickListener
;
38 import org
.eclipse
.jface
.viewers
.ILabelProviderListener
;
39 import org
.eclipse
.jface
.viewers
.ISelection
;
40 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
41 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
42 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
43 import org
.eclipse
.jface
.viewers
.Viewer
;
44 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
45 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.ITmfImageConstants
;
46 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Messages
;
47 import org
.eclipse
.linuxtools
.statesystem
.core
.ITmfStateSystem
;
48 import org
.eclipse
.linuxtools
.statesystem
.core
.exceptions
.AttributeNotFoundException
;
49 import org
.eclipse
.linuxtools
.statesystem
.core
.exceptions
.StateSystemDisposedException
;
50 import org
.eclipse
.linuxtools
.statesystem
.core
.exceptions
.StateValueTypeException
;
51 import org
.eclipse
.linuxtools
.statesystem
.core
.exceptions
.TimeRangeException
;
52 import org
.eclipse
.linuxtools
.statesystem
.core
.interval
.ITmfStateInterval
;
53 import org
.eclipse
.linuxtools
.statesystem
.core
.statevalue
.ITmfStateValue
;
54 import org
.eclipse
.linuxtools
.statesystem
.core
.statevalue
.ITmfStateValue
.Type
;
55 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfRangeSynchSignal
;
56 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
57 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTimeSynchSignal
;
58 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceClosedSignal
;
59 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
60 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceSelectedSignal
;
61 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
62 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfNanoTimestamp
;
63 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimeRange
;
64 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimestamp
;
65 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimestampDelta
;
66 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
67 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTraceManager
;
68 import org
.eclipse
.linuxtools
.tmf
.ui
.editors
.ITmfTraceEditor
;
69 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.TmfView
;
70 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.ITimeGraphRangeListener
;
71 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.ITimeGraphTimeListener
;
72 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphCombo
;
73 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphRangeUpdateEvent
;
74 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphTimeEvent
;
75 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphViewer
;
76 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.ITimeEvent
;
77 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.ITimeGraphEntry
;
78 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.NullTimeEvent
;
79 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.TimeEvent
;
80 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeGraphControl
;
81 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.TimeGraphSelection
;
82 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.widgets
.Utils
.TimeFormat
;
83 import org
.eclipse
.swt
.SWT
;
84 import org
.eclipse
.swt
.events
.ControlAdapter
;
85 import org
.eclipse
.swt
.events
.ControlEvent
;
86 import org
.eclipse
.swt
.events
.MouseAdapter
;
87 import org
.eclipse
.swt
.events
.MouseEvent
;
88 import org
.eclipse
.swt
.graphics
.Image
;
89 import org
.eclipse
.swt
.widgets
.Composite
;
90 import org
.eclipse
.swt
.widgets
.Display
;
91 import org
.eclipse
.swt
.widgets
.FileDialog
;
92 import org
.eclipse
.ui
.IActionBars
;
93 import org
.eclipse
.ui
.IEditorPart
;
96 * Main implementation for the Call Stack view
98 * @author Patrick Tasse
101 public class CallStackView
extends TmfView
{
103 // ------------------------------------------------------------------------
105 // ------------------------------------------------------------------------
108 public static final String ID
= "org.eclipse.linuxtools.tmf.ui.views.callstack"; //$NON-NLS-1$
113 private enum State
{ IDLE
, BUSY
, PENDING
}
115 private static final String
[] COLUMN_NAMES
= new String
[] {
116 Messages
.CallStackView_FunctionColumn
,
117 Messages
.CallStackView_DepthColumn
,
118 Messages
.CallStackView_EntryTimeColumn
,
119 Messages
.CallStackView_ExitTimeColumn
,
120 Messages
.CallStackView_DurationColumn
123 private static final int[] COLUMN_WIDTHS
= new int[] {
131 // Fraction of a function duration to be added as spacing
132 private static final double SPACING_RATIO
= 0.01;
134 private static final Image THREAD_IMAGE
= Activator
.getDefault().getImageFromPath("icons/obj16/thread_obj.gif"); //$NON-NLS-1$
135 private static final Image STACKFRAME_IMAGE
= Activator
.getDefault().getImageFromPath("icons/obj16/stckframe_obj.gif"); //$NON-NLS-1$
137 private static final String IMPORT_MAPPING_ICON_PATH
= "icons/etool16/import.gif"; //$NON-NLS-1$
139 // ------------------------------------------------------------------------
141 // ------------------------------------------------------------------------
143 // The time graph combo
144 private TimeGraphCombo fTimeGraphCombo
;
146 // The selected trace
147 private ITmfTrace fTrace
;
149 // The selected thread map
150 private final Map
<ITmfTrace
, String
> fSelectedThreadMap
= new HashMap
<>();
152 // The time graph entry list
153 private List
<ThreadEntry
> fEntryList
;
155 // The trace to entry list hash map
156 private final Map
<ITmfTrace
, ArrayList
<ThreadEntry
>> fEntryListMap
= new HashMap
<>();
158 // The trace to build thread hash map
159 private final Map
<ITmfTrace
, BuildThread
> fBuildThreadMap
= new HashMap
<>();
161 /** The map to map function addresses to function names */
162 private Map
<String
, String
> fNameMapping
;
165 private long fStartTime
;
168 private long fEndTime
;
171 private int fDisplayWidth
;
173 // The next event action
174 private Action fNextEventAction
;
176 // The previous event action
177 private Action fPrevEventAction
;
179 // The next item action
180 private Action fNextItemAction
;
182 // The previous item action
183 private Action fPreviousItemAction
;
185 /** The action to import a function-name mapping file */
186 private Action fImportMappingAction
;
189 private ZoomThread fZoomThread
;
191 // The redraw state used to prevent unnecessary queuing of display runnables
192 private State fRedrawState
= State
.IDLE
;
194 // The redraw synchronization object
195 private final Object fSyncObj
= new Object();
197 // The saved time sync. signal used when switching off the pinning of a view
198 private TmfTimeSynchSignal fSavedTimeSyncSignal
;
200 // The saved time range sync. signal used when switching off the pinning of a view
201 private TmfRangeSynchSignal fSavedRangeSyncSignal
;
203 // ------------------------------------------------------------------------
205 // ------------------------------------------------------------------------
207 private class ThreadEntry
implements ITimeGraphEntry
{
209 private final long fTraceStartTime
;
211 private final long fTraceEndTime
;
212 // The children of the entry
213 private ArrayList
<CallStackEntry
> fChildren
;
215 private final String fName
;
216 // The call stack quark
217 private final int fCallStackQuark
;
218 // The state system from which this entry comes
219 private final ITmfStateSystem fSS
;
221 public ThreadEntry(ITmfStateSystem ss
, String name
, int callStackQuark
, long startTime
, long endTime
) {
222 fChildren
= new ArrayList
<>();
224 fTraceStartTime
= startTime
;
225 fTraceEndTime
= endTime
;
226 fCallStackQuark
= callStackQuark
;
232 public ITimeGraphEntry
getParent() {
237 public boolean hasChildren() {
238 if (fChildren
== null) {
239 ITmfStateSystem ss
= getStateSystem();
244 ITmfStateInterval eventStackInterval
= ss
.querySingleState(ss
.getStartTime(), fCallStackQuark
);
245 return ! eventStackInterval
.getStateValue().isNull() || eventStackInterval
.getEndTime() != ss
.getCurrentEndTime();
246 } catch (AttributeNotFoundException e
) {
247 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
248 } catch (TimeRangeException e
) {
249 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
250 } catch (StateSystemDisposedException e
) {
254 return fChildren
!= null && fChildren
.size() > 0;
258 public List
<CallStackEntry
> getChildren() {
263 public String
getName() {
268 public long getStartTime() {
269 return fTraceStartTime
;
273 public long getEndTime() {
274 return fTraceEndTime
;
278 public boolean hasTimeEvents() {
283 public Iterator
<ITimeEvent
> getTimeEventsIterator() {
288 public <T
extends ITimeEvent
> Iterator
<T
> getTimeEventsIterator(long startTime
, long stopTime
, long visibleDuration
) {
292 public int getCallStackQuark() {
293 return fCallStackQuark
;
297 public ITmfStateSystem
getStateSystem() {
301 public void addChild(CallStackEntry entry
) {
302 entry
.setParent(this);
303 fChildren
.add(entry
);
307 private class TreeContentProvider
implements ITreeContentProvider
{
310 public void dispose() {
314 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
318 public Object
[] getElements(Object inputElement
) {
319 return (ITimeGraphEntry
[]) inputElement
;
323 public Object
[] getChildren(Object parentElement
) {
324 ITimeGraphEntry entry
= (ITimeGraphEntry
) parentElement
;
325 return entry
.getChildren().toArray();
329 public Object
getParent(Object element
) {
330 ITimeGraphEntry entry
= (ITimeGraphEntry
) element
;
331 return entry
.getParent();
335 public boolean hasChildren(Object element
) {
336 ITimeGraphEntry entry
= (ITimeGraphEntry
) element
;
337 return entry
.hasChildren();
342 private class TreeLabelProvider
implements ITableLabelProvider
{
345 public void addListener(ILabelProviderListener listener
) {
349 public void dispose() {
353 public boolean isLabelProperty(Object element
, String property
) {
358 public void removeListener(ILabelProviderListener listener
) {
362 public Image
getColumnImage(Object element
, int columnIndex
) {
363 if (columnIndex
== 0) {
364 if (element
instanceof ThreadEntry
) {
366 } else if (element
instanceof CallStackEntry
) {
367 CallStackEntry entry
= (CallStackEntry
) element
;
368 if (entry
.getFunctionName().length() > 0) {
369 return STACKFRAME_IMAGE
;
377 public String
getColumnText(Object element
, int columnIndex
) {
378 if (element
instanceof ThreadEntry
) {
379 if (columnIndex
== 0) {
380 return ((ThreadEntry
) element
).getName();
382 } else if (element
instanceof CallStackEntry
) {
383 CallStackEntry entry
= (CallStackEntry
) element
;
384 if (columnIndex
== 0) {
385 return entry
.getFunctionName();
386 } else if (columnIndex
== 1 && entry
.getFunctionName().length() > 0) {
387 int depth
= entry
.getStackLevel();
388 return Integer
.toString(depth
);
389 } else if (columnIndex
== 2 && entry
.getFunctionName().length() > 0) {
390 ITmfTimestamp ts
= new TmfTimestamp(entry
.getStartTime(), ITmfTimestamp
.NANOSECOND_SCALE
);
391 return ts
.toString();
392 } else if (columnIndex
== 3 && entry
.getFunctionName().length() > 0) {
393 ITmfTimestamp ts
= new TmfTimestamp(entry
.getEndTime(), ITmfTimestamp
.NANOSECOND_SCALE
);
394 return ts
.toString();
395 } else if (columnIndex
== 4 && entry
.getFunctionName().length() > 0) {
396 ITmfTimestamp ts
= new TmfTimestampDelta(entry
.getEndTime() - entry
.getStartTime(), ITmfTimestamp
.NANOSECOND_SCALE
);
397 return ts
.toString();
400 return ""; //$NON-NLS-1$
405 private class BuildThread
extends Thread
{
406 private final ITmfTrace fBuildTrace
;
407 private final IProgressMonitor fMonitor
;
409 public BuildThread(ITmfTrace trace
) {
410 super("CallStackView build"); //$NON-NLS-1$
412 fMonitor
= new NullProgressMonitor();
417 buildThreadList(fBuildTrace
, fMonitor
);
418 synchronized (fBuildThreadMap
) {
419 fBuildThreadMap
.remove(this);
423 public void cancel() {
424 fMonitor
.setCanceled(true);
428 private class ZoomThread
extends Thread
{
429 private final List
<ThreadEntry
> fZoomEntryList
;
430 private final long fZoomStartTime
;
431 private final long fZoomEndTime
;
432 private final IProgressMonitor fMonitor
;
434 public ZoomThread(List
<ThreadEntry
> entryList
, long startTime
, long endTime
) {
435 super("ResourcesView zoom"); //$NON-NLS-1$
436 fZoomEntryList
= entryList
;
437 fZoomStartTime
= startTime
;
438 fZoomEndTime
= endTime
;
439 fMonitor
= new NullProgressMonitor();
444 if (fZoomEntryList
== null) {
447 long resolution
= Math
.max(1, (fZoomEndTime
- fZoomStartTime
) / fDisplayWidth
);
448 for (ThreadEntry threadEntry
: fZoomEntryList
) {
449 ITmfStateSystem ss
= threadEntry
.getStateSystem();
454 if (ss
.isCancelled()) {
457 for (ITimeGraphEntry child
: threadEntry
.getChildren()) {
458 if (fMonitor
.isCanceled()) {
461 CallStackEntry entry
= (CallStackEntry
) child
;
462 if (fZoomStartTime
<= fStartTime
&& fZoomEndTime
>= fEndTime
) {
463 entry
.setZoomedEventList(null);
465 List
<ITimeEvent
> zoomedEventList
= getEventList(entry
, fZoomStartTime
, fZoomEndTime
, resolution
, fMonitor
);
466 if (zoomedEventList
!= null) {
467 entry
.setZoomedEventList(zoomedEventList
);
475 public void cancel() {
476 fMonitor
.setCanceled(true);
480 // ------------------------------------------------------------------------
482 // ------------------------------------------------------------------------
485 * Default constructor
487 public CallStackView() {
489 fDisplayWidth
= Display
.getDefault().getBounds().width
;
492 // ------------------------------------------------------------------------
494 // ------------------------------------------------------------------------
497 public void createPartControl(Composite parent
) {
498 fTimeGraphCombo
= new TimeGraphCombo(parent
, SWT
.NONE
);
500 fTimeGraphCombo
.setTreeContentProvider(new TreeContentProvider());
502 fTimeGraphCombo
.setTreeLabelProvider(new TreeLabelProvider());
504 fTimeGraphCombo
.setTreeColumns(COLUMN_NAMES
);
506 fTimeGraphCombo
.getTreeViewer().getTree().getColumn(0).setWidth(COLUMN_WIDTHS
[0]);
507 fTimeGraphCombo
.getTreeViewer().getTree().getColumn(1).setWidth(COLUMN_WIDTHS
[1]);
508 fTimeGraphCombo
.getTreeViewer().getTree().getColumn(2).setWidth(COLUMN_WIDTHS
[2]);
509 fTimeGraphCombo
.getTreeViewer().getTree().getColumn(3).setWidth(COLUMN_WIDTHS
[3]);
510 fTimeGraphCombo
.getTreeViewer().getTree().getColumn(4).setWidth(COLUMN_WIDTHS
[4]);
512 fTimeGraphCombo
.setTimeGraphProvider(new CallStackPresentationProvider(this));
513 fTimeGraphCombo
.getTimeGraphViewer().setTimeFormat(TimeFormat
.CALENDAR
);
515 fTimeGraphCombo
.getTimeGraphViewer().addRangeListener(new ITimeGraphRangeListener() {
517 public void timeRangeUpdated(TimeGraphRangeUpdateEvent event
) {
518 long startTime
= event
.getStartTime();
519 long endTime
= event
.getEndTime();
520 TmfTimeRange range
= new TmfTimeRange(new TmfNanoTimestamp(startTime
), new TmfNanoTimestamp(endTime
));
521 broadcast(new TmfRangeSynchSignal(CallStackView
.this, range
));
522 startZoomThread(startTime
, endTime
);
526 fTimeGraphCombo
.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() {
528 public void timeSelected(TimeGraphTimeEvent event
) {
529 long beginTime
= event
.getBeginTime();
530 long endTime
= event
.getEndTime();
531 selectTime(beginTime
);
532 broadcast(new TmfTimeSynchSignal(CallStackView
.this, new TmfNanoTimestamp(beginTime
), new TmfNanoTimestamp(endTime
)));
536 fTimeGraphCombo
.getTimeGraphViewer().getControl().addControlListener(new ControlAdapter() {
538 public void controlResized(ControlEvent e
) {
539 fDisplayWidth
= fTimeGraphCombo
.getTimeGraphViewer().getControl().getSize().x
;
540 if (fEntryList
!= null) {
541 startZoomThread(fTimeGraphCombo
.getTimeGraphViewer().getTime0(), fTimeGraphCombo
.getTimeGraphViewer().getTime1());
546 fTimeGraphCombo
.getTreeViewer().addDoubleClickListener(new IDoubleClickListener() {
548 public void doubleClick(DoubleClickEvent event
) {
549 Object selection
= ((IStructuredSelection
) event
.getSelection()).getFirstElement();
550 if (selection
instanceof CallStackEntry
) {
551 CallStackEntry entry
= (CallStackEntry
) selection
;
552 if (entry
.getFunctionName().length() > 0) {
553 long startTime
= entry
.getStartTime();
554 long endTime
= entry
.getEndTime();
555 long spacingTime
= (long) ((endTime
- startTime
) * SPACING_RATIO
);
556 startTime
-= spacingTime
;
557 endTime
+= spacingTime
;
558 TmfTimeRange range
= new TmfTimeRange(new TmfNanoTimestamp(startTime
), new TmfNanoTimestamp(endTime
));
559 broadcast(new TmfRangeSynchSignal(CallStackView
.this, range
));
560 fTimeGraphCombo
.getTimeGraphViewer().setStartFinishTime(startTime
, endTime
);
561 startZoomThread(startTime
, endTime
);
567 fTimeGraphCombo
.getTimeGraphViewer().getTimeGraphControl().addMouseListener(new MouseAdapter() {
569 public void mouseDoubleClick(MouseEvent e
) {
570 TimeGraphControl timeGraphControl
= fTimeGraphCombo
.getTimeGraphViewer().getTimeGraphControl();
571 ISelection selection
= timeGraphControl
.getSelection();
572 if (selection
instanceof TimeGraphSelection
) {
573 Object o
= ((TimeGraphSelection
) selection
).getFirstElement();
574 if (o
instanceof CallStackEvent
) {
575 CallStackEvent event
= (CallStackEvent
) o
;
576 long startTime
= event
.getTime();
577 long endTime
= startTime
+ event
.getDuration();
578 long spacingTime
= (long) ((endTime
- startTime
) * SPACING_RATIO
);
579 startTime
-= spacingTime
;
580 endTime
+= spacingTime
;
581 TmfTimeRange range
= new TmfTimeRange(new TmfNanoTimestamp(startTime
), new TmfNanoTimestamp(endTime
));
582 broadcast(new TmfRangeSynchSignal(CallStackView
.this, range
));
583 fTimeGraphCombo
.getTimeGraphViewer().setStartFinishTime(startTime
, endTime
);
584 startZoomThread(startTime
, endTime
);
590 IStatusLineManager statusLineManager
= getViewSite().getActionBars().getStatusLineManager();
591 fTimeGraphCombo
.getTimeGraphViewer().getTimeGraphControl().setStatusLineManager(statusLineManager
);
593 // View Action Handling
595 contributeToActionBars();
597 IEditorPart editor
= getSite().getPage().getActiveEditor();
598 if (editor
instanceof ITmfTraceEditor
) {
599 ITmfTrace trace
= ((ITmfTraceEditor
) editor
).getTrace();
601 traceSelected(new TmfTraceSelectedSignal(this, trace
));
607 public void setFocus() {
608 fTimeGraphCombo
.setFocus();
611 // ------------------------------------------------------------------------
613 // ------------------------------------------------------------------------
615 * Handler for the trace opened signal.
617 * The incoming signal
621 public void traceOpened(TmfTraceOpenedSignal signal
) {
622 fTrace
= signal
.getTrace();
627 * Handler for the trace selected signal
630 * The incoming signal
633 public void traceSelected(final TmfTraceSelectedSignal signal
) {
634 if (signal
.getTrace() == fTrace
) {
637 fTrace
= signal
.getTrace();
642 * Trace is closed: clear the data structures and the view
644 * @param signal the signal received
647 public void traceClosed(final TmfTraceClosedSignal signal
) {
648 synchronized (fBuildThreadMap
) {
649 BuildThread buildThread
= fBuildThreadMap
.remove(signal
.getTrace());
650 if (buildThread
!= null) {
651 buildThread
.cancel();
654 synchronized (fEntryListMap
) {
655 fEntryListMap
.remove(signal
.getTrace());
657 fSelectedThreadMap
.remove(signal
.getTrace());
658 if (signal
.getTrace() == fTrace
) {
667 * Handler for the TimeSynch signal
670 * The incoming signal
673 public void synchToTime(final TmfTimeSynchSignal signal
) {
675 fSavedTimeSyncSignal
= isPinned() ?
new TmfTimeSynchSignal(signal
.getSource(), signal
.getBeginTime(), signal
.getEndTime()) : null;
677 if (signal
.getSource() == this || fTrace
== null || isPinned()) {
680 final long beginTime
= signal
.getBeginTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
681 final long endTime
= signal
.getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
682 Display
.getDefault().asyncExec(new Runnable() {
685 if (fTimeGraphCombo
.isDisposed()) {
688 if (beginTime
== endTime
) {
689 fTimeGraphCombo
.getTimeGraphViewer().setSelectedTime(beginTime
, true);
691 fTimeGraphCombo
.getTimeGraphViewer().setSelectionRange(beginTime
, endTime
);
693 selectTime(beginTime
);
694 startZoomThread(fTimeGraphCombo
.getTimeGraphViewer().getTime0(), fTimeGraphCombo
.getTimeGraphViewer().getTime1());
695 if (fEntryList
== null) {
698 TimeGraphViewer viewer
= fTimeGraphCombo
.getTimeGraphViewer();
699 for (ThreadEntry threadEntry
: fEntryList
) {
700 ITmfStateSystem ss
= threadEntry
.getStateSystem();
701 if (ss
== null || beginTime
< ss
.getStartTime() || beginTime
> ss
.getCurrentEndTime()) {
705 int quark
= threadEntry
.getCallStackQuark();
706 ITmfStateInterval stackInterval
= ss
.querySingleState(beginTime
, quark
);
707 if (beginTime
== stackInterval
.getStartTime()) {
708 int stackLevel
= stackInterval
.getStateValue().unboxInt();
709 ITimeGraphEntry selectedEntry
= threadEntry
.getChildren().get(Math
.max(0, stackLevel
- 1));
710 fTimeGraphCombo
.setSelection(selectedEntry
);
711 viewer
.getTimeGraphControl().fireSelectionChanged();
714 } catch (AttributeNotFoundException e
) {
715 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
716 } catch (TimeRangeException e
) {
717 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
718 } catch (StateSystemDisposedException e
) {
719 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
720 } catch (StateValueTypeException e
) {
721 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
729 * Handler for the RangeSynch signal
732 * The incoming signal
735 public void synchToRange(final TmfRangeSynchSignal signal
) {
738 fSavedRangeSyncSignal
=
739 new TmfRangeSynchSignal(signal
.getSource(), new TmfTimeRange(signal
.getCurrentRange().getStartTime(), signal
.getCurrentRange().getEndTime()));
741 fSavedTimeSyncSignal
= null;
744 if (signal
.getSource() == this || fTrace
== null || isPinned()) {
747 if (signal
.getCurrentRange().getIntersection(fTrace
.getTimeRange()) == null) {
750 final long startTime
= signal
.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
751 final long endTime
= signal
.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
752 Display
.getDefault().asyncExec(new Runnable() {
755 if (fTimeGraphCombo
.isDisposed()) {
758 fTimeGraphCombo
.getTimeGraphViewer().setStartFinishTime(startTime
, endTime
);
759 startZoomThread(startTime
, endTime
);
764 // ------------------------------------------------------------------------
766 // ------------------------------------------------------------------------
768 private void loadTrace() {
769 synchronized (fEntryListMap
) {
770 fEntryList
= fEntryListMap
.get(fTrace
);
771 if (fEntryList
== null) {
772 synchronized (fBuildThreadMap
) {
773 BuildThread buildThread
= new BuildThread(fTrace
);
774 fBuildThreadMap
.put(fTrace
, buildThread
);
778 fStartTime
= fTrace
.getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
779 fEndTime
= fTrace
.getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
785 private void buildThreadList(final ITmfTrace trace
, IProgressMonitor monitor
) {
786 fStartTime
= Long
.MAX_VALUE
;
787 fEndTime
= Long
.MIN_VALUE
;
788 ITmfTrace
[] traces
= TmfTraceManager
.getTraceSet(trace
);
789 ArrayList
<ThreadEntry
> entryList
= new ArrayList
<>();
790 for (ITmfTrace aTrace
: traces
) {
791 if (monitor
.isCanceled()) {
794 AbstractCallStackAnalysis module
= getCallStackModule(trace
);
795 if (module
== null) {
798 ITmfStateSystem ss
= module
.getStateSystem();
800 addUnavailableEntry(aTrace
, entryList
);
804 if (ss
.isCancelled()) {
805 addUnavailableEntry(aTrace
, entryList
);
808 long startTime
= ss
.getStartTime();
809 long endTime
= ss
.getCurrentEndTime() + 1;
810 fStartTime
= Math
.min(fStartTime
, startTime
);
811 fEndTime
= Math
.max(fEndTime
, endTime
);
812 String
[] threadPaths
= module
.getThreadsPattern();
813 List
<Integer
> threadQuarks
= ss
.getQuarks(threadPaths
);
814 for (int i
= 0; i
< threadQuarks
.size(); i
++) {
815 if (monitor
.isCanceled()) {
818 int threadQuark
= threadQuarks
.get(i
);
820 String
[] callStackPath
= module
.getCallStackPath();
821 int callStackQuark
= ss
.getQuarkRelative(threadQuark
, callStackPath
);
822 String thread
= ss
.getAttributeName(threadQuark
);
823 String threadEntryName
= thread
+ ' ' + '(' + aTrace
.getName() + ')';
824 ThreadEntry threadEntry
= new ThreadEntry(ss
, threadEntryName
, callStackQuark
, startTime
, endTime
);
825 entryList
.add(threadEntry
);
827 for (int stackLevelQuark
: ss
.getSubAttributes(callStackQuark
, false)) {
828 CallStackEntry callStackEntry
= new CallStackEntry(stackLevelQuark
, level
++, aTrace
, ss
);
829 threadEntry
.addChild(callStackEntry
);
831 } catch (AttributeNotFoundException e
) {
832 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
836 synchronized (fEntryListMap
) {
837 fEntryListMap
.put(trace
, new ArrayList
<>(entryList
));
839 if (trace
== fTrace
) {
842 for (ThreadEntry threadEntry
: entryList
) {
843 for (ITimeGraphEntry callStackEntry
: threadEntry
.getChildren()) {
844 if (monitor
.isCanceled()) {
847 buildStatusEvents(trace
, (CallStackEntry
) callStackEntry
, monitor
);
852 private void addUnavailableEntry(ITmfTrace trace
, List
<ThreadEntry
> list
) {
853 String threadName
= Messages
.CallStackView_StackInfoNotAvailable
+ ' ' + '(' + trace
.getName() + ')';
854 ThreadEntry threadEntry
= new ThreadEntry(null, threadName
, -1, 0, 0);
855 list
.add(threadEntry
);
858 private void buildStatusEvents(ITmfTrace trace
, CallStackEntry entry
, IProgressMonitor monitor
) {
859 ITmfStateSystem ss
= entry
.getStateSystem();
860 long start
= ss
.getStartTime();
861 long end
= ss
.getCurrentEndTime() + 1;
862 long resolution
= Math
.max(1, (end
- start
) / fDisplayWidth
);
863 List
<ITimeEvent
> eventList
= getEventList(entry
, start
, end
, resolution
, monitor
);
864 if (monitor
.isCanceled()) {
867 entry
.setEventList(eventList
);
868 if (trace
== fTrace
) {
873 private static List
<ITimeEvent
> getEventList(CallStackEntry entry
,
874 long startTime
, long endTime
, long resolution
,
875 IProgressMonitor monitor
) {
876 ITmfStateSystem ss
= entry
.getStateSystem();
877 long start
= Math
.max(startTime
, ss
.getStartTime());
878 long end
= Math
.min(endTime
, ss
.getCurrentEndTime() + 1);
882 List
<ITimeEvent
> eventList
= null;
884 List
<ITmfStateInterval
> stackIntervals
= ss
.queryHistoryRange(entry
.getQuark(), start
, end
- 1, resolution
, monitor
);
885 eventList
= new ArrayList
<>(stackIntervals
.size());
886 long lastEndTime
= -1;
887 boolean lastIsNull
= true;
888 for (ITmfStateInterval statusInterval
: stackIntervals
) {
889 if (monitor
.isCanceled()) {
892 long time
= statusInterval
.getStartTime();
893 long duration
= statusInterval
.getEndTime() - time
+ 1;
894 if (!statusInterval
.getStateValue().isNull()) {
895 final int modulo
= CallStackPresentationProvider
.NUM_COLORS
/ 2;
896 int value
= statusInterval
.getStateValue().toString().hashCode() % modulo
+ modulo
;
897 eventList
.add(new CallStackEvent(entry
, time
, duration
, value
));
900 if (lastEndTime
== -1) {
901 // add null event if it intersects the start time
902 eventList
.add(new NullTimeEvent(entry
, time
, duration
));
904 if (lastEndTime
!= time
&& lastIsNull
) {
905 // add unknown event if between two null states
906 eventList
.add(new TimeEvent(entry
, lastEndTime
, time
- lastEndTime
));
908 if (time
+ duration
>= endTime
) {
909 // add null event if it intersects the end time
910 eventList
.add(new NullTimeEvent(entry
, time
, duration
));
915 lastEndTime
= time
+ duration
;
917 } catch (AttributeNotFoundException e
) {
918 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
919 } catch (TimeRangeException e
) {
920 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
921 } catch (StateSystemDisposedException e
) {
927 private void selectTime(long time
) {
928 if (fEntryList
== null) {
931 for (ThreadEntry threadEntry
: fEntryList
) {
932 ITmfStateSystem ss
= threadEntry
.getStateSystem();
937 if (ss
.isCancelled()) {
940 long queryTime
= Math
.max(ss
.getStartTime(), Math
.min(ss
.getCurrentEndTime(), time
));
941 for (ITimeGraphEntry child
: threadEntry
.getChildren()) {
942 CallStackEntry callStackEntry
= (CallStackEntry
) child
;
944 ITmfStateInterval stackLevelInterval
= ss
.querySingleState(queryTime
, callStackEntry
.getQuark());
945 ITmfStateValue nameValue
= stackLevelInterval
.getStateValue();
946 String name
= ""; //$NON-NLS-1$
948 if (nameValue
.getType() == Type
.STRING
) {
949 String address
= nameValue
.unboxStr();
950 name
= getFunctionName(address
);
951 } else if (nameValue
.getType() == Type
.INTEGER
) {
952 name
= "0x" + Integer
.toHexString(nameValue
.unboxInt()); //$NON-NLS-1$
953 } else if (nameValue
.getType() == Type
.LONG
) {
954 name
= "0x" + Long
.toHexString(nameValue
.unboxLong()); //$NON-NLS-1$
956 } catch (StateValueTypeException e
) {
958 callStackEntry
.setFunctionName(name
);
959 if (name
.length() > 0) {
960 callStackEntry
.setStartTime(stackLevelInterval
.getStartTime());
961 callStackEntry
.setEndTime(stackLevelInterval
.getEndTime() + 1);
963 } catch (AttributeNotFoundException e
) {
964 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
965 } catch (TimeRangeException e
) {
966 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
967 } catch (StateSystemDisposedException e
) {
968 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
972 fTimeGraphCombo
.refresh();
975 private void refresh() {
976 Display
.getDefault().asyncExec(new Runnable() {
979 if (fTimeGraphCombo
.isDisposed()) {
982 ITimeGraphEntry
[] entries
= null;
983 synchronized (fEntryListMap
) {
984 fEntryList
= fEntryListMap
.get(fTrace
);
985 if (fEntryList
== null) {
986 fEntryList
= new ArrayList
<>();
988 entries
= fEntryList
.toArray(new ITimeGraphEntry
[0]);
990 fTimeGraphCombo
.setInput(entries
);
991 fTimeGraphCombo
.getTimeGraphViewer().setTimeBounds(fStartTime
, fEndTime
);
993 long selectionBeginTime
= fTrace
== null ?
0 : fTraceManager
.getSelectionBeginTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
994 long selectionEndTime
= fTrace
== null ?
0 : fTraceManager
.getSelectionEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
995 long startTime
= fTrace
== null ?
0 : fTraceManager
.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
996 long endTime
= fTrace
== null ?
0 : fTraceManager
.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
997 startTime
= Math
.max(startTime
, fStartTime
);
998 endTime
= Math
.min(endTime
, fEndTime
);
999 fTimeGraphCombo
.getTimeGraphViewer().setSelectionRange(selectionBeginTime
, selectionEndTime
);
1000 selectTime(selectionBeginTime
);
1001 fTimeGraphCombo
.getTimeGraphViewer().setStartFinishTime(startTime
, endTime
);
1002 startZoomThread(startTime
, endTime
);
1007 private void redraw() {
1008 synchronized (fSyncObj
) {
1009 if (fRedrawState
== State
.IDLE
) {
1010 fRedrawState
= State
.BUSY
;
1012 fRedrawState
= State
.PENDING
;
1016 Display
.getDefault().asyncExec(new Runnable() {
1019 if (fTimeGraphCombo
.isDisposed()) {
1022 fTimeGraphCombo
.redraw();
1023 fTimeGraphCombo
.update();
1024 synchronized (fSyncObj
) {
1025 if (fRedrawState
== State
.PENDING
) {
1026 fRedrawState
= State
.IDLE
;
1029 fRedrawState
= State
.IDLE
;
1036 private void startZoomThread(long startTime
, long endTime
) {
1037 if (fZoomThread
!= null) {
1038 fZoomThread
.cancel();
1040 fZoomThread
= new ZoomThread(fEntryList
, startTime
, endTime
);
1041 fZoomThread
.start();
1044 private void makeActions() {
1045 fPreviousItemAction
= fTimeGraphCombo
.getTimeGraphViewer().getPreviousItemAction();
1046 fPreviousItemAction
.setText(Messages
.TmfTimeGraphViewer_PreviousItemActionNameText
);
1047 fPreviousItemAction
.setToolTipText(Messages
.TmfTimeGraphViewer_PreviousItemActionToolTipText
);
1048 fNextItemAction
= fTimeGraphCombo
.getTimeGraphViewer().getNextItemAction();
1049 fNextItemAction
.setText(Messages
.TmfTimeGraphViewer_NextItemActionNameText
);
1050 fNextItemAction
.setToolTipText(Messages
.TmfTimeGraphViewer_NextItemActionToolTipText
);
1053 private void contributeToActionBars() {
1054 IActionBars bars
= getViewSite().getActionBars();
1055 fillLocalToolBar(bars
.getToolBarManager());
1057 // Create pin action
1058 contributePinActionToToolBar();
1059 fPinAction
.addPropertyChangeListener(new IPropertyChangeListener(){
1061 public void propertyChange(PropertyChangeEvent event
) {
1062 if (IAction
.CHECKED
.equals(event
.getProperty()) && !isPinned()) {
1063 if (fSavedRangeSyncSignal
!= null) {
1064 synchToRange(fSavedRangeSyncSignal
);
1065 fSavedRangeSyncSignal
= null;
1068 if (fSavedTimeSyncSignal
!= null) {
1069 synchToTime(fSavedTimeSyncSignal
);
1070 fSavedTimeSyncSignal
= null;
1077 private void fillLocalToolBar(IToolBarManager manager
) {
1078 manager
.add(getImportMappingAction());
1079 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getResetScaleAction());
1080 manager
.add(getPreviousEventAction());
1081 manager
.add(getNextEventAction());
1082 manager
.add(fPreviousItemAction
);
1083 manager
.add(fNextItemAction
);
1084 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getZoomInAction());
1085 manager
.add(fTimeGraphCombo
.getTimeGraphViewer().getZoomOutAction());
1086 manager
.add(new Separator());
1090 * Get the the next event action.
1092 * @return The action object
1094 private Action
getNextEventAction() {
1095 if (fNextEventAction
== null) {
1096 fNextEventAction
= new Action() {
1099 TimeGraphViewer viewer
= fTimeGraphCombo
.getTimeGraphViewer();
1100 ITimeGraphEntry entry
= viewer
.getSelection();
1101 if (entry
instanceof CallStackEntry
) {
1103 CallStackEntry callStackEntry
= (CallStackEntry
) entry
;
1104 ITmfStateSystem ss
= callStackEntry
.getStateSystem();
1105 long time
= Math
.max(ss
.getStartTime(), Math
.min(ss
.getCurrentEndTime(), viewer
.getSelectionBegin()));
1106 ThreadEntry threadEntry
= (ThreadEntry
) callStackEntry
.getParent();
1107 int quark
= ss
.getParentAttributeQuark(callStackEntry
.getQuark());
1108 ITmfStateInterval stackInterval
= ss
.querySingleState(time
, quark
);
1109 long newTime
= stackInterval
.getEndTime() + 1;
1110 viewer
.setSelectedTimeNotify(newTime
, true);
1111 stackInterval
= ss
.querySingleState(Math
.min(ss
.getCurrentEndTime(), newTime
), quark
);
1112 int stackLevel
= stackInterval
.getStateValue().unboxInt();
1113 ITimeGraphEntry selectedEntry
= threadEntry
.getChildren().get(Math
.max(0, stackLevel
- 1));
1114 fTimeGraphCombo
.setSelection(selectedEntry
);
1115 viewer
.getTimeGraphControl().fireSelectionChanged();
1116 startZoomThread(viewer
.getTime0(), viewer
.getTime1());
1118 } catch (AttributeNotFoundException e
) {
1119 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
1120 } catch (TimeRangeException e
) {
1121 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
1122 } catch (StateSystemDisposedException e
) {
1123 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
1124 } catch (StateValueTypeException e
) {
1125 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
1131 fNextEventAction
.setText(Messages
.TmfTimeGraphViewer_NextEventActionNameText
);
1132 fNextEventAction
.setToolTipText(Messages
.TmfTimeGraphViewer_NextEventActionToolTipText
);
1133 fNextEventAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_NEXT_EVENT
));
1136 return fNextEventAction
;
1140 * Get the previous event action.
1142 * @return The Action object
1144 private Action
getPreviousEventAction() {
1145 if (fPrevEventAction
== null) {
1146 fPrevEventAction
= new Action() {
1149 TimeGraphViewer viewer
= fTimeGraphCombo
.getTimeGraphViewer();
1150 ITimeGraphEntry entry
= viewer
.getSelection();
1151 if (entry
instanceof CallStackEntry
) {
1153 CallStackEntry callStackEntry
= (CallStackEntry
) entry
;
1154 ITmfStateSystem ss
= callStackEntry
.getStateSystem();
1155 long time
= Math
.max(ss
.getStartTime(), Math
.min(ss
.getCurrentEndTime(), viewer
.getSelectionBegin()));
1156 ThreadEntry threadEntry
= (ThreadEntry
) callStackEntry
.getParent();
1157 int quark
= ss
.getParentAttributeQuark(callStackEntry
.getQuark());
1158 ITmfStateInterval stackInterval
= ss
.querySingleState(time
, quark
);
1159 if (stackInterval
.getStartTime() == time
&& time
> ss
.getStartTime()) {
1160 stackInterval
= ss
.querySingleState(time
- 1, quark
);
1162 viewer
.setSelectedTimeNotify(stackInterval
.getStartTime(), true);
1163 int stackLevel
= stackInterval
.getStateValue().unboxInt();
1164 ITimeGraphEntry selectedEntry
= threadEntry
.getChildren().get(Math
.max(0, stackLevel
- 1));
1165 fTimeGraphCombo
.setSelection(selectedEntry
);
1166 viewer
.getTimeGraphControl().fireSelectionChanged();
1167 startZoomThread(viewer
.getTime0(), viewer
.getTime1());
1169 } catch (AttributeNotFoundException e
) {
1170 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
1171 } catch (TimeRangeException e
) {
1172 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
1173 } catch (StateSystemDisposedException e
) {
1174 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
1175 } catch (StateValueTypeException e
) {
1176 Activator
.getDefault().logError("Error querying state system", e
); //$NON-NLS-1$
1182 fPrevEventAction
.setText(Messages
.TmfTimeGraphViewer_PreviousEventActionNameText
);
1183 fPrevEventAction
.setToolTipText(Messages
.TmfTimeGraphViewer_PreviousEventActionToolTipText
);
1184 fPrevEventAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_PREV_EVENT
));
1187 return fPrevEventAction
;
1190 private static @Nullable AbstractCallStackAnalysis
getCallStackModule(ITmfTrace trace
) {
1192 * Since we cannot know the exact analysis ID (in separate plugins), we
1193 * will search using the analysis type.
1195 Iterable
<AbstractCallStackAnalysis
> modules
=
1196 trace
.getAnalysisModulesOfClass(AbstractCallStackAnalysis
.class);
1197 Iterator
<AbstractCallStackAnalysis
> it
= modules
.iterator();
1198 if (!it
.hasNext()) {
1199 /* This trace does not provide a call-stack analysis */
1204 * We only look at the first module we find.
1206 * TODO Handle the advanced case where one trace provides more than one
1207 * call-stack analysis.
1209 AbstractCallStackAnalysis module
= it
.next();
1210 /* This analysis is not automatic, we need to schedule it on-demand */
1212 module
.waitForInitialization();
1216 // ------------------------------------------------------------------------
1217 // Methods related to function name mapping
1218 // ------------------------------------------------------------------------
1221 * Toolbar icon to import the function address-to-name mapping file.
1223 private Action
getImportMappingAction() {
1224 if (fImportMappingAction
!= null) {
1225 return fImportMappingAction
;
1227 fImportMappingAction
= new Action() {
1230 FileDialog dialog
= new FileDialog(getViewSite().getShell());
1231 dialog
.setText(Messages
.CallStackView_ImportMappingDialogTitle
);
1232 String filePath
= dialog
.open();
1233 if (filePath
== null) {
1234 /* No file was selected, don't change anything */
1238 * Start the mapping import in a separate thread (we do not want
1239 * to UI thread to do this).
1241 Job job
= new ImportMappingJob(new File(filePath
));
1246 fImportMappingAction
.setText(Messages
.CallStackView_ImportMappingButtonText
);
1247 fImportMappingAction
.setToolTipText(Messages
.CallStackView_ImportMappingButtonTooltip
);
1248 fImportMappingAction
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(IMPORT_MAPPING_ICON_PATH
));
1250 return fImportMappingAction
;
1253 private class ImportMappingJob
extends Job
{
1254 private final File fMappingFile
;
1256 public ImportMappingJob(File mappingFile
) {
1257 super(Messages
.CallStackView_ImportMappingJobName
);
1258 fMappingFile
= mappingFile
;
1262 public IStatus
run(IProgressMonitor monitor
) {
1263 fNameMapping
= FunctionNameMapper
.mapFromNmTextFile(fMappingFile
);
1265 /* Refresh the time graph and the list of entries */
1266 buildThreadList(fTrace
, new NullProgressMonitor());
1269 return Status
.OK_STATUS
;
1273 String
getFunctionName(String address
) {
1274 if (fNameMapping
== null) {
1275 /* No mapping available, just print the addresses */
1278 String ret
= fNameMapping
.get(address
);
1280 /* We didn't find this address in the mapping file, just use the address */