From: Marek P. <ma...@us...> - 2001-11-21 22:32:15
|
Update of /cvsroot/javaprofiler/library/src/commun In directory usw-pr-cvs1:/tmp/cvs-serv12170/src/commun Modified Files: Makefile.rules binaryFormat.h buffer.cpp buffer.h commun.h communSocket.cpp communSocket.h dir.info iprof.cpp iprof.h statDataModification.h Log Message: some parts completely rewritten; changes in communication interface to make it faster; ported to linux Index: Makefile.rules =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun/Makefile.rules,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** Makefile.rules 2001/07/22 23:37:58 1.2 --- Makefile.rules 2001/11/21 22:31:42 1.3 *************** *** 1,12 **** buffer.o \ ! buffer.obj: buffer.cpp ../main/includes.h $(CCC) $(CPPFLAGS) buffer.cpp communSocket.o \ ! communSocket.obj: communSocket.cpp ../main/includes.h $(CCC) $(CPPFLAGS) communSocket.cpp iprof.o \ ! iprof.obj: iprof.cpp ../main/includes.h $(CCC) $(CPPFLAGS) iprof.cpp --- 1,12 ---- buffer.o \ ! buffer.obj: buffer.cpp $(CCC) $(CPPFLAGS) buffer.cpp communSocket.o \ ! communSocket.obj: communSocket.cpp $(CCC) $(CPPFLAGS) communSocket.cpp iprof.o \ ! iprof.obj: iprof.cpp $(CCC) $(CPPFLAGS) iprof.cpp Index: binaryFormat.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun/binaryFormat.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** binaryFormat.h 2001/09/18 22:19:28 1.4 --- binaryFormat.h 2001/11/21 22:31:42 1.5 *************** *** 36,39 **** --- 36,42 ---- #define _BINARY_FORMAT_H_ + #include "../main/includes.h" + #include "../commun/buffer.h" + /** Statistic data binary format. Each class ** which has statistic data must be inherited from *************** *** 49,52 **** --- 52,61 ---- public: + /// Default constructor. + DataBinaryFormat() {} + + /// Destructor. + virtual ~DataBinaryFormat() {} + /** Convert data to binary. This method converts statistic ** data to binary format in which it is sent thru communication *************** *** 72,75 **** --- 81,90 ---- public: + /// Default constructor. + InfoBinaryFormat() {} + + /// Destructor. + virtual ~InfoBinaryFormat() {} + /** Convert info to binary. This method converts information ** data to binary format in which it is sent thru communication *************** *** 85,87 **** #endif // _BINARY_FORMAT_H_ - --- 100,101 ---- Index: buffer.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun/buffer.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** buffer.cpp 2001/09/02 20:14:21 1.4 --- buffer.cpp 2001/11/21 22:31:42 1.5 *************** *** 33,37 **** */ ! #include "../main/includes.h" Buffer::Buffer( const Buffer& b) { --- 33,37 ---- */ ! #include "../commun/buffer.h" Buffer::Buffer( const Buffer& b) { Index: buffer.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun/buffer.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** buffer.h 2001/09/02 20:14:21 1.4 --- buffer.h 2001/11/21 22:31:42 1.5 *************** *** 36,39 **** --- 36,42 ---- #define _BUFFER_H_ + #include "../main/includes.h" + #include "../string/string.h" + /** I/O buffer. This class implements an input/output buffer ** needed during communication between profiler dynamic library *************** *** 62,65 **** --- 65,70 ---- }; + private: + /// pointer to buffer char* _buf; *************** *** 80,84 **** _bufSize( 0) ! {}; /// Copy constructor. --- 85,89 ---- _bufSize( 0) ! {} /// Copy constructor. *************** *** 171,173 **** #endif // _BUFFER_H_ - --- 176,177 ---- Index: commun.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun/commun.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** commun.h 2001/09/23 16:50:15 1.5 --- commun.h 2001/11/21 22:31:42 1.6 *************** *** 36,39 **** --- 36,42 ---- #define _COMMUN_H_ + #include "../main/includes.h" + #include "../commun/buffer.h" + /** Communication. This abstract class offers standard ** interface for all inherited communication classes. *************** *** 49,53 **** class Commun { - protected: --- 52,55 ---- *************** *** 62,71 **** _failed( 0) ! {}; public: /// Destructor. ! virtual ~Commun() {}; /** Initialization of communication. This method should --- 64,73 ---- _failed( 0) ! {} public: /// Destructor. ! virtual ~Commun() {} /** Initialization of communication. This method should *************** *** 119,121 **** #endif // _COMMUN_H_ - --- 121,122 ---- Index: communSocket.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun/communSocket.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** communSocket.cpp 2001/09/02 20:14:21 1.8 --- communSocket.cpp 2001/11/21 22:31:42 1.9 *************** *** 33,37 **** */ ! #include "../main/includes.h" CommunSocket::CommunSocket( int connectMode, const String& hostname, unsigned short port) : --- 33,37 ---- */ ! #include "../commun/communSocket.h" CommunSocket::CommunSocket( int connectMode, const String& hostname, unsigned short port) : *************** *** 41,44 **** --- 41,46 ---- _port( port) { + FD_ZERO( &_fds); + #ifdef WIN32 _csock = INVALID_SOCKET; *************** *** 145,148 **** --- 147,156 ---- } + if( !_failed) { + + FD_ZERO( &_fds); + FD_SET( _csock, &_fds); + } + return !_failed; } *************** *** 170,176 **** jint nsize; - int rc = recv( _csock, (char*)&nsize, sizeof( nsize), 0); ! #ifdef WIN32 if( _failed = (rc == SOCKET_ERROR || rc < sizeof( nsize))) return *this; --- 178,183 ---- jint nsize; int rc = recv( _csock, (char*)&nsize, sizeof( nsize), 0); ! #ifdef WIN32 if( _failed = (rc == SOCKET_ERROR || rc < sizeof( nsize))) return *this; *************** *** 183,189 **** if( size) { ! char* buf = new char[size]; ! rc = recv( _csock, buf, size, 0); --- 190,196 ---- if( size) { ! char* buf = new char[size]; ! rc = recv( _csock, buf, size, 0); *************** *** 205,218 **** int CommunSocket::isReady() { - fd_set fds; - - FD_ZERO( &fds); - FD_SET( _csock, &fds); - timeval tv; ! tv.tv_sec = 0; ! tv.tv_usec = 1000; ! int rc = select( _csock+1, &fds, NULL, NULL, &tv); #ifdef WIN32 --- 212,220 ---- int CommunSocket::isReady() { timeval tv; ! tv.tv_sec = 5; ! tv.tv_usec = 0; // wait 5s before timeout ! int rc = select( _csock+1, &_fds, NULL, NULL, &tv); #ifdef WIN32 Index: communSocket.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun/communSocket.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** communSocket.h 2001/09/23 16:50:15 1.8 --- communSocket.h 2001/11/21 22:31:42 1.9 *************** *** 36,39 **** --- 36,44 ---- #define _COMMUN_SOCKET_H_ + #include "../main/includes.h" + #include "../commun/commun.h" + #include "../string/string.h" + #include "../commun/buffer.h" + /** Socket communication. This class implements TCP/IP socket ** communication and offers the user of this class the standard *************** *** 62,65 **** --- 67,73 ---- #endif + /// temporary FDSET for select() call + fd_set _fds; + /** Hostname. It is used only when connectMode is set ** to 'client' (1); it contains target host's name. */ *************** *** 139,141 **** #endif // _COMMUN_SOCKET_H_ - --- 147,148 ---- Index: dir.info =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun/dir.info,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** dir.info 2001/07/28 04:11:17 1.5 --- dir.info 2001/11/21 22:31:42 1.6 *************** *** 1,3 **** FILES = buffer communSocket iprof - CLEAN_FILES = *.pdb *.obj *.o --- 1,2 ---- Index: iprof.cpp =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun/iprof.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** iprof.cpp 2001/09/02 20:14:21 1.9 --- iprof.cpp 2001/11/21 22:31:42 1.10 *************** *** 33,43 **** */ ! #include "../main/includes.h" ! Allocator IProf::sID::_allocator( sizeof( IProf::sID)); ! IProf::IProf( const Setup& setup) : ! ! communLock( "_commun_lock"), conEstabl( 0) { --- 33,50 ---- */ ! #include "../commun/iprof.h" ! #include "../commun/communSocket.h" ! #include "../commun3/communShMem.h" ! #include "../delay/delay.h" ! #include "../prof/synchronized.h" ! #include "../prof/prof.h" ! ! #ifdef USE_ALLOCATOR ! Allocator IProf::sID::_allocator; ! #endif ! IProf::IProf( const Setup& setup, JVMPI_Interface* jvmpi) : ! communLock( "_commun_lock", jvmpi), conEstabl( 0) { *************** *** 52,56 **** _func[F_GET_CHANGED] = &IProf::_getChanged; ! if( setup.com.communType == COMMUN_SOCKET) _commun = new CommunSocket( setup.com.connectMode, --- 59,63 ---- _func[F_GET_CHANGED] = &IProf::_getChanged; ! if( setup.com.communType == Setup::COMMUN_SOCKET) _commun = new CommunSocket( setup.com.connectMode, *************** *** 74,92 **** Buffer buf; while( 1) { - - Synchronized sync( communLock, 0); ! while( 1) { ! ! sync.enter(); ! if( _commun->isReady()) break; ! sync.release(); if( _commun->hasFailed()) return (conEstabl = 0); ! ! Delay::delay( 1); } buf.clear(); (*_commun) >> buf; if( _commun->hasFailed()) return (conEstabl = 0); --- 81,95 ---- Buffer buf; while( 1) { ! if( !_commun->isReady()) { if( _commun->hasFailed()) return (conEstabl = 0); ! continue; } + Synchronized sync( communLock); + buf.clear(); + (*_commun) >> buf; if( _commun->hasFailed()) return (conEstabl = 0); *************** *** 187,190 **** --- 190,198 ---- b += s->infoId; b += s->objId; + + b += s->parentLeftObjId; + b += s->parentUpObjId; + b += s->parentRightObjId; + b += s->active; *************** *** 201,228 **** if( s->hasMonData) s->mon.dataToBin( b); ! return 0; ! } ! ! void IProf::_getAll( Buffer& b) { ! const char* buf = b.getBuffer()+sizeof( jint); // jump the "action" field ! jint objId = ntohl( *(const jint*)buf); ! buf += sizeof( objId); ! jint what = ntohl( *(const jint*)buf); ! ! seqID seq; ! jint rc = getAll( objId, (eSeqType)what, seq); ! ! b.clear( seq.length()*sizeof( sID)); ! b += rc; ! ! if( rc < 0) return; ! void* buf2 = &b; ! seq.forEach( sToBin, &buf2); } ! void IProf::_getChanged( Buffer& b) { const char* buf = b.getBuffer()+sizeof( jint); // jump the "action" field --- 209,224 ---- if( s->hasMonData) s->mon.dataToBin( b); ! b += s->hasInfo; ! if( s->hasInfo) { ! b += s->infoType; ! s->info->infoToBin( b); ! } ! return 0; } ! void IProf::_getAllOrChanged( int all, Buffer& b) { const char* buf = b.getBuffer()+sizeof( jint); // jump the "action" field *************** *** 230,237 **** jint objId = ntohl( *(const jint*)buf); buf += sizeof( objId); jint what = ntohl( *(const jint*)buf); seqID seq; ! jint rc = getChanged( objId, (eSeqType)what, seq); b.clear( seq.length()*sizeof( sID)); --- 226,243 ---- jint objId = ntohl( *(const jint*)buf); buf += sizeof( objId); + jint what = ntohl( *(const jint*)buf); + buf += sizeof( what); + jint includeInfo = ntohl( *(const jint*)buf); + buf += sizeof( includeInfo); + + jint optionalArg = ntohl( *(const jint*)buf); + seqID seq; ! jint rc; ! ! if( all) rc = getAll( objId, (eSeqType)what, includeInfo, optionalArg, seq); ! else rc = getChanged( objId, (eSeqType)what, includeInfo, optionalArg, seq); b.clear( seq.length()*sizeof( sID)); Index: iprof.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun/iprof.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** iprof.h 2001/09/02 20:14:21 1.12 --- iprof.h 2001/11/21 22:31:42 1.13 *************** *** 36,39 **** --- 36,50 ---- #define _IPROF_H_ + #include "../main/includes.h" + #include "../commun/buffer.h" + #include "../prof/lock.h" + #include "../alloc/allocStatData.h" + #include "../cpu/cpuStatData.h" + #include "../mon/monStatData.h" + #include "../allocator/allocator.h" + #include "../list/list.h" + #include "../setup/setup.h" + #include "../list/listItem.h" + /** Communication interface class. This class implements ** the whole communication interface between this profiler *************** *** 52,66 **** typedef void (IProf::*Func)( Buffer&); - public: - /// constants enum e { - /// default TCP port - COMMUN_PORT = 25595, - - /// default shared memory size (in bytes) - COMMUN_SHMEM_SIZE = 256*1024, - /// number of methods of the interface FUNC_COUNT = 9 --- 63,69 ---- *************** *** 85,100 **** typedef jint objectID; - public: - - /// type of communication - enum eCommunType { - - /// sockets (TCP/IP) - COMMUN_SOCKET, - - /// shared memory - COMMUN_SHMEM - }; - protected: --- 88,91 ---- *************** *** 160,188 **** /// info about Java class ! CLASS_INFO = 0, /// info about Java class field ! CLASS_FIELD_INFO = 1, /// info about Java class method ! METHOD_INFO = 2, /// info about Java method trace ! TRACE_INFO = 3, /// info about Java object ! OBJECT_INFO = 4, /// info about Java arena ! ARENA_INFO = 5, /// info about Java thread ! THREAD_INFO = 6, /// info about group of Java threads ! THREAD_GROUP_INFO = 7, /// info about Java garbage collector ! GC_INFO = 8 }; --- 151,179 ---- /// info about Java class ! CLASS_INFO = 0, /// info about Java class field ! CLASS_FIELD_INFO = 1, /// info about Java class method ! METHOD_INFO = 2, /// info about Java method trace ! TRACE_INFO = 3, /// info about Java object ! OBJECT_INFO = 4, /// info about Java arena ! ARENA_INFO = 5, /// info about Java thread ! THREAD_INFO = 6, /// info about group of Java threads ! THREAD_GROUP_INFO = 7, /// info about Java garbage collector ! GC_INFO = 8 }; *************** *** 236,239 **** --- 227,239 ---- objectID objId; + /// ID of parent #1 (on the left side in the structure) + objectID parentLeftObjId; + + /// ID of parent #2 (on up in the structure) + objectID parentUpObjId; + + /// ID of parent #3 (on the right side in the structure) + objectID parentRightObjId; + /// object still active or not jint active; *************** *** 257,260 **** --- 257,270 ---- MonStatData mon; + /// information about object is included or not + jint hasInfo; + + /// information about object (if turned on and possible) or NULL + InfoBinaryFormat* info; + + /// type of information (depends on type of object) + jint infoType; + + #ifdef USE_ALLOCATOR private: *************** *** 266,274 **** /** Overloaded new() operator. */ ! void* operator new( size_t) { return _allocator.get();} /** Overloaded delete() operator. */ void operator delete( void* unit) { _allocator.put( unit);} }; --- 276,285 ---- /** Overloaded new() operator. */ ! void* operator new( size_t sz) { return _allocator.get( sz);} /** Overloaded delete() operator. */ void operator delete( void* unit) { _allocator.put( unit);} + #endif }; *************** *** 396,400 **** /// method traces (monitor profiling) ! MON_TRACES = 38 }; --- 407,418 ---- /// method traces (monitor profiling) ! MON_TRACES = 38, ! ! /// threads where concrete method was called (memory profiling) ! ALLOC_METHOD_THREADS = 40, ! ! /** threads where concrete method in concrete trace ! ** was called (memory profiling) */ ! ALLOC_METHOD_TRACE_THREADS = 41 }; *************** *** 410,416 **** ** supported. ** ! ** @param setup commun setup */ ! IProf( const Setup& setup); /** Destructor. It stops communication and closes --- 428,435 ---- ** supported. ** ! ** @param setup commun setup ! ** @param jvmpi pointer to JVMPI interface */ ! IProf( const Setup& setup, JVMPI_Interface* jvmpi); /** Destructor. It stops communication and closes *************** *** 518,522 **** ** @see getAll() */ ! void _getAll( Buffer& b); /** Get all objects with changed statistic data. This method --- 537,541 ---- ** @see getAll() */ ! void _getAll( Buffer& b) { _getAllOrChanged( 1, b);} /** Get all objects with changed statistic data. This method *************** *** 528,533 **** ** ** @see getChanged() */ ! void _getChanged( Buffer& b); public: --- 547,559 ---- ** ** @see getChanged() */ + + void _getChanged( Buffer& b) { _getAllOrChanged( 0, b);} + + private: + + // internally used by IProf::_getAll() and IProf::_getChanged() + // not documented ! void _getAllOrChanged( int all, Buffer& b); public: *************** *** 573,578 **** ** @see Prof::getInfo(), Prof */ ! virtual jint getInfo( objectID infoId, // in (jint) ! eInfoType type, // in (jint) InfoBinaryFormat*& info) = 0; // out --- 599,604 ---- ** @see Prof::getInfo(), Prof */ ! virtual jint getInfo( objectID infoId, // in (jint) ! eInfoType type, // in (jint) InfoBinaryFormat*& info) = 0; // out *************** *** 582,588 **** ** @see Prof::getData(), Prof */ ! virtual jint getData( objectID objId, // in (jint) ! eDataType type, // in (jint) ! sData& data) = 0; // out /** Get all objects with all statistic data. An abstract --- 608,614 ---- ** @see Prof::getData(), Prof */ ! virtual jint getData( objectID objId, // in (jint) ! eDataType type, // in (jint) ! sData& data) = 0; // out /** Get all objects with all statistic data. An abstract *************** *** 591,597 **** ** @see Prof::getAll(), Prof */ ! virtual jint getAll( objectID objId, // in (jint) ! eSeqType what, // in (jint) ! seqID& seq) = 0; // out /** Get all objects with changed statistic data. An abstract --- 617,625 ---- ** @see Prof::getAll(), Prof */ ! virtual jint getAll( objectID objId, // in (jint) ! eSeqType what, // in (jint) ! jint includeInfo, // in (jint) ! jint optionalArg, // in (jint) ! seqID& seq) = 0; // out /** Get all objects with changed statistic data. An abstract *************** *** 600,606 **** ** @see Prof::getChanged(), Prof */ ! virtual jint getChanged( objectID objId, // in (jint) ! eSeqType what, // in (jint) ! seqID& seq) = 0; // out private: --- 628,636 ---- ** @see Prof::getChanged(), Prof */ ! virtual jint getChanged( objectID objId, // in (jint) ! eSeqType what, // in (jint) ! jint includeInfo, // in (jint) ! jint optionalArg, // in (jint) ! seqID& seq) = 0; // out private: *************** *** 629,631 **** #endif // _IPROF_H_ - --- 659,660 ---- Index: statDataModification.h =================================================================== RCS file: /cvsroot/javaprofiler/library/src/commun/statDataModification.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** statDataModification.h 2001/09/18 22:19:28 1.4 --- statDataModification.h 2001/11/21 22:31:42 1.5 *************** *** 36,39 **** --- 36,41 ---- #define _STAT_DATA_MODIFICATION_H_ + #include "../main/includes.h" + /** Statistic data modification. This class is used ** for indication of change of statistics. *************** *** 55,59 **** _changed( 1) ! {}; /** Data changed. This method returns TRUE, if data has changed. --- 57,61 ---- _changed( 1) ! {} /** Data changed. This method returns TRUE, if data has changed. *************** *** 75,77 **** #endif // _STAT_DATA_MODIFICATION_H_ - --- 77,78 ---- |