diff options
Diffstat (limited to 'ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf')
6 files changed, 397 insertions, 0 deletions
diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/CtfEventContextAspect.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/CtfEventContextAspect.java new file mode 100644 index 0000000000..fefa5429d5 --- /dev/null +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/CtfEventContextAspect.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2019 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 + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.tmf.ctf.core.event.aspect; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition; +import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; +import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; +import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect; +import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; +import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEventField; + +/** + * Event context event aspect for CTF traces. + * + * @author Matthew Khouzam + */ +public class CtfEventContextAspect implements ITmfEventAspect<List<ITmfEventField>> { + + private static final @NonNull String ANON = ""; //$NON-NLS-1$ + private static ITmfEventAspect<List<ITmfEventField>> sInstance = null; + + /** + * Get the instance + * + * @return the instance + */ + public static @NonNull ITmfEventAspect<List<ITmfEventField>> getInstance() { + ITmfEventAspect<List<ITmfEventField>> instance = sInstance; + if (instance == null) { + instance = new CtfEventContextAspect(); + sInstance = instance; + } + return instance; + } + + private CtfEventContextAspect() { + // do nothing + } + + @Override + public List<ITmfEventField> resolve(ITmfEvent event) { + if (!(event instanceof CtfTmfEvent)) { + return null; + } + ICompositeDefinition eventContext = ((CtfTmfEvent) event).getEventContext(); + if (eventContext == null) { + return null; + } + Object value = CtfTmfEventField.parseField(eventContext, ANON).getValue(); + if (value instanceof ITmfEventField[]) { + return Arrays.asList((@Nullable ITmfEventField @Nullable []) value); + } + return null; + } + + @Override + public @NonNull String getName() { + return Messages.getMessage(Messages.CtfEventContextAspect_name); + } + + @Override + public @NonNull String getHelpText() { + return Messages.getMessage(Messages.CtfEventContextAspect_description); + } + + @Override + public boolean isHiddenByDefault() { + return true; + } +} diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/CtfPacketContextAspect.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/CtfPacketContextAspect.java new file mode 100644 index 0000000000..07a3d1d473 --- /dev/null +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/CtfPacketContextAspect.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2019 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 + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.tmf.ctf.core.event.aspect; + +import java.util.Map; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; +import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect; +import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; + +/** + * Packet context aspect for CTF traces. + * + * @author Matthew Khouzam + */ +public class CtfPacketContextAspect implements ITmfEventAspect<Map<@NonNull String, @NonNull Object>> { + + private static ITmfEventAspect<Map<@NonNull String, @NonNull Object>> sInstance = null; + + /** + * Get the instance + * + * @return the instance + */ + public static @NonNull ITmfEventAspect<Map<@NonNull String, @NonNull Object>> getInstance() { + ITmfEventAspect<Map<@NonNull String, @NonNull Object>> instance = sInstance; + if (instance == null) { + instance = new CtfPacketContextAspect(); + sInstance = instance; + } + return instance; + } + + private CtfPacketContextAspect() { + // do nothing + } + + @Override + public Map<@NonNull String, @NonNull Object> resolve(ITmfEvent event) { + if (!(event instanceof CtfTmfEvent)) { + return null; + } + Map<@NonNull String, @NonNull Object> packetContext = ((CtfTmfEvent) event).getPacketAttributes(); + if (packetContext.isEmpty()) { + return null; + } + return packetContext; + } + + @Override + public @NonNull String getName() { + return Messages.getMessage(Messages.CtfPacketContextAspect_name); + } + + @Override + public @NonNull String getHelpText() { + return Messages.getMessage(Messages.CtfPacketContextAspect_description); + } + + @Override + public boolean isHiddenByDefault() { + return true; + } +} diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/CtfPacketHeaderAspect.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/CtfPacketHeaderAspect.java new file mode 100644 index 0000000000..82b9bbc2b4 --- /dev/null +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/CtfPacketHeaderAspect.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2019 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 + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.tmf.ctf.core.event.aspect; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition; +import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; +import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; +import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect; +import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; +import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEventField; + +/** + * Packet header aspect for CTF traces. + * + * @author Matthew Khouzam + */ +public class CtfPacketHeaderAspect implements ITmfEventAspect<List<ITmfEventField>> { + + private static final @NonNull String ANON = ""; //$NON-NLS-1$ + private static ITmfEventAspect<List<ITmfEventField>> sInstance = null; + + /** + * Get the instance + * + * @return the instance + */ + public static @NonNull ITmfEventAspect<List<ITmfEventField>> getInstance() { + ITmfEventAspect<List<ITmfEventField>> instance = sInstance; + if (instance == null) { + instance = new CtfPacketHeaderAspect(); + sInstance = instance; + } + return instance; + } + + private CtfPacketHeaderAspect() { + // do nothing + } + + @Override + public @Nullable List<ITmfEventField> resolve(ITmfEvent event) { + if (!(event instanceof CtfTmfEvent)) { + return null; + } + ICompositeDefinition packetContext = ((CtfTmfEvent) event).getPacketContext(); + if (packetContext == null) { + return null; + } + Object value = CtfTmfEventField.parseField(packetContext, ANON).getValue(); + if(value instanceof ITmfEventField[]) { + return Arrays.asList((ITmfEventField[]) value); + } + return null; + } + + @Override + public @NonNull String getName() { + return Messages.getMessage(Messages.CtfPacketHeaderAspect_name); + } + + @Override + public @NonNull String getHelpText() { + return Messages.getMessage(Messages.CtfPacketHeaderAspect_description); + } + + @Override + public boolean isHiddenByDefault() { + return true; + } +} diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/CtfStreamContextAspect.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/CtfStreamContextAspect.java new file mode 100644 index 0000000000..34701b02a6 --- /dev/null +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/CtfStreamContextAspect.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2019 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 + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.tmf.ctf.core.event.aspect; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition; +import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; +import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; +import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect; +import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; +import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEventField; + +/** + * Stream context event aspect for CTF traces. + * + * @author Matthew Khouzam + */ +public class CtfStreamContextAspect implements ITmfEventAspect<List<ITmfEventField>> { + + private static final @NonNull String ANON = ""; //$NON-NLS-1$ + private static ITmfEventAspect<List<ITmfEventField>> sInstance = null; + + /** + * Get the instance + * + * @return the instance + */ + public static @NonNull ITmfEventAspect<List<ITmfEventField>> getInstance() { + ITmfEventAspect<List<ITmfEventField>> instance = sInstance; + if (instance == null) { + instance = new CtfStreamContextAspect(); + sInstance = instance; + } + return instance; + } + + private CtfStreamContextAspect() { + // do nothing + } + + @Override + public List<ITmfEventField> resolve(ITmfEvent event) { + if (!(event instanceof CtfTmfEvent)) { + return null; + } + ICompositeDefinition streamContext = ((CtfTmfEvent) event).getStreamContext(); + if (streamContext == null) { + return null; + } + Object value = CtfTmfEventField.parseField(streamContext, ANON).getValue(); + if(value instanceof ITmfEventField[]) { + return Arrays.asList((@Nullable ITmfEventField @Nullable []) value); + } + return null; + } + + @Override + public @NonNull String getName() { + return Messages.getMessage(Messages.CtfStreamContextAspect_name); + } + + @Override + public @NonNull String getHelpText() { + return Messages.getMessage(Messages.CtfStreamContextAspect_description); + } + + @Override + public boolean isHiddenByDefault() { + return true; + } +} diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/Messages.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/Messages.java new file mode 100644 index 0000000000..e3bf6e20a3 --- /dev/null +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/Messages.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2019 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 + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.tmf.ctf.core.event.aspect; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.osgi.util.NLS; + +/** + * Messages + */ +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.tmf.ctf.core.event.aspect.messages"; //$NON-NLS-1$ + + /** Packet header name */ + public static String CtfPacketHeaderAspect_name; + /** Packet header description */ + public static String CtfPacketHeaderAspect_description; + /** Packet context name */ + public static String CtfPacketContextAspect_name; + /** Packet context description */ + public static String CtfPacketContextAspect_description; + /** Stream context name */ + public static String CtfStreamContextAspect_name; + /** Stream context description */ + public static String CtfStreamContextAspect_description; + /** Event context name */ + public static String CtfEventContextAspect_name; + /** Event context description */ + public static String CtfEventContextAspect_description; + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + /** + * NonNull wrapper + * + * @param msg + * message + * @return message or "" if msg is null + */ + public static @NonNull String getMessage(String msg) { + if (msg == null) { + return ""; //$NON-NLS-1$ + } + return msg; + } + + private Messages() { + // Do nothing + } +} diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/messages.properties b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/messages.properties new file mode 100644 index 0000000000..d41d67efa1 --- /dev/null +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/event/aspect/messages.properties @@ -0,0 +1,20 @@ +############################################################################### +# Copyright (c) 2019 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 +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Ericsson - Initial API and implementation +############################################################################### + +CtfPacketHeaderAspect_name=Trace Packet Header +CtfPacketHeaderAspect_description=The trace packet header of an event. The value can change for every packet, for every event in a same packet, the value will be the same. +CtfPacketContextAspect_name=Packet Context +CtfPacketContextAspect_description=The per-packet context of an event. The value can change for every packet, for every event in a same packet, the value will be the same. +CtfStreamContextAspect_name=Stream Context +CtfStreamContextAspect_description=The per-stream context of an event. The value can change for every event. +CtfEventContextAspect_name=Event Context +CtfEventContextAspect_description=The per-event type context of an event. The value can change for every event. |