diff options
| author | Stefan Monnier | 2002-09-12 21:26:27 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2002-09-12 21:26:27 +0000 |
| commit | 8b5cd4d0c5b5954807061536857e865a3c40e098 (patch) | |
| tree | f9b12d312f74833cccedaa107119c596122467be | |
| parent | 45aaa254f3cfbb10bde031bc9bf97311e8a425b3 (diff) | |
| download | emacs-8b5cd4d0c5b5954807061536857e865a3c40e098.tar.gz emacs-8b5cd4d0c5b5954807061536857e865a3c40e098.zip | |
(gud-gdb-massage-args, gud-sdb-massage-args)
(gud-pdb-massage-args): Delete.
(gdb, sdb, pdb): Don't pass gud-*-massage-args any more.
(gud-gdb-command-name): New var. Put "--fullname" in there.
(gud-query-cmdline): Use the most recent executable as the default.
Don't add "--fullname" (it's only valid/meaningful for GDB).
(gud-xdb-marker-filter): Use match-string.
(gud-perldb-massage-args): Don't add "-d".
(gud-perldb-command-name): Add "-d".
(gud-common-init): If `massage-args' is nil, don't call it.
(gud-format-command): Don't hardcode point-min==1.
| -rw-r--r-- | lisp/gud.el | 173 |
1 files changed, 88 insertions, 85 deletions
diff --git a/lisp/gud.el b/lisp/gud.el index 70e9f1418fb..b1eee6fbff8 100644 --- a/lisp/gud.el +++ b/lisp/gud.el | |||
| @@ -214,7 +214,7 @@ we're in the GUD buffer)." | |||
| 214 | 214 | ||
| 215 | ;; ====================================================================== | 215 | ;; ====================================================================== |
| 216 | ;; speedbar support functions and variables. | 216 | ;; speedbar support functions and variables. |
| 217 | (eval-when-compile (require 'speedbar)) | 217 | (eval-when-compile (require 'speedbar)) ;For speedbar-with-attached-buffer. |
| 218 | 218 | ||
| 219 | (defvar gud-last-speedbar-buffer nil | 219 | (defvar gud-last-speedbar-buffer nil |
| 220 | "The last GUD buffer used.") | 220 | "The last GUD buffer used.") |
| @@ -303,11 +303,13 @@ off the specialized speedbar mode." | |||
| 303 | ;; ====================================================================== | 303 | ;; ====================================================================== |
| 304 | ;; gdb functions | 304 | ;; gdb functions |
| 305 | 305 | ||
| 306 | ;;; History of argument lists passed to gdb. | 306 | ;; History of argument lists passed to gdb. |
| 307 | (defvar gud-gdb-history nil) | 307 | (defvar gud-gdb-history nil) |
| 308 | 308 | ||
| 309 | (defun gud-gdb-massage-args (file args) | 309 | (defcustom gud-gdb-command-name "gdb --fullname" |
| 310 | args) | 310 | "Default command to execute an executable under the GDB debugger." |
| 311 | :type 'string | ||
| 312 | :group 'gud) | ||
| 311 | 313 | ||
| 312 | (defvar gud-gdb-marker-regexp | 314 | (defvar gud-gdb-marker-regexp |
| 313 | ;; This used to use path-separator instead of ":"; | 315 | ;; This used to use path-separator instead of ":"; |
| @@ -383,7 +385,16 @@ off the specialized speedbar mode." | |||
| 383 | (read-from-minibuffer | 385 | (read-from-minibuffer |
| 384 | (format "Run %s (like this): " minor-mode) | 386 | (format "Run %s (like this): " minor-mode) |
| 385 | (or (car-safe (symbol-value hist-sym)) | 387 | (or (car-safe (symbol-value hist-sym)) |
| 386 | (concat (or cmd-name (symbol-name minor-mode)) " --fullname " init)) | 388 | (concat (or cmd-name (symbol-name minor-mode)) |
| 389 | " " | ||
| 390 | (or init | ||
| 391 | (let ((file nil)) | ||
| 392 | (dolist (f (directory-files default-directory) file) | ||
| 393 | (if (and (file-executable-p f) | ||
| 394 | (not (file-directory-p f)) | ||
| 395 | (or (not file) | ||
| 396 | (file-newer-than-file-p f file))) | ||
| 397 | (setq file f))))))) | ||
| 387 | gud-minibuffer-local-map nil | 398 | gud-minibuffer-local-map nil |
| 388 | hist-sym))) | 399 | hist-sym))) |
| 389 | 400 | ||
| @@ -394,7 +405,7 @@ The directory containing FILE becomes the initial working directory | |||
| 394 | and source-file directory for your debugger." | 405 | and source-file directory for your debugger." |
| 395 | (interactive (list (gud-query-cmdline 'gdb))) | 406 | (interactive (list (gud-query-cmdline 'gdb))) |
| 396 | 407 | ||
| 397 | (gud-common-init command-line 'gud-gdb-massage-args | 408 | (gud-common-init command-line nil |
| 398 | 'gud-gdb-marker-filter 'gud-gdb-find-file) | 409 | 'gud-gdb-marker-filter 'gud-gdb-find-file) |
| 399 | (set (make-local-variable 'gud-minor-mode) 'gdb) | 410 | (set (make-local-variable 'gud-minor-mode) 'gdb) |
| 400 | 411 | ||
| @@ -621,7 +632,7 @@ BUFFER is the GUD buffer in which to run the command." | |||
| 621 | ;; ====================================================================== | 632 | ;; ====================================================================== |
| 622 | ;; sdb functions | 633 | ;; sdb functions |
| 623 | 634 | ||
| 624 | ;;; History of argument lists passed to sdb. | 635 | ;; History of argument lists passed to sdb. |
| 625 | (defvar gud-sdb-history nil) | 636 | (defvar gud-sdb-history nil) |
| 626 | 637 | ||
| 627 | (defvar gud-sdb-needs-tags (not (file-exists-p "/var")) | 638 | (defvar gud-sdb-needs-tags (not (file-exists-p "/var")) |
| @@ -629,8 +640,6 @@ BUFFER is the GUD buffer in which to run the command." | |||
| 629 | 640 | ||
| 630 | (defvar gud-sdb-lastfile nil) | 641 | (defvar gud-sdb-lastfile nil) |
| 631 | 642 | ||
| 632 | (defun gud-sdb-massage-args (file args) args) | ||
| 633 | |||
| 634 | (defun gud-sdb-marker-filter (string) | 643 | (defun gud-sdb-marker-filter (string) |
| 635 | (setq gud-marker-acc | 644 | (setq gud-marker-acc |
| 636 | (if gud-marker-acc (concat gud-marker-acc string) string)) | 645 | (if gud-marker-acc (concat gud-marker-acc string) string)) |
| @@ -696,7 +705,7 @@ and source-file directory for your debugger." | |||
| 696 | (file-exists-p tags-file-name)))) | 705 | (file-exists-p tags-file-name)))) |
| 697 | (error "The sdb support requires a valid tags table to work")) | 706 | (error "The sdb support requires a valid tags table to work")) |
| 698 | 707 | ||
| 699 | (gud-common-init command-line 'gud-sdb-massage-args | 708 | (gud-common-init command-line nil |
| 700 | 'gud-sdb-marker-filter 'gud-sdb-find-file) | 709 | 'gud-sdb-marker-filter 'gud-sdb-find-file) |
| 701 | (set (make-local-variable 'gud-minor-mode) 'sdb) | 710 | (set (make-local-variable 'gud-minor-mode) 'sdb) |
| 702 | 711 | ||
| @@ -719,7 +728,7 @@ and source-file directory for your debugger." | |||
| 719 | ;; ====================================================================== | 728 | ;; ====================================================================== |
| 720 | ;; dbx functions | 729 | ;; dbx functions |
| 721 | 730 | ||
| 722 | ;;; History of argument lists passed to dbx. | 731 | ;; History of argument lists passed to dbx. |
| 723 | (defvar gud-dbx-history nil) | 732 | (defvar gud-dbx-history nil) |
| 724 | 733 | ||
| 725 | (defcustom gud-dbx-directories nil | 734 | (defcustom gud-dbx-directories nil |
| @@ -1074,7 +1083,7 @@ and source-file directory for your debugger." | |||
| 1074 | ;; ====================================================================== | 1083 | ;; ====================================================================== |
| 1075 | ;; xdb (HP PARISC debugger) functions | 1084 | ;; xdb (HP PARISC debugger) functions |
| 1076 | 1085 | ||
| 1077 | ;;; History of argument lists passed to xdb. | 1086 | ;; History of argument lists passed to xdb. |
| 1078 | (defvar gud-xdb-history nil) | 1087 | (defvar gud-xdb-history nil) |
| 1079 | 1088 | ||
| 1080 | (defcustom gud-xdb-directories nil | 1089 | (defcustom gud-xdb-directories nil |
| @@ -1125,10 +1134,8 @@ containing the executable being debugged." | |||
| 1125 | result) | 1134 | result) |
| 1126 | (string-match "[^: \t]+:[ \t]+\\([^:]+\\): [^:]+: \\([0-9]+\\):" | 1135 | (string-match "[^: \t]+:[ \t]+\\([^:]+\\): [^:]+: \\([0-9]+\\):" |
| 1127 | result)) | 1136 | result)) |
| 1128 | (let ((line (string-to-int | 1137 | (let ((line (string-to-int (match-string 2 result))) |
| 1129 | (substring result (match-beginning 2) (match-end 2)))) | 1138 | (file (gud-xdb-file-name (match-string 1 result)))) |
| 1130 | (file (gud-xdb-file-name | ||
| 1131 | (substring result (match-beginning 1) (match-end 1))))) | ||
| 1132 | (if file | 1139 | (if file |
| 1133 | (setq gud-last-frame (cons file line)))))) | 1140 | (setq gud-last-frame (cons file line)))))) |
| 1134 | (or result ""))) | 1141 | (or result ""))) |
| @@ -1176,19 +1183,18 @@ directories if your program contains sources from more than one directory." | |||
| 1176 | ;; ====================================================================== | 1183 | ;; ====================================================================== |
| 1177 | ;; perldb functions | 1184 | ;; perldb functions |
| 1178 | 1185 | ||
| 1179 | ;;; History of argument lists passed to perldb. | 1186 | ;; History of argument lists passed to perldb. |
| 1180 | (defvar gud-perldb-history nil) | 1187 | (defvar gud-perldb-history nil) |
| 1181 | 1188 | ||
| 1182 | ;; Convert a command line as would be typed normally to run a script | ||
| 1183 | ;; into one that invokes an Emacs-enabled debugging session. | ||
| 1184 | ;; "-d" in inserted as the first switch, and "-emacs" is inserted where | ||
| 1185 | ;; it will be $ARGV[0] (see perl5db.pl). | ||
| 1186 | (defun gud-perldb-massage-args (file args) | 1189 | (defun gud-perldb-massage-args (file args) |
| 1187 | (let* ((new-args (list "-d")) | 1190 | "Convert a command line as would be typed normally to run perldb |
| 1191 | into one that invokes an Emacs-enabled debugging session. | ||
| 1192 | \"-emacs\" is inserted where it will be $ARGV[0] (see perl5db.pl)." | ||
| 1193 | ;; FIXME: what if the command is `make perldb' and doesn't accept those extra | ||
| 1194 | ;; arguments ? | ||
| 1195 | (let* ((new-args nil) | ||
| 1188 | (seen-e nil) | 1196 | (seen-e nil) |
| 1189 | (shift (lambda () | 1197 | (shift (lambda () (push (pop args) new-args)))) |
| 1190 | (setq new-args (cons (car args) new-args)) | ||
| 1191 | (setq args (cdr args))))) | ||
| 1192 | 1198 | ||
| 1193 | ;; Pass all switches and -e scripts through. | 1199 | ;; Pass all switches and -e scripts through. |
| 1194 | (while (and args | 1200 | (while (and args |
| @@ -1275,8 +1281,8 @@ directories if your program contains sources from more than one directory." | |||
| 1275 | (defun gud-perldb-find-file (f) | 1281 | (defun gud-perldb-find-file (f) |
| 1276 | (find-file-noselect f)) | 1282 | (find-file-noselect f)) |
| 1277 | 1283 | ||
| 1278 | (defcustom gud-perldb-command-name "perl" | 1284 | (defcustom gud-perldb-command-name "perl -d" |
| 1279 | "File name for executing Perl." | 1285 | "Default command to execute a Perl script under debugger." |
| 1280 | :type 'string | 1286 | :type 'string |
| 1281 | :group 'gud) | 1287 | :group 'gud) |
| 1282 | 1288 | ||
| @@ -1310,12 +1316,9 @@ and source-file directory for your debugger." | |||
| 1310 | ;; ====================================================================== | 1316 | ;; ====================================================================== |
| 1311 | ;; pdb (Python debugger) functions | 1317 | ;; pdb (Python debugger) functions |
| 1312 | 1318 | ||
| 1313 | ;;; History of argument lists passed to pdb. | 1319 | ;; History of argument lists passed to pdb. |
| 1314 | (defvar gud-pdb-history nil) | 1320 | (defvar gud-pdb-history nil) |
| 1315 | 1321 | ||
| 1316 | (defun gud-pdb-massage-args (file args) | ||
| 1317 | args) | ||
| 1318 | |||
| 1319 | ;; Last group is for return value, e.g. "> test.py(2)foo()->None" | 1322 | ;; Last group is for return value, e.g. "> test.py(2)foo()->None" |
| 1320 | ;; Either file or function name may be omitted: "> <string>(0)?()" | 1323 | ;; Either file or function name may be omitted: "> <string>(0)?()" |
| 1321 | (defvar gud-pdb-marker-regexp | 1324 | (defvar gud-pdb-marker-regexp |
| @@ -1398,7 +1401,7 @@ and source-file directory for your debugger." | |||
| 1398 | (interactive | 1401 | (interactive |
| 1399 | (list (gud-query-cmdline 'pdb))) | 1402 | (list (gud-query-cmdline 'pdb))) |
| 1400 | 1403 | ||
| 1401 | (gud-common-init command-line 'gud-pdb-massage-args | 1404 | (gud-common-init command-line nil |
| 1402 | 'gud-pdb-marker-filter 'gud-pdb-find-file) | 1405 | 'gud-pdb-marker-filter 'gud-pdb-find-file) |
| 1403 | (set (make-local-variable 'gud-minor-mode) 'pdb) | 1406 | (set (make-local-variable 'gud-minor-mode) 'pdb) |
| 1404 | 1407 | ||
| @@ -1536,7 +1539,7 @@ class information on jdb startup (original method)." | |||
| 1536 | "Java/jdb classpath directories list. | 1539 | "Java/jdb classpath directories list. |
| 1537 | If `gud-jdb-use-classpath' is non-nil, gud-jdb derives the `gud-jdb-classpath' | 1540 | If `gud-jdb-use-classpath' is non-nil, gud-jdb derives the `gud-jdb-classpath' |
| 1538 | list automatically using the following methods in sequence | 1541 | list automatically using the following methods in sequence |
| 1539 | (with subsequent successful steps overriding the results of previous | 1542 | \(with subsequent successful steps overriding the results of previous |
| 1540 | steps): | 1543 | steps): |
| 1541 | 1544 | ||
| 1542 | 1) Read the CLASSPATH environment variable, | 1545 | 1) Read the CLASSPATH environment variable, |
| @@ -2103,46 +2106,46 @@ gud, see `gud-mode'." | |||
| 2103 | ;; | 2106 | ;; |
| 2104 | 2107 | ||
| 2105 | 2108 | ||
| 2106 | ;;; When we send a command to the debugger via gud-call, it's annoying | 2109 | ;; When we send a command to the debugger via gud-call, it's annoying |
| 2107 | ;;; to see the command and the new prompt inserted into the debugger's | 2110 | ;; to see the command and the new prompt inserted into the debugger's |
| 2108 | ;;; buffer; we have other ways of knowing the command has completed. | 2111 | ;; buffer; we have other ways of knowing the command has completed. |
| 2109 | ;;; | 2112 | ;; |
| 2110 | ;;; If the buffer looks like this: | 2113 | ;; If the buffer looks like this: |
| 2111 | ;;; -------------------- | 2114 | ;; -------------------- |
| 2112 | ;;; (gdb) set args foo bar | 2115 | ;; (gdb) set args foo bar |
| 2113 | ;;; (gdb) -!- | 2116 | ;; (gdb) -!- |
| 2114 | ;;; -------------------- | 2117 | ;; -------------------- |
| 2115 | ;;; (the -!- marks the location of point), and we type `C-x SPC' in a | 2118 | ;; (the -!- marks the location of point), and we type `C-x SPC' in a |
| 2116 | ;;; source file to set a breakpoint, we want the buffer to end up like | 2119 | ;; source file to set a breakpoint, we want the buffer to end up like |
| 2117 | ;;; this: | 2120 | ;; this: |
| 2118 | ;;; -------------------- | 2121 | ;; -------------------- |
| 2119 | ;;; (gdb) set args foo bar | 2122 | ;; (gdb) set args foo bar |
| 2120 | ;;; Breakpoint 1 at 0x92: file make-docfile.c, line 49. | 2123 | ;; Breakpoint 1 at 0x92: file make-docfile.c, line 49. |
| 2121 | ;;; (gdb) -!- | 2124 | ;; (gdb) -!- |
| 2122 | ;;; -------------------- | 2125 | ;; -------------------- |
| 2123 | ;;; Essentially, the old prompt is deleted, and the command's output | 2126 | ;; Essentially, the old prompt is deleted, and the command's output |
| 2124 | ;;; and the new prompt take its place. | 2127 | ;; and the new prompt take its place. |
| 2125 | ;;; | 2128 | ;; |
| 2126 | ;;; Not echoing the command is easy enough; you send it directly using | 2129 | ;; Not echoing the command is easy enough; you send it directly using |
| 2127 | ;;; process-send-string, and it never enters the buffer. However, | 2130 | ;; process-send-string, and it never enters the buffer. However, |
| 2128 | ;;; getting rid of the old prompt is trickier; you don't want to do it | 2131 | ;; getting rid of the old prompt is trickier; you don't want to do it |
| 2129 | ;;; when you send the command, since that will result in an annoying | 2132 | ;; when you send the command, since that will result in an annoying |
| 2130 | ;;; flicker as the prompt is deleted, redisplay occurs while Emacs | 2133 | ;; flicker as the prompt is deleted, redisplay occurs while Emacs |
| 2131 | ;;; waits for a response from the debugger, and the new prompt is | 2134 | ;; waits for a response from the debugger, and the new prompt is |
| 2132 | ;;; inserted. Instead, we'll wait until we actually get some output | 2135 | ;; inserted. Instead, we'll wait until we actually get some output |
| 2133 | ;;; from the subprocess before we delete the prompt. If the command | 2136 | ;; from the subprocess before we delete the prompt. If the command |
| 2134 | ;;; produced no output other than a new prompt, that prompt will most | 2137 | ;; produced no output other than a new prompt, that prompt will most |
| 2135 | ;;; likely be in the first chunk of output received, so we will delete | 2138 | ;; likely be in the first chunk of output received, so we will delete |
| 2136 | ;;; the prompt and then replace it with an identical one. If the | 2139 | ;; the prompt and then replace it with an identical one. If the |
| 2137 | ;;; command produces output, the prompt is moving anyway, so the | 2140 | ;; command produces output, the prompt is moving anyway, so the |
| 2138 | ;;; flicker won't be annoying. | 2141 | ;; flicker won't be annoying. |
| 2139 | ;;; | 2142 | ;; |
| 2140 | ;;; So - when we want to delete the prompt upon receipt of the next | 2143 | ;; So - when we want to delete the prompt upon receipt of the next |
| 2141 | ;;; chunk of debugger output, we position gud-delete-prompt-marker at | 2144 | ;; chunk of debugger output, we position gud-delete-prompt-marker at |
| 2142 | ;;; the start of the prompt; the process filter will notice this, and | 2145 | ;; the start of the prompt; the process filter will notice this, and |
| 2143 | ;;; delete all text between it and the process output marker. If | 2146 | ;; delete all text between it and the process output marker. If |
| 2144 | ;;; gud-delete-prompt-marker points nowhere, we leave the current | 2147 | ;; gud-delete-prompt-marker points nowhere, we leave the current |
| 2145 | ;;; prompt alone. | 2148 | ;; prompt alone. |
| 2146 | (defvar gud-delete-prompt-marker nil) | 2149 | (defvar gud-delete-prompt-marker nil) |
| 2147 | 2150 | ||
| 2148 | 2151 | ||
| @@ -2270,7 +2273,7 @@ comint mode, which see." | |||
| 2270 | (if w | 2273 | (if w |
| 2271 | (setcar w file))) | 2274 | (setcar w file))) |
| 2272 | (apply 'make-comint (concat "gud" filepart) program nil | 2275 | (apply 'make-comint (concat "gud" filepart) program nil |
| 2273 | (funcall massage-args file args))) | 2276 | (if massage-args (funcall massage-args file args) args))) |
| 2274 | ;; Since comint clobbered the mode, we don't set it until now. | 2277 | ;; Since comint clobbered the mode, we don't set it until now. |
| 2275 | (gud-mode) | 2278 | (gud-mode) |
| 2276 | (make-local-variable 'gud-marker-filter) | 2279 | (make-local-variable 'gud-marker-filter) |
| @@ -2438,10 +2441,10 @@ Obeying it means displaying in another window the specified file and line." | |||
| 2438 | (goto-char pos)))) | 2441 | (goto-char pos)))) |
| 2439 | (set-window-point window overlay-arrow-position))))) | 2442 | (set-window-point window overlay-arrow-position))))) |
| 2440 | 2443 | ||
| 2441 | ;;; The gud-call function must do the right thing whether its invoking | 2444 | ;; The gud-call function must do the right thing whether its invoking |
| 2442 | ;;; keystroke is from the GUD buffer itself (via major-mode binding) | 2445 | ;; keystroke is from the GUD buffer itself (via major-mode binding) |
| 2443 | ;;; or a C buffer. In the former case, we want to supply data from | 2446 | ;; or a C buffer. In the former case, we want to supply data from |
| 2444 | ;;; gud-last-frame. Here's how we do it: | 2447 | ;; gud-last-frame. Here's how we do it: |
| 2445 | 2448 | ||
| 2446 | (defun gud-format-command (str arg) | 2449 | (defun gud-format-command (str arg) |
| 2447 | (let ((insource (not (eq (current-buffer) gud-comint-buffer))) | 2450 | (let ((insource (not (eq (current-buffer) gud-comint-buffer))) |
| @@ -2469,7 +2472,7 @@ Obeying it means displaying in another window the specified file and line." | |||
| 2469 | (if insource | 2472 | (if insource |
| 2470 | (save-restriction | 2473 | (save-restriction |
| 2471 | (widen) | 2474 | (widen) |
| 2472 | (+ (count-lines 1 (point)) | 2475 | (+ (count-lines (point-min) (point)) |
| 2473 | (if (bolp) 1 0))) | 2476 | (if (bolp) 1 0))) |
| 2474 | (cdr frame))))) | 2477 | (cdr frame))))) |
| 2475 | ((eq key ?e) | 2478 | ((eq key ?e) |
| @@ -2537,12 +2540,12 @@ Obeying it means displaying in another window the specified file and line." | |||
| 2537 | (gud-display-frame) | 2540 | (gud-display-frame) |
| 2538 | (recenter arg)) | 2541 | (recenter arg)) |
| 2539 | 2542 | ||
| 2540 | ;;; Code for parsing expressions out of C code. The single entry point is | 2543 | ;; Code for parsing expressions out of C code. The single entry point is |
| 2541 | ;;; find-c-expr, which tries to return an lvalue expression from around point. | 2544 | ;; find-c-expr, which tries to return an lvalue expression from around point. |
| 2542 | ;;; | 2545 | ;; |
| 2543 | ;;; The rest of this file is a hacked version of gdbsrc.el by | 2546 | ;; The rest of this file is a hacked version of gdbsrc.el by |
| 2544 | ;;; Debby Ayers <ayers@asc.slb.com>, | 2547 | ;; Debby Ayers <ayers@asc.slb.com>, |
| 2545 | ;;; Rich Schaefer <schaefer@asc.slb.com> Schlumberger, Austin, Tx. | 2548 | ;; Rich Schaefer <schaefer@asc.slb.com> Schlumberger, Austin, Tx. |
| 2546 | 2549 | ||
| 2547 | (defun gud-find-c-expr () | 2550 | (defun gud-find-c-expr () |
| 2548 | "Returns the C expr that surrounds point." | 2551 | "Returns the C expr that surrounds point." |