aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2013-05-07 18:27:40 (EDT)
committerAlexandre Montplaisir2013-05-09 13:44:49 (EDT)
commit92b86f37d6917a776a833ccdceef219bfaa1653f (patch)
tree34908bfe41177f19e8498b567fc65b4f5edf602a
parent6d414bb198a93805e3d5e6b8aa16b55eb8636118 (diff)
downloadorg.eclipse.linuxtools-92b86f37d6917a776a833ccdceef219bfaa1653f.zip
org.eclipse.linuxtools-92b86f37d6917a776a833ccdceef219bfaa1653f.tar.gz
org.eclipse.linuxtools-92b86f37d6917a776a833ccdceef219bfaa1653f.tar.bz2
Bug 407474 - Exceptions thrown when opening/closing trace with no eventrefs/changes/04/12604/5
Change-Id: I54f618692fba19c07eec436227b1428cddc3a87d Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewed-on: https://git.eclipse.org/r/12604 Tested-by: Hudson CI Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java5
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java14
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/Messages.java3
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/messages.properties1
4 files changed, 20 insertions, 3 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
index 615efdb..2aa6afb 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
@@ -195,6 +195,11 @@ public class CTFTraceReader {
* lower next event timestamp.
*/
private void populateStreamInputReaderHeap() {
+ if (this.streamInputReaders.isEmpty()) {
+ this.prio = new PriorityQueue<StreamInputReader>();
+ return;
+ }
+
/*
* Create the priority queue with a size twice as bigger as the number
* of reader in order to avoid constant resizing.
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
index 4273276..8375eaa 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
+import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
import org.eclipse.linuxtools.internal.tmf.core.Activator;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
@@ -133,11 +134,18 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser {
IStatus validTrace = Status.OK_STATUS;
try {
final CTFTrace temp = new CTFTrace(path);
- boolean valid = temp.majortIsSet(); // random test
- temp.dispose();
- if (!valid) {
+ if (!temp.majortIsSet()) {
validTrace = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_MajorNotSet);
+ } else {
+ CTFTraceReader ctfTraceReader = new CTFTraceReader(temp);
+ if (!ctfTraceReader.hasMoreEvents()) {
+ // TODO: This will need an additional check when we support live traces
+ // because having no event is valid for a live trace
+ validTrace = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_NoEvent);
+ }
+ ctfTraceReader.dispose();
}
+ temp.dispose();
} catch (final CTFReaderException e) {
validTrace = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_ReadingError +": " + e.toString()); //$NON-NLS-1$
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/Messages.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/Messages.java
index fa6d296..654a6ce 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/Messages.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/Messages.java
@@ -29,6 +29,9 @@ public class Messages extends NLS {
/** Reading error */
public static String CtfTmfTrace_ReadingError;
+ /** No event */
+ public static String CtfTmfTrace_NoEvent;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/messages.properties b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/messages.properties
index fe43860..5fe42dc 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/messages.properties
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/messages.properties
@@ -12,3 +12,4 @@
CtfTmfTrace_MajorNotSet=Major version number not set
CtfTmfTrace_ReadingError=Reading error
+CtfTmfTrace_NoEvent=Trace has no events \ No newline at end of file