axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From whitl...@apache.org
Subject cvs commit: ws-axis/c/tools/org/apache/axis/tools/trace Tracer.java
Date Tue, 18 Jan 2005 15:02:20 GMT
whitlock    2005/01/18 07:02:20

  Modified:    c/src/common AxisTrace.cpp AxisTrace.h
               c/tools/org/apache/axis/tools/trace Tracer.java
  Log:
  Better exception trace
  
  Revision  Changes    Path
  1.54      +71 -31    ws-axis/c/src/common/AxisTrace.cpp
  
  Index: AxisTrace.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/common/AxisTrace.cpp,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- AxisTrace.cpp	17 Jan 2005 12:39:16 -0000	1.53
  +++ AxisTrace.cpp	18 Jan 2005 15:02:20 -0000	1.54
  @@ -25,11 +25,12 @@
   #include <stdarg.h>
   #include <stdlib.h>
   #include "AxisUtils.h"
  -#include <axis/GDefine.hpp>
  +#include <axis/AxisException.hpp>
   #include "AxisConfig.h"
   #include <string>
   // cctype is needed to make isprint compile on linux
   #include <cctype>
  +#include <exception>
   
   extern AXIS_CPP_NAMESPACE_PREFIX AxisConfig* g_pConfig;
   AXIS_CPP_NAMESPACE_START
  @@ -390,39 +391,16 @@
   		line += *((bool*)value)?"true":"false";
   		break;
   
  -	/*
  -	 * This code only prints out the first 32 bytes of storage pointed at by a 
  -	 * pointer. This is to prevent huge blocks of atorage repeatedly being output
  -	 * to the trace file. 32 bytes seems quite a low limit. Maybe this limit 
  -	 * could be increased in the future. Large blocks of storage could be output
  -	 * in a more human-friendly format.
  -	 */
   	case TRACETYPE_POINTER:	
               pcValue = *((char**)pcValue);
   		sprintf(prim,"%p ",pcValue);	
   		line += prim;	
  -            if (NULL==pcValue) return;
  -		// no break!
  +            if (NULL!=pcValue) 
  +			addDataParameter(line,len,value);
  +		break;
   	
   	case TRACETYPE_DATA:	
  -		try {
  -			line += "[";
  -			for (unsigned i=0; i<len && i<32; i++) {
  -				int x = (int)(pcValue[i]);
  -				sprintf(prim,"%2.2X",x);
  -				line += prim;
  -			}
  -			line += "] <";
  -			for (unsigned j=0; j<len && j<32; j++) {
  -				char c = pcValue[j];
  -				if (!isprint(c)) c='.';
  -				sprintf(prim,"%c",c);
  -				line += prim;
  -			}
  -			line += ">";
  -		} catch (...) {
  -			line += "<BADPOINTER>";
  -		}
  +		addDataParameter(line,len,value);
   		break;
   
   	case TRACETYPE_STRING:	
  @@ -441,9 +419,41 @@
   
   	case TRACETYPE_STLSTRING:
   		try {
  -			line += "\"";	
  -   		      line += ((string*)value)->c_str();
  -			line += "\"";	
  +			string *str = static_cast<string*>(value);
  +			if (str) {
  +				line += "\"";	
  +   			      line += str->c_str();
  +				line += "\"";	
  +			} else line += "<BADPOINTER>";
  +		} catch (...) {
  +			line += "<BADPOINTER>";
  +		}
  +		break;
  +
  +	case TRACETYPE_EXCEPTION:
  +		try {
  +			exception *ex = static_cast<exception*>(value);
  +	   	      const char *msg = ex->what();
  +			if (NULL==msg) msg = "\?\?\?\?";
  +			line += "exception(\"";
  +	   	      line += msg;
  +			line += "\")";	
  +		} catch (...) {
  +			line += "<BADPOINTER>";
  +		}
  +		break;
  +
  +	case TRACETYPE_AXISEXCEPTION:
  +		try {
  +			AxisException *ex = static_cast<AxisException*>(value);
  +		      const int code = ex->getExceptionCode();
  +	   	      const char *msg = ex->what();
  +			if (NULL==msg) msg = "\?\?\?\?";
  +			line += "AxisException(";	
  +   		      line += code;
  +   		     	line += ", \"";
  +	   	      line += msg;
  +			line += "\")";	
   		} catch (...) {
   			line += "<BADPOINTER>";
   		}
  @@ -459,6 +469,36 @@
   		line += prim;
   		line += ">";
   		break;
  +	}
  +}
  +
  +/**
  + * This code only prints out the first 32 bytes of storage pointed at by a 
  + * pointer. This is to prevent huge blocks of atorage repeatedly being output
  + * to the trace file. 32 bytes seems quite a low limit. Maybe this limit 
  + * could be increased in the future. Large blocks of storage could be output
  + * in a more human-friendly format.
  + */
  +void AxisTrace::addDataParameter(string& line, unsigned len, void *value) {
  +	char prim[32]; // Plenty big enough to hold a primitive
  +      char *pcValue = (char*)value;
  +	try {
  +		line += "[";
  +		for (unsigned i=0; i<len && i<32; i++) {
  +			int x = (int)(pcValue[i]);
  +			sprintf(prim,"%2.2X",x);
  +			line += prim;
  +		}
  +		line += "] <";
  +		for (unsigned j=0; j<len && j<32; j++) {
  +			char c = pcValue[j];
  +			if (!isprint(c)) c='.';
  +			sprintf(prim,"%c",c);
  +			line += prim;
  +		}
  +		line += ">";
  +	} catch (...) {
  +		line += "<BADPOINTER>";
   	}
   }
   
  
  
  
  1.26      +20 -17    ws-axis/c/src/common/AxisTrace.h
  
  Index: AxisTrace.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/common/AxisTrace.h,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- AxisTrace.h	17 Jan 2005 12:39:16 -0000	1.25
  +++ AxisTrace.h	18 Jan 2005 15:02:20 -0000	1.26
  @@ -60,23 +60,25 @@
   // Unfortunately the trace type has to be an int with #defines, not an enum because
   // it is used with '...' and va_args, and ints can be used with '...' but enums 
   // cannot.
  -#define TRACETYPE_UNKNOWN	0
  -#define TRACETYPE_CHAR		1
  -#define TRACETYPE_USHORT	2
  -#define TRACETYPE_SHORT		3
  -#define TRACETYPE_UINT		4
  -#define TRACETYPE_INT		5
  -#define TRACETYPE_ULONG		6
  -#define TRACETYPE_LONG		7
  -#define TRACETYPE_UDOUBLE	8
  -#define TRACETYPE_DOUBLE	9
  -#define TRACETYPE_FLOAT		10
  -#define TRACETYPE_BOOL		11
  -#define TRACETYPE_POINTER	12
  -#define TRACETYPE_DATA		13
  -#define TRACETYPE_STRING	14
  -#define TRACETYPE_STLSTRING	15
  -#define TRACETYPE_ANONYMOUS	16
  +#define TRACETYPE_UNKNOWN		0
  +#define TRACETYPE_CHAR			1
  +#define TRACETYPE_USHORT		2
  +#define TRACETYPE_SHORT			3
  +#define TRACETYPE_UINT			4
  +#define TRACETYPE_INT			5
  +#define TRACETYPE_ULONG			6	
  +#define TRACETYPE_LONG			7
  +#define TRACETYPE_UDOUBLE		8
  +#define TRACETYPE_DOUBLE		9
  +#define TRACETYPE_FLOAT			10
  +#define TRACETYPE_BOOL			11
  +#define TRACETYPE_POINTER		12
  +#define TRACETYPE_DATA			13
  +#define TRACETYPE_STRING		14
  +#define TRACETYPE_STLSTRING		15
  +#define TRACETYPE_ANONYMOUS		16
  +#define TRACETYPE_EXCEPTION		17
  +#define TRACETYPE_AXISEXCEPTION	18
   
   class AxisTraceEntrypoints {
   public:
  @@ -283,6 +285,7 @@
   
       static int logthis(const char* pcLog, int level, char* arg2, int arg3);
   	static void addParameter(std::string& line, int type, unsigned len, void *value);
  +	static void addDataParameter(std::string& line, unsigned len, void *value);
       static void traceHeader();
   };
   
  
  
  
  1.5       +8 -0      ws-axis/c/tools/org/apache/axis/tools/trace/Tracer.java
  
  Index: Tracer.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/tools/org/apache/axis/tools/trace/Tracer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Tracer.java	17 Jan 2005 12:39:16 -0000	1.4
  +++ Tracer.java	18 Jan 2005 15:02:20 -0000	1.5
  @@ -355,9 +355,17 @@
   			String contents = type.substring(0, type.length() - 1);
   			if (typetable.keySet().contains(contents)) {
   				parms += (String) typetable.get(contents) + ", 0, " + name;
  +			} else if (contents.startsWith("Axis") && contents.endsWith("Exception")) {
  +				parms += "AXISEXCEPTION, sizeof(" + type + "), " + name;
  +			} else if (contents.equals("exception")) {
  +				parms += "EXCEPTION, sizeof(" + type + "), " + name;
   			} else {
   				parms += "DATA, sizeof(" + type + "), " + name;
   			}
  +		} else if (type.startsWith("Axis") && type.endsWith("Exception")) {
  +			parms += "AXISEXCEPTION, sizeof(" + type + "), " + name;
  +		} else if (type.equals("exception")) {
  +			parms += "EXCEPTION, sizeof(" + type + "), " + name;
   		} else {
   			parms += "DATA, sizeof(" + type + "), " + name;
   		}
  
  
  

Mime
View raw message