[Top][All Lists]

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

Re: gdbui hang

From: Nick Roberts
Subject: Re: gdbui hang
Date: Tue, 11 May 2004 23:43:05 +0100

 > In general I think the add-hook should not be global but only apply to the
 > *gud* buffer.

kill-buffer-hook *is* a global variable, though. gud-kill-buffer-hook does
only apply to the *gud* buffer though the condition (eq (current-buffer)
gud-comint-buffer). What's there to make local?

 >          But I must say that I don't understand at all what the
 > current gud-kill-buffer-hook is doing:
 >    % grep -nH gud-minor-mode-type  *.el
 >    gud.el:2504:(defvar gud-minor-mode-type nil)
 >    gud.el:2512:       (if (eq gud-minor-mode-type 'gdba)
 >    gud.el:2549:      (setq gud-minor-mode-type gud-minor-mode)))
 > It's a variable used in the process sentinel but only set when
 > a gud-minor-mode buffer is killed.  Sounds pretty odd, yet there's no
 > comment explaniing what going on.  Sounds like a bug (or some left over
 > code).

I wrote that code, a while back. Here's my logic:

gud-sentinel needs to do different things depending on whether gdb is run
with "-fullname" (gud-minor-mode = 'gdb) or "-annotate=3" or
(gud-minor-mode = 'gdba). gud-sentinel is executed after the buffer is killed
and so can't deduce which case it is dealing with. However,
gud-kill-buffer-hook is run before the buffer is killed, so it is used to
store gud-minor-mode in the variable gud-minor-mode-type.

 > > Shall I commit this change?
 > Given that it changes the current behavior in ways I don't understand
 > (because I don't understand the current behavior), I can't tell.
 > But you might want to check that `get-buffer-process' returns non-nil.

How about:

(defun gud-kill-buffer-hook ()
  (when (eq (current-buffer) gud-comint-buffer)
    (setq gud-minor-mode-type gud-minor-mode)
    (condition-case nil
        (kill-process (get-buffer-process gud-comint-buffer))
      (error nil))))


reply via email to

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