/[emacs]/emacs/src/eval.c
ViewVC logotype

Diff of /emacs/src/eval.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.243 by lektu, Thu Jun 23 16:07:51 2005 UTC revision 1.244 by rms, Sat Jun 25 14:37:47 2005 UTC
# Line 227  init_eval () Line 227  init_eval ()
227    when_entered_debugger = -1;    when_entered_debugger = -1;
228  }  }
229    
230    /* unwind-protect function used by call_debugger.  */
231    
232    static Lisp_Object
233    restore_stack_limits (data)
234         Lisp_Object data;
235    {
236      max_specpdl_size = XINT (XCAR (data));
237      max_lisp_eval_depth = XINT (XCDR (data));
238    }
239    
240    /* Call the Lisp debugger, giving it argument ARG.  */
241    
242  Lisp_Object  Lisp_Object
243  call_debugger (arg)  call_debugger (arg)
244       Lisp_Object arg;       Lisp_Object arg;
# Line 234  call_debugger (arg) Line 246  call_debugger (arg)
246    int debug_while_redisplaying;    int debug_while_redisplaying;
247    int count = SPECPDL_INDEX ();    int count = SPECPDL_INDEX ();
248    Lisp_Object val;    Lisp_Object val;
249      int old_max = max_specpdl_size;
250    
251    if (lisp_eval_depth + 20 > max_lisp_eval_depth)    /* Temporarily bump up the stack limits,
252      max_lisp_eval_depth = lisp_eval_depth + 20;       so the debugger won't run out of stack.  */
253    
254    if (specpdl_size + 40 > max_specpdl_size)    max_specpdl_size += 1;
255      max_specpdl_size = specpdl_size + 40;    record_unwind_protect (restore_stack_limits,
256                             Fcons (make_number (old_max),
257                                    make_number (max_lisp_eval_depth)));
258      max_specpdl_size = old_max;
259    
260      if (lisp_eval_depth + 40 > max_lisp_eval_depth)
261        max_lisp_eval_depth = lisp_eval_depth + 40;
262    
263      if (SPECPDL_INDEX () + 100 > max_specpdl_size)
264        max_specpdl_size = SPECPDL_INDEX () + 100;
265    
266  #ifdef HAVE_X_WINDOWS  #ifdef HAVE_X_WINDOWS
267    if (display_hourglass_p)    if (display_hourglass_p)
# Line 256  call_debugger (arg) Line 278  call_debugger (arg)
278    specbind (intern ("debugger-may-continue"),    specbind (intern ("debugger-may-continue"),
279              debug_while_redisplaying ? Qnil : Qt);              debug_while_redisplaying ? Qnil : Qt);
280    specbind (Qinhibit_redisplay, Qnil);    specbind (Qinhibit_redisplay, Qnil);
281      specbind (Qdebug_on_error, Qnil);
282    
283  #if 0 /* Binding this prevents execution of Lisp code during  #if 0 /* Binding this prevents execution of Lisp code during
284           redisplay, which necessarily leads to display problems.  */           redisplay, which necessarily leads to display problems.  */
# Line 1533  See also the function `condition-case'. Line 1556  See also the function `condition-case'.
1556    /* This hook is used by edebug.  */    /* This hook is used by edebug.  */
1557    if (! NILP (Vsignal_hook_function)    if (! NILP (Vsignal_hook_function)
1558        && ! NILP (error_symbol))        && ! NILP (error_symbol))
1559      call2 (Vsignal_hook_function, error_symbol, data);      {
1560          /* Edebug takes care of restoring these variables when it exits.  */
1561          if (lisp_eval_depth + 20 > max_lisp_eval_depth)
1562            max_lisp_eval_depth = lisp_eval_depth + 20;
1563    
1564          if (SPECPDL_INDEX () + 40 > max_specpdl_size)
1565            max_specpdl_size = SPECPDL_INDEX () + 40;
1566    
1567          call2 (Vsignal_hook_function, error_symbol, data);
1568        }
1569    
1570    conditions = Fget (real_error_symbol, Qerror_conditions);    conditions = Fget (real_error_symbol, Qerror_conditions);
1571    
# Line 1555  See also the function `condition-case'. Line 1587  See also the function `condition-case'.
1587      {      {
1588        register Lisp_Object clause;        register Lisp_Object clause;
1589    
       if (lisp_eval_depth + 20 > max_lisp_eval_depth)  
         max_lisp_eval_depth = lisp_eval_depth + 20;  
   
       if (specpdl_size + 40 > max_specpdl_size)  
         max_specpdl_size = specpdl_size + 40;  
   
1590        clause = find_handler_clause (handlerlist->handler, conditions,        clause = find_handler_clause (handlerlist->handler, conditions,
1591                                      error_symbol, data, &debugger_value);                                      error_symbol, data, &debugger_value);
1592    
# Line 1673  skip_debugger (conditions, data) Line 1699  skip_debugger (conditions, data)
1699      = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA).      = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA).
1700         This is for memory-full errors only.         This is for memory-full errors only.
1701    
1702     Store value returned from debugger into *DEBUGGER_VALUE_PTR.  */     Store value returned from debugger into *DEBUGGER_VALUE_PTR.
1703    
1704       We need to increase max_specpdl_size temporarily around
1705       anything we do that can push on the specpdl, so as not to get
1706       a second error here in case we're handling specpdl overflow.  */
1707    
1708  static Lisp_Object  static Lisp_Object
1709  find_handler_clause (handlers, conditions, sig, data, debugger_value_ptr)  find_handler_clause (handlers, conditions, sig, data, debugger_value_ptr)
# Line 1691  find_handler_clause (handlers, condition Line 1721  find_handler_clause (handlers, condition
1721        || !NILP (Vdebug_on_signal)) /* This says call debugger even if        || !NILP (Vdebug_on_signal)) /* This says call debugger even if
1722                                        there is a handler.  */                                        there is a handler.  */
1723      {      {
       int count = SPECPDL_INDEX ();  
1724        int debugger_called = 0;        int debugger_called = 0;
1725        Lisp_Object sig_symbol, combined_data;        Lisp_Object sig_symbol, combined_data;
1726        /* This is set to 1 if we are handling a memory-full error,        /* This is set to 1 if we are handling a memory-full error,
# Line 1713  find_handler_clause (handlers, condition Line 1742  find_handler_clause (handlers, condition
1742    
1743        if (wants_debugger (Vstack_trace_on_error, conditions))        if (wants_debugger (Vstack_trace_on_error, conditions))
1744          {          {
1745              max_specpdl_size++;
1746  #ifdef PROTOTYPES  #ifdef PROTOTYPES
1747            internal_with_output_to_temp_buffer ("*Backtrace*",            internal_with_output_to_temp_buffer ("*Backtrace*",
1748                                                 (Lisp_Object (*) (Lisp_Object)) Fbacktrace,                                                 (Lisp_Object (*) (Lisp_Object)) Fbacktrace,
# Line 1721  find_handler_clause (handlers, condition Line 1751  find_handler_clause (handlers, condition
1751            internal_with_output_to_temp_buffer ("*Backtrace*",            internal_with_output_to_temp_buffer ("*Backtrace*",
1752                                                 Fbacktrace, Qnil);                                                 Fbacktrace, Qnil);
1753  #endif  #endif
1754              max_specpdl_size--;
1755          }          }
1756        if (! no_debugger        if (! no_debugger
1757            && (EQ (sig_symbol, Qquit)            && (EQ (sig_symbol, Qquit)
# Line 1729  find_handler_clause (handlers, condition Line 1760  find_handler_clause (handlers, condition
1760            && ! skip_debugger (conditions, combined_data)            && ! skip_debugger (conditions, combined_data)
1761            && when_entered_debugger < num_nonmacro_input_events)            && when_entered_debugger < num_nonmacro_input_events)
1762          {          {
           specbind (Qdebug_on_error, Qnil);  
1763            *debugger_value_ptr            *debugger_value_ptr
1764              = call_debugger (Fcons (Qerror,              = call_debugger (Fcons (Qerror,
1765                                      Fcons (combined_data, Qnil)));                                      Fcons (combined_data, Qnil)));
# Line 1739  find_handler_clause (handlers, condition Line 1769  find_handler_clause (handlers, condition
1769        if (EQ (handlers, Qerror))        if (EQ (handlers, Qerror))
1770          {          {
1771            if (debugger_called)            if (debugger_called)
1772              return unbind_to (count, Qlambda);              return Qlambda;
1773            return Qt;            return Qt;
1774          }          }
1775      }      }
# Line 3019  grow_specpdl () Line 3049  grow_specpdl ()
3049        if (max_specpdl_size < 400)        if (max_specpdl_size < 400)
3050          max_specpdl_size = 400;          max_specpdl_size = 400;
3051        if (specpdl_size >= max_specpdl_size)        if (specpdl_size >= max_specpdl_size)
3052          {          Fsignal (Qerror,
3053            if (!NILP (Vdebug_on_error))                   Fcons (build_string ("Variable binding depth exceeds max-specpdl-size"), Qnil));
             /* Leave room for some specpdl in the debugger.  */  
             max_specpdl_size = specpdl_size + 100;  
           Fsignal (Qerror,  
                    Fcons (build_string ("Variable binding depth exceeds max-specpdl-size"), Qnil));  
         }  
3054      }      }
3055    specpdl_size *= 2;    specpdl_size *= 2;
3056    if (specpdl_size > max_specpdl_size)    if (specpdl_size > max_specpdl_size)
# Line 3333  syms_of_eval () Line 3358  syms_of_eval ()
3358  {  {
3359    DEFVAR_INT ("max-specpdl-size", &max_specpdl_size,    DEFVAR_INT ("max-specpdl-size", &max_specpdl_size,
3360                doc: /* *Limit on number of Lisp variable bindings & unwind-protects.                doc: /* *Limit on number of Lisp variable bindings & unwind-protects.
3361  If Lisp code tries to make more than this many at once,  If Lisp code tries to increase the total number past this amount,
3362  an error is signaled.  an error is signaled.
3363  You can safely use a value considerably larger than the default value,  You can safely use a value considerably larger than the default value,
3364  if that proves inconveniently small.  However, if you increase it too far,  if that proves inconveniently small.  However, if you increase it too far,

Legend:
Removed from v.1.243  
changed lines
  Added in v.1.244

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26