aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2012-09-04 23:21:00 +0200
committerLars Ingebrigtsen2012-09-04 23:21:00 +0200
commit7f7e0167cf664f2d66ac3fa8a7301e05f09883d2 (patch)
treeef9d2dade54e23c6c37e6bd655aae118cdbde261
parentcf29dd84d205e1c78fed5d1ea0006a382658598c (diff)
downloademacs-7f7e0167cf664f2d66ac3fa8a7301e05f09883d2.tar.gz
emacs-7f7e0167cf664f2d66ac3fa8a7301e05f09883d2.zip
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'.
-rw-r--r--doc/lispref/ChangeLog4
-rw-r--r--doc/lispref/debugging.texi5
-rw-r--r--etc/NEWS4
-rw-r--r--src/ChangeLog8
-rw-r--r--src/eval.c2
-rw-r--r--src/lisp.h1
-rw-r--r--src/xdisp.c22
7 files changed, 44 insertions, 2 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index b0156e5ac7e..50f9853b7eb 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,7 @@
12012-09-04 Lars Ingebrigtsen <larsi@gnus.org>
2
3 * debugging.texi (Explicit Debug): Document `debug-on-message'.
4
12012-09-02 Chong Yidong <cyd@gnu.org> 52012-09-02 Chong Yidong <cyd@gnu.org>
2 6
3 * windows.texi (Window Configurations): Recommend against using 7 * windows.texi (Window Configurations): Recommend against using
diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi
index 00e8d84e9b3..5aeff576d09 100644
--- a/doc/lispref/debugging.texi
+++ b/doc/lispref/debugging.texi
@@ -298,6 +298,11 @@ of @code{(debug)} isn't ignored, it will alter the execution of the
298program!) The most common suitable places are inside a @code{progn} or 298program!) The most common suitable places are inside a @code{progn} or
299an implicit @code{progn} (@pxref{Sequencing}). 299an implicit @code{progn} (@pxref{Sequencing}).
300 300
301 If you don't know exactly where in the source code you want to put
302the debug statement, but you want to display a backtrace when a
303certain message is displayed, you can set @code{debug-on-message} to a
304regular expression matching the desired message.
305
301@node Using Debugger 306@node Using Debugger
302@subsection Using the Debugger 307@subsection Using the Debugger
303 308
diff --git a/etc/NEWS b/etc/NEWS
index 9a38deef05c..e137ebc0665 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1916,6 +1916,10 @@ instead of jumping all the way to the top-level.
1916*** Set `debug-on-event' to enter the debugger on events like SIGUSR1. 1916*** Set `debug-on-event' to enter the debugger on events like SIGUSR1.
1917This can be useful when `inhibit-quit' is set. 1917This can be useful when `inhibit-quit' is set.
1918 1918
1919*** Set `debug-on-message' to enter the debugger when a certain
1920message is displayed in the echo area. This can be useful when trying
1921to work out which code is doing something.
1922
1919** The new function `server-eval-at' allows evaluation of Lisp forms on 1923** The new function `server-eval-at' allows evaluation of Lisp forms on
1920named Emacs server instances. 1924named Emacs server instances.
1921 1925
diff --git a/src/ChangeLog b/src/ChangeLog
index ea3b3a92e01..d7a263df229 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12012-09-04 Lars Ingebrigtsen <larsi@gnus.org>
2
3 * eval.c (call_debugger): Make the function non-static so that we
4 can call it from set_message.
5
6 * xdisp.c (set_message): Implement the new variable `debug-on-message'.
7 (syms_of_xdisp): Defvar it and `inhibit-debug-on-message'.
8
12012-09-04 Paul Eggert <eggert@cs.ucla.edu> 92012-09-04 Paul Eggert <eggert@cs.ucla.edu>
2 10
3 Give more-useful info on a fatal error (Bug#12328). 11 Give more-useful info on a fatal error (Bug#12328).
diff --git a/src/eval.c b/src/eval.c
index 1015b013a26..4f0d6c69a51 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -191,7 +191,7 @@ restore_stack_limits (Lisp_Object data)
191 191
192/* Call the Lisp debugger, giving it argument ARG. */ 192/* Call the Lisp debugger, giving it argument ARG. */
193 193
194static Lisp_Object 194Lisp_Object
195call_debugger (Lisp_Object arg) 195call_debugger (Lisp_Object arg)
196{ 196{
197 bool debug_while_redisplaying; 197 bool debug_while_redisplaying;
diff --git a/src/lisp.h b/src/lisp.h
index 9ee9cd74b56..78c418f3051 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3076,6 +3076,7 @@ extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
3076extern _Noreturn void verror (const char *, va_list) 3076extern _Noreturn void verror (const char *, va_list)
3077 ATTRIBUTE_FORMAT_PRINTF (1, 0); 3077 ATTRIBUTE_FORMAT_PRINTF (1, 0);
3078extern Lisp_Object un_autoload (Lisp_Object); 3078extern Lisp_Object un_autoload (Lisp_Object);
3079extern Lisp_Object call_debugger (Lisp_Object arg);
3079extern void init_eval_once (void); 3080extern void init_eval_once (void);
3080extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...); 3081extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...);
3081extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); 3082extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object);
diff --git a/src/xdisp.c b/src/xdisp.c
index f543a96d6b3..90a8de0be27 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -364,6 +364,7 @@ static Lisp_Object Qslice;
364Lisp_Object Qcenter; 364Lisp_Object Qcenter;
365static Lisp_Object Qmargin, Qpointer; 365static Lisp_Object Qmargin, Qpointer;
366static Lisp_Object Qline_height; 366static Lisp_Object Qline_height;
367Lisp_Object Qinhibit_debug_on_message;
367 368
368/* These setters are used only in this file, so they can be private. */ 369/* These setters are used only in this file, so they can be private. */
369static inline void 370static inline void
@@ -10571,7 +10572,6 @@ truncate_message_1 (ptrdiff_t nchars, Lisp_Object a2, ptrdiff_t a3, ptrdiff_t a4
10571 return 0; 10572 return 0;
10572} 10573}
10573 10574
10574
10575/* Set the current message to a substring of S or STRING. 10575/* Set the current message to a substring of S or STRING.
10576 10576
10577 If STRING is a Lisp string, set the message to the first NBYTES 10577 If STRING is a Lisp string, set the message to the first NBYTES
@@ -10590,6 +10590,8 @@ static void
10590set_message (const char *s, Lisp_Object string, 10590set_message (const char *s, Lisp_Object string,
10591 ptrdiff_t nbytes, int multibyte_p) 10591 ptrdiff_t nbytes, int multibyte_p)
10592{ 10592{
10593 ptrdiff_t count = SPECPDL_INDEX ();
10594
10593 message_enable_multibyte 10595 message_enable_multibyte
10594 = ((s && multibyte_p) 10596 = ((s && multibyte_p)
10595 || (STRINGP (string) && STRING_MULTIBYTE (string))); 10597 || (STRINGP (string) && STRING_MULTIBYTE (string)));
@@ -10598,6 +10600,15 @@ set_message (const char *s, Lisp_Object string,
10598 (intptr_t) s, string, nbytes, multibyte_p); 10600 (intptr_t) s, string, nbytes, multibyte_p);
10599 message_buf_print = 0; 10601 message_buf_print = 0;
10600 help_echo_showing_p = 0; 10602 help_echo_showing_p = 0;
10603
10604 if (NILP (Vinhibit_debug_on_message) &&
10605 STRINGP (Vdebug_on_message) &&
10606 fast_string_match (Vdebug_on_message, string) >= 0) {
10607 specbind (Qinhibit_debug_on_message, Qt);
10608 call_debugger (Fcons (Qerror, Fcons (string, Qnil)));
10609 }
10610
10611 unbind_to (count, Qnil);
10601} 10612}
10602 10613
10603 10614
@@ -29299,6 +29310,15 @@ Its value should be an ASCII acronym string, `hex-code', `empty-box', or
29299 Vglyphless_char_display = Fmake_char_table (Qglyphless_char_display, Qnil); 29310 Vglyphless_char_display = Fmake_char_table (Qglyphless_char_display, Qnil);
29300 Fset_char_table_extra_slot (Vglyphless_char_display, make_number (0), 29311 Fset_char_table_extra_slot (Vglyphless_char_display, make_number (0),
29301 Qempty_box); 29312 Qempty_box);
29313
29314 DEFVAR_LISP ("debug-on-message", Vdebug_on_message,
29315 doc: /* If non-nil, debug if a message matching this regexp is displayed. */);
29316 Vdebug_on_message = Qnil;
29317
29318 DEFVAR_LISP ("inhibit-debug-on-message", Vinhibit_debug_on_message,
29319 doc: /* If non-nil, inhibit `debug-on-message' from entering the debugger. */);
29320 Vinhibit_debug_on_message = Qnil;
29321 DEFSYM(Qinhibit_debug_on_message, "inhibit-debug-on-message");
29302} 29322}
29303 29323
29304 29324