emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r109880: Implement `debug-on-message'


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109880: Implement `debug-on-message'.
Date: Tue, 04 Sep 2012 23:21:00 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109880
committer: Lars Ingebrigtsen <address@hidden>
branch nick: trunk
timestamp: Tue 2012-09-04 23:21:00 +0200
message:
  Implement `debug-on-message'.
  
  This allows tracking down what piece of code is outputting stuff in
  the echo area.
  
  * eval.c (call_debugger): Make the function non-static so that we
  can call it from set_message.
  
  * xdisp.c (set_message): Implement the new variable `debug-on-message'.
  (syms_of_xdisp): Defvar it and `inhibit-debug-on-message'.
modified:
  doc/lispref/ChangeLog
  doc/lispref/debugging.texi
  etc/NEWS
  src/ChangeLog
  src/eval.c
  src/lisp.h
  src/xdisp.c
=== modified file 'doc/lispref/ChangeLog'
--- a/doc/lispref/ChangeLog     2012-09-02 04:47:28 +0000
+++ b/doc/lispref/ChangeLog     2012-09-04 21:21:00 +0000
@@ -1,3 +1,7 @@
+2012-09-04  Lars Ingebrigtsen  <address@hidden>
+
+       * debugging.texi (Explicit Debug): Document `debug-on-message'.
+
 2012-09-02  Chong Yidong  <address@hidden>
 
        * windows.texi (Window Configurations): Recommend against using

=== modified file 'doc/lispref/debugging.texi'
--- a/doc/lispref/debugging.texi        2012-05-27 01:34:14 +0000
+++ b/doc/lispref/debugging.texi        2012-09-04 21:21:00 +0000
@@ -298,6 +298,11 @@
 program!)  The most common suitable places are inside a @code{progn} or
 an implicit @code{progn} (@pxref{Sequencing}).
 
+  If you don't know exactly where in the source code you want to put
+the debug statement, but you want to display a backtrace when a
+certain message is displayed, you can set @code{debug-on-message} to a
+regular expression matching the desired message.
+
 @node Using Debugger
 @subsection Using the Debugger
 

=== modified file 'etc/NEWS'
--- a/etc/NEWS  2012-09-04 18:29:04 +0000
+++ b/etc/NEWS  2012-09-04 21:21:00 +0000
@@ -1916,6 +1916,10 @@
 *** Set `debug-on-event' to enter the debugger on events like SIGUSR1.
 This can be useful when `inhibit-quit' is set.
 
+*** Set `debug-on-message' to enter the debugger when a certain
+message is displayed in the echo area.  This can be useful when trying
+to work out which code is doing something.
+
 ** The new function `server-eval-at' allows evaluation of Lisp forms on
 named Emacs server instances.
 

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-09-04 18:29:04 +0000
+++ b/src/ChangeLog     2012-09-04 21:21:00 +0000
@@ -1,3 +1,11 @@
+2012-09-04  Lars Ingebrigtsen  <address@hidden>
+
+       * eval.c (call_debugger): Make the function non-static so that we
+       can call it from set_message.
+
+       * xdisp.c (set_message): Implement the new variable `debug-on-message'.
+       (syms_of_xdisp): Defvar it and `inhibit-debug-on-message'.
+
 2012-09-04  Paul Eggert  <address@hidden>
 
        Give more-useful info on a fatal error (Bug#12328).

=== modified file 'src/eval.c'
--- a/src/eval.c        2012-09-04 17:34:54 +0000
+++ b/src/eval.c        2012-09-04 21:21:00 +0000
@@ -191,7 +191,7 @@
 
 /* Call the Lisp debugger, giving it argument ARG.  */
 
-static Lisp_Object
+Lisp_Object
 call_debugger (Lisp_Object arg)
 {
   bool debug_while_redisplaying;

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2012-09-04 18:29:04 +0000
+++ b/src/lisp.h        2012-09-04 21:21:00 +0000
@@ -3076,6 +3076,7 @@
 extern _Noreturn void verror (const char *, va_list)
   ATTRIBUTE_FORMAT_PRINTF (1, 0);
 extern Lisp_Object un_autoload (Lisp_Object);
+extern Lisp_Object call_debugger (Lisp_Object arg);
 extern void init_eval_once (void);
 extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...);
 extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object);

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2012-09-04 17:34:54 +0000
+++ b/src/xdisp.c       2012-09-04 21:21:00 +0000
@@ -364,6 +364,7 @@
 Lisp_Object Qcenter;
 static Lisp_Object Qmargin, Qpointer;
 static Lisp_Object Qline_height;
+Lisp_Object Qinhibit_debug_on_message;
 
 /* These setters are used only in this file, so they can be private.  */
 static inline void
@@ -10571,7 +10572,6 @@
   return 0;
 }
 
-
 /* Set the current message to a substring of S or STRING.
 
    If STRING is a Lisp string, set the message to the first NBYTES
@@ -10590,6 +10590,8 @@
 set_message (const char *s, Lisp_Object string,
             ptrdiff_t nbytes, int multibyte_p)
 {
+  ptrdiff_t count = SPECPDL_INDEX ();
+
   message_enable_multibyte
     = ((s && multibyte_p)
        || (STRINGP (string) && STRING_MULTIBYTE (string)));
@@ -10598,6 +10600,15 @@
                         (intptr_t) s, string, nbytes, multibyte_p);
   message_buf_print = 0;
   help_echo_showing_p = 0;
+
+  if (NILP (Vinhibit_debug_on_message) &&
+      STRINGP (Vdebug_on_message) &&
+      fast_string_match (Vdebug_on_message, string) >= 0) {
+    specbind (Qinhibit_debug_on_message, Qt);
+    call_debugger (Fcons (Qerror, Fcons (string, Qnil)));
+  }
+
+  unbind_to (count, Qnil);
 }
 
 
@@ -29299,6 +29310,15 @@
   Vglyphless_char_display = Fmake_char_table (Qglyphless_char_display, Qnil);
   Fset_char_table_extra_slot (Vglyphless_char_display, make_number (0),
                              Qempty_box);
+
+  DEFVAR_LISP ("debug-on-message", Vdebug_on_message,
+              doc: /* If non-nil, debug if a message matching this regexp is 
displayed.  */);
+  Vdebug_on_message = Qnil;
+
+  DEFVAR_LISP ("inhibit-debug-on-message", Vinhibit_debug_on_message,
+              doc: /* If non-nil, inhibit `debug-on-message' from entering the 
debugger.  */);
+  Vinhibit_debug_on_message = Qnil;
+  DEFSYM(Qinhibit_debug_on_message, "inhibit-debug-on-message");
 }
 
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]