* Random idea: Debugging `quit'
@ 2011-09-11 4:01 Lars Magne Ingebrigtsen
2011-09-11 7:58 ` Andreas Schwab
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-11 4:01 UTC (permalink / raw
To: emacs-devel
If something hangs, then I'd really like to know where it hangs. So I
always wish that I'd have been running with `debug-on-quit' set. But
doing so is really annoying, since `C-g' is a natural thing to do in
many circumstances.
So wouldn't it be nice if we could say, for instance, `C-u C-g' to get a
debugging `quit'? Or perhaps `C-u 6 6 6 C-g', or whatever deemed
necessary to avoid annoying people...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Random idea: Debugging `quit'
2011-09-11 4:01 Random idea: Debugging `quit' Lars Magne Ingebrigtsen
@ 2011-09-11 7:58 ` Andreas Schwab
2011-09-11 14:38 ` Antoine Levitt
2011-09-11 15:24 ` Lars Magne Ingebrigtsen
2011-09-11 11:25 ` Sean Sieger
2011-09-11 16:51 ` Helmut Eller
2 siblings, 2 replies; 9+ messages in thread
From: Andreas Schwab @ 2011-09-11 7:58 UTC (permalink / raw
To: emacs-devel
Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
> So wouldn't it be nice if we could say, for instance, `C-u C-g' to get a
> debugging `quit'? Or perhaps `C-u 6 6 6 C-g', or whatever deemed
> necessary to avoid annoying people...
That's really hard to do since quit-char is very special. It can only
be a single character and it is handled very low in the keyboard
handler.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Random idea: Debugging `quit'
2011-09-11 7:58 ` Andreas Schwab
@ 2011-09-11 14:38 ` Antoine Levitt
2011-09-11 15:24 ` Lars Magne Ingebrigtsen
1 sibling, 0 replies; 9+ messages in thread
From: Antoine Levitt @ 2011-09-11 14:38 UTC (permalink / raw
To: emacs-devel
11/09/11 09:58, Andreas Schwab
> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
>> So wouldn't it be nice if we could say, for instance, `C-u C-g' to get a
>> debugging `quit'? Or perhaps `C-u 6 6 6 C-g', or whatever deemed
>> necessary to avoid annoying people...
>
> That's really hard to do since quit-char is very special. It can only
> be a single character and it is handled very low in the keyboard
> handler.
>
> Andreas.
Is it feasible to instead add a third value to debug-on-quit that'd only
popup a debug window if emacs isn't waiting on user input? So
"problematic" uses of C-g (break out of an infinite loop, or external
process) would run the debugger, but C-x C-f C-g wouldn't.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Random idea: Debugging `quit'
2011-09-11 7:58 ` Andreas Schwab
2011-09-11 14:38 ` Antoine Levitt
@ 2011-09-11 15:24 ` Lars Magne Ingebrigtsen
2011-09-11 15:42 ` Andreas Schwab
2011-09-11 23:28 ` Stephen J. Turnbull
1 sibling, 2 replies; 9+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-11 15:24 UTC (permalink / raw
To: Andreas Schwab; +Cc: emacs-devel
Andreas Schwab <schwab@linux-m68k.org> writes:
> That's really hard to do since quit-char is very special. It can only
> be a single character and it is handled very low in the keyboard
> handler.
Yes, but could the `C-g' handler then check the prefix, and see whether
anything is in there? I'm assuming that Emacs would know at that point
(since it's already parsed its way to the `C-g' in the input stream),
which may be a totally wrong assumption, of course. :-)
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Random idea: Debugging `quit'
2011-09-11 15:24 ` Lars Magne Ingebrigtsen
@ 2011-09-11 15:42 ` Andreas Schwab
2011-09-11 23:28 ` Stephen J. Turnbull
1 sibling, 0 replies; 9+ messages in thread
From: Andreas Schwab @ 2011-09-11 15:42 UTC (permalink / raw
To: Lars Magne Ingebrigtsen; +Cc: emacs-devel
Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
> Yes, but could the `C-g' handler then check the prefix, and see whether
> anything is in there?
The handling of the quit char is too low level to know about a prefix
(it must also work when not reading keys).
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Random idea: Debugging `quit'
2011-09-11 15:24 ` Lars Magne Ingebrigtsen
2011-09-11 15:42 ` Andreas Schwab
@ 2011-09-11 23:28 ` Stephen J. Turnbull
1 sibling, 0 replies; 9+ messages in thread
From: Stephen J. Turnbull @ 2011-09-11 23:28 UTC (permalink / raw
To: Lars Magne Ingebrigtsen; +Cc: Andreas Schwab, emacs-devel
Lars Magne Ingebrigtsen writes:
> Yes, but could the `C-g' handler then check the prefix, and see whether
> anything is in there? I'm assuming that Emacs would know at that point
> (since it's already parsed its way to the `C-g' in the input stream),
> which may be a totally wrong assumption, of course. :-)
It is a wrong assumption for XEmacs, at least. XEmacs checks the
incoming event for C-g at the time of queueing the event for later
processing by XEmacs. The only "parsing" of events at that level is
into "quit events" and "non-quit events".
I suspect Emacs does the same. In theory one could force parsing of
the queue, somehow disabling "undesirable" actions, but this would be
fragile since commands in the queue could install keymaps etc which
changes the interpretation of the event stream.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Random idea: Debugging `quit'
2011-09-11 4:01 Random idea: Debugging `quit' Lars Magne Ingebrigtsen
2011-09-11 7:58 ` Andreas Schwab
@ 2011-09-11 11:25 ` Sean Sieger
2011-09-11 16:51 ` Helmut Eller
2 siblings, 0 replies; 9+ messages in thread
From: Sean Sieger @ 2011-09-11 11:25 UTC (permalink / raw
To: emacs-devel
`C-u 6 6 6 C-g'
:)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Random idea: Debugging `quit'
2011-09-11 4:01 Random idea: Debugging `quit' Lars Magne Ingebrigtsen
2011-09-11 7:58 ` Andreas Schwab
2011-09-11 11:25 ` Sean Sieger
@ 2011-09-11 16:51 ` Helmut Eller
2011-09-11 21:01 ` Lars Magne Ingebrigtsen
2 siblings, 1 reply; 9+ messages in thread
From: Helmut Eller @ 2011-09-11 16:51 UTC (permalink / raw
To: emacs-devel
* Lars Magne Ingebrigtsen [2011-09-11 04:01] writes:
> If something hangs, then I'd really like to know where it hangs. So I
> always wish that I'd have been running with `debug-on-quit' set. But
> doing so is really annoying, since `C-g' is a natural thing to do in
> many circumstances.
>
> So wouldn't it be nice if we could say, for instance, `C-u C-g' to get a
> debugging `quit'? Or perhaps `C-u 6 6 6 C-g', or whatever deemed
> necessary to avoid annoying people...
Yes, that would be nice.
Not so nice, but kill -SIGUSR2 <emacs-pid> in shell tells Emacs to
enter the debugger.
Another possibility would be to set debug-on-quit permanently to t
and at the same time set the variable debugger to some function
that is smart enough to look at the queued events:
(require 'cl)
(require 'debug) ; load it now to avoid resetting debugger
(setq debug-on-quit t)
(setq debugger 'my-debug)
(defun my-debug (&rest args)
(cond ((equal args '(error (quit)))
(let ((unread-events (loop while (input-pending-p)
collect (read-event nil nil 0.1))))
(cond ((equal (subseq unread-events -4)
'(21 54 54 54)) ; C-u 6 6 6
(debug nil 'my-break))
(t
(discard-input)
(let ((debug-on-quit nil))
(signal 'quit nil))))))
(t
(apply #'debug args))))
Helmut
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Random idea: Debugging `quit'
2011-09-11 16:51 ` Helmut Eller
@ 2011-09-11 21:01 ` Lars Magne Ingebrigtsen
0 siblings, 0 replies; 9+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-11 21:01 UTC (permalink / raw
To: Helmut Eller; +Cc: emacs-devel
Helmut Eller <eller.helmut@gmail.com> writes:
> Not so nice, but kill -SIGUSR2 <emacs-pid> in shell tells Emacs to
> enter the debugger.
I didn't know that. That sounds useful.
> Another possibility would be to set debug-on-quit permanently to t
> and at the same time set the variable debugger to some function
> that is smart enough to look at the queued events:
>
> (require 'cl)
> (require 'debug) ; load it now to avoid resetting debugger
> (setq debug-on-quit t)
> (setq debugger 'my-debug)
> (defun my-debug (&rest args)
> (cond ((equal args '(error (quit)))
> (let ((unread-events (loop while (input-pending-p)
> collect (read-event nil nil 0.1))))
> (cond ((equal (subseq unread-events -4)
> '(21 54 54 54)) ; C-u 6 6 6
> (debug nil 'my-break))
> (t
> (discard-input)
> (let ((debug-on-quit nil))
> (signal 'quit nil))))))
> (t
> (apply #'debug args))))
That works great! Thanks! It's now in my .emacs.
I think Emacs 24.2 should have something along these lines switched on
by default. I think it would make a lot of bug reporting easier, since
it would enable users to get a backtrace on hangs very easily.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-09-11 23:28 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-11 4:01 Random idea: Debugging `quit' Lars Magne Ingebrigtsen
2011-09-11 7:58 ` Andreas Schwab
2011-09-11 14:38 ` Antoine Levitt
2011-09-11 15:24 ` Lars Magne Ingebrigtsen
2011-09-11 15:42 ` Andreas Schwab
2011-09-11 23:28 ` Stephen J. Turnbull
2011-09-11 11:25 ` Sean Sieger
2011-09-11 16:51 ` Helmut Eller
2011-09-11 21:01 ` Lars Magne Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.