Mercurial > emacs
comparison lisp/gud.el @ 48638:fff05c8f251d
(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.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 03 Dec 2002 21:07:39 +0000 |
parents | 0513d8116258 |
children | 81f6fbdaa117 |
comparison
equal
deleted
inserted
replaced
48637:1915f224ca37 | 48638:fff05c8f251d |
---|---|
83 (defun gud-val (sym &optional minor-mode) | 83 (defun gud-val (sym &optional minor-mode) |
84 "Return the value of `gud-symbol' SYM. Default to nil." | 84 "Return the value of `gud-symbol' SYM. Default to nil." |
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 |
129 (easy-mmode-defmap gud-minor-mode-map | 130 (easy-mmode-defmap gud-minor-mode-map |
130 `(([menu-bar debug] . ("Gud" . ,gud-menu-map))) | 131 `(([menu-bar debug] . ("Gud" . ,gud-menu-map))) |
139 (make-sparse-keymap) | 140 (make-sparse-keymap) |
140 "`gud-mode' keymap.") | 141 "`gud-mode' keymap.") |
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 |
169 (set (make-local-variable 'gud-minor-mode) minor-mode) | 187 (set (make-local-variable 'gud-minor-mode) minor-mode) |
170 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)) | 188 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)) |
293 (if (and (save-excursion (goto-char (point-min)) | 311 (if (and (save-excursion (goto-char (point-min)) |
294 (looking-at "Current Stack")) | 312 (looking-at "Current Stack")) |
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) |
307 nil)))) | 323 nil)))) |
308 (erase-buffer) | 324 (erase-buffer) |
325 ; 'gud-gdb-get-scope-data | 341 ; 'gud-gdb-get-scope-data |
326 ; (car frames) t) | 342 ; (car frames) t) |
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)) |
334 (setq frames (cdr frames))) | 350 (setq frames (cdr frames))) |
335 ; (let ((selected-frame | 351 ; (let ((selected-frame |
408 (setq output (concat output gud-marker-acc) | 424 (setq output (concat output gud-marker-acc) |
409 gud-marker-acc "")) | 425 gud-marker-acc "")) |
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." |
419 :inherit minibuffer-local-map) | 432 :inherit minibuffer-local-map) |
420 | 433 |
424 (unless (boundp hist-sym) (set hist-sym nil)) | 437 (unless (boundp hist-sym) (set hist-sym nil)) |
425 (read-from-minibuffer | 438 (read-from-minibuffer |
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) |
433 (if (and (file-executable-p f) | 446 (if (and (file-executable-p f) |
434 (not (file-directory-p f)) | 447 (not (file-directory-p f)) |
443 "Run gdb on program FILE in buffer *gud-FILE*. | 456 "Run gdb on program FILE in buffer *gud-FILE*. |
444 The directory containing FILE becomes the initial working directory | 457 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.") |
453 (gud-def gud-tbreak "tbreak %f:%l" "\C-t" "Set temporary breakpoint at current line.") | 465 (gud-def gud-tbreak "tbreak %f:%l" "\C-t" "Set temporary breakpoint at current line.") |
454 (gud-def gud-remove "clear %f:%l" "\C-d" "Remove breakpoint at current line") | 466 (gud-def gud-remove "clear %f:%l" "\C-d" "Remove breakpoint at current line") |
747 (not (and (boundp 'tags-file-name) | 759 (not (and (boundp 'tags-file-name) |
748 (stringp tags-file-name) | 760 (stringp tags-file-name) |
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.") |
757 (gud-def gud-tbreak "%l c" "\C-t" "Set temporary breakpoint at current line.") | 768 (gud-def gud-tbreak "%l c" "\C-t" "Set temporary breakpoint at current line.") |
758 (gud-def gud-remove "%l d" "\C-d" "Remove breakpoint at current line") | 769 (gud-def gud-remove "%l d" "\C-d" "Remove breakpoint at current line") |
793 (while directories | 804 (while directories |
794 (setq result (cons (car directories) (cons "-I" result))) | 805 (setq result (cons (car directories) (cons "-I" result))) |
795 (setq directories (cdr directories))) | 806 (setq directories (cdr directories))) |
796 (nreverse result)) | 807 (nreverse result)) |
797 args)) | 808 args)) |
798 | |
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 | 809 |
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 |
816 (let (start) | 813 (let (start) |
850 ;; It's documented on OSF/1.3 | 847 ;; It's documented on OSF/1.3 |
851 (string-match "^mips-[^-]*-osf1" system-configuration) | 848 (string-match "^mips-[^-]*-osf1" system-configuration) |
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 |
860 (defun gud-mipsdbx-marker-filter (string) | 857 (defun gud-mipsdbx-marker-filter (string) |
861 (setq gud-marker-acc (concat gud-marker-acc string)) | 858 (setq gud-marker-acc (concat gud-marker-acc string)) |
989 (substring | 986 (substring |
990 result (match-beginning 2) (match-end 2))))))) | 987 result (match-beginning 2) (match-end 2))))))) |
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 |
1006 (defvar gud-dgux-p (string-match "-dgux" system-configuration) | 1001 (defvar gud-dgux-p (string-match "-dgux" system-configuration) |
1007 "Non-nil means to assume the interface approriate for DG/UX dbx. | 1002 "Non-nil means to assume the interface approriate for DG/UX dbx. |
1052 (if (string-match "Stopped\\|Frame" gud-marker-acc start) | 1047 (if (string-match "Stopped\\|Frame" gud-marker-acc start) |
1053 (substring gud-marker-acc (match-beginning 0)) | 1048 (substring gud-marker-acc (match-beginning 0)) |
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*. |
1066 The directory containing FILE becomes the initial working directory | 1055 The directory containing FILE becomes the initial working directory |
1067 and source-file directory for your debugger." | 1056 and source-file directory for your debugger." |
1068 (interactive (list (gud-query-cmdline 'dbx))) | 1057 (interactive (list (gud-query-cmdline 'dbx))) |
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 |
1086 (cond | 1074 (cond |
1087 (gud-mips-p | 1075 (gud-mips-p |
1149 (setq result (cons (car directories) (cons "-d" result))) | 1137 (setq result (cons (car directories) (cons "-d" result))) |
1150 (setq directories (cdr directories))) | 1138 (setq directories (cdr directories))) |
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) |
1171 (if (or (string-match comint-prompt-regexp string) | 1145 (if (or (string-match comint-prompt-regexp string) |
1172 (string-match ".*\012" string)) | 1146 (string-match ".*\012" string)) |
1174 gud-marker-acc "") | 1148 gud-marker-acc "") |
1175 (setq gud-marker-acc (concat gud-marker-acc string))) | 1149 (setq gud-marker-acc (concat gud-marker-acc string))) |
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 | |
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 | 1160 |
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*. |
1196 The directory containing FILE becomes the initial working directory | 1164 The directory containing FILE becomes the initial working directory |
1199 You can set the variable 'gud-xdb-directories' to a list of program source | 1167 You can set the variable 'gud-xdb-directories' to a list of program source |
1200 directories if your program contains sources from more than one directory." | 1168 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.") |
1208 (gud-def gud-tbreak "b %f:%l\\t" "\C-t" | 1176 (gud-def gud-tbreak "b %f:%l\\t" "\C-t" |
1209 "Set temporary breakpoint at current line.") | 1177 "Set temporary breakpoint at current line.") |
1320 (setq output (concat output gud-marker-acc) | 1288 (setq output (concat output gud-marker-acc) |
1321 gud-marker-acc "")) | 1289 gud-marker-acc "")) |
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 |
1331 :group 'gud) | 1296 :group 'gud) |
1332 | 1297 |
1338 (interactive | 1303 (interactive |
1339 (list (gud-query-cmdline 'perldb | 1304 (list (gud-query-cmdline 'perldb |
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.") |
1347 (gud-def gud-remove "d %l" "\C-d" "Remove breakpoint at current line") | 1312 (gud-def gud-remove "d %l" "\C-d" "Remove breakpoint at current line") |
1348 (gud-def gud-step "s" "\C-s" "Step one source line with display.") | 1313 (gud-def gud-step "s" "\C-s" "Step one source line with display.") |
1426 (setq output (concat output gud-marker-acc) | 1391 (setq output (concat output gud-marker-acc) |
1427 gud-marker-acc "")) | 1392 gud-marker-acc "")) |
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." |
1437 :type 'string | 1399 :type 'string |
1438 :group 'gud) | 1400 :group 'gud) |
1443 The directory containing FILE becomes the initial working directory | 1405 The directory containing FILE becomes the initial working directory |
1444 and source-file directory for your debugger." | 1406 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.") |
1453 (gud-def gud-remove "clear %f:%l" "\C-d" "Remove breakpoint at current line") | 1414 (gud-def gud-remove "clear %f:%l" "\C-d" "Remove breakpoint at current line") |
1454 (gud-def gud-step "step" "\C-s" "Step one source line with display.") | 1415 (gud-def gud-step "step" "\C-s" "Step one source line with display.") |
2064 (- (/ (* gud-marker-acc-max-length 3) 4))))) | 2025 (- (/ (* gud-marker-acc-max-length 3) 4))))) |
2065 | 2026 |
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) |
2075 "Run jdb with command line COMMAND-LINE in a buffer. | 2034 "Run jdb with command line COMMAND-LINE in a buffer. |
2076 The buffer is named \"*gud*\" if no initial class is given or | 2035 The buffer is named \"*gud*\" if no initial class is given or |
2096 (setq gud-jdb-classpath | 2055 (setq gud-jdb-classpath |
2097 (gud-jdb-parse-classpath-string gud-jdb-classpath-string))) | 2056 (gud-jdb-parse-classpath-string gud-jdb-classpath-string))) |
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 |
2105 (if gud-jdb-classpath-string | 2064 (if gud-jdb-classpath-string |
2106 (setq gud-jdb-classpath | 2065 (setq gud-jdb-classpath |
2271 ;; Perform initializations common to all debuggers. | 2230 ;; Perform initializations common to all debuggers. |
2272 ;; The first arg is the specified command line, | 2231 ;; The first arg is the specified command line, |
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. |
2282 (file-word (let ((w (cdr words))) | 2243 (file-word (let ((w (cdr words))) |
2283 (while (and w (= ?- (aref (car w) 0))) | 2244 (while (and w (= ?- (aref (car w) 0))) |
2297 (if (file-name-directory file-subst) | 2258 (if (file-name-directory file-subst) |
2298 (expand-file-name file-subst) | 2259 (expand-file-name file-subst) |
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 |
2305 ;; Don't set default-directory if no directory was specified. | 2268 ;; Don't set default-directory if no directory was specified. |
2306 ;; In that case, either the file is found in the current directory, | 2269 ;; In that case, either the file is found in the current directory, |