Commit 72d83b26 authored by Nick Roberts's avatar Nick Roberts

Reported in thread for Bug#4375.

* progmodes/gud.el (gud-tooltip-print-command): Use MI command
"-data-evaluate-expression" instead of print.
* progmodes/gdb-mi.el (gdb-tooltip-print-1): Ditto.
(gdb-tooltip-print): Parse output from above MI command.
parent 9f16c547
...@@ -854,17 +854,13 @@ detailed description of this mode. ...@@ -854,17 +854,13 @@ detailed description of this mode.
(defvar tooltip-use-echo-area) (defvar tooltip-use-echo-area)
(defun gdb-tooltip-print (expr) (defun gdb-tooltip-print (expr)
(tooltip-show
(with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer) (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
(goto-char (point-min)) (goto-char (point-min))
(let ((string (if (re-search-forward ".*value=\\(\".*\"\\)" nil t)
(if (search-forward "=" nil t) (tooltip-show
(concat expr (buffer-substring (- (point) 2) (point-max))) (concat expr " = " (read (match-string 1)))
(buffer-string)))) (or gud-tooltip-echo-area tooltip-use-echo-area
;; remove newline for gud-tooltip-echo-area (not (display-graphic-p)))))))
(substring string 0 (- (length string) 1))))
(or gud-tooltip-echo-area tooltip-use-echo-area
(not (display-graphic-p)))))
;; If expr is a macro for a function don't print because of possible dangerous ;; If expr is a macro for a function don't print because of possible dangerous
;; side-effects. Also printing a function within a tooltip generates an ;; side-effects. Also printing a function within a tooltip generates an
...@@ -875,7 +871,7 @@ detailed description of this mode. ...@@ -875,7 +871,7 @@ detailed description of this mode.
(if (search-forward "expands to: " nil t) (if (search-forward "expands to: " nil t)
(unless (looking-at "\\S-+.*(.*).*") (unless (looking-at "\\S-+.*(.*).*")
(gdb-input (gdb-input
(list (concat "print " expr) (list (concat "-data-evaluate-expression " expr)
`(lambda () (gdb-tooltip-print ,expr)))))))) `(lambda () (gdb-tooltip-print ,expr))))))))
(defun gdb-init-buffer () (defun gdb-init-buffer ()
...@@ -1307,7 +1303,7 @@ this trigger is subscribed to `gdb-buf-publisher' and called with ...@@ -1307,7 +1303,7 @@ this trigger is subscribed to `gdb-buf-publisher' and called with
(apply ',expr args)))) (apply ',expr args))))
;; Used to define all gdb-frame-*-buffer functions except ;; Used to define all gdb-frame-*-buffer functions except
;; `gdb-frame-separate-io-buffer' ;; `gdb-frame-io-buffer'
(defmacro def-gdb-frame-for-buffer (name buffer &optional doc) (defmacro def-gdb-frame-for-buffer (name buffer &optional doc)
"Define a function NAME which shows gdb BUFFER in a separate frame. "Define a function NAME which shows gdb BUFFER in a separate frame.
...@@ -1401,7 +1397,7 @@ DOC is an optional documentation string." ...@@ -1401,7 +1397,7 @@ DOC is an optional documentation string."
(gdb-get-target-string) (gdb-get-target-string)
"*")) "*"))
(defun gdb-display-separate-io-buffer () (defun gdb-display-io-buffer ()
"Display IO of debugged program in a separate window." "Display IO of debugged program in a separate window."
(interactive) (interactive)
(gdb-display-buffer (gdb-display-buffer
...@@ -1414,7 +1410,7 @@ DOC is an optional documentation string." ...@@ -1414,7 +1410,7 @@ DOC is an optional documentation string."
(menu-bar-lines . nil) (menu-bar-lines . nil)
(minibuffer . nil))) (minibuffer . nil)))
(defun gdb-frame-separate-io-buffer () (defun gdb-frame-io-buffer ()
"Display IO of debugged program in a new frame." "Display IO of debugged program in a new frame."
(interactive) (interactive)
(let ((special-display-regexps (append special-display-regexps '(".*"))) (let ((special-display-regexps (append special-display-regexps '(".*")))
...@@ -1423,11 +1419,11 @@ DOC is an optional documentation string." ...@@ -1423,11 +1419,11 @@ DOC is an optional documentation string."
(defvar gdb-inferior-io-mode-map (defvar gdb-inferior-io-mode-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-c" 'gdb-separate-io-interrupt) (define-key map "\C-c\C-c" 'gdb-io-interrupt)
(define-key map "\C-c\C-z" 'gdb-separate-io-stop) (define-key map "\C-c\C-z" 'gdb-io-stop)
(define-key map "\C-c\C-\\" 'gdb-separate-io-quit) (define-key map "\C-c\C-\\" 'gdb-io-quit)
(define-key map "\C-c\C-d" 'gdb-separate-io-eof) (define-key map "\C-c\C-d" 'gdb-io-eof)
(define-key map "\C-d" 'gdb-separate-io-eof) (define-key map "\C-d" 'gdb-io-eof)
map)) map))
;; We want to use comint because it has various nifty and familiar features. ;; We want to use comint because it has various nifty and familiar features.
...@@ -1447,25 +1443,25 @@ The following commands are available: ...@@ -1447,25 +1443,25 @@ The following commands are available:
(with-current-buffer (gdb-get-buffer-create 'gdb-inferior-io) (with-current-buffer (gdb-get-buffer-create 'gdb-inferior-io)
(comint-output-filter proc string))) (comint-output-filter proc string)))
(defun gdb-separate-io-interrupt () (defun gdb-io-interrupt ()
"Interrupt the program being debugged." "Interrupt the program being debugged."
(interactive) (interactive)
(interrupt-process (interrupt-process
(get-buffer-process gud-comint-buffer) comint-ptyp)) (get-buffer-process gud-comint-buffer) comint-ptyp))
(defun gdb-separate-io-quit () (defun gdb-io-quit ()
"Send quit signal to the program being debugged." "Send quit signal to the program being debugged."
(interactive) (interactive)
(quit-process (quit-process
(get-buffer-process gud-comint-buffer) comint-ptyp)) (get-buffer-process gud-comint-buffer) comint-ptyp))
(defun gdb-separate-io-stop () (defun gdb-io-stop ()
"Stop the program being debugged." "Stop the program being debugged."
(interactive) (interactive)
(stop-process (stop-process
(get-buffer-process gud-comint-buffer) comint-ptyp)) (get-buffer-process gud-comint-buffer) comint-ptyp))
(defun gdb-separate-io-eof () (defun gdb-io-eof ()
"Send end-of-file to the program being debugged." "Send end-of-file to the program being debugged."
(interactive) (interactive)
(process-send-eof (process-send-eof
...@@ -3820,7 +3816,7 @@ SPLIT-HORIZONTAL and show BUF in the new window." ...@@ -3820,7 +3816,7 @@ SPLIT-HORIZONTAL and show BUF in the new window."
'("Disassembly" . gdb-display-disassembly-buffer)) '("Disassembly" . gdb-display-disassembly-buffer))
(define-key menu [registers] '("Registers" . gdb-display-registers-buffer)) (define-key menu [registers] '("Registers" . gdb-display-registers-buffer))
(define-key menu [inferior] (define-key menu [inferior]
'("Separate IO" . gdb-display-separate-io-buffer)) '("IO" . gdb-display-io-buffer))
(define-key menu [locals] '("Locals" . gdb-display-locals-buffer)) (define-key menu [locals] '("Locals" . gdb-display-locals-buffer))
(define-key menu [frames] '("Stack" . gdb-display-stack-buffer)) (define-key menu [frames] '("Stack" . gdb-display-stack-buffer))
(define-key menu [breakpoints] (define-key menu [breakpoints]
...@@ -3836,7 +3832,7 @@ SPLIT-HORIZONTAL and show BUF in the new window." ...@@ -3836,7 +3832,7 @@ SPLIT-HORIZONTAL and show BUF in the new window."
(define-key menu [disassembly] '("Disassembly" . gdb-frame-disassembly-buffer)) (define-key menu [disassembly] '("Disassembly" . gdb-frame-disassembly-buffer))
(define-key menu [registers] '("Registers" . gdb-frame-registers-buffer)) (define-key menu [registers] '("Registers" . gdb-frame-registers-buffer))
(define-key menu [inferior] (define-key menu [inferior]
'("Separate IO" . gdb-frame-separate-io-buffer)) '("IO" . gdb-frame-io-buffer))
(define-key menu [locals] '("Locals" . gdb-frame-locals-buffer)) (define-key menu [locals] '("Locals" . gdb-frame-locals-buffer))
(define-key menu [frames] '("Stack" . gdb-frame-stack-buffer)) (define-key menu [frames] '("Stack" . gdb-frame-stack-buffer))
(define-key menu [breakpoints] (define-key menu [breakpoints]
......
...@@ -3411,7 +3411,8 @@ With arg, dereference expr if ARG is positive, otherwise do not derereference." ...@@ -3411,7 +3411,8 @@ With arg, dereference expr if ARG is positive, otherwise do not derereference."
(defun gud-tooltip-print-command (expr) (defun gud-tooltip-print-command (expr)
"Return a suitable command to print the expression EXPR." "Return a suitable command to print the expression EXPR."
(case gud-minor-mode (case gud-minor-mode
((dbx gdbmi) (concat "print " expr)) (gdbmi (concat "-data-evaluate-expression " expr))
(dbx (concat "print " expr))
((xdb pdb) (concat "p " expr)) ((xdb pdb) (concat "p " expr))
(sdb (concat expr "/")))) (sdb (concat expr "/"))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment