comparison lisp/gdb-ui.el @ 48641:da382393fb77

Get rid of (quote ..); use match-string and ignore.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 03 Dec 2002 22:24:21 +0000
parents 7bc8b0b65a02
children 4d69c0f01cc0
comparison
equal deleted inserted replaced
48640:7bc8b0b65a02 48641:da382393fb77
135 (setq gdb-proc (get-buffer-process (current-buffer))) 135 (setq gdb-proc (get-buffer-process (current-buffer)))
136 (gdb-make-instance) 136 (gdb-make-instance)
137 (if gdb-first-time (gdb-clear-inferior-io)) 137 (if gdb-first-time (gdb-clear-inferior-io))
138 138
139 ; find source file and compilation directory here 139 ; find source file and compilation directory here
140 (gdb-instance-enqueue-idle-input (list "server list\n" 140 (gdb-instance-enqueue-idle-input (list "server list\n" 'ignore))
141 '(lambda () nil)))
142 (gdb-instance-enqueue-idle-input (list "server info source\n" 141 (gdb-instance-enqueue-idle-input (list "server info source\n"
143 '(lambda () (gdb-source-info))))) 142 'gdb-source-info)))
144 143
145 (defun gud-break (arg) 144 (defun gud-break (arg)
146 "Set breakpoint at current line or address." 145 "Set breakpoint at current line or address."
147 (interactive "p") 146 (interactive "p")
148 (if (not (string-equal mode-name "Assembler")) 147 (if (not (string-equal mode-name "Assembler"))
175 174
176 (defun gud-display1 (expr) 175 (defun gud-display1 (expr)
177 (goto-char (point-min)) 176 (goto-char (point-min))
178 (if (re-search-forward "\*" nil t) 177 (if (re-search-forward "\*" nil t)
179 (gdb-instance-enqueue-idle-input 178 (gdb-instance-enqueue-idle-input
180 (list (concat "server display* " expr "\n") 179 (list (concat "server display* " expr "\n") 'ignore))
181 '(lambda () nil)))
182 ;else 180 ;else
183 (gdb-instance-enqueue-idle-input 181 (gdb-instance-enqueue-idle-input
184 (list (concat "server display " expr "\n") 182 (list (concat "server display " expr "\n") 'ignore))))
185 '(lambda () nil)))))
186 183
187 184
188 ;; The completion process filter is installed temporarily to slurp the 185 ;; The completion process filter is installed temporarily to slurp the
189 ;; output of GDB up to the next prompt and build the completion list. 186 ;; output of GDB up to the next prompt and build the completion list.
190 ;; It must also handle annotations. 187 ;; It must also handle annotations.
675 (defun gdb-source (args) 672 (defun gdb-source (args)
676 (string-match gdb-source-spec-regexp args) 673 (string-match gdb-source-spec-regexp args)
677 ;; Extract the frame position from the marker. 674 ;; Extract the frame position from the marker.
678 (setq gud-last-frame 675 (setq gud-last-frame
679 (cons 676 (cons
680 (substring args (match-beginning 1) (match-end 1)) 677 (match-string 1 args)
681 (string-to-int (substring args 678 (string-to-int (match-string 2 args))))
682 (match-beginning 2) 679 (setq gdb-current-address (match-string 3 args))
683 (match-end 2)))))
684 (setq gdb-current-address (substring args (match-beginning 3)
685 (match-end 3)))
686 (setq gdb-main-or-pc gdb-current-address) 680 (setq gdb-main-or-pc gdb-current-address)
687 ;update with new frame for machine code if necessary 681 ;update with new frame for machine code if necessary
688 (gdb-invalidate-assembler)) 682 (gdb-invalidate-assembler))
689 683
690 (defun gdb-prompt (ignored) 684 (defun gdb-prompt (ignored)
864 (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer)) 858 (set-buffer (gdb-get-instance-buffer 'gdb-partial-output-buffer))
865 (goto-char (point-min)) 859 (goto-char (point-min))
866 (search-forward ": ") 860 (search-forward ": ")
867 (looking-at "\\(.*?\\) =") 861 (looking-at "\\(.*?\\) =")
868 (let ((char "") 862 (let ((char "")
869 (gdb-temp-value (buffer-substring (match-beginning 1) 863 (gdb-temp-value (match-string 1)))
870 (match-end 1))))
871 ;move * to front of expression if necessary 864 ;move * to front of expression if necessary
872 (if (looking-at ".*\\*") 865 (if (looking-at ".*\\*")
873 (progn 866 (progn
874 (setq char "*") 867 (setq char "*")
875 (setq gdb-temp-value (substring gdb-temp-value 1 nil)))) 868 (setq gdb-temp-value (substring gdb-temp-value 1 nil))))
914 (beginning-of-line) 907 (beginning-of-line)
915 (setq gdb-point (point)) 908 (setq gdb-point (point))
916 (gdb-array-format))) 909 (gdb-array-format)))
917 (if (looking-at "field-begin \\(.\\)") 910 (if (looking-at "field-begin \\(.\\)")
918 (progn 911 (progn
919 (setq gdb-annotation-arg (buffer-substring (match-beginning 1) 912 (setq gdb-annotation-arg (match-string 1))
920 (match-end 1)))
921 (gdb-field-format-begin)))) 913 (gdb-field-format-begin))))
922 (save-excursion 914 (save-excursion
923 (set-buffer gdb-expression-buffer-name) 915 (set-buffer gdb-expression-buffer-name)
924 (if gdb-dive-display-number 916 (if gdb-dive-display-number
925 (progn 917 (progn
938 930
939 (defun gdb-display-go-back () 931 (defun gdb-display-go-back ()
940 ; delete display so they don't accumulate and delete buffer 932 ; delete display so they don't accumulate and delete buffer
941 (let ((number gdb-display-number)) 933 (let ((number gdb-display-number))
942 (gdb-instance-enqueue-idle-input 934 (gdb-instance-enqueue-idle-input
943 (list (concat "server delete display " number "\n") 935 (list (concat "server delete display " number "\n") 'ignore))
944 '(lambda () nil)))
945 (switch-to-buffer (concat "*display " gdb-dive-display-number "*")) 936 (switch-to-buffer (concat "*display " gdb-dive-display-number "*"))
946 (kill-buffer (get-buffer (concat "*display " number "*"))))) 937 (kill-buffer (get-buffer (concat "*display " number "*")))))
947 938
948 ; prefix annotations with ## and process whole output in one chunk 939 ; prefix annotations with ## and process whole output in one chunk
949 ; in gdb-partial-output-buffer (to allow recursion). 940 ; in gdb-partial-output-buffer (to allow recursion).
995 (setq gdb-nesting-level (+ gdb-nesting-level 1)) 986 (setq gdb-nesting-level (+ gdb-nesting-level 1))
996 (while (re-search-forward "##" nil t) 987 (while (re-search-forward "##" nil t)
997 ; keep making recursive calls... 988 ; keep making recursive calls...
998 (if (looking-at "field-begin \\(.\\)") 989 (if (looking-at "field-begin \\(.\\)")
999 (progn 990 (progn
1000 (setq gdb-annotation-arg (buffer-substring (match-beginning 1) 991 (setq gdb-annotation-arg (match-string 1))
1001 (match-end 1)))
1002 (gdb-field-format-begin))) 992 (gdb-field-format-begin)))
1003 ; until field-end. 993 ; until field-end.
1004 (if (looking-at "field-end") (gdb-field-format-end)))) 994 (if (looking-at "field-end") (gdb-field-format-end))))
1005 995
1006 (defun gdb-field-format-end () 996 (defun gdb-field-format-end ()
1030 (end (progn (end-of-line) (point))) 1020 (end (progn (end-of-line) (point)))
1031 (gdb-part-expression "") (gdb-last-field nil) (gdb-display-char nil)) 1021 (gdb-part-expression "") (gdb-last-field nil) (gdb-display-char nil))
1032 (beginning-of-line) 1022 (beginning-of-line)
1033 (if (looking-at "\*") (setq gdb-display-char "*")) 1023 (if (looking-at "\*") (setq gdb-display-char "*"))
1034 (re-search-forward "\\(\\S-+\\) = " end t) 1024 (re-search-forward "\\(\\S-+\\) = " end t)
1035 (setq gdb-last-field (buffer-substring-no-properties 1025 (setq gdb-last-field (match-string-no-properties 1))
1036 (match-beginning 1)
1037 (match-end 1)))
1038 (goto-char (match-beginning 1)) 1026 (goto-char (match-beginning 1))
1039 (let ((last-column (current-column))) 1027 (let ((last-column (current-column)))
1040 (while (re-search-backward "\\s-\\(\\S-+\\) = {" nil t) 1028 (while (re-search-backward "\\s-\\(\\S-+\\) = {" nil t)
1041 (goto-char (match-beginning 1)) 1029 (goto-char (match-beginning 1))
1042 (if (and (< (current-column) last-column) 1030 (if (and (< (current-column) last-column)
1043 (> (count-lines 1 (point)) 1)) 1031 (> (count-lines 1 (point)) 1))
1044 (progn 1032 (progn
1045 (setq gdb-part-expression 1033 (setq gdb-part-expression
1046 (concat "." (buffer-substring-no-properties 1034 (concat "." (match-string-no-properties 1)
1047 (match-beginning 1) 1035 gdb-part-expression))
1048 (match-end 1)) gdb-part-expression))
1049 (setq last-column (current-column)))))) 1036 (setq last-column (current-column))))))
1050 ; * not needed for components of a pointer to a structure in gdb 1037 ;; * not needed for components of a pointer to a structure in gdb
1051 (if (string-equal "*" (substring gdb-full-expression 0 1)) 1038 (if (string-equal "*" (substring gdb-full-expression 0 1))
1052 (setq gdb-full-expression (substring gdb-full-expression 1 nil))) 1039 (setq gdb-full-expression (substring gdb-full-expression 1 nil)))
1053 (setq gdb-full-expression 1040 (setq gdb-full-expression
1054 (concat gdb-full-expression gdb-part-expression "." gdb-last-field)) 1041 (concat gdb-full-expression gdb-part-expression "." gdb-last-field))
1055 (gdb-instance-enqueue-idle-input (list 1042 (gdb-instance-enqueue-idle-input
1056 (concat "server display" gdb-display-char 1043 (list (concat "server display" gdb-display-char
1057 " " gdb-full-expression "\n") 1044 " " gdb-full-expression "\n")
1058 '(lambda () nil)))))) 1045 'ignore)))))
1059 1046
1060 (defun gdb-insert-field () 1047 (defun gdb-insert-field ()
1061 (let ((start (progn (point))) 1048 (let ((start (progn (point)))
1062 (end (progn (next-line) (point))) 1049 (end (progn (next-line) (point)))
1063 (num 0)) 1050 (num 0))
1153 (> (aref indices num) (aref gdb-array-stop num))) 1140 (> (aref indices num) (aref gdb-array-stop num)))
1154 (setq flag nil)) 1141 (setq flag nil))
1155 (aset gdb-array-size num (aref indices num))) 1142 (aset gdb-array-size num (aref indices num)))
1156 (setq num (+ num 1))) 1143 (setq num (+ num 1)))
1157 (if flag 1144 (if flag
1158 (let ((gdb-display-value (substring (car gdb-value-list) 1145 (let ((gdb-display-value (match-string 1 (car gdb-value-list))))
1159 (match-beginning 1)
1160 (match-end 1))))
1161 (setq gdb-display-string (concat gdb-display-string " " 1146 (setq gdb-display-string (concat gdb-display-string " "
1162 gdb-display-value)) 1147 gdb-display-value))
1163 (insert 1148 (insert
1164 (concat indices-string "\t" gdb-display-value "\n")))) 1149 (concat indices-string "\t" gdb-display-value "\n"))))
1165 (setq indices-string "") 1150 (setq indices-string "")
1224 ;; Start accumulating output for the GUD buffer 1209 ;; Start accumulating output for the GUD buffer
1225 (output "")) 1210 (output ""))
1226 1211
1227 ;; Process all the complete markers in this chunk. 1212 ;; Process all the complete markers in this chunk.
1228 (while (string-match "\n\032\032\\(.*\\)\n" burst) 1213 (while (string-match "\n\032\032\\(.*\\)\n" burst)
1229 (let ((annotation (substring burst 1214 (let ((annotation (match-string 1 burst)))
1230 (match-beginning 1)
1231 (match-end 1))))
1232 1215
1233 ;; Stuff prior to the match is just ordinary output. 1216 ;; Stuff prior to the match is just ordinary output.
1234 ;; It is either concatenated to OUTPUT or directed 1217 ;; It is either concatenated to OUTPUT or directed
1235 ;; elsewhere. 1218 ;; elsewhere.
1236 (setq output 1219 (setq output
1241 ;; Take that stuff off the burst. 1224 ;; Take that stuff off the burst.
1242 (setq burst (substring burst (match-end 0))) 1225 (setq burst (substring burst (match-end 0)))
1243 1226
1244 ;; Parse the tag from the annotation, and maybe its arguments. 1227 ;; Parse the tag from the annotation, and maybe its arguments.
1245 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation) 1228 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation)
1246 (let* ((annotation-type (substring annotation 1229 (let* ((annotation-type (match-string 1 annotation))
1247 (match-beginning 1) 1230 (annotation-arguments (match-string 2 annotation))
1248 (match-end 1)))
1249 (annotation-arguments (substring annotation
1250 (match-beginning 2)
1251 (match-end 2)))
1252 (annotation-rule (assoc annotation-type 1231 (annotation-rule (assoc annotation-type
1253 gdb-annotation-rules))) 1232 gdb-annotation-rules)))
1254 ;; Call the handler for this annotation. 1233 ;; Call the handler for this annotation.
1255 (if annotation-rule 1234 (if annotation-rule
1256 (funcall (car (cdr annotation-rule)) 1235 (funcall (car (cdr annotation-rule))
1375 (buffer-read-only nil)) 1354 (buffer-read-only nil))
1376 (delete-region (point-min) (point-max)) 1355 (delete-region (point-min) (point-max))
1377 (insert-buffer (gdb-get-create-instance-buffer 1356 (insert-buffer (gdb-get-create-instance-buffer
1378 'gdb-partial-output-buffer)) 1357 'gdb-partial-output-buffer))
1379 (goto-char p))))) 1358 (goto-char p)))))
1380 ; put customisation here 1359 ;; put customisation here
1381 (,custom-defun))) 1360 (,custom-defun)))
1382 1361
1383 (defmacro def-gdb-auto-updated-buffer 1362 (defmacro def-gdb-auto-updated-buffer (buffer-key trigger-name gdb-command
1384 (buffer-key trigger-name gdb-command output-handler-name custom-defun) 1363 output-handler-name custom-defun)
1385 `(progn 1364 `(progn
1386 (def-gdb-auto-update-trigger ,trigger-name 1365 (def-gdb-auto-update-trigger ,trigger-name
1387 ;; The demand predicate: 1366 ;; The demand predicate:
1388 (lambda () 1367 (lambda () (gdb-get-instance-buffer ',buffer-key))
1389 (gdb-get-instance-buffer ',buffer-key))
1390 ,gdb-command 1368 ,gdb-command
1391 ,output-handler-name) 1369 ,output-handler-name)
1392 (def-gdb-auto-update-handler ,output-handler-name 1370 (def-gdb-auto-update-handler ,output-handler-name
1393 ,trigger-name ,buffer-key ,custom-defun))) 1371 ,trigger-name ,buffer-key ,custom-defun)))
1394 1372
1454 (looking-at "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)") 1432 (looking-at "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)")
1455 (setq flag (char-after (match-beginning 2))) 1433 (setq flag (char-after (match-beginning 2)))
1456 (beginning-of-line) 1434 (beginning-of-line)
1457 (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+") 1435 (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+")
1458 (looking-at "\\(\\S-*\\):\\([0-9]+\\)") 1436 (looking-at "\\(\\S-*\\):\\([0-9]+\\)")
1459 (let ((line (buffer-substring (match-beginning 2) 1437 (let ((line (match-string 2))
1460 (match-end 2))) 1438 (file (match-string 1)))
1461 (file (buffer-substring (match-beginning 1)
1462 (match-end 1))))
1463 (save-excursion 1439 (save-excursion
1464 (set-buffer 1440 (set-buffer
1465 (if (file-exists-p file) 1441 (find-file-noselect (if (file-exists-p file)
1466 (find-file-noselect file) 1442 file
1467 ;else 1443 (expand-file-name file gdb-cdir))))
1468 (find-file-noselect (concat gdb-cdir "/" file)))) 1444 (save-current-buffer
1469 (with-current-buffer (current-buffer) 1445 (set (make-local-variable 'gud-minor-mode) 'gdba)
1470 (progn 1446 (set (make-local-variable 'tool-bar-map)
1471 (set (make-local-variable 'gud-minor-mode) 'gdba) 1447 gud-tool-bar-map)
1472 (set (make-local-variable 'tool-bar-map) 1448 (setq left-margin-width 2)
1473 gud-tool-bar-map) 1449 (if (get-buffer-window (current-buffer))
1474 (setq left-margin-width 2) 1450 (set-window-margins (get-buffer-window
1475 (if (get-buffer-window (current-buffer)) 1451 (current-buffer))
1476 (set-window-margins (get-buffer-window 1452 left-margin-width
1477 (current-buffer)) 1453 right-margin-width)))
1478 left-margin-width 1454 ;; only want one breakpoint icon at each location
1479 right-margin-width))))
1480 ; only want one breakpoint icon at each location
1481 (save-excursion 1455 (save-excursion
1482 (goto-line (string-to-number line)) 1456 (goto-line (string-to-number line))
1483 (let ((start (progn (beginning-of-line) (- (point) 1))) 1457 (let ((start (progn (beginning-of-line) (- (point) 1)))
1484 (end (progn (end-of-line) (+ (point) 1)))) 1458 (end (progn (end-of-line) (+ (point) 1))))
1485 (if (display-graphic-p) 1459 (if (display-graphic-p)
1555 (list 1529 (list
1556 (concat 1530 (concat
1557 (if (eq ?y (char-after (match-beginning 2))) 1531 (if (eq ?y (char-after (match-beginning 2)))
1558 "server disable " 1532 "server disable "
1559 "server enable ") 1533 "server enable ")
1560 (buffer-substring (match-beginning 0) 1534 (match-string 1)
1561 (match-end 1))
1562 "\n") 1535 "\n")
1563 '(lambda () nil)))))) 1536 'ignore)))))
1564 1537
1565 (defun gdb-delete-bp-this-line () 1538 (defun gdb-delete-bp-this-line ()
1566 "Delete the breakpoint on this line." 1539 "Delete the breakpoint on this line."
1567 (interactive) 1540 (interactive)
1568 (beginning-of-line 1) 1541 (beginning-of-line 1)
1570 (error "Not recognized as break/watchpoint line") 1543 (error "Not recognized as break/watchpoint line")
1571 (gdb-instance-enqueue-idle-input 1544 (gdb-instance-enqueue-idle-input
1572 (list 1545 (list
1573 (concat 1546 (concat
1574 "server delete " 1547 "server delete "
1575 (buffer-substring (match-beginning 0) 1548 (match-string 1)
1576 (match-end 1))
1577 "\n") 1549 "\n")
1578 '(lambda () nil))))) 1550 'ignore))))
1579 1551
1580 (defvar gdb-source-window nil) 1552 (defvar gdb-source-window nil)
1581 1553
1582 (defun gdb-goto-bp-this-line () 1554 (defun gdb-goto-bp-this-line ()
1583 "Display the file at the specified breakpoint." 1555 "Display the file at the specified breakpoint."
1584 (interactive) 1556 (interactive)
1585 (save-excursion 1557 (save-excursion
1586 (beginning-of-line 1) 1558 (beginning-of-line 1)
1587 (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+") 1559 (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+")
1588 (looking-at "\\(\\S-*\\):\\([0-9]+\\)")) 1560 (looking-at "\\(\\S-*\\):\\([0-9]+\\)"))
1589 (let ((line (buffer-substring (match-beginning 2) 1561 (let ((line (match-string 2))
1590 (match-end 2))) 1562 (file (match-string 1)))
1591 (file (buffer-substring (match-beginning 1) 1563 (set-window-buffer gdb-source-window
1592 (match-end 1)))) 1564 (find-file-noselect
1593 (if (file-exists-p file) 1565 (if (file-exists-p file)
1594 (set-window-buffer gdb-source-window (find-file-noselect file)) 1566 file
1595 ;else 1567 (expand-file-name file gdb-cdir))))
1596 (setq file (concat gdb-cdir "/" file))
1597 (set-window-buffer gdb-source-window (find-file-noselect file)))
1598 (goto-line (string-to-number line)))) 1568 (goto-line (string-to-number line))))
1599 1569
1600 ;; 1570 ;;
1601 ;; Frames buffers. These display a perpetually correct bactracktrace 1571 ;; Frames buffers. These display a perpetually correct bactracktrace
1602 ;; (from the command `where'). 1572 ;; (from the command `where').
1618 (save-excursion 1588 (save-excursion
1619 (set-buffer (gdb-get-instance-buffer 'gdb-stack-buffer)) 1589 (set-buffer (gdb-get-instance-buffer 'gdb-stack-buffer))
1620 (let ((buffer-read-only nil)) 1590 (let ((buffer-read-only nil))
1621 (goto-char (point-min)) 1591 (goto-char (point-min))
1622 (looking-at "\\S-*\\s-*\\(\\S-*\\)") 1592 (looking-at "\\S-*\\s-*\\(\\S-*\\)")
1623 (setq gdb-current-frame (buffer-substring (match-beginning 1) (match-end 1))) 1593 (setq gdb-current-frame (match-string 1))
1624 (while (< (point) (point-max)) 1594 (while (< (point) (point-max))
1625 (put-text-property (progn (beginning-of-line) (point)) 1595 (put-text-property (progn (beginning-of-line) (point))
1626 (progn (end-of-line) (point)) 1596 (progn (end-of-line) (point))
1627 'mouse-face 'highlight) 1597 'mouse-face 'highlight)
1628 (forward-line 1))))) 1598 (forward-line 1)))))
1662 (gdb-invalidate-frames)) 1632 (gdb-invalidate-frames))
1663 1633
1664 (defun gdb-get-frame-number () 1634 (defun gdb-get-frame-number ()
1665 (save-excursion 1635 (save-excursion
1666 (let* ((pos (re-search-backward "^#\\([0-9]*\\)" nil t)) 1636 (let* ((pos (re-search-backward "^#\\([0-9]*\\)" nil t))
1667 (n (or (and pos 1637 (n (or (and pos (string-to-int (match-string 1))) 0)))
1668 (string-to-int
1669 (buffer-substring (match-beginning 1)
1670 (match-end 1))))
1671 0)))
1672 n))) 1638 n)))
1673 1639
1674 (defun gdb-frames-select-by-mouse (e) 1640 (defun gdb-frames-select-by-mouse (e)
1675 "Display the source of the selected frame." 1641 "Display the source of the selected frame."
1676 (interactive "e") 1642 (interactive "e")
1682 (setq selection (gdb-get-frame-number)))) 1648 (setq selection (gdb-get-frame-number))))
1683 (select-window (posn-window (event-end e))) 1649 (select-window (posn-window (event-end e)))
1684 (save-excursion 1650 (save-excursion
1685 (set-buffer (gdb-get-instance-buffer 'gdba)) 1651 (set-buffer (gdb-get-instance-buffer 'gdba))
1686 (gdb-instance-enqueue-idle-input 1652 (gdb-instance-enqueue-idle-input
1687 (list 1653 (list (gud-format-command "server frame %p\n" selection)
1688 (concat (gud-format-command "server frame %p" selection) 1654 'ignore))
1689 "\n") 1655 (gud-display-frame))))
1690 '(lambda () nil)))
1691 (gud-display-frame))))
1692 1656
1693 1657
1694 ;; 1658 ;;
1695 ;; Registers buffers 1659 ;; Registers buffers
1696 ;; 1660 ;;
1749 gdb-info-locals-custom) 1713 gdb-info-locals-custom)
1750 1714
1751 1715
1752 ;Abbreviate for arrays and structures. These can be expanded using gud-display 1716 ;Abbreviate for arrays and structures. These can be expanded using gud-display
1753 (defun gdb-info-locals-handler nil 1717 (defun gdb-info-locals-handler nil
1754 (set-gdb-instance-pending-triggers (delq (quote gdb-invalidate-locals) 1718 (set-gdb-instance-pending-triggers (delq 'gdb-invalidate-locals
1755 (gdb-instance-pending-triggers))) 1719 (gdb-instance-pending-triggers)))
1756 (let ((buf (gdb-get-instance-buffer (quote gdb-partial-output-buffer)))) 1720 (let ((buf (gdb-get-instance-buffer 'gdb-partial-output-buffer)))
1757 (save-excursion 1721 (save-excursion
1758 (set-buffer buf) 1722 (set-buffer buf)
1759 (goto-char (point-min)) 1723 (goto-char (point-min))
1760 (replace-regexp "^ .*\n" "") 1724 (replace-regexp "^ .*\n" "")
1761 (goto-char (point-min)) 1725 (goto-char (point-min))
1762 (replace-regexp "{[-0-9, {}\]*\n" "(array);\n"))) 1726 (replace-regexp "{[-0-9, {}\]*\n" "(array);\n")))
1763 (goto-char (point-min)) 1727 (goto-char (point-min))
1764 (replace-regexp "{.*=.*\n" "(structure);\n") 1728 (replace-regexp "{.*=.*\n" "(structure);\n")
1765 (let ((buf (gdb-get-instance-buffer (quote gdb-locals-buffer)))) 1729 (let ((buf (gdb-get-instance-buffer 'gdb-locals-buffer)))
1766 (and buf (save-excursion 1730 (and buf (save-excursion
1767 (set-buffer buf) 1731 (set-buffer buf)
1768 (let ((p (point)) 1732 (let ((p (point))
1769 (buffer-read-only nil)) 1733 (buffer-read-only nil))
1770 (delete-region (point-min) (point-max)) 1734 (delete-region (point-min) (point-max))
1771 (insert-buffer (gdb-get-create-instance-buffer 1735 (insert-buffer (gdb-get-create-instance-buffer
1772 (quote gdb-partial-output-buffer))) 1736 'gdb-partial-output-buffer))
1773 (goto-char p))))) 1737 (goto-char p)))))
1774 (run-hooks (quote gdb-info-locals-hook))) 1738 (run-hooks 'gdb-info-locals-hook))
1775 1739
1776 (defun gdb-info-locals-custom () 1740 (defun gdb-info-locals-custom ()
1777 nil) 1741 nil)
1778 1742
1779 (gdb-set-instance-buffer-rules 'gdb-locals-buffer 1743 (gdb-set-instance-buffer-rules 'gdb-locals-buffer
1882 (list 1846 (list
1883 (concat 1847 (concat
1884 (if (eq ?y (char-after (match-beginning 2))) 1848 (if (eq ?y (char-after (match-beginning 2)))
1885 "server disable display " 1849 "server disable display "
1886 "server enable display ") 1850 "server enable display ")
1887 (buffer-substring (match-beginning 0) 1851 (match-string 1)
1888 (match-end 1))
1889 "\n") 1852 "\n")
1890 '(lambda () nil)))))) 1853 'ignore)))))
1891 1854
1892 (defun gdb-delete-disp-this-line () 1855 (defun gdb-delete-disp-this-line ()
1893 "Delete the displayed expression on this line." 1856 "Delete the displayed expression on this line."
1894 (interactive) 1857 (interactive)
1895 (save-excursion 1858 (save-excursion
1896 (set-buffer 1859 (set-buffer
1897 (gdb-get-instance-buffer 'gdb-display-buffer)) 1860 (gdb-get-instance-buffer 'gdb-display-buffer))
1898 (beginning-of-line 1) 1861 (beginning-of-line 1)
1899 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)")) 1862 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)"))
1900 (error "No expression on this line") 1863 (error "No expression on this line")
1901 (let ((number (buffer-substring (match-beginning 0) 1864 (let ((number (match-string 1)))
1902 (match-end 1))))
1903 (gdb-instance-enqueue-idle-input 1865 (gdb-instance-enqueue-idle-input
1904 (list (concat "server delete display " number "\n") 1866 (list (concat "server delete display " number "\n")
1905 '(lambda () nil))) 1867 'ignore))
1906 (if (not (display-graphic-p)) 1868 (if (not (display-graphic-p))
1907 (kill-buffer (get-buffer (concat "*display " number "*"))) 1869 (kill-buffer (get-buffer (concat "*display " number "*")))
1908 ;else 1870 ;else
1909 (catch 'frame-found 1871 (catch 'frame-found
1910 (let ((frames (frame-list))) 1872 (let ((frames (frame-list)))
2177 (if (eq (selected-window) (minibuffer-window)) 2139 (if (eq (selected-window) (minibuffer-window))
2178 (other-window 1)) 2140 (other-window 1))
2179 (delete-other-windows)) 2141 (delete-other-windows))
2180 2142
2181 (defun gdb-source-info () 2143 (defun gdb-source-info ()
2182 "Finds the source file where the program starts and displays it with related 2144 "Find the source file where the program starts and displays it with related
2183 buffers." 2145 buffers."
2184 (goto-char (point-min)) 2146 (goto-char (point-min))
2185 (re-search-forward "directory is ") 2147 (search-forward "directory is ")
2186 (looking-at "\\(\\S-*\\)") 2148 (looking-at "\\S-*")
2187 (setq gdb-cdir (buffer-substring (match-beginning 1) (match-end 1))) 2149 (setq gdb-cdir (match-string 0))
2188 (re-search-forward "Located in ") 2150 (search-forward "Located in ")
2189 (looking-at "\\(\\S-*\\)") 2151 (looking-at "\\S-*")
2190 (setq gdb-main-file (buffer-substring (match-beginning 1) (match-end 1))) 2152 (setq gdb-main-file (match-string 0))
2191 ;; Make sure we are not in the minibuffer window when we try to delete 2153 ;; Make sure we are not in the minibuffer window when we try to delete
2192 ;; all other windows. 2154 ;; all other windows.
2193 (if (eq (selected-window) (minibuffer-window)) 2155 (if (window-minibuffer-p (selected-window))
2194 (other-window 1)) 2156 (other-window 1))
2195 (delete-other-windows) 2157 (delete-other-windows)
2196 (if gdb-many-windows 2158 (if gdb-many-windows
2197 (gdb-setup-windows) 2159 (gdb-setup-windows)
2198 ;else
2199 (gdb-display-breakpoints-buffer) 2160 (gdb-display-breakpoints-buffer)
2200 (gdb-display-display-buffer) 2161 (gdb-display-display-buffer)
2201 (gdb-display-stack-buffer) 2162 (gdb-display-stack-buffer)
2202 (delete-other-windows) 2163 (delete-other-windows)
2203 (split-window) 2164 (split-window)
2305 (defun gdb-delete-display () 2266 (defun gdb-delete-display ()
2306 "Delete displayed expression and its frame." 2267 "Delete displayed expression and its frame."
2307 (interactive) 2268 (interactive)
2308 (gdb-instance-enqueue-idle-input 2269 (gdb-instance-enqueue-idle-input
2309 (list (concat "server delete display " gdb-display-number "\n") 2270 (list (concat "server delete display " gdb-display-number "\n")
2310 '(lambda () nil))) 2271 'ignore))
2311 (kill-buffer nil) 2272 (kill-buffer nil)
2312 (delete-frame)) 2273 (delete-frame))
2313 2274
2314 ;; 2275 ;;
2315 ;; Assembler buffer 2276 ;; Assembler buffer
2348 (if (looking-at "[^\t].*breakpoint") 2309 (if (looking-at "[^\t].*breakpoint")
2349 (progn 2310 (progn
2350 (looking-at 2311 (looking-at
2351 "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x0\\(\\S-*\\)") 2312 "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x0\\(\\S-*\\)")
2352 ; info break gives '0x0' (8 digit) while dump gives '0x' (7 digit) 2313 ; info break gives '0x0' (8 digit) while dump gives '0x' (7 digit)
2353 (setq address (concat "0x" (buffer-substring (match-beginning 3) 2314 (setq address (concat "0x" (match-string 3)))
2354 (match-end 3))))
2355 (setq flag (char-after (match-beginning 2))) 2315 (setq flag (char-after (match-beginning 2)))
2356 (save-excursion 2316 (save-excursion
2357 (set-buffer buffer) 2317 (set-buffer buffer)
2358 (goto-char (point-min)) 2318 (goto-char (point-min))
2359 (if (re-search-forward address nil t) 2319 (if (re-search-forward address nil t)
2425 (defvar gdb-prev-main-or-pc nil) 2385 (defvar gdb-prev-main-or-pc nil)
2426 2386
2427 ; modified because if gdb-main-or-pc has changed value a new command 2387 ; modified because if gdb-main-or-pc has changed value a new command
2428 ; must be enqueued to update the buffer with the new output 2388 ; must be enqueued to update the buffer with the new output
2429 (defun gdb-invalidate-assembler (&optional ignored) 2389 (defun gdb-invalidate-assembler (&optional ignored)
2430 (if (and ((lambda () 2390 (if (and (gdb-get-instance-buffer 'gdb-assembler-buffer)
2431 (gdb-get-instance-buffer (quote gdb-assembler-buffer)))) 2391 (or (not (member 'gdb-invalidate-assembler
2432 (or (not (member (quote gdb-invalidate-assembler) 2392 (gdb-instance-pending-triggers)))
2433 (gdb-instance-pending-triggers))) 2393 (not (string-equal gdb-main-or-pc gdb-prev-main-or-pc))))
2434 (not (string-equal gdb-main-or-pc gdb-prev-main-or-pc))))
2435 (progn 2394 (progn
2436 2395
2437 ; take previous disassemble command off the queue 2396 ;; take previous disassemble command off the queue
2438 (save-excursion 2397 (save-excursion
2439 (set-buffer (gdb-get-instance-buffer 'gdba)) 2398 (set-buffer (gdb-get-instance-buffer 'gdba))
2440 (let ((queue gdb-idle-input-queue) (item)) 2399 (let ((queue gdb-idle-input-queue) (item))
2441 (while queue 2400 (while queue
2442 (setq item (car queue)) 2401 (setq item (car queue))
2443 (if (equal (cdr item) '(gdb-assembler-handler)) 2402 (if (equal (cdr item) '(gdb-assembler-handler))
2444 (delete item gdb-idle-input-queue)) 2403 (delete item gdb-idle-input-queue))
2445 (setq queue (cdr queue))))) 2404 (setq queue (cdr queue)))))
2446 2405
2447 (gdb-instance-enqueue-idle-input 2406 (gdb-instance-enqueue-idle-input
2448 (list (concat "server disassemble " gdb-main-or-pc "\n") 2407 (list (concat "server disassemble " gdb-main-or-pc "\n")
2449 (quote gdb-assembler-handler))) 2408 'gdb-assembler-handler))
2450 (set-gdb-instance-pending-triggers 2409 (set-gdb-instance-pending-triggers
2451 (cons (quote gdb-invalidate-assembler) 2410 (cons 'gdb-invalidate-assembler
2452 (gdb-instance-pending-triggers))) 2411 (gdb-instance-pending-triggers)))
2453 (setq gdb-prev-main-or-pc gdb-main-or-pc)))) 2412 (setq gdb-prev-main-or-pc gdb-main-or-pc))))
2454 2413
2455 (defun gdb-delete-line () 2414 (defun gdb-delete-line ()
2456 "Delete the current line." 2415 "Delete the current line."
2457 (interactive) 2416 (interactive)
2458 (let ((start (progn (beginning-of-line) (point))) 2417 (let ((start (progn (beginning-of-line) (point)))