00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00035
00036 #include "xdprof.h"
00037
00042 void ClassUnloadEvent(jobjectID class_id)
00043 {
00044 Lock(methods_lock);
00045 ClassMethopMap::iterator i;
00046 i = ClassMethods.find(class_id);
00047
00048 const ClassInfoMap::iterator & ci = Classes.find(class_id);
00049 if (ci != Classes.end())
00050 debug("Unload ", class_id, ci->second.getShortInfo());
00051 else
00052 debug("Unload ", class_id);
00053
00054 if (i != ClassMethods.end())
00055 {
00056 MethodList & ms = i->second;
00057
00058 debug("erase before ", Methods.size(), MethodCache.size());
00059 MethodList::iterator m;
00060 for (m = ms.begin(); m != ms.end(); ++m)
00061 {
00062 const MethodInfo* mi = Methods[*m];
00063 Methods.erase(*m);
00064 MethodCache.erase(*m);
00065 delete mi;
00066 }
00067 debug("erase after ", Methods.size(), MethodCache.size());
00068 }
00069
00070 ClassMethods.erase(class_id);
00071 Classes.erase(class_id);
00072 ClassCache.erase(class_id);
00073
00074 Unlock(methods_lock);
00075 }
00076
00077 #pragma warning(disable: 4100)
00078
00081 void ClassLoadEvent(JNIEnv *env_id,
00082 char** class_name,
00083 char** source_name,
00084 int num_interfaces,
00085 int num_statics,
00086 JVMPI_Field *statics,
00087 int num_instances,
00088 JVMPI_Field *instances,
00089 int num_methods,
00090 JVMPI_Method *methods,
00091 jobjectID class_id,
00092 jint eventType)
00093 {
00094
00095 if (ClassMethods.find(class_id) != ClassMethods.end())
00096 {
00097 debug("!!! exists!!!", class_id, *class_name);
00098 }
00099
00100 debug((eventType == (JVMPI_EVENT_CLASS_LOAD | JVMPI_REQUESTED_EVENT)) ? "Requested load" : "load", (*class_name) , *source_name == null ? "unknown" : *source_name , class_id);
00101
00102
00103
00104
00105 JVMPI_Method* jm = methods;
00106
00107 MethodList & temp_methods = ClassMethods[class_id] ;
00108
00109
00110
00111
00112
00113
00114
00115
00116 for (int i = 0; i < num_methods; i++)
00117 {
00118 debug("method", jm[i].method_id, jm[i].method_name, jm[i].method_signature);
00119
00120
00121
00122 Methods.insert(make_pair(jm[i].method_id, new MethodInfo(jm[i].method_name, jm[i].method_signature, jm[i].start_lineno, jm[i].end_lineno, jm[i].method_id, class_id)));
00123
00124
00125 temp_methods.push_back(jm[i].method_id);
00126 }
00127
00128
00129
00130
00131
00132 Classes.insert(make_pair(class_id, ClassInfo(*class_name, *source_name, class_id) ));
00133
00134 }