3b6adc47cdd0c6ecaecf11da5b682b5bd6c2a5fa
1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
10 * Matthew Khouzam - Initial API and implementation
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.ctf
.core
.event
;
17 * Callsite information to help with cdt integration
19 * @author Matthew Khouzam
23 public class CTFCallsite
implements Comparable
<CTFCallsite
> {
26 private static final int INT_BITS
= Integer
.SIZE
;
28 // a bitmask for the size of an integer
29 private static final long INT_MASK
= (1L << INT_BITS
) - 1;
34 private final String fEventName
;
37 * the file name of the callsite
39 private final String fFileName
;
42 * the instruction pointer
44 private final long fIp
;
49 private final String fFunctionName
;
52 * the line number of the callsite
54 private final long fLineNumber
;
57 * The callsite constructor
64 * the instruction pointer of the callsite
66 * the file name of the callsite
68 * the line number of the callsite
70 public CTFCallsite(String en
, String func
, long ip
, String fn
, long line
) {
79 * @return the eventName
81 public String
getEventName() {
86 * @return the fileName
88 public String
getFileName() {
100 * @return the functionName
102 public String
getFunctionName() {
103 return fFunctionName
;
107 * @return the lineNumber
109 public long getLineNumber() {
114 * The callsites will be sorted by calling addresses. To do this we take IPs
115 * (instruction pointers) and compare them. Java only supports signed
116 * operation and since memory addresses are unsigned, we will convert the
117 * longs into integers that contain the high and low bytes and compare them.
120 public int compareTo(CTFCallsite o
) {
122 * mask32 is 32 zeros followed by 32 ones, when we bitwise and this it
123 * will return the lower 32 bits
128 * To get a high int: we downshift by 32 and bitwise and with the mask
129 * to get rid of the sign
131 * To get the low int: we bitwise and with the mask.
133 long otherHigh
= (other
>> INT_BITS
) & INT_MASK
;
134 long otherLow
= other
& INT_MASK
;
135 long ownHigh
= (fIp
>> INT_BITS
) & INT_MASK
;
136 long ownLow
= fIp
& INT_MASK
;
137 /* are the high values different, if so ignore the lower values */
138 if (ownHigh
> otherHigh
) {
141 if (ownHigh
< otherHigh
) {
144 /* the high values are the same, compare the lower values */
145 if (ownLow
> otherLow
) {
148 if (ownLow
< otherLow
) {
151 /* the values are identical */
156 public int hashCode() {
157 final int prime
= 31;
159 result
= prime
* result
+ ((fEventName
== null) ?
0 : fEventName
.hashCode());
160 result
= prime
* result
+ ((fFileName
== null) ?
0 : fFileName
.hashCode());
161 result
= prime
* result
+ ((fFunctionName
== null) ?
0 : fFunctionName
.hashCode());
162 result
= prime
* result
+ (int) (fIp ^
(fIp
>>> 32));
163 result
= prime
* result
+ (int) (fLineNumber ^
(fLineNumber
>>> 32));
168 public boolean equals(Object obj
) {
175 if (getClass() != obj
.getClass()) {
178 CTFCallsite other
= (CTFCallsite
) obj
;
179 if (fEventName
== null) {
180 if (other
.fEventName
!= null) {
183 } else if (!fEventName
.equals(other
.fEventName
)) {
186 if (fFileName
== null) {
187 if (other
.fFileName
!= null) {
190 } else if (!fFileName
.equals(other
.fFileName
)) {
193 if (fFunctionName
== null) {
194 if (other
.fFunctionName
!= null) {
197 } else if (!fFunctionName
.equals(other
.fFunctionName
)) {
200 if (fIp
!= other
.fIp
) {
203 if (fLineNumber
!= other
.fLineNumber
) {
210 public String
toString() {
211 return fFileName
+ "/" + fFunctionName
+ ":" + fLineNumber
; //$NON-NLS-1$ //$NON-NLS-2$
This page took 0.036017 seconds and 5 git commands to generate.