1 /*******************************************************************************
2 * Copyright (c) 2012 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 * The callsite constructor
32 * the instruction pointer of the callsite
34 * the file name of the callsite
36 * the line number of the callsite
38 public CTFCallsite(String en
, String func
, long ip
, String fn
, long line
) {
43 this.LineNumber
= line
;
46 static private final long MASK32
= 0x00000000ffffffffL
;
50 private final String EventName
;
52 * the file name of the callsite
54 private final String FileName
;
56 * the instruction pointer
58 private final long ip
;
62 private final String FunctionName
;
64 * the line number of the callsite
66 private final long LineNumber
;
70 * @return the eventName
72 public String
getEventName() {
77 * @return the fileName
79 public String
getFileName() {
91 * @return the functionName
93 public String
getFunctionName() {
98 * @return the lineNumber
100 public long getLineNumber() {
105 * The callsites will be sorted by calling addresses. To do this we take IPs
106 * (instruction pointers) and compare them. Java only supports signed
107 * operation and since memory addresses are unsigned, we will convert the
108 * longs into integers that contain the high and low bytes and compare them.
111 public int compareTo(CTFCallsite o
) {
113 * mask32 is 32 zeros followed by 32 ones, when we bitwise and this it
114 * will return the lower 32 bits
119 * To get a high int: we downshift by 32 and bitwise and with the mask
120 * to get rid of the sign
122 * To get the low int: we bitwise and with the mask.
124 long otherHigh
= (other
>> 32) & MASK32
;
125 long otherLow
= other
& MASK32
;
126 long ownHigh
= (ip
>> 32) & MASK32
;
127 long ownLow
= ip
& MASK32
;
128 /* are the high values different, if so ignore the lower values */
129 if (ownHigh
> otherHigh
) {
132 if (ownHigh
< otherHigh
) {
135 /* the high values are the same, compare the lower values */
136 if (ownLow
> otherLow
) {
139 if (ownLow
< otherLow
) {
142 /* the values are identical */
150 * @see java.lang.Object#toString()
153 public String
toString() {
154 return FileName
+ "/" + FunctionName
+ ":" + LineNumber
; //$NON-NLS-1$ //$NON-NLS-2$
This page took 0.036153 seconds and 6 git commands to generate.