diff options
| author | Stefan Monnier | 2002-12-05 17:03:06 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2002-12-05 17:03:06 +0000 |
| commit | 7dcca9f502f7b5a682e9113fae7f599ddf53d214 (patch) | |
| tree | d31baea0a0aae4146401c6f33920cb7c2e68c6ac | |
| parent | 903307483a406bed559119d99c7926093b5e5ba7 (diff) | |
| download | emacs-7dcca9f502f7b5a682e9113fae7f599ddf53d214.tar.gz emacs-7dcca9f502f7b5a682e9113fae7f599ddf53d214.zip | |
(gud-gdb-complete-string, gud-gdb-complete-break)
(gud-gdb-complete-list, gud-gdb-complete-in-progress): Remove.
(gdba): Call `gdb' and then make modifications.
Always call gdb-clear-inferior-io rather than just "the first time".
(gud-break, gud-remove): Definitions moved to inside gdba.
(gdb-target-name): Remove. Use gud-target-name instead.
(gdba-complete-filter, gdba-common-init): Remove.
The changes were integrated into the generic code.
| -rw-r--r-- | lisp/gdb-ui.el | 187 |
1 files changed, 34 insertions, 153 deletions
diff --git a/lisp/gdb-ui.el b/lisp/gdb-ui.el index e16c6521c40..99e33c0ac0c 100644 --- a/lisp/gdb-ui.el +++ b/lisp/gdb-ui.el | |||
| @@ -38,12 +38,6 @@ | |||
| 38 | (defvar gdb-first-time nil) | 38 | (defvar gdb-first-time nil) |
| 39 | (defvar gdb-proc nil "The process associated with gdb.") | 39 | (defvar gdb-proc nil "The process associated with gdb.") |
| 40 | 40 | ||
| 41 | ;; Dynamically-bound vars in gud.el | ||
| 42 | (defvar gud-gdb-complete-string) | ||
| 43 | (defvar gud-gdb-complete-break) | ||
| 44 | (defvar gud-gdb-complete-list) | ||
| 45 | (defvar gud-gdb-complete-in-progress) | ||
| 46 | |||
| 47 | ;;;###autoload | 41 | ;;;###autoload |
| 48 | (defun gdba (command-line) | 42 | (defun gdba (command-line) |
| 49 | "Run gdb on program FILE in buffer *gdb-FILE*. | 43 | "Run gdb on program FILE in buffer *gdb-FILE*. |
| @@ -96,31 +90,28 @@ The following interactive lisp functions help control operation : | |||
| 96 | 90 | ||
| 97 | (interactive (list (gud-query-cmdline 'gdba))) | 91 | (interactive (list (gud-query-cmdline 'gdba))) |
| 98 | 92 | ||
| 99 | (gdba-common-init command-line nil 'gdba-marker-filter) | 93 | ;; Let's start with a basic gud-gdb buffer and then modify it a bit. |
| 94 | (gdb command-line) | ||
| 100 | 95 | ||
| 101 | (set (make-local-variable 'gud-minor-mode) 'gdba) | 96 | (set (make-local-variable 'gud-minor-mode) 'gdba) |
| 97 | (set (make-local-variable 'gud-marker-filter) 'gdba-marker-filter) | ||
| 98 | |||
| 99 | (gud-def gud-break (if (not (string-equal mode-name "Assembler")) | ||
| 100 | (gud-call "break %f:%l" arg) | ||
| 101 | (save-excursion | ||
| 102 | (beginning-of-line) | ||
| 103 | (forward-char 2) | ||
| 104 | (gud-call "break *%a" arg))) | ||
| 105 | "\C-b" "Set breakpoint at current line or address.") | ||
| 106 | |||
| 107 | (gud-def gud-remove (if (not (string-equal mode-name "Assembler")) | ||
| 108 | (gud-call "clear %f:%l" arg) | ||
| 109 | (save-excursion | ||
| 110 | (beginning-of-line) | ||
| 111 | (forward-char 2) | ||
| 112 | (gud-call "clear *%a" arg))) | ||
| 113 | "\C-d" "Remove breakpoint at current line or address.") | ||
| 102 | 114 | ||
| 103 | (gud-def gud-tbreak "tbreak %f:%l" "\C-t" "Set breakpoint at current line.") | ||
| 104 | (gud-def gud-run "run" nil "Run the program.") | ||
| 105 | (gud-def gud-stepi "stepi %p" "\C-i" "Step one instruction with display.") | ||
| 106 | (gud-def gud-step "step %p" "\C-s" "Step one source line with display.") | ||
| 107 | (gud-def gud-next "next %p" "\C-n" "Step one line (skip functions).") | ||
| 108 | (gud-def gud-finish "finish" "\C-f" "Finish executing current function.") | ||
| 109 | (gud-def gud-cont "cont" "\C-r" "Continue with display.") | ||
| 110 | (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).") | ||
| 111 | (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).") | ||
| 112 | (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.") | ||
| 113 | (gud-def gud-goto "until %f:%l" "\C-u" "Continue up to current line.") | ||
| 114 | |||
| 115 | (define-key gud-mode-map "\C-c\C-b" 'gud-break) | ||
| 116 | (define-key global-map "\C-x\C-a\C-b" 'gud-break) | ||
| 117 | |||
| 118 | (define-key gud-mode-map "\C-c\C-d" 'gud-remove) | ||
| 119 | (define-key global-map "\C-x\C-a\C-d" 'gud-remove) | ||
| 120 | |||
| 121 | (local-set-key "\C-i" 'gud-gdb-complete-command) | ||
| 122 | |||
| 123 | (setq comint-prompt-regexp "^(.*gdb[+]?) *") | ||
| 124 | (setq comint-input-sender 'gdb-send) | 115 | (setq comint-input-sender 'gdb-send) |
| 125 | 116 | ||
| 126 | ;; (re-)initialise | 117 | ;; (re-)initialise |
| @@ -128,38 +119,17 @@ The following interactive lisp functions help control operation : | |||
| 128 | (setq gdb-current-address nil) | 119 | (setq gdb-current-address nil) |
| 129 | (setq gdb-display-in-progress nil) | 120 | (setq gdb-display-in-progress nil) |
| 130 | (setq gdb-dive nil) | 121 | (setq gdb-dive nil) |
| 131 | (setq gud-last-last-frame nil) | ||
| 132 | (setq gud-running nil) | ||
| 133 | 122 | ||
| 134 | (run-hooks 'gdb-mode-hook) | ||
| 135 | (setq gdb-proc (get-buffer-process (current-buffer))) | 123 | (setq gdb-proc (get-buffer-process (current-buffer))) |
| 136 | (gdb-make-instance) | 124 | (gdb-make-instance) |
| 137 | (if gdb-first-time (gdb-clear-inferior-io)) | 125 | (gdb-clear-inferior-io) |
| 138 | 126 | ||
| 139 | ;; find source file and compilation directory here | 127 | ;; find source file and compilation directory here |
| 140 | (gdb-instance-enqueue-idle-input (list "server list\n" 'ignore)) | 128 | (gdb-instance-enqueue-idle-input (list "server list\n" 'ignore)) |
| 141 | (gdb-instance-enqueue-idle-input (list "server info source\n" | 129 | (gdb-instance-enqueue-idle-input (list "server info source\n" |
| 142 | 'gdb-source-info))) | 130 | 'gdb-source-info)) |
| 143 | 131 | ||
| 144 | (defun gud-break (arg) | 132 | (run-hooks 'gdba-mode-hook)) |
| 145 | "Set breakpoint at current line or address." | ||
| 146 | (interactive "p") | ||
| 147 | (if (not (string-equal mode-name "Assembler")) | ||
| 148 | (gud-call "break %f:%l" arg) | ||
| 149 | (save-excursion | ||
| 150 | (beginning-of-line) | ||
| 151 | (forward-char 2) | ||
| 152 | (gud-call "break *%a" arg)))) | ||
| 153 | |||
| 154 | (defun gud-remove (arg) | ||
| 155 | "Remove breakpoint at current line or address." | ||
| 156 | (interactive "p") | ||
| 157 | (if (not (string-equal mode-name "Assembler")) | ||
| 158 | (gud-call "clear %f:%l" arg) | ||
| 159 | (save-excursion | ||
| 160 | (beginning-of-line) | ||
| 161 | (forward-char 2) | ||
| 162 | (gud-call "clear *%a" arg)))) | ||
| 163 | 133 | ||
| 164 | (defun gud-display () | 134 | (defun gud-display () |
| 165 | "Display (possibly dereferenced) C expression at point." | 135 | "Display (possibly dereferenced) C expression at point." |
| @@ -172,100 +142,16 @@ The following interactive lisp functions help control operation : | |||
| 172 | 142 | ||
| 173 | (defun gud-display1 (expr) | 143 | (defun gud-display1 (expr) |
| 174 | (goto-char (point-min)) | 144 | (goto-char (point-min)) |
| 175 | (if (re-search-forward "\*" nil t) | 145 | (if (re-search-forward "\*" nil t) |
| 176 | (gdb-instance-enqueue-idle-input | ||
| 177 | (list (concat "server display* " expr "\n") 'ignore)) | ||
| 178 | (gdb-instance-enqueue-idle-input | 146 | (gdb-instance-enqueue-idle-input |
| 179 | (list (concat "server display " expr "\n") 'ignore)))) | 147 | (list (concat "server display* " expr "\n") 'ignore)) |
| 148 | (gdb-instance-enqueue-idle-input | ||
| 149 | (list (concat "server display " expr "\n") 'ignore)))) | ||
| 180 | 150 | ||
| 181 | 151 | ||
| 182 | ;; The completion process filter is installed temporarily to slurp the | 152 | ;; The completion process filter is installed temporarily to slurp the |
| 183 | ;; output of GDB up to the next prompt and build the completion list. | 153 | ;; output of GDB up to the next prompt and build the completion list. |
| 184 | ;; It must also handle annotations. | 154 | ;; It must also handle annotations. |
| 185 | (defun gdba-complete-filter (string) | ||
| 186 | (gdb-output-burst string) | ||
| 187 | (while (string-match "\n\032\032\\(.*\\)\n" string) | ||
| 188 | (setq string (concat (substring string 0 (match-beginning 0)) | ||
| 189 | (substring string (match-end 0))))) | ||
| 190 | (setq string (concat gud-gdb-complete-string string)) | ||
| 191 | (while (string-match "\n" string) | ||
| 192 | (setq gud-gdb-complete-list | ||
| 193 | (cons (substring string gud-gdb-complete-break (match-beginning 0)) | ||
| 194 | gud-gdb-complete-list)) | ||
| 195 | (setq string (substring string (match-end 0)))) | ||
| 196 | (if (string-match comint-prompt-regexp string) | ||
| 197 | (progn | ||
| 198 | (setq gud-gdb-complete-in-progress nil) | ||
| 199 | string) | ||
| 200 | (progn | ||
| 201 | (setq gud-gdb-complete-string string) | ||
| 202 | ""))) | ||
| 203 | |||
| 204 | (defvar gdb-target-name "--unknown--" | ||
| 205 | "The apparent name of the program being debugged in a gud buffer.") | ||
| 206 | |||
| 207 | (defun gdba-common-init (command-line massage-args marker-filter &optional find-file) | ||
| 208 | |||
| 209 | (let* ((words (split-string command-line)) | ||
| 210 | (program (car words)) | ||
| 211 | |||
| 212 | ;; Extract the file name from WORDS | ||
| 213 | ;; and put t in its place. | ||
| 214 | ;; Later on we will put the modified file name arg back there. | ||
| 215 | (file-word (let ((w (cdr words))) | ||
| 216 | (while (and w (= ?- (aref (car w) 0))) | ||
| 217 | (setq w (cdr w))) | ||
| 218 | (and w | ||
| 219 | (prog1 (car w) | ||
| 220 | (setcar w t))))) | ||
| 221 | (file-subst | ||
| 222 | (and file-word (substitute-in-file-name file-word))) | ||
| 223 | |||
| 224 | (args (cdr words)) | ||
| 225 | |||
| 226 | ;; If a directory was specified, expand the file name. | ||
| 227 | ;; Otherwise, don't expand it, so GDB can use the PATH. | ||
| 228 | ;; A file name without directory is literally valid | ||
| 229 | ;; only if the file exists in ., and in that case, | ||
| 230 | ;; omitting the expansion here has no visible effect. | ||
| 231 | (file (and file-word | ||
| 232 | (if (file-name-directory file-subst) | ||
| 233 | (expand-file-name file-subst) | ||
| 234 | file-subst))) | ||
| 235 | (filepart (and file-word (file-name-nondirectory file))) | ||
| 236 | (buffer-name (concat "*gdb-" filepart "*"))) | ||
| 237 | |||
| 238 | (setq gdb-first-time (not (get-buffer-process buffer-name))) | ||
| 239 | |||
| 240 | (switch-to-buffer buffer-name) | ||
| 241 | ;; Set default-directory to the file's directory. | ||
| 242 | (and file-word | ||
| 243 | gud-chdir-before-run | ||
| 244 | ;; Don't set default-directory if no directory was specified. | ||
| 245 | ;; In that case, either the file is found in the current directory, | ||
| 246 | ;; in which case this setq is a no-op, | ||
| 247 | ;; or it is found by searching PATH, | ||
| 248 | ;; in which case we don't know what directory it was found in. | ||
| 249 | (file-name-directory file) | ||
| 250 | (setq default-directory (file-name-directory file))) | ||
| 251 | (or (bolp) (newline)) | ||
| 252 | (insert "Current directory is " default-directory "\n") | ||
| 253 | ;; Put the substituted and expanded file name back in its place. | ||
| 254 | (let ((w args)) | ||
| 255 | (while (and w (not (eq (car w) t))) | ||
| 256 | (setq w (cdr w))) | ||
| 257 | (if w | ||
| 258 | (setcar w file))) | ||
| 259 | (apply 'make-comint (concat "gdb-" filepart) program nil args) | ||
| 260 | (gud-mode) | ||
| 261 | (setq gdb-target-name filepart)) | ||
| 262 | (make-local-variable 'gud-marker-filter) | ||
| 263 | (setq gud-marker-filter marker-filter) | ||
| 264 | (if find-file (set (make-local-variable 'gud-find-file) find-file)) | ||
| 265 | |||
| 266 | (set-process-filter (get-buffer-process (current-buffer)) 'gud-filter) | ||
| 267 | (set-process-sentinel (get-buffer-process (current-buffer)) 'gud-sentinel) | ||
| 268 | (gud-set-buffer)) | ||
| 269 | 155 | ||
| 270 | 156 | ||
| 271 | ;; ====================================================================== | 157 | ;; ====================================================================== |
| @@ -358,17 +244,15 @@ handlers.") | |||
| 358 | (defun gdb-make-instance () | 244 | (defun gdb-make-instance () |
| 359 | "Create a gdb instance object from a gdb process." | 245 | "Create a gdb instance object from a gdb process." |
| 360 | (with-current-buffer (process-buffer gdb-proc) | 246 | (with-current-buffer (process-buffer gdb-proc) |
| 361 | (progn | 247 | (mapc 'make-local-variable gdb-instance-variables) |
| 362 | (mapc 'make-local-variable gdb-instance-variables) | 248 | (setq gdb-buffer-type 'gdba))) |
| 363 | (setq gdb-buffer-type 'gdba)))) | ||
| 364 | 249 | ||
| 365 | (defun gdb-instance-target-string () | 250 | (defun gdb-instance-target-string () |
| 366 | "The apparent name of the program being debugged by a gdb instance. | 251 | "The apparent name of the program being debugged by a gdb instance. |
| 367 | For sure this the root string used in smashing together the gdb | 252 | For sure this the root string used in smashing together the gdb |
| 368 | buffer's name, even if that doesn't happen to be the name of a | 253 | buffer's name, even if that doesn't happen to be the name of a |
| 369 | program." | 254 | program." |
| 370 | (in-gdb-instance-context | 255 | (in-gdb-instance-context (lambda () gud-target-name))) |
| 371 | (function (lambda () gdb-target-name)))) | ||
| 372 | 256 | ||
| 373 | 257 | ||
| 374 | ;; | 258 | ;; |
| @@ -621,13 +505,12 @@ This filter may simply queue output for a later time." | |||
| 621 | ;; | 505 | ;; |
| 622 | 506 | ||
| 623 | (defcustom gud-gdba-command-name "gdb -annotate=2" | 507 | (defcustom gud-gdba-command-name "gdb -annotate=2" |
| 624 | "Default command to execute an executable under the GDB debugger (gdb-ui.el)." | 508 | "Default command to execute an executable under the GDB-UI debugger." |
| 625 | :type 'string | 509 | :type 'string |
| 626 | :group 'gud) | 510 | :group 'gud) |
| 627 | 511 | ||
| 628 | (defun gdba-marker-filter (string) | 512 | (defun gdba-marker-filter (string) |
| 629 | "A gud marker filter for gdb." | 513 | "A gud marker filter for gdb." |
| 630 | ;; Bogons don't tell us the process except through scoping crud. | ||
| 631 | (gdb-output-burst string)) | 514 | (gdb-output-burst string)) |
| 632 | 515 | ||
| 633 | (defvar gdb-annotation-rules | 516 | (defvar gdb-annotation-rules |
| @@ -1911,10 +1794,8 @@ buffer." | |||
| 1911 | ;;; FIXME: This should only return true for buffers in the current gdb-proc | 1794 | ;;; FIXME: This should only return true for buffers in the current gdb-proc |
| 1912 | (defun gdb-protected-buffer-p (buffer) | 1795 | (defun gdb-protected-buffer-p (buffer) |
| 1913 | "Is BUFFER a buffer which we want to leave displayed?" | 1796 | "Is BUFFER a buffer which we want to leave displayed?" |
| 1914 | (save-excursion | 1797 | (with-current-buffer buffer |
| 1915 | (set-buffer buffer) | 1798 | (or gdb-buffer-type overlay-arrow-position))) |
| 1916 | (or gdb-buffer-type | ||
| 1917 | overlay-arrow-position))) | ||
| 1918 | 1799 | ||
| 1919 | ;;; The way we abuse the dedicated-p flag is pretty gross, but seems | 1800 | ;;; The way we abuse the dedicated-p flag is pretty gross, but seems |
| 1920 | ;;; to do the right thing. Seeing as there is no way for Lisp code to | 1801 | ;;; to do the right thing. Seeing as there is no way for Lisp code to |
| @@ -1967,7 +1848,7 @@ buffer." | |||
| 1967 | (define-key gud-minor-mode-map "\C-c\M-\C-b" 'gdb-display-breakpoints-buffer) | 1848 | (define-key gud-minor-mode-map "\C-c\M-\C-b" 'gdb-display-breakpoints-buffer) |
| 1968 | 1849 | ||
| 1969 | (let ((menu (make-sparse-keymap "GDB-Windows"))) | 1850 | (let ((menu (make-sparse-keymap "GDB-Windows"))) |
| 1970 | (define-key gud-minor-mode-map [menu-bar debug displays] | 1851 | (define-key gud-menu-map [displays] |
| 1971 | `(menu-item "GDB-Windows" ,menu :visible (memq gud-minor-mode '(gdba)))) | 1852 | `(menu-item "GDB-Windows" ,menu :visible (memq gud-minor-mode '(gdba)))) |
| 1972 | (define-key menu [gdb] '("Gdb" . gdb-display-gdb-buffer)) | 1853 | (define-key menu [gdb] '("Gdb" . gdb-display-gdb-buffer)) |
| 1973 | (define-key menu [locals] '("Locals" . gdb-display-locals-buffer)) | 1854 | (define-key menu [locals] '("Locals" . gdb-display-locals-buffer)) |
| @@ -1983,7 +1864,7 @@ buffer." | |||
| 1983 | (gdb-get-create-instance-buffer 'gdba))) | 1864 | (gdb-get-create-instance-buffer 'gdba))) |
| 1984 | 1865 | ||
| 1985 | (let ((menu (make-sparse-keymap "GDB-Frames"))) | 1866 | (let ((menu (make-sparse-keymap "GDB-Frames"))) |
| 1986 | (define-key gud-minor-mode-map [menu-bar debug frames] | 1867 | (define-key gud-menu-map [frames] |
| 1987 | `(menu-item "GDB-Frames" ,menu :visible (memq gud-minor-mode '(gdba)))) | 1868 | `(menu-item "GDB-Frames" ,menu :visible (memq gud-minor-mode '(gdba)))) |
| 1988 | (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer)) | 1869 | (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer)) |
| 1989 | (define-key menu [locals] '("Locals" . gdb-frame-locals-buffer)) | 1870 | (define-key menu [locals] '("Locals" . gdb-frame-locals-buffer)) |