help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: What is Emacs doing when I start gdb-mode?


From: Nick Roberts
Subject: Re: What is Emacs doing when I start gdb-mode?
Date: Fri, 4 Apr 2008 08:33:32 +1200

 >     I'm using Emacs 22 on Linux. After start gdb-mode by `M-x gdb', it shows
 > that emacs is reading something. Then I start `gdb-many-windows'.
 > 
 >     In the "*GUD*" buffer, there is a status of gdb in the mode line:
 > "initializing". What is Emacs doing at this moment?
 > 
 >     The reason I ask this question is it takes a long time (about 4 mins)
 > for Emacs to tell me gdb is "ready" by the status of mode line. Before that,
 > I can not use gdb. I do not know what's going on.
 > 
 >     Does anybody have any idea on it?

I don't think gdb-many-windows should slow things down much and "initializing"
should appear in the mode line without it.

Emacs is finding out which source files were used to create the executable
and checking to see if there are buffers open that already visit these
files (so it can put them in the right mode, display the right toolbar etc).
It is also constructing a list of #define directives for each file for use
with GUD tooltips (when the program is not executing).

There are several factors that might make this slow:

1) An executable that was created from a large number of files.
2) Using stabs debug format.
3) Using an old PC.
4) Maybe using an old version of GDB (pre 6.4).

You can stop Emacs from performing this initialisation to speed things up by
commenting out a couple of lines in the function gdb-init-2 in gdb-ui.el (you
can then do M-x eval-buffer to load this new code but note that you will need
to byte compile it for Emacs to find it in the future):

(defun gdb-init-2 ()
  (if (eq window-system 'w32)
      (gdb-enqueue-input (list "set new-console off\n" 'ignore)))
  (gdb-enqueue-input (list "set height 0\n" 'ignore))
  (gdb-enqueue-input (list "set width 0\n" 'ignore))

  (if (string-equal gdb-version "pre-6.4")
      (progn

; Comment out these lines if GDB version is < 6.4

;       (gdb-enqueue-input (list (concat gdb-server-prefix "info sources\n")
;                                'gdb-set-gud-minor-mode-existing-buffers))

        (setq gdb-locals-font-lock-keywords gdb-locals-font-lock-keywords-1))
    (gdb-enqueue-input
     (list "server interpreter mi -data-list-register-names\n"
         'gdb-get-register-names))
    ; Needs GDB 6.2 onwards.

; Comment out these lines if GDB version is >= 6.4

;    (gdb-enqueue-input
;     (list "server interpreter mi \"-file-list-exec-source-files\"\n"
;          'gdb-set-gud-minor-mode-existing-buffers-1))

    (setq gdb-locals-font-lock-keywords gdb-locals-font-lock-keywords-2))

  ;; Find source file and compilation directory here.
  ;; Works for C, C++, Fortran and Ada but not Java (GDB 6.4)
  (gdb-enqueue-input (list "server list\n" 'ignore))
  (gdb-enqueue-input (list "server info source\n" 'gdb-source-info))

  (run-hooks 'gdb-mode-hook))


It may just be that constructing the list of #define directives is taking a
long time, in which case you could comment out:

        (when gud-tooltip-mode
          (make-local-variable 'gdb-define-alist)
          (gdb-create-define-alist)
          (add-hook 'after-save-hook 'gdb-create-define-alist nil t)))))
 
in gdb-set-gud-minor-mode-existing-buffers or
gdb-set-gud-minor-mode-existing-buffers-1.

You can test this first quite easily by just ensuring that gud-tooltip-mode is
off when you start M-x gdb.

Please report back your findings to this list so that I can incorporate them
into gdb-ui.el for other users.

Thanks in advance.

-- 
Nick                                           http://www.inet.net.nz/~nickrob




reply via email to

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