private static class FileOffset {
private final String fFilePath;
+ private final String fBuildId;
private final long fOffset;
- public FileOffset(String filePath, long offset) {
+ public FileOffset(String filePath, String buildId, long offset) {
fFilePath = filePath;
+ fBuildId = buildId;
fOffset = offset;
}
@Override
public int hashCode() {
- return Objects.hashCode(fFilePath, fOffset);
+ return Objects.hashCode(fFilePath, fBuildId, fOffset);
}
@Override
return false;
}
FileOffset other = (FileOffset) obj;
- if (!fFilePath.equals(other.fFilePath)) {
- return false;
- }
- if (fOffset != other.fOffset) {
- return false;
- }
- return true;
+ return Objects.equal(fFilePath, other.fFilePath) &&
+ Objects.equal(fBuildId, other.fBuildId) &&
+ Objects.equal(fOffset, other.fOffset);
}
}
*
* @param file
* The binary file to look at
+ * @param buildId
+ * The expected buildId of the binary file (is not verified at
+ * the moment)
* @param offset
* The memory offset in the file
* @return The list of callsites corresponding to the offset, reported from
* the "highest" inlining location, down to the initial definition.
*/
- public static @Nullable Iterable<TmfCallsite> getCallsiteFromOffset(File file, long offset) {
+ public static @Nullable Iterable<TmfCallsite> getCallsiteFromOffset(File file, String buildId, long offset) {
if (!Files.exists((file.toPath()))) {
return null;
}
- FileOffset fo = new FileOffset(checkNotNull(file.toString()), offset);
+ // 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);
}
public class BinaryCallsite {
private final String fBinaryFilePath;
+ private final String fBuildId;
private final String fSymbolName;
private final long fOffset;
* @param binaryFilePath
* The path to the binary file on disk, as specified in the trace
* (may or may not be present on the system opening the trace).
+ * @param buildId
+ * 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.
* The offset *within the binary* of the call site. This should
* be ready to be passed as-is to tools like addr2line.
*/
- public BinaryCallsite(String binaryFilePath, String symbolName, long offset) {
+ public BinaryCallsite(String binaryFilePath, String buildId, String symbolName, long offset) {
if (offset < 0) {
throw new IllegalArgumentException("Address offset cannot be negative"); //$NON-NLS-1$
}
fBinaryFilePath = binaryFilePath;
+ fBuildId = buildId;
fSymbolName = symbolName;
fOffset = offset;
}
return fBinaryFilePath;
}
+ /**
+ * The build-id of the binary
+ *
+ * @return The build-id
+ */
+ public String getBuildId() {
+ return fBuildId;
+ }
+
/**
* Get the name of the symbol this instruction pointer is from, if it is
* available.