From: Alexandre Montplaisir Date: Thu, 30 Jun 2016 18:11:27 +0000 (-0400) Subject: lttng.ust: Add logging to FileOffsetMapper X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=ba50b37629a23cbfa83e42d85a48352c487d3a4c;p=deliverable%2Ftracecompass.git lttng.ust: Add logging to FileOffsetMapper Should help identify requests and cache hits/misses more easily. Change-Id: I80eb4b405ad0ceb61e6a8386d397d110729badd0 Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/76399 Reviewed-by: Hudson CI --- diff --git a/common/org.eclipse.tracecompass.common.core/annotations/com/google/common/base/Objects$ToStringHelper.eea b/common/org.eclipse.tracecompass.common.core/annotations/com/google/common/base/Objects$ToStringHelper.eea new file mode 100644 index 0000000000..ae974a06be --- /dev/null +++ b/common/org.eclipse.tracecompass.common.core/annotations/com/google/common/base/Objects$ToStringHelper.eea @@ -0,0 +1,4 @@ +class com/google/common/base/Objects$ToStringHelper +toString + ()Ljava/lang/String; + ()L1java/lang/String; diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/FileOffsetMapper.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/FileOffsetMapper.java index 69c7b1f666..d426042769 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/FileOffsetMapper.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/debuginfo/FileOffsetMapper.java @@ -19,9 +19,11 @@ import java.nio.file.Files; import java.util.Arrays; import java.util.LinkedList; import java.util.List; +import java.util.logging.Logger; import java.util.stream.Collectors; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.common.core.log.TraceCompassLog; import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.SourceCallsite; import org.eclipse.tracecompass.tmf.core.event.lookup.TmfCallsite; @@ -38,6 +40,8 @@ import com.google.common.cache.LoadingCache; */ public final class FileOffsetMapper { + private static final Logger LOGGER = TraceCompassLog.getLogger(FileOffsetMapper.class); + private static final String DISCRIMINATOR = "\\(discriminator.*\\)"; //$NON-NLS-1$ private static final String ADDR2LINE_EXECUTABLE = "addr2line"; //$NON-NLS-1$ @@ -81,6 +85,15 @@ public final class FileOffsetMapper { Objects.equal(fBuildId, other.fBuildId) && Objects.equal(fOffset, other.fOffset); } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("fFilePath", fFilePath) //$NON-NLS-1$ + .add("fBuildId", fBuildId) //$NON-NLS-1$ + .add("fOffset", String.format("0x%h", fOffset)) //$NON-NLS-1$ //$NON-NLS-2$ + .toString(); + } } /** @@ -97,6 +110,7 @@ public final class FileOffsetMapper { .build(new CacheLoader>() { @Override public @Nullable Iterable load(FileOffset fo) { + LOGGER.fine(() -> "[FileOffsetMapper:CacheMiss] file/offset=" + fo.toString()); //$NON-NLS-1$ return getCallsiteFromOffsetWithAddr2line(fo); } })); @@ -120,14 +134,20 @@ public final class FileOffsetMapper { * the "highest" inlining location, down to the initial definition. */ public static @Nullable Iterable getCallsiteFromOffset(File file, @Nullable String buildId, long offset) { + LOGGER.finer(() -> String.format("[FileOffsetMapper:Request] file=%s, buildId=%s, offset=0x%h", //$NON-NLS-1$ + file.toString(), buildId, offset)); + if (!Files.exists((file.toPath()))) { + LOGGER.finer(() -> "[FileOffsetMapper:RequestFailed] File not found"); //$NON-NLS-1$ return null; } // TODO We should also eventually verify that the passed buildId matches // the file we are attempting to open. - FileOffset fo = new FileOffset(checkNotNull(file.toString()), buildId, offset); - return CALLSITE_CACHE.getUnchecked(fo); + + Iterable callsites = CALLSITE_CACHE.getUnchecked(fo); + LOGGER.finer(() -> String.format("[FileOffsetMapper:RequestComplete] callsites=%s", callsites)); //$NON-NLS-1$ + return callsites; } private static @Nullable Iterable getCallsiteFromOffsetWithAddr2line(FileOffset fo) {