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
.linuxtools
.ctf
.core
.event
;
17 * Callsite information to help with cdt integration
19 * @author Matthew Khouzam
23 public class CTFCallsite
implements Comparable
<CTFCallsite
> {
25 private static final long MASK32
= 0x00000000ffffffffL
;
30 private final String fEventName
;
33 * the file name of the callsite
35 private final String fFileName
;
38 * the instruction pointer
40 private final long fIp
;
45 private final String fFunctionName
;
48 * the line number of the callsite
50 private final long fLineNumber
;
53 * The callsite constructor
60 * the instruction pointer of the callsite
62 * the file name of the callsite
64 * the line number of the callsite
66 public CTFCallsite(String en
, String func
, long ip
, String fn
, long line
) {
75 * @return the eventName
77 public String
getEventName() {
82 * @return the fileName
84 public String
getFileName() {
96 * @return the functionName
98 public String
getFunctionName() {
103 * @return the lineNumber
105 public long getLineNumber() {
110 * The callsites will be sorted by calling addresses. To do this we take IPs
111 * (instruction pointers) and compare them. Java only supports signed
112 * operation and since memory addresses are unsigned, we will convert the
113 * longs into integers that contain the high and low bytes and compare them.
116 public int compareTo(CTFCallsite o
) {
118 * mask32 is 32 zeros followed by 32 ones, when we bitwise and this it
119 * will return the lower 32 bits
124 * To get a high int: we downshift by 32 and bitwise and with the mask
125 * to get rid of the sign
127 * To get the low int: we bitwise and with the mask.
129 long otherHigh
= (other
>> 32) & MASK32
;
130 long otherLow
= other
& MASK32
;
131 long ownHigh
= (fIp
>> 32) & MASK32
;
132 long ownLow
= fIp
& MASK32
;
133 /* are the high values different, if so ignore the lower values */
134 if (ownHigh
> otherHigh
) {
137 if (ownHigh
< otherHigh
) {
140 /* the high values are the same, compare the lower values */
141 if (ownLow
> otherLow
) {
144 if (ownLow
< otherLow
) {
147 /* the values are identical */
152 public String
toString() {
153 return fFileName
+ "/" + fFunctionName
+ ":" + fLineNumber
; //$NON-NLS-1$ //$NON-NLS-2$
This page took 0.033761 seconds and 5 git commands to generate.