lttng.ust: Tweaks to BinaryCallsite
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Fri, 8 Apr 2016 22:33:32 +0000 (18:33 -0400)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Tue, 3 May 2016 17:25:55 +0000 (13:25 -0400)
- 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 <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/70307
Reviewed-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/BinaryCallsite.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/Messages.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoBinaryAspect.java
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/messages.properties

index 1c55e4cc4b9bdbe446939272aaaed6e1d07948e7..db96a9e77156c97e00320d456d1d7917c4673450 100644 (file)
@@ -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();
     }
index 726280d636a51ecc198c0776cd85a9b25e7c2ab0..c9f8f2c76f400e3e326696aeaf3bbb96840baa38 100644 (file)
@@ -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);
index 942b7678ad71c372aa30f82fecaeb9dfbd493ace..17e26ea3dc93a57fab9b10b36219a228284ccb43 100644 (file)
@@ -107,22 +107,21 @@ public class UstDebugInfoBinaryAspect implements ITmfEventAspect<BinaryCallsite>
 
         /* 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);
     }
 
     /**
index badf1d16ef6322f2262fa9b6fdae2290a372124c..a16603810b819601ba2a1109701187600a853475 100644 (file)
@@ -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
This page took 0.028914 seconds and 5 git commands to generate.