From 633fa1c6081e14840b5b7cfa07c53ad4fa9dc4aa Mon Sep 17 00:00:00 2001 From: Siwei Zhang Date: Mon, 23 Sep 2024 16:42:10 +0200 Subject: [PATCH] Expose the clock and frequency in CtfTmfTrace The frequency of the CtfTmfTrace is currently exposed in an indirect way using cyclesToNanos(). BUt sometimes there is the need to get direct frequency. [Added] public method to get clock info in CTFTmfTrace [Added] public method to get frequency to get CTFClock Signed-off-by: Siwei Zhang --- .../tracecompass/ctf/core/event/CTFClock.java | 6 ++++++ .../tmf/ctf/core/trace/CtfTmfTrace.java | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/CTFClock.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/CTFClock.java index cf58d0bcc6..3b354e2ec8 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/CTFClock.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/CTFClock.java @@ -159,4 +159,10 @@ public boolean isClockScaled() { return fIsScaled; } + /** + * @return the frequency in Hz + */ + public long getFrequency() { + return ((Long) getProperty(FREQ)); + } } diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java index d34aebde0d..0b5b496e30 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java @@ -560,6 +560,20 @@ public Map getEnvironment() { return trace.getEnvironment(); } + /** + * Get the CTF clock defined in this CTF trace, in + * form. This comes from the trace's CTF metadata. + * + * @return The CTF environment + */ + public CTFClock getClock() { + CTFTrace trace = fTrace; + if (trace == null) { + return null; + } + return trace.getClock(); + } + /** * @since 3.0 */