[m-dev.] diff: debug support for exceptions
Zoltan Somogyi
zs at cs.mu.OZ.AU
Fri Mar 31 16:24:18 AEST 2000
library/exception.m:
runtime/mercury_engine.c:
If MR_DEBUG_JMPBUFS is defined, print out diagnostics to help debug
exceptions thrown across calls to MR_call_engine.
Zoltan.
Index: library/exception.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.16
diff -u -b -r1.16 exception.m
--- library/exception.m 2000/03/20 05:27:10 1.16
+++ library/exception.m 2000/03/31 04:53:47
@@ -640,6 +640,10 @@
ML_report_uncaught_exception(exception);
abort();
} else {
+#ifdef MR_DEBUG_JMPBUFS
+ fprintf(stderr, ""throw longjmp %p\n"",
+ ML_exception_handler->handler);
+#endif
ML_exception_handler->exception = exception;
longjmp(ML_exception_handler->handler, 1);
}
@@ -653,10 +657,20 @@
this_handler.prev = ML_exception_handler;
ML_exception_handler = &this_handler;
+
+#ifdef MR_DEBUG_JMPBUFS
+ fprintf(stderr, ""detcatch setjmp %p\n"", this_handler.handler);
+#endif
+
if (setjmp(this_handler.handler) == 0) {
ML_call_goal_det(type_info, pred, output);
ML_exception_handler = this_handler.prev;
} else {
+#ifdef MR_DEBUG_JMPBUFS
+ fprintf(stderr, ""detcatch caught jmp %p\n"",
+ this_handler.handler);
+#endif
+
ML_exception_handler = this_handler.prev;
ML_call_handler_det(type_info, handler_pred,
this_handler.exception, output);
@@ -671,11 +685,21 @@
this_handler.prev = ML_exception_handler;
ML_exception_handler = &this_handler;
+
+#ifdef MR_DEBUG_JMPBUFS
+ fprintf(stderr, ""semicatch setjmp %p\n"", this_handler.handler);
+#endif
+
if (setjmp(this_handler.handler) == 0) {
bool result = ML_call_goal_semi(type_info, pred, output);
ML_exception_handler = this_handler.prev;
return result;
} else {
+#ifdef MR_DEBUG_JMPBUFS
+ fprintf(stderr, ""semicatch caught jmp %p\n"",
+ this_handler.handler);
+#endif
+
ML_exception_handler = this_handler.prev;
return ML_call_handler_semi(type_info, handler_pred,
this_handler.exception, output);
@@ -713,10 +737,20 @@
this_handler.prev = ML_exception_handler;
ML_exception_handler = &this_handler;
+
+#ifdef MR_DEBUG_JMPBUFS
+ fprintf(stderr, ""noncatch setjmp %p\n"", this_handler.handler);
+#endif
+
if (setjmp(this_handler.handler) == 0) {
ML_call_goal_non(type_info, pred, output, success_cont);
ML_exception_handler = this_handler.prev;
} else {
+#ifdef MR_DEBUG_JMPBUFS
+ fprintf(stderr, ""noncatch caught jmp %p\n"",
+ this_handler.handler);
+#endif
+
ML_exception_handler = this_handler.prev;
ML_call_handler_non(type_info, handler_pred,
this_handler.exception, output, cont);
@@ -764,6 +798,11 @@
locals.this_handler.prev = ML_exception_handler;
ML_exception_handler = &locals.this_handler;
+
+#ifdef MR_DEBUG_JMPBUFS
+ fprintf(stderr, ""noncatch setjmp %p\n"", locals.this_handler.handler);
+#endif
+
if (setjmp(locals.this_handler.handler) == 0) {
ML_call_goal_non(type_info, pred, output,
ML_catch_success_cont, &locals);
@@ -782,6 +821,13 @@
** and then invoke the handler predicate
** for this handler.
*/
+
+#ifdef MR_DEBUG_JMPBUFS
+ fprintf(stderr, ""noncatch caught jmp %p\n"",
+ locals.this_handler.handler);
+#endif
+
+
ML_exception_handler = locals.this_handler.prev;
ML_call_handler_non(type_info, handler_pred,
locals.this_handler.exception, output,
@@ -1410,7 +1456,16 @@
** that we found.
*/
+#ifdef MR_DEBUG_JMPBUFS
+ fprintf(stderr, ""throw catch_code_model %d\n"", catch_code_model);
+#endif
+
if (catch_code_model == MR_C_LONGJMP_HANDLER) {
+#ifdef MR_DEBUG_JMPBUFS
+ fprintf(stderr, ""throw longjmp %p\n"",
+ *(MR_ENGINE(e_jmp_buf)));
+#endif
+
MR_ENGINE(e_exception) = (Word *) exception;
save_registers();
longjmp(*(MR_ENGINE(e_jmp_buf)), 1);
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_engine.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.c,v
retrieving revision 1.21
diff -u -b -r1.21 mercury_engine.c
--- runtime/mercury_engine.c 1999/11/22 18:37:36 1.21
+++ runtime/mercury_engine.c 2000/03/31 04:53:56
@@ -236,10 +236,20 @@
/*
** Mark this as the spot to return to.
*/
+
+#ifdef MR_DEBUG_JMPBUFS
+ printf("engine setjmp %p\n", curr_jmp_buf);
+#endif
+
if (setjmp(curr_jmp_buf)) {
Word * this_frame;
Word * exception;
+#ifdef MR_DEBUG_JMPBUFS
+ printf("engine caught jmp %p %p\n",
+ prev_jmp_buf, MR_ENGINE(e_jmp_buf));
+#endif
+
debugmsg0("...caught longjmp\n");
/*
** On return,
@@ -504,6 +514,11 @@
*/
MR_ENGINE(e_exception) = NULL;
save_registers();
+
+#ifdef MR_DEBUG_JMPBUFS
+ printf("engine longjmp %p\n", MR_ENGINE(e_jmp_buf));
+#endif
+
debugmsg0("longjmping out...\n");
longjmp(*(MR_ENGINE(e_jmp_buf)), 1);
}} /* end call_engine_inner() */
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list