Mercurial > emacs
comparison lisp/gdb-ui.el @ 52328:06d74a21fa32
(gdba): Remove gdb-quit (previously removed) from
documentation.
(gdb-source, gdb-source-info): Update to assembler unnecessary
as its done after each GDB command anyway.
(gdb-pre-prompt): Use with-current-buffer.
(gdb-insert-field): Add help-echo text.
(gdb-invalidate-assembler): Re-display of assembler now done in
gdb-info-breakpoints-custom.
(gdb-info-breakpoints-custom): Force re-display of assembler to
happen *after* update of breakpoints buffer.
(gdb-display-source-buffer): Don't choke if gdb-source-window
isn't visible.
(gdb-put-string, gdb-put-arrow): Remove free variables.
author | Nick Roberts <nickrob@snap.net.nz> |
---|---|
date | Sun, 24 Aug 2003 20:40:03 +0000 |
parents | 57a5b7571acc |
children | 695cf19ef79e |
comparison
equal
deleted
inserted
replaced
52327:8bc12f54b756 | 52328:06d74a21fa32 |
---|---|
119 Pointers in structures may be followed in a tree-like fashion. | 119 Pointers in structures may be followed in a tree-like fashion. |
120 | 120 |
121 The following interactive lisp functions help control operation : | 121 The following interactive lisp functions help control operation : |
122 | 122 |
123 `gdb-many-windows' - Toggle the number of windows gdb uses. | 123 `gdb-many-windows' - Toggle the number of windows gdb uses. |
124 `gdb-restore-windows' - To restore the window layout. | 124 `gdb-restore-windows' - To restore the window layout." |
125 `gdb-quit' - To delete (most) of the buffers used by GDB-UI and | |
126 reset variables." | |
127 ;; | 125 ;; |
128 (interactive (list (gud-query-cmdline 'gdba))) | 126 (interactive (list (gud-query-cmdline 'gdba))) |
129 ;; | 127 ;; |
130 ;; Let's start with a basic gud-gdb buffer and then modify it a bit. | 128 ;; Let's start with a basic gud-gdb buffer and then modify it a bit. |
131 (gdb command-line) | 129 (gdb command-line) |
568 (setq gud-last-frame | 566 (setq gud-last-frame |
569 (cons | 567 (cons |
570 (match-string 1 args) | 568 (match-string 1 args) |
571 (string-to-int (match-string 2 args)))) | 569 (string-to-int (match-string 2 args)))) |
572 (setq gdb-current-address (match-string 3 args)) | 570 (setq gdb-current-address (match-string 3 args)) |
573 (setq gdb-view-source t) | 571 (setq gdb-view-source t)) |
574 ;;update with new frame for machine code if necessary | |
575 (gdb-invalidate-assembler)) | |
576 | 572 |
577 (defun gdb-send-item (item) | 573 (defun gdb-send-item (item) |
578 (gdb-set-current-item item) | 574 (gdb-set-current-item item) |
579 (if (stringp item) | 575 (if (stringp item) |
580 (progn | 576 (progn |
594 ((eq sink 'user) t) | 590 ((eq sink 'user) t) |
595 ((eq sink 'emacs) | 591 ((eq sink 'emacs) |
596 (gdb-set-output-sink 'post-emacs) | 592 (gdb-set-output-sink 'post-emacs) |
597 (let ((handler | 593 (let ((handler |
598 (car (cdr (gdb-get-current-item))))) | 594 (car (cdr (gdb-get-current-item))))) |
599 (save-excursion | 595 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) |
600 (set-buffer (gdb-get-create-buffer | |
601 'gdb-partial-output-buffer)) | |
602 (funcall handler)))) | 596 (funcall handler)))) |
603 (t | 597 (t |
604 (gdb-set-output-sink 'user) | 598 (gdb-set-output-sink 'user) |
605 (error "Phase error in gdb-pre-prompt (got %s)" sink))))) | 599 (error "Phase error in gdb-pre-prompt (got %s)" sink))))) |
606 | 600 |
943 (insert "\t") | 937 (insert "\t") |
944 (setq num (+ num 1))) | 938 (setq num (+ num 1))) |
945 (insert-buffer-substring (gdb-get-buffer | 939 (insert-buffer-substring (gdb-get-buffer |
946 'gdb-partial-output-buffer) | 940 'gdb-partial-output-buffer) |
947 start end) | 941 start end) |
948 (add-text-properties (- (point) (- end start)) (- (point) 1) | 942 (add-text-properties |
949 `(mouse-face highlight local-map ,gdb-dive-map)))) | 943 (- (point) (- end start)) (- (point) 1) |
944 `(mouse-face highlight | |
945 local-map ,gdb-dive-map | |
946 help-echo "mouse-2: dive, S-mouse-2: dive in a new frame")))) | |
950 (delete-region start end))) | 947 (delete-region start end))) |
951 | 948 |
952 (defvar gdb-values nil) | 949 (defvar gdb-values nil) |
953 | 950 |
954 (defun gdb-array-format () | 951 (defun gdb-array-format () |
1394 'left-margin))) | 1391 'left-margin))) |
1395 (gdb-remove-strings start end) | 1392 (gdb-remove-strings start end) |
1396 (if (eq ?y flag) | 1393 (if (eq ?y flag) |
1397 (gdb-put-string "B" (+ start 1)) | 1394 (gdb-put-string "B" (+ start 1)) |
1398 (gdb-put-string "b" (+ start 1)))))))))))) | 1395 (gdb-put-string "b" (+ start 1)))))))))))) |
1399 (end-of-line)))))) | 1396 (end-of-line))))) |
1397 (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom))) | |
1400 | 1398 |
1401 (defun gdb-breakpoints-buffer-name () | 1399 (defun gdb-breakpoints-buffer-name () |
1402 (with-current-buffer gud-comint-buffer | 1400 (with-current-buffer gud-comint-buffer |
1403 (concat "*breakpoints of " (gdb-get-target-string) "*"))) | 1401 (concat "*breakpoints of " (gdb-get-target-string) "*"))) |
1404 | 1402 |
1480 (switch-to-buffer (find-file-noselect | 1478 (switch-to-buffer (find-file-noselect |
1481 (if (file-exists-p file) | 1479 (if (file-exists-p file) |
1482 file | 1480 file |
1483 (expand-file-name file gdb-cdir)))) | 1481 (expand-file-name file gdb-cdir)))) |
1484 (goto-line (string-to-number line)))))) | 1482 (goto-line (string-to-number line)))))) |
1485 ;; I'll get this to work one day! | |
1486 ;; (defun gdb-goto-breakpoint () | |
1487 ;; "Display the file in the source buffer at the breakpoint specified on the | |
1488 ;; current line." | |
1489 ;; (interactive) | |
1490 ;; (save-excursion | |
1491 ;; (let ((eol (progn (end-of-line) (point)))) | |
1492 ;; (beginning-of-line 1) | |
1493 ;; (if (re-search-forward "\\(\\S-*\\):\\([0-9]+\\)" eol t) | |
1494 ;; (let ((line (match-string 2)) | |
1495 ;; (file (match-string 1))) | |
1496 ;; (save-selected-window | |
1497 ;; (select-window gdb-source-window) | |
1498 ;; (switch-to-buffer (find-file-noselect | |
1499 ;; (if (file-exists-p file) | |
1500 ;; file | |
1501 ;; (expand-file-name file gdb-cdir)))) | |
1502 ;; (goto-line (string-to-number line)))))) | |
1503 ;; (let ((eol (progn (end-of-line) (point)))) | |
1504 ;; (beginning-of-line 1) | |
1505 ;; (if (re-search-forward "<\\(\\S-*?\\)\\(\\+*[0-9]*\\)>" eol t) | |
1506 ;; (save-selected-window | |
1507 ;; (select-window gdb-source-window) | |
1508 ;; (gdb-get-create-buffer 'gdb-assembler-buffer) | |
1509 ;; (gdb-enqueue-input | |
1510 ;; (list (concat "server disassemble " (match-string 1) "\n") | |
1511 ;; 'gdb-assembler-handler)) | |
1512 ;; (with-current-buffer (gdb-get-buffer 'gdb-assembler-buffer) | |
1513 ;; (re-search-forward | |
1514 ;; (concat (match-string 1) (match-string 2))))))))) | |
1515 | 1483 |
1516 (defun gdb-mouse-goto-breakpoint (event) | 1484 (defun gdb-mouse-goto-breakpoint (event) |
1517 "Display the file in the source buffer at the selected breakpoint." | 1485 "Display the file in the source buffer at the selected breakpoint." |
1518 (interactive "e") | 1486 (interactive "e") |
1519 (mouse-set-point event) | 1487 (mouse-set-point event) |
1958 (let ((must-split nil) | 1926 (let ((must-split nil) |
1959 (answer nil)) | 1927 (answer nil)) |
1960 (unwind-protect | 1928 (unwind-protect |
1961 (progn | 1929 (progn |
1962 (walk-windows | 1930 (walk-windows |
1963 '(lambda (win) | 1931 #'(lambda (win) |
1964 (if (or (eq gud-comint-buffer (window-buffer win)) | 1932 (if (or (eq gud-comint-buffer (window-buffer win)) |
1965 (eq gdb-source-window win)) | 1933 (eq gdb-source-window win)) |
1966 (set-window-dedicated-p win t)))) | 1934 (set-window-dedicated-p win t)))) |
1967 (setq answer (get-buffer-window buf)) | 1935 (setq answer (get-buffer-window buf)) |
1968 (if (not answer) | 1936 (if (not answer) |
1971 (progn | 1939 (progn |
1972 (set-window-buffer window buf) | 1940 (set-window-buffer window buf) |
1973 (setq answer window)) | 1941 (setq answer window)) |
1974 (setq must-split t))))) | 1942 (setq must-split t))))) |
1975 (walk-windows | 1943 (walk-windows |
1976 '(lambda (win) | 1944 #'(lambda (win) |
1977 (if (or (eq gud-comint-buffer (window-buffer win)) | 1945 (if (or (eq gud-comint-buffer (window-buffer win)) |
1978 (eq gdb-source-window win)) | 1946 (eq gdb-source-window win)) |
1979 (set-window-dedicated-p win nil))))) | 1947 (set-window-dedicated-p win nil))))) |
1980 (if must-split | 1948 (if must-split |
1981 (let* ((largest (get-largest-window)) | 1949 (let* ((largest (get-largest-window)) |
1985 (set-window-buffer answer buf))) | 1953 (set-window-buffer answer buf))) |
1986 answer)) | 1954 answer)) |
1987 | 1955 |
1988 (defun gdb-display-source-buffer (buffer) | 1956 (defun gdb-display-source-buffer (buffer) |
1989 (if (eq gdb-selected-view 'source) | 1957 (if (eq gdb-selected-view 'source) |
1990 (set-window-buffer gdb-source-window buffer) | 1958 (progn |
1991 (set-window-buffer gdb-source-window | 1959 (if (window-live-p gdb-source-window) |
1992 (gdb-get-buffer 'gdb-assembler-buffer))) | 1960 (set-window-buffer gdb-source-window buffer) |
1993 gdb-source-window) | 1961 (gdb-display-buffer buffer) |
1962 (setq gdb-source-window (get-buffer-window buffer))) | |
1963 gdb-source-window) | |
1964 (if (window-live-p gdb-source-window) | |
1965 (set-window-buffer gdb-source-window | |
1966 (gdb-get-buffer 'gdb-assembler-buffer)) | |
1967 (let ((buf (gdb-get-buffer 'gdb-assembler-buffer))) | |
1968 (gdb-display-buffer buf) | |
1969 (setq gdb-source-window (get-buffer-window buf)))) | |
1970 nil)) | |
1994 | 1971 |
1995 | 1972 |
1996 ;;; Shared keymap initialization: | 1973 ;;; Shared keymap initialization: |
1997 | 1974 |
1998 (let ((menu (make-sparse-keymap "GDB-Frames"))) | 1975 (let ((menu (make-sparse-keymap "GDB-Frames"))) |
2195 (if gdb-view-source | 2172 (if gdb-view-source |
2196 (switch-to-buffer | 2173 (switch-to-buffer |
2197 (if gud-last-last-frame | 2174 (if gud-last-last-frame |
2198 (gud-find-file (car gud-last-last-frame)) | 2175 (gud-find-file (car gud-last-last-frame)) |
2199 (gud-find-file gdb-main-file))) | 2176 (gud-find-file gdb-main-file))) |
2200 (switch-to-buffer (gdb-get-create-buffer 'gdb-assembler-buffer)) | 2177 (switch-to-buffer (gdb-get-create-buffer 'gdb-assembler-buffer))) |
2201 (gdb-invalidate-assembler)) | |
2202 (setq gdb-source-window (get-buffer-window (current-buffer))) | 2178 (setq gdb-source-window (get-buffer-window (current-buffer))) |
2203 (other-window 1))) | 2179 (other-window 1))) |
2204 | 2180 |
2205 ;;from put-image | 2181 ;;from put-image |
2206 (defun gdb-put-string (putstring pos) | 2182 (defun gdb-put-string (putstring pos) |
2207 "Put string PUTSTRING in front of POS in the current buffer. | 2183 "Put string PUTSTRING in front of POS in the current buffer. |
2208 PUTSTRING is displayed by putting an overlay into the current buffer with a | 2184 PUTSTRING is displayed by putting an overlay into the current buffer with a |
2209 `before-string' STRING that has a `display' property whose value is | 2185 `before-string' STRING that has a `display' property whose value is |
2210 PUTSTRING." | 2186 PUTSTRING." |
2211 (setq string "x") | 2187 (let ((gdb-string "x") |
2212 (let ((buffer (current-buffer))) | 2188 (buffer (current-buffer))) |
2213 (setq string (copy-sequence string)) | |
2214 (let ((overlay (make-overlay pos pos buffer)) | 2189 (let ((overlay (make-overlay pos pos buffer)) |
2215 (prop (list (list 'margin 'left-margin) putstring))) | 2190 (prop (list (list 'margin 'left-margin) putstring))) |
2216 (put-text-property 0 (length string) 'display prop string) | 2191 (put-text-property 0 (length gdb-string) 'display prop gdb-string) |
2217 (overlay-put overlay 'put-break t) | 2192 (overlay-put overlay 'put-break t) |
2218 (overlay-put overlay 'before-string string)))) | 2193 (overlay-put overlay 'before-string gdb-string)))) |
2219 | 2194 |
2220 ;;from remove-images | 2195 ;;from remove-images |
2221 (defun gdb-remove-strings (start end &optional buffer) | 2196 (defun gdb-remove-strings (start end &optional buffer) |
2222 "Remove strings between START and END in BUFFER. | 2197 "Remove strings between START and END in BUFFER. |
2223 Remove only strings that were put in BUFFER with calls to `put-string'. | 2198 Remove only strings that were put in BUFFER with calls to `put-string'. |
2234 (defun gdb-put-arrow (putstring pos) | 2209 (defun gdb-put-arrow (putstring pos) |
2235 "Put arrow string PUTSTRING in the left margin in front of POS | 2210 "Put arrow string PUTSTRING in the left margin in front of POS |
2236 in the current buffer. PUTSTRING is displayed by putting an | 2211 in the current buffer. PUTSTRING is displayed by putting an |
2237 overlay into the current buffer with a `before-string' | 2212 overlay into the current buffer with a `before-string' |
2238 \"gdb-arrow\" that has a `display' property whose value is | 2213 \"gdb-arrow\" that has a `display' property whose value is |
2239 PUTSTRING. STRING is defaulted if you omit it. POS may be an | 2214 PUTSTRING. POS may be an integer or marker." |
2240 integer or marker." | 2215 (let ((gdb-string "gdb-arrow") |
2241 (setq string "gdb-arrow") | 2216 (buffer (current-buffer))) |
2242 (let ((buffer (current-buffer))) | |
2243 (setq string (copy-sequence string)) | |
2244 (let ((overlay (make-overlay pos pos buffer)) | 2217 (let ((overlay (make-overlay pos pos buffer)) |
2245 (prop (list (list 'margin 'left-margin) putstring))) | 2218 (prop (list (list 'margin 'left-margin) putstring))) |
2246 (put-text-property 0 (length string) 'display prop string) | 2219 (put-text-property 0 (length gdb-string) 'display prop gdb-string) |
2247 (overlay-put overlay 'put-arrow t) | 2220 (overlay-put overlay 'put-arrow t) |
2248 (overlay-put overlay 'before-string string)))) | 2221 (overlay-put overlay 'before-string gdb-string)))) |
2249 | 2222 |
2250 (defun gdb-remove-arrow (&optional buffer) | 2223 (defun gdb-remove-arrow (&optional buffer) |
2251 "Remove arrow in BUFFER. | 2224 "Remove arrow in BUFFER. |
2252 Remove only images that were put in BUFFER with calls to `put-arrow'. | 2225 Remove only images that were put in BUFFER with calls to `put-arrow'. |
2253 BUFFER nil or omitted means use the current buffer." | 2226 BUFFER nil or omitted means use the current buffer." |
2372 (setq mode-name "Assembler") | 2345 (setq mode-name "Assembler") |
2373 (setq left-margin-width 2) | 2346 (setq left-margin-width 2) |
2374 (setq fringes-outside-margins t) | 2347 (setq fringes-outside-margins t) |
2375 (setq buffer-read-only t) | 2348 (setq buffer-read-only t) |
2376 (use-local-map gdb-assembler-mode-map) | 2349 (use-local-map gdb-assembler-mode-map) |
2377 (gdb-invalidate-assembler) | 2350 (gdb-invalidate-assembler)) |
2378 (gdb-invalidate-breakpoints)) | |
2379 | 2351 |
2380 (defun gdb-assembler-buffer-name () | 2352 (defun gdb-assembler-buffer-name () |
2381 (with-current-buffer gud-comint-buffer | 2353 (with-current-buffer gud-comint-buffer |
2382 (concat "*Machine Code " (gdb-get-target-string) "*"))) | 2354 (concat "*Machine Code " (gdb-get-target-string) "*"))) |
2383 | 2355 |
2394 ;; modified because if gdb-current-address has changed value a new command | 2366 ;; modified because if gdb-current-address has changed value a new command |
2395 ;; must be enqueued to update the buffer with the new output | 2367 ;; must be enqueued to update the buffer with the new output |
2396 (defun gdb-invalidate-assembler (&optional ignored) | 2368 (defun gdb-invalidate-assembler (&optional ignored) |
2397 (if (gdb-get-buffer 'gdb-assembler-buffer) | 2369 (if (gdb-get-buffer 'gdb-assembler-buffer) |
2398 (progn | 2370 (progn |
2399 (if (string-equal gdb-current-frame gdb-previous-frame) | 2371 (unless (string-equal gdb-current-frame gdb-previous-frame) |
2400 (gdb-assembler-custom) | |
2401 (if (or (not (member 'gdb-invalidate-assembler | 2372 (if (or (not (member 'gdb-invalidate-assembler |
2402 (gdb-get-pending-triggers))) | 2373 (gdb-get-pending-triggers))) |
2403 (not (string-equal gdb-current-address | 2374 (not (string-equal gdb-current-address |
2404 gdb-previous-address))) | 2375 gdb-previous-address))) |
2405 (progn | 2376 (progn |
2448 (eq gdb-selected-view 'assembler)) | 2419 (eq gdb-selected-view 'assembler)) |
2449 (progn | 2420 (progn |
2450 (set-window-buffer | 2421 (set-window-buffer |
2451 gdb-source-window | 2422 gdb-source-window |
2452 (gdb-get-create-buffer 'gdb-assembler-buffer)) | 2423 (gdb-get-create-buffer 'gdb-assembler-buffer)) |
2424 ;;update with new frame for machine code if necessary | |
2453 (gdb-invalidate-assembler))))))) | 2425 (gdb-invalidate-assembler))))))) |
2454 | 2426 |
2455 (provide 'gdb-ui) | 2427 (provide 'gdb-ui) |
2456 | 2428 |
2457 ;;; gdb-ui.el ends here | 2429 ;;; gdb-ui.el ends here |