Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

classes.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2001, John Lambert jlambert@jlambert.com
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without modification, are 
00006 permitted provided that the following conditions are met:
00007 
00008 Redistributions of source code must retain the above copyright notice, this list of 
00009 conditions and the following disclaimer.
00010 
00011 Redistributions in binary form must reproduce the above copyright notice, this list
00012 of conditions and the following disclaimer in the documentation and/or other
00013 materials provided with the distribution. 
00014 
00015 Neither the name of the xdProf project nor the names of its contributors may be used
00016 to endorse or promote products derived from this software without specific prior 
00017 written permission. 
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
00020 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00021 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
00022 SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
00023 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00024 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
00025 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00026 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
00027 WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028 */
00029 /*
00030 $Header: /xdprof-dll/classes.cpp 19    5/09/01 12:58a Admin $ 
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     //Lock(methods_lock);
00095     if (ClassMethods.find(class_id) != ClassMethods.end()) // then it exists
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     //debug("count", *class_name, num_instances , num_statics);
00103 
00104     // load method table
00105     JVMPI_Method* jm = methods;
00106     //string className(class_name);
00107     MethodList & temp_methods = ClassMethods[class_id]  ;
00108     //string sourceName;
00109     /*
00110     if (source_name != null)
00111         sourceName = string(source_name);
00112     else
00113         sourceName = "unknown";
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);//, jm[i].start_lineno, jm[i].end_lineno, jm[i].method_id, 
00119         //const MethodInfo *mi = new MethodInfo(jm[i].method_name, jm[i].method_signature, jm[i].start_lineno, jm[i].end_lineno, jm[i].method_id, class_id);
00120         //const pair<jmethodID, const MethodInfo*> p(jm[i].method_id, mi);
00121         //Methods.insert(p);
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         //Methods[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);
00124 
00125         temp_methods.push_back(jm[i].method_id);
00126     }
00127 
00128     //ClassMethods[class_id] = temp_methods;
00129     
00130     //ClassInfo ci(*class_name, *source_name, class_id);
00131     //assert(false);
00132     Classes.insert(make_pair(class_id, ClassInfo(*class_name, *source_name, class_id) ));
00133     //Unlock(methods_lock);
00134 }

Generated at Sun Jun 24 20:57:14 2001 for xdprof by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001