diff options
| author | Nick Roberts | 2002-11-14 01:56:58 +0000 |
|---|---|---|
| committer | Nick Roberts | 2002-11-14 01:56:58 +0000 |
| commit | f36ca8323a4dfb01da3766af9c7eb93d59f08ec9 (patch) | |
| tree | b326587aa0b2ebb2445a0ccb78810e93a26c4043 | |
| parent | 035ca7627f5c1d3afeeb11587cc5a2b681207dd8 (diff) | |
| download | emacs-f36ca8323a4dfb01da3766af9c7eb93d59f08ec9.tar.gz emacs-f36ca8323a4dfb01da3766af9c7eb93d59f08ec9.zip | |
(gud-find-file): Set up GDB tool bar.
(gud-menu-map): New commands: run, goto.
Enable some commands for gdba.
(gud-query-cmdline): Pass default directory to gdba.
(gdb): Defune gud-goto and gud-run.
(gud-gdb-complete-command): Maybe use gdba-complete-filter.
(gud-mode): Set up local tool bar.
(gud-display-line): For gdba, call gdb-display-source-buffer.
(gud-basic-call): For gdba, maybe delete the current prompt.
(gud-tool-bar-map): New variable.
(gud-read-address): Correction.
| -rw-r--r-- | lisp/gud.el | 93 |
1 files changed, 62 insertions, 31 deletions
diff --git a/lisp/gud.el b/lisp/gud.el index cdd9b855b4f..fa09bcb5841 100644 --- a/lisp/gud.el +++ b/lisp/gud.el | |||
| @@ -94,22 +94,29 @@ If SOFT is non-nil, returns nil if the symbol doesn't already exist." | |||
| 94 | (when buf | 94 | (when buf |
| 95 | ;; Copy `gud-minor-mode' to the found buffer to turn on the menu. | 95 | ;; Copy `gud-minor-mode' to the found buffer to turn on the menu. |
| 96 | (with-current-buffer buf | 96 | (with-current-buffer buf |
| 97 | (set (make-local-variable 'gud-minor-mode) minor-mode)) | 97 | (set (make-local-variable 'gud-minor-mode) minor-mode) |
| 98 | (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)) | ||
| 98 | buf))) | 99 | buf))) |
| 99 | 100 | ||
| 100 | (easy-mmode-defmap gud-menu-map | 101 | (easy-mmode-defmap gud-menu-map |
| 101 | '(([refresh] "Refresh" . gud-refresh) | 102 | '(([refresh] "Refresh" . gud-refresh) |
| 103 | ([run] menu-item "Run" gud-run | ||
| 104 | :enable (memq gud-minor-mode '(gdba gdb))) | ||
| 105 | ([goto] menu-item "Continue to selection" gud-goto | ||
| 106 | :enable (memq gud-minor-mode '(gdba gdb))) | ||
| 102 | ([remove] "Remove Breakpoint" . gud-remove) | 107 | ([remove] "Remove Breakpoint" . gud-remove) |
| 103 | ([tbreak] menu-item "Temporary Breakpoint" gud-tbreak | 108 | ([tbreak] menu-item "Temporary Breakpoint" gud-tbreak |
| 104 | :enable (memq gud-minor-mode '(gdb sdb xdb))) | 109 | :enable (memq gud-minor-mode '(gdba gdb sdb xdb))) |
| 105 | ([break] "Set Breakpoint" . gud-break) | 110 | ([break] "Set Breakpoint" . gud-break) |
| 106 | ([up] menu-item "Up Stack" gud-up | 111 | ([up] menu-item "Up Stack" gud-up |
| 107 | :enable (memq gud-minor-mode '(gdb dbx xdb jdb))) | 112 | :enable (memq gud-minor-mode '(gdba gdb dbx xdb jdb))) |
| 108 | ([down] menu-item "Down Stack" gud-down | 113 | ([down] menu-item "Down Stack" gud-down |
| 109 | :enable (memq gud-minor-mode '(gdb dbx xdb jdb))) | 114 | :enable (memq gud-minor-mode '(gdba gdb dbx xdb jdb))) |
| 110 | ([print] "Print Expression" . gud-print) | 115 | ([print] "Print Expression" . gud-print) |
| 116 | ([display] menu-item "Display Expression" gud-display | ||
| 117 | :enable (eq gud-minor-mode 'gdba)) | ||
| 111 | ([finish] menu-item "Finish Function" gud-finish | 118 | ([finish] menu-item "Finish Function" gud-finish |
| 112 | :enable (memq gud-minor-mode '(gdb xdb jdb))) | 119 | :enable (memq gud-minor-mode '(gdba gdb xdb jdb))) |
| 113 | ([stepi] "Step Instruction" . gud-stepi) | 120 | ([stepi] "Step Instruction" . gud-stepi) |
| 114 | ([step] "Step Line" . gud-step) | 121 | ([step] "Step Line" . gud-step) |
| 115 | ([next] "Next Line" . gud-next) | 122 | ([next] "Next Line" . gud-next) |
| @@ -386,7 +393,7 @@ off the specialized speedbar mode." | |||
| 386 | (format "Run %s (like this): " minor-mode) | 393 | (format "Run %s (like this): " minor-mode) |
| 387 | (or (car-safe (symbol-value hist-sym)) | 394 | (or (car-safe (symbol-value hist-sym)) |
| 388 | (concat (or cmd-name (symbol-name minor-mode)) | 395 | (concat (or cmd-name (symbol-name minor-mode)) |
| 389 | " " | 396 | " " default-directory |
| 390 | (or init | 397 | (or init |
| 391 | (let ((file nil)) | 398 | (let ((file nil)) |
| 392 | (dolist (f (directory-files default-directory) file) | 399 | (dolist (f (directory-files default-directory) file) |
| @@ -422,6 +429,8 @@ and source-file directory for your debugger." | |||
| 422 | (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).") | 429 | (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).") |
| 423 | (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).") | 430 | (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).") |
| 424 | (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.") | 431 | (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.") |
| 432 | (gud-def gud-goto "until %l" "\C-u" "Continue up to current line.") | ||
| 433 | (gud-def gud-run "run" nil "Run the program.") | ||
| 425 | 434 | ||
| 426 | (local-set-key "\C-i" 'gud-gdb-complete-command) | 435 | (local-set-key "\C-i" 'gud-gdb-complete-command) |
| 427 | (local-set-key [menu-bar debug tbreak] '("Temporary Breakpoint" . gud-tbreak)) | 436 | (local-set-key [menu-bar debug tbreak] '("Temporary Breakpoint" . gud-tbreak)) |
| @@ -464,7 +473,9 @@ available with older versions of GDB." | |||
| 464 | (setq gud-gdb-complete-break (match-beginning 2) | 473 | (setq gud-gdb-complete-break (match-beginning 2) |
| 465 | command-word (substring command gud-gdb-complete-break)) | 474 | command-word (substring command gud-gdb-complete-break)) |
| 466 | ;; Temporarily install our filter function. | 475 | ;; Temporarily install our filter function. |
| 467 | (let ((gud-marker-filter 'gud-gdb-complete-filter)) | 476 | (let ((gud-marker-filter (if (eq gud-minor-mode 'gdba) |
| 477 | 'gdba-complete-filter | ||
| 478 | 'gud-gdb-complete-filter))) | ||
| 468 | ;; Issue the command to GDB. | 479 | ;; Issue the command to GDB. |
| 469 | (gud-basic-call (concat "complete " command)) | 480 | (gud-basic-call (concat "complete " command)) |
| 470 | (setq gud-gdb-complete-in-progress t | 481 | (setq gud-gdb-complete-in-progress t |
| @@ -2208,6 +2219,7 @@ comint mode, which see." | |||
| 2208 | (setq mode-line-process '(":%s")) | 2219 | (setq mode-line-process '(":%s")) |
| 2209 | (define-key (current-local-map) "\C-c\C-l" 'gud-refresh) | 2220 | (define-key (current-local-map) "\C-c\C-l" 'gud-refresh) |
| 2210 | (set (make-local-variable 'gud-last-frame) nil) | 2221 | (set (make-local-variable 'gud-last-frame) nil) |
| 2222 | (set (make-local-variable 'tool-bar-map) gud-tool-bar-map) | ||
| 2211 | (make-local-variable 'comint-prompt-regexp) | 2223 | (make-local-variable 'comint-prompt-regexp) |
| 2212 | ;; Don't put repeated commands in command history many times. | 2224 | ;; Don't put repeated commands in command history many times. |
| 2213 | (set (make-local-variable 'comint-input-ignoredups) t) | 2225 | (set (make-local-variable 'comint-input-ignoredups) t) |
| @@ -2231,7 +2243,6 @@ comint mode, which see." | |||
| 2231 | (defun gud-common-init (command-line massage-args marker-filter &optional find-file) | 2243 | (defun gud-common-init (command-line massage-args marker-filter &optional find-file) |
| 2232 | (let* ((words (split-string command-line)) | 2244 | (let* ((words (split-string command-line)) |
| 2233 | (program (car words)) | 2245 | (program (car words)) |
| 2234 | (dir default-directory) | ||
| 2235 | ;; Extract the file name from WORDS | 2246 | ;; Extract the file name from WORDS |
| 2236 | ;; and put t in its place. | 2247 | ;; and put t in its place. |
| 2237 | ;; Later on we will put the modified file name arg back there. | 2248 | ;; Later on we will put the modified file name arg back there. |
| @@ -2255,7 +2266,6 @@ comint mode, which see." | |||
| 2255 | file-subst))) | 2266 | file-subst))) |
| 2256 | (filepart (and file-word (concat "-" (file-name-nondirectory file))))) | 2267 | (filepart (and file-word (concat "-" (file-name-nondirectory file))))) |
| 2257 | (pop-to-buffer (concat "*gud" filepart "*")) | 2268 | (pop-to-buffer (concat "*gud" filepart "*")) |
| 2258 | (setq default-directory dir) | ||
| 2259 | ;; Set default-directory to the file's directory. | 2269 | ;; Set default-directory to the file's directory. |
| 2260 | (and file-word | 2270 | (and file-word |
| 2261 | gud-chdir-before-run | 2271 | gud-chdir-before-run |
| @@ -2424,7 +2434,9 @@ Obeying it means displaying in another window the specified file and line." | |||
| 2424 | (set-buffer gud-comint-buffer)) | 2434 | (set-buffer gud-comint-buffer)) |
| 2425 | (gud-find-file true-file))) | 2435 | (gud-find-file true-file))) |
| 2426 | (window (and buffer (or (get-buffer-window buffer) | 2436 | (window (and buffer (or (get-buffer-window buffer) |
| 2427 | (display-buffer buffer)))) | 2437 | (if (eq gud-minor-mode 'gdba) |
| 2438 | (gdb-display-source-buffer buffer) | ||
| 2439 | (display-buffer buffer))))) | ||
| 2428 | (pos)) | 2440 | (pos)) |
| 2429 | (if buffer | 2441 | (if buffer |
| 2430 | (progn | 2442 | (progn |
| @@ -2494,22 +2506,23 @@ Obeying it means displaying in another window the specified file and line." | |||
| 2494 | 2506 | ||
| 2495 | (defun gud-read-address () | 2507 | (defun gud-read-address () |
| 2496 | "Return a string containing the core-address found in the buffer at point." | 2508 | "Return a string containing the core-address found in the buffer at point." |
| 2497 | (save-excursion | 2509 | (save-match-data |
| 2498 | (let ((pt (point)) found begin) | 2510 | (save-excursion |
| 2499 | (setq found (if (search-backward "0x" (- pt 7) t) (point))) | 2511 | (let ((pt (point)) found begin) |
| 2500 | (cond | 2512 | (setq found (if (search-backward "0x" (- pt 7) t) (point))) |
| 2501 | (found (forward-char 2) | 2513 | (cond |
| 2502 | (buffer-substring found | 2514 | (found (forward-char 2) |
| 2503 | (progn (re-search-forward "[^0-9a-f]") | 2515 | (buffer-substring found |
| 2504 | (forward-char -1) | 2516 | (progn (re-search-forward "[^0-9a-f]") |
| 2505 | (point)))) | 2517 | (forward-char -1) |
| 2506 | (t (setq begin (progn (re-search-backward "[^0-9]") | 2518 | (point)))) |
| 2507 | (forward-char 1) | 2519 | (t (setq begin (progn (re-search-backward "[^0-9]") |
| 2508 | (point))) | 2520 | (forward-char 1) |
| 2509 | (forward-char 1) | 2521 | (point))) |
| 2510 | (re-search-forward "[^0-9]") | 2522 | (forward-char 1) |
| 2511 | (forward-char -1) | 2523 | (re-search-forward "[^0-9]") |
| 2512 | (buffer-substring begin (point))))))) | 2524 | (forward-char -1) |
| 2525 | (buffer-substring begin (point)))))))) | ||
| 2513 | 2526 | ||
| 2514 | (defun gud-call (fmt &optional arg) | 2527 | (defun gud-call (fmt &optional arg) |
| 2515 | (let ((msg (gud-format-command fmt arg))) | 2528 | (let ((msg (gud-format-command fmt arg))) |
| @@ -2521,8 +2534,7 @@ Obeying it means displaying in another window the specified file and line." | |||
| 2521 | "Invoke the debugger COMMAND displaying source in other window." | 2534 | "Invoke the debugger COMMAND displaying source in other window." |
| 2522 | (interactive) | 2535 | (interactive) |
| 2523 | (gud-set-buffer) | 2536 | (gud-set-buffer) |
| 2524 | (let ((command (concat command "\n")) | 2537 | (let ((proc (get-buffer-process gud-comint-buffer))) |
| 2525 | (proc (get-buffer-process gud-comint-buffer))) | ||
| 2526 | (or proc (error "Current buffer has no process")) | 2538 | (or proc (error "Current buffer has no process")) |
| 2527 | ;; Arrange for the current prompt to get deleted. | 2539 | ;; Arrange for the current prompt to get deleted. |
| 2528 | (save-excursion | 2540 | (save-excursion |
| @@ -2532,8 +2544,10 @@ Obeying it means displaying in another window the specified file and line." | |||
| 2532 | (goto-char (process-mark proc)) | 2544 | (goto-char (process-mark proc)) |
| 2533 | (forward-line 0) | 2545 | (forward-line 0) |
| 2534 | (if (looking-at comint-prompt-regexp) | 2546 | (if (looking-at comint-prompt-regexp) |
| 2535 | (set-marker gud-delete-prompt-marker (point))))) | 2547 | (set-marker gud-delete-prompt-marker (point))) |
| 2536 | (process-send-string proc command))) | 2548 | (if (eq gud-minor-mode 'gdba) |
| 2549 | (apply comint-input-sender (list proc command)) | ||
| 2550 | (process-send-string proc (concat command "\n"))))))) | ||
| 2537 | 2551 | ||
| 2538 | (defun gud-refresh (&optional arg) | 2552 | (defun gud-refresh (&optional arg) |
| 2539 | "Fix up a possibly garbled display, and redraw the arrow." | 2553 | "Fix up a possibly garbled display, and redraw the arrow." |
| @@ -2719,6 +2733,23 @@ pathname standards using file-truename." | |||
| 2719 | (message "gud-find-class: class for file %s not found in gud-jdb-class-source-alist!" f) | 2733 | (message "gud-find-class: class for file %s not found in gud-jdb-class-source-alist!" f) |
| 2720 | nil)))) | 2734 | nil)))) |
| 2721 | 2735 | ||
| 2722 | (provide 'gud) | 2736 | (defvar gud-tool-bar-map |
| 2737 | (if (display-graphic-p) | ||
| 2738 | (let ((tool-bar-map (make-sparse-keymap))) | ||
| 2739 | (tool-bar-add-item-from-menu 'gud-break "gud-break" gud-minor-mode-map) | ||
| 2740 | (tool-bar-add-item-from-menu 'gud-remove "gud-remove" gud-minor-mode-map) | ||
| 2741 | (tool-bar-add-item-from-menu 'gud-print "gud-print" gud-minor-mode-map) | ||
| 2742 | (tool-bar-add-item-from-menu 'gud-display "gud-display" gud-minor-mode-map) | ||
| 2743 | (tool-bar-add-item-from-menu 'gud-run "gud-run" gud-minor-mode-map) | ||
| 2744 | (tool-bar-add-item-from-menu 'gud-goto "gud-goto" gud-minor-mode-map) | ||
| 2745 | (tool-bar-add-item-from-menu 'gud-cont "gud-cont" gud-minor-mode-map) | ||
| 2746 | (tool-bar-add-item-from-menu 'gud-step "gud-step" gud-minor-mode-map) | ||
| 2747 | (tool-bar-add-item-from-menu 'gud-next "gud-next" gud-minor-mode-map) | ||
| 2748 | (tool-bar-add-item-from-menu 'gud-finish "gud-finish" gud-minor-mode-map) | ||
| 2749 | (tool-bar-add-item-from-menu 'gud-up "gud-up" gud-minor-mode-map) | ||
| 2750 | (tool-bar-add-item-from-menu 'gud-down "gud-down" gud-minor-mode-map) | ||
| 2751 | tool-bar-map))) | ||
| 2752 | |||
| 2753 | (provide 'mygud) | ||
| 2723 | 2754 | ||
| 2724 | ;;; gud.el ends here | 2755 | ;;; gud.el ends here |