Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
166:7a77eb660975 | 167:85ec50267440 |
---|---|
475 | 475 |
476 /* Return 1 if an error with condition-symbols CONDITIONS, | 476 /* Return 1 if an error with condition-symbols CONDITIONS, |
477 and described by SIGNAL-DATA, should skip the debugger | 477 and described by SIGNAL-DATA, should skip the debugger |
478 according to debugger-ignore-errors. */ | 478 according to debugger-ignore-errors. */ |
479 | 479 |
480 extern Lisp_Object Frunning_temacs_p(), Ferror_message_string(Lisp_Object obj); | |
481 | |
482 static int | 480 static int |
483 skip_debugger (Lisp_Object conditions, Lisp_Object data) | 481 skip_debugger (Lisp_Object conditions, Lisp_Object data) |
484 { | 482 { |
483 /* This function can GC */ | |
485 Lisp_Object tail; | 484 Lisp_Object tail; |
486 int first_string = 1; | 485 int first_string = 1; |
487 Lisp_Object error_message; | 486 Lisp_Object error_message; |
488 #if 0 | |
489 struct gcpro gcpro1; | |
490 #endif | |
491 | |
492 /* Comment by Hrvoje Niksic: | |
493 For some reason, Ferror_message_string loses in temacs. This | |
494 should require some more consideration than this knee-jerk | |
495 solution, but it will do for now. For those interested in | |
496 debugging, here is what happens: | |
497 | |
498 In temacs, a condition-cased file-error occurs. Now, we enter | |
499 signal_call_debugger, which is supposed to decide whether we | |
500 should call debugger (for example, if `debug-on-signal' requires | |
501 it). signal_call_debugger calls skip_debugger, which calls | |
502 Ferror_message_string. Ferror_message_string in turn calls | |
503 print_error_message. For some unfathomable reason, the | |
504 expression | |
505 | |
506 errname = Fcar (data); | |
507 | |
508 fails with a `wrong-type-argument' error, which should not | |
509 happen, as the DATA argument is the very same Lisp_Object | |
510 skip_debugger was called with (which is in signal_call_debugger, | |
511 and the DATA argument is Fcons (FOO, BAR)). | |
512 | |
513 Of course, since an error is signaled, signal_call_debugger gets | |
514 called again, which calls skip_debugger, and we end up with a | |
515 beautiful endless recursion. | |
516 | |
517 The only explanation I can think of is that DATA should be | |
518 gc-protected during the way; I cannot test this, as I cannot | |
519 repeat all of this. The crash info comes from Steve. */ | |
520 #if 0 | |
521 if (!NILP(Frunning_temacs_p())) | |
522 { | |
523 return 0; | |
524 } | |
525 #endif | |
526 #if 0 | |
527 GCPRO1(data); | |
528 #endif | |
529 | 487 |
530 for (tail = Vdebug_ignored_errors; CONSP (tail); tail = XCDR (tail)) | 488 for (tail = Vdebug_ignored_errors; CONSP (tail); tail = XCDR (tail)) |
531 { | 489 { |
532 if (STRINGP (XCAR (tail))) | 490 if (STRINGP (XCAR (tail))) |
533 { | 491 { |
534 if (first_string) | 492 if (first_string) |
535 { | 493 { |
536 error_message = Ferror_message_string (data); | 494 error_message = Ferror_message_string (data); |
537 /* error_message = build_string("Tell_Hrvoje"); */ | |
538 first_string = 0; | 495 first_string = 0; |
539 } | 496 } |
540 if (fast_lisp_string_match (XCAR (tail), error_message) >= 0) { | 497 if (fast_lisp_string_match (XCAR (tail), error_message) >= 0) |
541 #if 0 | |
542 UNGCPRO; | |
543 #endif | |
544 return 1; | 498 return 1; |
545 } | |
546 } | 499 } |
547 else | 500 else |
548 { | 501 { |
549 Lisp_Object contail; | 502 Lisp_Object contail; |
550 | 503 |
551 for (contail = conditions; CONSP (contail); contail = XCDR (contail)) | 504 for (contail = conditions; CONSP (contail); contail = XCDR (contail)) |
552 if (EQ (XCAR (tail), XCAR (contail))) { | 505 if (EQ (XCAR (tail), XCAR (contail))) |
553 #if 0 | |
554 UNGCPRO; | |
555 #endif | |
556 return 1; | 506 return 1; |
557 } | |
558 } | 507 } |
559 } | 508 } |
560 | 509 |
561 #if 0 | |
562 UNGCPRO; | |
563 #endif | |
564 return 0; | 510 return 0; |
565 } | 511 } |
566 | 512 |
567 /* Actually generate a backtrace on STREAM. */ | 513 /* Actually generate a backtrace on STREAM. */ |
568 | 514 |
608 int *debugger_entered) | 554 int *debugger_entered) |
609 { | 555 { |
610 /* This function can GC */ | 556 /* This function can GC */ |
611 Lisp_Object val = Qunbound; | 557 Lisp_Object val = Qunbound; |
612 Lisp_Object all_handlers = Vcondition_handlers; | 558 Lisp_Object all_handlers = Vcondition_handlers; |
559 Lisp_Object temp_data = Qnil; | |
613 int speccount = specpdl_depth_counter; | 560 int speccount = specpdl_depth_counter; |
614 int skip_debugger_for_error = 0; | 561 struct gcpro gcpro1, gcpro2; |
615 struct gcpro gcpro1; | 562 GCPRO2 (all_handlers, temp_data); |
616 GCPRO1 (all_handlers); | |
617 | 563 |
618 Vcondition_handlers = active_handlers; | 564 Vcondition_handlers = active_handlers; |
619 | 565 |
620 skip_debugger_for_error = skip_debugger (conditions, Fcons (sig, data)); | 566 temp_data = Fcons (sig, data); /* needed for skip_debugger */ |
621 | 567 |
622 if (!entering_debugger && !*stack_trace_displayed && !signal_vars_only | 568 if (!entering_debugger && !*stack_trace_displayed && !signal_vars_only |
623 && !skip_debugger_for_error | 569 && wants_debugger (Vstack_trace_on_error, conditions) |
624 && wants_debugger (Vstack_trace_on_error, conditions)) | 570 && !skip_debugger (conditions, temp_data)) |
625 { | 571 { |
626 specbind (Qdebug_on_error, Qnil); | 572 specbind (Qdebug_on_error, Qnil); |
627 specbind (Qstack_trace_on_error, Qnil); | 573 specbind (Qstack_trace_on_error, Qnil); |
628 specbind (Qdebug_on_signal, Qnil); | 574 specbind (Qdebug_on_signal, Qnil); |
629 specbind (Qstack_trace_on_signal, Qnil); | 575 specbind (Qstack_trace_on_signal, Qnil); |
635 unbind_to (speccount, Qnil); | 581 unbind_to (speccount, Qnil); |
636 *stack_trace_displayed = 1; | 582 *stack_trace_displayed = 1; |
637 } | 583 } |
638 | 584 |
639 if (!entering_debugger && !*debugger_entered && !signal_vars_only | 585 if (!entering_debugger && !*debugger_entered && !signal_vars_only |
640 && !skip_debugger_for_error | |
641 && (EQ (sig, Qquit) | 586 && (EQ (sig, Qquit) |
642 ? debug_on_quit | 587 ? debug_on_quit |
643 : wants_debugger (Vdebug_on_error, conditions))) | 588 : wants_debugger (Vdebug_on_error, conditions)) |
589 && !skip_debugger (conditions, temp_data)) | |
644 { | 590 { |
645 debug_on_quit &= ~2; /* reset critical bit */ | 591 debug_on_quit &= ~2; /* reset critical bit */ |
646 specbind (Qdebug_on_error, Qnil); | 592 specbind (Qdebug_on_error, Qnil); |
647 specbind (Qstack_trace_on_error, Qnil); | 593 specbind (Qstack_trace_on_error, Qnil); |
648 specbind (Qdebug_on_signal, Qnil); | 594 specbind (Qdebug_on_signal, Qnil); |