libjboss-profiler-java-1.0.CR4.orig/0000755000175000017500000000000010463347662017217 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/readme.txt0000644000175000017500000000672310462070354021213 0ustar twernertwerner readme.txt - $Version$ This is a simple tutorial on using the JBoss Profiler. LICENSING This software is distributed under the terms of the LGPL license. BUILDING THE PROFILER 1. Build using ant. The built files will appear under the build/ directory. 2. To compile the native library (DLL or .so), you have to use gcc. Under Windows use Cygwin with gcc installed and run the compile.sh script in the native/win32 directory. Under Linux/Unix, run the compile.sh script in the native/linux or native/solaris directory. INSTALLATION 1. Once built, put jbossInspector.dll in your PATH (if you are using Windows) or libjbossInspector.so in your LD_LIBRARY_PATH (if you are using Linux/Unix.) 2. Copy the jboss-profiler.war file on your analysis system. Deploy under a standard web container. The jboss-provider.war file provides a front-end for analysis. When loaded, the front-end keeps the profile data loaded entirely in memory. You may have to allocate extra memory for the web container. (There is a class named "FileCollection" which uses the Tomcat's temporary file system as a virtual memory buffer. You might want to clean that directory after running Jboss Profiler.) USING THE PROFILER 1. Add the -XrunjbossInspector:, as a parameter to your JVM. (Sun's or IBM's JVM) Possible options include: start= include= ignore= socket=: uniqueNames=true Useful for running test cases wakeupOnStartup=true Start the profiler always after the JVM start This option is used to be used in conjunction with dpConsole.jar. If you use that option you have to include dpConsole.jar on the class-path of your application server. memory=true|false (default=true) Disable the memory profiler. If this options is disable the profiler wouldn't capture any allocations events during data gathering Example use: java -XrunjbossInspector:/tmp,include=org.jboss,ignore=*,start=org.jboss.mq.MQServer These options only capture data for org.jboss classes (everything else is ignored with the ignore=* option). The "start" option will capture data only after org.jboss.mq.MQServer appears on your stack trace. When running under JBoss, you can set the environment variable JAVA_OPTS to this parameter. Example use under Unix: $ export JAVA_OPTS=-XrunjbossInspector:/tmp,include=org.ex,ignore=*,start=org.ex.Main 2. Start the data capturing. The profiler sleeps until you send a signal. If you use Sun's JVM, send a signal using "kill -3" to start and another "kill -3" to finish capturing. (You have only one shot, as you can use start option to tell what you need to profile). CTRL-BREAK on Windows also sends the same signal. If you use IBM's JVM, use the option socket=server:port (e.g. localhost:1000). Before starting your JVM, execute: java -jar dpConsole.jar 1000 Then tell the dpConsole.jar what PID you want to signal to start. Alternatively, if you're running the profiler under JBoss, you can deploy either jboss-profiler-noAOP.sar or jboss-profiler.sar and stop, start, pause the data capturing through JMX and the JMX console. The MBean has the javax.management.ObjectName jboss.profiler:mbean=Native-profiler . [TODO : discuss use of AOP capturing] 3. After you have captured your .log.gz files you have to process them by using the front-end application. Access the analysis tool you installed previously. libjboss-profiler-java-1.0.CR4.orig/jvmpi/0000755000175000017500000000000010463347662020344 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmpi-src/0000755000175000017500000000000010463347662021131 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmpi-src/linux/0000755000175000017500000000000010462072616022261 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmpi-src/linux/compile.sh0000644000175000017500000000147710462070354024253 0ustar twernertwerner#!/bin/sh rm -f *.so rm -f *.dll rm -f *.o _INCLUDES="-I$JAVA_HOME/include -I$JAVA_HOME/include/linux -I../src/zlib" _OPTS="" # cd ./bin gcc $_OPTS $_INCLUDES -c ../src/zlib/adler32.c gcc $_OPTS $_INCLUDES -c ../src/zlib/compress.c gcc $_OPTS $_INCLUDES -c ../src/zlib/crc32.c gcc $_OPTS $_INCLUDES -c ../src/zlib/gzio.c gcc $_OPTS $_INCLUDES -c ../src/zlib/uncompr.c gcc $_OPTS $_INCLUDES -c ../src/zlib/deflate.c gcc $_OPTS $_INCLUDES -c ../src/zlib/trees.c gcc $_OPTS $_INCLUDES -c ../src/zlib/zutil.c gcc $_OPTS $_INCLUDES -c ../src/zlib/inflate.c gcc $_OPTS $_INCLUDES -c ../src/zlib/infback.c gcc $_OPTS $_INCLUDES -c ../src/zlib/inftrees.c gcc $_OPTS $_INCLUDES -c ../src/zlib/inffast.c g++ $_INCLUDES -D ZLIB -D LOOKUP_OBJ -D USE_SOCKETS $_OPTS -shared -o libjbossInspector.so ../src/jbossInspector.cc *.o libjboss-profiler-java-1.0.CR4.orig/jvmpi-src/linux64/0000755000175000017500000000000010462070270022425 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmpi-src/linux64/compile.sh0000644000175000017500000000173510462070354024422 0ustar twernertwerner#!/bin/sh rm -f *.so rm -f *.dll rm -f *.o _INCLUDES="-I$JAVA_HOME/include -I$JAVA_HOME/include/linux -I../src/zlib" # cd ./bin gcc $_OPTS $_INCLUDES -m64 -fpic -c ../src/zlib/adler32.c gcc $_OPTS $_INCLUDES -m64 -fpic -c ../src/zlib/compress.c gcc $_OPTS $_INCLUDES -m64 -fpic -c ../src/zlib/crc32.c gcc $_OPTS $_INCLUDES -m64 -fpic -c ../src/zlib/gzio.c gcc $_OPTS $_INCLUDES -m64 -fpic -c ../src/zlib/uncompr.c gcc $_OPTS $_INCLUDES -m64 -fpic -c ../src/zlib/deflate.c gcc $_OPTS $_INCLUDES -m64 -fpic -c ../src/zlib/trees.c gcc $_OPTS $_INCLUDES -m64 -fpic -c ../src/zlib/zutil.c gcc $_OPTS $_INCLUDES -m64 -fpic -c ../src/zlib/inflate.c gcc $_OPTS $_INCLUDES -m64 -fpic -c ../src/zlib/infback.c gcc $_OPTS $_INCLUDES -m64 -fpic -c ../src/zlib/inftrees.c gcc $_OPTS $_INCLUDES -m64 -fpic -c ../src/zlib/inffast.c g++ $_INCLUDES -m64 -fpic -D ZLIB -D LOOKUP_OBJ -D USE_SOCKETS $_OPTS -shared -o libjbossInspector.so ../src/jbossInspector.cc *.o libjboss-profiler-java-1.0.CR4.orig/jvmpi-src/macos/0000755000175000017500000000000010462070270022216 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmpi-src/macos/compile.sh0000644000175000017500000000140510462070354024205 0ustar twernertwerner#!/bin/sh rm -f *.jnilib rm -f *.o _INCLUDES="-I$JAVA_HOME/include -I../src/zlib" gcc $_OPTS $_INCLUDES -c ../src/zlib/adler32.c gcc $_OPTS $_INCLUDES -c ../src/zlib/compress.c gcc $_OPTS $_INCLUDES -c ../src/zlib/crc32.c gcc $_OPTS $_INCLUDES -c ../src/zlib/gzio.c gcc $_OPTS $_INCLUDES -c ../src/zlib/uncompr.c gcc $_OPTS $_INCLUDES -c ../src/zlib/deflate.c gcc $_OPTS $_INCLUDES -c ../src/zlib/trees.c gcc $_OPTS $_INCLUDES -c ../src/zlib/zutil.c gcc $_OPTS $_INCLUDES -c ../src/zlib/inflate.c gcc $_OPTS $_INCLUDES -c ../src/zlib/infback.c gcc $_OPTS $_INCLUDES -c ../src/zlib/inftrees.c gcc $_OPTS $_INCLUDES -c ../src/zlib/inffast.c g++ -O0 -bundle $_INCLUDES -DZLIB -DLOOKUP_OBJ -DUSE_SOCKETS -o libjbossInspector.jnilib ../src/jbossInspector.cc *.o libjboss-profiler-java-1.0.CR4.orig/jvmpi-src/solaris/0000755000175000017500000000000010462073520022571 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmpi-src/solaris/bin/0000755000175000017500000000000010462070354023343 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmpi-src/solaris/CC-compile.sh0000644000175000017500000000151610462073454025051 0ustar twernertwerner#!/bin/sh rm -f *.so rm -f *.dll rm -f *.o _INCLUDES="-I$JAVA_HOME/include -I$JAVA_HOME/include/solaris -I../../src/zlib" cd ./bin cc $_OPTS $_INCLUDES -c ../../src/zlib/adler32.c cc $_OPTS $_INCLUDES -c ../../src/zlib/compress.c cc $_OPTS $_INCLUDES -c ../../src/zlib/crc32.c cc $_OPTS $_INCLUDES -c ../../src/zlib/gzio.c cc $_OPTS $_INCLUDES -c ../../src/zlib/uncompr.c cc $_OPTS $_INCLUDES -c ../../src/zlib/deflate.c cc $_OPTS $_INCLUDES -c ../../src/zlib/trees.c cc $_OPTS $_INCLUDES -c ../../src/zlib/zutil.c cc $_OPTS $_INCLUDES -c ../../src/zlib/inflate.c cc $_OPTS $_INCLUDES -c ../../src/zlib/infback.c cc $_OPTS $_INCLUDES -c ../../src/zlib/inftrees.c cc $_OPTS $_INCLUDES -c ../../src/zlib/inffast.c CC $_INCLUDES -D ZLIB -D LOOKUP_OBJ -D USE_SOCKETS $_OPTS -G -o libjbossInspector.so ../../src/jbossInspector.cc *.o libjboss-profiler-java-1.0.CR4.orig/jvmpi-src/solaris/compile.sh0000644000175000017500000000153310432020344024550 0ustar twernertwerner#!/bin/sh rm -f *.so rm -f *.dll rm -f *.o _INCLUDES="-I$JAVA_HOME/include -I$JAVA_HOME/include/solaris -I../../src/zlib" cd ./bin gcc $_OPTS $_INCLUDES -c ../../src/zlib/adler32.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/compress.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/crc32.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/gzio.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/uncompr.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/deflate.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/trees.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/zutil.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/inflate.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/infback.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/inftrees.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/inffast.c g++ $_INCLUDES -D ZLIB -D LOOKUP_OBJ -D USE_SOCKETS $_OPTS -G -o libjbossInspector.so ../../src/jbossInspector.cc *.o libjboss-profiler-java-1.0.CR4.orig/jvmpi-src/src/0000755000175000017500000000000010462072420021702 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmpi-src/src/jbossInspector.cc0000644000175000017500000017006710462073656025247 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ // This is a simple JVMPI implementation, supposed to be fast enought to run on any production environment when you // have a BigDeal to discover into production. // The intent of that is to discover when Thread birth and when Thread die. // The second intent is to find bottlenecks into production systems // Author is Clebert Suconic // E-mail of author now is clebert.suconic@jboss.com // 11-apr-2003 // $Id: jbossInspector.cc,v 1.5 2006/07/27 16:16:54 csuconic Exp $ #include #include #include #include #include #ifdef WINDOWS #include #include #else #include #include #endif #include #include #include #ifdef ZLIB extern "C" { #include } #endif #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE 1 #endif // DEFINES FOR CONTROL OF EXECUTION #define IN_IGNORE_LIST 1 #define IN_START_LIST 2 #define IN_INCLUDE_LIST 3 // DEFINES FOR CONTROL OF CLASS-LOADING #define CLASS_UNLOADED 0 #define CLASS_LOADED 1 #define CLASS_NEEDS_LOAD 2 // JNI implementation #include "org_jboss_profiler_threadcheck_StartupProfilerCheck.h" #ifdef CYGWIN #define WINDOWS #endif void startConsoleCheck(char * pendereco, jlong ppid); // global jvmpi interface pointer static JVMPI_Interface *jvmpi_interface; static JNIEnv * jni_interface; #define CALL(f) (jvmpi_interface->f) // codigo extraido da JVM (para fazer um sysTimeMillis da mesma forma #ifdef WINDOWS #define FT2INT64(ft) ((jlong)(ft).dwHighDateTime << 32 | (jlong)(ft).dwLowDateTime) jlong sysTimeMillis(void) { static jlong fileTime_1_1_70 = 0; SYSTEMTIME st0; FILETIME ft0; if (fileTime_1_1_70 == 0) { /* Initialize fileTime_1_1_70 -- the Win32 file time of midnight * 1/1/70. */ memset(&st0, 0, sizeof(st0)); st0.wYear = 1970; st0.wMonth = 1; st0.wDay = 1; SystemTimeToFileTime(&st0, &ft0); fileTime_1_1_70 = FT2INT64(ft0); } GetSystemTime(&st0); SystemTimeToFileTime(&st0, &ft0); return (FT2INT64(ft0) - fileTime_1_1_70) / 10000; } #else jlong sysTimeMillis() { struct timeval t; gettimeofday(&t, 0); return ((jlong)t.tv_sec) * 1000 + (jlong)(t.tv_usec/1000); } #endif #ifdef COUNT_METHODS static int enterMethods=0; static int exitMethods=0; #endif struct _objInformation { jobjectID obj; void * objData; struct _objInformation * next; }; // utilizado para controlar o nome dos arquivos abertos por thread struct _filesInfo{ char nomeArquivo[1024]; void * fileHandler; // poder tanto faz ser um gzipFile ou FILE * }; typedef struct _filesInfo FilesInfo; /*struct _objLinkedList { struct _objInformation * root; struct _objInformation * end; }; */ typedef std::map ObjInfo; /* Linked list used to handle classLoading*/ static ObjInfo linkedListClasses; static ObjInfo linkedListThreads; JVMPI_RawMonitor list_mutex_t=NULL; static std::vector< void * > linkedListFiles; // para poder execura flush corretamente (principalmente quando se tratar de gzip) static jlong startTime; static jlong execTime; // -1 means that the load was not called static int profilerRunning=-1; // if true, the profiler will be started just after the JVM Load static int wakeupOnStartup=0; static int profileMemory=1; // para garantir sincronia entre as chamadas JVMPI_RawMonitor profileChangeLock; void changeProfiller(); static FILE * logfile = NULL; static jlong pid = 0; static char parametroSocket[255]; static int usingSockets=0; // Start List is a list where we will start to gathering information. The use of that list is optional. static int usingStartList=0; // ClassInfo about the thread struct _classInfo { // If is in ignoreList, we would stop gathering information for that thread int isInIgnoreList; // If is in startList, and if we are using a startList, we would start gathering information for that thread int isInStartList; // Controls if the class is on includeList or not. int isInIncludeList; // IgnoredList are not loaded into files at the first time. But if a object is loaded, it may be necessary int isLoaded; char * className; }; // a list can be class or package names char ** ignoreList=NULL; int * strLenOnIgnoreList; int ignoreListSize; // a list can be class or package names char ** startList=NULL; int * strLenOnStartList; int startListSize; // a list can be class or package names char ** includeList=NULL; int * strLenOnIncludeList; int includeListSize; //for transaction tracer static int transactionTracer = 0; void loadIgnoreList(int nparametros, char ** parametros) { ignoreListSize=0; startListSize=0; includeListSize=0; for (int i=0;izCont=0; return file; } inline int gzwritelocal (gzFile file,voidp buf, unsigned len, const char * msg) { if (gzwritelock) { //fprintf (logfile,"\n\n\n\n*******************************************************\nRealizando uma chamada a gzwrite quando nao deveria em %s\n\n\n\n",msg); fflush(logfile); return Z_OK; } int retValue = gzwrite(file,buf,len); if (retValue==0) { fflush(logfile); } return retValue; } #endif // retorna o node incluido void addObj(ObjInfo& linkedList, jobjectID obj, void * objData) { jvmpi_interface->RawMonitorEnter(list_mutex_t); linkedList.insert( std::make_pair(obj,objData) ); jvmpi_interface->RawMonitorExit(list_mutex_t); } void debugFiles() { std::vector::iterator p; fprintf (logfile,"**************** files debug information *********************\n"); for (p=linkedListFiles.begin();p!=linkedListFiles.end();p++) { FilesInfo* fileInfo = (FilesInfo *) *p; if (fileInfo->fileHandler!=NULL) { fprintf (logfile,"File %s (not closed yet)\n",fileInfo->nomeArquivo); } else { fprintf (logfile,"File %s (already closed)\n",fileInfo->nomeArquivo); } } fprintf (logfile,"**************** end files debug information report*********************\n"); fflush(logfile); } void addFileOnLinkedList(char * nomeArquivo,void * fileHandler) { FilesInfo * filesInfo = (FilesInfo *)malloc(sizeof(FilesInfo)); strcpy(filesInfo->nomeArquivo,nomeArquivo); filesInfo->fileHandler=fileHandler; jvmpi_interface->RawMonitorEnter(list_mutex_t); linkedListFiles.insert(linkedListFiles.end(),(void *)filesInfo); jvmpi_interface->RawMonitorExit(list_mutex_t); } int lookupObj(ObjInfo& linkedList, jobjectID & obj, void ** data) { std::map::iterator p; p = linkedList.find(obj); if (p != linkedList.end()) { *data = p->second; return 1; } else { return 0; } } int lookupObj(ObjInfo& linkedList, jobjectID & obj) { return lookupObj(linkedList,obj,NULL); } // Constants for use in registers //#define CONST_HEADER 255 #define CONST_LOADCLASS 1 #define CONST_LOADMETHOD 2 #define CONST_LOADOBJECT 3 #define CONST_UNLOADOBJECT 4 #define CONST_GCSTART 5 #define CONST_GCFINISH 6 #define CONST_THREADSTART 7 #define CONST_THREADEND 8 #define CONST_ENTERMETHOD 9 #define CONST_EXITMETHOD 10 #define CONST_MONITOR_IN 11 #define CONST_MONITOR_OUT 12 #define CONST_CONTENDED_ENTER 13 #define CONST_CONTENDED_ENTERED 14 #define CONST_CONTENDED_EXIT 15 #define CONST_RAW_CONTENDED_ENTER 16 #define CONST_RAW_CONTENDED_ENTERED 17 #define CONST_RAW_CONTENDED_EXIT 18 static FILE * out = NULL; static long maxSize=1024*1024*10; struct _stackInfo { int bufferSize; int size; int * buffer; }; typedef struct _stackInfo StackInfo; void debugStack(char * message, StackInfo& stackStatus) { fprintf (stderr,"JBossProfiler: %s ",message); for (int i=0;ihandler.bufferSize) { int newBufferSize=handler.bufferSize+100; int * newBuffer =(int *) malloc(sizeof(int)*(newBufferSize)); if (handler.buffer!=NULL) { for (int i=0;itimeCreated = timeCalled; (*handler)->clockCreated = clockCalled; (*handler)->threadNumber = threadsOpened; (*handler)->fileHandler = NULL; (*handler)->startupEntry=0; initStack ((*handler)->stackStatus); //(*handler)->numberOfIgnoredLevels = 0; CALL(SetThreadLocalStorage)(env_id, *handler); } //if (profilerRunning && (*handler)->fileHandler==NULL) { if (profilerRunning>=0 && (*handler)->fileHandler==NULL) { produceLogFileNameForThread((*handler)->strFileName,timeCalled,clockCalled); #ifdef ZLIB (*handler)->fileHandler = gzopenlocal ((*handler)->strFileName,"wb"); #else (*handler)->fileHandler = fopen ((*handler)->strFileName,"wb"); #endif if ((*handler)->fileHandler==NULL) { fprintf (logfile,"JBossProfiler Error: Cannot open file %s\n",(*handler)->strFileName); fprintf (stderr,"********************************************************"); fprintf (stderr,"JBossProfiler ERROR: Cannot open file %s\n",(*handler)->strFileName); fprintf (stderr,"********************************************************"); //(*handler)->fileHandler=out; } addFileOnLinkedList((*handler)->strFileName,(*handler)->fileHandler); } return (*handler)->fileHandler; } /* header - Type of register, identified by all defines begining with REGISTER_ at the top of this source file time - jlong to be written clock - jint to be written */ #ifdef ZLIB inline void writeHeader(jbyte header, jlong* time, jlong* clockCpu, const gzFile outFile) { #else inline void writeHeader(jbyte header, jlong* time, jlong* clockCpu, const FILE * outFile) { #endif static jlong lastClock=0; #ifdef ZLIB gzwritelocal (outFile,&header,sizeof(header),"write header1"); gzwritelocal (outFile,time,sizeof(jlong),"write header2"); gzwritelocal (outFile,clockCpu,sizeof(jlong),"write header3"); #else fwrite (&header,sizeof(header),1,outFile); fwrite (time,sizeof(jlong),1,outFile); fwrite (clockCpu,sizeof(jlong),1,outFile); #endif //fwrite (&elapsedClock,sizeof(jint),1,outFile); //fprintf (logfile,"clockCPU=%I64d\n",*clockCpu); } /* para uso do GCSTART|GCFINISH|FREE_OBJECT que colocaram seus resultados no main arqchive, sem compressao header - Type of register, identified by all defines begining with REGISTER_ at the top of this source file time - jlong to be written clock - jint to be written */ inline void writeHeaderPadrao(const jbyte header, const jlong* time, const jlong* clockCpu, FILE * outFile) { static jlong lastClock=0; fwrite (&header,sizeof(header),1,outFile); fwrite (time,sizeof(jlong),1,outFile); fwrite (clockCpu,sizeof(jlong),1,outFile); //fwrite (&elapsedClock,sizeof(jint),1,outFile); //fprintf (logfile,"clockCPU=%I64d\n",*clockCpu); } /* Writes... PROGID|255 (long)|Time_t|CLOCKS_PER_SEC ProgId identified on variable progID Write a long with 255 just to check alignment purpose when reading the produced file */ inline void writeMainHeader() { jint tst = 0xff; jlong timeMain = sysTimeMillis(); //time(&timeMain); fwrite (progID,sizeof (char),strlen(progID),out); fwrite (&tst,sizeof(tst),1,out); fwrite (&timeMain,sizeof(timeMain),1,out); } /* MESSAGES of LoadClass Message LoadClass: Message LoadMethod: */ void inline loadClass(JNIEnv *env_id, jobjectID & class_id,char * className, jint & num_methods, JVMPI_Method * methods ) { ThreadHandler * threadHandler; jshort i=0;// general purpose local variable jshort j=0;// general purpose local variable jlong clock = getClock(); getTime(); int ignoreResult = isInIgnoreList(className); int startResult = isInStartList(className); int includeResult = isInIncludeList(className); if (startResult) ignoreResult=0; struct _classInfo * classInfo = NULL; if (!lookupObj(linkedListClasses, class_id, (void **)&classInfo)) { classInfo=(struct _classInfo *) malloc(sizeof (struct _classInfo)); classInfo->isLoaded=0; classInfo->isInIgnoreList = ignoreResult; classInfo->isInIncludeList = includeResult; classInfo->isInStartList = startResult; classInfo->className = (char *)malloc(strlen(className)+1); strcpy (classInfo->className,className); addObj(linkedListClasses,class_id,classInfo); if (ignoreResult) { return; } } // if the profiler is not running, we are only interested on those classes // which are not inside ignoreList if (!profilerRunning && !ignoreResult && !startResult && !includeResult && classInfo->isLoaded==2) return; if (classInfo->isLoaded==CLASS_LOADED) { //fprintf (stderr,"Caution... not supposed to reach classInfo->isLoaded at loadClass\n"); return; } else if (classInfo->isLoaded==CLASS_NEEDS_LOAD) { classInfo->isLoaded=CLASS_LOADED; } #ifdef ZLIB gzFile threadFile = threadFileOpen(env_id,execTime,clock,&threadHandler); #else FILE * threadFile = threadFileOpen(env_id,execTime,clock,&threadHandler); #endif writeHeader(CONST_LOADCLASS,&execTime,&clock,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&class_id,sizeof(class_id),"loadclass1"); #else fwrite (&class_id,sizeof(class_id),1,threadFile); #endif i = strlen(className); #ifdef ZLIB gzwritelocal (threadFile,&i,sizeof(i),"loadclass2"); gzwritelocal (threadFile,className,sizeof(char)*i,"loadclass3"); gzwritelocal (threadFile,&num_methods,sizeof(num_methods),"loadclass4"); for (i=0;istartupEntry) return; #ifdef _DEBUG_STACK debugStack("objectAlloc", threadHandler->stackStatus); #endif if (threadHandler!=NULL) { int peekValue = peekStack(threadHandler->stackStatus); if (peekValue==1) return; } jobjectID threadId = CALL(GetThreadObject(env_id)); if (class_ID!=0) { struct _classInfo * classInfo = NULL; int result=lookupObj(linkedListClasses, class_ID, (void **)&classInfo); if (!result) { jint ret = CALL(RequestEvent(JVMPI_EVENT_CLASS_LOAD,class_ID)); } else // I need to recall this object if (result && classInfo->isLoaded==0) { classInfo->isLoaded=2; jint ret = CALL(RequestEvent(JVMPI_EVENT_CLASS_LOAD,class_ID)); } } /*if (!lookupObj(linkedListThreads, threadId)) { fprintf (logfile,"Requesting thread %ld \n",threadId); jint ret = CALL(RequestEvent(JVMPI_EVENT_THREAD_START,threadId)); }*/ //if (!threadHandler->numberOfIgnoredLevels) { writeHeader(CONST_LOADOBJECT,&execTime,&clockCalled,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&env_id, sizeof (JNIEnv *),"objalloc1"); gzwritelocal (threadFile,&threadId, sizeof (JNIEnv *),"objalloc2"); gzwritelocal (threadFile,&class_ID, sizeof (class_ID),"objalloc3"); gzwritelocal (threadFile,&object_ID, sizeof (object_ID),"objalloc4"); gzwritelocal (threadFile,&size, sizeof (size),"objalloc5"); #else fwrite (&env_id, sizeof (JNIEnv *), 1, threadFile); fwrite (&threadId, sizeof (JNIEnv *), 1, threadFile); fwrite (&class_ID, sizeof (class_ID), 1, threadFile); fwrite (&object_ID, sizeof (object_ID), 1, threadFile); fwrite (&size, sizeof (size), 1, threadFile); #endif #ifdef _FLUSH fflush(threadFile); #endif //} } /* MESSAGES of objectFree UNLOADOBJECT|time|clock|objectID */ void objectFree(JNIEnv *env_id, jobjectID object_ID) { ThreadHandler * threadHandler; jlong clockCalled = getClock(); getTime(); writeHeaderPadrao(CONST_UNLOADOBJECT,&execTime,&clockCalled,out); fwrite (&object_ID, sizeof (object_ID), 1, out); #ifdef _FLUSH fflush(out); #endif } /** MESSAGES of GCSTART GCSTART|time|clock */ void gcstart(JNIEnv *env_id) { fprintf (stderr,"JBossProfiler:GCSTART\n"); ThreadHandler * threadHandler; jlong clockCalled = getClock(); getTime(); writeHeaderPadrao(CONST_GCSTART,&execTime,&clockCalled,out); #ifdef _FLUSH fflush(threadFile); #endif } /** MESSAGES of GCFINISH GCFINISH|time|clock */ void gcfinish(JNIEnv *env_id) { fprintf (stderr,"JBossProfiler:GCFINISH\n"); ThreadHandler * threadHandler; jlong clockCalled = getClock(); getTime(); writeHeaderPadrao(CONST_GCFINISH,&execTime,&clockCalled,out); #ifdef _FLUSH fflush(threadFile); #endif } /* MESSAGES of ThreadStart THREADSTART|jlong|clock|env_id|thread_ID|sizeOfThreadName|Thread_name */ void inline threadStart(JNIEnv *env_id,jobjectID thread_id, char * thread_name ) { #ifdef DEBUG fprintf (logfile,"Thread Start %ld\n",thread_id); #endif ThreadHandler * threadHandler; jshort i=0; // general purpose variable jlong clockCalled=getClock(); getTime(); #ifdef ZLIB gzFile threadFile = threadFileOpen(env_id,execTime,clockCalled,&threadHandler); #else FILE * threadFile = threadFileOpen(env_id,execTime,clockCalled,&threadHandler); #endif writeHeader(CONST_THREADSTART,&execTime,&clockCalled,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&env_id, sizeof (JNIEnv *),"threadstart1"); gzwritelocal (threadFile,&thread_id, sizeof (thread_id),"threadstart2"); i = strlen(thread_name); gzwritelocal (threadFile,&i,sizeof(i),"threadstart3"); gzwritelocal (threadFile,thread_name,sizeof(char)*i,"threadstart4"); #else fwrite (&env_id, sizeof (JNIEnv *), 1, threadFile); fwrite (&thread_id, sizeof (thread_id), 1, threadFile); i = strlen(thread_name); fwrite (&i,sizeof(i),1,threadFile); fwrite (thread_name,sizeof(char),i,threadFile); #endif addObj(linkedListThreads,thread_id,threadFile); } /* MESSAGES of ThreadEnd THREADEND|jlong|clock|env_id|thread_id */ void inline threadEnd(JNIEnv *env_id) { // remover as 2 proximas linhas jobjectID threadId = CALL(GetThreadObject(env_id)); #ifdef DEBUG fprintf (logfile,"ThreadEnd %ld\n",threadId); #endif ThreadHandler * threadHandler; jlong clockCalled=getClock(); getTime(); #ifdef ZLIB gzFile threadFile = threadFileOpen(env_id,execTime,clockCalled,&threadHandler); #else FILE * threadFile = threadFileOpen(env_id,execTime,clockCalled,&threadHandler); #endif writeHeader(CONST_THREADEND,&execTime,&clockCalled,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&env_id, sizeof (JNIEnv *),"threadend1"); gzwritelocal (threadFile,&threadId, sizeof (threadId),"threadend2"); #else fwrite (&env_id, sizeof (JNIEnv *), 1,threadFile); fwrite (&threadId, sizeof (threadId), 1,threadFile); #endif if (threadHandler!=NULL) { if (threadHandler->fileHandler!=NULL) { #ifdef ZLIB /*int cderro=0; cderro=gzflush(threadHandler->fileHandler,Z_FINISH); if (cderro!=Z_OK) { fprintf (logfile,"Error during gzflush operation - %d\n",cderro); } cderro=gzclose(threadHandler->fileHandler); if (cderro) { //fprintf (logfile,"Error during gzflush operation - %ld\n",gzerror(threadHandler->fileHandler,&cderro)); fprintf (logfile,"Error during gzclose operation - %ld\n",cderro); fflush(logfile); } ((FilesInfo*)(threadHandler->fileObjNode))->fileHandler=NULL; */ #else fclose(threadHandler->fileHandler); #endif } free(threadHandler); } } /* MESSAGES of RawConteredEnter CONTENDED_ENTER|jlong|clock|env_id|threadId|sizeOfName|char *name|RawId */ void rawContendedEnter(JNIEnv * env_id, char * monitorName, JVMPI_RawMonitor idRaw) { ThreadHandler * handler; jshort i=0;// general purpose local variable jlong clockCalled = getClock(); getTime(); jobjectID threadId = CALL(GetThreadObject(env_id)); #ifdef ZLIB gzFile threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #else FILE * threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #endif writeHeader(CONST_RAW_CONTENDED_ENTER,&execTime,&clockCalled,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&env_id,sizeof (JNIEnv *),"rawcontendedenter1"); gzwritelocal (threadFile,&threadId, sizeof (threadId),"rawcontendedenter2"); i = strlen(monitorName); gzwritelocal (threadFile,&i,sizeof(i),"rawcontendedenter3"); gzwritelocal (threadFile,monitorName,sizeof(char)*i,"rawcontendedenter4"); gzwritelocal (threadFile,idRaw,sizeof(JVMPI_RawMonitor),"rawcontendedenter5"); #else fwrite (&env_id,sizeof (JNIEnv *),1,threadFile); fwrite (&threadId, sizeof (threadId), 1,threadFile); i = strlen(monitorName); fwrite (&i,sizeof(i),1,threadFile); fwrite ((const void *)monitorName,sizeof(char),i,threadFile); fwrite ((const void *)idRaw,sizeof(JVMPI_RawMonitor),1,threadFile); #endif #ifdef _FLUSH fflush(threadFile); #endif } /* MESSAGES of RawConteredEnter CONTENDED_ENTER|jlong|clock|env_id|threadId|sizeOfName|char *name|RawId */ void rawContendedEntered(JNIEnv * env_id, char * monitorName, JVMPI_RawMonitor idRaw) { ThreadHandler * handler; jshort i=0;// general purpose local variable jlong clockCalled = getClock(); getTime(); jobjectID threadId = CALL(GetThreadObject(env_id)); #ifdef ZLIB gzFile threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #else FILE * threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #endif writeHeader(CONST_RAW_CONTENDED_ENTERED,&execTime,&clockCalled,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&env_id,sizeof (JNIEnv *),"rawcontendedentered1"); gzwritelocal (threadFile,&threadId, sizeof (threadId),"rawcontendedentered2"); i = strlen(monitorName); gzwritelocal (threadFile,&i,sizeof(i),"rawcontendedentered3"); gzwritelocal (threadFile,monitorName,sizeof(char)*i,"rawcontendedentered4"); gzwritelocal (threadFile,idRaw,sizeof(JVMPI_RawMonitor),"rawcontendedentered5"); #else fwrite (&env_id,sizeof (JNIEnv *),1,threadFile); fwrite (&threadId, sizeof (threadId), 1,threadFile); i = strlen(monitorName); fwrite (&i,sizeof(i),1,threadFile); fwrite ((const void *)monitorName,sizeof(char),i,threadFile); fwrite ((const void *)idRaw,sizeof(JVMPI_RawMonitor),1,threadFile); #endif #ifdef _FLUSH fflush(threadFile); #endif } /* MESSAGES of RawConteredEnter CONTENDED_ENTER|jlong|clock|env_id|threadId|sizeOfName|char *name|RawId */ void rawContendedExit(JNIEnv * env_id, char * monitorName, JVMPI_RawMonitor idRaw) { ThreadHandler * handler; jshort i=0;// general purpose local variable jlong clockCalled = getClock(); getTime(); jobjectID threadId = CALL(GetThreadObject(env_id)); #ifdef ZLIB gzFile threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #else FILE * threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #endif writeHeader(CONST_RAW_CONTENDED_EXIT,&execTime,&clockCalled,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&env_id,sizeof (JNIEnv *),"rawcontendedexit1"); gzwritelocal (threadFile,&threadId, sizeof (threadId),"rawcontendedexit2"); i = strlen(monitorName); gzwritelocal (threadFile,&i,sizeof(i),"rawcontendedexit3"); gzwritelocal (threadFile,monitorName,sizeof(char)*i,"rawcontendedexit4"); gzwritelocal (threadFile,idRaw,sizeof(JVMPI_RawMonitor),"rawcontendedexit5"); #else fwrite (&env_id,sizeof (JNIEnv *),1,threadFile); fwrite (&threadId, sizeof (threadId), 1,threadFile); i = strlen(monitorName); fwrite (&i,sizeof(i),1,threadFile); fwrite ((const void *)monitorName,sizeof(char),i,threadFile); fwrite ((const void *)idRaw,sizeof(JVMPI_RawMonitor),1,threadFile); #endif #ifdef _FLUSH fflush(threadFile); #endif } /* MESSAGES of ConteredEnter CONTENDED_ENTER|jlong|clock|env_id|thread_id|object */ void contendedEnter(JNIEnv * env_id, jobjectID object) { ThreadHandler * handler; jlong clockCalled = getClock(); getTime(); jobjectID threadId = CALL(GetThreadObject(env_id)); #ifdef ZLIB gzFile threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #else FILE * threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #endif fprintf(stderr,"ContendedEnter ThreadId %ld %ld\n",threadId,execTime); writeHeader(CONST_CONTENDED_ENTER,&execTime,&clockCalled,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&env_id,sizeof (JNIEnv *),"contededenter1"); gzwritelocal (threadFile,&threadId,sizeof (JNIEnv *),"contededenter2"); gzwritelocal (threadFile,&object,sizeof (object),"contededenter3"); #else fwrite (&env_id,sizeof (JNIEnv *),1,threadFile); fwrite (&threadId,sizeof (JNIEnv *),1,threadFile); fwrite (&object,sizeof (object),1,threadFile); #endif #ifdef _FLUSH fflush(threadFile); #endif } /* MESSAGES of ConteredEntered CONTENDED_ENTERED|jlong|clock|env_id|thread_id|objectId */ void contendedEntered(JNIEnv * env_id, jobjectID object) { ThreadHandler * handler; jlong clockCalled = getClock(); getTime(); jobjectID threadId = CALL(GetThreadObject(env_id)); #ifdef ZLIB gzFile threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #else FILE * threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #endif fprintf(stderr,"ContendedEnterED ThreadId %ld %ld\n",threadId,execTime); writeHeader(CONST_CONTENDED_ENTERED,&execTime,&clockCalled,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&env_id,sizeof (JNIEnv *),"contededentered1"); gzwritelocal (threadFile,&threadId,sizeof (JNIEnv *),"contededentered2"); gzwritelocal (threadFile,&object,sizeof (object),"contededentered3"); #else fwrite (&env_id,sizeof (JNIEnv *),1,threadFile); fwrite (&threadId,sizeof (JNIEnv *),1,threadFile); fwrite (&object,sizeof (object),1,threadFile); #endif #ifdef _FLUSH fflush(threadFile); #endif } /* MESSAGES of ConteredExit CONTENDED_EXIT|jlong|clock|env_id|thread_id|objectId */ void contendedExit(JNIEnv * env_id, jobjectID object) { ThreadHandler * handler; jlong clockCalled = getClock(); getTime(); jobjectID threadId = CALL(GetThreadObject(env_id)); #ifdef ZLIB gzFile threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #else FILE * threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #endif fprintf(stderr,"ContendedEnterExit ThreadId %ld %ld\n",threadId,execTime); writeHeader(CONST_CONTENDED_EXIT,&execTime,&clockCalled,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&env_id,sizeof (JNIEnv *),"contededexit1"); gzwritelocal (threadFile,&threadId,sizeof (JNIEnv *),"contededexit2"); gzwritelocal (threadFile,&object,sizeof (object),"contededexit3"); #else fwrite (&env_id,sizeof (JNIEnv *),1,threadFile); fwrite (&threadId,sizeof (JNIEnv *),1,threadFile); fwrite (&object,sizeof (object),1,threadFile); #endif #ifdef _FLUSH fflush(threadFile); #endif } /* MESSAGES of ThreadWait THREAWAIT|jlong|clock|env_id|thread_id|timeout */ void threadWait(JNIEnv * env_id, jobjectID object, jint timeout) { ThreadHandler * handler; jlong clockCalled = getClock(); getTime(); #ifdef ZLIB gzFile threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #else FILE * threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #endif writeHeader(CONST_MONITOR_IN,&execTime,&clockCalled,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&env_id,sizeof (JNIEnv *),"threadwait1"); gzwritelocal (threadFile,&object,sizeof (object),"threadwait2"); #else fwrite (&env_id,sizeof (JNIEnv *),1,threadFile); fwrite (&object,sizeof (object),1,threadFile); #endif #ifdef _FLUSH fflush(threadFile); #endif } void threadWaited(JNIEnv * env_id, jobjectID object, jint timeout) { ThreadHandler * handler; jlong clockCalled = getClock(); getTime(); #ifdef ZLIB gzFile threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #else FILE * threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #endif writeHeader(CONST_MONITOR_OUT,&execTime,&clockCalled,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&env_id,sizeof (JNIEnv *),"threadwaited1"); gzwritelocal (threadFile,&object,sizeof (object),"threadwaited2"); #else fwrite (&env_id,sizeof (JNIEnv *),1,threadFile); fwrite (&object,sizeof (object),1,threadFile); #endif #ifdef _FLUSH fflush(threadFile); #endif } /* MESSAGES of EnterMethod ENTRYMETHOD|jlong|clock|env_id|MethodId|ObjectId */ void enterMethod(JNIEnv *env_id,jmethodID & methodId, jobjectID & object) { ThreadHandler * handler; jobjectID threadId = CALL(GetThreadObject(env_id)); jobjectID classID = CALL(GetMethodClass(methodId)); struct _classInfo * classInfo = NULL; if (!lookupObj(linkedListClasses, classID, (void **)&classInfo)) { jint ret = CALL(RequestEvent(JVMPI_EVENT_CLASS_LOAD,classID)); lookupObj(linkedListClasses, classID, (void **)&classInfo); } if (classInfo!=NULL && classInfo->isLoaded==CLASS_UNLOADED) { classInfo->isLoaded==CLASS_NEEDS_LOAD; lookupObj(linkedListClasses, classID, (void **)&classInfo); } #ifdef COUNT_METHODS enterMethods++; #endif jlong clockCalled = getClock(); getTime(); #ifdef ZLIB gzFile threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #else FILE * threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #endif /*if (classInfo!=NULL && classInfo->isInIgnoreList) { handler->numberOfIgnoredLevels++; } */ // push status if (classInfo!=NULL) { if (classInfo->isInStartList) { if (handler->startupEntry<=0){ handler->startupEntry=1; } else { handler->startupEntry++; } pushStack(handler->stackStatus,IN_START_LIST); } } if (!(usingStartList && !handler->startupEntry)) { #ifdef _DEBUG_STACK debugStack("enterMethod", handler->stackStatus); #endif if (classInfo==NULL || !classInfo->isInIgnoreList || classInfo->isInIncludeList ) { // If in startupmode, evedything has to be cathered if (classInfo!=NULL && classInfo->isLoaded==0) { classInfo->isLoaded=2; jint ret = CALL(RequestEvent(JVMPI_EVENT_CLASS_LOAD,classID)); } writeHeader(CONST_ENTERMETHOD,&execTime,&clockCalled,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&env_id,sizeof (JNIEnv *),"entermethod1"); gzwritelocal (threadFile,&threadId,sizeof (threadId),"entermethod2"); gzwritelocal (threadFile,&classID,sizeof (classID),"entermethod3"); gzwritelocal (threadFile,&methodId,sizeof (methodId),"entermethod4"); gzwritelocal (threadFile,&object,sizeof (object),"entermethod5"); #else fwrite (&env_id,sizeof (JNIEnv *),1,threadFile); fwrite (&threadId,sizeof (threadId),1,threadFile); fwrite (&classID,sizeof (classID),1,threadFile); fwrite (&methodId,sizeof (methodId),1,threadFile); fwrite (&object,sizeof (object),1,threadFile); #endif #ifdef _FLUSH fflush(threadFile); #endif } } } /* MESSAGES of ExitMethod EXITMETHOD|jlong|clock|env_id|MethodId */ void exitMethod(JNIEnv *env_id,jmethodID & methodId) { #ifdef COUNT_METHODS exitMethods++; #endif ThreadHandler * handler; jobjectID threadId = CALL(GetThreadObject(env_id)); jlong clockCalled = getClock(); getTime(); #ifdef ZLIB gzFile threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #else FILE * threadFile = threadFileOpen(env_id,execTime,clockCalled,&handler); #endif jobjectID classID = CALL(GetMethodClass(methodId)); struct _classInfo * classInfo; if (!lookupObj(linkedListClasses, classID, (void **)&classInfo)) { jint ret = CALL(RequestEvent(JVMPI_EVENT_CLASS_LOAD,classID)); lookupObj(linkedListClasses, classID, (void **)&classInfo); } if (classInfo!=NULL && classInfo->isLoaded==CLASS_UNLOADED) { classInfo->isLoaded==CLASS_NEEDS_LOAD; lookupObj(linkedListClasses, classID, (void **)&classInfo); } if (!(usingStartList && !handler->startupEntry)) { #ifdef _DEBUG_STACK debugStack("exitMethod ", handler->stackStatus); #endif if (classInfo==NULL || !classInfo->isInIgnoreList || classInfo->isInIncludeList ) { if (classInfo!=NULL) { popStack(handler->stackStatus); } writeHeader(CONST_EXITMETHOD,&execTime,&clockCalled,threadFile); #ifdef ZLIB gzwritelocal (threadFile,&env_id,sizeof (JNIEnv *),"methodexit1"); gzwritelocal (threadFile,&threadId,sizeof (threadId),"methodexit2"); gzwritelocal (threadFile,&methodId,sizeof (methodId),"methodexit3"); #else fwrite (&env_id,sizeof (JNIEnv *),1,threadFile); fwrite (&threadId,sizeof (threadId),1,threadFile); fwrite (&methodId,sizeof (methodId),1,threadFile); #endif #ifdef _FLUSH fflush(threadFile); #endif } if (classInfo!=NULL && classInfo->isInStartList) { handler->startupEntry--; } } /* if (classInfo!=NULL && classInfo->isInIgnoreList) { handler->numberOfIgnoredLevels--; if (handler->numberOfIgnoredLevels<0) handler->numberOfIgnoredLevels=0; } */ } void inline flushAllFiles(){ #ifdef ZLIB gzwritelock=1; // nao podem mais acontecer nenhuma escria #endif std::vector::iterator p; fprintf (logfile,"**************** files debug information *********************\n"); for (p=linkedListFiles.begin();p!=linkedListFiles.end();p++) { FilesInfo* fileInfo = (FilesInfo*)(*p); if (fileInfo->fileHandler!=NULL) { #ifdef ZLIB gzFile threadFile = (gzFile) fileInfo->fileHandler; int cderro=0; cderro=gzclose(threadFile); if (cderro) { fprintf (logfile,"Error during gzclose operation(flushAllFiles) - %s\n",gzerror(threadFile,&cderro)); fflush(logfile); } #else FILE * threadFile = (FILE *) fileInfo->fileHandler; fflush(threadFile); #endif } } fflush(logfile); fflush(out); } void removeProfiler(short isShutdown) { if (!isShutdown) { CALL(RunGC)(); } profilerRunning=-1; fprintf (logfile,"Stopping DataGathering\n"); fprintf (stderr,"Stopping DataGathering\n"); // enabling class load event notification jvmpi_interface->DisableEvent(JVMPI_EVENT_CLASS_LOAD, NULL); //jvmpi_interface->DisableEvent(JVMPI_EVENT_CLASS_UNLOAD, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_METHOD_ENTRY2, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_METHOD_EXIT, NULL); if (profileMemory) { jvmpi_interface->DisableEvent(JVMPI_EVENT_OBJECT_ALLOC, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_OBJECT_FREE, NULL); } jvmpi_interface->DisableEvent(JVMPI_EVENT_GC_START, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_GC_FINISH, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_MONITOR_WAIT, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_MONITOR_WAITED, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_MONITOR_CONTENDED_ENTER, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_MONITOR_CONTENDED_ENTERED, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_MONITOR_CONTENDED_EXIT, NULL); /*jvmpi_interface->DisableEvent(JVMPI_EVENT_MONITOR_CONTENDED_ENTER, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_MONITOR_CONTENDED_ENTERED, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_MONITOR_CONTENDED_EXIT, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT, NULL); */ jvmpi_interface->DisableEvent(JVMPI_EVENT_THREAD_START, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_THREAD_END, NULL); #ifdef ZLIB gzwritelock=1; #endif //jlong target = sysTimeMillis() + (jlong)10000; // esperando 10 segundos para que todos os eventos acabem //while (target>sysTimeMillis()); flushAllFiles(); jvmpi_interface->RawMonitorDestroy(list_mutex_t); // debugFiles(); } void pauseProfiler() { fprintf (logfile,"JBossProfiler: Pausing DataGathering\n"); fflush(logfile); fprintf (stderr,"JBossProfiler: Pausing DataGathering\n"); // enabling class load event notification jvmpi_interface->DisableEvent(JVMPI_EVENT_CLASS_LOAD, NULL); //jvmpi_interface->DisableEvent(JVMPI_EVENT_CLASS_UNLOAD, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_METHOD_ENTRY2, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_METHOD_EXIT, NULL); if (profileMemory) { jvmpi_interface->DisableEvent(JVMPI_EVENT_OBJECT_ALLOC, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_OBJECT_FREE, NULL); } jvmpi_interface->DisableEvent(JVMPI_EVENT_GC_START, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_GC_FINISH, NULL); //jvmpi_interface->DisableEvent(JVMPI_EVENT_MONITOR_WAIT, NULL); //jvmpi_interface->DisableEvent(JVMPI_EVENT_MONITOR_WAITED, NULL); //jvmpi_interface->DisableEvent(JVMPI_EVENT_MONITOR_CONTENDED_ENTER, NULL); //jvmpi_interface->DisableEvent(JVMPI_EVENT_MONITOR_CONTENDED_ENTERED, NULL); //jvmpi_interface->DisableEvent(JVMPI_EVENT_MONITOR_CONTENDED_EXIT, NULL); //jvmpi_interface->DisableEvent(JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER, NULL); //jvmpi_interface->DisableEvent(JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED, NULL); //jvmpi_interface->DisableEvent(JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_THREAD_START, NULL); jvmpi_interface->DisableEvent(JVMPI_EVENT_THREAD_END, NULL); } void initProfiler() { profilerRunning=1; fprintf (logfile,"Initializing DataGathering\n"); fflush(logfile); fprintf (stderr,"JBossProfiler: Initializing DataGathering\n"); // enabling class load event notification jvmpi_interface->EnableEvent(JVMPI_EVENT_CLASS_LOAD, NULL); //jvmpi_interface->EnableEvent(JVMPI_EVENT_CLASS_UNLOAD, NULL); jvmpi_interface->EnableEvent(JVMPI_EVENT_METHOD_ENTRY2, NULL); jvmpi_interface->EnableEvent(JVMPI_EVENT_METHOD_EXIT, NULL); if (profileMemory) { jvmpi_interface->EnableEvent(JVMPI_EVENT_OBJECT_ALLOC, NULL); jvmpi_interface->EnableEvent(JVMPI_EVENT_OBJECT_FREE, NULL); } jvmpi_interface->EnableEvent(JVMPI_EVENT_GC_START, NULL); jvmpi_interface->EnableEvent(JVMPI_EVENT_GC_FINISH, NULL); //jvmpi_interface->EnableEvent(JVMPI_EVENT_MONITOR_WAIT, NULL); //jvmpi_interface->EnableEvent(JVMPI_EVENT_MONITOR_WAITED, NULL); jvmpi_interface->EnableEvent(JVMPI_EVENT_MONITOR_CONTENDED_ENTER, NULL); jvmpi_interface->EnableEvent(JVMPI_EVENT_MONITOR_CONTENDED_ENTERED, NULL); //jvmpi_interface->EnableEvent(JVMPI_EVENT_MONITOR_CONTENDED_EXIT, NULL); //jvmpi_interface->EnableEvent(JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER, NULL); //jvmpi_interface->EnableEvent(JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED, NULL); //jvmpi_interface->EnableEvent(JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT, NULL); jvmpi_interface->EnableEvent(JVMPI_EVENT_JVM_SHUT_DOWN, NULL); jvmpi_interface->EnableEvent(JVMPI_EVENT_THREAD_START, NULL); jvmpi_interface->EnableEvent(JVMPI_EVENT_THREAD_END, NULL); list_mutex_t= jvmpi_interface->RawMonitorCreate("_thread_list_files"); } void changeProfiller() { if (profilerRunning) { fprintf (stderr,"JBossProfiler: Singal for removeProfiler\n"); removeProfiler(FALSE); } else { fprintf (stderr,"JBossProfiler: Singal for initProfiler\n"); initProfiler(); } } // function for handling event notification void notifyEvent(JVMPI_Event *event) { if (profilerRunning<0) return; // check da inicializacao do profiler por socket if (!profilerRunning && event->event_type==JVMPI_EVENT_METHOD_ENTRY2) return; #ifdef COUNT_METHODS static int cont=0; if ((cont++)%1000==0) { fprintf (logfile,"Enter = %ld Exit=%ld\n",enterMethods,exitMethods); } #endif switch(event->event_type) { case JVMPI_EVENT_CLASS_UNLOAD: fprintf (stderr,"JBossProfiler: Class Unloading\n"); break; case JVMPI_EVENT_CLASS_LOAD|JVMPI_REQUESTED_EVENT: case JVMPI_EVENT_CLASS_LOAD: loadClass(event->env_id, event->u.class_load.class_id, (char *)event->u.class_load.class_name, event->u.class_load.num_methods, event->u.class_load.methods); break; case JVMPI_EVENT_METHOD_ENTRY2: enterMethod(event->env_id,event->u.method_entry2.method_id,event->u.method_entry2.obj_id); break; case JVMPI_EVENT_METHOD_EXIT: exitMethod(event->env_id,event->u.method.method_id); break; case JVMPI_EVENT_OBJECT_ALLOC: if (event->u.obj_alloc.is_array==JVMPI_NORMAL_OBJECT) { objectAlloc(event->env_id, event->u.obj_alloc.class_id, event->u.obj_alloc.obj_id, event->u.obj_alloc.size); } break; case JVMPI_EVENT_OBJECT_FREE: objectFree(event->env_id,event->u.obj_free.obj_id); break; case JVMPI_EVENT_GC_START: gcstart(event->env_id); break; case JVMPI_EVENT_GC_FINISH: gcfinish(event->env_id); break; case JVMPI_EVENT_THREAD_START|JVMPI_REQUESTED_EVENT: case JVMPI_EVENT_THREAD_START: threadStart(event->env_id,event->u.thread_start.thread_id,event->u.thread_start.thread_name); break; case JVMPI_EVENT_THREAD_END: threadEnd(event->env_id); break; case JVMPI_EVENT_MONITOR_WAIT: threadWait(event->env_id, event->u.monitor_wait.object, event->u.monitor_wait.timeout); break; case JVMPI_EVENT_MONITOR_WAITED: threadWaited(event->env_id, event->u.monitor_wait.object, event->u.monitor_wait.timeout); break; case JVMPI_EVENT_MONITOR_CONTENDED_ENTER: contendedEnter(event->env_id, event->u.monitor.object); break; case JVMPI_EVENT_MONITOR_CONTENDED_ENTERED: contendedEntered(event->env_id, event->u.monitor.object); break; case JVMPI_EVENT_MONITOR_CONTENDED_EXIT: contendedExit(event->env_id, event->u.monitor.object); break; case JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER: rawContendedEnter(event->env_id, (char *)event->u.raw_monitor.name, event->u.raw_monitor.id); break; case JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED: rawContendedEntered(event->env_id,(char *) event->u.raw_monitor.name, event->u.raw_monitor.id); break; case JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT: rawContendedExit(event->env_id, (char *)event->u.raw_monitor.name, event->u.raw_monitor.id); break; case JVMPI_EVENT_DATA_DUMP_REQUEST: if (profilerRunning) { removeProfiler(FALSE); } else { initProfiler(); } break; case JVMPI_EVENT_JVM_INIT_DONE: if(wakeupOnStartup) { initProfiler(); } #ifdef USE_SOCKETS if (usingSockets) { startConsoleCheck(parametroSocket,pid); //jvmpi_interface->EnableEvent(JVMPI_EVENT_METHOD_ENTRY2, NULL); } #endif break; case JVMPI_EVENT_JVM_SHUT_DOWN: fprintf (stderr,"\n\nJBossProfiler: Stopping profiler by shutdown\n"); if (profilerRunning) { removeProfiler(TRUE); } break; default: fprintf (logfile,"JBossProfiler: Invalid Event in the switch -> %d\n",event->event_type); } if (profilerRunning==-1) { fflush(logfile); } #ifdef _FLUSH fflush(out); #endif } char ** divideStringsByCharacter(char * parameter, char characterToDive, int * numberOfResultStrings) { int len = strlen(parameter); int nComma=0; for (int i=0;i=sizeOfParameter || equalsPosition>(sizeOfParameter-1)) // tests if '=' char wasnn't found or if '=' is the latest char { //fprintf (stderr,"parameter %s didn't have '='\n",parameter); return 1; } char * secondParameter = parameter + equalsPosition + 1; //int maxParameters=7; int maxParameters=8; //char * validParameters[] ={"wakeupOnStartup","uniqueNames","memory","ignore","start","include","socket"}; char * validParameters[] ={"wakeupOnStartup","uniqueNames","memory","ignore","start","include","socket","tracer"}; int parameterNumber=0; for (parameterNumber=0;parameterNumber=maxParameters) { //fprintf (stderr,"didn't find %s",parameter); return 0; } if (parameterNumber<=2) // location of boolean parameters { if (!(strcmp(secondParameter,"true")==0 || strcmp(secondParameter,"false")==0)) { //fprintf (stderr,"Invalid value %s at %s\n",parameter,secondParameter); return 0; } } return 1; } // main - ponto principal de entrada // profiler agent entry point extern "C" { JNIEXPORT jint JNICALL JVM_OnLoad(JavaVM *jvm, char *options, void *reserved) { // get jvmpi interface pointer #ifdef WINDOWS fprintf (stderr,"Running process on Windows %ld\n",_getpid()); pid = _getpid(); getTime(); startTime=execTime; #else fprintf (stderr,"Running process %ld\n",getpid()); pid = getpid(); getTime(); startTime=execTime; #endif profilerRunning=0; int n=0; char ** parameterStrings = divideStringsByCharacter(options,',',&n); int uniqueNames=0; for (int i=0;iGetEnv((void **)&jvmpi_interface, JVMPI_VERSION_1)) < 0) { fprintf(stderr, "dpInspector> error in obtaining jvmpi interface pointer\n"); return JNI_ERR; } if ((jvm->GetEnv((void **)&jni_interface, JNI_VERSION_1_2)) < 0) { fprintf(stderr, "dpInspector> error in obtaining JNI interface pointer\n"); return JNI_ERR; } if (options==NULL) { fprintf (stderr,"Usage of SPYServer:\n"); fprintf (stderr,"java -XrundpInspector:\"log directory\"\n"); jvmpi_interface->ProfilerExit(-2); } char strFileLog[256]; #ifdef WINDOWS sprintf (logFileDirectory,"%s\\",options); sprintf (strFileLog,"%slog_spyserver_%I64d.txt",logFileDirectory,pid); #else sprintf (logFileDirectory,"%s/",options); sprintf (strFileLog,"%slog_spyserver_%lld.txt",logFileDirectory,pid); #endif logfile = fopen(strFileLog,"wb"); if (logfile==NULL) { fprintf (stderr,"Cannot open file %s. Please check you directory name\n",strFileLog); exit(-1); } loadIgnoreList(n,parameterStrings); log_start = startTime; #ifdef WINDOWS sprintf (mainLogFileName,"%sserverspy_%I64d_main_%I64d.log", logFileDirectory,pid, log_start); #else sprintf (mainLogFileName,"%sserverspy_%lld_main_%lld.log", logFileDirectory,pid, log_start); #endif out = fopen (mainLogFileName,"wb"); //addFileOnLinkedList(mainLogFileName,out); if (out==NULL) { fprintf (logfile,"Isn't possible open file %s\n",mainLogFileName); jvmpi_interface->ProfilerExit(-2); } writeMainHeader(); // initialize jvmpi interface jvmpi_interface->NotifyEvent = notifyEvent; #ifndef FULLPROFILLER jvmpi_interface->EnableEvent(JVMPI_EVENT_DATA_DUMP_REQUEST, NULL); #endif //jvmpi_interface->EnableEvent(JVMPI_EVENT_THREAD_START, NULL); //jvmpi_interface->EnableEvent(JVMPI_EVENT_CLASS_LOAD, NULL); //jvmpi_interface->EnableEvent(JVMPI_EVENT_THREAD_END, NULL); jvmpi_interface->EnableEvent(JVMPI_EVENT_JVM_INIT_DONE, NULL); #ifdef FULLPROFILLER initProfiler(); #endif fflush(out); free(parameterStrings); return JNI_OK; } } void printMessageError() { fprintf (stderr,"Error: Requires initialization with -XrunjbossInspector:,parameters\n"); fprintf (stderr,"Read the documentation about JBossProfiler\n"); } JNIEXPORT void JNICALL Java_org_jboss_profiler_threadcheck_StartupProfilerCheck_startProfilerInternal (JNIEnv * penv, jclass pclass) { if (profilerRunning>=0) { initProfiler(); } else { printMessageError(); } // todo: exception if not initialized } JNIEXPORT void JNICALL Java_org_jboss_profiler_threadcheck_StartupProfilerCheck_stopProfilerInternal (JNIEnv * penv, jclass pclass) { if (profilerRunning>=0) { removeProfiler(FALSE); } else { printMessageError(); } } JNIEXPORT void JNICALL Java_org_jboss_profiler_threadcheck_StartupProfilerCheck_pauseProfilerInternal (JNIEnv * penv, jclass pclass) { if (profilerRunning>=0) { pauseProfiler(); } else { printMessageError(); } } // rotina que ira conectar com a console void startConsoleCheck(char * socketParameter, jlong pid) { jclass checkClass=jni_interface->FindClass("org/jboss/profiler/threadcheck/StartupProfilerCheck"); if (checkClass==NULL) { fprintf (stderr,"\n***********************\nFatalError: Cannot find org.jboss.profiler.threadcheck.StartupProfilerCheck.initCheck(String,int)\n"); fprintf (stderr,"Check you classpath for profilerConsole.jar\n"); return; } jmethodID metodoInit=jni_interface->GetStaticMethodID(checkClass,"initCheck","(Ljava/lang/String;L)V"); if (metodoInit==NULL) { fprintf (stderr,"\n***********************\nFatalError: Cannot find org/jboss/profiler/threadcheck/StartupProfilerCheck.initCheck(String,int)\n"); fprintf (stderr,"Check you classpath for profilerConsole.jar\n"); return; } jstring strParameter = jni_interface->NewStringUTF(socketParameter); jlong jlongPid = pid; jni_interface->CallStaticVoidMethod(checkClass,metodoInit,strParameter,jlongPid); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-profiler-java-1.0.CR4.orig/jvmpi-src/src/org_jboss_profiler_threadcheck_StartupProfilerCheck.hlibjboss-profiler-java-1.0.CR4.orig/jvmpi-src/src/org_jboss_profiler_threadcheck_StartupProfilerChec0000644000175000017500000000415610462070354034065 0ustar twernertwerner/* DO NOT EDIT THIS FILE - it is machine generated */ #include /* Header for class org_jboss_profiler_threadcheck_StartupProfilerCheck */ #ifndef _Included_org_jboss_profiler_threadcheck_StartupProfilerCheck #define _Included_org_jboss_profiler_threadcheck_StartupProfilerCheck #ifdef __cplusplus extern "C" { #endif #undef org_jboss_profiler_threadcheck_StartupProfilerCheck_COMMAND_START #define org_jboss_profiler_threadcheck_StartupProfilerCheck_COMMAND_START 1L #undef org_jboss_profiler_threadcheck_StartupProfilerCheck_COMMAND_PAUSE #define org_jboss_profiler_threadcheck_StartupProfilerCheck_COMMAND_PAUSE 2L #undef org_jboss_profiler_threadcheck_StartupProfilerCheck_COMMAND_STOP #define org_jboss_profiler_threadcheck_StartupProfilerCheck_COMMAND_STOP 3L #undef org_jboss_profiler_threadcheck_StartupProfilerCheck_STOPPED #define org_jboss_profiler_threadcheck_StartupProfilerCheck_STOPPED 0L #undef org_jboss_profiler_threadcheck_StartupProfilerCheck_RUNNING #define org_jboss_profiler_threadcheck_StartupProfilerCheck_RUNNING 1L #undef org_jboss_profiler_threadcheck_StartupProfilerCheck_PAUSED #define org_jboss_profiler_threadcheck_StartupProfilerCheck_PAUSED 2L #undef org_jboss_profiler_threadcheck_StartupProfilerCheck_DETTACHED #define org_jboss_profiler_threadcheck_StartupProfilerCheck_DETTACHED 3L /* Inaccessible static: profilerState */ /* * Class: org_jboss_profiler_threadcheck_StartupProfilerCheck * Method: startProfilerInternal * Signature: ()V */ JNIEXPORT void JNICALL Java_org_jboss_profiler_threadcheck_StartupProfilerCheck_startProfilerInternal (JNIEnv *, jclass); /* * Class: org_jboss_profiler_threadcheck_StartupProfilerCheck * Method: pauseProfilerInternal * Signature: ()V */ JNIEXPORT void JNICALL Java_org_jboss_profiler_threadcheck_StartupProfilerCheck_pauseProfilerInternal (JNIEnv *, jclass); /* * Class: org_jboss_profiler_threadcheck_StartupProfilerCheck * Method: stopProfilerInternal * Signature: ()V */ JNIEXPORT void JNICALL Java_org_jboss_profiler_threadcheck_StartupProfilerCheck_stopProfilerInternal (JNIEnv *, jclass); #ifdef __cplusplus } #endif #endif libjboss-profiler-java-1.0.CR4.orig/jvmpi-src/win32/0000755000175000017500000000000010462070274022062 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmpi-src/win32/bin/0000755000175000017500000000000010462070274022632 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmpi-src/win32/compile.sh0000644000175000017500000000171010462070354024044 0ustar twernertwerner#!/bin/sh rm -f *.so rm -f *.dll rm -f *.o _INCLUDES="-I$JAVA_HOME/include -I$JAVA_HOME/include/win32 -I../../src/zlib" _OPTS="-mno-cygwin -pg" mkdir bin cd ./bin gcc $_OPTS $_INCLUDES -c ../../src/zlib/adler32.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/compress.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/crc32.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/gzio.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/uncompr.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/deflate.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/trees.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/zutil.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/inflate.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/infback.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/inftrees.c gcc $_OPTS $_INCLUDES -c ../../src/zlib/inffast.c g++ $_INCLUDES -D ZLIB -D LOOKUP_OBJ -D USE_SOCKETS -D WINDOWS -D _WINDOWS $_OPTS -shared -Wl,-add-stdcall-alias -o jbossInspector.dll ../../src/jbossInspector.cc *.o libjboss-profiler-java-1.0.CR4.orig/jvmti/0000755000175000017500000000000010463347662020350 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti/native/0000755000175000017500000000000010463347662021636 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti/native/win32/0000755000175000017500000000000010463347662022600 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti/native/suse-linux64/0000755000175000017500000000000010463347662024124 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti/native/linux/0000755000175000017500000000000010463347662022775 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/0000755000175000017500000000000010463347662021135 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/java-src/0000755000175000017500000000000010462070276022634 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/java-src/org/0000755000175000017500000000000010462070276023423 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/java-src/org/jboss/0000755000175000017500000000000010462070276024543 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/java-src/org/jboss/profiler/0000755000175000017500000000000010462070276026365 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/java-src/org/jboss/profiler/jvmti/0000755000175000017500000000000010462070442027511 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/java-src/org/jboss/profiler/jvmti/InventoryDataPoint.javalibjboss-profiler-java-1.0.CR4.orig/jvmti-src/java-src/org/jboss/profiler/jvmti/InventoryDataPoint.j0000644000175000017500000000401610462070354033470 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.profiler.jvmti; import java.lang.ref.WeakReference; /** * Used to return quantity of instances and bytes per class * */ public class InventoryDataPoint implements Comparable { public InventoryDataPoint(Class clazz) { this.clazz = new WeakReference(clazz); } public InventoryDataPoint(Class clazz, int instances) { this.clazz = new WeakReference(clazz); this.instances=instances; } WeakReference clazz; int instances; long bytes; public long getBytes() { return bytes; } public void setBytes(long bytes) { this.bytes = bytes; } public Class getClazz() { return (Class)clazz.get(); } public void setClazz(Class clazz) { this.clazz = new WeakReference(clazz); } public int getInstances() { return instances; } public void setInstances(int instances) { this.instances = instances; } public int compareTo(Object o) { InventoryDataPoint that = (InventoryDataPoint)o; long result = that.bytes - this.bytes; if (result==0) return 0; else if (result>0) return 1; else return -1; } } libjboss-profiler-java-1.0.CR4.orig/jvmti-src/java-src/org/jboss/profiler/jvmti/JVMTICallBack.java0000644000175000017500000001002610462070354032623 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.profiler.jvmti; /** * Interface to get notifications for references on JVMTI * @author csuconic * */ public interface JVMTICallBack { public static final int JVMTI_REFERENCE_CLASS=1;// Reference from an object to its class. public static final int JVMTI_REFERENCE_FIELD=2;//Reference from an object to the value of one of its instance fields. For references of this kind the referrer_index parameter to the jvmtiObjectReferenceCallback is the index of the the instance field. The index is based on the order of all the object's fields. This includes all fields of the directly declared static and instance fields in the class, and includes all fields (both public and private) fields declared in superclasses and superinterfaces. The index is thus calculated by summing the index of field in the directly declared class (see GetClassFields), with the total number of fields (both public and private) declared in all superclasses and superinterfaces. The index starts at zero. public static final int JVMTI_REFERENCE_ARRAY_ELEMENT=3;//Reference from an array to one of its elements. For references of this kind the referrer_index parameter to the jvmtiObjectReferenceCallback is the array index. public static final int JVMTI_REFERENCE_CLASS_LOADER=4;// Reference from a class to its class loader. public static final int JVMTI_REFERENCE_SIGNERS=5;//Reference from a class to its signers array. public static final int JVMTI_REFERENCE_PROTECTION_DOMAIN=6;//Reference from a class to its protection domain. public static final int JVMTI_REFERENCE_INTERFACE=7;//Reference from a class to one of its interfaces. public static final int JVMTI_REFERENCE_STATIC_FIELD=8;//Reference from a class to the value of one of its static fields. For references of this kind the referrer_index parameter to the jvmtiObjectReferenceCallback is the index of the static field. The index is based on the order of the directly declared static and instance fields in the class (not inherited fields), starting at zero. See GetClassFields. public static final int JVMTI_REFERENCE_CONSTANT_POOL= 9;//Reference from a class to a resolved entry in the constant pool. For references of this kind the referrer_index parameter to the jvmtiObjectReferenceCallback is the index into constant pool table of the class, starting at 1. See The Constant Pool in the Java Virtual Machine Specification. public static final int ROOT_REFERENCE = 10; public static final int THREAD_REFERENCE= 11; /** *JNISignature for this method = (JJJJJB)V * @param referenceHolder A tag id of an object (if -1 means the root) * @param referencedObject A tag id of an object * @param fieldId A tag id for a Field referencing the object. If -1 that means a static reference in a method */ public void notifyReference(long referenceHolder,long referencedObject,long classTag, long index,long method,byte referenceType); /** Notifications of loaded classes*/ public void notifyClass(long classTag,Class clazz); /** Notifications of loaded classes*/ public void notifyObject(long classTag,long objectId, long bytes); } libjboss-profiler-java-1.0.CR4.orig/jvmti-src/java-src/org/jboss/profiler/jvmti/JVMTIInterface.java0000644000175000017500000011047210462070354033075 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.profiler.jvmti; import gnu.trove.TLongObjectHashMap; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.CharArrayWriter; import java.io.File; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.PrintStream; import java.io.PrintWriter; import java.io.Serializable; import java.lang.ref.SoftReference; import java.lang.ref.WeakReference; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.TreeSet; import java.util.WeakHashMap; import org.jboss.logging.Logger; /** * @author Clebert Suconic */ public class JVMTIInterface implements JVMTIInterfaceMBean { private static final Logger log = Logger.getLogger(JVMTIInterface.class); private static boolean isLoaded=true; static { try { System.loadLibrary("jbossAgent"); } catch (Throwable e) { isLoaded=false; log.error("The DLL couldn't be loaded, you won't be able to use any JVMTIInterface feature",e); } } private void addTo(Collection coll, Field[] obj) { for (int i=0;i=0;i--) { Field fields[] = ((Class)list.get(i)).getDeclaredFields(); if (fieldId=0 && currentLevel>=maxLevel) { out.println("
" + level + "MaxLevel"); return; } Integer index = new Integer(System.identityHashCode(source)); if (alreadyExplored.contains(index)) { if (source instanceof Class) { out.println("
" + level + " object instanceOf " + source + "@" + index + " was already described before on this report"); } else { out.println("
" + level + " object instanceOf " + source.getClass() + "@" + index + " was already described before on this report"); } return; } alreadyExplored.add(index); log.info("resolving references of " + callToString(source,useToString) + "..."); Long sourceTag = new Long(this.getTagOnObject(source)); ArrayList listPoints = (ArrayList)mapDataPoints.get(sourceTag); if (listPoints ==null) { log.info("didn't find references"); return; } log.info("References found"); Iterator iter = listPoints.iterator(); while (iter.hasNext()) { ReferenceDataPoint point = (ReferenceDataPoint)iter.next(); Object nextReference = treatReference(level, out, point, useToString); if (nextReference!=null && !weakAndSoft) { if (nextReference instanceof WeakReference || nextReference instanceof SoftReference) { nextReference=null; } } if (nextReference!=null) { exploreObject(out,nextReference,currentLevel+1,maxLevel,useToString,weakAndSoft,mapDataPoints,alreadyExplored); } } } /** This is used by JSPs to have access to internal features formating results according to the navigations. That's the only reason this method is public. * This is not intended to be used as part of the public API. * @urlBaseToFollow will be concatenated objId=3> obj to the outputStream*/ public Object treatReference(String level, PrintWriter out, ReferenceDataPoint point, boolean useToString) { Object referenceHolder = null; if (point.getReferenceHolder()==0 || point.getReferenceHolder()==-1) { referenceHolder=null; } else { referenceHolder = this.getObjectOnTag(point.getReferenceHolder()); } Object nextReference = null; switch (point.getReferenceType()) { case JVMTICallBack.JVMTI_REFERENCE_CLASS:;// Reference from an object to its class. out.print("
" + level + "InstanceOfReference:"); out.println("ToString=" + callToString(referenceHolder,useToString)); nextReference = referenceHolder; break; case JVMTICallBack.JVMTI_REFERENCE_FIELD://Reference from an object to the value of one of its instance fields. For references of this kind the referrer_index parameter to the jvmtiObjectReferenceCallback is the index of the the instance field. The index is based on the order of all the object's fields. This includes all fields of the directly declared static and instance fields in the class, and includes all fields (both public and private) fields declared in superclasses and superinterfaces. The index is thus calculated by summing the index of field in the directly declared class (see GetClassFields), with the total number of fields (both public and private) declared in all superclasses and superinterfaces. The index starts at zero. { String fieldName = null; if (referenceHolder == null) { fieldName = "Reference GONE"; } else { Class clazz = referenceHolder.getClass(); Field field = this.getObjectField(clazz,(int)point.getIndex()); if (field==null) { fieldName = "UndefinedField@" + referenceHolder; } else { fieldName = field.toString(); } } out.print("
" + level + " FieldReference " + fieldName + "=" + callToString(referenceHolder,useToString)); nextReference = referenceHolder; break; } case JVMTICallBack.JVMTI_REFERENCE_ARRAY_ELEMENT://Reference from an array to one of its elements. For references of this kind the referrer_index parameter to the jvmtiObjectReferenceCallback is the array index. if (referenceHolder==null) { out.println("
" + level +" arrayRef Position " + point.getIndex() + " is gone"); } else { out.println("
" + level +" arrayRef " + referenceHolder.getClass().getName() + "[" + point.getIndex() + "] id=@" + System.identityHashCode(referenceHolder) ); } nextReference = referenceHolder; break; case JVMTICallBack.JVMTI_REFERENCE_CLASS_LOADER:// Reference from a class to its class loader. out.println("
" + level +"ClassLoaderReference @ " + callToString(referenceHolder,useToString)); nextReference = referenceHolder; break; case JVMTICallBack.JVMTI_REFERENCE_SIGNERS://Reference from a class to its signers array. out.println("
" + level +"ReferenceSigner@" + callToString(referenceHolder,useToString) ); nextReference = referenceHolder; break; case JVMTICallBack.JVMTI_REFERENCE_PROTECTION_DOMAIN://Reference from a class to its protection domain. out.println("
" + level +"ProtectionDomain@" + callToString(referenceHolder,useToString) ); nextReference = referenceHolder; break; case JVMTICallBack.JVMTI_REFERENCE_INTERFACE://Reference from a class to one of its interfaces. out.println("
" + level +"ReferenceInterface@" + callToString(referenceHolder,useToString) ); nextReference = referenceHolder; break; case JVMTICallBack.JVMTI_REFERENCE_STATIC_FIELD://Reference from a class to the value of one of its static fields. For references of this kind the referrer_index parameter to the jvmtiObjectReferenceCallback is the index of the static field. The index is based on the order of the directly declared static and instance fields in the class (not inherited fields), starting at zero. See GetClassFields. { Class clazz = (Class)referenceHolder; Field field = this.getObjectField(clazz,(int)point.getIndex()); String fieldName = null; if (field==null) { fieldName = "UndefinedField@" + referenceHolder; } else { fieldName = field.toString(); } out.println("
" + level +" StaticFieldReference " + fieldName); nextReference = null; break; } case JVMTICallBack.JVMTI_REFERENCE_CONSTANT_POOL://Reference from a class to a resolved entry in the constant pool. For references of this kind the referrer_index parameter to the jvmtiObjectReferenceCallback is the index into constant pool table of the class, starting at 1. See The Constant Pool in the Java Virtual Machine Specification. out.println("
" + level +"ReferenceInterface@" + callToString(referenceHolder,useToString) ); nextReference = referenceHolder; break; case JVMTICallBack.ROOT_REFERENCE : out.println("
" + level +"Root"); nextReference = null; break; case JVMTICallBack.THREAD_REFERENCE:; Class methodClass = this.getMethodClass(point.getMethod()); if (methodClass!=null) { String className= null; if (methodClass!=null) { className = methodClass.getName(); } Thread.yield(); // this is weird but without this sleep here, the JVM crashes. /*try { Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); }*/ String methodName = this.getMethodName(point.getMethod()); out.println("
" + level + " Reference inside a method - " + className+ "::" + methodName); } nextReference = null; break; default: log.warn("unexpected reference " + point); } return nextReference; } /** This method tags the JVM and return an index. You can navigate through references using this returned HashMap. * This method can't be exposed through JMX as it would serialize a huge amount of data. * @return HashMap referencees> * */ public HashMap createIndexMatrix() throws IOException { final HashMap referencesMap = new HashMap(); File tmpFile = File.createTempFile("tmpRefs",".tmp"); this.notifyOnReferences(tmpFile.getAbsolutePath(),new JVMTICallBack() { int count=0; public void notifyReference(long referenceHolder, long referencedObject, long classTag, long index, long method, byte referenceType) { if (count==0) { log.info("started receiving references"); } count++; if (count%1000==0) { log.info(count + " references received"); } ReferenceDataPoint dataPoint = new ReferenceDataPoint(referenceHolder, referencedObject, classTag, index, method, referenceType); Long indexLong = new Long(referencedObject); ArrayList arrayList = (ArrayList)referencesMap.get(indexLong); if (arrayList==null) { arrayList = new ArrayList(); referencesMap.put(indexLong,arrayList); } arrayList.add(dataPoint); } public void notifyClass(long classTag, Class clazz) { } public void notifyObject(long classTag, long objectId, long bytes) { } }); tmpFile.delete(); return referencesMap; } /** * Show the reference holders tree of an object * @param className The name of the class to explore * @param maxLevel The number of levels to explode. Be careful as if you put this number too high, you migh endup in a forever loop, specially if your object is referencing something too generic * @param solveReferencesOnClass Will expose the tree on the class * @param solveReferencesOnClassLoader Will expode the tree on the classLoader (I mostly recommend to only look for classLoader's references) * @param useToString If true, will use toString when an object is printed. If False will use className@ * @param weakAndSoft If false, won't detail references on Weak and Soft References * @param printObject If true, Will print (with toString) every single instance of the object passed as parameter */ public String exploreClassReferences(String className, int maxLevel, boolean solveReferencesOnClasses, boolean solveReferencesOnClassLoaders, boolean useToString, boolean weakAndSoft, boolean printObjects) { this.forceGC(); if (!solveReferencesOnClasses && !solveReferencesOnClassLoaders && !printObjects) { return " you have to select at least solveReferences || solveClassLoaders || printObjects "; } HashMap referencesMap = null; try { referencesMap = createIndexMatrix(); } catch (Exception e) { CharArrayWriter charArray = new CharArrayWriter(); PrintWriter out = new PrintWriter(charArray); e.printStackTrace(out); return charArray.toString(); } try { return exploreClassReferences(className, maxLevel, solveReferencesOnClasses, solveReferencesOnClassLoaders, useToString, weakAndSoft, printObjects, referencesMap); } finally { referencesMap.clear(); this.releaseTags(); } } /** This is an overload to reuse the matrix index in case you already have indexed the JVM */ public String exploreClassReferences(String className, int maxLevel, boolean solveReferencesOnClasses, boolean solveReferencesOnClassLoaders, boolean useToString, boolean weakAndSoft, boolean printObjects, HashMap referencesMap) { CharArrayWriter charArray = new CharArrayWriter(); PrintWriter out = new PrintWriter(charArray); try { Class[] loadClasses = this.getLoadedClasses(); for (int i=0;i

References to " + loadClasses[i] + ""); if (solveReferencesOnClasses)exploreObject(out,loadClasses[i],0,maxLevel,useToString,weakAndSoft,referencesMap,new HashSet()); if (solveReferencesOnClassLoaders) { if (loadClasses[i].getClassLoader()!=null) { out.println("
references to its classloader " + loadClasses[i].getClassLoader() +""); exploreObject(out,loadClasses[i].getClassLoader(),0,maxLevel,useToString,weakAndSoft,referencesMap,new HashSet()); } } out.println("
"); if (printObjects) { Object objects[] = this.getAllObjects(loadClasses[i]); for (int j=0;j100)=" + obj.length); return charArray.toString(); } for (int i=0;iReferences to obj["+i+"]=" + (useToString?obj[i].toString():obj[i].getClass().getName())); out.println(exploreObjectReferences(referencesMap,obj[i],maxLevel,useToString)); } return charArray.toString(); } finally { referencesMap.clear(); this.releaseTags(); } } /** * Show the reference holders tree of an object. This returns a report you can visualize through MBean. */ public String exploreObjectReferences(HashMap referencesMap, Object thatObject, int maxLevel, boolean useToString) { CharArrayWriter charArray = new CharArrayWriter(); PrintWriter out = new PrintWriter(charArray); try { exploreObject(out,thatObject,0,maxLevel,useToString,false,referencesMap,new HashSet()); out.println("
"); return charArray.toString(); } catch (Exception e) { charArray = new CharArrayWriter(); out = new PrintWriter(charArray); e.printStackTrace(out); return charArray.toString(); } } /** Forces an OutOfMemoryError and releases the memory immediatly. This will force SoftReferences to go away. */ public void forceReleaseOnSoftReferences() { SoftReference reference = new SoftReference(new Object()); ArrayList list = new ArrayList(); int i=0; try { while(true) { list.add("A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String " + (i++)); if (i%1000==0) // doing the check on each 100 elements { if (reference.get()==null) { System.out.println("Break as the soft reference was gone"); break; } } } } catch (Throwable e) { } list.clear(); try { ByteArrayOutputStream byteout = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(byteout); out.writeObject(new Dummy()); ByteArrayInputStream byteInput = new ByteArrayInputStream(byteout.toByteArray()); ObjectInputStream input = new ObjectInputStream(byteInput); input.readObject(); } catch (Exception e) { e.printStackTrace(); } this.forceGC(); } /** Used just to serialize anything and release SoftCache on java Serialization */ static class Dummy implements Serializable { private static final long serialVersionUID = 1L; } /** * Will show a report of every class loaded on this JVM. At the beggining of the report you will see duplicated classes (classes loaded in more than one classLoader) */ public String listClassesHTMLReport() throws Exception { try { forceGC(); CharArrayWriter charArray = new CharArrayWriter(); PrintWriter out = new PrintWriter(charArray); Collection classSet = createTreeSet(new ClassSorterByClassName()); boolean printedHeader=false; ClassLoader systemClassLoaderDummy = new ClassLoader(){public String toString(){return "SystemClassLoader";}}; ArrayList classLoaderDuplicates = new ArrayList(); Iterator iter = classSet.iterator(); String currentName=null; Class currentClass = null; while (iter.hasNext()) { currentClass = (Class)iter.next(); if (currentName!=currentClass.getName()) { if (classLoaderDuplicates.size()>1) { if (!printedHeader) { out.println("
List of duplicated classes"); printedHeader=true; } out.println("
" + " Class " + currentName +" was loaded on these classLoaders:"); Iterator iterClassLoader = classLoaderDuplicates.iterator(); while (iterClassLoader.hasNext()) { ClassLoader loader = (ClassLoader) iterClassLoader.next(); out.println("
" + loader.toString()); } } currentName = currentClass.getName(); classLoaderDuplicates.clear(); } ClassLoader loader = currentClass.getClassLoader(); if (loader==null) { loader = systemClassLoaderDummy; } classLoaderDuplicates.add(loader ); currentName = currentClass.getName(); } if (classLoaderDuplicates.size()>1) { out.println("
" + " Class " + currentName +" was loaded on these classLoaders:"); Iterator iterClassLoader = classLoaderDuplicates.iterator(); while (iterClassLoader.hasNext()) { ClassLoader loader = (ClassLoader) iterClassLoader.next(); out.println("
" + loader.toString()); } } out.println("
List of classes by ClassLoader"); classSet = retrieveLoadedClassesByClassLoader(); // I will need a dummy reference, as the first classLoader on the iterator will be null ClassLoader currentClassLoader = new ClassLoader(){}; out.println("
"); iter = classSet.iterator(); while (iter.hasNext()) { Class clazz = (Class)iter.next(); if (currentClassLoader!=clazz.getClassLoader()) { currentClassLoader = clazz.getClassLoader(); out.println("
ClassLoader = " + (currentClassLoader==null?"System Class Loader":(currentClassLoader.toString())) + ""); } out.println("Class = " + clazz.getName()); } return new String(charArray.toCharArray()); } catch (Exception e) { e.printStackTrace(); throw e; } } /** Used by JSPs and JMX to report */ public Collection retrieveLoadedClassesByClassName() { Collection classSet; classSet = createTreeSet(new ClassSorterByClassName()); return classSet; } /** Used by JSPs and JMX to report */ public Collection retrieveLoadedClassesByClassLoader() { Collection classSet; classSet = createTreeSet(new ClassSorterByClassLoader()); return classSet; } private Collection createTreeSet(Comparator comparator) { Class[] classes = this.getLoadedClasses(); ArrayList classSet = new ArrayList(); for (int i=0;ipoint1.getInstances()) { InventoryDataPoint expectedIncrease = (InventoryDataPoint)expectedIncreasesHash.get(clazz); boolean failed=true; if (expectedIncrease!=null) { if ((point2.getInstances() - point1.getInstances())<=expectedIncrease.getInstances()) { failed=false; } } if (failed) { int expected=0; if (expectedIncrease!=null) { expected = expectedIncrease.getInstances(); } reportOK=false; reportOutput.println("
Class " + clazz.getName() + " had an increase of " + ((point2.getInstances() - point1.getInstances())-expected) + " instances represented by " + (point2.getBytes() - point1.getBytes()) + " bytes"); if (expectedIncrease!=null) { reportOutput.print("
" + ((point2.getInstances() - point1.getInstances())-expectedIncrease.getInstances()) + " higher than expected"); } } } } } } return reportOK; } private void addExpectedIncrease(HashMap expectedIncreasesHash,String name, int numberOfInstances) { Class tmpClass = getClassByName(name); if (tmpClass!=null) { expectedIncreasesHash.put(tmpClass,new InventoryDataPoint(tmpClass,numberOfInstances)); } } /** Returns a WeakHashMap summarizing the current JVM's inventory. * */ public Map produceInventory() throws IOException { this.forceGC(); InnerCallBack callBack = new InnerCallBack(); File tmpFileObjects = File.createTempFile("delete-me",".objects"); try { notifyInventory(true,null,tmpFileObjects.getAbsolutePath(),callBack); } finally { if (tmpFileObjects.exists()) { try { tmpFileObjects.delete(); } catch (Exception ignored) { } } } return callBack.maps; } /** Will list the current memory inventory. Exposed through JMX. */ public String inventoryReport() throws Exception { Map map = produceInventory(); TreeSet valuesSet = new TreeSet(map.values()); Iterator iterDataPoints = valuesSet.iterator(); CharArrayWriter charArray = new CharArrayWriter(); PrintWriter out = new PrintWriter(charArray); out.println(""); while (iterDataPoints.hasNext()) { InventoryDataPoint point = (InventoryDataPoint)iterDataPoints.next(); out.println(""); } out.println("
Class#Instances#Bytes
" + point.getClazz().getName() + "" + point.getInstances() + "" + point.getBytes() + "
"); return charArray.toString(); } /** Will print a report of every instance of the class passed by parameter. Exposed through JMX . */ public String printObjects(String className) throws Exception { CharArrayWriter charArray = new CharArrayWriter(); PrintWriter out = new PrintWriter(charArray); Object objects[] = this.getAllObjects(className); out.println(""); for (int i=0;i"); } } out.println("
"); out.println(objects[i]); if (objects[i] instanceof Object[]) { out.println(""); out.println("array of " + ((Object[])objects[i]).length); out.println("
"); return charArray.toString(); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/java-src/org/jboss/profiler/jvmti/JVMTIInterfaceMBean.javalibjboss-profiler-java-1.0.CR4.orig/jvmti-src/java-src/org/jboss/profiler/jvmti/JVMTIInterfaceMBean.0000644000175000017500000000377110462070354033141 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.profiler.jvmti; import java.util.Collection; public interface JVMTIInterfaceMBean { public void heapSnapshot(String basicFileName, String suffix); public void forceGC(); public Class[] retrieveLoadedClasses(); public Collection retrieveLoadedClassesByClassLoader(); public Object[] getReferenceHolders(Object [] objects); public Object[] getAllObjects(Class clazz); public Object[] getAllObjects(String clazz); public Class getClassByName(String className); public String listClassesHTMLReport() throws Exception; public String inventoryReport() throws Exception; public String printObjects(String className) throws Exception; public void forceReleaseOnSoftReferences(); public String exploreClassReferences(String className, int maxLevel, boolean solveReferencesOnClasses, boolean solveReferencesOnClassLoaders, boolean useToString, boolean weakAndSoft, boolean printObjects); public String exploreObjectReferences(String className, int maxLevel, boolean useToString); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/java-src/org/jboss/profiler/jvmti/ReferenceDataPoint.javalibjboss-profiler-java-1.0.CR4.orig/jvmti-src/java-src/org/jboss/profiler/jvmti/ReferenceDataPoint.j0000644000175000017500000000530510462070354033373 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.profiler.jvmti; public class ReferenceDataPoint { public ReferenceDataPoint(long referenceHolder,long referencedObject,long classTag, long index,long method,byte referenceType) { this.referenceHolder=referenceHolder; this.referencedObject=referencedObject; this.classTag = classTag; this.index=index; this.method=method; this.referenceType=referenceType; } private long referenceHolder; private long referencedObject; private long classTag; private long index; private long method; private byte referenceType; public long getIndex() { return index; } public void setIndex(long index) { this.index = index; } public long getMethod() { return method; } public void setMethod(long method) { this.method = method; } public long getReferencedObject() { return referencedObject; } public void setReferencedObject(long referencedObject) { this.referencedObject = referencedObject; } public long getReferenceHolder() { return referenceHolder; } public void setReferenceHolder(long referenceHolder) { this.referenceHolder = referenceHolder; } public byte getReferenceType() { return referenceType; } public void setReferenceType(byte referenceType) { this.referenceType = referenceType; } public long getClassTag() { return classTag; } public void setClassTag(long classTag) { this.classTag = classTag; } public String toString() { return super.toString() + " {referenceHolder=" + referenceHolder + "\n referencedObject=" + referencedObject + "\n classTag=" + classTag + "\n index=" + index + "\n method=" + method + "\n referenceType=" + referenceType + "}"; } } libjboss-profiler-java-1.0.CR4.orig/jvmti-src/linux/0000755000175000017500000000000010462070276022265 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/linux/compile.sh0000644000175000017500000000051610462070354024250 0ustar twernertwerner#!/bin/sh _INCLUDES="-I"$JAVA_HOME/include" -I"$JAVA_HOME/include/linux"" g++ $_INCLUDES -c ../native-src/jbossAgent.cpp g++ $_INCLUDES -c ../native-src/jbossAgentJNI.cpp g++ $_INCLUDES -c ../native-src/jbossAgentUtilities.cpp #gcc -G -o libjbossAgent.so $_INCLUDES -shared *.o g++ $_INCLUDES -shared -o libjbossAgent.so *.o libjboss-profiler-java-1.0.CR4.orig/jvmti-src/linux64/0000755000175000017500000000000010462070276022437 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/linux64/suse/0000755000175000017500000000000010462070276023416 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/linux64/compile.sh0000644000175000017500000000061410462070354024421 0ustar twernertwerner#!/bin/sh _INCLUDES="-I"$JAVA_HOME/include" -I"$JAVA_HOME/include/linux"" g++ -m64 -shared -fpic $_INCLUDES -c ../native-src/jbossAgent.cpp g++ -m64 -shared -fpic $_INCLUDES -c ../native-src/jbossAgentJNI.cpp g++ -m64 -shared -fpic $_INCLUDES -c ../native-src/jbossAgentUtilities.cpp #gcc -G -o libjbossAgent.so $_INCLUDES -shared *.o g++ $_INCLUDES -m64 -shared -o libjbossAgent.so *.o libjboss-profiler-java-1.0.CR4.orig/jvmti-src/macos/0000755000175000017500000000000010462070276022230 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/macos/compile.sh0000644000175000017500000000061610462070354024214 0ustar twernertwerner#!/bin/sh _INCLUDES="-I"$JAVA_HOME/include" -I"$JAVA_HOME/include/macos"" g++ -shared -fpic $_INCLUDES -c ../native-src/jbossAgent.cpp g++ -shared -fpic $_INCLUDES -c ../native-src/jbossAgentJNI.cpp g++ -shared -fpic $_INCLUDES -c ../native-src/jbossAgentUtilities.cpp #gcc -G -o libjbossAgent.so $_INCLUDES -shared *.o g++ -O0 -bundle $_INCLUDES -o libjbossAgent.jnilib *.o libjboss-profiler-java-1.0.CR4.orig/jvmti-src/mbean/0000755000175000017500000000000010462070276022210 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/mbean/jboss-service.xml0000644000175000017500000000031710462070354025506 0ustar twernertwerner libjboss-profiler-java-1.0.CR4.orig/jvmti-src/mbean/jvmti-xmbean.xml0000644000175000017500000001001010462070354025320 0ustar twernertwerner JVMTIWrapper MBean Utility / JBoss Profiler Tool org.jboss.profiler.jvmti.JVMTIInterface Creates a snapshot of the current heap state heapSnapshot A Prefix file, for example /tmp/memory directoryAndPrefix java.lang.String suffix file, example log suffix java.lang.String void Show the reference holders tree of an object exploreClassReferences The name of the class to explore className java.lang.String maxLevel int solveReferencesOnClass boolean solveReferencesOnClassLoader boolean useToString boolean weakAndSoft boolean If true will print every object instanceof parameter className printObjects boolean java.lang.String Will force a fullGC using internal JVMTI operation. This doesn't use System.gc(). After calling this method a FullGC will really happen. forceGC Will show a report of every class loaded on this JVM. At the beggining of the report you will see duplicated classes (classes loaded in more than one classLoader) listClassesHTMLReport java.lang.String Will force an OutOfMemoryError and clean the memory immediatly. This will force any SoftReference being released. forceReleaseOnSoftReferences Will list the current memory inventory . inventoryReport java.lang.String Print every object on a given class printObjects The name of the class to explore className java.lang.String java.lang.String Print every object Reference Tree on a given class. (Careful: don't use any extensive object as String, as this method might hang. exploreObjectReferences The name of the class to explore className java.lang.String maxLevel int useToString boolean java.lang.String libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src/0000755000175000017500000000000010462070276023201 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src/jbossAgent.cpp0000644000175000017500000000134610462070354026005 0ustar twernertwerner#include #include #include "jvmti.h" #include "org_jboss_profiler_jvmti_JVMTIInterface.h" #define AGENT_MAIN #include "jbossAgent.h" jint initJVMTI(JavaVM *jvm) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_0); if (res!=JNI_OK) { return res; } jvmtiError error; jvmtiCapabilities capabilities; error = jvmti->GetCapabilities(&capabilities); verifyError(error); capabilities.can_tag_objects = 1; capabilities.can_generate_garbage_collection_events = 1; error= jvmti->AddCapabilities(&capabilities); verifyError(error); return JNI_OK; } JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { return initJVMTI(jvm); } libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src/jbossAgent.h0000644000175000017500000000336310462070354025453 0ustar twernertwerner// It requires you to include "string.h" and "io.h" #ifdef AGENT_MAIN jvmtiEnv *jvmti = NULL; #else extern jvmtiEnv *jvmti; #endif #define REFERENCE_ROOT 10 #define REFERENCE_THREAD 11 typedef struct _iterateControl { FILE * fileObjects; FILE * fileReferences; FILE * fileClasses; jlong genericCount; } IterateControl; typedef struct _iteraOverObjectsControl { jint size; jint maxsize; jlong * tags; jlong count; } IteraOverObjectsControl; inline void verifyError(jvmtiError error) { if ( error != JVMTI_ERROR_NONE ) { char * errorName; jvmti->GetErrorName(error,&errorName); fprintf (stderr,"JVMTI Error %s\n",errorName); fflush(stderr); jvmti->Deallocate((unsigned char *)errorName); } } inline void addTag(IteraOverObjectsControl * control, jlong & taglong) { if (control->size>=control->maxsize) { unsigned char * buffer; jvmtiError error = jvmti->Allocate(sizeof(jlong) * (control->maxsize+1000),&buffer); verifyError(error); jlong * newbuffer = (jlong *) buffer; if (control->tags!=NULL) { for (jint i=0;isize;i++) { newbuffer[i] = control->tags[i]; } jvmti->Deallocate((unsigned char *)control->tags); } control->tags = newbuffer; control->maxsize=control->size+1000; } control->tags[control->size++] = taglong; } void throwException(JNIEnv * env,char * clazz, char * message); jint initJVMTI(JavaVM *jvm); inline int checkJVMTI(JNIEnv * env) { if (jvmti==NULL) { throwException(env,"java/lang/RuntimeException","Agent not initialized"); return 0; } return 1; } libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src/jbossAgentJNI.cpp0000644000175000017500000006405310462070354026352 0ustar twernertwerner#include #include #include "jvmti.h" //#define DEBUG 0 #include "org_jboss_profiler_jvmti_JVMTIInterface.h" #include "jbossAgent.h" /** Local function for dealing with memory heaps... loading objects */ void memoryWriteReference(IterateControl* iterate, jlong tagReferrer, jlong tagReferee, jint index) { #ifdef WINDOWS fprintf (iterate->fileReferences,"%I64d,%I64d,%ld\n",tagReferrer,tagReferee,index); #else fprintf (iterate->fileReferences,"%lld,%lld,%ld\n",tagReferrer,tagReferee,index); #endif } /** Local function for dealing with memory heaps... loading objects */ void memoryWriteThreadReference(IterateControl* iterate, jlong tagReferrer, jlong tagReferee, jint index) { #ifdef WINDOWS fprintf (iterate->fileReferences,"Thread%I64d,%I64d,%ld\n",tagReferrer,tagReferee,index); #else fprintf (iterate->fileReferences,"Thread%lld,%lld,%ld\n",tagReferrer,tagReferee,index); #endif } /** Local function for dealing with memory heaps... loading objects */ void memoryWriteObject(IterateControl* iterate, jlong objectTag, jlong classTag, jlong size) { long longclassTag = (long)classTag; #ifdef WINDOWS fprintf (iterate->fileObjects,"%I64d,%I64d,%I64d\n",objectTag,classTag,size); #else fprintf (iterate->fileObjects,"%lld,%lld,%lld\n",objectTag,classTag,size); #endif } /** Local function for dealing with memory heaps... loading classes */ void memoryWriteClass(JNIEnv *env, jlong tag, IterateControl* iterate, jclass iterateClass) { char * signature; char * genericPointer; jvmtiError err = jvmti->GetClassSignature(iterateClass,&signature,&genericPointer); if ( err != JVMTI_ERROR_NONE ) { verifyError(err); return; } jobject classLoader; jvmti->GetClassLoader(iterateClass,&classLoader); jlong tagLoader = 0; if (classLoader!=NULL) { err = jvmti->GetTag(classLoader,&tagLoader); if ( err != JVMTI_ERROR_NONE ) { verifyError(err); } } if (tagLoader==0 && classLoader!=NULL) { tagLoader = iterate->genericCount++; jvmti->SetTag(classLoader,tagLoader); jlong classLoaderClassTag; jclass classLoaderClass = env->GetObjectClass(classLoader); jvmti->GetTag(classLoaderClass,&classLoaderClassTag); jlong size; jvmti->GetObjectSize(classLoaderClass,&size); memoryWriteObject(iterate,tagLoader,classLoaderClassTag,size); } #ifdef WINDOWS fprintf (iterate->fileClasses,"%10I64d,%s,%I64d\n",tag,signature,tagLoader); #else fprintf (iterate->fileClasses,"%lld,%s,%lld\n",tag,signature,tagLoader); #endif if (signature!=NULL) jvmti->Deallocate((unsigned char *)signature); if (genericPointer!=NULL) jvmti->Deallocate((unsigned char *)genericPointer); } JNIEXPORT jobjectArray JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getLoadedClasses (JNIEnv * env, jobject thisObject) { if (!checkJVMTI(env)) { return NULL; } jclass loadedClass = env->FindClass("java/lang/Class"); #ifdef DEBUG fprintf (stderr,"LoadedClass = %ld\n",loadedClass); #endif jint classCount=0; jclass * classesPointer; jvmti->GetLoadedClasses(&classCount,&classesPointer); // Set the object array jobjectArray arrayReturn = env->NewObjectArray(classCount,loadedClass,0); for (jsize i=0;iSetObjectArrayElement(arrayReturn,i, classesPointer[i]); } jvmti->Deallocate((unsigned char *)classesPointer); return arrayReturn; } /** Callback JVMTI function for threadReference */ static jvmtiIterationControl JNICALL iterateThreadReference (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong thread_tag, jint depth, jmethodID method, jint slot, void* user_data) { IterateControl * iterate = (IterateControl *) user_data; if ((*tag_ptr)==0) { *tag_ptr = iterate->genericCount++; memoryWriteObject(iterate, *tag_ptr,class_tag,size); } if (!class_tag) { fprintf (stderr,"ClassTAG can't be NULL... it happened at iterateThreadReference\n"); } #ifdef DEBUG fprintf (stderr,"Thread - classTag = %ld\n",class_tag); #endif memoryWriteThreadReference(iterate, thread_tag, *tag_ptr, 0); return JVMTI_ITERATION_CONTINUE; } /** Callback JVMTI function for Root references */ jvmtiIterationControl JNICALL iterateRoot (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) { IterateControl * iterate = (IterateControl *) user_data; if ((*tag_ptr)==0) { *tag_ptr = iterate->genericCount++; memoryWriteObject(iterate, *tag_ptr,class_tag,size); } #ifdef DEBUG fprintf (stderr,"Root - classTag = %ld and class=%ld reference = %ld\n",class_tag,*tag_ptr); #endif memoryWriteReference(iterate, 0, *tag_ptr, 0); return JVMTI_ITERATION_CONTINUE; } /** Callback JVMTI function for Object Relationships */ jvmtiIterationControl JNICALL iterateObjectRelationship (jvmtiObjectReferenceKind reference_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong referrer_tag, jint referrer_index, void* user_data) { /*if (reference_kind==JVMTI_REFERENCE_CLASS || reference_kind==JVMTI_REFERENCE_CLASS_LOADER || reference_kind==JVMTI_REFERENCE_INTERFACE || reference_kind==JVMTI_REFERENCE_CONSTANT_POOL) { return JVMTI_ITERATION_CONTINUE; } */ IterateControl * iterate = (IterateControl *) user_data; if ((*tag_ptr)==0) { *tag_ptr = iterate->genericCount++; memoryWriteObject(iterate, *tag_ptr,class_tag,size); } memoryWriteReference(iterate, referrer_tag, *tag_ptr, referrer_index); #ifdef DEBUG // fprintf (stderr,"Relationship between %ld and %ld\n",referrer_tag, *tag_ptr); fprintf (stderr,"Relationship between %ld ",*tag_ptr); fprintf (stderr,"and reftag=%ld\n",referrer_tag); #endif return JVMTI_ITERATION_CONTINUE; } jvmtiIterationControl JNICALL cleanTag (jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) { *tag_ptr=0; return JVMTI_ITERATION_CONTINUE; } void releaseTags() { jvmti->IterateOverHeap( JVMTI_HEAP_OBJECT_TAGGED, &cleanTag, NULL); } JNIEXPORT void JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_heapSnapshot (JNIEnv * env, jclass clazz, jstring classesFileName, jstring referencesFileName, jstring objectsFileName) { jint classCount=0; jclass * classesPointer; const char * strClasses = env->GetStringUTFChars(classesFileName,NULL); const char * strReferences = env->GetStringUTFChars(referencesFileName,NULL); const char * strObjects = env->GetStringUTFChars(objectsFileName,NULL); if (!checkJVMTI(env)) { return; } IterateControl iterate; iterate.genericCount=0; iterate.fileObjects = fopen (strObjects,"w+"); if (iterate.fileObjects==NULL) { fprintf (stderr,"couldn't open file %s\n",strObjects); throwException(env,"java/lang/RuntimeException","Couldn't open objects file"); return; } fprintf (iterate.fileObjects,"objectTag,classTag,size\n"); iterate.fileReferences = fopen (strReferences,"w+"); if (iterate.fileReferences==NULL) { fprintf (stderr,"couldn't open file %s\n",strReferences); throwException(env,"java/lang/RuntimeException","Couldn't open references file"); return; } fprintf (iterate.fileReferences,"tagReferrer,tagReferee,index\n"); iterate.fileClasses = fopen (strClasses,"w+"); if (iterate.fileClasses==NULL) { fprintf (stderr,"couldn't open file %s\n",strClasses); throwException(env,"java/lang/RuntimeException","Couldn't open classes file"); return; } fprintf (iterate.fileClasses,"tagClass,signature,tagClassLoader\n"); env->ReleaseStringUTFChars(classesFileName,strClasses); env->ReleaseStringUTFChars(referencesFileName,strReferences); env->ReleaseStringUTFChars(objectsFileName,strObjects); jvmti->GetLoadedClasses(&classCount,&classesPointer); jvmtiError err; // we need to first setAllTags, to avoid dependencies between classes and classLoaders for (jsize i=0;iSetTag(classesPointer[i],i+1); iterate.genericCount = i; } iterate.genericCount = iterate.genericCount + 1002; for (jsize i=0;iGetTag(classesPointer[i],&classTag); //err = jvmti->SetTag(classesPointer[i],i); if ( err != JVMTI_ERROR_NONE ) { verifyError(err); return; } memoryWriteClass(env, classTag, &iterate,classesPointer[i]); } jvmti->Deallocate((unsigned char *)classesPointer); err = jvmti->IterateOverReachableObjects(iterateRoot, iterateThreadReference, iterateObjectRelationship, &iterate); verifyError(err); fclose(iterate.fileObjects); fclose(iterate.fileReferences); fclose(iterate.fileClasses); releaseTags(); verifyError(err); } JNIEXPORT void JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_forceGC (JNIEnv * env, jobject thisObject) { if (!checkJVMTI(env)) { return; } jvmti->ForceGarbageCollection(); } jvmtiIterationControl JNICALL iterate_getAllObjects (jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) { IteraOverObjectsControl * control = (IteraOverObjectsControl *) user_data; *tag_ptr=1; control->count++; // fprintf (stderr,"Iterate getAllObjects = %ld\n",control->count); return JVMTI_ITERATION_CONTINUE; } /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: getAllObjects * Signature: (Ljava/lang/Class;)[Ljava/lang/Object; */ JNIEXPORT jobjectArray JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getAllObjects (JNIEnv * env, jobject jvmtiInteface_this, jclass klass) { if (!checkJVMTI(env)) { return NULL; } jclass loadedObject = env->FindClass("java/lang/Object"); IteraOverObjectsControl control; control.size = 0; control.maxsize = 0; control.count=0; jvmti->IterateOverInstancesOfClass( klass, JVMTI_HEAP_OBJECT_EITHER, iterate_getAllObjects, &control); jint countObjts=0; jobject * objs; jlong * tagResults; jlong idToQuery=1; /// http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html#GetObjectsWithTags jvmti->GetObjectsWithTags(1, &idToQuery, &countObjts, &objs, &tagResults); // Set the object array jobjectArray arrayReturn = env->NewObjectArray(countObjts,loadedObject,0); for (jsize i=0;iSetObjectArrayElement(arrayReturn,i, objs[i]); } jvmti->Deallocate((unsigned char *)tagResults); jvmti->Deallocate((unsigned char *)objs); releaseTags(); return arrayReturn; } /** Callback JVMTI function for threadReference */ static jvmtiIterationControl JNICALL iterateThreadReferenceLookupReference (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong thread_tag, jint depth, jmethodID method, jint slot, void* user_data) { IteraOverObjectsControl * control = (IteraOverObjectsControl *)user_data; if (*tag_ptr==10) { addTag(control,thread_tag); } else if (*tag_ptr!=10) { *tag_ptr=control->count++; } return JVMTI_ITERATION_CONTINUE; } /** Callback JVMTI function for Root references */ jvmtiIterationControl JNICALL iterateRootLookupReference (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) { IteraOverObjectsControl * control = (IteraOverObjectsControl *)user_data; if (*tag_ptr!=10) { *tag_ptr=control->count++; } return JVMTI_ITERATION_CONTINUE; } /** Callback JVMTI function for Object Relationships */ jvmtiIterationControl JNICALL iterateObjectRelationshipLookupReference (jvmtiObjectReferenceKind reference_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong referrer_tag, jint referrer_index, void* user_data) { IteraOverObjectsControl * control = (IteraOverObjectsControl *)user_data; if (*tag_ptr==10) { addTag(control,referrer_tag); } else if (*tag_ptr!=10) { *tag_ptr=control->count++; } return JVMTI_ITERATION_CONTINUE; } JNIEXPORT jobjectArray JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getReferenceHolders (JNIEnv * env, jobject thisObject, jobjectArray objectArray) { if (!checkJVMTI(env)) { return NULL; } jobject referencedObject; jsize arrayLength = env->GetArrayLength(objectArray); for (jsize i=0;iGetObjectArrayElement(objectArray,i); jvmti->SetTag(referencedObject,(jlong)10); } IteraOverObjectsControl control; control.size = 0; control.maxsize = 0; control.count=1000; control.tags=NULL; jvmtiError err = jvmti->IterateOverReachableObjects(iterateRootLookupReference, iterateThreadReferenceLookupReference, iterateObjectRelationshipLookupReference, &control); jint countObjts=0; jobject * objs=NULL; jlong * tagResults; jlong idToQuery=1; /// http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html#GetObjectsWithTags jvmti->GetObjectsWithTags(control.size, control.tags, &countObjts, &objs, &tagResults); // Set the object array jclass loadedObject = env->FindClass("java/lang/Object"); jobjectArray arrayReturn = env->NewObjectArray(countObjts,loadedObject,0); for (jsize i=0;iSetObjectArrayElement(arrayReturn,i, objs[i]); } if (control.tags!=NULL) { jvmti->Deallocate((unsigned char *)control.tags); } jvmti->Deallocate((unsigned char *)tagResults); jvmti->Deallocate((unsigned char *)objs); releaseTags(); return arrayReturn; } JNIEXPORT void JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_releaseTags (JNIEnv *, jobject) { releaseTags(); } void writeReferenceOnNotify(FILE * fileReference,jlong referenceHolder,jlong referencedObject,jlong classTag,jlong index,jmethodID method,jbyte referenceType) { if (fileReference!=NULL) { fwrite((const void *) &referenceHolder,sizeof(referenceHolder),1,fileReference); fwrite((const void *) &referencedObject,sizeof(referencedObject),1,fileReference); fwrite((const void *) &classTag,sizeof(classTag),1,fileReference); fwrite((const void *) &index,sizeof(index),1,fileReference); fwrite((const void *) &referenceType,sizeof(referenceType),1,fileReference); fwrite((const void *) &method,sizeof(method),1,fileReference); } } void writeObjectOnNotify(FILE * fileReference,jlong classTag,jlong objectTag,jlong bytes) { if (fileReference!=NULL) { fwrite((const void *) &classTag,sizeof(classTag),1,fileReference); fwrite((const void *) &objectTag,sizeof(objectTag),1,fileReference); fwrite((const void *) &bytes,sizeof(bytes),1,fileReference); } } /** Callback JVMTI function for Root references used on notifyOnReferences*/ jvmtiIterationControl JNICALL iterateRootOnNotify (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) { IterateControl * iterate = (IterateControl *) user_data; if ((*tag_ptr)==0) { *tag_ptr = iterate->genericCount++; writeObjectOnNotify(iterate->fileObjects, class_tag, *tag_ptr,size); } writeReferenceOnNotify(iterate->fileReferences,-1,*tag_ptr,0,0,NULL,10); #ifdef DEBUG fprintf (stderr,"Root - classTag = %ld and class=%ld reference = %ld\n",class_tag,*tag_ptr); #endif return JVMTI_ITERATION_CONTINUE; } /** Callback JVMTI function for threadReference used on notifyOnReferences*/ static jvmtiIterationControl JNICALL iterateThreadReferenceOnNotify (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong thread_tag, jint depth, jmethodID method, jint slot, void* user_data) { IterateControl * iterate = (IterateControl *) user_data; if ((*tag_ptr)==0) { *tag_ptr = iterate->genericCount++; writeObjectOnNotify(iterate->fileObjects, class_tag, *tag_ptr,size); } if (!class_tag) { fprintf (stderr,"ClassTAG can't be NULL... it happened at iterateThreadReference\n"); } #ifdef DEBUG fprintf (stderr,"Thread - classTag = %ld\n",class_tag); #endif // meed to verify this option writeReferenceOnNotify(iterate->fileReferences,class_tag,*tag_ptr,class_tag,0,method,REFERENCE_THREAD); return JVMTI_ITERATION_CONTINUE; } /** Callback JVMTI function for Object Relationships used on notifyOnReferences*/ jvmtiIterationControl JNICALL iterateObjectRelationshipOnNotify (jvmtiObjectReferenceKind reference_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong referrer_tag, jint referrer_index, void* user_data) { if (reference_kind==JVMTI_REFERENCE_CONSTANT_POOL) { return JVMTI_ITERATION_CONTINUE; } /*if (reference_kind==JVMTI_REFERENCE_CLASS || reference_kind==JVMTI_REFERENCE_CLASS_LOADER || reference_kind==JVMTI_REFERENCE_INTERFACE || reference_kind==JVMTI_REFERENCE_CONSTANT_POOL) { return JVMTI_ITERATION_CONTINUE; } */ IterateControl * iterate = (IterateControl *) user_data; if ((*tag_ptr)==0) { *tag_ptr = iterate->genericCount++; writeObjectOnNotify(iterate->fileObjects, class_tag, *tag_ptr,size); } writeReferenceOnNotify(iterate->fileReferences, referrer_tag, *tag_ptr, class_tag, referrer_index, NULL, reference_kind); return JVMTI_ITERATION_CONTINUE; } JNIEXPORT void JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_notifyInventory (JNIEnv *env, jobject thisObject, jboolean notifyClasses, jstring temporaryFileReferences, jstring temporaryFileObjects, jobject jvmtiCallBack) { if (!checkJVMTI(env)) { return; } IterateControl iterate; releaseTags(); jvmtiError err; if (temporaryFileReferences!=NULL) { const char * strTemporaryFile = strTemporaryFile = env->GetStringUTFChars(temporaryFileReferences,NULL); iterate.fileReferences = fopen(strTemporaryFile,"wb+"); if (iterate.fileReferences==NULL) { fprintf (stderr,"Couldn't open %s\n",strTemporaryFile); throwException(env,"java/lang/RuntimeException","Couldn't open references file"); return; } env->ReleaseStringUTFChars(temporaryFileReferences,strTemporaryFile); } else { iterate.fileReferences = NULL; } if (temporaryFileObjects!=NULL) { const char * strTemporaryFile = strTemporaryFile = env->GetStringUTFChars(temporaryFileObjects,NULL); iterate.fileObjects = fopen(strTemporaryFile,"wb+"); if (iterate.fileObjects==NULL) { fprintf (stderr,"Couldn't open %s\n",strTemporaryFile); throwException(env,"java/lang/RuntimeException","Couldn't open objects file"); return; } env->ReleaseStringUTFChars(temporaryFileObjects,strTemporaryFile); } else { iterate.fileObjects=NULL; } if (!checkJVMTI(env)) { return; } jint classCount=0; jclass * classesPointer; jvmti->GetLoadedClasses(&classCount,&classesPointer); // we need to first setAllTags, to avoid dependencies between classes and classLoaders for (jsize i=0;iSetTag(classesPointer[i],i+1); } jclass clazz = env->GetObjectClass(jvmtiCallBack); jmethodID methodNotifyClass = env->GetMethodID(clazz,"notifyClass","(JLjava/lang/Class;)V"); if (methodNotifyClass==NULL) { throwException(env,"java/lang/RuntimeException","Method notifyClass not found on JVMTICallBack"); return; } jmethodID notifyMethod = env->GetMethodID(clazz,"notifyReference","(JJJJJB)V"); if (notifyMethod==NULL) { throwException(env,"java/lang/RuntimeException","Couldn't find notifyReference"); return ; } jmethodID notifyMethodObject = env->GetMethodID(clazz,"notifyObject","(JJJ)V"); if (notifyMethodObject==NULL) { throwException(env,"java/lang/RuntimeException","Couldn't find notifyObject"); return ; } fflush(stderr); iterate.genericCount=classCount + 1000; jvmti->ForceGarbageCollection(); fflush(stderr); err = jvmti->IterateOverReachableObjects(iterateRootOnNotify, iterateThreadReferenceOnNotify, iterateObjectRelationshipOnNotify, &iterate); verifyError(err); if (notifyClasses) { // we need to first setAllTags, to avoid dependencies between classes and classLoaders for (jsize i=0;iCallVoidMethod(jvmtiCallBack,methodNotifyClass,(jlong)(i+1),classesPointer[i]); } } jvmti->Deallocate((unsigned char *)classesPointer); if (iterate.fileObjects!=NULL) { fseek(iterate.fileObjects,SEEK_SET,0l); jlong classTag=0; jlong objectTag=0; jlong bytes=0; while (!feof(iterate.fileObjects)) { fread((void *) &classTag,sizeof(classTag),1,iterate.fileObjects); fread((void *) &objectTag,sizeof(objectTag),1,iterate.fileObjects); fread((void *) &bytes,sizeof(bytes),1,iterate.fileObjects); env->CallVoidMethod(jvmtiCallBack,notifyMethodObject,classTag,objectTag,bytes); } } if (iterate.fileReferences!=NULL) { fseek(iterate.fileReferences,SEEK_SET,0l); jlong referenceHolder=0; jlong referencedObject=0; jlong classTag; jlong index=0; jbyte referenceType=0; jmethodID method; jlong methodParameter=0; while (!feof(iterate.fileReferences)) { fread((void *) &referenceHolder,sizeof(referenceHolder),1,iterate.fileReferences); fread((void *) &referencedObject,sizeof(referencedObject),1,iterate.fileReferences); fread((void *) &classTag,sizeof(classTag),1,iterate.fileReferences); fread((void *) &index,sizeof(index),1,iterate.fileReferences); fread((void *) &referenceType,sizeof(referenceType),1,iterate.fileReferences); fread((void *) &method,sizeof(method),1,iterate.fileReferences); // this line generates a warning due to this convertion. You can safely ignore this methodParameter = (jlong)method; env->CallVoidMethod(jvmtiCallBack,notifyMethod,referenceHolder,referencedObject,classTag, index,methodParameter,referenceType); } fclose(iterate.fileReferences); } verifyError(err); } JNIEXPORT jlong JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getTagOnObject (JNIEnv * env, jobject thisObject, jobject taggedObject) { if (!checkJVMTI(env)) { return 0; } jlong retTag; jvmti->GetTag(taggedObject,&retTag); return retTag; } JNIEXPORT jobject JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getObjectOnTag (JNIEnv * env, jobject thisObject, jlong tag) { if (!checkJVMTI(env)) { return NULL; } jint countObjts=0; jobject * objs; jlong * tagResults; if (tag<=0) { throwException(env,"java/lang/RuntimeException","Can't use a tag=0"); return NULL; } /// http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html#GetObjectsWithTags jvmti->GetObjectsWithTags(1, &tag, &countObjts, &objs, &tagResults); jobject retObject = NULL; if (countObjts==1) { retObject = objs[0]; } jvmti->Deallocate((unsigned char *)tagResults); jvmti->Deallocate((unsigned char *)objs); return retObject; } JNIEXPORT jobject JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getObjectField (JNIEnv * env, jobject thisObject, jclass clazz, jboolean isStatic,jlong fieldIndex) { if (!checkJVMTI(env)) { return NULL; } jint fieldCount=0; jfieldID * fields; jvmtiError err = jvmti->GetClassFields(clazz,&fieldCount,&fields); if ( err != JVMTI_ERROR_NONE ) { verifyError(err); return NULL; } jobject field = NULL; if (fields!=NULL && fieldIndexToReflectedField(clazz,fields[fieldIndex],0); } if (fieldCount>0 && fields!=NULL) { jvmti->Deallocate((unsigned char *)fields); } return field; } JNIEXPORT jstring JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getMethodName (JNIEnv * env, jobject thisObject, jlong lMethodId) { if (!checkJVMTI(env)) { return NULL; } if (lMethodId==0 || lMethodId==-1) return NULL; char * name; char * signature; jmethodID id = (jmethodID)lMethodId; jvmti->GetMethodName(id,&name,NULL,NULL); jstring retString = env->NewStringUTF(name); jvmti->Deallocate((unsigned char *) name); jvmti->Deallocate((unsigned char *) signature); return retString; } JNIEXPORT jstring JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getMethodSignature (JNIEnv * env, jobject thisObject, jlong lMethodId) { if (!checkJVMTI(env)) { return NULL; } if (lMethodId==0 || lMethodId==-1) return NULL; char * name; char * signature; jmethodID id = (jmethodID)lMethodId; jvmti->GetMethodName(id,NULL,&name,NULL); jstring retString = env->NewStringUTF(name); jvmti->Deallocate((unsigned char *) name); jvmti->Deallocate((unsigned char *) signature); return retString; } JNIEXPORT jclass JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getMethodClass (JNIEnv * env, jobject thisObject, jlong lMethodId) { if (!checkJVMTI(env)) { return NULL; } if (lMethodId==0 || lMethodId==-1) return NULL; jmethodID id = (jmethodID)lMethodId; jclass retClass; jvmti->GetMethodDeclaringClass(id,&retClass); return retClass; } JNIEXPORT jboolean JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_internalIsConfiguredProperly (JNIEnv * env, jobject thisObject) { return jvmti!=NULL; } libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src/jbossAgentUtilities.cpp0000644000175000017500000000101110462070354027666 0ustar twernertwerner#include #include #include #include "jvmti.h" #include "jbossAgent.h" void throwException(JNIEnv * env,char * clazz, char * message) { jclass exceptionClass = env->FindClass(clazz); if (exceptionClass==NULL) { exceptionClass = env->FindClass("java/lang/RuntimeException"); if (exceptionClass==NULL) { fprintf (stderr,"Couldn't throw exception %s - %s\n",clazz,message); } } env->ThrowNew(exceptionClass,message); } libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src/org_jboss_profiler_jvmti_JVMTIInterface.h0000644000175000017500000000730410462070354033247 0ustar twernertwerner/* DO NOT EDIT THIS FILE - it is machine generated */ #include /* Header for class org_jboss_profiler_jvmti_JVMTIInterface */ #ifndef _Included_org_jboss_profiler_jvmti_JVMTIInterface #define _Included_org_jboss_profiler_jvmti_JVMTIInterface #ifdef __cplusplus extern "C" { #endif /* Inaccessible static: log */ /* Inaccessible static: isLoaded */ /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: forceGC * Signature: ()V */ JNIEXPORT void JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_forceGC (JNIEnv *, jobject); /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: releaseTags * Signature: ()V */ JNIEXPORT void JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_releaseTags (JNIEnv *, jobject); /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: notifyInventory * Signature: (ZLjava/lang/String;Ljava/lang/String;Lorg/jboss/profiler/jvmti/JVMTICallBack;)V */ JNIEXPORT void JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_notifyInventory (JNIEnv *, jobject, jboolean, jstring, jstring, jobject); /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: getReferenceHolders * Signature: ([Ljava/lang/Object;)[Ljava/lang/Object; */ JNIEXPORT jobjectArray JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getReferenceHolders (JNIEnv *, jobject, jobjectArray); /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: getLoadedClasses * Signature: ()[Ljava/lang/Class; */ JNIEXPORT jobjectArray JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getLoadedClasses (JNIEnv *, jobject); /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: getAllObjects * Signature: (Ljava/lang/Class;)[Ljava/lang/Object; */ JNIEXPORT jobjectArray JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getAllObjects (JNIEnv *, jobject, jclass); /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: getTagOnObject * Signature: (Ljava/lang/Object;)J */ JNIEXPORT jlong JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getTagOnObject (JNIEnv *, jobject, jobject); /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: getObjectOnTag * Signature: (J)Ljava/lang/Object; */ JNIEXPORT jobject JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getObjectOnTag (JNIEnv *, jobject, jlong); /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: internalIsConfiguredProperly * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_internalIsConfiguredProperly (JNIEnv *, jobject); /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: getMethodName * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getMethodName (JNIEnv *, jobject, jlong); /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: getMethodSignature * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getMethodSignature (JNIEnv *, jobject, jlong); /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: getMethodClass * Signature: (J)Ljava/lang/Class; */ JNIEXPORT jclass JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_getMethodClass (JNIEnv *, jobject, jlong); /* * Class: org_jboss_profiler_jvmti_JVMTIInterface * Method: heapSnapshot * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_org_jboss_profiler_jvmti_JVMTIInterface_heapSnapshot (JNIEnv *, jclass, jstring, jstring, jstring); #ifdef __cplusplus } #endif #endif libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src-library/0000755000175000017500000000000010462070276024643 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src-library/BaseLogger.cpp0000644000175000017500000000020010462070354027346 0ustar twernertwerner#include #include #include "BaseLogger.h" BaseLogger::BaseLogger() { } BaseLogger::~BaseLogger() { } libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src-library/BaseLogger.h0000644000175000017500000000740410462070354027030 0ustar twernertwerner#ifndef BASELOGGER_H_ #define BASELOGGER_H_ #include #include "TimeUtil.h" #define CONST_LOADCLASS 1 #define CONST_LOADMETHOD 2 #define CONST_LOADOBJECT 3 #define CONST_UNLOADOBJECT 4 #define CONST_GCSTART 5 #define CONST_GCFINISH 6 #define CONST_THREADSTART 7 #define CONST_THREADEND 8 #define CONST_ENTERMETHOD 9 #define CONST_EXITMETHOD 10 #define CONST_MONITOR_IN 11 #define CONST_MONITOR_OUT 12 #define CONST_CONTENDED_ENTER 13 #define CONST_CONTENDED_ENTERED 14 #define CONST_CONTENDED_EXIT 15 #define CONST_RAW_CONTENDED_ENTER 16 #define CONST_RAW_CONTENDED_ENTERED 17 #define CONST_RAW_CONTENDED_EXIT 18 class BaseLogger { public: BaseLogger(); ~BaseLogger(); virtual int write(const void * buffer, size_t len) const = 0; inline void writeString(char * stringValue) { jshort len = strlen(stringValue); write(&len,sizeof(len)); write(stringValue,sizeof(char) * len); } inline void writeHeader(jbyte header, jlong& time, jlong& clockCPU) { write(&header,(unsigned int)sizeof(header)); write(&time,(unsigned int)sizeof(time)); write(&clockCPU,(unsigned int)sizeof(clockCPU)); } inline void writeMainHeader() { static const char * progID = (const char *) "DPINSP"; jint tst = 0xff; jlong timeMain = timeUtil.sysTimeMillis(); write(progID,sizeof(char) * strlen(progID)); write(&tst,sizeof(tst)); write(&timeMain,sizeof(timeMain)); } void writeLoadClass(jlong& time, jlong& clockCPU, char *& className, jint& classId, jint& numberOfMethods) { writeHeader(CONST_LOADCLASS,time,clockCPU); write(&classId,sizeof(classId)); writeString(className); write(&numberOfMethods,sizeof(numberOfMethods)); } void writeLoadMethod(jlong& time, jlong& clockCPU, jint& classId, jint& methodId, char *& methodName, char *& signature) { writeHeader(CONST_LOADMETHOD,time,clockCPU); write(&classId,sizeof(classId)); write(&methodId,sizeof(methodId)); writeString(methodName); writeString(signature); } void writeEnterMethod(jlong& time, jlong& clockCPU, jint& envId, jint& threadId, jint& classId, jint& methodId, jint& objectId) { writeHeader(CONST_ENTERMETHOD,time,clockCPU); write(&envId,sizeof(envId)); write(&threadId,sizeof(threadId)); write(&classId,sizeof(classId)); write(&methodId,sizeof(methodId)); write(&objectId,sizeof(objectId)); } void writeExitMethod(jlong& time, jlong& clockCPU, jint& envId, jint& threadId, jint& methodId) { writeHeader(CONST_EXITMETHOD,time,clockCPU); write(&envId,sizeof(envId)); write(&threadId,sizeof(threadId)); write(&methodId,sizeof(methodId)); } void writeBeginThread(jlong& time, jlong& clockCPU, jint& envId, jint& threadId, char *&threadName) { writeHeader(CONST_THREADSTART,time,clockCPU); write(&envId,sizeof(envId)); write(&threadId,sizeof(threadId)); writeString(threadName); } void writeEndThread(jlong& time, jlong& clockCPU, jint& envId, jint& threadId) { writeHeader(CONST_THREADSTART,time,clockCPU); write(&envId,sizeof(envId)); write(&threadId,sizeof(threadId)); } inline TimeUtil getTimeUtil() { return timeUtil; } private: TimeUtil timeUtil; }; #endif /*BASELOGGER_H_*/ libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src-library/GZFileLogger.cpp0000644000175000017500000000060010462070354027620 0ustar twernertwerner#include #include #include "GZFileLogger.h" GZFileLogger::GZFileLogger() { } short GZFileLogger::openFile(char * name) { isOpened=1; fileName=name; outFile = gzopen(fileName,"wb"); if (outFile==NULL) { fprintf (stderr,"Coudln't open file %s\n",name); } return (outFile!=NULL); } GZFileLogger::~GZFileLogger() { if (isOpened) { closeFile(); } } libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src-library/GZFileLogger.h0000644000175000017500000000114210462070354027267 0ustar twernertwerner#ifndef FILELOGGER_H_ #define FILELOGGER_H_ #include "BaseLogger.h" #include #include #include class GZFileLogger : public BaseLogger { public: GZFileLogger(); virtual ~GZFileLogger(); /** returns TRUE if the file could be opened OK, FALSE otherwise */ short openFile(char * name); void closeFile() { isOpened=0; gzclose(outFile); } gzFile outFile; int write(const void * buffer, size_t len) const { return gzwrite(outFile,buffer,len); } private: int lastReturnOperation; char * fileName; short isOpened; }; #endif /*FILELOGGER_H_*/ libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src-library/TimeUtil.cpp0000644000175000017500000000165110462070354027103 0ustar twernertwerner#include "TimeUtil.h" TimeUtil::TimeUtil() { } TimeUtil::~TimeUtil() { } // codigo extraido da JVM (para fazer um sysTimeMillis da mesma forma #ifdef WINDOWS #define FT2INT64(ft) ((jlong)(ft).dwHighDateTime << 32 | (jlong)(ft).dwLowDateTime) void TimeUtil::sysTimeMillis(jlong ¤tTime) { static jlong fileTime_1_1_70 = 0; if (fileTime_1_1_70 == 0) { /* Initialize fileTime_1_1_70 -- the Win32 file time of midnight * 1/1/70. */ memset(&st0, 0, sizeof(st0)); st0.wYear = 1970; st0.wMonth = 1; st0.wDay = 1; SystemTimeToFileTime(&st0, &ft0); fileTime_1_1_70 = FT2INT64(ft0); } GetSystemTime(&st0); SystemTimeToFileTime(&st0, &ft0); currentTime = (FT2INT64(ft0) - fileTime_1_1_70) / 10000; } #else void TimeUtil:: sysTimeMillis(long & currentTime) { gettimeofday(&t, 0); currentTime = ((jlong)t.tv_sec) * 1000 + (jlong)(t.tv_usec/1000); } #endif libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src-library/TimeUtil.h0000644000175000017500000000114410462070354026545 0ustar twernertwerner#ifndef TIMEUTIL_H_ #define TIMEUTIL_H_ #include #ifdef WINDOWS #include #include #else #include #include #endif /** Use one TimeUtil per thread. This is not thread safe as there is no synchronization on this class */ class TimeUtil { public: TimeUtil(); virtual ~TimeUtil(); void sysTimeMillis(jlong ¤tTime); inline jlong sysTimeMillis() { jlong retTime; sysTimeMillis(retTime); return retTime; } private: #ifdef WINDOWS SYSTEMTIME st0; FILETIME ft0; #else struct timeval t; #endif }; #endif /*TIMEUTIL_H_*/ libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src-testsuite/0000755000175000017500000000000010462070276025230 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src-testsuite/BaseTest.cpp0000644000175000017500000000225310462070354027445 0ustar twernertwerner#include "BaseTest.h" #include BaseTest::BaseTest() { currentTestName=NULL; currentStatus=0; startTime=0; } BaseTest::~BaseTest() { } /** A test method needs to inform that his test is beggining. This is because we not using any reflection here */ void BaseTest::startTest(char * testName) { currentTestName = testName; currentStatus=0; startTime = time(&startTime); printf ("Test \"%s\" is starting\n",currentTestName); } /** A test method needs to inform that his test finished */ void BaseTest::stopTest() { time_t finishTime; finishTime = time(&finishTime); time_t difference = finishTime - startTime; if (currentStatus) { printf ("Test \"%s\" failed with status %d, executed in %ld seconds\n",currentTestName,currentStatus, difference); } else { printf ("Test \"%s\" finished without any errors, executed in %ld seconds\n",currentTestName, difference); } } short BaseTest::assert(short clause, char * message) { if (clause) { printf ("Test %s failure = %s\n",currentTestName,message); } currentStatus=clause; return currentStatus; } void BaseTest::fail(char * failMessage) { printf ("%s failed because of %s\n",currentTestName,failMessage); } libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src-testsuite/BaseTest.h0000644000175000017500000000125710462070354027115 0ustar twernertwerner#ifndef BASETEST_H_ #define BASETEST_H_ #include class BaseTest { public: BaseTest(); ~BaseTest(); /** abstract method. Every subClass needs to implement this */ void executeTests(); protected: /** A test method needs to inform that his test is beggining. This is because we not using any reflection here */ void startTest(char * testName); /** A test method needs to inform that his test finished */ void stopTest(); /** Inform that the result of a test */ short assert(short booleanClause, char * message); void fail(char * failMessage); private: char * currentTestName; short currentStatus; time_t startTime; }; #endif /*BASETEST_H_*/ libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src-testsuite/LoggerTester.cpp0000644000175000017500000000644210462070354030345 0ustar twernertwerner#include #include "LoggerTester.h" #include "GZFileLogger.h" #include "TimeUtil.h" #define LOOP_COUNT 1000000L LoggerTester::LoggerTester() :BaseTest() { } LoggerTester::~LoggerTester() { } void LoggerTester::testMessages() { testHeaderWithoutTime(); testHeaderWithTime(); testHeaderWithTimeCopy(); testMethodsLoads(); } void LoggerTester::testHeaderWithoutTime() { startTest("testHeaderWithoutTime"); GZFileLogger * logger = new GZFileLogger(); if (assert(logger->openFile("file-test-header.gz")==FALSE,"can't open file")) { return; } jbyte tmpByte = 0; jlong tmpLong = 0; jlong tmpLong2 = 0; logger->writeMainHeader(); for (long i=0;iwriteHeader(tmpByte, tmpLong, tmpLong2); } delete logger; stopTest(); } void LoggerTester::testHeaderWithTime() { startTest("testHeaderWithTime"); GZFileLogger * logger = new GZFileLogger(); if (assert(logger->openFile("file-test-header-time.gz")==FALSE,"can't open file")) { return; } jbyte tmpByte = 0; jlong tmpLong = 0; jlong tmpLong2 = 0; logger->writeMainHeader(); for (long i=0;igetTimeUtil().sysTimeMillis(tmpLong); logger->writeHeader(tmpByte, tmpLong, tmpLong2); } delete logger; stopTest(); } void LoggerTester::testHeaderWithTimeCopy() { startTest("testHeaderWithTimeCopy"); GZFileLogger * logger = new GZFileLogger(); if (assert(logger->openFile("file-test-header-time-copy.gz")==FALSE,"can't open file")) { return; } jbyte tmpByte = 0; jlong tmpLong = 0; jlong tmpLong2 = 0; logger->writeMainHeader(); for (long i=0;igetTimeUtil().sysTimeMillis(); logger->writeHeader(tmpByte, tmpLong, tmpLong2); } delete logger; stopTest(); } // void LoggerTester::testMethodsLoads() { startTest("testMethodsLoads"); GZFileLogger * logger = new GZFileLogger(); if (assert(logger->openFile("serverspy_1_main_1137089546857.log.gz")==FALSE,"can't open file")) { return; } logger->writeMainHeader(); delete logger; logger = new GZFileLogger(); if (assert(logger->openFile("serverspy_1_thread_1137037871436_32609794_2.log.gz")==FALSE,"can't open file")) { return; } jlong time=0; jlong clockCPU=0; char * className = "Test"; jint classId=1; jint numberOfMethods=1; logger->writeLoadClass(time,clockCPU,className,classId,numberOfMethods); logger->writeLoadMethod(time,clockCPU,classId,classId,className,className); logger->writeBeginThread(time, clockCPU, classId, classId, className); for (long i=0;iwriteEnterMethod(time, clockCPU, classId, classId, classId, classId, classId); logger->writeExitMethod(time, clockCPU, classId, classId, classId); } logger->writeEndThread(time, clockCPU, classId, classId); delete logger; stopTest(); } libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src-testsuite/LoggerTester.h0000644000175000017500000000064310462070354030007 0ustar twernertwerner#ifndef LOGGERTESTER_H_ #define LOGGERTESTER_H_ #include #include "BaseTest.h" class LoggerTester : public BaseTest { public: LoggerTester(); ~LoggerTester(); void executeTests() { testMessages(); } void testMessages(); void testHeaderWithoutTime(); void testHeaderWithTime(); void testHeaderWithTimeCopy(); void testMethodsLoads(); void testHeader(); }; #endif /*LOGGERTESTER_H_*/ libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-src-testsuite/testMain.cpp0000644000175000017500000000030710462070354027515 0ustar twernertwerner #include #include "LoggerTester.h" int main(int numberOfArguments, char** arguments) { LoggerTester * logger = new LoggerTester(); logger->testMessages(); delete logger; return 0; } libjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-tests/0000755000175000017500000000000010462070276023554 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-tests/org/0000755000175000017500000000000010462070276024343 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-tests/org/jboss/0000755000175000017500000000000010462070276025463 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-tests/org/jboss/profiler/0000755000175000017500000000000010462070276027305 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-tests/org/jboss/profiler/jvmtitest/0000755000175000017500000000000010462070276031336 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-tests/org/jboss/profiler/jvmtitest/JVMTITest.javalibjboss-profiler-java-1.0.CR4.orig/jvmti-src/native-tests/org/jboss/profiler/jvmtitest/JVMTITest.ja0000644000175000017500000003330010462070354033377 0ustar twernertwerner/* * Distributable under LGPL license. See terms of license at gnu.org. */ package org.jboss.profiler.jvmtitest; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.WeakHashMap; import junit.framework.TestCase; import org.jboss.profiler.jvmti.InventoryDataPoint; import org.jboss.profiler.jvmti.JVMTICallBack; import org.jboss.profiler.jvmti.JVMTIInterface; import org.jboss.profiler.jvmti.ReferenceDataPoint; import org.jboss.profiler.memoryprofiler.engine.MemorySnapshotController; import org.jboss.profiler.memoryprofiler.engine.MemorySnapshotEngine; import org.jboss.profiler.memoryprofiler.model.MemoryClass; class B { } class Dummy { String a; String b; B b12 = null; String c; static B staticB ; } class A extends Dummy { public A() { b = new B(); staticB=b; } B b; B b1 = null; String str = null; } class Holder { int count = 0; UsedByHolder[] objs = new UsedByHolder[100000]; public void addInstance(UsedByHolder obj) { objs[count++] = obj; } public void print() { for (int i = 0; i < count; i++) { System.out.println("class=" + objs[i].toString()); } } } class UsedByHolder { int x; static int count = 0; public UsedByHolder() { x = count++; } public String toString() { return "value " + x; } } /** * To run this test, you need to use -agentlib:jbossAgent in you IDE * @author Clebert Suconic */ public class JVMTITest extends TestCase { static class LocalCallbackTestOnClasses implements JVMTICallBack { int count=0; public void notifyReference(long referenceHolder, long referencedObject, long classTag, long index, long method, byte referenceType) { fail("Shouldn't be called"); } public void notifyClass(long classTag, Class clazz) { count++; } public void notifyObject(long classTag, long objectId, long bytes) { fail("Shouldn't be called"); } } static class LocalCallbackTestOnObjects implements JVMTICallBack { int count=0; public void notifyReference(long referenceHolder, long referencedObject, long classTag, long index, long method, byte referenceType) { fail("Shouldn't be called"); } public void notifyClass(long classTag, Class clazz) { fail("Shouldn't be called"); } public void notifyObject(long classTag, long objectId, long bytes) { count++; } } public void testNotifyOnClasses() { JVMTIInterface jvmti = new JVMTIInterface(); LocalCallbackTestOnClasses localTest = new LocalCallbackTestOnClasses(); jvmti.notifyInventory(true,null,null,localTest); assertEquals(jvmti.getLoadedClasses().length,localTest.count); } public void testInventoryReport() throws Exception { JVMTIInterface jvmti = new JVMTIInterface(); System.out.println(jvmti.inventoryReport()); } public void testProduceInventoryMinimal() throws Exception { JVMTIInterface jvmti = new JVMTIInterface(); // The JVMTIWrapper used to produce inventories Map map = jvmti.produceInventory(); Map map2 = jvmti.produceInventory(); assertTrue( jvmti.compareInventories(System.out,map,map2,null,null,null)); } public void testProduceInventory() throws Exception { class TestClass { } JVMTIInterface jvmti = new JVMTIInterface(); // The JVMTIWrapper used to produce inventories Map map = jvmti.produceInventory(); Map map2 = jvmti.produceInventory(); jvmti.compareInventories(System.out,map,map2,null,null,null); System.out.println("size=" + map.size()); map=null; map2=null; TestClass keepr = new TestClass(); // at least one instance, so point2 won't be null Map firstMap = jvmti.produceInventory(); // The inventory of classes, this is HashMap TestClass [] tests = new TestClass[1000]; for (int i=0;i<1000;i++) { tests[i] = new TestClass(); // allocating 1000 objects } Map secondMap = jvmti.produceInventory(); // the second inventory InventoryDataPoint point1 = (InventoryDataPoint)secondMap.get(TestClass.class); InventoryDataPoint point2 = (InventoryDataPoint)firstMap.get(TestClass.class); assertEquals(1000,point1.getInstances()-point2.getInstances()); // you can manually compare it assertTrue(jvmti.compareInventories(System.out,firstMap,secondMap,new Class[]{WeakHashMap.class},new String[]{"[Ljava.util.WeakHashMap$Entry;","java.lang.ref"}, new InventoryDataPoint[]{new InventoryDataPoint(TestClass.class,2000)})); assertFalse(jvmti.compareInventories(System.out,firstMap,secondMap,new Class[]{WeakHashMap.class},new String[]{"[Ljava.util.WeakHashMap$Entry;","java.lang.ref"}, new InventoryDataPoint[]{new InventoryDataPoint(TestClass.class,100)})); } public void testExploreObject() throws Exception { A a = new A(); B b = a.b; JVMTIInterface jvmti = new JVMTIInterface(); HashMap map = jvmti.createIndexMatrix(); jvmti.exploreClassReferences(B.class.getName(),-1,true,true,true,true,false,map); System.out.println(jvmti.exploreObjectReferences(map,b,1,true)); /*map=null; jvmti.releaseTags(); System.out.println(jvmti.exploreObjectReferences(B.class.getName(),2,true)); */ } public void notestNotify() { A a = new A(); B b = a.b; final ArrayList list = new ArrayList(); JVMTIInterface jvmti = new JVMTIInterface(); jvmti.notifyOnReferences("/tmp/tst.refs",new JVMTICallBack(){ int count=0; public void notifyReference(long referenceHolder, long referencedObject,long classTag, long index, long method, byte referenceType) { list.add(new ReferenceDataPoint(referenceHolder, referencedObject,classTag, index, method, referenceType)); } public void notifyClass(long classTag, Class clazz) { fail("This shouldn't be called now"); } public void notifyObject(long classTag, long objectId, long bytes) { fail("This shouldn't be called now"); } }); long tag = jvmti.getTagOnObject(a); Object newObject = jvmti.getObjectOnTag(tag); assertSame(a,newObject); int count=0; Iterator iter = list.iterator(); while (iter.hasNext()) { ReferenceDataPoint point = (ReferenceDataPoint)iter.next(); //System.out.println("point=" + point); if (point.getClassTag()!=0 ) { Object obj = jvmti.getObjectOnTag(point.getClassTag()); if (!(obj instanceof Class)) { System.out.println("point=" + point); System.out.println("obj=" + obj); fail("Object was supposed to be a Class"); } } if (point.getReferenceType()==JVMTICallBack.JVMTI_REFERENCE_STATIC_FIELD || point.getReferenceType()==JVMTICallBack.JVMTI_REFERENCE_FIELD) { try { Object referenced = jvmti.getObjectOnTag(point.getReferencedObject()); Object obj = jvmti.getObjectOnTag(point.getReferenceHolder()); Field field = jvmti.getObjectField(obj .getClass(),(int)point.getIndex()); Class clazz = (Class)jvmti.getObjectOnTag(point.getClassTag()); /*if (field==null) { System.out.println(point); System.out.println(referenced + " couldn't find field " +point.getIndex() + " on " + obj); Field field2 = jvmti.getObjectField(obj .getClass(),(int)point.getIndex()); } assertNotNull(field); -- I would like to enforce this, but it seems impossible due to internal classes on JVM */ } catch (NullPointerException e) { } } else if (point.getReferenceType()==JVMTICallBack.THREAD_REFERENCE) { try { Object classTag = jvmti.getObjectOnTag(point.getClassTag()); Object objReferenced = jvmti.getObjectOnTag(point.getReferencedObject()); Object objHolder = jvmti.getObjectOnTag(point.getReferenceHolder()); String methodName= jvmti.getMethodClass(point.getMethod()).getName() + "::" + jvmti.getMethodName(point.getMethod()) + jvmti.getMethodSignature(point.getMethod()); //System.out.println(objReferenced + " being referenced at "+methodName); } catch (NullPointerException e) { // this can happen here; } } } System.out.println(); long tagOnA = jvmti.getTagOnObject(a.b); iter = list.iterator(); while (iter.hasNext()) { ReferenceDataPoint point = (ReferenceDataPoint)iter.next(); if (tagOnA == point.getReferencedObject() && (point.getReferenceType()==JVMTICallBack.JVMTI_REFERENCE_FIELD || point.getReferenceType()==JVMTICallBack.JVMTI_REFERENCE_STATIC_FIELD)) { Object obj = jvmti.getObjectOnTag(point.getReferenceHolder()); Field field = null; if (point.getReferenceType()==JVMTICallBack.JVMTI_REFERENCE_FIELD) { field = jvmti.getObjectField((Class)obj.getClass() ,(int)point.getIndex()); } else { field = jvmti.getObjectField((Class)obj ,(int)point.getIndex()); } System.out.println(obj + " being referenced at " + field); } else if (tagOnA == point.getReferencedObject() && (point.getReferenceType()==JVMTICallBack.THREAD_REFERENCE)) { Object classTag = jvmti.getObjectOnTag(point.getClassTag()); Object objReferenced = jvmti.getObjectOnTag(point.getReferencedObject()); Object objHolder = jvmti.getObjectOnTag(point.getReferenceHolder()); System.out.println("classTag=" + classTag); System.out.println("objReferenced=" + objReferenced); System.out.println("objHolder=" + objHolder); System.out.println("name=" +jvmti.getMethodClass(point.getMethod()).getName() + "::" + jvmti.getMethodName(point.getMethod()) + jvmti.getMethodSignature(point.getMethod())); } } try { jvmti.getObjectOnTag(0); fail("Supposed to throw an exception"); } catch (Throwable e) { } try { jvmti.getObjectOnTag(-1); fail("Supposed to throw an exception"); } catch (Throwable e) { } jvmti.releaseTags(); assertEquals(0,jvmti.getTagOnObject(a)); } public void testGetReferenceHolders() { JVMTIInterface jvmti = new JVMTIInterface(); A a = new A(); Object[] objects = jvmti.getReferenceHolders(new Object[]{a.b}); assertEquals(2,objects.length); assertSame(a,objects[0]); } public void testGetObjects() { JVMTIInterface interfaceJVMTI = new JVMTIInterface(); Object[] result = interfaceJVMTI.getAllObjects(java.lang.String.class); for (int i = 0; i < result.length; i++) { System.out.println("String result[" + i + "]=" + result[i]); } result = interfaceJVMTI.getAllObjects(java.lang.Class.class); assertTrue(result.length>0); for (int i = 0; i < result.length; i++) { System.out.println("class result[" + i + "]=" + result[i]); } } ThreadLocal local = new ThreadLocal(); static Holder holder[] = new Holder[100]; static { for (int i=0;i0); } if (clazz.getClassLoaderId()!=0) { Collection collClassLoader = controller.solveLoadedClass(clazz.getClassLoaderId(),false); } } } public static void main(String arg[]) { JVMTITest test = new JVMTITest(); try { test.testGetObjects(); } catch (Throwable e1) { e1.printStackTrace(); } try { test.testNavigation(); } catch (Throwable e) { e.printStackTrace(); } } } libjboss-profiler-java-1.0.CR4.orig/jvmti-src/solaris/0000755000175000017500000000000010462071462022600 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/solaris/CC-solaris.sh0000644000175000017500000000057110462070354025075 0ustar twernertwerner#!/bin/sh rm -f *.so rm -f *.dll rm -f *.o _INCLUDES="-I$JAVA_HOME/include -I$JAVA_HOME/include/solaris -I../../src/zlib" CC $_INCLUDES -D ZLIB $_OPTS -c ../native-src/jbossAgent.cpp CC $_INCLUDES -D ZLIB $_OPTS -c ../native-src/jbossAgentJNI.cpp CC $_INCLUDES -D ZLIB $_OPTS -c ../native-src/jbossAgentUtilities.cpp CC $_INCLUDES -D ZLIB $_OPTS -G -o libjbossAgent.so *.o libjboss-profiler-java-1.0.CR4.orig/jvmti-src/solaris/compile.sh0000644000175000017500000000057610462071416024573 0ustar twernertwerner#!/bin/sh rm -f *.so rm -f *.dll rm -f *.o _INCLUDES="-I$JAVA_HOME/include -I$JAVA_HOME/include/solaris -I../../src/zlib" g++ $_INCLUDES -D ZLIB $_OPTS -c ../native-src/jbossAgent.cpp g++ $_INCLUDES -D ZLIB $_OPTS -c ../native-src/jbossAgentJNI.cpp g++ $_INCLUDES -D ZLIB $_OPTS -c ../native-src/jbossAgentUtilities.cpp g++ $_INCLUDES -D ZLIB $_OPTS -G -o libjbossAgent.so *.o libjboss-profiler-java-1.0.CR4.orig/jvmti-src/win32/0000755000175000017500000000000010462070276022070 5ustar twernertwernerlibjboss-profiler-java-1.0.CR4.orig/jvmti-src/win32/compile.sh0000644000175000017500000000104210462070354024046 0ustar twernertwerner#!/bin/sh rm -f *.so rm -f *.dll rm -f *.o _INCLUDES="-I"$JAVA_HOME/include" -I"$JAVA_HOME/include/win32" -I../../src/zlib" _OPTS="-mno-cygwin -pg" g++ $_INCLUDES -D ZLIB -D WINDOWS -D _WINDOWS $_OPTS -c ../native-src/jbossAgent.cpp g++ $_INCLUDES -D ZLIB -D WINDOWS -D _WINDOWS $_OPTS -c ../native-src/jbossAgentJNI.cpp g++ $_INCLUDES -D ZLIB -D WINDOWS -D _WINDOWS $_OPTS -c ../native-src/jbossAgentUtilities.cpp gcc $_INCLUDES -D ZLIB -D WINDOWS -D _WINDOWS $_OPTS -shared -Wl,-add-stdcall-alias -o jbossAgent.dll *.o libjboss-profiler-java-1.0.CR4.orig/jvmti-src/win32/makefile0000644000175000017500000000143210462070354023565 0ustar twernertwernermakefile: all includes=-I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/win32" -I../src/zlib CXXFLAGS=$(includes) -mno-cygwin -pg -D ZLIB -D WINDOWS -D _WINDOWS SOURCEDIR=../native-src/ all: jbossAgent.dll jbossAgent.o:$(SOURCEDIR)/jbossAgent.cpp g++ $(CXXFLAGS) -c $(SOURCEDIR)/jbossAgent.cpp jbossAgentJNI.o:$(SOURCEDIR)/jbossAgentJNI.cpp g++ $(CXXFLAGS) -c $(SOURCEDIR)/jbossAgentJNI.cpp jbossAgentJNI.o:$(SOURCEDIR)/jbossAgentJNI.cpp g++ $(CXXFLAGS) -c $(SOURCEDIR)/jbossAgentJNI.cpp jbossAgentUtilities.o:$(SOURCEDIR)/jbossAgentUtilities.cpp g++ $(CXXFLAGS) -c $(SOURCEDIR)/jbossAgentUtilities.cpp jbossAgent.dll:jbossAgent.o jbossAgentJNI.o jbossAgentUtilities.o gcc $(CXXFLAGS) -shared -Wl,-add-stdcall-alias -o jbossAgent.dll *.o clean: rm -f *.so rm -f *.dll rm -f *.o libjboss-profiler-java-1.0.CR4.orig/jvmti-src/.cdtproject0000644000175000017500000000436310462070354023273 0ustar twernertwerner libjboss-profiler-java-1.0.CR4.orig/jvmti-src/.project0000644000175000017500000000511110462070354022570 0ustar twernertwerner jbossProfiler-JVMTI org.eclipse.cdt.make.core.makeBuilder org.eclipse.cdt.make.core.build.arguments org.eclipse.cdt.core.errorOutputParser org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser; org.eclipse.cdt.make.core.enableAutoBuild false org.eclipse.cdt.make.core.environment org.eclipse.cdt.make.core.enableFullBuild true org.eclipse.cdt.make.core.build.target.inc all org.eclipse.cdt.make.core.enabledIncrementalBuild true org.eclipse.cdt.make.core.build.target.clean clean org.eclipse.cdt.make.core.build.command make org.eclipse.cdt.make.core.enableCleanBuild true org.eclipse.cdt.make.core.append_environment true org.eclipse.cdt.make.core.build.target.full clean all org.eclipse.cdt.make.core.useDefaultBuildCmd true org.eclipse.cdt.make.core.build.target.auto all org.eclipse.cdt.make.core.stopOnError false org.eclipse.cdt.make.core.ScannerConfigBuilder org.eclipse.cdt.core.cnature org.eclipse.cdt.make.core.makeNature org.eclipse.cdt.make.core.ScannerConfigNature org.eclipse.cdt.core.ccnature libjboss-profiler-java-1.0.CR4.orig/jvmti-src/build.xml0000644000175000017500000000260410462070354022746 0ustar twernertwerner libjboss-profiler-java-1.0.CR4.orig/jvmti-src/makefile0000644000175000017500000000556610462070354022637 0ustar twernertwernermakefile: SOURCEDIR=./native-src LIBDIR=$(SOURCEDIR)-library TESTDIR=$(SOURCEDIR)-testsuite GZIPDIR=$(SOURCEDIR)/../../jvmpi-lib/src/zlib includes=-I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/win32" -I../src/zlib -I$(SOURCEDIR) -I$(TESTDIR) -I$(LIBDIR) -I$(GZIPDIR) CXXFLAGS=$(includes) -mno-cygwin -D ZLIB -D WINDOWS CCFLAGS=$(includes) -mno-cygwin -D ZLIB $(includes) jbossAgentSources=jbossAgent.o jbossAgentJNI.o jbossAgentUtilities.o BaseLogger.o GZFileLogger.o adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o TimeUtil.o sourcesTest=jbossAgent.o jbossAgentJNI.o jbossAgentUtilities.o BaseLogger.o BaseTest.o LoggerTester.o GZFileLogger.o testMain.o adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o TimeUtil.o all: jbossAgent.dll test test: testAgent.exe jbossAgent.o:$(SOURCEDIR)/jbossAgent.cpp g++ $(CXXFLAGS) -c $(SOURCEDIR)/jbossAgent.cpp jbossAgentJNI.o:$(SOURCEDIR)/jbossAgentJNI.cpp g++ $(CXXFLAGS) -c $(SOURCEDIR)/jbossAgentJNI.cpp jbossAgentJNI.o:$(SOURCEDIR)/jbossAgentJNI.cpp g++ $(CXXFLAGS) -c $(SOURCEDIR)/jbossAgentJNI.cpp jbossAgentUtilities.o:$(SOURCEDIR)/jbossAgentUtilities.cpp g++ $(CXXFLAGS) -c $(SOURCEDIR)/jbossAgentUtilities.cpp BaseLogger.o:$(LIBDIR)/BaseLogger.cpp g++ $(CXXFLAGS) -c $(LIBDIR)/BaseLogger.cpp TimeUtil.o:$(LIBDIR)/TimeUtil.cpp g++ $(CXXFLAGS) -c $(LIBDIR)/TimeUtil.cpp BaseTest.o:$(TESTDIR)/BaseTest.cpp g++ $(CXXFLAGS) -c $(TESTDIR)/BaseTest.cpp GZFileLogger.o::$(LIBDIR)/GZFileLogger.cpp $(LIBDIR)/GZFileLogger.h g++ $(CXXFLAGS) -c $(LIBDIR)/GZFileLogger.cpp LoggerTester.o:$(TESTDIR)/LoggerTester.cpp g++ $(CXXFLAGS) -c $(TESTDIR)/LoggerTester.cpp testMain.o:$(TESTDIR)/testMain.cpp g++ $(CXXFLAGS) -c $(TESTDIR)/testMain.cpp adler32.o:$(GZIPDIR)/adler32.c gcc $(CCFLAGS) -c $(GZIPDIR)/adler32.c compress.o:$(GZIPDIR)/compress.c gcc $(CCFLAGS) -c $(GZIPDIR)/compress.c crc32.o:$(GZIPDIR)/crc32.c gcc $(CCFLAGS) -c $(GZIPDIR)/crc32.c gzio.o:$(GZIPDIR)/gzio.c gcc $(CCFLAGS) -c $(GZIPDIR)/gzio.c uncompr.o:$(GZIPDIR)/uncompr.c gcc $(CCFLAGS) -c $(GZIPDIR)/uncompr.c deflate.o:$(GZIPDIR)/deflate.c gcc $(CCFLAGS) -c $(GZIPDIR)/deflate.c trees.o:$(GZIPDIR)/trees.c gcc $(CCFLAGS) -c $(GZIPDIR)/trees.c zutil.o:$(GZIPDIR)/zutil.c gcc $(CCFLAGS) -c $(GZIPDIR)/zutil.c inflate.o:$(GZIPDIR)/inflate.c gcc $(CCFLAGS) -c $(GZIPDIR)/inflate.c infback.o:$(GZIPDIR)/infback.c gcc $(CCFLAGS) -c $(GZIPDIR)/infback.c inftrees.o:$(GZIPDIR)/inftrees.c gcc $(CCFLAGS) -c $(GZIPDIR)/inftrees.c inffast.o:$(GZIPDIR)/inffast.c gcc $(CCFLAGS) -c $(GZIPDIR)/inffast.c testAgent.exe:$(sourcesTest) g++ $(CXXFLAGS) -o testAgent.exe $(sourcesTest) testAgent.exe jbossAgent.dll:$(jbossAgentSources) g++ $(CXXFLAGS) -shared -L $(GZIPDIR) -o jbossAgent.dll $(jbossAgentSources) clean: rm -f *.so rm -f *.dll rm -f *.o