1 /*******************************************************************************
2 * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.internal
.lttng2
.ust
.core
.analysis
.debuginfo
;
12 import java
.util
.Objects
;
14 import org
.eclipse
.jdt
.annotation
.Nullable
;
17 * Wrapper class to reference to a particular binary, which can be an
18 * executable or library. It contains both the complete file path (at the
19 * time the trace was taken) and the build ID of the binary.
21 public class UstDebugInfoBinaryFile
implements Comparable
<UstDebugInfoBinaryFile
> {
23 private final String fFilePath
;
24 private final String fBuildId
;
25 private final boolean fIsPic
;
26 private final String fToString
;
32 * The binary's path on the filesystem
34 * The binary's unique buildID (in base16 form).
36 * If the binary is position-independent or not
38 public UstDebugInfoBinaryFile(String filePath
, String buildId
, boolean isPic
) {
43 fToString
= filePath
+ " (" + //$NON-NLS-1$
44 (fIsPic ?
"PIC" : "non-PIC") + //$NON-NLS-1$ //$NON-NLS-2$
45 ", " + buildId
+ ')'; //$NON-NLS-1$
49 * Get the file's path, as was referenced to in the trace.
51 * @return The file path
53 public String
getFilePath() {
58 * Get the build ID of the binary. It should be a unique identifier.
60 * On Unix systems, you can use <pre>eu-readelf -n [binary]</pre> to get
63 * @return The file's build ID.
65 public String
getBuildId() {
70 * Return whether the given file (binary or library) is Position-Independent
73 * This indicates whether the symbols in the ELF are absolute or relative to
74 * the runtime base address, and determines which address we need to pass to
77 * @return Whether this file is position-independent or not
79 public boolean isPic() {
84 public String
toString() {
89 public boolean equals(@Nullable Object obj
) {
90 if (!(obj
instanceof UstDebugInfoBinaryFile
)) {
93 UstDebugInfoBinaryFile other
= (UstDebugInfoBinaryFile
) obj
;
94 return (fFilePath
.equals(other
.fFilePath
) &&
95 fBuildId
.equals(other
.fBuildId
) &&
96 fIsPic
== other
.fIsPic
);
100 public int hashCode() {
101 return Objects
.hash(fBuildId
, fFilePath
, fIsPic
);
105 * Used for sorting. Sorts by using alphabetical order of the file
109 public int compareTo(@Nullable UstDebugInfoBinaryFile o
) {
113 return fFilePath
.compareTo(o
.fFilePath
);