dd603c7e2c7a5e8e0e3b641b78af2a3e24351956
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.ust.core / src / org / eclipse / tracecompass / internal / lttng2 / ust / core / analysis / debuginfo / UstDebugInfoBinaryFile.java
1 /*******************************************************************************
2 * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
3 *
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 *******************************************************************************/
9
10 package org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.debuginfo;
11
12 import org.eclipse.jdt.annotation.Nullable;
13
14 /**
15 * Wrapper class to reference to a particular binary, which can be an
16 * executable or library. It contains both the complete file path (at the
17 * time the trace was taken) and the build ID of the binary.
18 */
19 public class UstDebugInfoBinaryFile implements Comparable<UstDebugInfoBinaryFile> {
20
21 private final String fFilePath;
22 private final String fBuildId;
23 private final String fToString;
24
25 /**
26 * Constructor
27 *
28 * @param filePath
29 * The binary's path on the filesystem
30 * @param buildId
31 * The binary's unique buildID (in base16 form).
32 */
33 public UstDebugInfoBinaryFile(String filePath, String buildId) {
34 fFilePath = filePath;
35 fBuildId = buildId;
36 fToString = filePath + " (" + buildId + ')'; //$NON-NLS-1$
37 }
38
39 /**
40 * Get the file's path, as was referenced to in the trace.
41 *
42 * @return The file path
43 */
44 public String getFilePath() {
45 return fFilePath;
46 }
47
48 /**
49 * Get the build ID of the binary. It should be a unique identifier.
50 *
51 * On Unix systems, you can use <pre>eu-readelf -n [binary]</pre> to get
52 * this ID.
53 *
54 * @return The file's build ID.
55 */
56 public String getBuildId() {
57 return fBuildId;
58 }
59
60 @Override
61 public String toString() {
62 return fToString;
63 }
64
65 @Override
66 public boolean equals(@Nullable Object obj) {
67 if (!(obj instanceof UstDebugInfoBinaryFile)) {
68 return false;
69 }
70 UstDebugInfoBinaryFile other = (UstDebugInfoBinaryFile) obj;
71 return (fFilePath == other.fFilePath &&
72 fBuildId == other.fBuildId);
73 }
74
75 @Override
76 public int hashCode() {
77 final int prime = 31;
78 int result = 1;
79 result = prime * result + fBuildId.hashCode();
80 result = prime * result + fFilePath.hashCode();
81 return result;
82 }
83
84 /**
85 * Used for sorting. Sorts by using alphabetical order of the file
86 * paths.
87 */
88 @Override
89 public int compareTo(@Nullable UstDebugInfoBinaryFile o) {
90 if (o == null) {
91 return 1;
92 }
93 return fFilePath.compareTo(o.fFilePath);
94 }
95 }
This page took 0.032885 seconds and 4 git commands to generate.