* @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();
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());
}
}