lttng: Make use of "is_pic" event field in debug info analysis
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.ust.core / src / org / eclipse / tracecompass / lttng2 / ust / core / analysis / debuginfo / UstDebugInfoBinaryAspect.java
index 4bb345e2dd3310f283c8f4ced7a3e24695057350..3cb29f28512a3f6f3b0bb52c3f21bdafdff7c628 100644 (file)
@@ -30,7 +30,7 @@ import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
  * @author Alexandre Montplaisir
  * @since 2.0
  */
-public class UstDebugInfoBinaryAspect implements ITmfEventAspect<BinaryCallsite> {
+public final class UstDebugInfoBinaryAspect implements ITmfEventAspect<BinaryCallsite> {
 
     /** Singleton instance */
     public static final UstDebugInfoBinaryAspect INSTANCE = new UstDebugInfoBinaryAspect();
@@ -109,34 +109,18 @@ public class UstDebugInfoBinaryAspect implements ITmfEventAspect<BinaryCallsite>
         String fullPath = (trace.getSymbolProviderConfig().getActualRootDirPath() + file.getFilePath());
 
         long offset;
-        if (isPIC(fullPath)) {
+        if (file.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, EMPTY_STRING, offset);
-    }
-
-    /**
-     * Return if the given file (binary or library) is Position-Independent Code
-     * or not. This indicates if addr2line considers the addresses as absolute
-     * addresses or as offsets.
-     */
-    private static boolean isPIC(String filePath) {
-        /*
-         * Ghetto binary/library identification for now. It would be possible to
-         * parse the ELF binary to check if it is position-independent
-         * (-fPIC/-fPIE) or not.
-         */
-        return (filePath.endsWith(".so") || filePath.contains(".so.")); //$NON-NLS-1$ //$NON-NLS-2$
+        return new BinaryCallsite(fullPath, file.getBuildId(), offset, file.isPic());
     }
 
 }
This page took 0.038798 seconds and 5 git commands to generate.