|
From: Marek P. <ma...@us...> - 2002-07-15 21:55:16
|
Update of /cvsroot/javaprofiler/library/src/setup
In directory usw-pr-cvs1:/tmp/cvs-serv25109/src/setup
Modified Files:
setup.cpp setup.h
Log Message:
verbose messages added
new "verbose={on|off}" command-line argument
Index: setup.cpp
===================================================================
RCS file: /cvsroot/javaprofiler/library/src/setup/setup.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** setup.cpp 22 Mar 2002 21:22:42 -0000 1.10
--- setup.cpp 15 Jul 2002 21:55:13 -0000 1.11
***************
*** 36,40 ****
#include "../main/const.h"
! Setup::Setup( char* options) {
alloc.turnedOn = 1;
--- 36,40 ----
#include "../main/const.h"
! Setup::Setup( const char* options) {
alloc.turnedOn = 1;
***************
*** 59,111 ****
mon.linenoEnabled = 1;
if( options) processOptions( options);
}
! void Setup::processOptions( char* options) {
!
! char option[100];
! char* end;
! int len;
if( !options) return;
! while( end = strchr(options, ',')) {
! len = end - options;
if( (len > 0) && (len < 100)) {
! strncpy( option, options, len);
option[len] = '\0';
processOption( option);
}
! options = end + 1;
}
! len = strlen( options);
if( (len > 0) && (len < 100)) {
strcpy( option, options);
processOption( option);
}
- }
! void Setup::processOption( char* option) {
! char* eq;
! if( !(eq = strchr( option, '='))) {
! if( !strcmp( option, "version")) {
! cout << "Java Profiling Tool - profiler library" << endl;
! cout << "http://javaprofiler.sourceforge.net/" << endl << endl;
! cout << "build: " << __DATE__ << " " << __TIME__ << endl << endl;
! }
! return;
! }
*eq = '\0';
--- 59,140 ----
mon.linenoEnabled = 1;
+ _verbose = 0;
+
if( options) processOptions( options);
}
! void Setup::processOptions( const char* options) {
if( !options) return;
! const char* p = options;
! const char* end;
!
! while( end = strchr( options, ',')) {
!
! int len = end-options;
!
! if( !memcmp( options, "verbose=on", len)) _verbose = 1;
! else if( !memcmp( options, "verbose=off", len)) _verbose = 0;
!
! options = end+1;
! }
!
! if( !strcmp( options, "verbose=on")) _verbose = 1;
! else if( !strcmp( options, "verbose=off")) _verbose = 0;
!
! if( _verbose) {
!
! cout << endl << "Java Profiling Tool - dynamic profiling library" << endl;
! cout << "http://javaprofiler.sourceforge.net/" << endl;
! cout << "build: " << __DATE__ << " " << __TIME__ << endl << endl;
! cout << "analyzing arguments..." << endl;
! }
!
! options = p;
!
! while( end = strchr( options, ',')) {
! int len = end-options;
if( (len > 0) && (len < 100)) {
! char option[100];
!
! memcpy( option, options, len);
option[len] = '\0';
+
processOption( option);
}
! options = end+1;
}
! int len = strlen( options);
if( (len > 0) && (len < 100)) {
+ char option[100];
+
strcpy( option, options);
+
processOption( option);
}
! if( _verbose) {
! cout << endl << "sumarizing..." << endl;
! if( _verbose) printSumarize();
! cout << endl << "profiling..." << endl;
! }
! }
! void Setup::processOption( char* option) {
! char* eq = strchr( option, '=');
!
! if( !eq) return;
*eq = '\0';
***************
*** 113,274 ****
}
! void Setup::setParameter( char* name, char* value) {
! if( !strcmp( name, "alloc")) {
!
! if( !strcmp( value, "on")) alloc.turnedOn = 1;
! else if( !strcmp( value, "off")) alloc.turnedOn = 0;
! return;
! }
! if( !strcmp( name, "alloc_level")) {
!
! if( !strcmp( value, "object")) alloc.level = LEVEL_OBJECT;
! else if( !strcmp( value, "method")) alloc.level = LEVEL_METHOD;
! else if( !strcmp( value, "trace")) alloc.level = LEVEL_TRACE;
! return;
! }
! if( !strcmp( name, "alloc_trace_depth")) {
!
! int depth = atoi( value);
! if( depth > 0) {
! if( depth > MAX_TRACE) depth = MAX_TRACE;
! alloc.traceDepth = depth;
! }
! return;
! }
! if( !strcmp( name, "alloc_thread")) {
!
! if( !strcmp( value, "on")) alloc.threadsEnabled = 1;
! else if( !strcmp( value, "off")) alloc.threadsEnabled = 0;
! return;
}
! if( !strcmp( name, "alloc_line")) {
! if( !strcmp( value, "on")) alloc.linenoEnabled = 1;
! else if( !strcmp( value, "off")) alloc.linenoEnabled = 0;
! return;
! }
! if( !strcmp( name, "cpu")) {
!
! if( !strcmp( value, "on")) cpu.turnedOn = 1;
! else if( !strcmp( value, "off")) cpu.turnedOn = 0;
! return;
! }
! if( !strcmp( name, "cpu_method")) {
!
! if( !strcmp( value, "exact")) cpu.sampling = 0;
! else if( !strcmp( value, "sampling")) cpu.sampling = 1;
! return;
! }
! if( !strcmp( name, "cpu_level")) {
!
! if( !strcmp( value, "method")) cpu.level = LEVEL_METHOD;
! else if( !strcmp( value, "trace")) cpu.level = LEVEL_TRACE;
! return;
! }
! if( !strcmp( name, "cpu_trace_depth")) {
!
! int depth = atoi( value);
! if( depth > 0) {
!
! if( depth > MAX_TRACE) depth = MAX_TRACE;
! cpu.traceDepth = depth;
! }
! return;
! }
! if( !strcmp( name, "cpu_thread")) {
!
! if( !strcmp( value, "on")) cpu.threadsEnabled = 1;
! else if( !strcmp( value, "off")) cpu.threadsEnabled = 0;
! return;
! }
! if( !strcmp( name, "cpu_line")) {
!
! if( !strcmp( value, "on")) cpu.linenoEnabled = 1;
! else if( !strcmp( value, "off")) cpu.linenoEnabled = 0;
! return;
}
! if( !strcmp( name, "cpu_calltree")) {
! if( !strcmp( value, "on")) cpu.callTreeEnabled = 1;
! else if( !strcmp( value, "off")) cpu.callTreeEnabled = 0;
! return;
! }
! if( !strcmp( name, "cpu_calltree_line")) {
! if( !strcmp( value, "on")) cpu.callTreeLinenoEnabled = 1;
! else if( !strcmp( value, "off")) cpu.callTreeLinenoEnabled = 0;
return;
}
! if( !strcmp( name, "mon")) {
! if( !strcmp( value, "on")) mon.turnedOn = 1;
! else if( !strcmp( value, "off")) mon.turnedOn = 0;
!
! return;
! }
! if( !strcmp( name, "mon_level")) {
!
! if( !strcmp( value, "method")) mon.level = LEVEL_METHOD;
! else if( !strcmp( value, "trace")) mon.level = LEVEL_TRACE;
return;
}
! if( !strcmp( name, "mon_trace_depth")) {
! int depth = atoi( value);
!
! if( depth > 0) {
! if( depth > MAX_TRACE) depth = MAX_TRACE;
! mon.traceDepth = depth;
! }
return;
}
! if( !strcmp( name, "mon_thread")) {
! if( !strcmp( value, "on")) mon.threadsEnabled = 1;
! else if( !strcmp( value, "off")) mon.threadsEnabled = 0;
!
! return;
! }
!
! if( !strcmp( name, "mon_line")) {
! if( !strcmp( value, "on")) mon.linenoEnabled = 1;
! else if( !strcmp( value, "off")) mon.linenoEnabled = 0;
return;
--- 142,278 ----
}
! int Setup::setParamOnOff( const char* name, const char* value) {
! static struct _nv {
! const char* name;
! int* value;
! } nv[] = { { "alloc", &alloc.turnedOn},
! { "alloc_thread", &alloc.threadsEnabled},
! { "alloc_line", &alloc.linenoEnabled},
! { "cpu", &cpu.turnedOn},
! { "cpu_thread", &cpu.threadsEnabled},
! { "cpu_line", &cpu.linenoEnabled},
! { "cpu_calltree", &cpu.callTreeEnabled},
! { "cpu_calltree_line", &cpu.callTreeLinenoEnabled},
! { "mon", &mon.turnedOn},
! { "mon_thread", &mon.threadsEnabled},
! { "mon_line", &mon.linenoEnabled},
! { NULL, NULL}};
! _nv* p = nv;
! while( p->name) {
! if( !strcmp( p->name, name)) {
! if( !strcmp( value, "on")) *p->value = 1;
! else if( !strcmp( value, "off")) *p->value = 0;
! else if( _verbose)
! cout << name
! << ": illegal value, accepted is {on|off}"
! << endl;
! return 1;
! }
! p++;
}
! return 0;
! }
! int Setup::setParamDepth( const char* name, const char* value) {
! static struct _nv {
! const char* name;
! int* value;
! } nv[] = { { "alloc_trace_depth", &alloc.traceDepth},
! { "cpu_trace_depth", &cpu.traceDepth},
! { "mon_trace_depth", &mon.traceDepth},
! { NULL, NULL}};
! _nv* p = nv;
! while( p->name) {
! if( !strcmp( p->name, name)) {
! int depth = atoi( value);
! if( depth < 1 || depth > MAX_TRACE) {
! if( depth > MAX_TRACE) depth = MAX_TRACE;
! else if( depth < 1) depth = 1;
! if( _verbose)
! cout << name
! << ": out of range (1-" << MAX_TRACE
! << "), set to " << depth
! << endl;
! }
! *p->value = depth;
! return 1;
! }
! p++;
}
! return 0;
! }
! void Setup::setParameter( const char* name, const char* value) {
! if( setParamOnOff( name, value)) return;
! if( setParamDepth( name, value)) return;
! if( !strcmp( name, "alloc_level")) {
!
! if( !strcmp( value, "object")) alloc.level = LEVEL_OBJECT;
! else if( !strcmp( value, "method")) alloc.level = LEVEL_METHOD;
! else if( !strcmp( value, "trace")) alloc.level = LEVEL_TRACE;
! else if( _verbose)
! cout << name << ": illegal value, accepted is {object|method|trace}" << endl;
return;
}
! if( !strcmp( name, "cpu_method")) {
! if( !strcmp( value, "exact")) cpu.sampling = 0;
! else if( !strcmp( value, "sampling")) cpu.sampling = 1;
! else if( _verbose)
! cout << name << ": illegal value, accepted is {exact|sampling}" << endl;
return;
}
! if( !strcmp( name, "cpu_level")) {
! if( !strcmp( value, "method")) cpu.level = LEVEL_METHOD;
! else if( !strcmp( value, "trace")) cpu.level = LEVEL_TRACE;
! else if( _verbose)
! cout << name << ": illegal value, accepted is {method|trace}" << endl;
return;
}
! if( !strcmp( name, "mon_level")) {
! if( !strcmp( value, "method")) mon.level = LEVEL_METHOD;
! else if( !strcmp( value, "trace")) mon.level = LEVEL_TRACE;
! else if( _verbose)
! cout << name << ": illegal value, accepted is {method|trace}" << endl;
return;
***************
*** 279,282 ****
--- 283,289 ----
if( !strcmp( value, "socket")) com.communType = COMMUN_SOCKET;
else if( !strcmp( value, "shmem")) com.communType = COMMUN_SHMEM;
+ else if( _verbose)
+
+ cout << name << ": illegal value, accepted is {socket|shmem}" << endl;
return;
***************
*** 286,289 ****
--- 293,300 ----
com.hostname = value;
+
+ if( _verbose && !strlen( value))
+ cout << name << ": hostname is empty !!!" << endl;
+
return;
}
***************
*** 298,301 ****
--- 309,321 ----
com.shmemSize = atoi( value);
+
+ if( com.shmemSize < 256) {
+
+ com.shmemSize = 256;
+
+ if( _verbose)
+ cout << name << ": insufficient size, set to 256 bytes" << endl;
+ }
+
return;
}
***************
*** 304,307 ****
--- 324,331 ----
com.shmemId = value;
+
+ if( _verbose && !strlen( com.shmemId))
+ cout << name << ": shared memory identifier is empty !!!" << endl;
+
return;
}
***************
*** 311,316 ****
--- 335,455 ----
if( !strcmp( value, "server")) com.connectMode = 0;
else if( !strcmp( value, "client")) com.connectMode = 1;
+ else if( _verbose)
+
+ cout << name << ": illegal value, accepted is {server|client}" << endl;
+
+ return;
+ }
+
+ if( !strcmp( name, "verbose")) {
+
+ if( _verbose && strcmp( value, "off") && strcmp( value, "on"))
+
+ cout << name << ": illegal value, accepted is {on|off}" << endl;
return;
+ }
+
+ if( _verbose)
+ cout << name << ": unknown parameter" << endl;
+ }
+
+ void Setup::printSumarize() {
+
+ cout << "memory profiling: ";
+ if( alloc.turnedOn) {
+
+ cout << "enabled" << endl;
+
+ cout << " profiling level: ";
+ if( alloc.level == LEVEL_OBJECT) cout << "objects" << endl;
+ else if( alloc.level == LEVEL_METHOD) cout << "objects and methods" << endl;
+ else {
+
+ cout << "objects, methods and traces" << endl;
+ cout << " trace depth: " << alloc.traceDepth << endl;
+ cout << " trace resolution to lines: "
+ << ((alloc.linenoEnabled) ? "enabled" : "disabled") << endl;
+ }
+
+ cout << " resolution to threads: "
+ << ((alloc.threadsEnabled) ? "enabled" : "disabled") << endl;
+ }
+ else cout << "disabled" << endl;
+
+ cout << "cpu profiling: ";
+ if( cpu.turnedOn) {
+
+ cout << "enabled" << endl;
+
+ cout << " profiling method: " << ((cpu.sampling) ? "sampling" : "exact") << endl;
+
+ cout << " profiling level: ";
+ if( cpu.level == LEVEL_METHOD) cout << "methods" << endl;
+ else {
+
+ cout << "methods and traces" << endl;
+ cout << " trace depth: " << cpu.traceDepth << endl;
+ cout << " trace resolution to lines: "
+ << ((cpu.linenoEnabled) ? "enabled" : "disabled") << endl;
+ }
+
+ cout << " resolution to threads: "
+ << ((cpu.threadsEnabled) ? "enabled" : "disabled") << endl;
+
+ cout << " calltree: ";
+ if( cpu.callTreeEnabled) {
+
+ cout << "enabled" << endl;
+
+ cout << " calltree node resolution to lines: "
+ << ((cpu.callTreeLinenoEnabled) ? "enabled" : "disabled") << endl;
+ }
+ else cout << "disabled" << endl;
+ }
+ else cout << "disabled" << endl;
+
+ cout << "monitor profiling: ";
+ if( mon.turnedOn) {
+
+ cout << "enabled" << endl;
+
+ cout << " profiling level: ";
+ if( mon.level == LEVEL_METHOD) cout << "methods" << endl;
+ else {
+
+ cout << "methods and traces" << endl;
+ cout << " trace depth: " << mon.traceDepth << endl;
+ cout << " trace resolution to lines: "
+ << ((mon.linenoEnabled) ? "enabled" : "disabled") << endl;
+ }
+
+ cout << " resolution to threads: "
+ << ((mon.threadsEnabled) ? "enabled" : "disabled") << endl;
+ }
+ else cout << "disabled" << endl;
+
+ cout << "communication interface: ";
+ if( com.communType == COMMUN_SOCKET) {
+
+ cout << "TCP/IP sockets (local and remote)" << endl;
+ cout << " connection mode (library acts as): ";
+ if( com.connectMode) {
+
+ cout << "client" << endl;
+ cout << " hostname of remote server: " << com.hostname << endl;
+ cout << " port on remote server: " << com.port << endl;
+ }
+ else {
+
+ cout << "server" << endl;
+ cout << " port where library listens for incoming connections: " << com.port << endl;
+ }
+ }
+ else {
+
+ cout << "shared memory (local)" << endl;
+ cout << " identifier (first 3 chars): " << com.shmemId << endl;
+ cout << " size (in bytes): " << com.shmemSize << endl;
}
}
Index: setup.h
===================================================================
RCS file: /cvsroot/javaprofiler/library/src/setup/setup.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** setup.h 22 Mar 2002 21:22:42 -0000 1.12
--- setup.h 15 Jul 2002 21:55:13 -0000 1.13
***************
*** 208,218 ****
** @param options command-line options */
! Setup( char* options = NULL);
/** Sets parameters according to command line options.
**
! ** @param options command line options string */
! void processOptions( char* options);
private:
--- 208,218 ----
** @param options command-line options */
! Setup( const char* options = NULL);
/** Sets parameters according to command line options.
**
! ** @param options command line options string */
! void processOptions( const char* options);
private:
***************
*** 226,233 ****
/** Sets parameter.
**
! ** @param name parameter name
! ** @param value parameter value */
! void setParameter( char* name, char* value);
};
--- 226,271 ----
/** Sets parameter.
**
! ** @param name parameter name
! ** @param value parameter value
! **
! ** @see setParamOnOff(), setParamDepth() */
!
! void setParameter( const char* name, const char* value);
!
! /** Sets an on/off parameter. It only processes
! ** parameters of this type.
! **
! ** @param name parameter name
! ** @param value parameter value (on/off)
! **
! ** @return 1 (okay, processed);
! ** 0 (bad value, not an on/off-parameter)
! **
! ** @see setParameter() */
!
! int setParamOnOff( const char* name, const char* value);
!
! /** Sets a trace depth parameter. It only processes
! ** parameters of this type.
! **
! ** @param name parameter name
! ** @param value parameter value (positive integer)
! **
! ** @return 1 (okay, processed);
! ** 0 (bad value, not a trace depth)
! **
! ** @see setParameter() */
!
! int setParamDepth( const char* name, const char* value);
!
! /** Print sumarizing information. This method prints
! ** the setup sumarizations. */
!
! void printSumarize();
!
! private:
! /// verbose mode is on(1)/off(0)
! int _verbose;
};
|