diff options
| author | Stefan Monnier | 2002-12-03 21:07:39 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2002-12-03 21:07:39 +0000 |
| commit | b94a30018ea5b7bdf9f6d254a97cc2b0152a8b38 (patch) | |
| tree | 0a351a8ddc27c3f93bf02daebfcb50d9b1388b5a | |
| parent | 02d588e2360faec87e6ac970dc7c6ad04432f8d0 (diff) | |
| download | emacs-b94a30018ea5b7bdf9f6d254a97cc2b0152a8b38.tar.gz emacs-b94a30018ea5b7bdf9f6d254a97cc2b0152a8b38.zip | |
(gud-running): Rename from gdb-running. Update uses.
(gud-tool-bar-map): Use tool-bar-local-item-from-menu rather than
tool-bar-add-item-from-menu to avoid let binding tool-bar-map
which fails if tool-bar.el is loaded in the mean time.
(gud-file-name): New fun.
(gud-find-file): Use it as default value for gud-find-file.
(gud-speedbar-buttons): Discriminate on gud-minor-mode rather than
on gud-find-file.
(gud-gdb-find-file, gud-dbx-file-name, gud-dbx-find-file)
(gud-xdb-file-name, gud-xdb-find-file, gud-perldb-find-file)
(gud-pdb-find-file, gud-jdb-find-file): Remove.
(gud-query-cmdline): Don't stuff the whole cwd in the command.
(gdb, dbx, xdb, perldb, pdb, jdb): Use the default for gud-find-file.
(gud-mipsdbx-massage-args): Remove.
(gud-dbx-command-name): New var. Do what gud-mipsdbx-massage-args did.
(gud-irixdbx-marker-filter): Use match-string and gud-file-name.
(gud-jdb-command-name): New var.
(gud-common-init): Re-instate RMS code of 11/13.
| -rw-r--r-- | lisp/gud.el | 195 |
1 files changed, 79 insertions, 116 deletions
diff --git a/lisp/gud.el b/lisp/gud.el index 08f1c20f820..4deae7a4e05 100644 --- a/lisp/gud.el +++ b/lisp/gud.el | |||
| @@ -85,44 +85,45 @@ If SOFT is non-nil, returns nil if the symbol doesn't already exist." | |||
| 85 | (let ((sym (gud-symbol sym t minor-mode))) | 85 | (let ((sym (gud-symbol sym t minor-mode))) |
| 86 | (if (boundp sym) (symbol-value sym)))) | 86 | (if (boundp sym) (symbol-value sym)))) |
| 87 | 87 | ||
| 88 | (defvar gdb-running nil "Used by gdba only. Non-nil if debuggee is running | 88 | (defvar gud-running nil |
| 89 | so that the relevant toolbar icons are greyed out.") | 89 | "Non-nil if debuggee is running. |
| 90 | Used to grey out relevant toolbar icons.") | ||
| 90 | 91 | ||
| 91 | (easy-mmode-defmap gud-menu-map | 92 | (easy-mmode-defmap gud-menu-map |
| 92 | '(([refresh] "Refresh" . gud-refresh) | 93 | '(([refresh] "Refresh" . gud-refresh) |
| 93 | ([run] menu-item "Run" gud-run | 94 | ([run] menu-item "Run" gud-run |
| 94 | :enable (and (not gdb-running) | 95 | :enable (and (not gud-running) |
| 95 | (memq gud-minor-mode '(gdba gdb)))) | 96 | (memq gud-minor-mode '(gdba gdb)))) |
| 96 | ([goto] menu-item "Continue to selection" gud-goto | 97 | ([goto] menu-item "Continue to selection" gud-goto |
| 97 | :enable (and (not gdb-running) | 98 | :enable (and (not gud-running) |
| 98 | (memq gud-minor-mode '(gdba gdb)))) | 99 | (memq gud-minor-mode '(gdba gdb)))) |
| 99 | ([remove] menu-item "Remove Breakpoint" gud-remove | 100 | ([remove] menu-item "Remove Breakpoint" gud-remove |
| 100 | :enable (not gdb-running)) | 101 | :enable (not gud-running)) |
| 101 | ([tbreak] menu-item "Temporary Breakpoint" gud-tbreak | 102 | ([tbreak] menu-item "Temporary Breakpoint" gud-tbreak |
| 102 | :enable (memq gud-minor-mode '(gdba gdb sdb xdb))) | 103 | :enable (memq gud-minor-mode '(gdba gdb sdb xdb))) |
| 103 | ([break] menu-item "Set Breakpoint" gud-break | 104 | ([break] menu-item "Set Breakpoint" gud-break |
| 104 | :enable (not gdb-running)) | 105 | :enable (not gud-running)) |
| 105 | ([up] menu-item "Up Stack" gud-up | 106 | ([up] menu-item "Up Stack" gud-up |
| 106 | :enable (and (not gdb-running) | 107 | :enable (and (not gud-running) |
| 107 | (memq gud-minor-mode '(gdba gdb dbx xdb jdb)))) | 108 | (memq gud-minor-mode '(gdba gdb dbx xdb jdb)))) |
| 108 | ([down] menu-item "Down Stack" gud-down | 109 | ([down] menu-item "Down Stack" gud-down |
| 109 | :enable (and (not gdb-running) | 110 | :enable (and (not gud-running) |
| 110 | (memq gud-minor-mode '(gdba gdb dbx xdb jdb)))) | 111 | (memq gud-minor-mode '(gdba gdb dbx xdb jdb)))) |
| 111 | ([print] menu-item "Print Expression" gud-print | 112 | ([print] menu-item "Print Expression" gud-print |
| 112 | :enable (not gdb-running)) | 113 | :enable (not gud-running)) |
| 113 | ([display] menu-item "Display Expression" gud-display | 114 | ([display] menu-item "Display Expression" gud-display |
| 114 | :enable (and (not gdb-running) | 115 | :enable (and (not gud-running) |
| 115 | (eq gud-minor-mode 'gdba))) | 116 | (eq gud-minor-mode 'gdba))) |
| 116 | ([finish] menu-item "Finish Function" gud-finish | 117 | ([finish] menu-item "Finish Function" gud-finish |
| 117 | :enable (and (not gdb-running) | 118 | :enable (and (not gud-running) |
| 118 | (memq gud-minor-mode '(gdba gdb xdb jdb)))) | 119 | (memq gud-minor-mode '(gdba gdb xdb jdb)))) |
| 119 | ([stepi] "Step Instruction" . gud-stepi) | 120 | ([stepi] "Step Instruction" . gud-stepi) |
| 120 | ([step] menu-item "Step Line" gud-step | 121 | ([step] menu-item "Step Line" gud-step |
| 121 | :enable (not gdb-running)) | 122 | :enable (not gud-running)) |
| 122 | ([next] menu-item "Next Line" gud-next | 123 | ([next] menu-item "Next Line" gud-next |
| 123 | :enable (not gdb-running)) | 124 | :enable (not gud-running)) |
| 124 | ([cont] menu-item "Continue" gud-cont | 125 | ([cont] menu-item "Continue" gud-cont |
| 125 | :enable (not gdb-running))) | 126 | :enable (not gud-running))) |
| 126 | "Menu for `gud-mode'." | 127 | "Menu for `gud-mode'." |
| 127 | :name "Gud") | 128 | :name "Gud") |
| 128 | 129 | ||
| @@ -141,28 +142,45 @@ so that the relevant toolbar icons are greyed out.") | |||
| 141 | 142 | ||
| 142 | (defvar gud-tool-bar-map | 143 | (defvar gud-tool-bar-map |
| 143 | (if (display-graphic-p) | 144 | (if (display-graphic-p) |
| 144 | (let ((tool-bar-map (make-sparse-keymap))) | 145 | (let ((map (make-sparse-keymap))) |
| 145 | (tool-bar-add-item-from-menu 'gud-break "gud-break" gud-minor-mode-map) | 146 | (dolist (x '((gud-break . "gud-break") |
| 146 | (tool-bar-add-item-from-menu 'gud-remove "gud-remove" gud-minor-mode-map) | 147 | (gud-remove . "gud-remove") |
| 147 | (tool-bar-add-item-from-menu 'gud-print "gud-print" gud-minor-mode-map) | 148 | (gud-print . "gud-print") |
| 148 | (tool-bar-add-item-from-menu 'gud-display "gud-display" | 149 | (gud-display . "gud-display") |
| 149 | gud-minor-mode-map) | 150 | (gud-run . "gud-run") |
| 150 | (tool-bar-add-item-from-menu 'gud-run "gud-run" gud-minor-mode-map) | 151 | (gud-goto . "gud-goto") |
| 151 | (tool-bar-add-item-from-menu 'gud-goto "gud-goto" gud-minor-mode-map) | 152 | (gud-cont . "gud-cont") |
| 152 | (tool-bar-add-item-from-menu 'gud-cont "gud-cont" gud-minor-mode-map) | 153 | (gud-step . "gud-step") |
| 153 | (tool-bar-add-item-from-menu 'gud-step "gud-step" gud-minor-mode-map) | 154 | (gud-next . "gud-next") |
| 154 | (tool-bar-add-item-from-menu 'gud-next "gud-next" gud-minor-mode-map) | 155 | (gud-finish . "gud-finish") |
| 155 | (tool-bar-add-item-from-menu 'gud-finish "gud-finish" gud-minor-mode-map) | 156 | (gud-up . "gud-up") |
| 156 | (tool-bar-add-item-from-menu 'gud-up "gud-up" gud-minor-mode-map) | 157 | (gud-down . "gud-down")) |
| 157 | (tool-bar-add-item-from-menu 'gud-down "gud-down" gud-minor-mode-map) | 158 | map) |
| 158 | tool-bar-map))) | 159 | (tool-bar-local-item-from-menu |
| 160 | (car x) (cdr x) map gud-minor-mode-map))))) | ||
| 161 | |||
| 162 | (defun gud-file-name (f) | ||
| 163 | "Transform a relative file name to an absolute file name. | ||
| 164 | Uses `gud-<MINOR-MODE>-directories' to find the source files." | ||
| 165 | (if (file-exists-p f) (expand-file-name f) | ||
| 166 | (let ((directories (gud-val 'directories)) | ||
| 167 | (result nil)) | ||
| 168 | (while directories | ||
| 169 | (let ((path (expand-file-name f (car directories)))) | ||
| 170 | (if (file-exists-p path) | ||
| 171 | (setq result path | ||
| 172 | directories nil))) | ||
| 173 | (setq directories (cdr directories))) | ||
| 174 | result))) | ||
| 159 | 175 | ||
| 160 | (defun gud-find-file (file) | 176 | (defun gud-find-file (file) |
| 161 | ;; Don't get confused by double slashes in the name that comes from GDB. | 177 | ;; Don't get confused by double slashes in the name that comes from GDB. |
| 162 | (while (string-match "//+" file) | 178 | (while (string-match "//+" file) |
| 163 | (setq file (replace-match "/" t t file))) | 179 | (setq file (replace-match "/" t t file))) |
| 164 | (let ((minor-mode gud-minor-mode) | 180 | (let ((minor-mode gud-minor-mode) |
| 165 | (buf (funcall gud-find-file file))) | 181 | (buf (funcall (or gud-find-file 'gud-file-name) file))) |
| 182 | (when (stringp buf) | ||
| 183 | (setq buf (and (file-readable-p buf) (find-file-noselect buf 'nowarn)))) | ||
| 166 | (when buf | 184 | (when buf |
| 167 | ;; Copy `gud-minor-mode' to the found buffer to turn on the menu. | 185 | ;; Copy `gud-minor-mode' to the found buffer to turn on the menu. |
| 168 | (with-current-buffer buf | 186 | (with-current-buffer buf |
| @@ -295,12 +313,10 @@ off the specialized speedbar mode." | |||
| 295 | (equal gud-last-last-frame gud-last-speedbar-stackframe)) | 313 | (equal gud-last-last-frame gud-last-speedbar-stackframe)) |
| 296 | nil | 314 | nil |
| 297 | (setq gud-last-speedbar-buffer buffer) | 315 | (setq gud-last-speedbar-buffer buffer) |
| 298 | (let* ((ff (save-excursion (set-buffer buffer) gud-find-file)) | 316 | (let* ((minor-mode (with-current-buffer buffer gud-minor-mode)) |
| 299 | ;;(lf (save-excursion (set-buffer buffer) gud-last-last-frame)) | ||
| 300 | (frames | 317 | (frames |
| 301 | (cond ((eq ff 'gud-gdb-find-file) | 318 | (cond ((memq minor-mode '(gdba gdb)) |
| 302 | (gud-gdb-get-stackframe buffer) | 319 | (gud-gdb-get-stackframe buffer)) |
| 303 | ) | ||
| 304 | ;; Add more debuggers here! | 320 | ;; Add more debuggers here! |
| 305 | (t | 321 | (t |
| 306 | (speedbar-remove-localized-speedbar-support buffer) | 322 | (speedbar-remove-localized-speedbar-support buffer) |
| @@ -327,7 +343,7 @@ off the specialized speedbar mode." | |||
| 327 | (speedbar-insert-button (car (car frames)) | 343 | (speedbar-insert-button (car (car frames)) |
| 328 | 'speedbar-file-face | 344 | 'speedbar-file-face |
| 329 | 'speedbar-highlight-face | 345 | 'speedbar-highlight-face |
| 330 | (cond ((eq ff 'gud-gdb-find-file) | 346 | (cond ((memq minor-mode '(gdba gdb)) |
| 331 | 'gud-gdb-goto-stackframe) | 347 | 'gud-gdb-goto-stackframe) |
| 332 | (t (error "Should never be here"))) | 348 | (t (error "Should never be here"))) |
| 333 | (car frames) t)) | 349 | (car frames) t)) |
| @@ -410,9 +426,6 @@ off the specialized speedbar mode." | |||
| 410 | 426 | ||
| 411 | output)) | 427 | output)) |
| 412 | 428 | ||
| 413 | (defun gud-gdb-find-file (f) | ||
| 414 | (find-file-noselect f 'nowarn)) | ||
| 415 | |||
| 416 | (easy-mmode-defmap gud-minibuffer-local-map | 429 | (easy-mmode-defmap gud-minibuffer-local-map |
| 417 | '(("\C-i" . comint-dynamic-complete-filename)) | 430 | '(("\C-i" . comint-dynamic-complete-filename)) |
| 418 | "Keymap for minibuffer prompting of gud startup command." | 431 | "Keymap for minibuffer prompting of gud startup command." |
| @@ -426,7 +439,7 @@ off the specialized speedbar mode." | |||
| 426 | (format "Run %s (like this): " minor-mode) | 439 | (format "Run %s (like this): " minor-mode) |
| 427 | (or (car-safe (symbol-value hist-sym)) | 440 | (or (car-safe (symbol-value hist-sym)) |
| 428 | (concat (or cmd-name (symbol-name minor-mode)) | 441 | (concat (or cmd-name (symbol-name minor-mode)) |
| 429 | " " default-directory | 442 | " " |
| 430 | (or init | 443 | (or init |
| 431 | (let ((file nil)) | 444 | (let ((file nil)) |
| 432 | (dolist (f (directory-files default-directory) file) | 445 | (dolist (f (directory-files default-directory) file) |
| @@ -445,8 +458,7 @@ The directory containing FILE becomes the initial working directory | |||
| 445 | and source-file directory for your debugger." | 458 | and source-file directory for your debugger." |
| 446 | (interactive (list (gud-query-cmdline 'gdb))) | 459 | (interactive (list (gud-query-cmdline 'gdb))) |
| 447 | 460 | ||
| 448 | (gud-common-init command-line nil | 461 | (gud-common-init command-line nil 'gud-gdb-marker-filter) |
| 449 | 'gud-gdb-marker-filter 'gud-gdb-find-file) | ||
| 450 | (set (make-local-variable 'gud-minor-mode) 'gdb) | 462 | (set (make-local-variable 'gud-minor-mode) 'gdb) |
| 451 | 463 | ||
| 452 | (gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.") | 464 | (gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.") |
| @@ -749,8 +761,7 @@ and source-file directory for your debugger." | |||
| 749 | (file-exists-p tags-file-name)))) | 761 | (file-exists-p tags-file-name)))) |
| 750 | (error "The sdb support requires a valid tags table to work")) | 762 | (error "The sdb support requires a valid tags table to work")) |
| 751 | 763 | ||
| 752 | (gud-common-init command-line nil | 764 | (gud-common-init command-line nil 'gud-sdb-marker-filter 'gud-sdb-find-file) |
| 753 | 'gud-sdb-marker-filter 'gud-sdb-find-file) | ||
| 754 | (set (make-local-variable 'gud-minor-mode) 'sdb) | 765 | (set (make-local-variable 'gud-minor-mode) 'sdb) |
| 755 | 766 | ||
| 756 | (gud-def gud-break "%l b" "\C-b" "Set breakpoint at current line.") | 767 | (gud-def gud-break "%l b" "\C-b" "Set breakpoint at current line.") |
| @@ -796,20 +807,6 @@ containing the executable being debugged." | |||
| 796 | (nreverse result)) | 807 | (nreverse result)) |
| 797 | args)) | 808 | args)) |
| 798 | 809 | ||
| 799 | (defun gud-dbx-file-name (f) | ||
| 800 | "Transform a relative file name to an absolute file name, for dbx." | ||
| 801 | (let ((result nil)) | ||
| 802 | (if (file-exists-p f) | ||
| 803 | (setq result (expand-file-name f)) | ||
| 804 | (let ((directories gud-dbx-directories)) | ||
| 805 | (while directories | ||
| 806 | (let ((path (concat (car directories) "/" f))) | ||
| 807 | (if (file-exists-p path) | ||
| 808 | (setq result (expand-file-name path) | ||
| 809 | directories nil))) | ||
| 810 | (setq directories (cdr directories))))) | ||
| 811 | result)) | ||
| 812 | |||
| 813 | (defun gud-dbx-marker-filter (string) | 810 | (defun gud-dbx-marker-filter (string) |
| 814 | (setq gud-marker-acc (if gud-marker-acc (concat gud-marker-acc string) string)) | 811 | (setq gud-marker-acc (if gud-marker-acc (concat gud-marker-acc string) string)) |
| 815 | 812 | ||
| @@ -852,8 +849,8 @@ containing the executable being debugged." | |||
| 852 | (string-match "^alpha[^-]*-[^-]*-osf" system-configuration)) | 849 | (string-match "^alpha[^-]*-[^-]*-osf" system-configuration)) |
| 853 | "Non-nil to assume the MIPS/OSF dbx conventions (argument `-emacs').") | 850 | "Non-nil to assume the MIPS/OSF dbx conventions (argument `-emacs').") |
| 854 | 851 | ||
| 855 | (defun gud-mipsdbx-massage-args (file args) | 852 | (defvar gud-dbx-command-name |
| 856 | (cons "-emacs" args)) | 853 | (concat "dbx" (if gud-mips-p " -emacs"))) |
| 857 | 854 | ||
| 858 | ;; This is just like the gdb one except for the regexps since we need to cope | 855 | ;; This is just like the gdb one except for the regexps since we need to cope |
| 859 | ;; with an optional breakpoint number in [] before the ^Z^Z | 856 | ;; with an optional breakpoint number in [] before the ^Z^Z |
| @@ -991,15 +988,13 @@ a better solution in 6.1 upwards.") | |||
| 991 | result) | 988 | result) |
| 992 | ((string-match ; kluged-up marker as above | 989 | ((string-match ; kluged-up marker as above |
| 993 | "\032\032\\([0-9]*\\):\\(.*\\)\n" result) | 990 | "\032\032\\([0-9]*\\):\\(.*\\)\n" result) |
| 994 | (let ((file (gud-dbx-file-name | 991 | (let ((file (gud-file-name (match-string 2 result)))) |
| 995 | (substring result (match-beginning 2) (match-end 2))))) | ||
| 996 | (if (and file (file-exists-p file)) | 992 | (if (and file (file-exists-p file)) |
| 997 | (setq gud-last-frame | 993 | (setq gud-last-frame |
| 998 | (cons | 994 | (cons |
| 999 | file | 995 | file |
| 1000 | (string-to-int | 996 | (string-to-int |
| 1001 | (substring | 997 | (match-string 1 result)))))) |
| 1002 | result (match-beginning 1) (match-end 1))))))) | ||
| 1003 | (setq result (substring result 0 (match-beginning 0)))))) | 998 | (setq result (substring result 0 (match-beginning 0)))))) |
| 1004 | (or result ""))) | 999 | (or result ""))) |
| 1005 | 1000 | ||
| @@ -1054,12 +1049,6 @@ This was tested using R4.11.") | |||
| 1054 | nil))) | 1049 | nil))) |
| 1055 | string) | 1050 | string) |
| 1056 | 1051 | ||
| 1057 | (defun gud-dbx-find-file (f) | ||
| 1058 | (save-excursion | ||
| 1059 | (let ((realf (gud-dbx-file-name f))) | ||
| 1060 | (if realf | ||
| 1061 | (find-file-noselect realf))))) | ||
| 1062 | |||
| 1063 | ;;;###autoload | 1052 | ;;;###autoload |
| 1064 | (defun dbx (command-line) | 1053 | (defun dbx (command-line) |
| 1065 | "Run dbx on program FILE in buffer *gud-FILE*. | 1054 | "Run dbx on program FILE in buffer *gud-FILE*. |
| @@ -1069,17 +1058,16 @@ and source-file directory for your debugger." | |||
| 1069 | 1058 | ||
| 1070 | (cond | 1059 | (cond |
| 1071 | (gud-mips-p | 1060 | (gud-mips-p |
| 1072 | (gud-common-init command-line 'gud-mipsdbx-massage-args | 1061 | (gud-common-init command-line nil 'gud-mipsdbx-marker-filter)) |
| 1073 | 'gud-mipsdbx-marker-filter 'gud-dbx-find-file)) | ||
| 1074 | (gud-irix-p | 1062 | (gud-irix-p |
| 1075 | (gud-common-init command-line 'gud-dbx-massage-args | 1063 | (gud-common-init command-line 'gud-dbx-massage-args |
| 1076 | 'gud-irixdbx-marker-filter 'gud-dbx-find-file)) | 1064 | 'gud-irixdbx-marker-filter)) |
| 1077 | (gud-dgux-p | 1065 | (gud-dgux-p |
| 1078 | (gud-common-init command-line 'gud-dbx-massage-args | 1066 | (gud-common-init command-line 'gud-dbx-massage-args |
| 1079 | 'gud-dguxdbx-marker-filter 'gud-dbx-find-file)) | 1067 | 'gud-dguxdbx-marker-filter)) |
| 1080 | (t | 1068 | (t |
| 1081 | (gud-common-init command-line 'gud-dbx-massage-args | 1069 | (gud-common-init command-line 'gud-dbx-massage-args |
| 1082 | 'gud-dbx-marker-filter 'gud-dbx-find-file))) | 1070 | 'gud-dbx-marker-filter))) |
| 1083 | 1071 | ||
| 1084 | (set (make-local-variable 'gud-minor-mode) 'dbx) | 1072 | (set (make-local-variable 'gud-minor-mode) 'dbx) |
| 1085 | 1073 | ||
| @@ -1151,20 +1139,6 @@ containing the executable being debugged." | |||
| 1151 | (nreverse result)) | 1139 | (nreverse result)) |
| 1152 | args)) | 1140 | args)) |
| 1153 | 1141 | ||
| 1154 | (defun gud-xdb-file-name (f) | ||
| 1155 | "Transform a relative pathname to a full pathname in xdb mode" | ||
| 1156 | (let ((result nil)) | ||
| 1157 | (if (file-exists-p f) | ||
| 1158 | (setq result (expand-file-name f)) | ||
| 1159 | (let ((directories gud-xdb-directories)) | ||
| 1160 | (while directories | ||
| 1161 | (let ((path (concat (car directories) "/" f))) | ||
| 1162 | (if (file-exists-p path) | ||
| 1163 | (setq result (expand-file-name path) | ||
| 1164 | directories nil))) | ||
| 1165 | (setq directories (cdr directories))))) | ||
| 1166 | result)) | ||
| 1167 | |||
| 1168 | ;; xdb does not print the lines all at once, so we have to accumulate them | 1142 | ;; xdb does not print the lines all at once, so we have to accumulate them |
| 1169 | (defun gud-xdb-marker-filter (string) | 1143 | (defun gud-xdb-marker-filter (string) |
| 1170 | (let (result) | 1144 | (let (result) |
| @@ -1176,20 +1150,14 @@ containing the executable being debugged." | |||
| 1176 | (if result | 1150 | (if result |
| 1177 | (if (or (string-match "\\([^\n \t:]+\\): [^:]+: \\([0-9]+\\)[: ]" | 1151 | (if (or (string-match "\\([^\n \t:]+\\): [^:]+: \\([0-9]+\\)[: ]" |
| 1178 | result) | 1152 | result) |
| 1179 | (string-match "[^: \t]+:[ \t]+\\([^:]+\\): [^:]+: \\([0-9]+\\):" | 1153 | (string-match "[^: \t]+:[ \t]+\\([^:]+\\): [^:]+: \\([0-9]+\\):" |
| 1180 | result)) | 1154 | result)) |
| 1181 | (let ((line (string-to-int (match-string 2 result))) | 1155 | (let ((line (string-to-int (match-string 2 result))) |
| 1182 | (file (gud-xdb-file-name (match-string 1 result)))) | 1156 | (file (gud-file-name (match-string 1 result)))) |
| 1183 | (if file | 1157 | (if file |
| 1184 | (setq gud-last-frame (cons file line)))))) | 1158 | (setq gud-last-frame (cons file line)))))) |
| 1185 | (or result ""))) | 1159 | (or result ""))) |
| 1186 | 1160 | ||
| 1187 | (defun gud-xdb-find-file (f) | ||
| 1188 | (save-excursion | ||
| 1189 | (let ((realf (gud-xdb-file-name f))) | ||
| 1190 | (if realf | ||
| 1191 | (find-file-noselect realf))))) | ||
| 1192 | |||
| 1193 | ;;;###autoload | 1161 | ;;;###autoload |
| 1194 | (defun xdb (command-line) | 1162 | (defun xdb (command-line) |
| 1195 | "Run xdb on program FILE in buffer *gud-FILE*. | 1163 | "Run xdb on program FILE in buffer *gud-FILE*. |
| @@ -1201,7 +1169,7 @@ directories if your program contains sources from more than one directory." | |||
| 1201 | (interactive (list (gud-query-cmdline 'xdb))) | 1169 | (interactive (list (gud-query-cmdline 'xdb))) |
| 1202 | 1170 | ||
| 1203 | (gud-common-init command-line 'gud-xdb-massage-args | 1171 | (gud-common-init command-line 'gud-xdb-massage-args |
| 1204 | 'gud-xdb-marker-filter 'gud-xdb-find-file) | 1172 | 'gud-xdb-marker-filter) |
| 1205 | (set (make-local-variable 'gud-minor-mode) 'xdb) | 1173 | (set (make-local-variable 'gud-minor-mode) 'xdb) |
| 1206 | 1174 | ||
| 1207 | (gud-def gud-break "b %f:%l" "\C-b" "Set breakpoint at current line.") | 1175 | (gud-def gud-break "b %f:%l" "\C-b" "Set breakpoint at current line.") |
| @@ -1322,9 +1290,6 @@ into one that invokes an Emacs-enabled debugging session. | |||
| 1322 | 1290 | ||
| 1323 | output)) | 1291 | output)) |
| 1324 | 1292 | ||
| 1325 | (defun gud-perldb-find-file (f) | ||
| 1326 | (find-file-noselect f)) | ||
| 1327 | |||
| 1328 | (defcustom gud-perldb-command-name "perl -d" | 1293 | (defcustom gud-perldb-command-name "perl -d" |
| 1329 | "Default command to execute a Perl script under debugger." | 1294 | "Default command to execute a Perl script under debugger." |
| 1330 | :type 'string | 1295 | :type 'string |
| @@ -1340,7 +1305,7 @@ and source-file directory for your debugger." | |||
| 1340 | (concat (or (buffer-file-name) "-e 0") " ")))) | 1305 | (concat (or (buffer-file-name) "-e 0") " ")))) |
| 1341 | 1306 | ||
| 1342 | (gud-common-init command-line 'gud-perldb-massage-args | 1307 | (gud-common-init command-line 'gud-perldb-massage-args |
| 1343 | 'gud-perldb-marker-filter 'gud-perldb-find-file) | 1308 | 'gud-perldb-marker-filter) |
| 1344 | (set (make-local-variable 'gud-minor-mode) 'perldb) | 1309 | (set (make-local-variable 'gud-minor-mode) 'perldb) |
| 1345 | 1310 | ||
| 1346 | (gud-def gud-break "b %l" "\C-b" "Set breakpoint at current line.") | 1311 | (gud-def gud-break "b %l" "\C-b" "Set breakpoint at current line.") |
| @@ -1428,9 +1393,6 @@ and source-file directory for your debugger." | |||
| 1428 | 1393 | ||
| 1429 | output)) | 1394 | output)) |
| 1430 | 1395 | ||
| 1431 | (defun gud-pdb-find-file (f) | ||
| 1432 | (find-file-noselect f)) | ||
| 1433 | |||
| 1434 | (defcustom gud-pdb-command-name "pdb" | 1396 | (defcustom gud-pdb-command-name "pdb" |
| 1435 | "File name for executing the Python debugger. | 1397 | "File name for executing the Python debugger. |
| 1436 | This should be an executable on your path, or an absolute file name." | 1398 | This should be an executable on your path, or an absolute file name." |
| @@ -1445,8 +1407,7 @@ and source-file directory for your debugger." | |||
| 1445 | (interactive | 1407 | (interactive |
| 1446 | (list (gud-query-cmdline 'pdb))) | 1408 | (list (gud-query-cmdline 'pdb))) |
| 1447 | 1409 | ||
| 1448 | (gud-common-init command-line nil | 1410 | (gud-common-init command-line nil 'gud-pdb-marker-filter) |
| 1449 | 'gud-pdb-marker-filter 'gud-pdb-find-file) | ||
| 1450 | (set (make-local-variable 'gud-minor-mode) 'pdb) | 1411 | (set (make-local-variable 'gud-minor-mode) 'pdb) |
| 1451 | 1412 | ||
| 1452 | (gud-def gud-break "break %l" "\C-b" "Set breakpoint at current line.") | 1413 | (gud-def gud-break "break %l" "\C-b" "Set breakpoint at current line.") |
| @@ -2066,9 +2027,7 @@ nil) | |||
| 2066 | ;; We don't filter any debugger output so just return what we were given. | 2027 | ;; We don't filter any debugger output so just return what we were given. |
| 2067 | string) | 2028 | string) |
| 2068 | 2029 | ||
| 2069 | (defun gud-jdb-find-file (f) | 2030 | (defvar gud-jdb-command-name "jdb" "Command that executes the Java debugger.") |
| 2070 | (and (file-readable-p f) | ||
| 2071 | (find-file-noselect f))) | ||
| 2072 | 2031 | ||
| 2073 | ;;;###autoload | 2032 | ;;;###autoload |
| 2074 | (defun jdb (command-line) | 2033 | (defun jdb (command-line) |
| @@ -2098,7 +2057,7 @@ gud, see `gud-mode'." | |||
| 2098 | (setq gud-jdb-classpath-string nil) ; prepare for next | 2057 | (setq gud-jdb-classpath-string nil) ; prepare for next |
| 2099 | 2058 | ||
| 2100 | (gud-common-init command-line 'gud-jdb-massage-args | 2059 | (gud-common-init command-line 'gud-jdb-massage-args |
| 2101 | 'gud-jdb-marker-filter 'gud-jdb-find-file) | 2060 | 'gud-jdb-marker-filter) |
| 2102 | (set (make-local-variable 'gud-minor-mode) 'jdb) | 2061 | (set (make-local-variable 'gud-minor-mode) 'jdb) |
| 2103 | 2062 | ||
| 2104 | ;; If a -classpath option was provided, set gud-jdb-classpath | 2063 | ;; If a -classpath option was provided, set gud-jdb-classpath |
| @@ -2273,9 +2232,11 @@ comint mode, which see." | |||
| 2273 | ;; which starts with the program to debug. | 2232 | ;; which starts with the program to debug. |
| 2274 | ;; The other three args specify the values to use | 2233 | ;; The other three args specify the values to use |
| 2275 | ;; for local variables in the debugger buffer. | 2234 | ;; for local variables in the debugger buffer. |
| 2276 | (defun gud-common-init (command-line massage-args marker-filter &optional find-file) | 2235 | (defun gud-common-init (command-line massage-args marker-filter |
| 2236 | &optional find-file) | ||
| 2277 | (let* ((words (split-string command-line)) | 2237 | (let* ((words (split-string command-line)) |
| 2278 | (program (car words)) | 2238 | (program (car words)) |
| 2239 | (dir default-directory) | ||
| 2279 | ;; Extract the file name from WORDS | 2240 | ;; Extract the file name from WORDS |
| 2280 | ;; and put t in its place. | 2241 | ;; and put t in its place. |
| 2281 | ;; Later on we will put the modified file name arg back there. | 2242 | ;; Later on we will put the modified file name arg back there. |
| @@ -2299,6 +2260,8 @@ comint mode, which see." | |||
| 2299 | file-subst))) | 2260 | file-subst))) |
| 2300 | (filepart (and file-word (concat "-" (file-name-nondirectory file))))) | 2261 | (filepart (and file-word (concat "-" (file-name-nondirectory file))))) |
| 2301 | (pop-to-buffer (concat "*gud" filepart "*")) | 2262 | (pop-to-buffer (concat "*gud" filepart "*")) |
| 2263 | ;; Set the dir, in case the buffer already existed with a different dir. | ||
| 2264 | (setq default-directory dir) | ||
| 2302 | ;; Set default-directory to the file's directory. | 2265 | ;; Set default-directory to the file's directory. |
| 2303 | (and file-word | 2266 | (and file-word |
| 2304 | gud-chdir-before-run | 2267 | gud-chdir-before-run |