From: Daniel Colascione Date: Tue, 26 Apr 2011 11:26:05 +0000 (-0700) Subject: Implement debug-on-event X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~208^2~5 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0438ce915d3408496eae848c351c2c7dde896b7b;p=emacs.git Implement debug-on-event --- diff --git a/etc/ChangeLog b/etc/ChangeLog index 24f44b9d0e8..73cee7763db 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog @@ -1,3 +1,8 @@ +2011-04-26 Daniel Colascione + + * Document debug-on-event default behavior and utility for + debugging. + 2011-04-22 Noah Friedman * emacs-buffer.gdb: Add trailing underscores to appropriate member diff --git a/etc/DEBUG b/etc/DEBUG index c8fd48c6bfa..625a76ac952 100644 --- a/etc/DEBUG +++ b/etc/DEBUG @@ -405,6 +405,11 @@ stepping, you will see where the loop starts and ends. Also, examine the data being used in the loop and try to determine why the loop does not exit when it should. +You can also trying sending Emacs SIGUSR2, which, if `debug-on-event' +has its default value, will cause Emacs to attempt to break it out of +its current loop and into the Lisp debugger. This feature is useful +when a C-level debugger is not conveniently available. + ** If certain operations in Emacs are slower than they used to be, here is some advice for how to find out why. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index de7379149e8..0bf790e7137 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2011-04-26 Daniel Colascione + + * cus-start.el (all): Define customization for debug-on-event. + 2011-04-26 Daniel Colascione * subr.el (shell-quote-argument): Escape correctly under Windows. diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 1188d37150a..6113a4321c5 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -259,6 +259,11 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of (suggest-key-bindings keyboard (choice (const :tag "off" nil) (integer :tag "time" 2) (other :tag "on"))) + (debug-on-event debug + (choice (const :tag "None" nil) + (const :tag "When sent SIGUSR1" sigusr1) + (const :tag "When sent SIGUSR2" sigusr2)) + "24.1") ;; This is not good news because it will use the wrong ;; version-specific directories when you upgrade. We need diff --git a/src/ChangeLog b/src/ChangeLog index 1985cdc3768..04f2e6a5752 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2011-04-26 Daniel Colascione + + * lisp.h (Qdebug): List symbol. + * eval.c (Qdebug): restore global linkage. + * keyboard.c (debug-on-event): New variable. + (handle_user_signal): Break into debugger when debug-on-event + matches the current signal symbol. + 2011-04-25 Dan Nicolaescu * alloc.c (check_sblock, check_string_bytes) diff --git a/src/eval.c b/src/eval.c index d1f327021e6..8716ad78468 100644 --- a/src/eval.c +++ b/src/eval.c @@ -88,7 +88,7 @@ static Lisp_Object Qdebug_on_error; static Lisp_Object Qdeclare; Lisp_Object Qinternal_interpreter_environment, Qclosure; -static Lisp_Object Qdebug; +Lisp_Object Qdebug; /* This holds either the symbol `run-hooks' or nil. It is nil at an early stage of startup, and when Emacs diff --git a/src/keyboard.c b/src/keyboard.c index c601649ebca..11cdeaf469c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -7228,12 +7228,29 @@ handle_user_signal (int sig) { int old_errno = errno; struct user_signal_info *p; + const char* special_event_name = NULL; SIGNAL_THREAD_CHECK (sig); - + + if (SYMBOLP (Vdebug_on_event)) + special_event_name = SDATA (SYMBOL_NAME (Vdebug_on_event)); + for (p = user_signals; p; p = p->next) if (p->sig == sig) { + if (special_event_name && + strcmp (special_event_name, p->name) == 0) + { + /* Enter the debugger in many ways. */ + debug_on_next_call = 1; + debug_on_quit = 1; + Vquit_flag = Qt; + Vinhibit_quit = Qnil; + + /* Eat the event. */ + break; + } + p->npending++; #ifdef SIGIO if (interrupt_input) @@ -12165,6 +12182,17 @@ text in the region before modifying the buffer. The next `deactivate-mark' call uses this to set the window selection. */); Vsaved_region_selection = Qnil; + DEFVAR_LISP ("debug-on-event", + Vdebug_on_event, + doc: /* Enter debugger on this event. When Emacs +receives the special event specifed by this variable, it will try to +break into the debugger as soon as possible instead of processing the +event normally through `special-event-map'. + +Currently, the only supported values for this +variable are `sigusr1' and `sigusr2'. */); + Vdebug_on_event = intern_c_string ("sigusr2"); + /* Create the initial keyboard. */ initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); init_kboard (initial_kboard); diff --git a/src/lisp.h b/src/lisp.h index 07b2cb0b1ef..44df38e9fa6 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2796,7 +2796,7 @@ extern void syms_of_lread (void); /* Defined in eval.c. */ extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qdefun, Qmacro; -extern Lisp_Object Qinhibit_quit, Qclosure; +extern Lisp_Object Qinhibit_quit, Qclosure, Qdebug; extern Lisp_Object Qand_rest; extern Lisp_Object Vautoload_queue; extern Lisp_Object Vsignaling_function;