aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Roberts2003-05-21 00:49:46 +0000
committerNick Roberts2003-05-21 00:49:46 +0000
commit12174bc39e1819308d206f55a79ed5c7d85b2cd5 (patch)
tree644db4ff0ebe5c3688cc07145e6c3d958eb106f8
parent3d50b198116536fb07358620d7873a4ff157ffc6 (diff)
downloademacs-12174bc39e1819308d206f55a79ed5c7d85b2cd5.tar.gz
emacs-12174bc39e1819308d206f55a79ed5c7d85b2cd5.zip
(gdb-view-source, gdb-selected-view): New variables.
(gdba): Inhibit DOS window in MS Windows. (gdb-inferior-io-mode): Use hexl instead of cat. (gdb-info-breakpoints-custom, gdb-assembler-custom, gdb-reset): Use text in margin for MS Windows as there is no image support. (gdb-restore-windows, gdb-setup-windows): Restore/start with assembler view if appropriate. (gdb-assembler-custom): Assembler code should display at point. Parse address correctly. (gdb-frame-handler): Accommodate selection of display of source or assembler. Add radio buttons to select display of source or assembler.
-rw-r--r--lisp/gdb-ui.el128
1 files changed, 86 insertions, 42 deletions
diff --git a/lisp/gdb-ui.el b/lisp/gdb-ui.el
index 9a7b250582f..55c59e747ee 100644
--- a/lisp/gdb-ui.el
+++ b/lisp/gdb-ui.el
@@ -41,8 +41,9 @@
41;; developing the mode itself, then see the Annotations section in the GDB 41;; developing the mode itself, then see the Annotations section in the GDB
42;; info manual. 42;; info manual.
43;; 43;;
44;; Known Bugs: Does not auto-display arrays of structures or structures 44;; Known Bugs:
45;; containing arrays. 45;; 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.
46 47
47;;; Code: 48;;; Code:
48 49
@@ -62,6 +63,8 @@
62(defvar gdb-previous-address nil) 63(defvar gdb-previous-address nil)
63(defvar gdb-display-in-progress nil) 64(defvar gdb-display-in-progress nil)
64(defvar gdb-dive nil) 65(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")
65(defvar gdb-buffer-type nil) 68(defvar gdb-buffer-type nil)
66(defvar gdb-variables '() 69(defvar gdb-variables '()
67 "A list of variables that are local to the GUD buffer.") 70 "A list of variables that are local to the GUD buffer.")
@@ -158,12 +161,16 @@ The following interactive lisp functions help control operation :
158 (setq gdb-previous-address nil) 161 (setq gdb-previous-address nil)
159 (setq gdb-display-in-progress nil) 162 (setq gdb-display-in-progress nil)
160 (setq gdb-dive nil) 163 (setq gdb-dive nil)
164 (setq gdb-view-source t)
165 (setq gdb-selected-view 'source)
161 ;; 166 ;;
162 (mapc 'make-local-variable gdb-variables) 167 (mapc 'make-local-variable gdb-variables)
163 (setq gdb-buffer-type 'gdba) 168 (setq gdb-buffer-type 'gdba)
164 ;; 169 ;;
165 (gdb-clear-inferior-io) 170 (gdb-clear-inferior-io)
166 ;; 171 ;;
172 (if (eq window-system 'w32)
173 (gdb-enqueue-input (list "set set new-console off\n" 'ignore)))
167 (gdb-enqueue-input (list "set height 0\n" 'ignore)) 174 (gdb-enqueue-input (list "set height 0\n" 'ignore))
168 ;; find source file and compilation directory here 175 ;; find source file and compilation directory here
169 (gdb-enqueue-input (list "server list\n" 'ignore)) 176 (gdb-enqueue-input (list "server list\n" 'ignore))
@@ -381,7 +388,7 @@ The key should be one of the cars in `gdb-buffer-rules-assoc'."
381 ;; a dummy one. 388 ;; a dummy one.
382 (make-comint-in-buffer 389 (make-comint-in-buffer
383 (substring (buffer-name) 1 (- (length (buffer-name)) 1)) 390 (substring (buffer-name) 1 (- (length (buffer-name)) 1))
384 (current-buffer) "cat") 391 (current-buffer) "hexl")
385 (setq comint-input-sender 'gdb-inferior-io-sender)) 392 (setq comint-input-sender 'gdb-inferior-io-sender))
386 393
387(defun gdb-inferior-io-sender (proc string) 394(defun gdb-inferior-io-sender (proc string)
@@ -561,6 +568,7 @@ This filter may simply queue output for a later time."
561 (match-string 1 args) 568 (match-string 1 args)
562 (string-to-int (match-string 2 args)))) 569 (string-to-int (match-string 2 args))))
563 (setq gdb-current-address (match-string 3 args)) 570 (setq gdb-current-address (match-string 3 args))
571 (setq gdb-view-source t)
564 ;;update with new frame for machine code if necessary 572 ;;update with new frame for machine code if necessary
565 (gdb-invalidate-assembler)) 573 (gdb-invalidate-assembler))
566 574
@@ -1328,7 +1336,7 @@ static char *magick[] = {
1328 (with-current-buffer buffer 1336 (with-current-buffer buffer
1329 (if (and (eq gud-minor-mode 'gdba) 1337 (if (and (eq gud-minor-mode 'gdba)
1330 (not (string-match "^\*" (buffer-name)))) 1338 (not (string-match "^\*" (buffer-name))))
1331 (if (display-graphic-p) 1339 (if (eq window-system 'x)
1332 (remove-images (point-min) (point-max)) 1340 (remove-images (point-min) (point-max))
1333 (gdb-remove-strings (point-min) (point-max)))))) 1341 (gdb-remove-strings (point-min) (point-max))))))
1334 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer) 1342 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)
@@ -1369,7 +1377,7 @@ static char *magick[] = {
1369 (let ((start (progn (beginning-of-line) 1377 (let ((start (progn (beginning-of-line)
1370 (- (point) 1))) 1378 (- (point) 1)))
1371 (end (progn (end-of-line) (+ (point) 1)))) 1379 (end (progn (end-of-line) (+ (point) 1))))
1372 (if (display-graphic-p) 1380 (if (eq window-system 'x)
1373 (progn 1381 (progn
1374 (remove-images start end) 1382 (remove-images start end)
1375 (if (eq ?y flag) 1383 (if (eq ?y flag)
@@ -1382,8 +1390,8 @@ static char *magick[] = {
1382 'left-margin))) 1390 'left-margin)))
1383 (gdb-remove-strings start end) 1391 (gdb-remove-strings start end)
1384 (if (eq ?y flag) 1392 (if (eq ?y flag)
1385 (put-string "B" (point)) 1393 (gdb-put-string "B" (point))
1386 (put-string "b" (point)))))))))))) 1394 (gdb-put-string "b" (point))))))))))))
1387 (end-of-line)))))) 1395 (end-of-line))))))
1388 1396
1389(defun gdb-breakpoints-buffer-name () 1397(defun gdb-breakpoints-buffer-name ()
@@ -1973,7 +1981,8 @@ the source buffer."
1973 (switch-to-buffer-other-frame 1981 (switch-to-buffer-other-frame
1974 (gdb-get-create-buffer 'gdba))) 1982 (gdb-get-create-buffer 'gdba)))
1975 1983
1976(let ((menu (make-sparse-keymap "GDB-Frames"))) 1984(let ((menu (make-sparse-keymap "GDB-Frames"))
1985 (submenu (make-sparse-keymap "View")))
1977 (define-key gud-menu-map [frames] 1986 (define-key gud-menu-map [frames]
1978 `(menu-item "GDB-Frames" ,menu :visible (eq gud-minor-mode 'gdba))) 1987 `(menu-item "GDB-Frames" ,menu :visible (eq gud-minor-mode 'gdba)))
1979 (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer)) 1988 (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer))
@@ -1983,7 +1992,39 @@ the source buffer."
1983 (define-key menu [breakpoints] '("Breakpoints" . gdb-frame-breakpoints-buffer)) 1992 (define-key menu [breakpoints] '("Breakpoints" . gdb-frame-breakpoints-buffer))
1984 (define-key menu [display] '("Display" . gdb-frame-display-buffer)) 1993 (define-key menu [display] '("Display" . gdb-frame-display-buffer))
1985 (define-key menu [threads] '("Threads" . gdb-frame-threads-buffer)) 1994 (define-key menu [threads] '("Threads" . gdb-frame-threads-buffer))
1986 (define-key menu [assembler] '("Assembler" . gdb-frame-assembler-buffer))) 1995 (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))
1987 2028
1988(defvar gdb-main-file nil "Source file from which program execution begins.") 2029(defvar gdb-main-file nil "Source file from which program execution begins.")
1989 2030
@@ -2001,10 +2042,12 @@ the source buffer."
2001 (other-window 1) 2042 (other-window 1)
2002 (switch-to-buffer (gdb-locals-buffer-name)) 2043 (switch-to-buffer (gdb-locals-buffer-name))
2003 (other-window 1) 2044 (other-window 1)
2004 (switch-to-buffer 2045 (if gdb-view-source
2005 (if gud-last-last-frame 2046 (switch-to-buffer
2006 (gud-find-file (car gud-last-last-frame)) 2047 (if gud-last-last-frame
2007 (gud-find-file gdb-main-file))) 2048 (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)))
2008 (setq gdb-source-window (get-buffer-window (current-buffer))) 2051 (setq gdb-source-window (get-buffer-window (current-buffer)))
2009 (split-window-horizontally) 2052 (split-window-horizontally)
2010 (other-window 1) 2053 (other-window 1)
@@ -2035,10 +2078,12 @@ This arrangement depends on the value of `gdb-many-windows'."
2035 (delete-other-windows) 2078 (delete-other-windows)
2036 (split-window) 2079 (split-window)
2037 (other-window 1) 2080 (other-window 1)
2038 (switch-to-buffer 2081 (if gdb-view-source
2039 (if gud-last-last-frame 2082 (switch-to-buffer
2040 (gud-find-file (car gud-last-last-frame)) 2083 (if gud-last-last-frame
2041 (gud-find-file gdb-main-file))) 2084 (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)))
2042 (other-window 1))) 2087 (other-window 1)))
2043 2088
2044(defun gdb-reset () 2089(defun gdb-reset ()
@@ -2051,7 +2096,7 @@ This arrangement depends on the value of `gdb-many-windows'."
2051 (if (eq gud-minor-mode 'gdba) 2096 (if (eq gud-minor-mode 'gdba)
2052 (if (string-match "^\*.+*$" (buffer-name)) 2097 (if (string-match "^\*.+*$" (buffer-name))
2053 (kill-buffer nil) 2098 (kill-buffer nil)
2054 (if (display-graphic-p) 2099 (if (eq window-system 'x)
2055 (remove-images (point-min) (point-max)) 2100 (remove-images (point-min) (point-max))
2056 (gdb-remove-strings (point-min) (point-max))) 2101 (gdb-remove-strings (point-min) (point-max)))
2057 (setq left-margin-width 0) 2102 (setq left-margin-width 0)
@@ -2201,17 +2246,14 @@ BUFFER nil or omitted means use the current buffer."
2201 (if (not (equal gdb-current-address "main")) 2246 (if (not (equal gdb-current-address "main"))
2202 (progn 2247 (progn
2203 (gdb-remove-arrow) 2248 (gdb-remove-arrow)
2204 (save-selected-window 2249 (goto-char (point-min))
2205 (select-window gdb-source-window) 2250 (if (re-search-forward gdb-current-address nil t)
2206 (goto-char (point-min)) 2251 (gdb-put-arrow "=>" (point)))))
2207 (if (re-search-forward gdb-current-address nil t)
2208 (gdb-put-arrow "=>" (point))))))
2209 ;; remove all breakpoint-icons in assembler buffer before updating. 2252 ;; remove all breakpoint-icons in assembler buffer before updating.
2210 (save-excursion 2253 (if (eq window-system 'x)
2211 (if (display-graphic-p) 2254 (remove-images (point-min) (point-max))
2212 (remove-images (point-min) (point-max)) 2255 (gdb-remove-strings (point-min) (point-max))))
2213 (gdb-remove-strings (point-min) (point-max)))) 2256 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)
2214 (set-buffer (gdb-get-buffer 'gdb-breakpoints-buffer))
2215 (goto-char (point-min)) 2257 (goto-char (point-min))
2216 (while (< (point) (- (point-max) 1)) 2258 (while (< (point) (- (point-max) 1))
2217 (forward-line 1) 2259 (forward-line 1)
@@ -2220,18 +2262,16 @@ BUFFER nil or omitted means use the current buffer."
2220 (looking-at 2262 (looking-at
2221 "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x\\(\\S-*\\)") 2263 "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x\\(\\S-*\\)")
2222 (setq flag (char-after (match-beginning 1))) 2264 (setq flag (char-after (match-beginning 1)))
2223 (let ((number (match-string 2))) 2265 (setq address (match-string 2))
2224 ;; remove leading 0s from output of info break. 2266 ;; remove leading 0s from output of info break.
2225 (if (string-match "0x0+\\(.*\\)" number) 2267 (if (string-match "0+\\(.*\\)" address)
2226 (setq address (concat "0x" (match-string 1 address))) 2268 (setq address (match-string 1 address)))
2227 (setq address number)))
2228 (with-current-buffer buffer 2269 (with-current-buffer buffer
2229 (save-excursion
2230 (goto-char (point-min)) 2270 (goto-char (point-min))
2231 (if (re-search-forward address nil t) 2271 (if (re-search-forward address nil t)
2232 (let ((start (progn (beginning-of-line) (- (point) 1))) 2272 (let ((start (progn (beginning-of-line) (- (point) 1)))
2233 (end (progn (end-of-line) (+ (point) 1)))) 2273 (end (progn (end-of-line) (+ (point) 1))))
2234 (if (display-graphic-p) 2274 (if (eq window-system 'x)
2235 (progn 2275 (progn
2236 (remove-images start end) 2276 (remove-images start end)
2237 (if (eq ?y flag) 2277 (if (eq ?y flag)
@@ -2243,8 +2283,8 @@ BUFFER nil or omitted means use the current buffer."
2243 'left-margin))) 2283 'left-margin)))
2244 (gdb-remove-strings start end) 2284 (gdb-remove-strings start end)
2245 (if (eq ?y flag) 2285 (if (eq ?y flag)
2246 (put-string "B" (point)) 2286 (gdb-put-string "B" (point))
2247 (put-string "b" (point)))))))))))))) 2287 (gdb-put-string "b" (point)))))))))))))
2248 2288
2249(defvar gdb-assembler-mode-map 2289(defvar gdb-assembler-mode-map
2250 (let ((map (make-sparse-keymap))) 2290 (let ((map (make-sparse-keymap)))
@@ -2320,14 +2360,18 @@ BUFFER nil or omitted means use the current buffer."
2320 (let ((address (match-string 1))) 2360 (let ((address (match-string 1)))
2321 ;; remove leading 0s from output of frame command. 2361 ;; remove leading 0s from output of frame command.
2322 (if (string-match "0x0+\\(.*\\)" address) 2362 (if (string-match "0x0+\\(.*\\)" address)
2323 (setq gdb-current-address (concat "0x" (match-string 1 address))) 2363 (setq gdb-current-address
2364 (concat "0x" (match-string 1 address)))
2324 (setq gdb-current-address address))) 2365 (setq gdb-current-address address)))
2325 (if (not (looking-at ".*) at ")) 2366 (if (or (if (not (looking-at ".*) at "))
2367 (progn (setq gdb-view-source nil) t))
2368 (eq gdb-selected-view 'assembler))
2326 (progn 2369 (progn
2327 (set-window-buffer gdb-source-window 2370 (set-window-buffer
2328 (gdb-get-create-buffer 'gdb-assembler-buffer)) 2371 gdb-source-window
2372 (gdb-get-create-buffer 'gdb-assembler-buffer))
2329 (gdb-invalidate-assembler)))) 2373 (gdb-invalidate-assembler))))
2330 (if (looking-at "^#[0-9]*\\s-*\\(\\S-*\\)") 2374 (if (looking-at "^#0\\s-*\\(\\S-*\\)")
2331 (setq gdb-current-frame (match-string 1)))))) 2375 (setq gdb-current-frame (match-string 1))))))
2332 2376
2333(provide 'gdb-ui) 2377(provide 'gdb-ui)