comparison lisp/progmodes/gdb-ui.el @ 78946:b70291074dcf

(gdb-init-1): Don't set the values gud-minor-mode and gud-marker-filter. (gdb-fullname-regexp): New variable. (gud-gdba-marker-filter): Use it to switch to text command mode if appropriate.
author Nick Roberts <nickrob@snap.net.nz>
date Tue, 02 Oct 2007 10:57:03 +0000
parents 5f7e08d29d9f
children 47523d623a1c
comparison
equal deleted inserted replaced
78945:07537c759a20 78946:b70291074dcf
470 (concat "." component)))) 470 (concat "." component))))
471 (setq varnumlet (concat varnumlet "." component))) 471 (setq varnumlet (concat varnumlet "." component)))
472 expr))) 472 expr)))
473 473
474 (defun gdb-init-1 () 474 (defun gdb-init-1 ()
475 (set (make-local-variable 'gud-minor-mode) 'gdba)
476 (set (make-local-variable 'gud-marker-filter) 'gud-gdba-marker-filter)
477 ;;
478 (gud-def gud-break (if (not (string-match "Machine" mode-name)) 475 (gud-def gud-break (if (not (string-match "Machine" mode-name))
479 (gud-call "break %f:%l" arg) 476 (gud-call "break %f:%l" arg)
480 (save-excursion 477 (save-excursion
481 (beginning-of-line) 478 (beginning-of-line)
482 (forward-char 2) 479 (forward-char 2)
1513 (when source-window 1510 (when source-window
1514 (setq gdb-source-window source-window) 1511 (setq gdb-source-window source-window)
1515 (set-window-buffer source-window buffer)) 1512 (set-window-buffer source-window buffer))
1516 source-window)) 1513 source-window))
1517 1514
1515 ;; Derived from gud-gdb-marker-regexp
1516 (defvar gdb-fullname-regexp
1517 (concat "\\(.:?[^" ":" "\n]*\\)" ":" "\\([0-9]*\\)" ":" ".*"))
1518
1518 (defun gud-gdba-marker-filter (string) 1519 (defun gud-gdba-marker-filter (string)
1519 "A gud marker filter for gdb. Handle a burst of output from GDB." 1520 "A gud marker filter for gdb. Handle a burst of output from GDB."
1520 (if gdb-flush-pending-output 1521 (if gdb-flush-pending-output
1521 nil 1522 nil
1522 (when gdb-enable-debug 1523 (when gdb-enable-debug
1529 ;; Start accumulating output for the GUD buffer. 1530 ;; Start accumulating output for the GUD buffer.
1530 (let ((output "")) 1531 (let ((output ""))
1531 ;; 1532 ;;
1532 ;; Process all the complete markers in this chunk. 1533 ;; Process all the complete markers in this chunk.
1533 (while (string-match "\n\032\032\\(.*\\)\n" gud-marker-acc) 1534 (while (string-match "\n\032\032\\(.*\\)\n" gud-marker-acc)
1534 (let ((annotation (match-string 1 gud-marker-acc))) 1535 (let ((annotation (match-string 1 gud-marker-acc))
1535 ;; 1536 (before (substring gud-marker-acc 0 (match-beginning 0)))
1536 ;; Stuff prior to the match is just ordinary output. 1537 (after (substring gud-marker-acc (match-end 0))))
1537 ;; It is either concatenated to OUTPUT or directed
1538 ;; elsewhere.
1539 (setq output
1540 (gdb-concat-output
1541 output
1542 (substring gud-marker-acc 0 (match-beginning 0))))
1543 ;;
1544 ;; Take that stuff off the gud-marker-acc.
1545 (setq gud-marker-acc (substring gud-marker-acc (match-end 0)))
1546 ;; 1538 ;;
1547 ;; Parse the tag from the annotation, and maybe its arguments. 1539 ;; Parse the tag from the annotation, and maybe its arguments.
1548 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation) 1540 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation)
1549 (let* ((annotation-type (match-string 1 annotation)) 1541 (let* ((annotation-type (match-string 1 annotation))
1550 (annotation-arguments (match-string 2 annotation)) 1542 (annotation-arguments (match-string 2 annotation))
1551 (annotation-rule (assoc annotation-type 1543 (annotation-rule (assoc annotation-type
1552 gdb-annotation-rules))) 1544 gdb-annotation-rules))
1545 (fullname (string-match gdb-fullname-regexp annotation-type)))
1546
1547 ;; Stuff prior to the match is just ordinary output.
1548 ;; It is either concatenated to OUTPUT or directed
1549 ;; elsewhere.
1550 (setq output
1551 (gdb-concat-output output
1552 (concat before (if fullname "\n"))))
1553
1554 ;; Take that stuff off the gud-marker-acc.
1555 (setq gud-marker-acc after)
1556
1553 ;; Call the handler for this annotation. 1557 ;; Call the handler for this annotation.
1554 (if annotation-rule 1558 (if annotation-rule
1555 (funcall (car (cdr annotation-rule)) 1559 (funcall (car (cdr annotation-rule))
1556 annotation-arguments) 1560 annotation-arguments)
1557 ;; Else the annotation is not recognized. Ignore it silently, 1561
1558 ;; so that GDB can add new annotations without causing 1562 ;; Switch to gud-gdb-marker-filter if appropriate.
1559 ;; us to blow up. 1563 (when fullname
1560 )))) 1564
1561 ;; 1565 ;; Extract the frame position from the marker.
1566 (setq gud-last-frame (cons (match-string 1 annotation)
1567 (string-to-number
1568 (match-string 2 annotation))))
1569
1570 (set (make-local-variable 'gud-minor-mode) 'gdb)
1571 (set (make-local-variable 'gud-marker-filter)
1572 'gud-gdb-marker-filter)))
1573
1574 ;; Else the annotation is not recognized. Ignore it silently,
1575 ;; so that GDB can add new annotations without causing
1576 ;; us to blow up.
1577 )))
1578
1562 ;; Does the remaining text end in a partial line? 1579 ;; Does the remaining text end in a partial line?
1563 ;; If it does, then keep part of the gud-marker-acc until we get more. 1580 ;; If it does, then keep part of the gud-marker-acc until we get more.
1564 (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'" 1581 (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'"
1565 gud-marker-acc) 1582 gud-marker-acc)
1566 (progn 1583 (progn
2808 ;;;; Window management 2825 ;;;; Window management
2809 (defun gdb-display-buffer (buf dedicated &optional size) 2826 (defun gdb-display-buffer (buf dedicated &optional size)
2810 (let ((answer (get-buffer-window buf 0)) 2827 (let ((answer (get-buffer-window buf 0))
2811 (must-split nil)) 2828 (must-split nil))
2812 (if answer 2829 (if answer
2813 (display-buffer buf nil 0) ;Raise the frame if necessary. 2830 (display-buffer buf nil 0) ;Deiconify the frame if necessary.
2814 ;; The buffer is not yet displayed. 2831 ;; The buffer is not yet displayed.
2815 (pop-to-buffer gud-comint-buffer) ;Select the right frame. 2832 (pop-to-buffer gud-comint-buffer) ;Select the right frame.
2816 (let ((window (get-lru-window))) 2833 (let ((window (get-lru-window)))
2817 (if (and window 2834 (if (and window
2818 (not (memq window `(,(get-buffer-window gud-comint-buffer) 2835 (not (memq window `(,(get-buffer-window gud-comint-buffer)