Index: engine/verify_except.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/verify_except.c,v
retrieving revision 1.9
diff -c -r1.9 verify_except.c
*** engine/verify_except.c	26 May 2003 05:47:03 -0000	1.9
--- engine/verify_except.c	8 May 2004 22:14:11 -0000
***************
*** 20,25 ****
--- 20,40 ----
  
  #if defined(IL_VERIFY_GLOBALS)
  
+ #define TRACE_EXCEPTION_INTERNALS() \
+ 			do { \
+ 					printf("\t\t\texception == %p\n", exception); \
+ 					printf("\t\t\t\t{\n"); \
+ 					printf("\t\t\t\t\tflags         = %d,\n", exception->flags); \
+ 					printf("\t\t\t\t\ttryOffset     = %d,\n", exception->tryOffset); \
+ 					printf("\t\t\t\t\ttryLength     = %d,\n", exception->tryLength); \
+ 					printf("\t\t\t\t\thandlerOffset = %d,\n", exception->handlerOffset); \
+ 					printf("\t\t\t\t\thandlerLength = %d,\n", exception->handlerLength); \
+ 					printf("\t\t\t\t\textraArg      = %d,\n", exception->extraArg); \
+ 					printf("\t\t\t\t\tuserData      = %d,\n", exception->userData); \
+ 					printf("\t\t\t\t\tnext          = %p\n",  exception->next); \
+ 					printf("\t\t\t\t};\n"); \
+ 				} while(0)
+ 
  /*
   * Output a table of exception matching directives.
   * Each table entry specifies a region of code for the
***************
*** 38,127 ****
  	ILException *exception;
  	ILClass *classInfo;
  
  	/* Process all regions in the method */
  	offset = 0;
  	for(;;)
  	{
  		/* Find the exception region that matches the offset */
  		exception = exceptions;
  		lowestTry = IL_MAX_UINT32;
  		while(exception != 0)
  		{
  			if(offset >= exception->tryOffset &&
  			   offset < (exception->tryOffset + exception->tryLength))
  			{
  				/* The offset is within this region */
  				break;
  			}
! 			else if(offset < exception->tryOffset)
  			{
! 				/* The offset starts entirely before this region */
! 				lowestTry = exception->tryOffset;
! 				break;
  			}
  			exception = exception->next;
  		}
  		if(!exception)
  		{
  			break;
  		}
  		if(lowestTry != IL_MAX_UINT32)
  		{
  			end = lowestTry;
  		}
  		else
  		{
  			end = exception->tryOffset + exception->tryLength;
  		}
  
  		/* Output the region information to the table */
  		ILCoderTryHandlerStart(coder, offset, end);
  
  		/* Output exception matching code for this region */
  		exception = exceptions;
  		while(exception != 0)
  		{
  			if(offset >= exception->tryOffset &&
  			   offset < (exception->tryOffset + exception->tryLength))
  			{
  				if((exception->flags & (IL_META_EXCEPTION_FINALLY |
  										IL_META_EXCEPTION_FAULT)) != 0)
  				{
  					/* Call a "finally" or "fault" clause */
  					ILCoderJsr(coder, exception->handlerOffset);
  				}
- 				else if((exception->flags & IL_META_EXCEPTION_FILTER) == 0)
- 				{
- 					/* Match against a "catch" clause */
- 					classInfo = ILProgramItemToClass
- 						((ILProgramItem *)ILImageTokenInfo
- 							(ILProgramItem_Image(method), exception->extraArg));
- 					ILCoderCatch(coder, exception, classInfo, hasRethrow);
- 				}
  				else
  				{
! 					/* TODO: handle a "filter" clause */
  				}
  			}
  			exception = exception->next;
  		}
  
  		/* If execution falls off the end of the matching code,
  		   then throw the exception to the calling method */
  		ILCoderThrow(coder, 0);
  
  		/* Mark the end of the handler */
  		ILCoderTryHandlerEnd(coder);
  
  		/* Advance to the next region within the code */
  		offset = end;
  	}
  
  	/* If execution gets here, then there were no applicable catch blocks,
  	   so we always throw the exception to the calling method */
  	ILCoderTryHandlerStart(coder, 0, IL_MAX_UINT32);
  	ILCoderThrow(coder, 0);
  	ILCoderTryHandlerEnd(coder);
  }
  
  /*
--- 53,225 ----
  	ILException *exception;
  	ILClass *classInfo;
  
+ 
+ 	printf("OutputExceptionTable(%s)\n", ILMember_Name((ILMember *)method));
+ 	printf("{\n");
+ 
  	/* Process all regions in the method */
  	offset = 0;
+ 	printf("\tfor(;;)\n");
+ 	printf("\t{\n");
  	for(;;)
  	{
+ 		printf("\t\toffset = %d;\n", offset);
+ 
  		/* Find the exception region that matches the offset */
  		exception = exceptions;
  		lowestTry = IL_MAX_UINT32;
+ 		printf("\t\twhile(exception != 0)\n");
+ 		printf("\t\t{\n");
  		while(exception != 0)
  		{
+ 			TRACE_EXCEPTION_INTERNALS();
+ 
+ 			printf("\t\t\tif(offset::%d >= exception->tryOffset::%d &&\n", offset, exception->tryOffset);
+ 			printf("\t\t\t   offset::%d < (exception->tryOffset::%d + exception->tryLength::%d))\n", offset, exception->tryOffset, exception->tryLength);
+ 			printf("\t\t\t{\n");
  			if(offset >= exception->tryOffset &&
  			   offset < (exception->tryOffset + exception->tryLength))
  			{
  				/* The offset is within this region */
+ 				printf("\t\t\t\tbreak;\n");
+ 				printf("\t\t\t}\n");
  				break;
  			}
! 			else
  			{
! 				printf("\t\t\t}\n");
! 				printf("\t\t\telse if(offset::%d < exception->tryOffset::%d)\n", offset, exception->tryOffset);
! 				printf("\t\t\t{\n");
! 				if(offset < exception->tryOffset)
! 				{
! 					/* The offset starts entirely before this region */
! 					lowestTry = exception->tryOffset;
! 					printf("\t\t\t\tlowestTry = exception->tryOffset::%d;\n", exception->tryOffset);
! 					printf("\t\t\t\tbreak;\n");
! 					printf("\t\t\t}\n");
! 					break;
! 				}
  			}
+ 			printf("\t\t\t}\n");
  			exception = exception->next;
  		}
+ 		printf("\t\t}\n\n");
+ 
+ 		printf("\t\tif(!exception)\n");
+ 		printf("\t\t{\n");
  		if(!exception)
  		{
+ 			printf("\t\t\tbreak;\n");
+ 			printf("\t\t}\n");
  			break;
  		}
+ 		printf("\t\t}\n\n");
+ 
+ 		printf("\t\tif(lowestTry::%d != IL_MAX_UINT32)\n", lowestTry);
+ 		printf("\t\t{\n");
  		if(lowestTry != IL_MAX_UINT32)
  		{
+ 			printf("\t\t\tend = lowestTry::%d;\n", lowestTry);
  			end = lowestTry;
  		}
  		else
  		{
+ 			printf("\t\t}\n");
+ 			printf("\t\telse\n");
+ 			printf("\t\t{\n");
+ 			printf("\t\t\tend = exception->tryOffset::%d + exception->tryLength::%d;\n", exception->tryOffset, exception->tryLength);
  			end = exception->tryOffset + exception->tryLength;
  		}
+ 		printf("\t\t}\n\n");
  
  		/* Output the region information to the table */
+ 		printf("\t\tILCoderTryHandlerStart(coder::%p, offset::%d, end::%d);\n", coder, offset, end);
  		ILCoderTryHandlerStart(coder, offset, end);
  
  		/* Output exception matching code for this region */
  		exception = exceptions;
+ 		printf("\t\twhile(exception != 0)\n");
+ 		printf("\t\t{\n");
  		while(exception != 0)
  		{
+ 			TRACE_EXCEPTION_INTERNALS();
+ 
+ 			printf("\t\t\tif(offset::%d >= exception->tryOffset::%d &&\n", offset, exception->tryOffset);
+ 			printf("\t\t\t   offset::%d < (exception->tryOffset::%d + exception->tryLength::%d))\n", offset, exception->tryOffset, exception->tryLength);
+ 			printf("\t\t\t{\n");
  			if(offset >= exception->tryOffset &&
  			   offset < (exception->tryOffset + exception->tryLength))
  			{
+ 				printf("\t\t\t\tif(exception->flags::%d & (IL_META_EXCEPTION_FINALLY::%d |\n", exception->flags, IL_META_EXCEPTION_FINALLY);
+ 				printf("\t\t\t\t                           IL_META_EXCEPTION_FAULT::%d)) !=0)\n", IL_META_EXCEPTION_FAULT);
+ 				printf("\t\t\t\t{\n");
  				if((exception->flags & (IL_META_EXCEPTION_FINALLY |
  										IL_META_EXCEPTION_FAULT)) != 0)
  				{
+ 					printf("\t\t\t\t\tILCoderJsr(coder::%p, exception->handlerOffset::%d);\n", coder, exception->handlerOffset);
  					/* Call a "finally" or "fault" clause */
  					ILCoderJsr(coder, exception->handlerOffset);
  				}
  				else
  				{
! 					printf("\t\t\t\t}\n");
! 					printf("\t\t\t\telse if((exception->flags & IL_META_EXCEPTION_FILTER) == 0)\n");
! 					printf("\t\t\t\t{\n");
! 					if((exception->flags & IL_META_EXCEPTION_FILTER) == 0)
! 					{
! 						printf("\t\t\t\t\tclassInfo = ILProgramItemToClass\n");
! 						printf("\t\t\t\t\t\t((ILProgramItem *)ILImageTokenInfo\n");
! 						printf("\t\t\t\t\t\t\t(ILProgramItem_Image(method::%p), exception->extraArg::%d));\n", method, exception->extraArg);
! 						/* Match against a "catch" clause */
! 						classInfo = ILProgramItemToClass
! 							((ILProgramItem *)ILImageTokenInfo
! 								(ILProgramItem_Image(method), exception->extraArg));
! 						printf("\t\t\t\t\tILCoderCatch(coder::%p, exception::%p, classInfo::%p, hasRethrow::%d);\n", coder, exception, classInfo, hasRethrow);
! 						ILCoderCatch(coder, exception, classInfo, hasRethrow);
! 					}
! 					else
! 					{
! 						printf("\t\t\t\t}\n");
! 						printf("\t\t\t\telse\n");
! 						printf("\t\t\t\t{\n");
! 						printf("\t\t\t\t\t/* TODO: handle a \"filter\" clause */\n");
! 						/* TODO: handle a "filter" clause */
! 					}
  				}
+ 				printf("\t\t\t\t}\n");
  			}
+ 			printf("\t\t\t}\n");
  			exception = exception->next;
  		}
+ 		printf("\t\t}\n");
  
  		/* If execution falls off the end of the matching code,
  		   then throw the exception to the calling method */
+ 		printf("\t\tILCoderThrow(coder::%p, 0);\n", coder);
  		ILCoderThrow(coder, 0);
  
  		/* Mark the end of the handler */
+ 		printf("\t\tILCoderTryHandlerEnd(coder::%p);\n", coder);
  		ILCoderTryHandlerEnd(coder);
  
  		/* Advance to the next region within the code */
+ 		printf("\t\toffset = end::%d;\n", end);
  		offset = end;
+ 
+ 		printf("\n********************************************************************************\n\n");
  	}
+ 	printf("\t}\n");
  
  	/* If execution gets here, then there were no applicable catch blocks,
  	   so we always throw the exception to the calling method */
+ 	printf("\tILCoderTryHandlerStart(coder::%p, 0, IL_MAX_UINT32);\n", coder);
  	ILCoderTryHandlerStart(coder, 0, IL_MAX_UINT32);
+ 	printf("\tILCoderThrow(coder::%p, 0);\n", coder);
  	ILCoderThrow(coder, 0);
+ 	printf("\tILCoderTryHandlerEnd(coder::%p);\n", coder);
  	ILCoderTryHandlerEnd(coder);
+ 
+ 	printf("}\n");
  }
  
  /*
