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
.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 * @author Alexandre Montplaisir
22 * @noreference Meant to be used internally by the analysis only
24 public class UstDebugInfoBinaryFile
implements Comparable
<UstDebugInfoBinaryFile
> {
26 private final String fFilePath
;
27 private final @Nullable String fBuildId
;
28 private final @Nullable String fDebugLink
;
29 private final boolean fIsPic
;
35 * The binary's path on the filesystem.
37 * The binary's unique buildID (in base16 form).
39 * Path to the binary's separate debug info.
41 * Whether the code in the binary is position-independent.
43 public UstDebugInfoBinaryFile(String filePath
, @Nullable String buildId
,
44 @Nullable String debugLink
, boolean isPic
) {
47 fDebugLink
= debugLink
;
52 * Get the file's path, as was referenced to in the trace.
54 * @return The file path
56 public String
getFilePath() {
61 * Get the build ID of the binary. It should be a unique identifier.
63 * On Unix systems, you can use <pre>eu-readelf -n [binary]</pre> to get
66 * @return The file's build ID, or null if the file has no build ID..
68 public @Nullable String
getBuildId() {
73 * Get the path to the separate debug info of this binary.
75 * @return The path to the separate debug info, or null if the file has no
76 * separate debug info.
78 public @Nullable String
getDebugLink() {
83 * Return whether the given file (binary or library) is Position-Independent
86 * This indicates whether the symbols in the ELF are absolute or relative to
87 * the runtime base address, and determines which address we need to pass to
90 * @return Whether this file is position-independent or not
92 public boolean isPic() {
97 public String
toString() {
98 return com
.google
.common
.base
.Objects
.toStringHelper(this)
99 .add("path", fFilePath
) //$NON-NLS-1$
100 .add("build_id", fBuildId
) //$NON-NLS-1$
101 .add("debug_link", fDebugLink
) //$NON-NLS-1$
102 .add("is_pic", fIsPic
) //$NON-NLS-1$
107 public int hashCode() {
108 return Objects
.hash(fFilePath
, fBuildId
, fDebugLink
, fIsPic
);
112 public boolean equals(@Nullable Object obj
) {
119 if (!(getClass().equals(obj
.getClass()))) {
123 UstDebugInfoBinaryFile other
= (UstDebugInfoBinaryFile
) obj
;
125 return Objects
.equals(fFilePath
, other
.fFilePath
) &&
126 Objects
.equals(fBuildId
, other
.fBuildId
) &&
127 Objects
.equals(fDebugLink
, other
.fDebugLink
) &&
128 fIsPic
== other
.fIsPic
;
132 * Used for sorting. Sorts by using alphabetical order of the file
136 public int compareTo(@Nullable UstDebugInfoBinaryFile o
) {
140 return fFilePath
.compareTo(o
.fFilePath
);