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

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

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

revision 1.30 by nickrob, Sun May 18 22:19:17 2003 UTC revision 1.31 by nickrob, Wed May 21 00:49:46 2003 UTC
# Line 41  Line 41 
41  ;; developing the mode itself, then see the Annotations section in the GDB  ;; developing the mode itself, then see the Annotations section in the GDB
42  ;; info manual.  ;; info manual.
43  ;;  ;;
44  ;;  Known Bugs: Does not auto-display arrays of structures or structures  ;;  Known Bugs:
45  ;;  containing arrays.  ;;  Does not auto-display arrays of structures or structures containing arrays.
46    ;;  On MS Windows, GDB from MINGW does not flush the output from the inferior.
47    
48  ;;; Code:  ;;; Code:
49    
# Line 62  Line 63 
63  (defvar gdb-previous-address nil)  (defvar gdb-previous-address nil)
64  (defvar gdb-display-in-progress nil)  (defvar gdb-display-in-progress nil)
65  (defvar gdb-dive nil)  (defvar gdb-dive nil)
66    (defvar gdb-view-source t "Non-nil means that source code can be viewed")
67    (defvar gdb-selected-view 'source "Code type that user wishes to view")
68  (defvar gdb-buffer-type nil)  (defvar gdb-buffer-type nil)
69  (defvar gdb-variables '()  (defvar gdb-variables '()
70    "A list of variables that are local to the GUD buffer.")    "A list of variables that are local to the GUD buffer.")
# Line 158  The following interactive lisp functions Line 161  The following interactive lisp functions
161    (setq gdb-previous-address nil)    (setq gdb-previous-address nil)
162    (setq gdb-display-in-progress nil)    (setq gdb-display-in-progress nil)
163    (setq gdb-dive nil)    (setq gdb-dive nil)
164      (setq gdb-view-source t)
165      (setq gdb-selected-view 'source)
166    ;;    ;;
167    (mapc 'make-local-variable gdb-variables)    (mapc 'make-local-variable gdb-variables)
168    (setq gdb-buffer-type 'gdba)    (setq gdb-buffer-type 'gdba)
169    ;;    ;;
170    (gdb-clear-inferior-io)    (gdb-clear-inferior-io)
171    ;;    ;;
172      (if (eq window-system 'w32)
173          (gdb-enqueue-input (list "set set new-console off\n" 'ignore)))
174    (gdb-enqueue-input (list "set height 0\n" 'ignore))    (gdb-enqueue-input (list "set height 0\n" 'ignore))
175    ;; find source file and compilation directory here    ;; find source file and compilation directory here
176    (gdb-enqueue-input (list "server list\n" 'ignore))    (gdb-enqueue-input (list "server list\n" 'ignore))
# Line 381  The key should be one of the cars in `gd Line 388  The key should be one of the cars in `gd
388    ;; a dummy one.    ;; a dummy one.
389    (make-comint-in-buffer    (make-comint-in-buffer
390     (substring (buffer-name) 1 (- (length (buffer-name)) 1))     (substring (buffer-name) 1 (- (length (buffer-name)) 1))
391     (current-buffer) "cat")     (current-buffer) "hexl")
392    (setq comint-input-sender 'gdb-inferior-io-sender))    (setq comint-input-sender 'gdb-inferior-io-sender))
393    
394  (defun gdb-inferior-io-sender (proc string)  (defun gdb-inferior-io-sender (proc string)
# Line 561  This filter may simply queue output for Line 568  This filter may simply queue output for
568           (match-string 1 args)           (match-string 1 args)
569           (string-to-int (match-string 2 args))))           (string-to-int (match-string 2 args))))
570    (setq gdb-current-address (match-string 3 args))    (setq gdb-current-address (match-string 3 args))
571      (setq gdb-view-source t)
572    ;;update with new frame for machine code if necessary    ;;update with new frame for machine code if necessary
573    (gdb-invalidate-assembler))    (gdb-invalidate-assembler))
574    
# Line 1328  static char *magick[] = { Line 1336  static char *magick[] = {
1336        (with-current-buffer buffer        (with-current-buffer buffer
1337          (if (and (eq gud-minor-mode 'gdba)          (if (and (eq gud-minor-mode 'gdba)
1338                   (not (string-match "^\*" (buffer-name))))                   (not (string-match "^\*" (buffer-name))))
1339              (if (display-graphic-p)              (if (eq window-system 'x)
1340                  (remove-images (point-min) (point-max))                  (remove-images (point-min) (point-max))
1341                (gdb-remove-strings (point-min) (point-max))))))                (gdb-remove-strings (point-min) (point-max))))))
1342      (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)      (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)
# Line 1369  static char *magick[] = { Line 1377  static char *magick[] = {
1377                              (let ((start (progn (beginning-of-line)                              (let ((start (progn (beginning-of-line)
1378                                                  (- (point) 1)))                                                  (- (point) 1)))
1379                                    (end (progn (end-of-line) (+ (point) 1))))                                    (end (progn (end-of-line) (+ (point) 1))))
1380                                (if (display-graphic-p)                                (if (eq window-system 'x)
1381                                    (progn                                    (progn
1382                                      (remove-images start end)                                      (remove-images start end)
1383                                      (if (eq ?y flag)                                      (if (eq ?y flag)
# Line 1382  static char *magick[] = { Line 1390  static char *magick[] = {
1390                                                   'left-margin)))                                                   'left-margin)))
1391                                  (gdb-remove-strings start end)                                  (gdb-remove-strings start end)
1392                                  (if (eq ?y flag)                                  (if (eq ?y flag)
1393                                      (put-string "B" (point))                                      (gdb-put-string "B" (point))
1394                                    (put-string "b" (point))))))))))))                                    (gdb-put-string "b" (point))))))))))))
1395            (end-of-line))))))            (end-of-line))))))
1396    
1397  (defun gdb-breakpoints-buffer-name ()  (defun gdb-breakpoints-buffer-name ()
# Line 1973  the source buffer." Line 1981  the source buffer."
1981    (switch-to-buffer-other-frame    (switch-to-buffer-other-frame
1982     (gdb-get-create-buffer 'gdba)))     (gdb-get-create-buffer 'gdba)))
1983    
1984  (let ((menu (make-sparse-keymap "GDB-Frames")))  (let ((menu (make-sparse-keymap "GDB-Frames"))
1985          (submenu (make-sparse-keymap "View")))
1986    (define-key gud-menu-map [frames]    (define-key gud-menu-map [frames]
1987      `(menu-item "GDB-Frames" ,menu :visible (eq gud-minor-mode 'gdba)))      `(menu-item "GDB-Frames" ,menu :visible (eq gud-minor-mode 'gdba)))
1988    (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer))    (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer))
# Line 1983  the source buffer." Line 1992  the source buffer."
1992    (define-key menu [breakpoints] '("Breakpoints" . gdb-frame-breakpoints-buffer))    (define-key menu [breakpoints] '("Breakpoints" . gdb-frame-breakpoints-buffer))
1993    (define-key menu [display] '("Display" . gdb-frame-display-buffer))    (define-key menu [display] '("Display" . gdb-frame-display-buffer))
1994    (define-key menu [threads] '("Threads" . gdb-frame-threads-buffer))    (define-key menu [threads] '("Threads" . gdb-frame-threads-buffer))
1995    (define-key menu [assembler] '("Assembler" . gdb-frame-assembler-buffer)))    (define-key menu [view] `(menu-item "View" ,submenu))
1996      (define-key submenu [source]
1997        '(menu-item "Source" gdb-view-source
1998                    :help "Display source only"
1999                    :button (:radio . (eq gdb-selected-view 'source))))
2000      (define-key submenu [assembler]
2001        '(menu-item "Assembler" gdb-view-assembler
2002                    :help "Display assembler only"
2003                    :button (:radio . (eq gdb-selected-view 'assembler))))
2004    ;  (define-key submenu [both]
2005    ;    '(menu-item "Both" gdb-view-both
2006    ;               :help "Display both source and assembler"
2007    ;               :button (:radio . (eq gdb-selected-view 'both))))
2008    )
2009    
2010    (defun gdb-view-source()
2011    (interactive)
2012    (if gdb-view-source
2013      (if gud-last-last-frame
2014          (set-window-buffer gdb-source-window
2015                             (gud-find-file (car gud-last-last-frame)))
2016        (set-window-buffer gdb-source-window (gud-find-file gdb-main-file))))
2017    (setq gdb-selected-view 'source))
2018    
2019    (defun gdb-view-assembler()
2020    (interactive)
2021    (set-window-buffer gdb-source-window
2022                       (gdb-get-create-buffer 'gdb-assembler-buffer))
2023    (setq gdb-selected-view 'assembler))
2024    
2025    ;(defun gdb-view-both()
2026    ;(interactive)
2027    ;(setq gdb-selected-view 'both))
2028    
2029  (defvar gdb-main-file nil "Source file from which program execution begins.")  (defvar gdb-main-file nil "Source file from which program execution begins.")
2030    
# Line 2001  the source buffer." Line 2042  the source buffer."
2042    (other-window 1)    (other-window 1)
2043    (switch-to-buffer (gdb-locals-buffer-name))    (switch-to-buffer (gdb-locals-buffer-name))
2044    (other-window 1)    (other-window 1)
2045    (switch-to-buffer    (if gdb-view-source
2046     (if gud-last-last-frame        (switch-to-buffer
2047         (gud-find-file (car gud-last-last-frame))         (if gud-last-last-frame
2048       (gud-find-file gdb-main-file)))             (gud-find-file (car gud-last-last-frame))
2049             (gud-find-file gdb-main-file)))
2050        (switch-to-buffer (gdb-get-create-buffer 'gdb-assembler-buffer)))
2051    (setq gdb-source-window (get-buffer-window (current-buffer)))    (setq gdb-source-window (get-buffer-window (current-buffer)))
2052    (split-window-horizontally)    (split-window-horizontally)
2053    (other-window 1)    (other-window 1)
# Line 2035  This arrangement depends on the value of Line 2078  This arrangement depends on the value of
2078      (delete-other-windows)      (delete-other-windows)
2079      (split-window)      (split-window)
2080      (other-window 1)      (other-window 1)
2081      (switch-to-buffer      (if gdb-view-source
2082       (if gud-last-last-frame          (switch-to-buffer
2083           (gud-find-file (car gud-last-last-frame))           (if gud-last-last-frame
2084         (gud-find-file gdb-main-file)))               (gud-find-file (car gud-last-last-frame))
2085               (gud-find-file gdb-main-file)))
2086          (switch-to-buffer (gdb-get-create-buffer 'gdb-assembler-buffer)))
2087      (other-window 1)))      (other-window 1)))
2088    
2089  (defun gdb-reset ()  (defun gdb-reset ()
# Line 2051  This arrangement depends on the value of Line 2096  This arrangement depends on the value of
2096            (if (eq gud-minor-mode 'gdba)            (if (eq gud-minor-mode 'gdba)
2097                (if (string-match "^\*.+*$" (buffer-name))                (if (string-match "^\*.+*$" (buffer-name))
2098                    (kill-buffer nil)                    (kill-buffer nil)
2099                  (if (display-graphic-p)                  (if (eq window-system 'x)
2100                      (remove-images (point-min) (point-max))                      (remove-images (point-min) (point-max))
2101                    (gdb-remove-strings (point-min) (point-max)))                    (gdb-remove-strings (point-min) (point-max)))
2102                  (setq left-margin-width 0)                  (setq left-margin-width 0)
# Line 2201  BUFFER nil or omitted means use the curr Line 2246  BUFFER nil or omitted means use the curr
2246        (if (not (equal gdb-current-address "main"))        (if (not (equal gdb-current-address "main"))
2247            (progn            (progn
2248              (gdb-remove-arrow)              (gdb-remove-arrow)
2249              (save-selected-window              (goto-char (point-min))
2250                (select-window gdb-source-window)              (if (re-search-forward gdb-current-address nil t)
2251                (goto-char (point-min))                  (gdb-put-arrow "=>" (point)))))
               (if (re-search-forward gdb-current-address nil t)  
                   (gdb-put-arrow "=>" (point))))))  
2252        ;; remove all breakpoint-icons in assembler buffer before updating.        ;; remove all breakpoint-icons in assembler buffer before updating.
2253        (save-excursion        (if (eq window-system 'x)
2254          (if (display-graphic-p)            (remove-images (point-min) (point-max))
2255              (remove-images (point-min) (point-max))          (gdb-remove-strings (point-min) (point-max))))
2256            (gdb-remove-strings (point-min) (point-max))))      (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)
       (set-buffer (gdb-get-buffer 'gdb-breakpoints-buffer))  
2257        (goto-char (point-min))        (goto-char (point-min))
2258        (while (< (point) (- (point-max) 1))        (while (< (point) (- (point-max) 1))
2259          (forward-line 1)          (forward-line 1)
# Line 2220  BUFFER nil or omitted means use the curr Line 2262  BUFFER nil or omitted means use the curr
2262                (looking-at                (looking-at
2263                 "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x\\(\\S-*\\)")                 "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x\\(\\S-*\\)")
2264                (setq flag (char-after (match-beginning 1)))                (setq flag (char-after (match-beginning 1)))
2265                (let ((number (match-string 2)))                (setq address (match-string 2))
2266                  ;; remove leading 0s from output of info break.                ;; remove leading 0s from output of info break.
2267                  (if (string-match "0x0+\\(.*\\)" number)                (if (string-match "0+\\(.*\\)" address)
2268                      (setq address (concat "0x" (match-string 1 address)))                    (setq address (match-string 1 address)))
                   (setq address number)))  
2269                (with-current-buffer buffer                (with-current-buffer buffer
                 (save-excursion  
2270                    (goto-char (point-min))                    (goto-char (point-min))
2271                    (if (re-search-forward address nil t)                    (if (re-search-forward address nil t)
2272                        (let ((start (progn (beginning-of-line) (- (point) 1)))                        (let ((start (progn (beginning-of-line) (- (point) 1)))
2273                              (end (progn (end-of-line) (+ (point) 1))))                              (end (progn (end-of-line) (+ (point) 1))))
2274                          (if (display-graphic-p)                          (if (eq window-system 'x)
2275                              (progn                              (progn
2276                                (remove-images start end)                                (remove-images start end)
2277                                (if (eq ?y flag)                                (if (eq ?y flag)
# Line 2243  BUFFER nil or omitted means use the curr Line 2283  BUFFER nil or omitted means use the curr
2283                                             'left-margin)))                                             'left-margin)))
2284                            (gdb-remove-strings start end)                            (gdb-remove-strings start end)
2285                            (if (eq ?y flag)                            (if (eq ?y flag)
2286                                (put-string "B" (point))                                (gdb-put-string "B" (point))
2287                              (put-string "b" (point))))))))))))))                              (gdb-put-string "b" (point)))))))))))))
2288    
2289  (defvar gdb-assembler-mode-map  (defvar gdb-assembler-mode-map
2290    (let ((map (make-sparse-keymap)))    (let ((map (make-sparse-keymap)))
# Line 2320  BUFFER nil or omitted means use the curr Line 2360  BUFFER nil or omitted means use the curr
2360            (let ((address (match-string 1)))            (let ((address (match-string 1)))
2361              ;; remove leading 0s from output of frame command.              ;; remove leading 0s from output of frame command.
2362              (if (string-match "0x0+\\(.*\\)" address)              (if (string-match "0x0+\\(.*\\)" address)
2363                  (setq gdb-current-address (concat "0x" (match-string 1 address)))                  (setq gdb-current-address
2364                          (concat "0x" (match-string 1 address)))
2365                (setq gdb-current-address address)))                (setq gdb-current-address address)))
2366            (if (not (looking-at ".*) at "))            (if (or (if (not (looking-at ".*) at "))
2367                          (progn (setq gdb-view-source nil) t))
2368                      (eq gdb-selected-view 'assembler))
2369                (progn                (progn
2370                  (set-window-buffer gdb-source-window                  (set-window-buffer
2371                                     (gdb-get-create-buffer 'gdb-assembler-buffer))                   gdb-source-window
2372                     (gdb-get-create-buffer 'gdb-assembler-buffer))
2373                  (gdb-invalidate-assembler))))                  (gdb-invalidate-assembler))))
2374        (if (looking-at "^#[0-9]*\\s-*\\(\\S-*\\)")        (if (looking-at "^#0\\s-*\\(\\S-*\\)")
2375            (setq gdb-current-frame (match-string 1))))))            (setq gdb-current-frame (match-string 1))))))
2376    
2377  (provide 'gdb-ui)  (provide 'gdb-ui)

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31

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