diff options
| author | Stefan Monnier | 2000-11-12 18:48:22 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-11-12 18:48:22 +0000 |
| commit | c157af51b5592ea64950b3cff73e32aa073a03cf (patch) | |
| tree | 4d1ff1b05ca6f281732534d3df066dd39dec2665 | |
| parent | 165958d2b4194b75afd0d57b8095cdc036e7ee7b (diff) | |
| download | emacs-c157af51b5592ea64950b3cff73e32aa073a03cf.tar.gz emacs-c157af51b5592ea64950b3cff73e32aa073a03cf.zip | |
(gud-minor-mode): New var.
(gud-symbol, gud-val): New functions.
(gud-find-file): Copy gud-minor-mode to the new buffer.
(gud-menu-map): Include entries for commands that are not always
available, using :enable to (de)activate them.
(gud-minor-mode-map): New map. Add it to minor-mode-map-alist.
(gud-mode-map): New map.
(gud-gdb-find-file, gud-sdb-find-file, gud-dbx-find-file)
(gud-xdb-find-file, gud-perldb-find-file, gud-pdb-find-file):
Don't set up gud's menu (it's done by the minor-mode).
(gud-minibuffer-local-map): New.
Replace gdb-minibuffer-local-map and pdb-minibuffer-local-map.
(gud-query-cmdline): New function.
(gdb, sdb, dbx, xdb, perldb, pdb, jdb): Use it. Set gud-minor-mode.
(gud-mode): Use define-derived-mode.
Don't set up gud's menu (it's done by the minor-mode).
(gud-chop-words): Remove.
(gud-common-init): Use split-string instead.
(gud-new-keymap, gud-make-debug-menu): Eradicate.
| -rw-r--r-- | lisp/gud.el | 297 |
1 files changed, 107 insertions, 190 deletions
diff --git a/lisp/gud.el b/lisp/gud.el index 13a8a101118..9e9650931df 100644 --- a/lisp/gud.el +++ b/lisp/gud.el | |||
| @@ -68,28 +68,67 @@ Supported debuggers include gdb, sdb, dbx, xdb, perldb, pdb (Python), and jdb." | |||
| 68 | (defun gud-marker-filter (&rest args) | 68 | (defun gud-marker-filter (&rest args) |
| 69 | (apply gud-marker-filter args)) | 69 | (apply gud-marker-filter args)) |
| 70 | 70 | ||
| 71 | (defvar gud-minor-mode nil) | ||
| 72 | (put 'gud-minor-mode 'permanent-local t) | ||
| 73 | |||
| 74 | (defun gud-symbol (sym &optional soft minor-mode) | ||
| 75 | "Return the symbol used for SYM in MINOR-MODE. | ||
| 76 | MINOR-MODE defaults to `gud-minor-mode. | ||
| 77 | The symbol returned is `gud-<MINOR-MODE>-<SYM>'. | ||
| 78 | If SOFT is non-nil, returns nil if the symbol doesn't already exist." | ||
| 79 | (unless (or minor-mode gud-minor-mode) (error "Gud internal error")) | ||
| 80 | (funcall (if soft 'intern-soft 'intern) | ||
| 81 | (format "gud-%s-%s" (or minor-mode gud-minor-mode) sym))) | ||
| 82 | |||
| 83 | (defun gud-val (sym &optional minor-mode) | ||
| 84 | "Return the value of `gud-symbol' SYM. Default to nil." | ||
| 85 | (let ((sym (gud-symbol sym t minor-mode))) | ||
| 86 | (if (boundp sym) (symbol-value sym)))) | ||
| 87 | |||
| 71 | (defun gud-find-file (file) | 88 | (defun gud-find-file (file) |
| 72 | ;; Don't get confused by double slashes in the name that comes from GDB. | 89 | ;; Don't get confused by double slashes in the name that comes from GDB. |
| 73 | (while (string-match "//+" file) | 90 | (while (string-match "//+" file) |
| 74 | (setq file (replace-match "/" t t file))) | 91 | (setq file (replace-match "/" t t file))) |
| 75 | (funcall gud-find-file file)) | 92 | (let ((minor-mode gud-minor-mode) |
| 76 | 93 | (buf (funcall gud-find-file file))) | |
| 77 | ;; Keymap definitions for menu bar entries common to all debuggers and | 94 | (when buf |
| 78 | ;; slots for debugger-dependent ones in sensible places. (Defined here | 95 | ;; Copy `gud-minor-mode' to the found buffer to turn on the menu. |
| 79 | ;; before use.) | 96 | (with-current-buffer buf |
| 80 | (defvar gud-menu-map (make-sparse-keymap "Gud") nil) | 97 | (set (make-local-variable 'gud-minor-mode) minor-mode)) |
| 81 | (define-key gud-menu-map [refresh] '("Refresh" . gud-refresh)) | 98 | buf))) |
| 82 | (define-key gud-menu-map [remove] '("Remove Breakpoint" . gud-remove)) | 99 | |
| 83 | (define-key gud-menu-map [tbreak] nil) ; gdb, sdb and xdb | 100 | (easy-mmode-defmap gud-menu-map |
| 84 | (define-key gud-menu-map [break] '("Set Breakpoint" . gud-break)) | 101 | '(([refresh] "Refresh" . gud-refresh) |
| 85 | (define-key gud-menu-map [up] nil) ; gdb, dbx, and xdb | 102 | ([remove] "Remove Breakpoint" . gud-remove) |
| 86 | (define-key gud-menu-map [down] nil) ; gdb, dbx, and xdb | 103 | ([tbreak] menu-item "Temporary Breakpoint" gud-tbreak |
| 87 | (define-key gud-menu-map [print] '("Print Expression" . gud-print)) | 104 | :enable (memq gud-minor-mode '(gdb sdb xdb))) |
| 88 | (define-key gud-menu-map [finish] nil) ; gdb or xdb | 105 | ([break] "Set Breakpoint" . gud-break) |
| 89 | (define-key gud-menu-map [stepi] '("Step Instruction" . gud-stepi)) | 106 | ([up] menu-item "Up Stack" gud-up |
| 90 | (define-key gud-menu-map [step] '("Step Line" . gud-step)) | 107 | :enable (memq gud-minor-mode '(gdb dbx xdb))) |
| 91 | (define-key gud-menu-map [next] '("Next Line" . gud-next)) | 108 | ([down] menu-item "Down Stack" gud-down |
| 92 | (define-key gud-menu-map [cont] '("Continue" . gud-cont)) | 109 | :enable (memq gud-minor-mode '(gdb dbx xdb))) |
| 110 | ([print] "Print Expression" . gud-print) | ||
| 111 | ([finish] menu-item "Finish Function" gud-finish | ||
| 112 | :enable (memq gud-minor-mode '(gdb xdb))) | ||
| 113 | ([stepi] "Step Instruction" . gud-stepi) | ||
| 114 | ([step] "Step Line" . gud-step) | ||
| 115 | ([next] "Next Line" . gud-next) | ||
| 116 | ([cont] "Continue" . gud-cont)) | ||
| 117 | "Menu for `gud-mode'." | ||
| 118 | :name "Gud") | ||
| 119 | |||
| 120 | (easy-mmode-defmap gud-minor-mode-map | ||
| 121 | `(([menu-bar debug] . ("Gud" . ,gud-menu-map))) | ||
| 122 | "Map used in visited files.") | ||
| 123 | |||
| 124 | (let ((m (assq 'gud-minor-mode minor-mode-map-alist))) | ||
| 125 | (if m (setcdr m gud-minor-mode-map) | ||
| 126 | (push (cons 'gud-minor-mode gud-minor-mode-map) minor-mode-map-alist))) | ||
| 127 | |||
| 128 | (defvar gud-mode-map | ||
| 129 | ;; Will inherit from comint-mode via define-derived-mode. | ||
| 130 | (make-sparse-keymap) | ||
| 131 | "`gud-mode' keymap.") | ||
| 93 | 132 | ||
| 94 | ;; ====================================================================== | 133 | ;; ====================================================================== |
| 95 | ;; command definition | 134 | ;; command definition |
| @@ -171,7 +210,7 @@ we're in the GUD buffer)." | |||
| 171 | ;; | 210 | ;; |
| 172 | ;; The job of the find-file method is to visit and return the buffer indicated | 211 | ;; The job of the find-file method is to visit and return the buffer indicated |
| 173 | ;; by the car of gud-tag-frame. This may be a file name, a tag name, or | 212 | ;; by the car of gud-tag-frame. This may be a file name, a tag name, or |
| 174 | ;; something else. It would be good if it also copied the Gud menubar entry. | 213 | ;; something else. |
| 175 | 214 | ||
| 176 | ;; ====================================================================== | 215 | ;; ====================================================================== |
| 177 | ;; speedbar support functions and variables. | 216 | ;; speedbar support functions and variables. |
| @@ -330,40 +369,34 @@ off the specialized speedbar mode." | |||
| 330 | output)) | 369 | output)) |
| 331 | 370 | ||
| 332 | (defun gud-gdb-find-file (f) | 371 | (defun gud-gdb-find-file (f) |
| 333 | (save-excursion | 372 | (find-file-noselect f 'nowarn)) |
| 334 | (let ((buf (find-file-noselect f 'nowarn))) | 373 | |
| 335 | (set-buffer buf) | 374 | (easy-mmode-defmap gud-minibuffer-local-map |
| 336 | (gud-make-debug-menu) | 375 | '(("\C-i" . comint-dynamic-complete-filename)) |
| 337 | (local-set-key [menu-bar debug tbreak] | 376 | "Keymap for minibuffer prompting of gud startup command." |
| 338 | '("Temporary Breakpoint" . gud-tbreak)) | 377 | :inherit minibuffer-local-map) |
| 339 | (local-set-key [menu-bar debug finish] '("Finish Function" . gud-finish)) | 378 | |
| 340 | (local-set-key [menu-bar debug up] '("Up Stack" . gud-up)) | 379 | (defun gud-query-cmdline (minor-mode &optional init) |
| 341 | (local-set-key [menu-bar debug down] '("Down Stack" . gud-down)) | 380 | (let* ((hist-sym (gud-symbol 'history nil minor-mode)) |
| 342 | buf))) | 381 | (cmd-name (gud-val 'command-name minor-mode))) |
| 343 | 382 | (unless (boundp hist-sym) (set hist-sym nil)) | |
| 344 | (defvar gdb-minibuffer-local-map nil | 383 | (read-from-minibuffer |
| 345 | "Keymap for minibuffer prompting of gdb startup command.") | 384 | (format "Run %s (like this): " minor-mode) |
| 346 | (if gdb-minibuffer-local-map | 385 | (or (car-safe (symbol-value hist-sym)) |
| 347 | () | 386 | (concat (or cmd-name (symbol-name minor-mode)) " " init)) |
| 348 | (setq gdb-minibuffer-local-map (copy-keymap minibuffer-local-map)) | 387 | gud-minibuffer-local-map nil |
| 349 | (define-key | 388 | hist-sym))) |
| 350 | gdb-minibuffer-local-map "\C-i" 'comint-dynamic-complete-filename)) | ||
| 351 | 389 | ||
| 352 | ;;;###autoload | 390 | ;;;###autoload |
| 353 | (defun gdb (command-line) | 391 | (defun gdb (command-line) |
| 354 | "Run gdb on program FILE in buffer *gud-FILE*. | 392 | "Run gdb on program FILE in buffer *gud-FILE*. |
| 355 | The directory containing FILE becomes the initial working directory | 393 | The directory containing FILE becomes the initial working directory |
| 356 | and source-file directory for your debugger." | 394 | and source-file directory for your debugger." |
| 357 | (interactive | 395 | (interactive (list (gud-query-cmdline 'gdb))) |
| 358 | (list (read-from-minibuffer "Run gdb (like this): " | ||
| 359 | (if (consp gud-gdb-history) | ||
| 360 | (car gud-gdb-history) | ||
| 361 | "gdb ") | ||
| 362 | gdb-minibuffer-local-map nil | ||
| 363 | 'gud-gdb-history))) | ||
| 364 | 396 | ||
| 365 | (gud-common-init command-line 'gud-gdb-massage-args | 397 | (gud-common-init command-line 'gud-gdb-massage-args |
| 366 | 'gud-gdb-marker-filter 'gud-gdb-find-file) | 398 | 'gud-gdb-marker-filter 'gud-gdb-find-file) |
| 399 | (set (make-local-variable 'gud-minor-mode) 'gdb) | ||
| 367 | 400 | ||
| 368 | (gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.") | 401 | (gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.") |
| 369 | (gud-def gud-tbreak "tbreak %f:%l" "\C-t" "Set temporary breakpoint at current line.") | 402 | (gud-def gud-tbreak "tbreak %f:%l" "\C-t" "Set temporary breakpoint at current line.") |
| @@ -646,27 +679,15 @@ BUFFER is the GUD buffer in which to run the command." | |||
| 646 | string) | 679 | string) |
| 647 | 680 | ||
| 648 | (defun gud-sdb-find-file (f) | 681 | (defun gud-sdb-find-file (f) |
| 649 | (save-excursion | 682 | (if gud-sdb-needs-tags (find-tag-noselect f) (find-file-noselect f))) |
| 650 | (let ((buf (if gud-sdb-needs-tags | ||
| 651 | (find-tag-noselect f) | ||
| 652 | (find-file-noselect f)))) | ||
| 653 | (set-buffer buf) | ||
| 654 | (gud-make-debug-menu) | ||
| 655 | (local-set-key [menu-bar debug tbreak] '("Temporary Breakpoint" . gud-tbreak)) | ||
| 656 | buf))) | ||
| 657 | 683 | ||
| 658 | ;;;###autoload | 684 | ;;;###autoload |
| 659 | (defun sdb (command-line) | 685 | (defun sdb (command-line) |
| 660 | "Run sdb on program FILE in buffer *gud-FILE*. | 686 | "Run sdb on program FILE in buffer *gud-FILE*. |
| 661 | The directory containing FILE becomes the initial working directory | 687 | The directory containing FILE becomes the initial working directory |
| 662 | and source-file directory for your debugger." | 688 | and source-file directory for your debugger." |
| 663 | (interactive | 689 | (interactive (list (gud-query-cmdline 'sdb))) |
| 664 | (list (read-from-minibuffer "Run sdb (like this): " | 690 | |
| 665 | (if (consp gud-sdb-history) | ||
| 666 | (car gud-sdb-history) | ||
| 667 | "sdb ") | ||
| 668 | nil nil | ||
| 669 | 'gud-sdb-history))) | ||
| 670 | (if (and gud-sdb-needs-tags | 691 | (if (and gud-sdb-needs-tags |
| 671 | (not (and (boundp 'tags-file-name) | 692 | (not (and (boundp 'tags-file-name) |
| 672 | (stringp tags-file-name) | 693 | (stringp tags-file-name) |
| @@ -675,6 +696,7 @@ and source-file directory for your debugger." | |||
| 675 | 696 | ||
| 676 | (gud-common-init command-line 'gud-sdb-massage-args | 697 | (gud-common-init command-line 'gud-sdb-massage-args |
| 677 | 'gud-sdb-marker-filter 'gud-sdb-find-file) | 698 | 'gud-sdb-marker-filter 'gud-sdb-find-file) |
| 699 | (set (make-local-variable 'gud-minor-mode) 'sdb) | ||
| 678 | 700 | ||
| 679 | (gud-def gud-break "%l b" "\C-b" "Set breakpoint at current line.") | 701 | (gud-def gud-break "%l b" "\C-b" "Set breakpoint at current line.") |
| 680 | (gud-def gud-tbreak "%l c" "\C-t" "Set temporary breakpoint at current line.") | 702 | (gud-def gud-tbreak "%l c" "\C-t" "Set temporary breakpoint at current line.") |
| @@ -981,26 +1003,14 @@ This was tested using R4.11.") | |||
| 981 | (save-excursion | 1003 | (save-excursion |
| 982 | (let ((realf (gud-dbx-file-name f))) | 1004 | (let ((realf (gud-dbx-file-name f))) |
| 983 | (if realf | 1005 | (if realf |
| 984 | (let ((buf (find-file-noselect realf))) | 1006 | (find-file-noselect realf))))) |
| 985 | (set-buffer buf) | ||
| 986 | (gud-make-debug-menu) | ||
| 987 | (local-set-key [menu-bar debug up] '("Up Stack" . gud-up)) | ||
| 988 | (local-set-key [menu-bar debug down] '("Down Stack" . gud-down)) | ||
| 989 | buf) | ||
| 990 | nil)))) | ||
| 991 | 1007 | ||
| 992 | ;;;###autoload | 1008 | ;;;###autoload |
| 993 | (defun dbx (command-line) | 1009 | (defun dbx (command-line) |
| 994 | "Run dbx on program FILE in buffer *gud-FILE*. | 1010 | "Run dbx on program FILE in buffer *gud-FILE*. |
| 995 | The directory containing FILE becomes the initial working directory | 1011 | The directory containing FILE becomes the initial working directory |
| 996 | and source-file directory for your debugger." | 1012 | and source-file directory for your debugger." |
| 997 | (interactive | 1013 | (interactive (list (gud-query-cmdline 'dbx))) |
| 998 | (list (read-from-minibuffer "Run dbx (like this): " | ||
| 999 | (if (consp gud-dbx-history) | ||
| 1000 | (car gud-dbx-history) | ||
| 1001 | "dbx ") | ||
| 1002 | nil nil | ||
| 1003 | 'gud-dbx-history))) | ||
| 1004 | 1014 | ||
| 1005 | (cond | 1015 | (cond |
| 1006 | (gud-mips-p | 1016 | (gud-mips-p |
| @@ -1016,6 +1026,8 @@ and source-file directory for your debugger." | |||
| 1016 | (gud-common-init command-line 'gud-dbx-massage-args | 1026 | (gud-common-init command-line 'gud-dbx-massage-args |
| 1017 | 'gud-dbx-marker-filter 'gud-dbx-find-file))) | 1027 | 'gud-dbx-marker-filter 'gud-dbx-find-file))) |
| 1018 | 1028 | ||
| 1029 | (set (make-local-variable 'gud-minor-mode) 'dbx) | ||
| 1030 | |||
| 1019 | (cond | 1031 | (cond |
| 1020 | (gud-mips-p | 1032 | (gud-mips-p |
| 1021 | (gud-def gud-up "up %p" "<" "Up (numeric arg) stack frames.") | 1033 | (gud-def gud-up "up %p" "<" "Up (numeric arg) stack frames.") |
| @@ -1123,17 +1135,7 @@ containing the executable being debugged." | |||
| 1123 | (save-excursion | 1135 | (save-excursion |
| 1124 | (let ((realf (gud-xdb-file-name f))) | 1136 | (let ((realf (gud-xdb-file-name f))) |
| 1125 | (if realf | 1137 | (if realf |
| 1126 | (let ((buf (find-file-noselect realf))) | 1138 | (find-file-noselect realf))))) |
| 1127 | (set-buffer buf) | ||
| 1128 | (gud-make-debug-menu) | ||
| 1129 | (local-set-key [menu-bar debug tbreak] | ||
| 1130 | '("Temporary Breakpoint" . gud-tbreak)) | ||
| 1131 | (local-set-key [menu-bar debug finish] | ||
| 1132 | '("Finish Function" . gud-finish)) | ||
| 1133 | (local-set-key [menu-bar debug up] '("Up Stack" . gud-up)) | ||
| 1134 | (local-set-key [menu-bar debug down] '("Down Stack" . gud-down)) | ||
| 1135 | buf) | ||
| 1136 | nil)))) | ||
| 1137 | 1139 | ||
| 1138 | ;;;###autoload | 1140 | ;;;###autoload |
| 1139 | (defun xdb (command-line) | 1141 | (defun xdb (command-line) |
| @@ -1143,16 +1145,11 @@ and source-file directory for your debugger. | |||
| 1143 | 1145 | ||
| 1144 | You can set the variable 'gud-xdb-directories' to a list of program source | 1146 | You can set the variable 'gud-xdb-directories' to a list of program source |
| 1145 | directories if your program contains sources from more than one directory." | 1147 | directories if your program contains sources from more than one directory." |
| 1146 | (interactive | 1148 | (interactive (list (gud-query-cmdline 'xdb))) |
| 1147 | (list (read-from-minibuffer "Run xdb (like this): " | ||
| 1148 | (if (consp gud-xdb-history) | ||
| 1149 | (car gud-xdb-history) | ||
| 1150 | "xdb ") | ||
| 1151 | nil nil | ||
| 1152 | 'gud-xdb-history))) | ||
| 1153 | 1149 | ||
| 1154 | (gud-common-init command-line 'gud-xdb-massage-args | 1150 | (gud-common-init command-line 'gud-xdb-massage-args |
| 1155 | 'gud-xdb-marker-filter 'gud-xdb-find-file) | 1151 | 'gud-xdb-marker-filter 'gud-xdb-find-file) |
| 1152 | (set (make-local-variable 'gud-minor-mode) 'xdb) | ||
| 1156 | 1153 | ||
| 1157 | (gud-def gud-break "b %f:%l" "\C-b" "Set breakpoint at current line.") | 1154 | (gud-def gud-break "b %f:%l" "\C-b" "Set breakpoint at current line.") |
| 1158 | (gud-def gud-tbreak "b %f:%l\\t" "\C-t" | 1155 | (gud-def gud-tbreak "b %f:%l\\t" "\C-t" |
| @@ -1274,11 +1271,7 @@ directories if your program contains sources from more than one directory." | |||
| 1274 | output)) | 1271 | output)) |
| 1275 | 1272 | ||
| 1276 | (defun gud-perldb-find-file (f) | 1273 | (defun gud-perldb-find-file (f) |
| 1277 | (save-excursion | 1274 | (find-file-noselect f)) |
| 1278 | (let ((buf (find-file-noselect f))) | ||
| 1279 | (set-buffer buf) | ||
| 1280 | (gud-make-debug-menu) | ||
| 1281 | buf))) | ||
| 1282 | 1275 | ||
| 1283 | (defcustom gud-perldb-command-name "perl" | 1276 | (defcustom gud-perldb-command-name "perl" |
| 1284 | "File name for executing Perl." | 1277 | "File name for executing Perl." |
| @@ -1291,19 +1284,12 @@ directories if your program contains sources from more than one directory." | |||
| 1291 | The directory containing FILE becomes the initial working directory | 1284 | The directory containing FILE becomes the initial working directory |
| 1292 | and source-file directory for your debugger." | 1285 | and source-file directory for your debugger." |
| 1293 | (interactive | 1286 | (interactive |
| 1294 | (list (read-from-minibuffer "Run perldb (like this): " | 1287 | (list (gud-query-cmdline 'perldb |
| 1295 | (if (consp gud-perldb-history) | 1288 | (concat (or (buffer-file-name) "-e 0") " ")))) |
| 1296 | (car gud-perldb-history) | ||
| 1297 | (concat gud-perldb-command-name | ||
| 1298 | " " | ||
| 1299 | (or (buffer-file-name) | ||
| 1300 | "-e 0") | ||
| 1301 | " ")) | ||
| 1302 | nil nil | ||
| 1303 | 'gud-perldb-history))) | ||
| 1304 | 1289 | ||
| 1305 | (gud-common-init command-line 'gud-perldb-massage-args | 1290 | (gud-common-init command-line 'gud-perldb-massage-args |
| 1306 | 'gud-perldb-marker-filter 'gud-perldb-find-file) | 1291 | 'gud-perldb-marker-filter 'gud-perldb-find-file) |
| 1292 | (set (make-local-variable 'gud-minor-mode) 'perldb) | ||
| 1307 | 1293 | ||
| 1308 | (gud-def gud-break "b %l" "\C-b" "Set breakpoint at current line.") | 1294 | (gud-def gud-break "b %l" "\C-b" "Set breakpoint at current line.") |
| 1309 | (gud-def gud-remove "d %l" "\C-d" "Remove breakpoint at current line") | 1295 | (gud-def gud-remove "d %l" "\C-d" "Remove breakpoint at current line") |
| @@ -1317,8 +1303,7 @@ and source-file directory for your debugger." | |||
| 1317 | 1303 | ||
| 1318 | (setq comint-prompt-regexp "^ DB<+[0-9]+>+ ") | 1304 | (setq comint-prompt-regexp "^ DB<+[0-9]+>+ ") |
| 1319 | (setq paragraph-start comint-prompt-regexp) | 1305 | (setq paragraph-start comint-prompt-regexp) |
| 1320 | (run-hooks 'perldb-mode-hook) | 1306 | (run-hooks 'perldb-mode-hook)) |
| 1321 | ) | ||
| 1322 | 1307 | ||
| 1323 | ;; ====================================================================== | 1308 | ;; ====================================================================== |
| 1324 | ;; pdb (Python debugger) functions | 1309 | ;; pdb (Python debugger) functions |
| @@ -1395,22 +1380,7 @@ and source-file directory for your debugger." | |||
| 1395 | output)) | 1380 | output)) |
| 1396 | 1381 | ||
| 1397 | (defun gud-pdb-find-file (f) | 1382 | (defun gud-pdb-find-file (f) |
| 1398 | (save-excursion | 1383 | (find-file-noselect f)) |
| 1399 | (let ((buf (find-file-noselect f))) | ||
| 1400 | (set-buffer buf) | ||
| 1401 | (gud-make-debug-menu) | ||
| 1402 | ;; (local-set-key [menu-bar debug finish] '("Finish Function" . gud-finish)) | ||
| 1403 | ;; (local-set-key [menu-bar debug up] '("Up Stack" . gud-up)) | ||
| 1404 | ;; (local-set-key [menu-bar debug down] '("Down Stack" . gud-down)) | ||
| 1405 | buf))) | ||
| 1406 | |||
| 1407 | (defvar pdb-minibuffer-local-map nil | ||
| 1408 | "Keymap for minibuffer prompting of pdb startup command.") | ||
| 1409 | (if pdb-minibuffer-local-map | ||
| 1410 | () | ||
| 1411 | (setq pdb-minibuffer-local-map (copy-keymap minibuffer-local-map)) | ||
| 1412 | (define-key | ||
| 1413 | pdb-minibuffer-local-map "\C-i" 'comint-dynamic-complete-filename)) | ||
| 1414 | 1384 | ||
| 1415 | (defcustom gud-pdb-command-name "pdb" | 1385 | (defcustom gud-pdb-command-name "pdb" |
| 1416 | "File name for executing the Python debugger. | 1386 | "File name for executing the Python debugger. |
| @@ -1424,15 +1394,11 @@ This should be an executable on your path, or an absolute file name." | |||
| 1424 | The directory containing FILE becomes the initial working directory | 1394 | The directory containing FILE becomes the initial working directory |
| 1425 | and source-file directory for your debugger." | 1395 | and source-file directory for your debugger." |
| 1426 | (interactive | 1396 | (interactive |
| 1427 | (list (read-from-minibuffer "Run pdb (like this): " | 1397 | (list (gud-query-cmdline 'pdb))) |
| 1428 | (if (consp gud-pdb-history) | ||
| 1429 | (car gud-pdb-history) | ||
| 1430 | (concat gud-pdb-command-name " ")) | ||
| 1431 | pdb-minibuffer-local-map nil | ||
| 1432 | 'gud-pdb-history))) | ||
| 1433 | 1398 | ||
| 1434 | (gud-common-init command-line 'gud-pdb-massage-args | 1399 | (gud-common-init command-line 'gud-pdb-massage-args |
| 1435 | 'gud-pdb-marker-filter 'gud-pdb-find-file) | 1400 | 'gud-pdb-marker-filter 'gud-pdb-find-file) |
| 1401 | (set (make-local-variable 'gud-minor-mode) 'pdb) | ||
| 1436 | 1402 | ||
| 1437 | (gud-def gud-break "break %l" "\C-b" "Set breakpoint at current line.") | 1403 | (gud-def gud-break "break %l" "\C-b" "Set breakpoint at current line.") |
| 1438 | (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line") | 1404 | (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line") |
| @@ -1911,15 +1877,11 @@ the source code display in sync with the debugging session.") | |||
| 1911 | if there is. If the \"-classpath\" switch is given, omit all whitespace | 1877 | if there is. If the \"-classpath\" switch is given, omit all whitespace |
| 1912 | between it and it's value." | 1878 | between it and it's value." |
| 1913 | (interactive | 1879 | (interactive |
| 1914 | (list (read-from-minibuffer "Run jdb (like this): " | 1880 | (list (gud-query-cmdline 'jdb))) |
| 1915 | (if (consp gud-jdb-history) | ||
| 1916 | (car gud-jdb-history) | ||
| 1917 | (concat gud-jdb-command-name " ")) | ||
| 1918 | nil nil | ||
| 1919 | 'gud-jdb-history))) | ||
| 1920 | 1881 | ||
| 1921 | (gud-common-init command-line 'gud-jdb-massage-args | 1882 | (gud-common-init command-line 'gud-jdb-massage-args |
| 1922 | 'gud-jdb-marker-filter 'gud-jdb-find-file) | 1883 | 'gud-jdb-marker-filter 'gud-jdb-find-file) |
| 1884 | (set (make-local-variable 'gud-minor-mode) 'jdb) | ||
| 1923 | 1885 | ||
| 1924 | (gud-def gud-break "stop at %F:%l" "\C-b" "Set breakpoint at current line.") | 1886 | (gud-def gud-break "stop at %F:%l" "\C-b" "Set breakpoint at current line.") |
| 1925 | (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line") | 1887 | (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line") |
| @@ -1991,7 +1953,7 @@ between it and it's value." | |||
| 1991 | 1953 | ||
| 1992 | (put 'gud-mode 'mode-class 'special) | 1954 | (put 'gud-mode 'mode-class 'special) |
| 1993 | 1955 | ||
| 1994 | (defun gud-mode () | 1956 | (define-derived-mode gud-mode comint-mode "Debugger" |
| 1995 | "Major mode for interacting with an inferior debugger process. | 1957 | "Major mode for interacting with an inferior debugger process. |
| 1996 | 1958 | ||
| 1997 | You start it up with one of the commands M-x gdb, M-x sdb, M-x dbx, | 1959 | You start it up with one of the commands M-x gdb, M-x sdb, M-x dbx, |
| @@ -2045,42 +2007,14 @@ commands. | |||
| 2045 | 2007 | ||
| 2046 | Other commands for interacting with the debugger process are inherited from | 2008 | Other commands for interacting with the debugger process are inherited from |
| 2047 | comint mode, which see." | 2009 | comint mode, which see." |
| 2048 | (interactive) | ||
| 2049 | (comint-mode) | ||
| 2050 | (setq major-mode 'gud-mode) | ||
| 2051 | (setq mode-name "Debugger") | ||
| 2052 | (setq mode-line-process '(":%s")) | 2010 | (setq mode-line-process '(":%s")) |
| 2053 | (use-local-map comint-mode-map) | ||
| 2054 | (gud-make-debug-menu) | ||
| 2055 | (define-key (current-local-map) "\C-c\C-l" 'gud-refresh) | 2011 | (define-key (current-local-map) "\C-c\C-l" 'gud-refresh) |
| 2056 | (make-local-variable 'gud-last-frame) | 2012 | (set (make-local-variable 'gud-last-frame) nil) |
| 2057 | (setq gud-last-frame nil) | ||
| 2058 | (make-local-variable 'comint-prompt-regexp) | 2013 | (make-local-variable 'comint-prompt-regexp) |
| 2059 | ;; Don't put repeated commands in command history many times. | 2014 | ;; Don't put repeated commands in command history many times. |
| 2060 | (make-local-variable 'comint-input-ignoredups) | 2015 | (set (make-local-variable 'comint-input-ignoredups) t) |
| 2061 | (setq comint-input-ignoredups t) | ||
| 2062 | (make-local-variable 'paragraph-start) | 2016 | (make-local-variable 'paragraph-start) |
| 2063 | (make-local-variable 'gud-delete-prompt-marker) | 2017 | (set (make-local-variable 'gud-delete-prompt-marker) (make-marker))) |
| 2064 | (setq gud-delete-prompt-marker (make-marker)) | ||
| 2065 | (run-hooks 'gud-mode-hook)) | ||
| 2066 | |||
| 2067 | ;; Chop STRING into words separated by SPC or TAB and return a list of them. | ||
| 2068 | (defun gud-chop-words (string) | ||
| 2069 | (let ((i 0) (beg 0) | ||
| 2070 | (len (length string)) | ||
| 2071 | (words nil)) | ||
| 2072 | (while (< i len) | ||
| 2073 | (if (memq (aref string i) '(?\t ? )) | ||
| 2074 | (progn | ||
| 2075 | (setq words (cons (substring string beg i) words) | ||
| 2076 | beg (1+ i)) | ||
| 2077 | (while (and (< beg len) (memq (aref string beg) '(?\t ? ))) | ||
| 2078 | (setq beg (1+ beg))) | ||
| 2079 | (setq i (1+ beg))) | ||
| 2080 | (setq i (1+ i)))) | ||
| 2081 | (if (< beg len) | ||
| 2082 | (setq words (cons (substring string beg) words))) | ||
| 2083 | (nreverse words))) | ||
| 2084 | 2018 | ||
| 2085 | ;; Cause our buffers to be displayed, by default, | 2019 | ;; Cause our buffers to be displayed, by default, |
| 2086 | ;; in the selected window. | 2020 | ;; in the selected window. |
| @@ -2092,7 +2026,7 @@ comint mode, which see." | |||
| 2092 | ;; The other three args specify the values to use | 2026 | ;; The other three args specify the values to use |
| 2093 | ;; for local variables in the debugger buffer. | 2027 | ;; for local variables in the debugger buffer. |
| 2094 | (defun gud-common-init (command-line massage-args marker-filter find-file) | 2028 | (defun gud-common-init (command-line massage-args marker-filter find-file) |
| 2095 | (let* ((words (gud-chop-words command-line)) | 2029 | (let* ((words (split-string command-line)) |
| 2096 | (program (car words)) | 2030 | (program (car words)) |
| 2097 | ;; Extract the file name from WORDS | 2031 | ;; Extract the file name from WORDS |
| 2098 | ;; and put t in its place. | 2032 | ;; and put t in its place. |
| @@ -2145,12 +2079,11 @@ comint mode, which see." | |||
| 2145 | 2079 | ||
| 2146 | (set-process-filter (get-buffer-process (current-buffer)) 'gud-filter) | 2080 | (set-process-filter (get-buffer-process (current-buffer)) 'gud-filter) |
| 2147 | (set-process-sentinel (get-buffer-process (current-buffer)) 'gud-sentinel) | 2081 | (set-process-sentinel (get-buffer-process (current-buffer)) 'gud-sentinel) |
| 2148 | (gud-set-buffer) | 2082 | (gud-set-buffer)) |
| 2149 | ) | ||
| 2150 | 2083 | ||
| 2151 | (defun gud-set-buffer () | 2084 | (defun gud-set-buffer () |
| 2152 | (cond ((eq major-mode 'gud-mode) | 2085 | (when (eq major-mode 'gud-mode) |
| 2153 | (setq gud-comint-buffer (current-buffer))))) | 2086 | (setq gud-comint-buffer (current-buffer)))) |
| 2154 | 2087 | ||
| 2155 | (defvar gud-filter-defer-flag nil | 2088 | (defvar gud-filter-defer-flag nil |
| 2156 | "Non-nil means don't process anything from the debugger right now. | 2089 | "Non-nil means don't process anything from the debugger right now. |
| @@ -2400,21 +2333,6 @@ Obeying it means displaying in another window the specified file and line." | |||
| 2400 | (or gud-last-frame (setq gud-last-frame gud-last-last-frame)) | 2333 | (or gud-last-frame (setq gud-last-frame gud-last-last-frame)) |
| 2401 | (gud-display-frame)) | 2334 | (gud-display-frame)) |
| 2402 | 2335 | ||
| 2403 | |||
| 2404 | (defun gud-new-keymap (map) | ||
| 2405 | "Return a new keymap which inherits from MAP and has name `Gud'." | ||
| 2406 | (nconc (make-sparse-keymap "Gud") map)) | ||
| 2407 | |||
| 2408 | (defun gud-make-debug-menu () | ||
| 2409 | "Make sure the current local map has a [menu-bar debug] submap. | ||
| 2410 | If it doesn't, replace it with a new map that inherits it, | ||
| 2411 | and create such a submap in that new map." | ||
| 2412 | (use-local-map (gud-new-keymap (current-local-map))) | ||
| 2413 | (define-key (current-local-map) [menu-bar] | ||
| 2414 | (gud-new-keymap (lookup-key (current-local-map) [menu-bar]))) | ||
| 2415 | (define-key (current-local-map) [menu-bar debug] | ||
| 2416 | (cons "Gud" (gud-new-keymap gud-menu-map)))) | ||
| 2417 | |||
| 2418 | ;;; Code for parsing expressions out of C code. The single entry point is | 2336 | ;;; Code for parsing expressions out of C code. The single entry point is |
| 2419 | ;;; find-c-expr, which tries to return an lvalue expression from around point. | 2337 | ;;; find-c-expr, which tries to return an lvalue expression from around point. |
| 2420 | ;;; | 2338 | ;;; |
| @@ -2445,8 +2363,7 @@ and create such a submap in that new map." | |||
| 2445 | (setq test-expr (gud-next-expr)) | 2363 | (setq test-expr (gud-next-expr)) |
| 2446 | (while (gud-expr-compound expr test-expr) | 2364 | (while (gud-expr-compound expr test-expr) |
| 2447 | (setq expr (cons (car expr) (cdr test-expr))) | 2365 | (setq expr (cons (car expr) (cdr test-expr))) |
| 2448 | (setq test-expr (gud-next-expr)) | 2366 | (setq test-expr (gud-next-expr))) |
| 2449 | ) | ||
| 2450 | (buffer-substring (car expr) (cdr expr))))) | 2367 | (buffer-substring (car expr) (cdr expr))))) |
| 2451 | 2368 | ||
| 2452 | (defun gud-innermost-expr () | 2369 | (defun gud-innermost-expr () |