26791f3ca6e3d41b580884194c14844f03bc4d09
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.ust.core / src / org / eclipse / tracecompass / lttng2 / ust / core / analysis / debuginfo / BinaryCallsite.java
1 /*******************************************************************************
2 * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9
10 package org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo;
11
12 /**
13 * Object carrying the information about the "binary callsite" corresponding to
14 * an instruction pointer. This consists in:
15 *
16 * <ul>
17 * <li>Binary file</li>
18 * <li>Symbol name</li>
19 * <li>Offset (within the binary)</li>
20 * </ul>
21 *
22 * @author Alexandre Montplaisir
23 * @since 2.0
24 */
25 public class BinaryCallsite {
26
27 private final String fBinaryFilePath;
28 private final String fSymbolName;
29 private final long fOffset;
30
31 /**
32 * Constructor
33 *
34 * @param binaryFilePath
35 * The path to the binary file on disk, as specified in the trace
36 * (may or may not be present on the system opening the trace).
37 * @param symbolName
38 * The name of the symbol in the path. Should not be null, but
39 * can be an empty string if not available.
40 * @param offset
41 * The offset *within the binary* of the call site. This should
42 * be ready to be passed as-is to tools like addr2line.
43 */
44 public BinaryCallsite(String binaryFilePath, String symbolName, long offset) {
45 if (offset < 0) {
46 throw new IllegalArgumentException("Address offset cannot be negative"); //$NON-NLS-1$
47 }
48
49 fBinaryFilePath = binaryFilePath;
50 fSymbolName = symbolName;
51 fOffset = offset;
52 }
53
54 /**
55 * Get the binary file's path
56 *
57 * @return The binary file path
58 */
59 public String getBinaryFilePath() {
60 return fBinaryFilePath;
61 }
62
63 /**
64 * Get the name of the symbol this instruction pointer is from, if it is
65 * available.
66 *
67 * @return The symbol name, or an empty string if not available
68 */
69 public String getSymbolName() {
70 return fSymbolName;
71 }
72
73 /**
74 * Get the address offset within the binary file corresponding to the
75 * instruction pointer.
76 *
77 * @return The address offset
78 */
79 public long getOffset() {
80 return fOffset;
81 }
82
83 @Override
84 public String toString() {
85 StringBuilder sb = new StringBuilder();
86 sb.append(fBinaryFilePath);
87 if (!fSymbolName.equals("")) { //$NON-NLS-1$
88 sb.append(", "); //$NON-NLS-1$
89 sb.append(Messages.UstDebugInfoAnalysis_Symbol);
90 sb.append('=');
91 sb.append(fSymbolName);
92 }
93 sb.append(", "); //$NON-NLS-1$
94 sb.append(Messages.UstDebugInfoAnalysis_Offset);
95 sb.append('=');
96 sb.append(fOffset);
97
98 return sb.toString();
99 }
100 }
This page took 0.033408 seconds and 4 git commands to generate.