Add support for GDB Tracepoints
authorFrancois Chouinard <fchouinard@gmail.com>
Wed, 30 Mar 2011 21:38:28 +0000 (17:38 -0400)
committerFrancois Chouinard <fchouinard@gmail.com>
Wed, 30 Mar 2011 21:38:28 +0000 (17:38 -0400)
[1] Support for experiment disposal

Normally, there is only one case where no experiment is selected: at
startup. However, with GDB Tracepoints, each experiment is tied to a
GDB launch. If Mr. User terminates all his experiments, then none is
selected and the various views (namely the Events View :-) should be
cleared.

This patch adds a new signal (TmfExperimentDisposedSignal) and the
necessary support code. In addition, it provides for some symmetry in
the experiment signals.

[2] Trace re-positionning

The Events view is a actually a window on the trace i.e. for memory
consumption reasons, not all the events are read but only a subset
encompassing the visible area. That subset acts as a cache and is
populated on demand.

For LTTng and other internal tools this is just fine. But for GDB
Tracepoints, populating the cache also sets the current event pointer
to the last event read (not the one that was selected before the read
operation). So the pointer needs to refreshed on cache population
completion. Unfortunately, this breaks the other tracers.

As a temporary fix to have everybody sit on the same version of the
TMF, a hook was added. Today, it is only implemented by GDB
Tracepoints.

org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/experiment/TmfExperiment.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/signal/TmfExperimentDisposedSignal.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java

index a52f3d4b9eeed2a48c3fa2da3048877fff03a956..bf69d29accf122477841b0db9340d31c0946ef24 100644 (file)
@@ -1418,7 +1418,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                                 fTable.refresh();\r
                                 packColumns();\r
                             }\r
-//                            fTrace.seekEvent(fSelectedRank);\r
+                            populateCompleted();\r
                         }\r
                     });\r
                 }\r
@@ -1435,7 +1435,11 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
         job.setPriority(Job.SHORT);\r
         job.schedule();\r
     }\r
-    \r
+\r
+    protected void populateCompleted() {\r
+       // Nothing by default;\r
+    }\r
+\r
     // ------------------------------------------------------------------------\r
     // Bookmark handling\r
     // ------------------------------------------------------------------------\r
index 6ca4e7ab0a5dca81735d5dbe78a64584ff11feec..ed1593d0bfe788c014ba424f35c5770b648ab92a 100644 (file)
@@ -15,8 +15,10 @@ package org.eclipse.linuxtools.tmf.ui.views;
 
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
+import org.eclipse.linuxtools.tmf.signal.TmfExperimentDisposedSignal;
 import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal;
 import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin;
 import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
 import org.eclipse.swt.widgets.Composite;
 
@@ -106,12 +108,31 @@ public class TmfEventsView extends TmfView {
     @TmfSignalHandler
     public void experimentSelected(TmfExperimentSelectedSignal<TmfEvent> signal) {
         // Update the trace reference
-        fExperiment = (TmfExperiment<TmfEvent>) signal.getExperiment();
-        setPartName(fTitlePrefix + " - " + fExperiment.getName()); //$NON-NLS-1$
-
-        if (fEventsTable != null) {
-            fEventsTable.setTrace(fExperiment, false);
+        TmfExperiment<TmfEvent> exp = (TmfExperiment<TmfEvent>) signal.getExperiment();
+        if (!exp.equals(fExperiment)) {
+               fExperiment = exp;
+            setPartName(fTitlePrefix + " - " + fExperiment.getName()); //$NON-NLS-1$
+            if (fEventsTable != null) {
+               fEventsTable.setTrace(fExperiment, false);
+            }
         }
     }
 
+       @SuppressWarnings("unchecked")
+       @TmfSignalHandler
+       public void experimentDisposed(TmfExperimentDisposedSignal<TmfEvent> signal) {
+               // Clear the trace reference
+               TmfExperiment<TmfEvent> experiment = (TmfExperiment<TmfEvent>) signal.getExperiment();
+               if (experiment.equals(fExperiment)) {
+                       fEventsTable.setTrace(null, false);
+               }
+
+               TmfUiPlugin.getDefault().getWorkbench().getWorkbenchWindows()[0].getShell().getDisplay().syncExec(new Runnable() {
+                       @Override
+                       public void run() {
+                               setPartName(fTitlePrefix);
+                       }
+               });
+       }
+
 }
\ No newline at end of file
index 0e4cb9ebacdbc7ee890f7bd1b44f126bf813bdd0..d7cc787222b4d9580093585c6803847aae44f270 100644 (file)
@@ -28,6 +28,7 @@ import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType;
 import org.eclipse.linuxtools.tmf.request.ITmfEventRequest;
 import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
 import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.signal.TmfExperimentDisposedSignal;
 import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal;
 import org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal;
 import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
@@ -154,6 +155,10 @@ public class TmfExperiment<T extends TmfEvent> extends TmfEventProvider<T> imple
      */
     @Override
        public synchronized void dispose() {
+
+       TmfExperimentDisposedSignal<T> signal = new TmfExperimentDisposedSignal<T>(this, this);
+       broadcast(signal);
+
        if (fTraces != null) {
                for (ITmfTrace trace : fTraces) {
                        trace.dispose();
diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/signal/TmfExperimentDisposedSignal.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/signal/TmfExperimentDisposedSignal.java
new file mode 100644 (file)
index 0000000..33bfe55
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.signal;
+
+import org.eclipse.linuxtools.tmf.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
+
+/**
+ * <b><u>TmfExperimentDisposedSignal</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfExperimentDisposedSignal<T extends TmfEvent> extends TmfSignal {
+
+       private final TmfExperiment<T> fExperiment;
+       
+       public TmfExperimentDisposedSignal(Object source, TmfExperiment<T> experiment) {
+               super(source);
+               fExperiment = experiment;
+       }
+
+       public TmfExperiment<? extends TmfEvent> getExperiment() {
+               return fExperiment;
+       }
+
+       @Override
+    @SuppressWarnings("nls")
+       public String toString() {
+               return "[TmfExperimentDisposedSignal (" + fExperiment.getName() + ")]";
+       }
+}
index 7cc3ca5abb786951137a40f3b07c48bd03fa4b89..f190c964f8277100e8ccca38469e1d360bd96315 100644 (file)
@@ -12,7 +12,6 @@
 
 package org.eclipse.linuxtools.tmf.trace;
 
-import java.io.File;
 import java.io.FileNotFoundException;
 import java.util.Collections;
 import java.util.Vector;
@@ -120,9 +119,11 @@ public abstract class TmfTrace<T extends TmfEvent> extends TmfEventProvider<T> i
      */
     protected TmfTrace(String name, Class<T> type, String path, int cacheSize, boolean indexTrace) throws FileNotFoundException {
        super(name, type);
-       int sep = path.lastIndexOf(File.separator);
-       String simpleName = (sep >= 0) ? path.substring(sep + 1) : path;
-       setName(simpleName);
+//     if (path != null) {
+//             int sep = path.lastIndexOf(File.separator);
+//             String simpleName = (sep >= 0) ? path.substring(sep + 1) : path;
+//             setName(simpleName);
+//     }
        fPath = path;
         fIndexPageSize = (cacheSize > 0) ? cacheSize : DEFAULT_INDEX_PAGE_SIZE;
         if (indexTrace) {
@@ -428,7 +429,7 @@ public abstract class TmfTrace<T extends TmfEvent> extends TmfEventProvider<T> i
         * event).
         */
 
-    @SuppressWarnings({ "unchecked", "unused" })
+    @SuppressWarnings({ "unchecked" })
     private void indexTrace(boolean waitForCompletion) {
 
        final Job job = new Job("Indexing " + getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$
This page took 0.03247 seconds and 5 git commands to generate.