sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi.call/src/com/nokia/carbide/cpp/pi/call/GfcSample.java
changeset 2 b9ab3b238396
child 5 844b047e260d
equal deleted inserted replaced
1:1050670c6980 2:b9ab3b238396
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: 
       
    15  *
       
    16  */
       
    17 
       
    18 package com.nokia.carbide.cpp.pi.call;
       
    19 
       
    20 import java.util.Vector;
       
    21 
       
    22 import com.nokia.carbide.cpp.internal.pi.analyser.NpiInstanceRepository;
       
    23 import com.nokia.carbide.cpp.internal.pi.model.Function;
       
    24 import com.nokia.carbide.cpp.internal.pi.model.FunctionResolver;
       
    25 import com.nokia.carbide.cpp.internal.pi.model.GenericSampleWithFunctions;
       
    26 import com.nokia.carbide.cpp.internal.pi.model.ParsedTraceData;
       
    27 import com.nokia.carbide.cpp.internal.pi.model.TraceDataRepository;
       
    28 import com.nokia.carbide.cpp.pi.address.GppSample;
       
    29 import com.nokia.carbide.cpp.pi.address.GppTrace;
       
    30 
       
    31 
       
    32 public class GfcSample extends GenericSampleWithFunctions
       
    33 {
       
    34   private static final long serialVersionUID =  4293607815033391377L;
       
    35   
       
    36   private static transient Vector gppSamples = null;
       
    37  
       
    38   public long programCounter;
       
    39   public long linkRegister;
       
    40   public long sampleNumber;
       
    41 
       
    42   public Function callerFunctionSym;
       
    43   public Function currentFunctionSym;
       
    44   
       
    45   public Function callerFunctionItt;
       
    46   public Function currentFunctionItt;
       
    47   
       
    48   public GfcSample(long programCounter, long linkRegister, long sampleNumber, long sampleSynchTime)
       
    49   {
       
    50     this.programCounter = programCounter;
       
    51     this.linkRegister = linkRegister;
       
    52     this.sampleNumber = sampleNumber;
       
    53     this.sampleSynchTime = sampleSynchTime;
       
    54   }
       
    55 
       
    56   public void resolveFunction(FunctionResolver res)
       
    57   {
       
    58 	  if (res.getResolverName().equals("Symbol")) //$NON-NLS-1$
       
    59 	  {
       
    60 		  this.callerFunctionSym  = res.findFunctionForAddress(linkRegister);
       
    61 		  int index = (int)this.sampleNumber;
       
    62 		  if (gppSamples != null && index < gppSamples.size()) {
       
    63 			  GppSample gppSample = (GppSample)gppSamples.get(index);
       
    64 			  if (gppSample.programCounter == programCounter)
       
    65 				  this.currentFunctionSym = gppSample.currentFunctionSym;
       
    66 			  else
       
    67 				  this.currentFunctionSym = res.findFunctionForAddress(programCounter);
       
    68 		  } else
       
    69 			  this.currentFunctionSym = res.findFunctionForAddress(programCounter);		  
       
    70 	  }
       
    71 	  else if (res.getResolverName().equals("ITT")) //$NON-NLS-1$
       
    72 	  {
       
    73 		  if (this.callerFunctionSym == null)
       
    74 			  this.callerFunctionItt  = res.findFunctionForAddress(linkRegister);
       
    75 		  if (this.currentFunctionSym == null) {
       
    76 			  GppSample gppSample = (GppSample)gppSamples.get((int)this.sampleNumber);
       
    77 			  if (gppSample.programCounter == programCounter)
       
    78 				  this.currentFunctionItt = gppSample.currentFunctionItt;
       
    79 			  else
       
    80 				  this.currentFunctionItt = res.findFunctionForAddress(programCounter);		  
       
    81 		  }
       
    82 	  }
       
    83   }
       
    84   
       
    85   public String toString()
       
    86   {
       
    87   	return "Gfc:#" + this.sampleSynchTime //$NON-NLS-1$
       
    88   			+ " @0x" + Long.toHexString(this.programCounter) //$NON-NLS-1$
       
    89   			+ " fS:" //$NON-NLS-1$
       
    90   			+ ((this.currentFunctionSym == null || (this.currentFunctionSym.functionName == null)) ? "" : this.currentFunctionSym.functionName) //$NON-NLS-1$
       
    91   			+ " cS:" //$NON-NLS-1$
       
    92   			+ ((this.callerFunctionSym  == null || (this.callerFunctionSym.functionName  == null)) ? "" : this.callerFunctionSym.functionName); //$NON-NLS-1$
       
    93   }
       
    94   
       
    95   public static void setAddressTraceSamples() {
       
    96 	  ParsedTraceData traceData = TraceDataRepository.getInstance().getTrace(NpiInstanceRepository.getInstance().activeUid(), GppTrace.class);
       
    97 	  if (traceData != null && traceData.traceData != null && (traceData.traceData instanceof GppTrace))
       
    98 		  gppSamples = ((GppTrace)traceData.traceData).samples; //$NON-NLS-1$
       
    99   }
       
   100 }