[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/engine ilrun.c,1.26,1.27 lib_defs.h,1.1
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/engine ilrun.c,1.26,1.27 lib_defs.h,1.17,1.18 lib_diag.c,1.9,1.10 throw.c,1.3,1.4 |
Date: |
Thu, 26 Dec 2002 04:26:42 -0500 |
Update of /cvsroot/dotgnu-pnet/pnet/engine
In directory subversions:/tmp/cvs-serv12717/engine
Modified Files:
ilrun.c lib_defs.h lib_diag.c throw.c
Log Message:
Use an alternative strategy for printing information about an exception
if calling "ToString()" fails, to hopefully give a better indication
as to what is happening.
Index: ilrun.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/ilrun.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** ilrun.c 16 Dec 2002 12:14:52 -0000 1.26
--- ilrun.c 26 Dec 2002 09:26:39 -0000 1.27
***************
*** 118,123 ****
ILExecThread *thread;
ILObject *args;
- ILString *argString;
- ILObject *exception;
int sawException;
int registerMode = 0;
--- 118,121 ----
***************
*** 360,382 ****
if(sawException)
{
! exception = ILExecThreadGetException(thread);
! ILExecThreadClearException(thread);
! argString = ILObjectToString(thread, exception);
! if(argString != 0 &&
! (param = ILStringToAnsi(thread, argString)) != 0)
! {
! fputs("Uncaught exception: ", stderr);
! fputs(param, stderr);
! putc('\n', stderr);
! }
! else if(exception)
! {
! fputs("An exception occurred which could not be
converted "
! "into a string\n", stderr);
! }
! else
! {
! fputs("virtual memory exhausted\n", stderr);
! }
}
--- 358,362 ----
if(sawException)
{
! ILExecThreadPrintException(thread);
}
Index: lib_defs.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_defs.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** lib_defs.h 21 Jun 2002 06:59:55 -0000 1.17
--- lib_defs.h 26 Dec 2002 09:26:39 -0000 1.18
***************
*** 200,203 ****
--- 200,214 ----
/*
+ * Structure of the "System.Diagnostics.PackedStackFrame" class.
+ */
+ typedef struct
+ {
+ ILMethod *method;
+ ILInt32 offset;
+ ILInt32 nativeOffset;
+
+ } PackedStackFrame;
+
+ /*
* Prototype all of the "internalcall" methods in the engine.
*/
Index: lib_diag.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_diag.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** lib_diag.c 24 Jun 2002 05:54:37 -0000 1.9
--- lib_diag.c 26 Dec 2002 09:26:39 -0000 1.10
***************
*** 400,414 ****
/*
- * Structure of the "System.Diagnostics.PackedStackFrame" class.
- */
- typedef struct
- {
- ILMethod *method;
- ILInt32 offset;
- ILInt32 nativeOffset;
-
- } PackedStackFrame;
-
- /*
* internal static PackedStackFrame[] GetExceptionStackTrace();
*/
--- 400,403 ----
Index: throw.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/throw.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** throw.c 18 Dec 2001 10:15:00 -0000 1.3
--- throw.c 26 Dec 2002 09:26:39 -0000 1.4
***************
*** 19,23 ****
*/
! #include "engine.h"
#ifdef __cplusplus
--- 19,25 ----
*/
! #include "engine_private.h"
! #include "lib_defs.h"
! #include "il_debug.h"
#ifdef __cplusplus
***************
*** 192,195 ****
--- 194,312 ----
{
ILExecThreadSetException(thread,
thread->process->outOfMemoryObject);
+ }
+ }
+
+ void ILExecThreadPrintException(ILExecThread *thread)
+ {
+ ILObject *exception;
+ ILString *str;
+ char *ansistr;
+ ILClass *classInfo;
+ ILClass *exceptionClass;
+ ILField *field;
+ ILObject *stackTrace;
+ ILInt32 length;
+ ILInt32 posn;
+ PackedStackFrame *frames;
+ ILMethod *method;
+ ILImage *image;
+ ILDebugContext *dbg;
+ const char *filename;
+ ILUInt32 line;
+ ILUInt32 col;
+
+ /* Get the exception object from the thread. If there is no object,
+ then assume that memory is exhausted */
+ exception = ILExecThreadGetException(thread);
+ ILExecThreadClearException(thread);
+ if(!exception)
+ {
+ exception = thread->process->outOfMemoryObject;
+ }
+
+ /* Attempt to use "ToString" to format the exception, but not
+ if we know that the exception is reporting out of memory */
+ if(exception != thread->process->outOfMemoryObject)
+ {
+ str = ILObjectToString(thread, exception);
+ if(str != 0 && (ansistr = ILStringToAnsi(thread, str)) != 0)
+ {
+ fputs("Uncaught exception: ", stderr);
+ fputs(ansistr, stderr);
+ putc('\n', stderr);
+ return;
+ }
+ }
+
+ /* Print the class information for the exception */
+ fputs("Uncaught exception: ", stderr);
+ classInfo = GetObjectClass(exception);
+ if(ILClass_Namespace(classInfo))
+ {
+ fputs(ILClass_Namespace(classInfo), stderr);
+ putc('.', stderr);
+ }
+ fputs(ILClass_Name(classInfo), stderr);
+ putc('\n', stderr);
+
+ /* Extract the stack trace from the exception object */
+ exceptionClass = ILExecThreadLookupClass(thread, "System.Exception");
+ stackTrace = 0;
+ if(exceptionClass && ILClassInheritsFrom(classInfo, exceptionClass))
+ {
+ field = 0;
+ while((field = (ILField *)ILClassNextMemberByKind
+ (exceptionClass, (ILMember *)field,
+ IL_META_MEMBERKIND_FIELD)) != 0)
+ {
+ if(!strcmp(ILField_Name(field), "stackTrace"))
+ {
+ stackTrace = *((ILObject **)(((unsigned char
*)exception) +
+
field->offset));
+ break;
+ }
+ }
+ }
+
+ /* Print the exception stack trace */
+ if(stackTrace)
+ {
+ frames = (PackedStackFrame *)ArrayToBuffer(stackTrace);
+ length = ((System_Array *)stackTrace)->length;
+ for(posn = 0; posn < length; ++posn)
+ {
+ method = frames[posn].method;
+ if(method)
+ {
+ fputs("\tat ", stderr);
+ classInfo = ILMethod_Owner(method);
+ if(ILClass_Namespace(classInfo))
+ {
+ fputs(ILClass_Namespace(classInfo),
stderr);
+ putc('.', stderr);
+ }
+ fputs(ILClass_Name(classInfo), stderr);
+ putc('.', stderr);
+ fputs(ILMethod_Name(method), stderr);
+ putc('(', stderr);
+ putc('?', stderr);
+ putc(')', stderr);
+ image = ILProgramItem_Image(method);
+ if(ILDebugPresent(image) && (dbg =
ILDebugCreate(image)) != 0)
+ {
+ filename = ILDebugGetLineInfo
+ (dbg, ILMethod_Token(method),
+ frames[posn].offset, &line,
&col);
+ if(filename)
+ {
+ fputs(" in ", stderr);
+ fputs(filename, stderr);
+ fprintf(stderr, ":%ld",
(long)line);
+ }
+ ILDebugDestroy(dbg);
+ }
+ putc('\n', stderr);
+ }
+ }
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/engine ilrun.c,1.26,1.27 lib_defs.h,1.17,1.18 lib_diag.c,1.9,1.10 throw.c,1.3,1.4,
Rhys Weatherley <address@hidden> <=