Mercurial > emacs
comparison lisp/gud.el @ 20756:eccadd41e2a5
Added gud-speedbar-buttons, and support for GDB buttons.
author | Eric M. Ludlam <zappo@gnu.org> |
---|---|
date | Fri, 23 Jan 1998 02:04:20 +0000 |
parents | 6bbf4a411f07 |
children | e78bc1ffd88d |
comparison
equal
deleted
inserted
replaced
20755:0ceaf8e0782b | 20756:eccadd41e2a5 |
---|---|
167 ;; the rest. | 167 ;; the rest. |
168 ;; | 168 ;; |
169 ;; The job of the find-file method is to visit and return the buffer indicated | 169 ;; The job of the find-file method is to visit and return the buffer indicated |
170 ;; by the car of gud-tag-frame. This may be a file name, a tag name, or | 170 ;; by the car of gud-tag-frame. This may be a file name, a tag name, or |
171 ;; something else. It would be good if it also copied the Gud menubar entry. | 171 ;; something else. It would be good if it also copied the Gud menubar entry. |
172 | |
173 ;; ====================================================================== | |
174 ;; speedbar support functions and variables. | |
175 (defvar gud-last-speedbar-buffer nil | |
176 "The last GUD buffer used.") | |
177 | |
178 (defvar gud-last-speedbar-stackframe nil | |
179 "Description of the currently displayed GUD stack. | |
180 t means that there is no stack, and we are in display-file mode.") | |
181 | |
182 (defvar gud-speedbar-menu-items | |
183 ;; Note to self. Add expand, and turn off items when not available. | |
184 '(["Jump to stack frame" speedbar-edit-line t]) | |
185 "Additional menu items to add the the speedbar frame.") | |
186 | |
187 (defun gud-speedbar-buttons (buffer) | |
188 "Create a speedbar display based on the current state of GUD. | |
189 If the GUD BUFFER is not running a supported debugger, then turn | |
190 off the specialized speedbar mode." | |
191 (if (and (save-excursion (goto-char (point-min)) | |
192 (looking-at "Current Stack")) | |
193 (equal gud-last-last-frame gud-last-speedbar-stackframe)) | |
194 nil | |
195 (setq gud-last-speedbar-buffer buffer) | |
196 (let* ((ff (save-excursion (set-buffer buffer) gud-find-file)) | |
197 ;;(lf (save-excursion (set-buffer buffer) gud-last-last-frame)) | |
198 (frames | |
199 (cond ((eq ff 'gud-gdb-find-file) | |
200 (gud-gdb-get-stackframe buffer) | |
201 ) | |
202 ;; Add more debuggers here! | |
203 (t | |
204 (speedbar-remove-localized-speedbar-support buffer) | |
205 nil)))) | |
206 (erase-buffer) | |
207 (if (not frames) | |
208 (insert "No Stack frames\n") | |
209 (insert "Current Stack:\n")) | |
210 (while frames | |
211 (insert (nth 1 (car frames)) ":\n") | |
212 (if (= (length (car frames)) 2) | |
213 (progn | |
214 ; (speedbar-insert-button "[?]" | |
215 ; 'speedbar-button-face | |
216 ; nil nil nil t) | |
217 (speedbar-insert-button (car (car frames)) | |
218 'speedbar-directory-face | |
219 nil nil nil t)) | |
220 ; (speedbar-insert-button "[+]" | |
221 ; 'speedbar-button-face | |
222 ; 'speedbar-highlight-face | |
223 ; 'gud-gdb-get-scope-data | |
224 ; (car frames) t) | |
225 (speedbar-insert-button (car (car frames)) | |
226 'speedbar-file-face | |
227 'speedbar-highlight-face | |
228 (cond ((eq ff 'gud-gdb-find-file) | |
229 'gud-gdb-goto-stackframe) | |
230 (t (error "Should never be here."))) | |
231 (car frames) t)) | |
232 (setq frames (cdr frames))) | |
233 ; (let ((selected-frame | |
234 ; (cond ((eq ff 'gud-gdb-find-file) | |
235 ; (gud-gdb-selected-frame-info buffer)) | |
236 ; (t (error "Should never be here.")))))) | |
237 ) | |
238 (setq gud-last-speedbar-stackframe gud-last-last-frame))) | |
239 | |
172 | 240 |
173 ;; ====================================================================== | 241 ;; ====================================================================== |
174 ;; gdb functions | 242 ;; gdb functions |
175 | 243 |
176 ;;; History of argument lists passed to gdb. | 244 ;;; History of argument lists passed to gdb. |
385 string) | 453 string) |
386 (progn | 454 (progn |
387 (setq gud-gdb-complete-string string) | 455 (setq gud-gdb-complete-string string) |
388 ""))) | 456 ""))) |
389 | 457 |
458 ;; gdb speedbar functions | |
459 | |
460 (defun gud-gdb-goto-stackframe (text token indent) | |
461 "Goto the stackframe described by TEXT, TOKEN, and INDENT." | |
462 (speedbar-with-attached-buffer | |
463 (gud-basic-call (concat "frame " (nth 1 token))) | |
464 (sit-for 1))) | |
465 | |
466 (defvar gud-gdb-fetched-stack-frame nil | |
467 "Stack frames we are fetching from GDB.") | |
468 | |
469 (defvar gud-gdb-fetched-stack-frame-list nil | |
470 "List of stack frames we are fetching from GDB.") | |
471 | |
472 ;(defun gud-gdb-get-scope-data (text token indent) | |
473 ; ;; checkdoc-params: (indent) | |
474 ; "Fetch data associated with a stack frame, and expand/contract it. | |
475 ;Data to do this is retrieved from TEXT and TOKEN." | |
476 ; (let ((args nil) (scope nil)) | |
477 ; (gud-gdb-run-command-fetch-lines "info args") | |
478 ; | |
479 ; (gud-gdb-run-command-fetch-lines "info local") | |
480 ; | |
481 ; )) | |
482 | |
483 (defun gud-gdb-get-stackframe (buffer) | |
484 "Extract the current stack frame out of the GUD GDB BUFFER." | |
485 (let ((newlst nil) | |
486 (gud-gdb-fetched-stack-frame-list nil)) | |
487 (gud-gdb-run-command-fetch-lines "backtrace" buffer) | |
488 (if (string-match "No stack" (car gud-gdb-fetched-stack-frame-list)) | |
489 ;; Go into some other mode??? | |
490 nil | |
491 (while gud-gdb-fetched-stack-frame-list | |
492 (let ((e (car gud-gdb-fetched-stack-frame-list)) | |
493 (name nil) (num nil)) | |
494 (if (not (or | |
495 (string-match "^#\\([0-9]+\\) +[0-9a-fx]+ in \\([0-9a-zA-Z_]+\\) (" e) | |
496 (string-match "^#\\([0-9]+\\) +\\([0-9a-zA-Z_]+\\) (" e))) | |
497 (if (not (string-match | |
498 "at \\([-0-9a-zA-Z_.]+\\):\\([0-9]+\\)$" e)) | |
499 nil | |
500 (setcar newlst | |
501 (list (nth 0 (car newlst)) | |
502 (nth 1 (car newlst)) | |
503 (match-string 1 e) | |
504 (match-string 2 e)))) | |
505 (setq num (match-string 1 e) | |
506 name (match-string 2 e)) | |
507 (setq newlst | |
508 (cons | |
509 (if (string-match | |
510 "at \\([-0-9a-zA-Z_.]+\\):\\([0-9]+\\)$" e) | |
511 (list name num (match-string 1 e) | |
512 (match-string 2 e)) | |
513 (list name num)) | |
514 newlst)))) | |
515 (setq gud-gdb-fetched-stack-frame-list | |
516 (cdr gud-gdb-fetched-stack-frame-list))) | |
517 (nreverse newlst)))) | |
518 | |
519 ;(defun gud-gdb-selected-frame-info (buffer) | |
520 ; "Learn GDB information for the currently selected stack frame in BUFFER." | |
521 ; ) | |
522 | |
523 (defun gud-gdb-run-command-fetch-lines (command buffer) | |
524 "Run COMMAND, and return when `gud-gdb-fetched-stack-frame-list' is full. | |
525 BUFFER is the GUD buffer in which to run the command." | |
526 (save-excursion | |
527 (set-buffer buffer) | |
528 (if (save-excursion | |
529 (goto-char (point-max)) | |
530 (beginning-of-line) | |
531 (not (looking-at comint-prompt-regexp))) | |
532 nil | |
533 ;; Much of this copied from GDB complete, but I'm grabbing the stack | |
534 ;; frame instead. | |
535 (let ((gud-marker-filter 'gud-gdb-speedbar-stack-filter)) | |
536 ;; Issue the command to GDB. | |
537 (gud-basic-call command) | |
538 (setq gud-gdb-complete-in-progress t ;; use this flag for our purposes. | |
539 gud-gdb-complete-string nil | |
540 gud-gdb-complete-list nil) | |
541 ;; Slurp the output. | |
542 (while gud-gdb-complete-in-progress | |
543 (accept-process-output (get-buffer-process gud-comint-buffer))) | |
544 (setq gud-gdb-fetched-stack-frame nil | |
545 gud-gdb-fetched-stack-frame-list | |
546 (nreverse gud-gdb-fetched-stack-frame-list)))))) | |
547 | |
548 (defun gud-gdb-speedbar-stack-filter (string) | |
549 ;; checkdoc-params: (string) | |
550 "Filter used to read in the current GDB stack." | |
551 (setq string (concat gud-gdb-fetched-stack-frame string)) | |
552 (while (string-match "\n" string) | |
553 (setq gud-gdb-fetched-stack-frame-list | |
554 (cons (substring string 0 (match-beginning 0)) | |
555 gud-gdb-fetched-stack-frame-list)) | |
556 (setq string (substring string (match-end 0)))) | |
557 (if (string-match comint-prompt-regexp string) | |
558 (progn | |
559 (setq gud-gdb-complete-in-progress nil) | |
560 string) | |
561 (progn | |
562 (setq gud-gdb-complete-string string) | |
563 ""))) | |
564 | |
390 | 565 |
391 ;; ====================================================================== | 566 ;; ====================================================================== |
392 ;; sdb functions | 567 ;; sdb functions |
393 | 568 |
394 ;;; History of argument lists passed to sdb. | 569 ;;; History of argument lists passed to sdb. |