From adecf0a77605ab45a0182ec255e709105b6f9be4 Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Mon, 18 Apr 2016 15:37:06 -0400 Subject: [PATCH] lttng: Fix filters not shown with LTTng 2.8 In LTTng 2.8, a new MI field was added, filter_expression. This needs to be handled by Trace Compass. Bug: 491941 Change-Id: If1e796ca24d5542422f61f63c91cb4c37d702edd Signed-off-by: Marc-Andre Laperle Reviewed-on: https://git.eclipse.org/r/70905 Reviewed-by: Hudson CI Reviewed-by: Patrick Tasse Tested-by: Patrick Tasse --- .../service/LTTngControlServiceMiTest.java | 73 ++++++++++++++ .../testfiles/LTTngServiceMiTest.cfg | 95 +++++++++++++++++++ .../views/service/LTTngControlServiceMI.java | 8 +- .../control/ui/views/service/MIStrings.java | 5 + 4 files changed, 177 insertions(+), 4 deletions(-) diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceMiTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceMiTest.java index 488a18c528..3d06be2b6b 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceMiTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/src/org/eclipse/tracecompass/lttng2/control/ui/tests/service/LTTngControlServiceMiTest.java @@ -49,6 +49,7 @@ public class LTTngControlServiceMiTest extends LTTngControlServiceTest { private static final String SCEN_SESSION_WITH_SYSCALLS = "GetSessionWithSyscalls"; private static final String SCEN_LIST_SESSION_2_7_COMPAT = "ListSession2.7Compat"; + private static final String SCEN_GET_SESSION_FILTER_EXPRESSION = "GetSessionFilterExpression"; @Override protected ILttngControlService getControlService() { @@ -306,4 +307,76 @@ public class LTTngControlServiceMiTest extends LTTngControlServiceTest { fail(e.toString()); } } + + @Test + public void testGetSessionWithFilterExpression() throws ExecutionException { + // FIXME: Disable scheme validation for now until MI 3.0 is integrated + LTTngControlServiceMI service = new LTTngControlServiceMI(getShell(), null); + + fShell.setScenario(SCEN_GET_SESSION_FILTER_EXPRESSION); + ISessionInfo session = service.getSession("mysession", new NullProgressMonitor()); + + // Verify Session + assertNotNull(session); + assertEquals("mysession", session.getName()); + assertEquals("/home/user/lttng-traces/mysession-20120129-084256", session.getSessionPath()); + assertEquals(TraceSessionState.ACTIVE, session.getSessionState()); + + IDomainInfo[] domains = session.getDomains(); + assertNotNull(domains); + assertEquals(2, domains.length); + + // Verify Kernel domain + assertEquals("Kernel", domains[0].getName()); + IChannelInfo[] channels = domains[0].getChannels(); + assertNotNull(channels); + assertEquals(1, channels.length); + + // Verify Kernel's channel0 + assertEquals("channel0", channels[0].getName()); + assertEquals(4, channels[0].getNumberOfSubBuffers()); + assertEquals("splice()", channels[0].getOutputType().getInName()); + assertEquals(TraceChannelOutputType.SPLICE, channels[0].getOutputType()); + assertEquals(false, channels[0].isOverwriteMode()); + assertEquals(200, channels[0].getReadTimer()); + assertEquals(TraceEnablement.ENABLED, channels[0].getState()); + assertEquals(262144, channels[0].getSubBufferSize()); + assertEquals(0, channels[0].getSwitchTimer()); + + // Verify event info + IEventInfo[] channel0Events = channels[0].getEvents(); + assertNotNull(channel0Events); + assertEquals(1, channel0Events.length); + assertEquals("block_rq_remap", channel0Events[0].getName()); + assertEquals(TraceLogLevel.TRACE_EMERG, channel0Events[0].getLogLevel()); + assertEquals(TraceEventType.TRACEPOINT, channel0Events[0].getEventType()); + assertEquals(TraceEnablement.ENABLED, channel0Events[0].getState()); + assertEquals("foo > 10", channel0Events[0].getFilterExpression()); + + // Verify domain UST global + assertEquals("UST global", domains[1].getName()); + + IChannelInfo[] ustChannels = domains[1].getChannels(); + + // Verify UST global's channel0 + assertEquals("channel0", ustChannels[0].getName()); + assertEquals(4, ustChannels[0].getNumberOfSubBuffers()); + assertEquals("mmap()", ustChannels[0].getOutputType().getInName()); + assertEquals(TraceChannelOutputType.MMAP, ustChannels[0].getOutputType()); + assertEquals(false, ustChannels[0].isOverwriteMode()); + assertEquals(200, ustChannels[0].getReadTimer()); + assertEquals(TraceEnablement.ENABLED, ustChannels[0].getState()); + assertEquals(4096, ustChannels[0].getSubBufferSize()); + assertEquals(0, ustChannels[0].getSwitchTimer()); + + // Verify event info + IEventInfo[] ustEvents = ustChannels[0].getEvents(); + assertEquals(1, ustEvents.length); + + assertEquals("ust_tests_hello:tptest_sighandler", ustEvents[0].getName()); + assertEquals(TraceLogLevel.TRACE_DEBUG_LINE, ustEvents[0].getLogLevel()); + assertEquals(TraceEventType.TRACEPOINT, ustEvents[0].getEventType()); + assertEquals(TraceEnablement.DISABLED, ustEvents[0].getState()); + assertEquals("foo > 10", ustEvents[0].getFilterExpression()); + } } diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg index 1e0da9128a..969cee7491 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui.tests/testfiles/LTTngServiceMiTest.cfg @@ -457,6 +457,101 @@ lttng --mi xml list mysession1 +#################################################################### +# Scenario: Test lttng list in the presence of filter expressions +#################################################################### + +GetSessionFilterExpression + +lttng --mi xml list mysession + + +0 + + + + + list + + + + mysession + /home/user/lttng-traces/mysession-20120129-084256 + true + 0 + 0 + + + KERNEL + PER_PID + + + channel0 + true + + DISCARD + 262144 + 4 + 0 + 200 + SPLICE + 0 + 0 + 0 + + + + block_rq_remap + TRACEPOINT + true + foo > 10 + TRACE_EMERG + ALL + false + + + + + + + UST + PER_UID + + + channel0 + true + + DISCARD + 4096 + 4 + 0 + 200 + MMAP + 0 + 0 + 0 + + + + ust_tests_hello:tptest_sighandler + TRACEPOINT + false + foo > 10 + TRACE_DEBUG_LINE + ALL + false + + + + + + + + + + + + #################################################################### # Scenario: Test lttng list (with live time interval) diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java index 928c3516bd..bb36ea6059 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/LTTngControlServiceMI.java @@ -851,15 +851,15 @@ public class LTTngControlServiceMI extends LTTngControlService { eventInfo.setState(TraceEnablement.valueOfString(infoNode.getTextContent())); break; case MIStrings.FILTER: - // TODO - // See bug 334 http://bugs.lttng.org/issues/334 from - // LTTng - // For now we emulate the non-mi behavior and simply put + // Before LTTng 2.8: We emulate the non-mi behavior and simply put // "with filter" if (Boolean.TRUE.toString().equals(infoNode.getTextContent())) { eventInfo.setFilterExpression(Messages.TraceControl_DefaultEventFilterString); } break; + case MIStrings.FILTER_EXPRESSION: + eventInfo.setFilterExpression(infoNode.getTextContent()); + break; case MIStrings.EXCLUSION: // TODO: Currently not supported by tmf // ExclusionS element is ignored diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/MIStrings.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/MIStrings.java index 15c69efee7..d01cc7ed49 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/MIStrings.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/service/MIStrings.java @@ -536,6 +536,11 @@ public interface MIStrings { */ String FILTER = "filter"; + /** + * Represent the filter_expression xml element + */ + String FILTER_EXPRESSION = "filter_expression"; + /** * Represent the snapshot_outputs xml element */ -- 2.34.1