From ed48dc75057206ed8992076bdfb1c3be1e74b2ff Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Fri, 6 May 2016 11:00:29 -0400 Subject: [PATCH] ss: Replace AttributeNotFoundException with IOOBE for quark parameters Methods that take a quark integer as parameter are changed to throw a runtime IndexOutOfBoundsException instead of a checked AttributeNotFoundException. This makes those methods consistent with other methods that already throw IOOBE when the quark is out of range. Many occurrences were already swallowing the exception or re-throwing a runtime exception. Change-Id: I943b407e07bbc226c6b7c03306cd6d00f783bca2 Signed-off-by: Patrick Tasse Reviewed-on: https://git.eclipse.org/r/72198 Reviewed-by: Alexandre Montplaisir Reviewed-by: Hudson CI --- .../KernelThreadInformationProvider.java | 2 +- .../core/tid/ActiveTidStateProvider.java | 3 +- .../os/linux/core/tid/TidAnalysisModule.java | 3 +- .../core/inputoutput/DiskWriteModel.java | 12 +-- .../ui/views/controlflow/ControlFlowView.java | 5 - .../KernelMemoryUsageTreeViewer.java | 3 +- .../tid/TidAnalysisUsageBenchmark.java | 10 +- .../module/VirtualMachineStateProvider.java | 4 +- .../views/vm/vcpuview/VirtualMachineView.java | 5 - .../memory/UstMemoryStateProvider.java | 5 +- .../debuginfo/UstDebugInfoAnalysisModule.java | 58 +++++----- .../core/tests/StateSystemPushPopTest.java | 4 +- .../core/tests/StateSystemUtilsTest.java | 4 +- .../tests/backend/InMemoryBackendTest.java | 15 ++- .../backend/StateHistoryBackendTestBase.java | 3 +- .../statesystem/core/AttributeTree.java | 30 +++--- .../statesystem/core/StateSystem.java | 99 ++++++++--------- .../statesystem/core/TransientState.java | 50 ++++----- .../core/backend/InMemoryBackend.java | 7 +- .../statesystem/core/ITmfStateSystem.java | 36 +++---- .../core/ITmfStateSystemBuilder.java | 43 ++++---- .../statesystem/core/StateSystemUtils.java | 4 +- .../core/backend/IStateHistoryBackend.java | 9 +- .../model/TmfXmlScenarioHistoryBuilder.java | 19 ++-- .../ui/views/timegraph/XmlTimeGraphView.java | 63 ++++++----- .../xml/ui/views/xychart/XmlXYViewer.java | 27 ++--- .../tests/statesystem/AttributePoolTest.java | 19 +--- .../mipmap/TmfMipmapStateProviderStub.java | 6 +- .../analysis/TestExperimentAnalysis.java | 5 +- .../analysis/TestStateSystemProvider.java | 5 +- .../partial/PartialHistoryBackend.java | 20 ++-- .../AbstractTmfMipmapStateProvider.java | 9 +- .../statesystem/mipmap/TmfMipmapFeature.java | 5 +- .../callstack/CallStackStateProvider.java | 100 ++++++++---------- .../event/aspect/TmfStateSystemAspect.java | 5 +- .../core/statesystem/TmfAttributePool.java | 8 +- .../CallStackPresentationProvider.java | 7 +- .../tmf/ui/views/callstack/CallStackView.java | 4 +- .../statesystem/TmfStateSystemViewer.java | 75 ++++++------- 39 files changed, 331 insertions(+), 460 deletions(-) diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java index 0beb0e5c85..de0125ba18 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java @@ -189,7 +189,7 @@ public final class KernelThreadInformationProvider { } try { return ss.querySingleState(ts, prioQuark).getStateValue().unboxInt(); - } catch (AttributeNotFoundException | StateSystemDisposedException e) { + } catch (StateSystemDisposedException e) { return -1; } } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/tid/ActiveTidStateProvider.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/tid/ActiveTidStateProvider.java index d9f9dee5ff..78a5ee7ac5 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/tid/ActiveTidStateProvider.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/tid/ActiveTidStateProvider.java @@ -17,7 +17,6 @@ import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEven import org.eclipse.tracecompass.common.core.NonNullUtils; import org.eclipse.tracecompass.internal.analysis.os.linux.core.Activator; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; @@ -90,7 +89,7 @@ class ActiveTidStateProvider extends AbstractTmfStateProvider { int nextTid = ((Long) event.getContent().getField(fNextTid).getValue()).intValue(); final TmfStateValue value = TmfStateValue.newValueInt(nextTid); ssb.modifyAttribute(event.getTimestamp().toNanos(), value, cpuQuark); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { Activator.getDefault().logError(NonNullUtils.nullToEmptyString(e.getMessage()), e); } } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/tid/TidAnalysisModule.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/tid/TidAnalysisModule.java index cf261f4176..3745b4ccae 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/tid/TidAnalysisModule.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/tid/TidAnalysisModule.java @@ -23,7 +23,6 @@ import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace; import org.eclipse.tracecompass.common.core.NonNullUtils; import org.eclipse.tracecompass.internal.analysis.os.linux.core.Activator; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; @@ -90,7 +89,7 @@ public class TidAnalysisModule extends TmfStateSystemAnalysisModule { if (value.getType().equals(Type.INTEGER)) { tid = value.unboxInt(); } - } catch (AttributeNotFoundException | StateSystemDisposedException e) { + } catch (StateSystemDisposedException e) { Activator.getDefault().logError(NonNullUtils.nullToEmptyString(e.getMessage()), e); } return tid; diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/inputoutput/DiskWriteModel.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/inputoutput/DiskWriteModel.java index feaecbcb2c..6800c4c0e8 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/inputoutput/DiskWriteModel.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/inputoutput/DiskWriteModel.java @@ -71,7 +71,7 @@ public class DiskWriteModel extends Disk { super.setDiskName(diskname); try { fSs.modifyAttribute(fSs.getCurrentEndTime(), TmfStateValue.newValueString(diskname), getQuark()); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { Activator.getDefault().logError("Cannot set the diskname for disk " + diskname, e); //$NON-NLS-1$ } } @@ -145,7 +145,7 @@ public class DiskWriteModel extends Disk { int mergedInQuark = fSs.getQuarkRelativeAndAdd(slotQuark, Attributes.MERGED_IN); fSs.modifyAttribute(ts, TmfStateValue.nullValue(), mergedInQuark); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { Activator.getDefault().logError("Error inserting request", e); //$NON-NLS-1$ } fWaitingQueue.put(request.getSector(), new Pair<>(request, slotQuark)); @@ -192,7 +192,7 @@ public class DiskWriteModel extends Disk { int mergedInQuark = fSs.getQuarkRelativeAndAdd(slotQuark, Attributes.MERGED_IN); fSs.modifyAttribute(ts, TmfStateValue.nullValue(), mergedInQuark); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { Activator.getDefault().logError("Error inserting request", e); //$NON-NLS-1$ } @@ -275,7 +275,7 @@ public class DiskWriteModel extends Disk { int issuedFromQuark = fSs.getQuarkRelativeAndAdd(slotQuark, Attributes.ISSUED_FROM); fSs.modifyAttribute(ts, issuedFromValue, issuedFromQuark); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { Activator.getDefault().logError("Error issuing request", e); //$NON-NLS-1$ } @@ -341,7 +341,7 @@ public class DiskWriteModel extends Disk { int issuedFromQuark = fSs.getQuarkRelativeAndAdd(mergedQuark, Attributes.MERGED_IN); fSs.modifyAttribute(ts, TmfStateValue.newValueInt(Integer.parseInt(reqQueueId)), issuedFromQuark); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { Activator.getDefault().logError("Error adding the merged request information", e); //$NON-NLS-1$ } } @@ -363,7 +363,7 @@ public class DiskWriteModel extends Disk { fSs.modifyAttribute(ts, TmfStateValue.newValueInt(getDriverQueueSize()), fDriverQueueLength); int fWaitinQueueLength = fSs.getQuarkRelativeAndAdd(getQuark(), Attributes.WAITING_QUEUE_LENGTH); fSs.modifyAttribute(ts, TmfStateValue.newValueInt(getWaitingQueueSize()), fWaitinQueueLength); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { Activator.getDefault().logError("Error updating queues lengths", e); //$NON-NLS-1$ } } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/controlflow/ControlFlowView.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/controlflow/ControlFlowView.java index e7b5d9bd24..0f96a61fe8 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/controlflow/ControlFlowView.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/controlflow/ControlFlowView.java @@ -458,8 +458,6 @@ public class ControlFlowView extends AbstractStateSystemTimeGraphView { ppidInterval = ssq.querySingleState(startTime - 1, ppidQuark); startTime = execNameInterval.getStartTime(); endTime = execNameInterval.getEndTime() + 1; - } catch (AttributeNotFoundException e) { - Activator.getDefault().logError(e.getMessage()); } catch (StateSystemDisposedException e) { /* ignored */ } @@ -773,9 +771,6 @@ public class ControlFlowView extends AbstractStateSystemTimeGraphView { long end = Math.min(currentThreadInterval.getEndTime() + 1, ss.getCurrentEndTime()); currentThreadIntervals.add(ss.querySingleState(end, currentThreadQuark)); } - } catch (AttributeNotFoundException e) { - Activator.getDefault().logError(e.getMessage()); - return list; } catch (StateSystemDisposedException e) { /* Ignored */ return list; diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/kernelmemoryusage/KernelMemoryUsageTreeViewer.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/kernelmemoryusage/KernelMemoryUsageTreeViewer.java index c40c262c85..2a239a6fad 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/kernelmemoryusage/KernelMemoryUsageTreeViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/kernelmemoryusage/KernelMemoryUsageTreeViewer.java @@ -25,7 +25,6 @@ import org.eclipse.tracecompass.analysis.os.linux.core.kernelmemoryusage.KernelM import org.eclipse.tracecompass.analysis.os.linux.core.kernelmemoryusage.KernelMemoryStateProvider; import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Activator; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; @@ -183,7 +182,7 @@ public class KernelMemoryUsageTreeViewer extends AbstractTmfTreeViewer { entryList.add(obj); } } - } catch (StateSystemDisposedException | AttributeNotFoundException e) { + } catch (StateSystemDisposedException e) { Activator.getDefault().logError(e.getMessage(), e); } return root; diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/tid/TidAnalysisUsageBenchmark.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/tid/TidAnalysisUsageBenchmark.java index 012f343ced..fac86915db 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/tid/TidAnalysisUsageBenchmark.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/tid/TidAnalysisUsageBenchmark.java @@ -24,7 +24,6 @@ import org.eclipse.tracecompass.analysis.os.linux.core.tid.TidAnalysisModule; import org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.kernel.KernelAnalysisBenchmark; import org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace; import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException; import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; @@ -135,13 +134,8 @@ public class TidAnalysisUsageBenchmark { /* Get the number of CPUs */ int cpuCount = -1; - try { - @NonNull - List<@NonNull Integer> cpus = ss.getSubAttributes(ITmfStateSystem.ROOT_ATTRIBUTE, false); - cpuCount = cpus.size(); - } catch (AttributeNotFoundException e) { - fail(e.getMessage()); - } + @NonNull List<@NonNull Integer> cpus = ss.getSubAttributes(ITmfStateSystem.ROOT_ATTRIBUTE, false); + cpuCount = cpus.size(); if (cpuCount < 1) { fail("Impossible to get the number of CPUs"); } diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java index 17ba06d529..d1087567b4 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2015 École Polytechnique de Montréal + * Copyright (c) 2014, 2016 École Polytechnique de Montréal * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -335,7 +335,7 @@ public class VirtualMachineStateProvider extends AbstractTmfStateProvider { break; } - } catch (AttributeNotFoundException | TimeRangeException | StateValueTypeException e) { + } catch (TimeRangeException | StateValueTypeException e) { Activator.getDefault().logError("Error handling event in VirtualMachineStateProvider", e); //$NON-NLS-1$ } } diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/views/vm/vcpuview/VirtualMachineView.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/views/vm/vcpuview/VirtualMachineView.java index 4352641034..5b56d30751 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/views/vm/vcpuview/VirtualMachineView.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/views/vm/vcpuview/VirtualMachineView.java @@ -227,11 +227,6 @@ public class VirtualMachineView extends AbstractTimeGraphView { /* Add the entries for the threads */ buildThreadEntries(vmEntry, entryMap, startTime, endTime); } - } catch (AttributeNotFoundException e) { - /* - * The attribute may not exist yet if the state system is being - * built - */ } catch (TimeRangeException | StateValueTypeException e) { Activator.getDefault().logError("VirtualMachineView: error building event list", e); //$NON-NLS-1$ } diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStateProvider.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStateProvider.java index 68d5426e24..28dbc5bf6e 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStateProvider.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStateProvider.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2014, 2015 Ericsson, École Polytechnique de Montréal + * Copyright (c) 2014, 2016 Ericsson, École Polytechnique de Montréal * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -22,7 +22,6 @@ import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace; import org.eclipse.tracecompass.lttng2.ust.core.trace.layout.ILttngUstEventLayout; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; @@ -226,7 +225,7 @@ public class UstMemoryStateProvider extends AbstractTmfStateProvider { long prevMemValue = prevMem.unboxLong(); prevMemValue += memoryDiff.longValue(); ss.modifyAttribute(ts, TmfStateValue.newValueLong(prevMemValue), tidMemQuark); - } catch (AttributeNotFoundException | TimeRangeException | StateValueTypeException e) { + } catch (TimeRangeException | StateValueTypeException e) { throw new IllegalStateException(e); } } diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java index 4953d989f9..30cd99d975 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir + * Copyright (c) 2015, 2016 EfficiOS Inc., Alexandre Montplaisir * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -119,44 +119,40 @@ public class UstDebugInfoAnalysisModule extends TmfStateSystemAnalysisModule { ITmfStateSystem ss = checkNotNull(getStateSystem()); Set files = new TreeSet<>(); - try { - ImmutableList.Builder builder = ImmutableList.builder(); - List vpidQuarks = ss.getSubAttributes(-1, false); - for (Integer vpidQuark : vpidQuarks) { - builder.addAll(ss.getSubAttributes(vpidQuark, false)); - } - List baddrQuarks = builder.build(); + ImmutableList.Builder builder = ImmutableList.builder(); + List vpidQuarks = ss.getSubAttributes(-1, false); + for (Integer vpidQuark : vpidQuarks) { + builder.addAll(ss.getSubAttributes(vpidQuark, false)); + } + List baddrQuarks = builder.build(); - /* - * For each "baddr" attribute, get the "buildId" sub-attribute, - * whose value is the file path. - */ + /* + * For each "baddr" attribute, get the "buildId" sub-attribute, + * whose value is the file path. + */ - for (Integer baddrQuark : baddrQuarks) { + for (Integer baddrQuark : baddrQuarks) { - List buildIdQuarks = ss.getSubAttributes(baddrQuark, false); - for (Integer buildIdQuark : buildIdQuarks) { - String buildId = ss.getAttributeName(buildIdQuark); + List buildIdQuarks = ss.getSubAttributes(baddrQuark, false); + for (Integer buildIdQuark : buildIdQuarks) { + String buildId = ss.getAttributeName(buildIdQuark); + /* + * Explore the history of this attribute "horizontally", + * even though there should only be one valid interval. + */ + ITmfStateInterval interval = StateSystemUtils.queryUntilNonNullValue(ss, buildIdQuark, ss.getStartTime(), Long.MAX_VALUE); + if (interval == null) { /* - * Explore the history of this attribute "horizontally", - * even though there should only be one valid interval. + * If we created the attribute, we should have assigned + * a value to it! */ - ITmfStateInterval interval = StateSystemUtils.queryUntilNonNullValue(ss, buildIdQuark, ss.getStartTime(), Long.MAX_VALUE); - if (interval == null) { - /* - * If we created the attribute, we should have assigned - * a value to it! - */ - throw new IllegalStateException(); - } - String filePath = interval.getStateValue().unboxStr(); - - files.add(new UstDebugInfoBinaryFile(filePath, buildId)); + throw new IllegalStateException(); } + String filePath = interval.getStateValue().unboxStr(); + + files.add(new UstDebugInfoBinaryFile(filePath, buildId)); } - } catch (AttributeNotFoundException e) { - throw new IllegalStateException(e); } return files; } diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/StateSystemPushPopTest.java b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/StateSystemPushPopTest.java index c47f19f527..37b5773513 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/StateSystemPushPopTest.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/StateSystemPushPopTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2015 Ericsson + * Copyright (c) 2012, 2016 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -156,7 +156,7 @@ public class StateSystemPushPopTest { assertEquals(30, interval.getEndTime()); assertTrue(interval.getStateValue().isNull()); - } catch (AttributeNotFoundException | TimeRangeException | StateSystemDisposedException e) { + } catch (TimeRangeException | StateSystemDisposedException e) { fail(errMsg + e.toString()); } } diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/StateSystemUtilsTest.java b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/StateSystemUtilsTest.java index 71fd1f7635..853357ef6c 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/StateSystemUtilsTest.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/StateSystemUtilsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2015 École Polytechnique de Montréal + * Copyright (c) 2014, 2016 École Polytechnique de Montréal * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -58,7 +58,7 @@ public class StateSystemUtilsTest { fStateSystem.modifyAttribute(1200L, TmfStateValue.newValueInt(10), quark); fStateSystem.modifyAttribute(1500L, TmfStateValue.newValueInt(20), quark); fStateSystem.closeHistory(2000L); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { fail(e.getMessage()); } } diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/InMemoryBackendTest.java b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/InMemoryBackendTest.java index 6785c488d7..b128577860 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/InMemoryBackendTest.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/InMemoryBackendTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2015 Ericsson + * Copyright (c) 2013, 2016 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -24,7 +24,6 @@ import java.util.List; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend; import org.eclipse.tracecompass.statesystem.core.backend.StateHistoryBackendFactory; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; @@ -171,7 +170,7 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase { ITmfStateInterval ref[] = intervalQuery.toArray(new ITmfStateInterval[0]); assertArrayEquals(ref, interval); - } catch (TimeRangeException | AttributeNotFoundException | StateSystemDisposedException e) { + } catch (TimeRangeException | StateSystemDisposedException e) { fail(e.getMessage()); } } @@ -187,7 +186,7 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase { ITmfStateInterval interval = backend.doSingularQuery(999, 0); assertEquals(TmfStateValue.nullValue(), interval.getStateValue()); - } catch (TimeRangeException | AttributeNotFoundException | StateSystemDisposedException e) { + } catch (TimeRangeException | StateSystemDisposedException e) { fail(e.getMessage()); } } @@ -205,7 +204,7 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase { assertEquals(90, interval.getEndTime()); assertEquals(0, interval.getStateValue().unboxInt()); - } catch (TimeRangeException | AttributeNotFoundException | StateSystemDisposedException e) { + } catch (TimeRangeException | StateSystemDisposedException e) { fail(e.getMessage()); } } @@ -221,7 +220,7 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase { ITmfStateInterval interval = backend.doSingularQuery(99998, 9); testInterval(interval, 99909, 99999, 99); - } catch (TimeRangeException | AttributeNotFoundException | StateSystemDisposedException e) { + } catch (TimeRangeException | StateSystemDisposedException e) { fail(e.getMessage()); } } @@ -240,7 +239,7 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase { ITmfStateInterval interval = backend.doSingularQuery(-1, 0); assertNull(interval); - } catch (AttributeNotFoundException | StateSystemDisposedException e) { + } catch (StateSystemDisposedException e) { fail(e.getMessage()); } } @@ -259,7 +258,7 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase { ITmfStateInterval interval = backend.doSingularQuery(100000, 0); assertNull(interval); - } catch (AttributeNotFoundException | StateSystemDisposedException e) { + } catch (StateSystemDisposedException e) { fail(e.getMessage()); } } diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/StateHistoryBackendTestBase.java b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/StateHistoryBackendTestBase.java index 8f0db65c9f..e841c5b821 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/StateHistoryBackendTestBase.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/StateHistoryBackendTestBase.java @@ -20,7 +20,6 @@ import java.util.List; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; @@ -338,7 +337,7 @@ public abstract class StateHistoryBackendTestBase { interval = backend.doSingularQuery(startTime + (2 * timeStep) + 1, intQuark); assertEquals("Int interval value", INT_VAL1, interval.getStateValue()); - } catch (TimeRangeException | StateSystemDisposedException | IOException | AttributeNotFoundException e) { + } catch (TimeRangeException | StateSystemDisposedException | IOException e) { fail(e.getMessage()); } } diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java index fa3ca8ed31..e3c92bd7c4 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java @@ -33,7 +33,6 @@ import java.util.List; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; /** * The Attribute Tree is the /proc-like filesystem used to organize attributes. @@ -160,10 +159,10 @@ public final class AttributeTree { * @return The quark of the specified attribute, or * {@link ITmfStateSystem#INVALID_ATTRIBUTE} if that attribute does * not exist. + * @throws IndexOutOfBoundsException + * If the starting node quark is out of range */ public synchronized int getQuarkDontAdd(int startingNodeQuark, String... subPath) { - assert (startingNodeQuark >= ROOT_ATTRIBUTE); - Attribute prevNode; /* If subPath is empty, simply return the starting quark */ @@ -193,12 +192,12 @@ public final class AttributeTree { * @param subPath * The path to the attribute, relative to the starting node. * @return The quark of the attribute represented by the path + * @throws IndexOutOfBoundsException + * If the starting node quark is out of range */ public synchronized int getQuarkAndAdd(int startingNodeQuark, String... subPath) { // FIXME synchronized here is probably quite costly... maybe only locking // the "for" would be enough? - assert (subPath != null && subPath.length > 0); - assert (startingNodeQuark >= ROOT_ATTRIBUTE); Attribute nextNode = null; Attribute prevNode; @@ -246,20 +245,13 @@ public final class AttributeTree { * one level deep will be returned. If true, all descendants will * be returned (depth-first search) * @return The list of quarks representing the children attributes - * @throws AttributeNotFoundException - * If 'attributeQuark' is invalid, or if there is no attribute - * associated to it. + * @throws IndexOutOfBoundsException + * If the attribute quark is out of range */ - public synchronized @NonNull List<@NonNull Integer> getSubAttributes(int attributeQuark, boolean recursive) - throws AttributeNotFoundException { + public synchronized @NonNull List<@NonNull Integer> getSubAttributes(int attributeQuark, boolean recursive) { List<@NonNull Integer> listOfChildren = new ArrayList<>(); Attribute startingAttribute; - /* Check if the quark is valid */ - if (attributeQuark < ROOT_ATTRIBUTE || attributeQuark >= attributeList.size()) { - throw new AttributeNotFoundException(ss.getSSID() + " Quark:" + attributeQuark); //$NON-NLS-1$ - } - /* Set up the node from which we'll start the search */ if (attributeQuark == ROOT_ATTRIBUTE) { startingAttribute = attributeTreeRoot; @@ -281,6 +273,8 @@ public final class AttributeTree { * The quark of the attribute * @return Quark of the parent attribute or * {@link ITmfStateSystem#ROOT_ATTRIBUTE} for the root attribute + * @throws IndexOutOfBoundsException + * If the quark is out of range */ public synchronized int getParentAttributeQuark(int quark) { if (quark == ROOT_ATTRIBUTE) { @@ -305,6 +299,8 @@ public final class AttributeTree { * @param quark * The quark of the attribute * @return The (base) name of the attribute + * @throws IndexOutOfBoundsException + * If the quark is out of range */ public synchronized @NonNull String getAttributeName(int quark) { return attributeList.get(quark).getName(); @@ -316,6 +312,8 @@ public final class AttributeTree { * @param quark * The quark of the attribute * @return The full path name of the attribute + * @throws IndexOutOfBoundsException + * If the quark is out of range */ public synchronized @NonNull String getFullAttributeName(int quark) { return attributeList.get(quark).getFullAttributeName(); @@ -328,6 +326,8 @@ public final class AttributeTree { * @param quark * The quark of the attribute * @return The path elements of the full path + * @throws IndexOutOfBoundsException + * If the quark is out of range */ public synchronized String @NonNull [] getFullAttributePathArray(int quark) { return attributeList.get(quark).getFullAttribute(); diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java index 3e992d4834..4213a597c7 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java @@ -280,14 +280,12 @@ public class StateSystem implements ITmfStateSystemBuilder { } @Override - public List<@NonNull Integer> getSubAttributes(int quark, boolean recursive) - throws AttributeNotFoundException { + public List<@NonNull Integer> getSubAttributes(int quark, boolean recursive) { return getAttributeTree().getSubAttributes(quark, recursive); } @Override - public List<@NonNull Integer> getSubAttributes(int quark, boolean recursive, String pattern) - throws AttributeNotFoundException { + public List<@NonNull Integer> getSubAttributes(int quark, boolean recursive, String pattern) { List all = getSubAttributes(quark, recursive); List<@NonNull Integer> ret = new LinkedList<>(); for (Integer attQuark : all) { @@ -321,40 +319,35 @@ public class StateSystem implements ITmfStateSystemBuilder { } private void getQuarks(Builder<@NonNull Integer> builder, int quark, List pattern) { - try { - String element = pattern.get(0); - if (element == null) { - return; + String element = pattern.get(0); + if (element == null) { + return; + } + List remainder = pattern.subList(1, pattern.size()); + if (remainder.isEmpty()) { + if (element.equals(WILDCARD)) { + builder.addAll(getSubAttributes(quark, false)); + } else if (element.equals(PARENT)){ + builder.add(getParentAttributeQuark(quark)); + } else { + int subQuark = optQuarkRelative(quark, element); + if (subQuark != INVALID_ATTRIBUTE) { + builder.add(subQuark); + } } - List remainder = pattern.subList(1, pattern.size()); - if (remainder.isEmpty()) { - if (element.equals(WILDCARD)) { - builder.addAll(getSubAttributes(quark, false)); - } else if (element.equals(PARENT)){ - builder.add(getParentAttributeQuark(quark)); - } else { - int subQuark = optQuarkRelative(quark, element); - if (subQuark != INVALID_ATTRIBUTE) { - builder.add(subQuark); - } + } else { + if (element.equals(WILDCARD)) { + for (@NonNull Integer subquark : getSubAttributes(quark, false)) { + getQuarks(builder, subquark, remainder); } + } else if (element.equals(PARENT)){ + getQuarks(builder, getParentAttributeQuark(quark), remainder); } else { - if (element.equals(WILDCARD)) { - for (@NonNull Integer subquark : getSubAttributes(quark, false)) { - getQuarks(builder, subquark, remainder); - } - } else if (element.equals(PARENT)){ - getQuarks(builder, getParentAttributeQuark(quark), remainder); - } else { - int subQuark = optQuarkRelative(quark, element); - if (subQuark != INVALID_ATTRIBUTE) { - getQuarks(builder, subQuark, remainder); - } + int subQuark = optQuarkRelative(quark, element); + if (subQuark != INVALID_ATTRIBUTE) { + getQuarks(builder, subQuark, remainder); } } - } catch (AttributeNotFoundException e) { - /* The starting node quark is out of range */ - throw new IndexOutOfBoundsException(String.format("Index: %d, Size: %d", quark, getNbAttributes())); //$NON-NLS-1$ } } @@ -364,8 +357,7 @@ public class StateSystem implements ITmfStateSystemBuilder { @Override public void modifyAttribute(long t, ITmfStateValue value, int attributeQuark) - throws TimeRangeException, AttributeNotFoundException, - StateValueTypeException { + throws TimeRangeException, StateValueTypeException { if (value == null) { /* * TODO Replace with @NonNull parameter (will require fixing all the @@ -379,8 +371,7 @@ public class StateSystem implements ITmfStateSystemBuilder { @Deprecated @Override public void incrementAttribute(long t, int attributeQuark) - throws StateValueTypeException, TimeRangeException, - AttributeNotFoundException { + throws StateValueTypeException, TimeRangeException { ITmfStateValue stateValue = queryOngoingState(attributeQuark); int prevValue = 0; /* if the attribute was previously null, start counting at 0 */ @@ -393,8 +384,7 @@ public class StateSystem implements ITmfStateSystemBuilder { @Override public void pushAttribute(long t, ITmfStateValue value, int attributeQuark) - throws TimeRangeException, AttributeNotFoundException, - StateValueTypeException { + throws TimeRangeException, StateValueTypeException { int stackDepth; int subAttributeQuark; ITmfStateValue previousSV = transState.getOngoingStateValue(attributeQuark); @@ -419,7 +409,7 @@ public class StateSystem implements ITmfStateSystemBuilder { * out of control due to buggy insertions */ String message = " Stack limit reached, not pushing"; //$NON-NLS-1$ - throw new AttributeNotFoundException(getSSID() + " Quark:" + attributeQuark + message); //$NON-NLS-1$ + throw new IllegalStateException(getSSID() + " Quark:" + attributeQuark + message); //$NON-NLS-1$ } stackDepth++; @@ -431,8 +421,7 @@ public class StateSystem implements ITmfStateSystemBuilder { @Override public ITmfStateValue popAttribute(long t, int attributeQuark) - throws AttributeNotFoundException, TimeRangeException, - StateValueTypeException { + throws TimeRangeException, StateValueTypeException { /* These are the state values of the stack-attribute itself */ ITmfStateValue previousSV = transState.getOngoingStateValue(attributeQuark); @@ -461,7 +450,13 @@ public class StateSystem implements ITmfStateSystemBuilder { } /* The attribute should already exist at this point */ - int subAttributeQuark = getQuarkRelative(attributeQuark, String.valueOf(stackDepth)); + int subAttributeQuark; + try { + subAttributeQuark = getQuarkRelative(attributeQuark, String.valueOf(stackDepth)); + } catch (AttributeNotFoundException e) { + String message = " Stack attribute missing sub-attribute for depth:" + stackDepth; //$NON-NLS-1$ + throw new IllegalStateException(getSSID() + " Quark:" + attributeQuark + message); //$NON-NLS-1$ + } ITmfStateValue poppedValue = queryOngoingState(subAttributeQuark); /* Update the state value of the stack-attribute */ @@ -482,11 +477,7 @@ public class StateSystem implements ITmfStateSystemBuilder { @Override public void removeAttribute(long t, int attributeQuark) - throws TimeRangeException, AttributeNotFoundException { - if (attributeQuark < 0) { - throw new IllegalArgumentException(); - } - + throws TimeRangeException { /* * Nullify our children first, recursively. We pass 'false' because we * handle the recursion ourselves. @@ -516,20 +507,17 @@ public class StateSystem implements ITmfStateSystemBuilder { //-------------------------------------------------------------------------- @Override - public ITmfStateValue queryOngoingState(int attributeQuark) - throws AttributeNotFoundException { + public ITmfStateValue queryOngoingState(int attributeQuark) { return transState.getOngoingStateValue(attributeQuark); } @Override - public long getOngoingStartTime(int attribute) - throws AttributeNotFoundException { + public long getOngoingStartTime(int attribute) { return transState.getOngoingStartTime(attribute); } @Override - public void updateOngoingState(ITmfStateValue newValue, int attributeQuark) - throws AttributeNotFoundException { + public void updateOngoingState(ITmfStateValue newValue, int attributeQuark) { transState.changeOngoingStateValue(attributeQuark, newValue); } @@ -588,8 +576,7 @@ public class StateSystem implements ITmfStateSystemBuilder { @Override public ITmfStateInterval querySingleState(long t, int attributeQuark) - throws AttributeNotFoundException, TimeRangeException, - StateSystemDisposedException { + throws TimeRangeException, StateSystemDisposedException { if (isDisposed) { throw new StateSystemDisposedException(); } diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/TransientState.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/TransientState.java index dfa22f0ebc..6a013366bd 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/TransientState.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/TransientState.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2015 Ericsson + * Copyright (c) 2012, 2016 Ericsson * Copyright (c) 2010, 2011 École Polytechnique de Montréal * Copyright (c) 2010, 2011 Alexandre Montplaisir * @@ -23,7 +23,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; @@ -91,13 +90,12 @@ public class TransientState { * @param quark * The quark of the attribute to look for * @return The corresponding state value - * @throws AttributeNotFoundException - * If the quark is invalid + * @throws IndexOutOfBoundsException + * If the quark is out of range */ - public ITmfStateValue getOngoingStateValue(int quark) throws AttributeNotFoundException { + public ITmfStateValue getOngoingStateValue(int quark) { fRWLock.readLock().lock(); try { - checkValidAttribute(quark); return fOngoingStateInfo.get(quark); } finally { fRWLock.readLock().unlock(); @@ -110,13 +108,12 @@ public class TransientState { * @param quark * The quark of the attribute to look for * @return The start time of the current state for this attribute - * @throws AttributeNotFoundException - * If the quark is invalid + * @throws IndexOutOfBoundsException + * If the quark is out of range */ - public long getOngoingStartTime(int quark) throws AttributeNotFoundException { + public long getOngoingStartTime(int quark) { fRWLock.readLock().lock(); try { - checkValidAttribute(quark); return fOngoingStateStartTimes.get(quark); } finally { fRWLock.readLock().unlock(); @@ -131,14 +128,12 @@ public class TransientState { * The quark of the attribute to modify * @param newValue * The state value the attribute should have - * @throws AttributeNotFoundException - * If the quark is invalid + * @throws IndexOutOfBoundsException + * If the quark is out of range */ - public void changeOngoingStateValue(int quark, ITmfStateValue newValue) - throws AttributeNotFoundException { + public void changeOngoingStateValue(int quark, ITmfStateValue newValue) { fRWLock.writeLock().lock(); try { - checkValidAttribute(quark); fOngoingStateInfo.set(quark, newValue); } finally { fRWLock.writeLock().unlock(); @@ -153,13 +148,12 @@ public class TransientState { * The quark of the attribute * @return An interval representing the current state (but whose end time is * the current one, and probably not the "final" one) - * @throws AttributeNotFoundException - * If the quark is invalid + * @throws IndexOutOfBoundsException + * If the quark is out of range */ - public ITmfStateInterval getOngoingInterval(int quark) throws AttributeNotFoundException { + public ITmfStateInterval getOngoingInterval(int quark) { fRWLock.readLock().lock(); try { - checkValidAttribute(quark); return new TmfStateInterval(fOngoingStateStartTimes.get(quark), fLatestTime, quark, fOngoingStateInfo.get(quark)); } finally { @@ -178,29 +172,22 @@ public class TransientState { * The quark of the attribute to look for * @return The corresponding TmfStateInterval object if we could find it in * this transient state, or null if we couldn't. + * @throws IndexOutOfBoundsException + * If the quark is out of range */ public @Nullable ITmfStateInterval getIntervalAt(long time, int quark) { fRWLock.readLock().lock(); try { - checkValidAttribute(quark); if (!isActive() || time < fOngoingStateStartTimes.get(quark)) { return null; } return new TmfStateInterval(fOngoingStateStartTimes.get(quark), fLatestTime, quark, fOngoingStateInfo.get(quark)); - } catch (AttributeNotFoundException e) { - return null; } finally { fRWLock.readLock().unlock(); } } - private void checkValidAttribute(int quark) throws AttributeNotFoundException { - if (quark > fOngoingStateInfo.size() - 1 || quark < 0) { - throw new AttributeNotFoundException(fBackend.getSSID() + " Quark:" + quark); //$NON-NLS-1$ - } - } - /** * More advanced version of {@link #changeOngoingStateValue}. Replaces the * complete ongoingStateInfo in one go, and updates the @@ -265,14 +252,14 @@ public class TransientState { * The quark of the attribute that is being modified * @throws TimeRangeException * If 'eventTime' is invalid - * @throws AttributeNotFoundException - * IF 'quark' does not represent an existing attribute + * @throws IndexOutOfBoundsException + * If the quark is out of range * @throws StateValueTypeException * If the state value to be inserted is of a different type of * what was inserted so far for this attribute. */ public void processStateChange(long eventTime, ITmfStateValue value, int quark) - throws TimeRangeException, AttributeNotFoundException, StateValueTypeException { + throws TimeRangeException, StateValueTypeException { if (!this.fIsActive) { return; } @@ -280,7 +267,6 @@ public class TransientState { fRWLock.writeLock().lock(); try { Type expectedSvType = fStateValueTypes.get(quark); - checkValidAttribute(quark); /* * Make sure the state value type we're inserting is the same as the diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/InMemoryBackend.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/InMemoryBackend.java index 08d87eca44..40e86b027a 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/InMemoryBackend.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/InMemoryBackend.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2015 Ericsson + * Copyright (c) 2013, 2016 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -26,7 +26,6 @@ import java.util.TreeSet; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; import org.eclipse.tracecompass.statesystem.core.interval.TmfStateInterval; @@ -159,7 +158,7 @@ public class InMemoryBackend implements IStateHistoryBackend { @Override public ITmfStateInterval doSingularQuery(long t, int attributeQuark) - throws TimeRangeException, AttributeNotFoundException { + throws TimeRangeException { if (!checkValidTime(t)) { throw new TimeRangeException(ssid + " Time:" + t + ", Start:" + startTime + ", End:" + latestTime); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } @@ -182,7 +181,7 @@ public class InMemoryBackend implements IStateHistoryBackend { } } } - throw new AttributeNotFoundException(ssid + " Quark:" + attributeQuark); //$NON-NLS-1$ + return null; } private boolean checkValidTime(long t) { diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java index d5b4385b72..4df70c1619 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java @@ -223,11 +223,10 @@ public interface ITmfStateSystem { * True if you want all recursive sub-attributes, false if you * only want the first level. * @return A List of integers, matching the quarks of the sub-attributes. - * @throws AttributeNotFoundException - * If the quark was not existing or invalid. + * @throws IndexOutOfBoundsException + * If the quark is out of range */ - @NonNull List<@NonNull Integer> getSubAttributes(int quark, boolean recursive) - throws AttributeNotFoundException; + @NonNull List<@NonNull Integer> getSubAttributes(int quark, boolean recursive); /** * Return the sub-attributes of the target attribute, as a List of quarks, @@ -246,11 +245,10 @@ public interface ITmfStateSystem { * @return A List of integers, matching the quarks of the sub-attributes * that match the regex. An empty list is returned if there is no * matching attribute. - * @throws AttributeNotFoundException - * If the 'quark' was not existing or invalid. + * @throws IndexOutOfBoundsException + * If the quark is out of range */ - @NonNull List<@NonNull Integer> getSubAttributes(int quark, boolean recursive, String pattern) - throws AttributeNotFoundException; + @NonNull List<@NonNull Integer> getSubAttributes(int quark, boolean recursive, String pattern); /** * Batch quark-retrieving method. This method allows you to specify a path @@ -371,24 +369,22 @@ public interface ITmfStateSystem { * @param attributeQuark * For which attribute we want the current state * @return The State value that's "current" for this attribute - * @throws AttributeNotFoundException - * If the requested attribute is invalid + * @throws IndexOutOfBoundsException + * If the attribute quark is out of range */ - @NonNull ITmfStateValue queryOngoingState(int attributeQuark) - throws AttributeNotFoundException; + @NonNull ITmfStateValue queryOngoingState(int attributeQuark); /** * Get the start time of the current ongoing state, for the specified * attribute. * - * @param attribute + * @param attributeQuark * Quark of the attribute * @return The current start time of the ongoing state - * @throws AttributeNotFoundException - * If the attribute is invalid + * @throws IndexOutOfBoundsException + * If the attribute quark is out of range */ - long getOngoingStartTime(int attribute) - throws AttributeNotFoundException; + long getOngoingStartTime(int attributeQuark); /** * Load the complete state information at time 't' into the returned List. @@ -430,11 +426,11 @@ public interface ITmfStateSystem { * @return The StateInterval representing the state * @throws TimeRangeException * If 't' is invalid - * @throws AttributeNotFoundException - * If the requested quark does not exist in the model + * @throws IndexOutOfBoundsException + * If the attribute quark is out of range * @throws StateSystemDisposedException * If the query is sent after the state system has been disposed */ @NonNull ITmfStateInterval querySingleState(long t, int attributeQuark) - throws AttributeNotFoundException, StateSystemDisposedException; + throws StateSystemDisposedException; } \ No newline at end of file diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystemBuilder.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystemBuilder.java index 9cd6dbf8d9..881ddf0300 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystemBuilder.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystemBuilder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2014 Ericsson + * Copyright (c) 2012, 2016 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -13,7 +13,6 @@ package org.eclipse.tracecompass.statesystem.core; import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; @@ -79,6 +78,8 @@ public interface ITmfStateSystemBuilder extends ITmfStateSystem { * @param subPath * "Rest" of the path to get to the final attribute * @return The matching quark, either if it's new of just got created. + * @throws IndexOutOfBoundsException + * If the starting node quark is out of range */ int getQuarkRelativeAndAdd(int startingNodeQuark, String... subPath); @@ -102,11 +103,10 @@ public interface ITmfStateSystemBuilder extends ITmfStateSystem { * The new value that will overwrite the "current" one. * @param attributeQuark * For which attribute in the system - * @throws AttributeNotFoundException - * If the requested attribute is invalid + * @throws IndexOutOfBoundsException + * If the attribute quark is out of range */ - void updateOngoingState(@NonNull ITmfStateValue newValue, int attributeQuark) - throws AttributeNotFoundException; + void updateOngoingState(@NonNull ITmfStateValue newValue, int attributeQuark); /** * Basic attribute modification method, we simply specify a new value, for a @@ -121,14 +121,14 @@ public interface ITmfStateSystemBuilder extends ITmfStateSystem { * want to modify * @throws TimeRangeException * If the requested time is outside of the trace's range - * @throws AttributeNotFoundException - * If the requested attribute quark is invalid + * @throws IndexOutOfBoundsException + * If the attribute quark is out of range * @throws StateValueTypeException * If the inserted state value's type does not match what is * already assigned to this attribute. */ void modifyAttribute(long t, ITmfStateValue value, int attributeQuark) - throws AttributeNotFoundException, StateValueTypeException; + throws StateValueTypeException; /** * Increment attribute method. Reads the current value of a given integer @@ -144,15 +144,15 @@ public interface ITmfStateSystemBuilder extends ITmfStateSystem { * If the attribute already exists but is not of type Integer * @throws TimeRangeException * If the given timestamp is invalid - * @throws AttributeNotFoundException - * If the quark is invalid + * @throws IndexOutOfBoundsException + * If the attribute quark is out of range * @deprecated Use * {@link StateSystemBuilderUtils#incrementAttributeInt(ITmfStateSystemBuilder, long, int, int)} * instead */ @Deprecated void incrementAttribute(long t, int attributeQuark) - throws AttributeNotFoundException, StateValueTypeException; + throws StateValueTypeException; /** * "Push" helper method. This uses the given integer attribute as a stack: @@ -170,14 +170,14 @@ public interface ITmfStateSystemBuilder extends ITmfStateSystem { * will be created (with depth = 1) * @throws TimeRangeException * If the requested timestamp is invalid - * @throws AttributeNotFoundException - * If the attribute is invalid + * @throws IndexOutOfBoundsException + * If the attribute quark is out of range * @throws StateValueTypeException * If the attribute 'attributeQuark' already exists, but is not * of integer type. */ void pushAttribute(long t, ITmfStateValue value, int attributeQuark) - throws AttributeNotFoundException, StateValueTypeException; + throws StateValueTypeException; /** * Antagonist of the pushAttribute(), pops the top-most attribute on the @@ -191,8 +191,8 @@ public interface ITmfStateSystemBuilder extends ITmfStateSystem { * Quark of the stack-attribute to pop * @return The state value that was popped, or 'null' if nothing was * actually removed from the stack. - * @throws AttributeNotFoundException - * If the attribute is invalid + * @throws IndexOutOfBoundsException + * If the attribute quark is out of range * @throws TimeRangeException * If the timestamp is invalid * @throws StateValueTypeException @@ -200,7 +200,7 @@ public interface ITmfStateSystemBuilder extends ITmfStateSystem { * type is invalid (not an integer) */ ITmfStateValue popAttribute(long t, int attributeQuark) - throws AttributeNotFoundException, StateValueTypeException; + throws StateValueTypeException; /** * Remove attribute method. Similar to the above modify- methods, with value @@ -213,11 +213,10 @@ public interface ITmfStateSystemBuilder extends ITmfStateSystem { * Attribute to remove * @throws TimeRangeException * If the timestamp is invalid - * @throws AttributeNotFoundException - * If the quark is invalid + * @throws IndexOutOfBoundsException + * If the attribute quark is out of range */ - void removeAttribute(long t, int attributeQuark) - throws AttributeNotFoundException; + void removeAttribute(long t, int attributeQuark); /** * Method to close off the History Provider. This happens for example when diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/StateSystemUtils.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/StateSystemUtils.java index a3f8d70e99..82ad0baa95 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/StateSystemUtils.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/StateSystemUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2015 École Polytechnique de Montréal + * Copyright (c) 2014, 2016 École Polytechnique de Montréal * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -273,7 +273,7 @@ public final class StateSystemUtils { } current = currentInterval.getEndTime() + 1; } - } catch (AttributeNotFoundException | StateSystemDisposedException | TimeRangeException e) { + } catch (StateSystemDisposedException | TimeRangeException e) { /* Nothing to do */ } return null; diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/backend/IStateHistoryBackend.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/backend/IStateHistoryBackend.java index 093e781dc3..6e71574be6 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/backend/IStateHistoryBackend.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/backend/IStateHistoryBackend.java @@ -19,7 +19,6 @@ import java.util.List; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; @@ -173,17 +172,15 @@ public interface IStateHistoryBackend { * The target timestamp of the query. * @param attributeQuark * The single attribute for which you want the state interval - * @return The state interval matching this timestamp/attribute pair + * @return The state interval matching this timestamp/attribute pair, or + * null if it was not found * @throws TimeRangeException * If the timestamp was invalid - * @throws AttributeNotFoundException - * If the quark was invalid * @throws StateSystemDisposedException * If the state system is disposed while a request is ongoing. */ ITmfStateInterval doSingularQuery(long t, int attributeQuark) - throws TimeRangeException, AttributeNotFoundException, - StateSystemDisposedException; + throws TimeRangeException, StateSystemDisposedException; /** * Debug method to print the contents of the history backend. diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/model/TmfXmlScenarioHistoryBuilder.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/model/TmfXmlScenarioHistoryBuilder.java index 026d573ac1..e4e678dd87 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/model/TmfXmlScenarioHistoryBuilder.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/model/TmfXmlScenarioHistoryBuilder.java @@ -17,7 +17,6 @@ import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.Activator; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.IXmlStateSystemContainer; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.stateprovider.TmfXmlStrings; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; @@ -97,7 +96,7 @@ public class TmfXmlScenarioHistoryBuilder { int attributeQuark = getQuarkRelativeAndAdd(ss, info.getQuark(), START_TIME); ITmfStateInterval state = ss.querySingleState(ts, attributeQuark); return state.getStartTime(); - } catch (AttributeNotFoundException | StateSystemDisposedException e) { + } catch (StateSystemDisposedException e) { Activator.logError("failed to get the start time of the scenario", e); //$NON-NLS-1$ } return -1L; @@ -123,7 +122,7 @@ public class TmfXmlScenarioHistoryBuilder { try { int attributeQuark = getQuarkRelativeAndAdd(ss, info.getQuark(), TmfXmlStrings.STORED_FIELDS, attributeName); ss.modifyAttribute(ts, value, attributeQuark); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { Activator.logError("failed to save the stored field " + attributeName, e); //$NON-NLS-1$ } } @@ -147,7 +146,7 @@ public class TmfXmlScenarioHistoryBuilder { try { int attributeQuark = getQuarkRelativeAndAdd(ss, info.getQuark(), TmfXmlStrings.STORED_FIELDS, attributeName); ss.modifyAttribute(ts, value, attributeQuark); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { Activator.logError("failed to clear the stored fields", e); //$NON-NLS-1$ } } @@ -173,7 +172,7 @@ public class TmfXmlScenarioHistoryBuilder { try { int attributeQuark = getQuarkRelativeAndAdd(ss, info.getQuark(), TmfXmlStrings.STORED_FIELDS, attributeName); state = ss.querySingleState(ts, attributeQuark); - } catch (AttributeNotFoundException | StateSystemDisposedException e) { + } catch (StateSystemDisposedException e) { Activator.logError("failed to get the value of the stored field " + attributeName, e); //$NON-NLS-1$ } return (state != null) ? NonNullUtils.checkNotNull(state.getStateValue()) : TmfStateValue.nullValue(); @@ -250,7 +249,7 @@ public class TmfXmlScenarioHistoryBuilder { int attributeQuark = getQuarkRelativeAndAdd(ss, info.getQuark(), TmfXmlStrings.STATE, stateName, START_TIME); ITmfStateInterval state = ss.querySingleState(ts, attributeQuark); return state.getStartTime(); - } catch (AttributeNotFoundException | StateSystemDisposedException e) { + } catch (StateSystemDisposedException e) { Activator.logError("failed the start time of the state " + stateName, e); //$NON-NLS-1$ } return -1l; @@ -339,7 +338,7 @@ public class TmfXmlScenarioHistoryBuilder { break; } ss.modifyAttribute(ts, value, info.getStatusQuark()); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { Activator.logError("failed to update scenario status"); //$NON-NLS-1$ } } @@ -362,7 +361,7 @@ public class TmfXmlScenarioHistoryBuilder { ITmfStateValue value = TmfStateValue.newValueString(info.getActiveState()); int attributeQuark = ss.getQuarkRelativeAndAdd(info.getQuark(), TmfXmlStrings.STATE); ss.modifyAttribute(ts, value, attributeQuark); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { Activator.logError("failed to update scenario state"); //$NON-NLS-1$ } } @@ -388,7 +387,7 @@ public class TmfXmlScenarioHistoryBuilder { ITmfStateValue value = TmfStateValue.newValueLong(ts); ss.modifyAttribute(ts, value, attributeQuark); } - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { Activator.logError("failed to update the start time of the state"); //$NON-NLS-1$ } } @@ -412,7 +411,7 @@ public class TmfXmlScenarioHistoryBuilder { ITmfStateValue value = TmfStateValue.newValueLong(ts); int attributeQuark = ss.getQuarkRelativeAndAdd(info.getQuark(), START_TIME); ss.modifyAttribute(ts, value, attributeQuark); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { Activator.logError("failed to update the start time of the scenario"); //$NON-NLS-1$ } } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java index 106e85e0f1..aa9f8fe7da 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java @@ -336,43 +336,40 @@ public class XmlTimeGraphView extends AbstractTimeGraphView { int i = 0; List quarks = Collections.singletonList(baseQuark); - try { - while (i < paths.length) { - List subQuarks = new LinkedList<>(); - /* Replace * by .* to have a regex string */ - String name = paths[i].replaceAll("\\*", ".*"); //$NON-NLS-1$ //$NON-NLS-2$ - for (int relativeQuark : quarks) { - for (int quark : ss.getSubAttributes(relativeQuark, false, name)) { - subQuarks.add(quark); - } + while (i < paths.length) { + List subQuarks = new LinkedList<>(); + /* Replace * by .* to have a regex string */ + String name = paths[i].replaceAll("\\*", ".*"); //$NON-NLS-1$ //$NON-NLS-2$ + for (int relativeQuark : quarks) { + for (int quark : ss.getSubAttributes(relativeQuark, false, name)) { + subQuarks.add(quark); } - quarks = subQuarks; - i++; } + quarks = subQuarks; + i++; + } - /* Process each quark */ - XmlEntry currentEntry = parentEntry; - Element displayElement = null; - Map entryMap = new HashMap<>(); - if (!displayElements.isEmpty()) { - displayElement = displayElements.get(0); - } - for (int quark : quarks) { - currentEntry = parentEntry; - /* Process the current entry, if specified */ - if (displayElement != null) { - currentEntry = processEntry(entryElement, displayElement, parentEntry, quark, ss); - entryMap.put(currentEntry.getId(), currentEntry); - } - /* Process the children entry of this entry */ - for (Element subEntryEl : entryElements) { - buildEntry(subEntryEl, currentEntry, quark); - } + /* Process each quark */ + XmlEntry currentEntry = parentEntry; + Element displayElement = null; + Map entryMap = new HashMap<>(); + if (!displayElements.isEmpty()) { + displayElement = displayElements.get(0); + } + for (int quark : quarks) { + currentEntry = parentEntry; + /* Process the current entry, if specified */ + if (displayElement != null) { + currentEntry = processEntry(entryElement, displayElement, parentEntry, quark, ss); + entryMap.put(currentEntry.getId(), currentEntry); } - if (!entryMap.isEmpty()) { - buildTree(entryMap, parentEntry); + /* Process the children entry of this entry */ + for (Element subEntryEl : entryElements) { + buildEntry(subEntryEl, currentEntry, quark); } - } catch (AttributeNotFoundException e) { + } + if (!entryMap.isEmpty()) { + buildTree(entryMap, parentEntry); } } @@ -417,7 +414,7 @@ public class XmlTimeGraphView extends AbstractTimeGraphView { } entryEnd = oneInterval.getEndTime(); - } catch (AttributeNotFoundException | StateSystemDisposedException e) { + } catch (StateSystemDisposedException e) { } return new XmlEntry(quark, displayQuark, parentEntry.getTrace(), ss.getAttributeName(quark), diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java index 8be63d53f0..31c7cae0af 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2015 École Polytechnique de Montréal and others. + * Copyright (c) 2014, 2016 École Polytechnique de Montréal and others. * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -37,7 +37,6 @@ import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.Activator; import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings; import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlViewInfo; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; @@ -190,22 +189,14 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer { String[] paths = fPath.split(SPLIT_STRING); List quarks = Collections.singletonList(IXmlStateSystemContainer.ROOT_QUARK); - try { - for (String path : paths) { - List subQuarks = new LinkedList<>(); - /* Replace * by .* to have a regex string */ - String name = WILDCARD_PATTERN.matcher(path).replaceAll(".*"); //$NON-NLS-1$ - for (int relativeQuark : quarks) { - subQuarks.addAll(fStateSystem.getSubAttributes(relativeQuark, false, name)); - } - quarks = subQuarks; + for (String path : paths) { + List subQuarks = new LinkedList<>(); + /* Replace * by .* to have a regex string */ + String name = WILDCARD_PATTERN.matcher(path).replaceAll(".*"); //$NON-NLS-1$ + for (int relativeQuark : quarks) { + subQuarks.addAll(fStateSystem.getSubAttributes(relativeQuark, false, name)); } - } catch (AttributeNotFoundException e) { - /* - * We get all attributes from the state system itself, this - * should not happen. - */ - throw new IllegalStateException(); + quarks = subQuarks; } return quarks; } @@ -322,7 +313,7 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer { setSeries(data.getSeriesName(), data.getYValues()); } updateDisplay(); - } catch (AttributeNotFoundException | StateValueTypeException e) { + } catch (StateValueTypeException e) { Activator.logError("Error updating the data of XML XY view", e); //$NON-NLS-1$ } catch (StateSystemDisposedException e) { return; diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/AttributePoolTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/AttributePoolTest.java index 39bda59fb2..a51c30cee6 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/AttributePoolTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/AttributePoolTest.java @@ -20,7 +20,6 @@ import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; import org.eclipse.tracecompass.statesystem.core.StateSystemFactory; import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend; import org.eclipse.tracecompass.statesystem.core.backend.StateHistoryBackendFactory; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; @@ -108,21 +107,13 @@ public class AttributePoolTest { assertEquals("1", fStateSystem.getAttributeName(available2)); /* Modify them */ - try { - fStateSystem.modifyAttribute(START_TIME + 10, VALUE, available); - fStateSystem.modifyAttribute(START_TIME + 10, VALUE, available2); - } catch (StateValueTypeException | AttributeNotFoundException e) { - fail(e.getMessage()); - } + fStateSystem.modifyAttribute(START_TIME + 10, VALUE, available); + fStateSystem.modifyAttribute(START_TIME + 10, VALUE, available2); /* Recycle one and make sure it is set to null */ pool.recycle(available, START_TIME + 20); - try { - ITmfStateValue value = fStateSystem.queryOngoingState(available); - assertEquals(TmfStateValue.nullValue(), value); - } catch (AttributeNotFoundException e) { - fail(e.getMessage()); - } + ITmfStateValue value = fStateSystem.queryOngoingState(available); + assertEquals(TmfStateValue.nullValue(), value); /* Get a new one and make sure it is reusing the one just recycled */ Integer available3 = pool.getAvailable(); @@ -176,7 +167,7 @@ public class AttributePoolTest { assertEquals(TmfStateValue.nullValue(), value); value = fStateSystem.queryOngoingState(child2); assertEquals(TmfStateValue.nullValue(), value); - } catch (StateValueTypeException | AttributeNotFoundException e) { + } catch (StateValueTypeException e) { fail(e.getMessage()); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java index 83c1150b80..02552cc583 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2015 Ericsson + * Copyright (c) 2013, 2016 Ericsson * * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which @@ -19,7 +19,6 @@ import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.core.Activator; import org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap.AbstractTmfMipmapStateProvider; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; @@ -48,7 +47,6 @@ class TmfMipmapStateProviderStub extends AbstractTmfMipmapStateProvider { private ITmfStateValue.Type type; private static final @NonNull String MIPMAP_ID = "MIPMAP_ID"; //$NON-NLS-1$ - private final String ERROR_ATTRIBUTE_NOT_FOUND = "Error : Impossible to find the attribute"; //$NON-NLS-1$ private final String ERROR_INVALID_STATE_VALUE = "Error : Invalid state value"; //$NON-NLS-1$ private final String ERROR_INVALID_TIMESTAMP = "Error : Invalid timestamp"; //$NON-NLS-1$ @@ -76,8 +74,6 @@ class TmfMipmapStateProviderStub extends AbstractTmfMipmapStateProvider { modifyMipmapAttribute(ts, value, quark, MIN | MAX | AVG, resolution); } catch (TimeRangeException e) { Activator.logError(ERROR_INVALID_TIMESTAMP, e); - } catch (AttributeNotFoundException e) { - Activator.logError(ERROR_ATTRIBUTE_NOT_FOUND, e); } catch (StateValueTypeException e) { Activator.logError(ERROR_INVALID_STATE_VALUE, e); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/analysis/TestExperimentAnalysis.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/analysis/TestExperimentAnalysis.java index ec7c344102..78efff52fc 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/analysis/TestExperimentAnalysis.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/analysis/TestExperimentAnalysis.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2015 École Polytechnique de Montréal + * Copyright (c) 2014, 2016 École Polytechnique de Montréal * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -19,7 +19,6 @@ import java.util.Set; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; @@ -88,7 +87,7 @@ public class TestExperimentAnalysis extends TmfStateSystemAnalysisModule { int quarkId = ss.getQuarkAbsoluteAndAdd(TRACE_QUARK_NAME); ss.modifyAttribute(event.getTimestamp().getValue(), TmfStateValue.newValueInt(++fCount), quarkId); fTraces.add(event.getTrace()); - } catch (TimeRangeException | AttributeNotFoundException | StateValueTypeException e) { + } catch (TimeRangeException | StateValueTypeException e) { } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/analysis/TestStateSystemProvider.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/analysis/TestStateSystemProvider.java index bfc692ac6d..72fb9db575 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/analysis/TestStateSystemProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/analysis/TestStateSystemProvider.java @@ -18,7 +18,6 @@ import java.util.concurrent.locks.ReentrantLock; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; @@ -63,7 +62,7 @@ public class TestStateSystemProvider extends AbstractTmfStateProvider { int quarkId = ss.getQuarkAbsoluteAndAdd("String"); int quark = ss.getQuarkRelativeAndAdd(quarkId, fString); ss.modifyAttribute(event.getTimestamp().getValue(), TmfStateValue.newValueInt(fCount++), quark); - } catch (TimeRangeException | AttributeNotFoundException | StateValueTypeException e) { + } catch (TimeRangeException | StateValueTypeException e) { } } @@ -114,8 +113,6 @@ public class TestStateSystemProvider extends AbstractTmfStateProvider { sfHandler.eventHandle(ss, event); } - - @Override public void processEvent(@NonNull ITmfEvent event) { fLock.lock(); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java index 472ba6fc40..89414feeff 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2015 Ericsson + * Copyright (c) 2013, 2016 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 @@ -28,7 +28,6 @@ import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; @@ -255,18 +254,13 @@ public class PartialHistoryBackend implements IStateHistoryBackend { * looking for. However, the method expects a List of *state intervals*, * not state values, so we'll create intervals with a dummy end time. */ - try { - for (int i = 0; i < currentStateInfo.size(); i++) { - long start = 0; - start = ((ITmfStateSystem) fPartialSS).getOngoingStartTime(i); - ITmfStateValue val = ((ITmfStateSystem) fPartialSS).queryOngoingState(i); + for (int i = 0; i < currentStateInfo.size(); i++) { + long start = 0; + start = ((ITmfStateSystem) fPartialSS).getOngoingStartTime(i); + ITmfStateValue val = ((ITmfStateSystem) fPartialSS).queryOngoingState(i); - ITmfStateInterval interval = new TmfStateInterval(start, t, i, checkNotNull(val)); - currentStateInfo.set(i, interval); - } - } catch (AttributeNotFoundException e) { - /* Should not happen, we iterate over existing values. */ - e.printStackTrace(); + ITmfStateInterval interval = new TmfStateInterval(start, t, i, checkNotNull(val)); + currentStateInfo.set(i, interval); } fPartialSS.releaseQueryLock(); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/AbstractTmfMipmapStateProvider.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/AbstractTmfMipmapStateProvider.java index ec942ba703..0b2e42d6eb 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/AbstractTmfMipmapStateProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/AbstractTmfMipmapStateProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2015 Ericsson + * Copyright (c) 2013, 2016 Ericsson * * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which @@ -23,7 +23,6 @@ import java.util.Set; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.core.Activator; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; @@ -135,8 +134,6 @@ public abstract class AbstractTmfMipmapStateProvider extends AbstractTmfStatePro * The mipmap resolution (must be greater than 1) * @throws TimeRangeException * If the requested time is outside of the trace's range - * @throws AttributeNotFoundException - * If the requested attribute quark is invalid * @throws StateValueTypeException * If the inserted state value's type does not match what is * already assigned to this attribute. @@ -145,7 +142,7 @@ public abstract class AbstractTmfMipmapStateProvider extends AbstractTmfStatePro * @see #AVG */ public void modifyMipmapAttribute(long ts, ITmfStateValue value, int baseQuark, int mipmapFeatureBits, int resolution) - throws TimeRangeException, AttributeNotFoundException, StateValueTypeException { + throws TimeRangeException, StateValueTypeException { ITmfStateSystemBuilder ss = checkNotNull(getStateSystemBuilder()); ss.modifyAttribute(ts, value, baseQuark); if (value.getType() == Type.LONG || value.getType() == Type.INTEGER || value.getType() == Type.DOUBLE || value.isNull()) { @@ -194,8 +191,6 @@ public abstract class AbstractTmfMipmapStateProvider extends AbstractTmfStatePro } } catch (TimeRangeException e) { Activator.logError("MipMapProvider : Time stamp outside of time range of state system", e); //$NON-NLS-1$ - } catch (AttributeNotFoundException e) { - Activator.logError("MipMapProvider : Attribute not found", e); //$NON-NLS-1$ } catch (StateValueTypeException e) { Activator.logError("MipMapProvider : Wrong state value type", e); //$NON-NLS-1$ } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/TmfMipmapFeature.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/TmfMipmapFeature.java index 3c832ead21..d1ed5d0592 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/TmfMipmapFeature.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/TmfMipmapFeature.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2014 Ericsson + * Copyright (c) 2013, 2016 Ericsson * * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which @@ -18,7 +18,6 @@ import java.util.List; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.core.Activator; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; @@ -151,8 +150,6 @@ public abstract class TmfMipmapFeature implements ITmfMipmapFeature { ss.modifyAttribute(startTime, value, levelQuark); } catch (StateValueTypeException e) { Activator.logError("TmfMipmapFeature : Bad state value type", e); //$NON-NLS-1$ - } catch (AttributeNotFoundException e) { - Activator.logError("TmfMipmapFeature : Attribute not found", e); //$NON-NLS-1$ } catch (TimeRangeException e) { Activator.logError("TmfMipmapFeature : Time stamp is out of range", e); //$NON-NLS-1$ } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/callstack/CallStackStateProvider.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/callstack/CallStackStateProvider.java index 245876e508..7159df876d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/callstack/CallStackStateProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/callstack/CallStackStateProvider.java @@ -19,7 +19,6 @@ import org.eclipse.jdt.annotation.Nullable; import org.eclipse.osgi.util.NLS; import org.eclipse.tracecompass.internal.tmf.core.Activator; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; @@ -121,63 +120,58 @@ public abstract class CallStackStateProvider extends AbstractTmfStateProvider { ITmfStateSystemBuilder ss = checkNotNull(getStateSystemBuilder()); - try { - /* Check if the event is a function entry */ - ITmfStateValue functionEntryName = functionEntry(event); - if (functionEntryName != null) { - long timestamp = event.getTimestamp().toNanos(); + /* Check if the event is a function entry */ + ITmfStateValue functionEntryName = functionEntry(event); + if (functionEntryName != null) { + long timestamp = event.getTimestamp().toNanos(); - String processName = getProcessName(event); - int processId = getProcessId(event); - if (processName == null) { - processName = (processId == UNKNOWN_PID) ? UNKNOWN : Integer.toString(processId); - } - int processQuark = ss.getQuarkAbsoluteAndAdd(PROCESSES, processName); - ss.updateOngoingState(TmfStateValue.newValueInt(processId), processQuark); - - String threadName = getThreadName(event); - long threadId = getThreadId(event); - if (threadName == null) { - threadName = Long.toString(threadId); - } - int threadQuark = ss.getQuarkRelativeAndAdd(processQuark, threadName); - ss.updateOngoingState(TmfStateValue.newValueLong(threadId), threadQuark); - - int callStackQuark = ss.getQuarkRelativeAndAdd(threadQuark, CALL_STACK); - ITmfStateValue value = functionEntryName; - ss.pushAttribute(timestamp, value, callStackQuark); - return; + String processName = getProcessName(event); + int processId = getProcessId(event); + if (processName == null) { + processName = (processId == UNKNOWN_PID) ? UNKNOWN : Integer.toString(processId); } + int processQuark = ss.getQuarkAbsoluteAndAdd(PROCESSES, processName); + ss.updateOngoingState(TmfStateValue.newValueInt(processId), processQuark); - /* Check if the event is a function exit */ - ITmfStateValue functionExitState = functionExit(event); - if (functionExitState != null) { - long timestamp = event.getTimestamp().toNanos(); - String processName = getProcessName(event); - if (processName == null) { - int processId = getProcessId(event); - processName = (processId == UNKNOWN_PID) ? UNKNOWN : Integer.toString(processId); - } - String threadName = getThreadName(event); - if (threadName == null) { - threadName = Long.toString(getThreadId(event)); - } - int quark = ss.getQuarkAbsoluteAndAdd(PROCESSES, processName, threadName, CALL_STACK); - ITmfStateValue poppedValue = ss.popAttribute(timestamp, quark); - /* - * Verify that the value we are popping matches the one in the - * event field, unless the latter is undefined. - */ - if (!functionExitState.isNull() && !functionExitState.equals(poppedValue)) { - Activator.logWarning(NLS.bind( - Messages.CallStackStateProvider_UnmatchedPoppedValue, - functionExitState, - poppedValue)); - } + String threadName = getThreadName(event); + long threadId = getThreadId(event); + if (threadName == null) { + threadName = Long.toString(threadId); } + int threadQuark = ss.getQuarkRelativeAndAdd(processQuark, threadName); + ss.updateOngoingState(TmfStateValue.newValueLong(threadId), threadQuark); + + int callStackQuark = ss.getQuarkRelativeAndAdd(threadQuark, CALL_STACK); + ITmfStateValue value = functionEntryName; + ss.pushAttribute(timestamp, value, callStackQuark); + return; + } - } catch (AttributeNotFoundException e) { - e.printStackTrace(); + /* Check if the event is a function exit */ + ITmfStateValue functionExitState = functionExit(event); + if (functionExitState != null) { + long timestamp = event.getTimestamp().toNanos(); + String processName = getProcessName(event); + if (processName == null) { + int processId = getProcessId(event); + processName = (processId == UNKNOWN_PID) ? UNKNOWN : Integer.toString(processId); + } + String threadName = getThreadName(event); + if (threadName == null) { + threadName = Long.toString(getThreadId(event)); + } + int quark = ss.getQuarkAbsoluteAndAdd(PROCESSES, processName, threadName, CALL_STACK); + ITmfStateValue poppedValue = ss.popAttribute(timestamp, quark); + /* + * Verify that the value we are popping matches the one in the + * event field, unless the latter is undefined. + */ + if (!functionExitState.isNull() && !functionExitState.equals(poppedValue)) { + Activator.logWarning(NLS.bind( + Messages.CallStackStateProvider_UnmatchedPoppedValue, + functionExitState, + poppedValue)); + } } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/aspect/TmfStateSystemAspect.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/aspect/TmfStateSystemAspect.java index 793e413587..78433f4638 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/aspect/TmfStateSystemAspect.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/aspect/TmfStateSystemAspect.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2015 Ericsson + * Copyright (c) 2014, 2016 Ericsson * * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which @@ -18,7 +18,6 @@ import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.osgi.util.NLS; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; @@ -77,7 +76,7 @@ public class TmfStateSystemAspect implements ITmfEventAspect { try { ITmfStateValue value = fSS.querySingleState(event.getTimestamp().getValue(), fAttribute).getStateValue(); return checkNotNull(value.toString()); - } catch (AttributeNotFoundException | StateSystemDisposedException e) { + } catch (StateSystemDisposedException e) { return null; } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfAttributePool.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfAttributePool.java index 309a41ff86..ebc7ed76b0 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfAttributePool.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfAttributePool.java @@ -16,9 +16,7 @@ import java.util.Set; import java.util.TreeSet; import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.tracecompass.internal.tmf.core.Activator; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; /** * This class allows to recycle state system attributes. Instead of creating a @@ -137,11 +135,7 @@ public class TmfAttributePool { if (!fQuarksInUse.remove(quark)) { throw new IllegalArgumentException(); } - try { - fSs.removeAttribute(ts, quark); - } catch (AttributeNotFoundException e) { - Activator.logError("Error getting sub-attributes", e); //$NON-NLS-1$ - } + fSs.removeAttribute(ts, quark); fAvailableQuarks.add(quark); } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackPresentationProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackPresentationProvider.java index 6a8be0b32d..2631bc72f0 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackPresentationProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackPresentationProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2014 Ericsson + * Copyright (c) 2013, 2016 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -19,7 +19,6 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.tracecompass.internal.tmf.ui.Activator; import org.eclipse.tracecompass.internal.tmf.ui.Messages; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; @@ -114,8 +113,6 @@ public class CallStackPresentationProvider extends TimeGraphPresentationProvider if (!value.isNull()) { return fView.getFunctionName(entry.getTrace(), entry.getProcessId(), event.getTime(), value); } - } catch (AttributeNotFoundException e) { - Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$ } catch (TimeRangeException e) { Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$ } catch (StateSystemDisposedException e) { @@ -146,8 +143,6 @@ public class CallStackPresentationProvider extends TimeGraphPresentationProvider gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE)); Utils.drawText(gc, name, bounds.x, bounds.y, bounds.width, bounds.height, true, true); } - } catch (AttributeNotFoundException e) { - Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$ } catch (TimeRangeException e) { Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$ } catch (StateSystemDisposedException e) { diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackView.java index bb3a0eb8ff..43286766e5 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackView.java @@ -987,7 +987,7 @@ public class CallStackView extends AbstractTimeGraphView { viewer.getTimeGraphControl().fireSelectionChanged(); startZoomThread(viewer.getTime0(), viewer.getTime1()); - } catch (AttributeNotFoundException | TimeRangeException | StateSystemDisposedException | StateValueTypeException e) { + } catch (TimeRangeException | StateSystemDisposedException | StateValueTypeException e) { Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$ } } @@ -1032,7 +1032,7 @@ public class CallStackView extends AbstractTimeGraphView { viewer.getTimeGraphControl().fireSelectionChanged(); startZoomThread(viewer.getTime0(), viewer.getTime1()); - } catch (AttributeNotFoundException | TimeRangeException | StateSystemDisposedException | StateValueTypeException e) { + } catch (TimeRangeException | StateSystemDisposedException | StateValueTypeException e) { Activator.getDefault().logError("Error querying state system", e); //$NON-NLS-1$ } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java index 50053b54d1..7b944e9016 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014 École Polytechnique de Montréal + * Copyright (c) 2014, 2016 École Polytechnique de Montréal and others. * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -29,7 +29,6 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; -import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; @@ -257,48 +256,44 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer { private boolean updateStateEntries(ITmfStateSystem ss, List fullState, TmfTreeViewerEntry parent, int parentQuark, long timestamp) { boolean changed = false; - try { - for (int quark : ss.getSubAttributes(parentQuark, false)) { - if (quark >= fullState.size()) { - // attribute was created after the full state query - continue; - } - ITmfStateInterval interval = fullState.get(quark); - StateEntry stateEntry = findStateEntry(parent, quark); - if (stateEntry == null) { - boolean modified = fFilterStatus ? - interval.getStartTime() == timestamp : - !interval.getStateValue().isNull(); - stateEntry = new StateEntry(ss.getAttributeName(quark), quark, ss.getFullAttributePath(quark), - interval.getStateValue(), - TmfTimestamp.fromNanos(interval.getStartTime()), - TmfTimestamp.fromNanos(interval.getEndTime()), - modified); - - // update children first to know if parent is really needed - updateStateEntries(ss, fullState, stateEntry, quark, timestamp); - - /* - * Add this entry to parent if filtering is off, or - * if the entry has children to display, or - * if there is a state change at the current timestamp - */ - if (!fFilterStatus || stateEntry.hasChildren() || interval.getStartTime() == timestamp) { - parent.addChild(stateEntry); - changed = true; - } - } else { - stateEntry.update(interval.getStateValue(), - TmfTimestamp.fromNanos(interval.getStartTime()), - TmfTimestamp.fromNanos(interval.getEndTime())); + for (int quark : ss.getSubAttributes(parentQuark, false)) { + if (quark >= fullState.size()) { + // attribute was created after the full state query + continue; + } + ITmfStateInterval interval = fullState.get(quark); + StateEntry stateEntry = findStateEntry(parent, quark); + if (stateEntry == null) { + boolean modified = fFilterStatus ? + interval.getStartTime() == timestamp : + !interval.getStateValue().isNull(); + stateEntry = new StateEntry(ss.getAttributeName(quark), quark, ss.getFullAttributePath(quark), + interval.getStateValue(), + TmfTimestamp.fromNanos(interval.getStartTime()), + TmfTimestamp.fromNanos(interval.getEndTime()), + modified); + + // update children first to know if parent is really needed + updateStateEntries(ss, fullState, stateEntry, quark, timestamp); - // update children recursively - updateStateEntries(ss, fullState, stateEntry, quark, timestamp); + /* + * Add this entry to parent if filtering is off, or + * if the entry has children to display, or + * if there is a state change at the current timestamp + */ + if (!fFilterStatus || stateEntry.hasChildren() || interval.getStartTime() == timestamp) { + parent.addChild(stateEntry); + changed = true; } + } else { + stateEntry.update(interval.getStateValue(), + TmfTimestamp.fromNanos(interval.getStartTime()), + TmfTimestamp.fromNanos(interval.getEndTime())); + // update children recursively + updateStateEntries(ss, fullState, stateEntry, quark, timestamp); } - } catch (AttributeNotFoundException e) { - /* Should not happen, we're iterating on known attributes */ + } return changed; } -- 2.34.1