lttng.ust: Do not block in UstDebugInfoAnalysisModule
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Thu, 14 Jul 2016 23:59:13 +0000 (19:59 -0400)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Fri, 2 Sep 2016 18:15:57 +0000 (14:15 -0400)
Query methods in the module should not call waitForCompletion()
on the analysis, but should return whatever data they have
(or null).

This is because this is called by the aspects, which are called
by the event table, which are called by the UI thread! The UI
should not block while the analysis is waiting construction.

If a specific caller wants to wait for the full data, they can
call waitForCompletion() manually, like the tests do.

Change-Id: I2cf4e3544a8eea71a65f1e16fe7d4b5ba881d5ca
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/77374
Reviewed-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/analysis/debuginfo/UstDebugInfoAnalysisModuleTest.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java

index 6d5c15027322b96127db705ca97f101b43a6ac8f..38ae3740031963ddc678bfd0631823bacbe248f5 100644 (file)
@@ -37,6 +37,7 @@ import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType;
 import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
 import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
 import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
 import org.junit.After;
@@ -164,6 +165,10 @@ public class UstDebugInfoAnalysisModuleTest {
         TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, trace, null);
         TmfSignalManager.dispatchSignal(signal);
 
+        UstDebugInfoAnalysisModule module = TmfTraceUtils.getAnalysisModuleOfClass(trace, UstDebugInfoAnalysisModule.class, UstDebugInfoAnalysisModule.ID);
+        assertNotNull(module);
+        module.waitForCompletion();
+
         /* Send a request to get the 3 events we are interested in */
         List<@NonNull LttngUstEvent> events = new ArrayList<>();
         TmfEventRequest request = new TmfEventRequest(LttngUstEvent.class, 31, 1, ExecutionType.FOREGROUND) {
index dad1258a4077d3706e5a377aaae9e3636edf48cc..6bed8e314a64d5018f64ec4cde84012e596a9152 100644 (file)
@@ -114,7 +114,6 @@ public class UstDebugInfoAnalysisModule extends TmfStateSystemAnalysisModule {
      * @return The binaries (executables or libraries) referred to in the trace.
      */
     public Collection<UstDebugInfoBinaryFile> getAllBinaries() {
-        waitForCompletion();
         ITmfStateSystem ss = getStateSystem();
         if (ss == null) {
             /* State system might not yet be initialized */
@@ -167,9 +166,7 @@ public class UstDebugInfoAnalysisModule extends TmfStateSystemAnalysisModule {
                     interval = StateSystemUtils.queryUntilNonNullValue(ss, baddrQuark, ts, Long.MAX_VALUE);
                 }
             }
-        } catch (AttributeNotFoundException e) {
-            throw new IllegalStateException(e);
-        } catch (TimeRangeException | StateSystemDisposedException e) {
+        } catch (AttributeNotFoundException | TimeRangeException | StateSystemDisposedException e) {
             /* Oh well, such is life. */
         }
         return files;
@@ -194,7 +191,6 @@ public class UstDebugInfoAnalysisModule extends TmfStateSystemAnalysisModule {
     @VisibleForTesting
     public @Nullable UstDebugInfoLoadedBinaryFile getMatchingFile(long ts, long vpid, long ip) {
         try {
-            waitForCompletion();
             final ITmfStateSystem ss = getStateSystem();
             if (ss == null) {
                 /* State system might not yet be initialized */
@@ -252,11 +248,8 @@ public class UstDebugInfoAnalysisModule extends TmfStateSystemAnalysisModule {
 
             return new UstDebugInfoLoadedBinaryFile(baddr, filePath, buildId, debugLink, isPic);
 
-        } catch (AttributeNotFoundException e) {
-            // TODO: that's probably not true anymore
-            /* We're only using quarks we've checked for. */
-            throw new IllegalStateException(e);
-        } catch (TimeRangeException | StateSystemDisposedException e) {
+        } catch (AttributeNotFoundException | TimeRangeException | StateSystemDisposedException e) {
+            /* Either the data is not available yet, or incomplete. */
             return null;
         }
     }
This page took 0.025981 seconds and 5 git commands to generate.