From xemacs-m  Fri Jun 27 07:59:39 1997
Received: from jagor.srce.hr (hniksic@jagor.srce.hr [161.53.2.130])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id HAA29894
	for <xemacs-beta@xemacs.org>; Fri, 27 Jun 1997 07:59:37 -0500 (CDT)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id OAA10013; Fri, 27 Jun 1997 14:59:28 +0200 (MET DST)
To: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: Slight cleanup to skip_debugger
X-Attribution: Hrv
X-Face: Mie8:rOV<\c/~z{s.X4A{!?vY7{drJ([U]0O=W/<W*SMo/Mv:58:*_y~ki>xDi&N7XG
        KV^$k0m3Oe/)'e%3=$PCR&3ITUXH,cK>]bci&<qQ>Ff%x_>1`T(+M2Gg/fgndU%k*ft
        [(7._6e0n-V%|%'[c|q:;}td$#INd+;?!-V=c8Pqf}3J
From: Hrvoje Niksic <hniksic@srce.hr>
Date: 27 Jun 1997 14:59:27 +0200
Message-ID: <kigvi30b3rk.fsf@jagor.srce.hr>
Lines: 150

Here is a cleanup in skip_debugger.  I didn't want to send it in
before, because this patch is likely to make things /more/ stable, and
I wanted us to fix problems (if any) first.

As for gcpro-ing: since a gc can happen below `skip_debugger', I
believe it is the duty of the caller to gcpro.  This may make a gcpro
in print.c unnecessary, but better safe than sorry.

Also note that call to `skip_debugger' is now after the call to
`wants_debugger', which means that this function will be much more
rarely (in fact, almost never, if debug_on_error is nil) called.  This 
will eliminate the possibility of another endless recursion.  Also,
`wants_debugger' doesn't include that many regexps, so it will make
things marginally faster, too (that's the way FSFmacs has it.)

--- src/eval.c.orig	Fri Jun 27 03:33:33 1997
+++ src/eval.c	Fri Jun 27 14:53:58 1997
@@ -482,50 +482,10 @@
 static int
 skip_debugger (Lisp_Object conditions, Lisp_Object data)
 {
+  /* This function can GC */
   Lisp_Object tail;
   int first_string = 1;
   Lisp_Object error_message;
-#if 0
-  struct gcpro gcpro1;
-#endif
-
-  /* Comment by Hrvoje Niksic:
-     For some reason, Ferror_message_string loses in temacs.  This
-     should require some more consideration than this knee-jerk
-     solution, but it will do for now.  For those interested in
-     debugging, here is what happens:
-
-     In temacs, a condition-cased file-error occurs.  Now, we enter
-     signal_call_debugger, which is supposed to decide whether we
-     should call debugger (for example, if `debug-on-signal' requires
-     it).  signal_call_debugger calls skip_debugger, which calls
-     Ferror_message_string.  Ferror_message_string in turn calls
-     print_error_message.  For some unfathomable reason, the
-     expression
-
-        errname = Fcar (data);
-
-     fails with a `wrong-type-argument' error, which should not
-     happen, as the DATA argument is the very same Lisp_Object
-     skip_debugger was called with (which is in signal_call_debugger,
-     and the DATA argument is Fcons (FOO, BAR)).
-
-     Of course, since an error is signaled, signal_call_debugger gets
-     called again, which calls skip_debugger, and we end up with a
-     beautiful endless recursion.
-
-     The only explanation I can think of is that DATA should be
-     gc-protected during the way; I cannot test this, as I cannot
-     repeat all of this.  The crash info comes from Steve. */
-#if 0
-  if (!NILP(Frunning_temacs_p()))
-    {
-      return 0;
-    }
-#endif
-#if 0
-  GCPRO1(data);
-#endif
 
   for (tail = Vdebug_ignored_errors; CONSP (tail); tail = XCDR (tail))
     {
@@ -534,33 +494,21 @@
 	  if (first_string)
 	    {
 	      error_message = Ferror_message_string (data);
-/*	      error_message = build_string("Tell_Hrvoje"); */
 	      first_string = 0;
 	    }
-	  if (fast_lisp_string_match (XCAR (tail), error_message) >= 0) {
-#if 0
-	    UNGCPRO;
-#endif
+	  if (fast_lisp_string_match (XCAR (tail), error_message) >= 0)
 	    return 1;
-	  }
 	}
       else
 	{
 	  Lisp_Object contail;
 
           for (contail = conditions; CONSP (contail); contail = XCDR (contail))
-            if (EQ (XCAR (tail), XCAR (contail))) {
-#if 0
-	      UNGCPRO;
-#endif
+            if (EQ (XCAR (tail), XCAR (contail)))
 	      return 1;
-	    }
 	}
     }
 
-#if 0
-  UNGCPRO;
-#endif
   return 0;
 }
 
@@ -610,18 +558,18 @@
   /* This function can GC */
   Lisp_Object val = Qunbound;
   Lisp_Object all_handlers = Vcondition_handlers;
+  Lisp_Object temp_data = Qnil;
   int speccount = specpdl_depth_counter;
-  int skip_debugger_for_error = 0;
-  struct gcpro gcpro1;
-  GCPRO1 (all_handlers);
+  struct gcpro gcpro1, gcpro2;
+  GCPRO2 (all_handlers, temp_data);
 
   Vcondition_handlers = active_handlers;
 
-  skip_debugger_for_error = skip_debugger (conditions, Fcons (sig, data));
+  temp_data = Fcons (sig, data); /* needed for skip_debugger */
 
   if (!entering_debugger && !*stack_trace_displayed && !signal_vars_only
-      && !skip_debugger_for_error
-      && wants_debugger (Vstack_trace_on_error, conditions))
+      && wants_debugger (Vstack_trace_on_error, conditions)
+      && !skip_debugger (conditions, temp_data))
     {
       specbind (Qdebug_on_error, Qnil);
       specbind (Qstack_trace_on_error, Qnil);
@@ -637,10 +585,10 @@
     }
       
   if (!entering_debugger && !*debugger_entered && !signal_vars_only
-      && !skip_debugger_for_error
       && (EQ (sig, Qquit)
 	  ? debug_on_quit
-	  : wants_debugger (Vdebug_on_error, conditions)))
+	  : wants_debugger (Vdebug_on_error, conditions))
+      && !skip_debugger (conditions, temp_data))
     {
       debug_on_quit &= ~2;	/* reset critical bit */
       specbind (Qdebug_on_error, Qnil);


-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Unspeakable horrors from outer space paralyze the living and
resurrect the dead!

