Mercurial > emacs
comparison lisp/gud.el @ 10448:ec596f12f13f
(gud-gdb-find-file): Propagate debug menu to found buffers.
(gud-dbx-find-file, gud-xdb-find-file, gud-sdb-find-file, gud-perldb-find-file):
Likewise.
(gud-menu-map): New variable.
(gud-mode): Use gud-menu-map and move the menu-setting outside.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 18 Jan 1995 04:51:29 +0000 |
parents | 55bc74681031 |
children | d291152ebe20 |
comparison
equal
deleted
inserted
replaced
10447:55bc74681031 | 10448:ec596f12f13f |
---|---|
65 (defun gud-find-file (file) | 65 (defun gud-find-file (file) |
66 ;; Don't get confused by double slashes in the name that comes from GDB. | 66 ;; Don't get confused by double slashes in the name that comes from GDB. |
67 (while (string-match "//+" file) | 67 (while (string-match "//+" file) |
68 (setq file (replace-match "/" t t file))) | 68 (setq file (replace-match "/" t t file))) |
69 (funcall gud-find-file file)) | 69 (funcall gud-find-file file)) |
70 | |
71 ;; Keymap definitions for menu bar entries common to all debuggers and | |
72 ;; slots for debugger-dependent ones in sensible places. (Defined here | |
73 ;; before use.) | |
74 (defvar gud-menu-map (make-sparse-keymap "Gud") nil) | |
75 (define-key gud-menu-map [refresh] '("Refresh" . gud-refresh)) | |
76 (define-key gud-menu-map [remove] '("Remove breakpoint" . gud-remove)) | |
77 (define-key gud-menu-map [tbreak] nil) ; gdb, sdb and xdb | |
78 (define-key gud-menu-map [break] '("Set breakpoint" . gud-break)) | |
79 (define-key gud-menu-map [up] nil) ; gdb, dbx, and xdb | |
80 (define-key gud-menu-map [down] nil) ; gdb, dbx, and xdb | |
81 (define-key gud-menu-map [print] '("Print expression" . gud-print)) | |
82 (define-key gud-menu-map [finish] nil) ; gdb or xdb | |
83 (define-key gud-menu-map [stepi] '("Step instruction" . gud-stepi)) | |
84 (define-key gud-menu-map [step] '("Step line" . gud-step)) | |
85 (define-key gud-menu-map [next] '("Next line" . gud-next)) | |
86 (define-key gud-menu-map [cont] '("Continue" . gud-cont)) | |
70 | 87 |
71 ;; ====================================================================== | 88 ;; ====================================================================== |
72 ;; command definition | 89 ;; command definition |
73 | 90 |
74 ;; This macro is used below to define some basic debugger interface commands. | 91 ;; This macro is used below to define some basic debugger interface commands. |
210 gud-marker-acc "")) | 227 gud-marker-acc "")) |
211 | 228 |
212 output)) | 229 output)) |
213 | 230 |
214 (defun gud-gdb-find-file (f) | 231 (defun gud-gdb-find-file (f) |
215 (find-file-noselect f)) | 232 (save-excursion |
233 (let ((buf (find-file-noselect f))) | |
234 (set-buffer buf) | |
235 (define-key (current-local-map) [menu-bar debug] | |
236 ;; The copy-keymap here avoids redefining the gud-menu-map | |
237 ;; items in other buffers. | |
238 (cons "Gud" (copy-keymap gud-menu-map))) | |
239 (local-set-key [menu-bar debug tbreak] | |
240 '("Temporary breakpoint" . gud-tbreak)) | |
241 (local-set-key [menu-bar debug finish] '("Finish function" . gud-finish)) | |
242 (local-set-key [menu-bar debug up] '("Up stack" . gud-up)) | |
243 (local-set-key [menu-bar debug down] '("Down stack" . gud-down)) | |
244 buf))) | |
216 | 245 |
217 (defvar gdb-minibuffer-local-map nil | 246 (defvar gdb-minibuffer-local-map nil |
218 "Keymap for minibuffer prompting of gdb startup command.") | 247 "Keymap for minibuffer prompting of gdb startup command.") |
219 (if gdb-minibuffer-local-map | 248 (if gdb-minibuffer-local-map |
220 () | 249 () |
419 (substring gud-marker-acc start) | 448 (substring gud-marker-acc start) |
420 nil))) | 449 nil))) |
421 string) | 450 string) |
422 | 451 |
423 (defun gud-sdb-find-file (f) | 452 (defun gud-sdb-find-file (f) |
424 (if gud-sdb-needs-tags | 453 (save-excursion |
425 (find-tag-noselect f) | 454 (let ((buf (if gud-sdb-needs-tags |
426 (find-file-noselect f))) | 455 (find-tag-noselect f) |
456 (find-file-noselect f)))) | |
457 (set-buffer buf) | |
458 (define-key (current-local-map) [menu-bar debug] (cons "Gud" (copy-keymap gud-menu-map))) | |
459 (local-set-key [menu-bar debug tbreak] '("Temporary breakpoint" . gud-tbreak)) | |
460 buf))) | |
427 | 461 |
428 ;;;###autoload | 462 ;;;###autoload |
429 (defun sdb (command-line) | 463 (defun sdb (command-line) |
430 "Run sdb on program FILE in buffer *gud-FILE*. | 464 "Run sdb on program FILE in buffer *gud-FILE*. |
431 The directory containing FILE becomes the initial working directory | 465 The directory containing FILE becomes the initial working directory |
648 result (match-beginning 1) (match-end 1))))))) | 682 result (match-beginning 1) (match-end 1))))))) |
649 (setq result (substring result 0 (match-beginning 0)))))) | 683 (setq result (substring result 0 (match-beginning 0)))))) |
650 (or result ""))) | 684 (or result ""))) |
651 | 685 |
652 (defun gud-dbx-find-file (f) | 686 (defun gud-dbx-find-file (f) |
653 (find-file-noselect f)) | 687 (save-excursion |
688 (let ((buf (find-file-noselect f))) | |
689 (set-buffer buf) | |
690 (local-set-key [menu-bar debug] (cons "Gud" (copy-keymap gud-menu-map))) | |
691 (local-set-key [menu-bar debug up] '("Up stack" . gud-up)) | |
692 (local-set-key [menu-bar debug down] '("Down stack" . gud-down)) | |
693 buf))) | |
654 | 694 |
655 ;;;###autoload | 695 ;;;###autoload |
656 (defun dbx (command-line) | 696 (defun dbx (command-line) |
657 "Run dbx on program FILE in buffer *gud-FILE*. | 697 "Run dbx on program FILE in buffer *gud-FILE*. |
658 The directory containing FILE becomes the initial working directory | 698 The directory containing FILE becomes the initial working directory |
770 (if file | 810 (if file |
771 (setq gud-last-frame (cons file line)))))) | 811 (setq gud-last-frame (cons file line)))))) |
772 (or result ""))) | 812 (or result ""))) |
773 | 813 |
774 (defun gud-xdb-find-file (f) | 814 (defun gud-xdb-find-file (f) |
775 (let ((realf (gud-xdb-file-name f))) | 815 (save-excursion |
776 (if realf (find-file-noselect realf)))) | 816 (let ((realf (gud-xdb-file-name f))) |
817 (if realf | |
818 (let ((buf (find-file-noselect realf))) | |
819 (set-buffer buf) | |
820 (local-set-key [menu-bar debug] (cons "Gud" (copy-keymap gud-menu-map))) | |
821 (local-set-key [menu-bar debug tbreak] | |
822 '("Temporary breakpoint" . gud-tbreak)) | |
823 (local-set-key [menu-bar debug finish] | |
824 '("Finish function" . gud-finish)) | |
825 (local-set-key [menu-bar debug up] '("Up stack" . gud-up)) | |
826 (local-set-key [menu-bar debug up] '("Up stack" . gud-up)) | |
827 (local-set-key [menu-bar debug down] '("Down stack" . gud-down)) | |
828 buf) | |
829 nil)))) | |
777 | 830 |
778 ;;;###autoload | 831 ;;;###autoload |
779 (defun xdb (command-line) | 832 (defun xdb (command-line) |
780 "Run xdb on program FILE in buffer *gud-FILE*. | 833 "Run xdb on program FILE in buffer *gud-FILE*. |
781 The directory containing FILE becomes the initial working directory | 834 The directory containing FILE becomes the initial working directory |
874 gud-marker-acc "")) | 927 gud-marker-acc "")) |
875 | 928 |
876 output)) | 929 output)) |
877 | 930 |
878 (defun gud-perldb-find-file (f) | 931 (defun gud-perldb-find-file (f) |
879 (find-file-noselect f)) | 932 (save-excursion |
933 (let ((buf (find-file-noselect f))) | |
934 (set-buffer buf) | |
935 (define-key (current-local-map) [menu-bar debug] (cons "Gud" (copy-keymap gud-menu-map))) | |
936 buf))) | |
880 | 937 |
881 ;;;###autoload | 938 ;;;###autoload |
882 (defun perldb (command-line) | 939 (defun perldb (command-line) |
883 "Run perldb on program FILE in buffer *gud-FILE*. | 940 "Run perldb on program FILE in buffer *gud-FILE*. |
884 The directory containing FILE becomes the initial working directory | 941 The directory containing FILE becomes the initial working directory |
1015 (setq major-mode 'gud-mode) | 1072 (setq major-mode 'gud-mode) |
1016 (setq mode-name "Debugger") | 1073 (setq mode-name "Debugger") |
1017 (setq mode-line-process '(":%s")) | 1074 (setq mode-line-process '(":%s")) |
1018 (use-local-map (copy-keymap comint-mode-map)) | 1075 (use-local-map (copy-keymap comint-mode-map)) |
1019 (define-key (current-local-map) "\C-c\C-l" 'gud-refresh) | 1076 (define-key (current-local-map) "\C-c\C-l" 'gud-refresh) |
1020 ;; Keymap definitions for menu bar entries common to all debuggers | |
1021 ;; and slots for debugger-dependent ones. The menu should be made | |
1022 ;; to propagate to buffers found by gud-find-file. | |
1023 (define-key (current-local-map) [menu-bar debug] | 1077 (define-key (current-local-map) [menu-bar debug] |
1024 (cons "Gud" (make-sparse-keymap "Gud"))) | 1078 (cons "Gud" gud-menu-map)) |
1025 (define-key (current-local-map) [menu-bar debug refresh] | |
1026 '("Refresh" . gud-refresh)) | |
1027 (define-key (current-local-map) [menu-bar debug remove] | |
1028 '("Remove breakpoint" . gud-remove)) | |
1029 (define-key (current-local-map) [menu-bar debug tbreak] ; gdb, sdb and xdb | |
1030 nil) | |
1031 (define-key (current-local-map) [menu-bar debug break] | |
1032 '("Set breakpoint" . gud-break)) | |
1033 (define-key (current-local-map) [menu-bar debug up] ; gdb, dbx, and xdb | |
1034 nil) | |
1035 (define-key (current-local-map) [menu-bar debug down] ; gdb, dbx, and xdb | |
1036 nil) | |
1037 (define-key (current-local-map) [menu-bar debug print] | |
1038 '("Print expression" . gud-print)) ; though not in the source | |
1039 ; buffer until it gets a menu... | |
1040 (define-key (current-local-map) [menu-bar debug finish] ; gdb or xdb | |
1041 nil) | |
1042 (define-key (current-local-map) [menu-bar debug stepi] | |
1043 '("Step instruction" . gud-stepi)) | |
1044 (define-key (current-local-map) [menu-bar debug step] | |
1045 '("Step line" . gud-step)) | |
1046 (define-key (current-local-map) [menu-bar debug next] | |
1047 '("Next line" . gud-next)) | |
1048 (define-key (current-local-map) [menu-bar debug cont] | |
1049 '("Continue" . gud-cont)) | |
1050 (make-local-variable 'gud-last-frame) | 1079 (make-local-variable 'gud-last-frame) |
1051 (setq gud-last-frame nil) | 1080 (setq gud-last-frame nil) |
1052 (make-local-variable 'comint-prompt-regexp) | 1081 (make-local-variable 'comint-prompt-regexp) |
1053 (make-local-variable 'paragraph-start) | 1082 (make-local-variable 'paragraph-start) |
1054 (make-local-variable 'gud-delete-prompt-marker) | 1083 (make-local-variable 'gud-delete-prompt-marker) |