#include #include "Profile/Profiler.h" #include "Profile/TauJAPI.h" #include "Profile/TauJava.h" #ifdef TAU_DOT_H_LESS_HEADERS #include using namespace std; #else /* TAU_DOT_H_LESS_HEADERS */ #include #endif /* TAU_DOT_H_LESS_HEADERS */ /* * Class: Profile * Method: NativeProfile * Signature: (Ljava/lang/String;Ljava/lang/String;J)V */ JNIEXPORT void JNICALL Java_TAU_Profile_NativeProfile (JNIEnv *env, jobject obj, jstring name, jstring type, jstring groupname, jlong group) { /* Get name and type strings from the JVM */ const char *blockName = env->GetStringUTFChars(name, 0); const char *blockType = env->GetStringUTFChars(type, 0); const char *blockGroup = env->GetStringUTFChars(groupname, 0); /* create a new FunctionInfo object by passing these to it */ FunctionInfo *f = new FunctionInfo(blockName, blockType, (TauGroup_t) group, blockGroup, true); /* true indicates InitData will ensure that all data is clean */ /* Now release the strings back to the JVM */ env->ReleaseStringUTFChars(name, blockName); env->ReleaseStringUTFChars(type, blockType); env->ReleaseStringUTFChars(groupname, blockGroup); /* Find the field FuncInfoPtr in the Profile class where we need to store the address of the FunctionInfo object just created */ jclass cls = env->GetObjectClass(obj); jfieldID fid = env->GetFieldID(cls, "FuncInfoPtr", "J"); /* Check if new was successful */ if (f == (FunctionInfo *) NULL) { cout << "ERROR: FunctionInfo new returns NULL: Memory problem"<SetLongField(obj, fid, (jlong) f); DEBUGPROFMSG("Java_Profile_NativeProfile: FunctionInfoPtr set to "<GetObjectClass(obj); jfieldID fid; FunctionInfo *f; fid = env->GetFieldID(cls, "FuncInfoPtr", "J"); f = (FunctionInfo *) env->GetLongField(obj, fid); TAU_PROFILE_START(f); } /* * Class: Profile * Method: NativeStop * Signature: ()V */ JNIEXPORT void JNICALL Java_TAU_Profile_NativeStop (JNIEnv * env, jobject obj) { TAU_GLOBAL_TIMER_STOP(); } /* EOF Profile.cpp */ /*************************************************************************** * $RCSfile: TauJAPI.cpp,v $ $Author: amorris $ * $Revision: 1.3 $ $Date: 2009/02/19 20:08:29 $ * TAU_VERSION_ID: $Id: TauJAPI.cpp,v 1.3 2009/02/19 20:08:29 amorris Exp $ ***************************************************************************/