diff options
author | Geneviève Bastien | 2018-04-04 21:07:25 +0000 |
---|---|---|
committer | Genevieve Bastien | 2018-04-05 14:16:33 +0000 |
commit | 5ec21d429b511ac614f79024f41138377f7bb589 (patch) | |
tree | 109c39c0022a77c8cd53b49674d6f8ba0c45ed4b | |
parent | 34f2442794563003eb969cee1022a51c7f6593af (diff) | |
download | org.eclipse.tracecompass.incubator-5ec21d429b511ac614f79024f41138377f7bb589.tar.gz org.eclipse.tracecompass.incubator-5ec21d429b511ac614f79024f41138377f7bb589.tar.xz org.eclipse.tracecompass.incubator-5ec21d429b511ac614f79024f41138377f7bb589.zip |
callstack: Use Object instead of state value to create functions
Change-Id: I28023a164ac125a72fdb111b8b8b1d9ddb46ed92
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/120744
Tested-by: CI Bot
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
4 files changed, 25 insertions, 39 deletions
diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/src/org/eclipse/tracecompass/incubator/callstack/core/tests/callgraph/CalledFunctionTest.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/src/org/eclipse/tracecompass/incubator/callstack/core/tests/callgraph/CalledFunctionTest.java index 19e6cc534..0860bfb55 100644 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/src/org/eclipse/tracecompass/incubator/callstack/core/tests/callgraph/CalledFunctionTest.java +++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core.tests/src/org/eclipse/tracecompass/incubator/callstack/core/tests/callgraph/CalledFunctionTest.java @@ -24,7 +24,6 @@ import org.eclipse.tracecompass.incubator.callstack.core.instrumented.ICalledFun import org.eclipse.tracecompass.incubator.internal.callstack.core.instrumented.callgraph.CalledFunction; import org.eclipse.tracecompass.incubator.internal.callstack.core.instrumented.callgraph.CalledFunctionFactory; import org.eclipse.tracecompass.incubator.internal.callstack.core.instrumented.callgraph.CalledStringFunction; -import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; import org.junit.Before; import org.junit.Test; @@ -48,10 +47,10 @@ public class CalledFunctionTest { */ @Before public void setup() { - ICalledFunction fixture = CalledFunctionFactory.create(10, 1010, TmfStateValue.newValueString("Hello"), 0, 0, null, fModel); + ICalledFunction fixture = CalledFunctionFactory.create(10, 1010, "Hello", 0, 0, null, fModel); assertTrue(fixture instanceof CalledStringFunction); fFixture = (CalledStringFunction) fixture; - ICalledFunction fixture42 = CalledFunctionFactory.create(400, 500, TmfStateValue.newValueLong(0x42), 0, 0, fFixture, fModel); + ICalledFunction fixture42 = CalledFunctionFactory.create(400, 500, 0x42L, 0, 0, fFixture, fModel); f42Fixture = fixture42; ICalledFunction hiFixture = CalledFunctionFactory.create(20, 50, "Hi", 0, 0, fFixture, fModel); fHiFixture = hiFixture; @@ -62,17 +61,17 @@ public class CalledFunctionTest { * value */ public void createValid() { - assertNotNull(CalledFunctionFactory.create(0, 0, TmfStateValue.newValueLong(0), 0, 0, null, fModel)); - assertNotNull(CalledFunctionFactory.create(0, 0, TmfStateValue.newValueInt(0), 0, 0, null, fModel)); - assertNotNull(CalledFunctionFactory.create(0, 0, TmfStateValue.newValueString(""), 0, 0, null, fModel)); + assertNotNull(CalledFunctionFactory.create(0, 0, 0L, 0, 0, null, fModel)); + assertNotNull(CalledFunctionFactory.create(0, 0, 0, 0, 0, null, fModel)); + assertNotNull(CalledFunctionFactory.create(0, 0, "", 0, 0, null, fModel)); } /** * Test a value with a floating point memory address. */ - @Test(expected = IllegalArgumentException.class) + @Test public void createInvalidDouble() { - CalledFunctionFactory.create(0, 0, TmfStateValue.newValueDouble(3.14), 0, 0, null, fModel); + assertNotNull(CalledFunctionFactory.create(0, 0, 3.14, 0, 0, null, fModel)); } /** @@ -80,7 +79,7 @@ public class CalledFunctionTest { */ @Test(expected = IllegalArgumentException.class) public void createInvalidNull() { - CalledFunctionFactory.create(0, 0, TmfStateValue.nullValue(), 0, 0, null, fModel); + CalledFunctionFactory.create(0, 0, (Object) null, 0, 0, null, fModel); } /** @@ -96,7 +95,7 @@ public class CalledFunctionTest { */ @Test(expected = IllegalArgumentException.class) public void createInvalidTimeRangeStateLong() { - CalledFunctionFactory.create(10, -10, TmfStateValue.newValueLong(42), 0, 0, null, fModel); + CalledFunctionFactory.create(10, -10, 42L, 0, 0, null, fModel); } /** @@ -104,7 +103,7 @@ public class CalledFunctionTest { */ @Test(expected = IllegalArgumentException.class) public void createInvalidTimeRangeStateInteger() { - CalledFunctionFactory.create(10, -10, TmfStateValue.newValueInt(42), 0, 0, null, fModel); + CalledFunctionFactory.create(10, -10, 42, 0, 0, null, fModel); } /** @@ -112,7 +111,7 @@ public class CalledFunctionTest { */ @Test(expected = IllegalArgumentException.class) public void createInvalidTimeRangeStateString() { - CalledFunctionFactory.create(10, -10, TmfStateValue.newValueString("42"), 0, 0, null, fModel); + CalledFunctionFactory.create(10, -10, "42", 0, 0, null, fModel); } /** @@ -121,7 +120,7 @@ public class CalledFunctionTest { @Test public void testAddChildOk1() { assertNotNull(fFixture); - CalledFunction newchild = (CalledFunction) CalledFunctionFactory.create(100, 200, TmfStateValue.newValueInt(0x64), 0, 0, fFixture, fModel); + CalledFunction newchild = (CalledFunction) CalledFunctionFactory.create(100, 200, 0x64, 0, 0, fFixture, fModel); ICalledFunction hiFixture = fHiFixture; ICalledFunction fixture42 = f42Fixture; assertNotNull(hiFixture); @@ -268,7 +267,7 @@ public class CalledFunctionTest { @Test public void testHashCode() { assertEquals(f42Fixture.hashCode(), f42Fixture.hashCode()); - ICalledFunction calledFunction = CalledFunctionFactory.create(400, 500, TmfStateValue.newValueLong(0x42), 0, 0, fFixture, fModel); + ICalledFunction calledFunction = CalledFunctionFactory.create(400, 500, 0x42L, 0, 0, fFixture, fModel); assertEquals(f42Fixture, calledFunction); assertEquals(f42Fixture.hashCode(), calledFunction.hashCode()); calledFunction = CalledFunctionFactory.create(20, 50, "Hi", 0, 0, fFixture, fModel); diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/flamechart/CallStack.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/flamechart/CallStack.java index 6564c87b5..d76d13085 100644 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/flamechart/CallStack.java +++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/flamechart/CallStack.java @@ -120,7 +120,7 @@ public class CallStack { } if (!callInterval.getStateValue().isNull()) { int threadId = getThreadId(callInterval.getStartTime()); - callList.add(CalledFunctionFactory.create(callInterval.getStartTime(), callInterval.getEndTime() + 1, callInterval.getStateValue(), getSymbolKeyAt(callInterval.getStartTime()), threadId, + callList.add(CalledFunctionFactory.create(callInterval.getStartTime(), callInterval.getEndTime() + 1, callInterval.getValue(), getSymbolKeyAt(callInterval.getStartTime()), threadId, null, ModelManager.getModelFor(getHostId(callInterval.getStartTime())))); } } @@ -187,7 +187,7 @@ public class CallStack { interval = fStateSystem.querySingleState(interval.getEndTime() + 1, fQuarks.get(depth - 1)); } if (!interval.getStateValue().isNull() && interval.getStartTime() >= time) { - return CalledFunctionFactory.create(interval.getStartTime(), interval.getEndTime() + 1, interval.getStateValue(), getSymbolKeyAt(interval.getStartTime()), getThreadId(interval.getStartTime()), null, + return CalledFunctionFactory.create(interval.getStartTime(), interval.getEndTime() + 1, interval.getValue(), getSymbolKeyAt(interval.getStartTime()), getThreadId(interval.getStartTime()), null, ModelManager.getModelFor(getHostId(time))); } } catch (StateSystemDisposedException e) { @@ -233,7 +233,7 @@ public class CallStack { interval = fStateSystem.querySingleState(interval.getEndTime() + 1, fQuarks.get(depth - 1)); } if (!interval.getStateValue().isNull() && interval.getStartTime() < end) { - return CalledFunctionFactory.create(Math.max(start, interval.getStartTime()), Math.min(end, interval.getEndTime() + 1), interval.getStateValue(), getSymbolKeyAt(interval.getStartTime()), getThreadId(interval.getStartTime()), parent, model); + return CalledFunctionFactory.create(Math.max(start, interval.getStartTime()), Math.min(end, interval.getEndTime() + 1), interval.getValue(), getSymbolKeyAt(interval.getStartTime()), getThreadId(interval.getStartTime()), parent, model); } } catch (StateSystemDisposedException e) { diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/instrumented/statesystem/CallStackSeries.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/instrumented/statesystem/CallStackSeries.java index a9224cf6f..1e2d2c3f7 100644 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/instrumented/statesystem/CallStackSeries.java +++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/callstack/core/instrumented/statesystem/CallStackSeries.java @@ -574,7 +574,7 @@ public class CallStackSeries implements ISegmentStore<ISegment> { if (hostThread == null) { hostThread = new HostThread(StringUtils.EMPTY, IHostModel.UNKNOWN_TID); } - return CalledFunctionFactory.create(interval.getStartTime(), interval.getEndTime() + 1, interval.getStateValue(), -1, hostThread.getTid(), + return CalledFunctionFactory.create(interval.getStartTime(), interval.getEndTime() + 1, interval.getValue(), -1, hostThread.getTid(), null, ModelManager.getModelFor(hostThread.getHost())); }; return Iterables.transform(query2d, fct); diff --git a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/instrumented/callgraph/CalledFunctionFactory.java b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/instrumented/callgraph/CalledFunctionFactory.java index e7205f179..5057898d5 100644 --- a/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/instrumented/callgraph/CalledFunctionFactory.java +++ b/callstack/org.eclipse.tracecompass.incubator.callstack.core/src/org/eclipse/tracecompass/incubator/internal/callstack/core/instrumented/callgraph/CalledFunctionFactory.java @@ -12,7 +12,6 @@ package org.eclipse.tracecompass.incubator.internal.callstack.core.instrumented. import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.incubator.analysis.core.model.IHostModel; import org.eclipse.tracecompass.incubator.callstack.core.instrumented.ICalledFunction; -import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; /** * Factory to create {@link ICalledFunction}s. @@ -21,9 +20,6 @@ import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; */ public final class CalledFunctionFactory { - private static final String SEPARATOR = ": "; //$NON-NLS-1$ - private static final String ERROR_MSG = "Cannot create a called function of type : "; //$NON-NLS-1$ - private CalledFunctionFactory() { // do nothing } @@ -35,7 +31,7 @@ public final class CalledFunctionFactory { * the start time * @param end * the end time - * @param stateValue + * @param symbolValue * the symbol * @param processId * The process ID of the traced application @@ -48,23 +44,14 @@ public final class CalledFunctionFactory { * The operating system model this function is a part of * @return an ICalledFunction with the specified properties */ - public static AbstractCalledFunction create(long start, long end, ITmfStateValue stateValue, int processId, int threadId, @Nullable ICalledFunction parent, IHostModel model) { - switch (stateValue.getType()) { - case INTEGER: - return create(start, end, stateValue.unboxInt(), processId, threadId, parent, model); - case LONG: - return create(start, end, stateValue.unboxLong(), processId, threadId, parent, model); - case STRING: - return create(start, end, stateValue.unboxStr(), processId, threadId, parent, model); - case CUSTOM: - // Fall through - case DOUBLE: - // Fall through - case NULL: - // Fall through - default: - throw new IllegalArgumentException(ERROR_MSG + stateValue.getType() + SEPARATOR + stateValue.toString()); + public static AbstractCalledFunction create(long start, long end, @Nullable Object symbolValue, int processId, int threadId, @Nullable ICalledFunction parent, IHostModel model) { + if (symbolValue == null) { + throw new IllegalArgumentException("Symbol value is null"); + } + if (symbolValue instanceof Number) { + return create(start, end, ((Number) symbolValue).longValue(), processId, threadId, parent, model); } + return create(start, end, String.valueOf(symbolValue), processId, threadId, parent, model); } /** |