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

prof_class.cpp

00001 /*
00002  *                         Sun Public License Notice
00003  *
00004  * The contents of this file are subject to the Sun Public License
00005  * Version 1.0 (the "License"); you may not use this file except
00006  * in compliance with the License. A copy of the License is available
00007  * at http://www.sun.com/
00008  *
00009  * The Original Code is the Java Profiler module.  The Initial Developers
00010  * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner,
00011  * Lukas Petru and Marek Przeczek.
00012  *
00013  * Portions created by Jan Stola are Copyright (C) 2000-2001.
00014  * All Rights Reserved.
00015  *
00016  * Portions created by Pavel Vacha are Copyright (C) 2000-2001.
00017  * All Rights Reserved.
00018  *
00019  * Portions created by Michal Pise are Copyright (C) 2000-2001.
00020  * All Rights Reserved.
00021  *
00022  * Portions created by Petr Luner are Copyright (C) 2000-2001.
00023  * All Rights Reserved.
00024  *
00025  * Portions created by Lukas Petru are Copyright (C) 2000-2001.
00026  * All Rights Reserved.
00027  *
00028  * Portions created by Marek Przeczek are Copyright (C) 2000-2001.
00029  * All Rights Reserved.
00030  *
00031  * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner,
00032  *               Lukas Petru and Marek Przeczek.
00033  */
00034 
00035 #include "../prof/prof.h"
00036 #include "../shared/classField.h"
00037 #include "../prof/synchronized.h"
00038 
00039 void Prof::event_classLoad( JVMPI_Event* event) {
00040 
00041         Synchronized sync( dataLock, 0);
00042         if( !(event->event_type & JVMPI_REQUESTED_EVENT)) sync.enter();
00043 
00044         if( !event->u.class_load.class_id) return;
00045 
00046         static int firstTime = 1;
00047         if( firstTime) {
00048 
00049                 jvmpiInterface->EnableEvent( JVMPI_EVENT_CLASS_UNLOAD, NULL);
00050 
00051                 if( setup.alloc.turnedOn) jvmpiInterface->EnableEvent( JVMPI_EVENT_OBJECT_ALLOC, NULL);
00052 
00053                 if( setup.cpu.turnedOn && !setup.cpu.sampling)
00054                         jvmpiInterface->EnableEvent( JVMPI_EVENT_METHOD_ENTRY, NULL);
00055 
00056                 if( setup.mon.turnedOn)
00057                         jvmpiInterface->EnableEvent( JVMPI_EVENT_MONITOR_CONTENDED_ENTER, NULL);
00058 
00059                 firstTime = 0;
00060         }
00061 
00062         Class* c = new Class;
00063 
00064         c->className  = event->u.class_load.class_name;
00065         c->sourceName = event->u.class_load.source_name;
00066 
00067         c->numInterfaces     = event->u.class_load.num_interfaces;
00068         c->numMethods        = event->u.class_load.num_methods;
00069         c->numStaticFields   = event->u.class_load.num_static_fields;
00070         c->numInstanceFields = event->u.class_load.num_instance_fields;
00071 
00072         JVMPI_Method* pm = event->u.class_load.methods;
00073         for( jint i = 0; i < c->numMethods; i++, pm++) {
00074         
00075                 Method* m = new Method;
00076                 m->clss = c;
00077 
00078                 m->methodName      = pm->method_name;
00079                 m->methodSignature = pm->method_signature;
00080                 
00081                 m->startLineno = pm->start_lineno;
00082                 m->endLineno   = pm->end_lineno;
00083 
00084                 m->methodId = pm->method_id;
00085 
00086                 c->methods.add( m);
00087         }
00088 
00089         JVMPI_Field* pf = event->u.class_load.statics;
00090         for( jint j = 0; j < c->numStaticFields; j++, pf++) {
00091                 
00092                 ClassField* f = new ClassField;
00093 
00094                 f->fieldName      = pf->field_name;
00095                 f->fieldSignature = pf->field_signature;
00096 
00097                 c->statics.add( f);
00098         }
00099 
00100         pf = event->u.class_load.instances;
00101         for( jint k = 0; k < c->numInstanceFields; k++, pf++) {
00102                 
00103                 ClassField* f = new ClassField;
00104 
00105                 f->fieldName      = pf->field_name;
00106                 f->fieldSignature = pf->field_signature;
00107 
00108                 c->instances.add( f);
00109         }
00110 
00111         c->classId = event->u.class_load.class_id;
00112 
00113         classes.add( c);
00114         activeClasses.add(c);
00115 
00116         Method* m = c->methods.first();
00117         while( m) {
00118                 
00119                 activeMethods.add( m);
00120                 m = c->methods.next(m);
00121         }
00122 }
00123 
00124 void Prof::event_classUnload( JVMPI_Event* event) {
00125 
00126         Synchronized sync( dataLock);
00127 
00128         Class* c = getClass(event->u.class_unload.class_id, 0);
00129         if( c) c->deactivate();
00130 }

Generated on Mon Jan 28 14:53:27 2002 for Java Profiler Dynamic Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001