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

trace.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 "../shared/trace.h"
00036 #include "../shared/traceFrame.h"
00037 #include "../shared/method.h"
00038 
00039 Trace::~Trace() {
00040 
00041         if( frames) TraceFrame::deleteArray(frames, numFrames);
00042         frames = NULL;
00043 }
00044 
00045 Buffer& Trace::infoToBin( Buffer& b) {
00046 
00047         b += numFrames;
00048 
00049         TraceFrame* p = frames;
00050         for( jint i = 0; i < numFrames; i++, p++) {
00051         
00052                 b += p->lineno;
00053                 b += p->method->getProfID();
00054         }
00055 
00056         return b;
00057 }
00058 
00059 const TraceKey& Trace::getKey(TraceKey& key) {
00060 
00061         TraceFrame* tf = frames;
00062         JVMPI_CallFrame* cf = key.frames;
00063 
00064         key.numFrames = numFrames;
00065         for (int i = 0; i < numFrames; i++, tf++, cf++) {
00066                 cf->lineno = tf->lineno;
00067                 tf->method->getKey(cf->method_id);
00068         }
00069 
00070         return key;
00071 }
00072 
00073 int Trace::operator==(const TraceKey& key) {
00074 
00075         if (key.numFrames != numFrames) return 0;
00076 
00077         const JVMPI_CallFrame* cf = key.frames;
00078         TraceFrame* tf = frames;
00079 
00080         for (int i = 0; i < numFrames; i++, tf++, cf++)
00081                 if( (tf->lineno != cf->lineno) || (!(*tf->method == cf->method_id))) return 0;
00082 
00083         return 1;
00084 }
00085 
00086 int Trace::hashKey(const TraceKey& key) {
00087 
00088         const JVMPI_CallFrame* p = key.frames;
00089         int sum = 0;
00090 
00091         for (int i = 0; i < key.numFrames; i++, p++) {
00092                 sum += (int)p->lineno;
00093                 sum += Method::hashKey(p->method_id);
00094         }
00095 
00096         return sum;
00097 }

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