/[emacs]/emacs/lisp/progmodes/gdb-ui.el
ViewVC logotype

Diff of /emacs/lisp/progmodes/gdb-ui.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.47 by nickrob, Wed Feb 9 19:42:09 2005 UTC revision 1.48 by nickrob, Tue Feb 15 09:19:13 2005 UTC
# Line 79  Line 79 
79  (defvar gdb-overlay-arrow-position nil)  (defvar gdb-overlay-arrow-position nil)
80  (defvar gdb-server-prefix nil)  (defvar gdb-server-prefix nil)
81  (defvar gdb-flush-pending-output nil)  (defvar gdb-flush-pending-output nil)
82    (defvar gdb-location-list nil "List of directories for source files.")
83    (defvar gdb-find-file-unhook nil)
84    
85  (defvar gdb-buffer-type nil  (defvar gdb-buffer-type nil
86    "One of the symbols bound in `gdb-buffer-rules'.")    "One of the symbols bound in `gdb-buffer-rules'.")
# Line 191  detailed description of this mode. Line 193  detailed description of this mode.
193    :group 'gud    :group 'gud
194    :version "22.1")    :version "22.1")
195    
196    (defun gdb-set-gud-minor-mode (buffer)
197      "Set gud-minor-mode from find-file if appropriate."
198      (goto-char (point-min))
199      (unless (search-forward "No source file named " nil t)
200        (condition-case nil
201            (gdb-enqueue-input
202             (list (concat gdb-server-prefix "info source\n")
203                   `(lambda () (gdb-set-gud-minor-mode-1 ,buffer))))
204          (error (setq gdb-find-file-unhook t)))))
205    
206    (defun gdb-set-gud-minor-mode-1 (buffer)
207      (goto-char (point-min))
208      (if (and (search-forward "Located in " nil t)
209               (looking-at "\\S-*")
210               (string-equal (buffer-file-name buffer)
211                             (match-string 0)))
212          (with-current-buffer buffer
213            (set (make-local-variable 'gud-minor-mode) 'gdba)
214            (set (make-local-variable 'tool-bar-map) gud-tool-bar-map))))
215    
216    (defun gdb-set-gud-minor-mode-existing-buffers ()
217      (dolist (buffer (buffer-list))
218        (let ((file (buffer-file-name buffer)))
219          (if file
220            (progn
221              (gdb-enqueue-input
222               (list (concat "list " (file-name-nondirectory file) ":1\n")
223                     `(lambda () (gdb-set-gud-minor-mode ,buffer)))))))))
224    
225  (defun gdb-ann3 ()  (defun gdb-ann3 ()
226    (setq gdb-debug-log nil)    (setq gdb-debug-log nil)
227    (set (make-local-variable 'gud-minor-mode) 'gdba)    (set (make-local-variable 'gud-minor-mode) 'gdba)
# Line 249  detailed description of this mode. Line 280  detailed description of this mode.
280    (setq gdb-server-prefix "server ")    (setq gdb-server-prefix "server ")
281    (setq gdb-flush-pending-output nil)    (setq gdb-flush-pending-output nil)
282    (setq gdb-location-list nil)    (setq gdb-location-list nil)
283      (setq gdb-find-file-unhook nil)
284    ;;    ;;
285    (setq gdb-buffer-type 'gdba)    (setq gdb-buffer-type 'gdba)
286    ;;    ;;
# Line 263  detailed description of this mode. Line 295  detailed description of this mode.
295    (gdb-enqueue-input (list "server list MAIN__\n" 'ignore))   ; Fortran program    (gdb-enqueue-input (list "server list MAIN__\n" 'ignore))   ; Fortran program
296    (gdb-enqueue-input (list "server info source\n" 'gdb-source-info))    (gdb-enqueue-input (list "server info source\n" 'gdb-source-info))
297    ;;    ;;
298      (gdb-set-gud-minor-mode-existing-buffers)
299    (run-hooks 'gdba-mode-hook))    (run-hooks 'gdba-mode-hook))
300    
301  (defcustom gdb-use-colon-colon-notation nil  (defcustom gdb-use-colon-colon-notation nil
# Line 1048  happens to be appropriate." Line 1081  happens to be appropriate."
1081    ;; buffer specific functions    ;; buffer specific functions
1082    gdb-info-breakpoints-custom)    gdb-info-breakpoints-custom)
1083    
 (defvar gdb-location-list nil "List of directories for source files.")  
   
1084  (defconst breakpoint-xpm-data  (defconst breakpoint-xpm-data
1085    "/* XPM */    "/* XPM */
1086  static char *magick[] = {  static char *magick[] = {
# Line 1159  static char *magick[] = { Line 1190  static char *magick[] = {
1190                             (setq file (cdr (assoc bptno gdb-location-list))))                             (setq file (cdr (assoc bptno gdb-location-list))))
1191                          (unless (string-equal file "File not found")                          (unless (string-equal file "File not found")
1192                            (if file                            (if file
1193                                (with-current-buffer                                (with-current-buffer (find-file-noselect file)
1194                                    (find-file-noselect file)                                  (set (make-local-variable 'gud-minor-mode)
                                 (save-current-buffer  
                                   (set (make-local-variable 'gud-minor-mode)  
1195                                       'gdba)                                       'gdba)
1196                                    (set (make-local-variable 'tool-bar-map)                                  (set (make-local-variable 'tool-bar-map)
1197                                         gud-tool-bar-map))                                       gud-tool-bar-map)
1198                                  ;; only want one breakpoint icon at each location                                  ;; only want one breakpoint icon at each location
1199                                  (save-excursion                                  (save-excursion
1200                                    (goto-line (string-to-number line))                                    (goto-line (string-to-number line))
# Line 2054  Kills the gdb buffers and resets the sou Line 2083  Kills the gdb buffers and resets the sou
2083    "Find the source file where the program starts and displays it with related    "Find the source file where the program starts and displays it with related
2084  buffers."  buffers."
2085    (goto-char (point-min))    (goto-char (point-min))
2086    (if (search-forward "Located in " nil t)    (if (and (search-forward "Located in " nil t)
2087        (if (looking-at "\\S-*")             (looking-at "\\S-*"))
2088            (setq gdb-main-file (match-string 0))))        (setq gdb-main-file (match-string 0)))
2089   (if gdb-many-windows   (if gdb-many-windows
2090        (gdb-setup-windows)        (gdb-setup-windows)
2091     (gdb-get-create-buffer 'gdb-breakpoints-buffer)     (gdb-get-create-buffer 'gdb-breakpoints-buffer)
2092      (if gdb-show-main     (if gdb-show-main
2093        (let ((pop-up-windows t))         (let ((pop-up-windows t))
2094          (display-buffer (gud-find-file gdb-main-file))))))           (display-buffer (gud-find-file gdb-main-file))))))
2095    
2096  (defun gdb-get-location (bptno line flag)  (defun gdb-get-location (bptno line flag)
2097    "Find the directory containing the relevant source file.    "Find the directory containing the relevant source file.
# Line 2085  Add directory to search path for source Line 2114  Add directory to search path for source
2114        (goto-line (string-to-number line))        (goto-line (string-to-number line))
2115        (gdb-put-breakpoint-icon (eq flag ?y) bptno))))        (gdb-put-breakpoint-icon (eq flag ?y) bptno))))
2116    
2117    (add-hook 'find-file-hook 'gdb-find-file-hook)
2118    
2119    (defun gdb-find-file-hook ()
2120      (if (and (not gdb-find-file-unhook)
2121               ;; in case gud or gdb-ui is just loaded
2122               gud-comint-buffer
2123               (buffer-name gud-comint-buffer)
2124               (with-current-buffer gud-comint-buffer
2125                 (eq gud-minor-mode 'gdba)))
2126          (condition-case nil
2127            (gdb-enqueue-input
2128             (list (concat "list " (file-name-nondirectory buffer-file-name)
2129                           ":1\n")
2130                   `(lambda () (gdb-set-gud-minor-mode ,(current-buffer)))))
2131            (error (setq gdb-find-file-unhook t)))))
2132    
2133  ;;from put-image  ;;from put-image
2134  (defun gdb-put-string (putstring pos &optional dprop)  (defun gdb-put-string (putstring pos &optional dprop)
2135    "Put string PUTSTRING in front of POS in the current buffer.    "Put string PUTSTRING in front of POS in the current buffer.

Legend:
Removed from v.1.47  
changed lines
  Added in v.1.48

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26