d929d6b3c867a8ef74701dafc74a2c0979a0b4a8
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfTmfCallsite.java
1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are made
5 * 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 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 * Bernd Hufmann - Updated for new parent class
12 *******************************************************************************/
13
14 package org.eclipse.linuxtools.tmf.core.ctfadaptor;
15
16 import org.eclipse.linuxtools.ctf.core.event.CTFCallsite;
17 import org.eclipse.linuxtools.tmf.core.event.lookup.TmfCallsite;
18
19 /**
20 * CTF TMF call site information for source code lookup.
21 *
22 * @author Patrick Tasse
23 * @since 2.0
24 */
25 public class CtfTmfCallsite extends TmfCallsite {
26
27 // ------------------------------------------------------------------------
28 // Attributes
29 // ------------------------------------------------------------------------
30
31 /** The event name. */
32 final private String fEventName;
33
34 /** The instruction pointer. */
35 final private long fInstructionPointer;
36
37 // ------------------------------------------------------------------------
38 // Constructors
39 // ------------------------------------------------------------------------
40
41 /**
42 * Standard Constructor.
43 *
44 * @param callsite
45 * - a CTF call site
46 */
47 CtfTmfCallsite(CTFCallsite callsite) {
48 super(callsite.getFileName(), callsite.getFunctionName(), callsite.getLineNumber());
49 fEventName = callsite.getEventName();
50 fInstructionPointer = callsite.getIp();
51 }
52
53 // ------------------------------------------------------------------------
54 // Accessors
55 // ------------------------------------------------------------------------
56
57 /**
58 * Returns the event name of the call site.
59 * @return the event name
60 */
61 public String getEventName() {
62 return fEventName;
63 }
64
65 /**
66 * Returns the instruction pointer of the call site.
67 * @return the instruction pointer
68 */
69 public long getIntructionPointer() {
70 return fInstructionPointer;
71 }
72
73 // ------------------------------------------------------------------------
74 // Accessors
75 // ------------------------------------------------------------------------
76
77 @Override
78 public int hashCode() {
79 final int prime = 31;
80 int result = super.hashCode();
81 result = prime * result + ((fEventName == null) ? 0 : fEventName.hashCode());
82 result = prime * result + (int) (fInstructionPointer ^ (fInstructionPointer >>> 32));
83 return result;
84 }
85
86 @Override
87 public boolean equals(Object obj) {
88 if (this == obj) {
89 return true;
90 }
91 if (!super.equals(obj)) {
92 return false;
93 }
94 if (getClass() != obj.getClass()) {
95 return false;
96 }
97 CtfTmfCallsite other = (CtfTmfCallsite) obj;
98 if (fEventName == null) {
99 if (other.fEventName != null) {
100 return false;
101 }
102 } else if (!fEventName.equals(other.fEventName)) {
103 return false;
104 }
105 if (fInstructionPointer != other.fInstructionPointer) {
106 return false;
107 }
108 return true;
109 }
110
111 @Override
112 public String toString() {
113 return getEventName() + "@0x" + Long.toHexString(fInstructionPointer) + ": " + //$NON-NLS-1$ //$NON-NLS-2$
114 getFileName() + ':' + Long.toString(getLineNumber()) + ' ' + getFileName() + "()"; //$NON-NLS-1$
115 }
116 }
This page took 0.034251 seconds and 4 git commands to generate.