diff src/eval.c @ 167:85ec50267440 r20-3b10

Import from CVS: tag r20-3b10
author cvs
date Mon, 13 Aug 2007 09:45:46 +0200
parents 5a88923fcbfe
children 8eaf7971accc
line wrap: on
line diff
--- a/src/eval.c	Mon Aug 13 09:44:44 2007 +0200
+++ b/src/eval.c	Mon Aug 13 09:45:46 2007 +0200
@@ -477,55 +477,13 @@
    and described by SIGNAL-DATA, should skip the debugger
    according to debugger-ignore-errors.  */
 
-extern Lisp_Object Frunning_temacs_p(), Ferror_message_string(Lisp_Object obj);
-
 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 +492,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 +556,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 +583,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);