From: Alexandre Montplaisir Date: Fri, 8 Apr 2016 22:33:32 +0000 (-0400) Subject: lttng.ust: Tweaks to BinaryCallsite X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;ds=sidebyside;h=1b084865c7c48055f673b20042ab53b3b5d1a9ed;p=deliverable%2Ftracecompass.git lttng.ust: Tweaks to BinaryCallsite - Rename the aspect (and Event table column) to Binary Location. - Remove the concept of function name, it is not part of the information available from the trace. Was not being used anyway. - Print the offset differently depending on if the address is absolute or not: /usr/lib/mylib.so+0x123 for Position-Indpendant-Code (PIC) binaries /usr/myprog@0x401234 for non-PIC binaries The differentiation PIC/PIE is not very robust at the moment (we just check if the file name ends in ".so"), but it will be improved due to a new field being added by UST soon. Change-Id: Ib0014a77e14c6a88ae19f0c4b410d3675f7966d4 Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/70307 Reviewed-by: Hudson CI Reviewed-by: Marc-Andre Laperle Tested-by: Marc-Andre Laperle --- diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/BinaryCallsite.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/BinaryCallsite.java index 1c55e4cc4b..db96a9e771 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/BinaryCallsite.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/BinaryCallsite.java @@ -26,8 +26,8 @@ public class BinaryCallsite { private final String fBinaryFilePath; private final String fBuildId; - private final String fSymbolName; private final long fOffset; + private final boolean fIsPic; /** * Constructor @@ -39,22 +39,25 @@ public class BinaryCallsite { * The Build-Id of the binary file. This is an unique identifier * for a given object, so it can be used to make sure the file at * the given path is the exact one we expect. - * @param symbolName - * The name of the symbol in the path. Should not be null, but - * can be an empty string if not available. * @param offset - * The offset *within the binary* of the call site. This should - * be ready to be passed as-is to tools like addr2line. + * The offset of the call site. Its exact meaning will depend on + * the value of 'isPic'. This should be ready to be passed as-is + * to tools like addr2line. + * @param isPic + * Indicates if the specified binary is Position-Independant Code + * or not. This will indicate if the 'offset' parameter is an + * absolute address (if isPic is false), or if it is an offset in + * the binary (is isPic is true). */ - public BinaryCallsite(String binaryFilePath, String buildId, String symbolName, long offset) { + public BinaryCallsite(String binaryFilePath, String buildId, long offset, boolean isPic) { if (offset < 0) { throw new IllegalArgumentException("Address offset cannot be negative"); //$NON-NLS-1$ } fBinaryFilePath = binaryFilePath; fBuildId = buildId; - fSymbolName = symbolName; fOffset = offset; + fIsPic = isPic; } /** @@ -75,16 +78,6 @@ public class BinaryCallsite { return fBuildId; } - /** - * Get the name of the symbol this instruction pointer is from, if it is - * available. - * - * @return The symbol name, or an empty string if not available - */ - public String getSymbolName() { - return fSymbolName; - } - /** * Get the address offset within the binary file corresponding to the * instruction pointer. @@ -97,18 +90,22 @@ public class BinaryCallsite { @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(fBinaryFilePath); - if (!fSymbolName.equals("")) { //$NON-NLS-1$ - sb.append(", "); //$NON-NLS-1$ - sb.append(Messages.UstDebugInfoAnalysis_Symbol); - sb.append('='); - sb.append(fSymbolName); + /* + * Output is of the following format: + * + * For PIC/PIE binaries: /usr/lib/mylib.so+0x123 + * For non-PIC binaries: /usr/myprogram@0x401234 + */ + StringBuilder sb = new StringBuilder() + .append(fBinaryFilePath); + + if (fIsPic) { + sb.append('+'); + } else { + sb.append('@'); } - sb.append(", "); //$NON-NLS-1$ - sb.append(Messages.UstDebugInfoAnalysis_Offset); - sb.append('='); - sb.append(fOffset); + + sb.append("0x").append(Long.toHexString(fOffset)); //$NON-NLS-1$ return sb.toString(); } diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/Messages.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/Messages.java index 726280d636..c9f8f2c76f 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/Messages.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/Messages.java @@ -28,9 +28,6 @@ public class Messages extends NLS { public static @Nullable String UstDebugInfoAnalysis_BinaryAspectName; public static @Nullable String UstDebugInfoAnalysis_BinaryAspectHelpText; - public static @Nullable String UstDebugInfoAnalysis_Offset; - public static @Nullable String UstDebugInfoAnalysis_Symbol; - static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryAspect.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryAspect.java index 942b7678ad..17e26ea3dc 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryAspect.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryAspect.java @@ -107,22 +107,21 @@ public class UstDebugInfoBinaryAspect implements ITmfEventAspect /* Apply the path prefix defined by the trace, if any */ String fullPath = (trace.getSymbolProviderConfig().getActualRootDirPath() + file.getFilePath()); + boolean isPIC = isPIC(fullPath); long offset; - if (isPIC(fullPath)) { + if (isPIC) { offset = (ip - file.getBaseAddress()); } else { /* - * In the case of the object being the main binary (loaded at a very - * low address), we must pass the actual ip address to addr2line. + * In the case of the object being non-position-independant (loaded + * at a very low address), we must pass the actual 'ip' address + * directly to addr2line. */ offset = ip; } - // TODO If the binary is present on the current file system, we could - // try to get the symbol name from it. - - return new BinaryCallsite(fullPath, file.getBuildId(), EMPTY_STRING, offset); + return new BinaryCallsite(fullPath, file.getBuildId(), offset, isPIC); } /** diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/messages.properties b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/messages.properties index badf1d16ef..a16603810b 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/messages.properties +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/messages.properties @@ -9,8 +9,5 @@ UstDebugInfoAnalysis_SourceAspectName = Source callsite UstDebugInfoAnalysis_SourceAspectHelpText = The call site of this event in the source code -UstDebugInfoAnalysis_BinaryAspectName = Binary callsite +UstDebugInfoAnalysis_BinaryAspectName = Binary Location UstDebugInfoAnalysis_BinaryAspectHelpText = The call site of this event in the binary file - -UstDebugInfoAnalysis_Offset = offset -UstDebugInfoAnalysis_Symbol = symbol