LTTng: CPU usage analysis from the LTTng kernel trace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfTmfCallsite.java
CommitLineData
60fb38b8
PT
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
f47ed727 11 * Bernd Hufmann - Updated for new parent class
60fb38b8
PT
12 *******************************************************************************/
13
14package org.eclipse.linuxtools.tmf.core.ctfadaptor;
15
16import org.eclipse.linuxtools.ctf.core.event.CTFCallsite;
f47ed727 17import org.eclipse.linuxtools.tmf.core.event.lookup.TmfCallsite;
60fb38b8
PT
18
19/**
f47ed727
BH
20 * CTF TMF call site information for source code lookup.
21 *
22 * @author Patrick Tasse
60fb38b8
PT
23 * @since 2.0
24 */
f47ed727
BH
25public 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;
60fb38b8 36
f47ed727
BH
37 // ------------------------------------------------------------------------
38 // Constructors
39 // ------------------------------------------------------------------------
60fb38b8 40
f47ed727
BH
41 /**
42 * Standard Constructor.
43 *
44 * @param callsite
45 * - a CTF call site
46 */
60fb38b8 47 CtfTmfCallsite(CTFCallsite callsite) {
f47ed727
BH
48 super(callsite.getFileName(), callsite.getFunctionName(), callsite.getLineNumber());
49 fEventName = callsite.getEventName();
50 fInstructionPointer = callsite.getIp();
60fb38b8
PT
51 }
52
f47ed727
BH
53 // ------------------------------------------------------------------------
54 // Accessors
55 // ------------------------------------------------------------------------
56
60fb38b8 57 /**
f47ed727 58 * Returns the event name of the call site.
60fb38b8
PT
59 * @return the event name
60 */
61 public String getEventName() {
f47ed727 62 return fEventName;
60fb38b8
PT
63 }
64
65 /**
f47ed727
BH
66 * Returns the instruction pointer of the call site.
67 * @return the instruction pointer
60fb38b8 68 */
f47ed727
BH
69 public long getIntructionPointer() {
70 return fInstructionPointer;
60fb38b8
PT
71 }
72
f47ed727
BH
73 // ------------------------------------------------------------------------
74 // Accessors
75 // ------------------------------------------------------------------------
60fb38b8 76
f47ed727
BH
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;
60fb38b8
PT
84 }
85
f47ed727
BH
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;
60fb38b8
PT
109 }
110
111 @Override
112 public String toString() {
f47ed727
BH
113 return getEventName() + "@0x" + Long.toHexString(fInstructionPointer) + ": " + //$NON-NLS-1$ //$NON-NLS-2$
114 getFileName() + ':' + Long.toString(getLineNumber()) + ' ' + getFileName() + "()"; //$NON-NLS-1$
60fb38b8
PT
115 }
116}
This page took 0.051385 seconds and 5 git commands to generate.