/**************************************************************************** ** TAU Portable Profiling Package ** ** http://www.cs.uoregon.edu/research/tau ** ***************************************************************************** ** Copyright 1997 ** ** Department of Computer and Information Science, University of Oregon ** ** Advanced Computing Laboratory, Los Alamos National Laboratory ** ****************************************************************************/ /*************************************************************************** ** File : FunctionInfo.cpp ** ** Description : TAU Profiling Package ** * Contact : tau-team@cs.uoregon.edu ** ** Documentation : See http://www.cs.uoregon.edu/research/tau ** ***************************************************************************/ ////////////////////////////////////////////////////////////////////// // Include Files ////////////////////////////////////////////////////////////////////// #include "Profile/Profiler.h" #include #ifdef TAU_DOT_H_LESS_HEADERS #include using namespace std; #else /* TAU_DOT_H_LESS_HEADERS */ #include #endif /* TAU_DOT_H_LESS_HEADERS */ #include #include #include #include #if (!defined(TAU_WINDOWS)) #include #else #include #endif //TAU_WINDOWS #ifdef TAU_VAMPIRTRACE #include #else /* TAU_VAMPIRTRACE */ #ifdef TAU_EPILOG #include "elg_trc.h" #endif /* TAU_EPILOG */ #endif /* TAU_VAMPIRTRACE */ #ifdef TAU_SILC #include #endif #include #include #include ////////////////////////////////////////////////////////////////////// // The purpose of this subclass of vector is to give us a chance to execute // some code when TheFunctionDB is destroyed. For Dyninst, this is necessary // when running with fortran programs ////////////////////////////////////////////////////////////////////// class FIvector : public vector { public: ~FIvector() { Tau_destructor_trigger(); } }; ////////////////////////////////////////////////////////////////////// // Instead of using a global var., use static inside a function to // ensure that non-local static variables are initialised before being // used (Ref: Scott Meyers, Item 47 Eff. C++). ////////////////////////////////////////////////////////////////////// vector& TheFunctionDB(void) { // FunctionDB contains pointers to each FunctionInfo static object // we now use the above FIvector, which subclasses vector //static vector FunctionDB; static FIvector FunctionDB; static int flag = 1; if (flag) { flag = 0; Tau_init_initializeTAU(); } return FunctionDB; } ////////////////////////////////////////////////////////////////////// // It is not safe to call Profiler::StoreData() after // FunctionInfo::~FunctionInfo has been called as names are null ////////////////////////////////////////////////////////////////////// int& TheSafeToDumpData() { static int SafeToDumpData=1; return SafeToDumpData; } ////////////////////////////////////////////////////////////////////// // Set when uning Dyninst ////////////////////////////////////////////////////////////////////// int& TheUsingDyninst() { static int UsingDyninst=0; return UsingDyninst; } ////////////////////////////////////////////////////////////////////// // Set when uning Compiler Instrumentation ////////////////////////////////////////////////////////////////////// int& TheUsingCompInst() { static int UsingCompInst=0; return UsingCompInst; } ////////////////////////////////////////////////////////////////////// // Member Function Definitions For class FunctionInfo ////////////////////////////////////////////////////////////////////// static char *strip_tau_group(const char *ProfileGroupName) { char *source = strdup(ProfileGroupName); const char *find = "TAU_GROUP_"; char *ptr; while (ptr = strstr(source,find)) { char *endptr = ptr+strlen(find); while (*endptr != '\0') { *ptr++ = *endptr++; } } return source; } ////////////////////////////////////////////////////////////////////// // FunctionInfoInit is called by all four forms of FunctionInfo ctor ////////////////////////////////////////////////////////////////////// void FunctionInfo::FunctionInfoInit(TauGroup_t ProfileGroup, const char *ProfileGroupName, bool InitData, int tid) { /* Make sure TAU is initialized */ static int flag = 1; if (flag) { flag = 0; Tau_init_initializeTAU(); } Tau_global_incr_insideTAU_tid(tid); //Need to keep track of all the groups this function is a member of. AllGroups = strip_tau_group(ProfileGroupName); GroupName = strdup(RtsLayer::PrimaryGroup(AllGroups).c_str()); // Since FunctionInfo constructor is called once for each function (static) // we know that it couldn't be already on the call stack. RtsLayer::LockDB(); // Use LockDB to avoid a possible race condition. //Add function name to the name list. TauProfiler_theFunctionList(NULL, NULL, true, (const char *)GetName()); if (InitData) { for (int i=0; i < TAU_MAX_THREADS; i++) { NumCalls[i] = 0; SetAlreadyOnStack(false, i); NumSubrs[i] = 0; for(int j=0;j 0 && strcmp(GetType()," ") != 0) { ostr << GetName() << " " << GetType() << ":GROUP:" << GetAllGroups(); } else { ostr << GetName() << ":GROUP:" << GetAllGroups(); } FullName = new string; string tmpstr = ostr.str(); char *tmp = strdup(tmpstr.c_str()); tmp = Tau_util_removeRuns(tmp); *FullName = tmp; } return FullName; } /*************************************************************************** * $RCSfile: FunctionInfo.cpp,v $ $Author: amorris $ * $Revision: 1.84 $ $Date: 2010/04/27 23:13:55 $ * VERSION_ID: $Id: FunctionInfo.cpp,v 1.84 2010/04/27 23:13:55 amorris Exp $ ***************************************************************************/