summaryrefslogtreecommitdiff
path: root/lisp/progmodes/gdb-ui.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/gdb-ui.el')
-rw-r--r--lisp/progmodes/gdb-ui.el132
1 files changed, 85 insertions, 47 deletions
diff --git a/lisp/progmodes/gdb-ui.el b/lisp/progmodes/gdb-ui.el
index 3a253796f28..01e4fe7abe7 100644
--- a/lisp/progmodes/gdb-ui.el
+++ b/lisp/progmodes/gdb-ui.el
@@ -4,7 +4,7 @@
;; Maintainer: FSF
;; Keywords: unix, tools
-;; Copyright (C) 2002, 2003, 2004, 2005, 2006
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
;; Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
@@ -123,9 +123,10 @@ address for root variables.")
(defvar gdb-server-prefix nil)
(defvar gdb-flush-pending-output nil)
(defvar gdb-location-alist nil
- "Alist of breakpoint numbers and full filenames.")
-(defvar gdb-active-process nil "GUD tooltips display variable values when t, \
-and #define directives otherwise.")
+ "Alist of breakpoint numbers and full filenames. Only used for files that
+Emacs can't find.")
+(defvar gdb-active-process nil
+ "GUD tooltips display variable values when t, and macro definitions otherwise.")
(defvar gdb-error "Non-nil when GDB is reporting an error.")
(defvar gdb-macro-info nil
"Non-nil if GDB knows that the inferior includes preprocessor macro info.")
@@ -273,19 +274,22 @@ detailed description of this mode.
(gdb command-line)
(gdb-init-1))
-(defcustom gdb-debug-ring-max 128
- "Maximum size of `gdb-debug-ring'."
+(defcustom gdb-debug-log-max 128
+ "Maximum size of `gdb-debug-log'. If nil, size is unlimited."
:group 'gud
- :type 'integer
+ :type '(choice (integer :tag "Number of elements")
+ (const :tag "Unlimited" nil))
:version "22.1")
-(defvar gdb-debug-ring nil
- "List of commands, most recent first, sent to and replies received from GDB.
-This variable is used to debug GDB-UI.")
+(defvar gdb-debug-log nil
+ "List of commands sent to and replies received from GDB. Most
+recent commands are listed first. This list stores only the last
+'gdb-debug-log-max' values. This variable is used to debug
+GDB-UI.")
;;;###autoload
(defcustom gdb-enable-debug nil
- "Non-nil means record the process input and output in `gdb-debug-ring'."
+ "Non-nil means record the process input and output in `gdb-debug-log'."
:type 'boolean
:group 'gud
:version "22.1")
@@ -316,7 +320,7 @@ Also display the main routine in the disassembly buffer if present."
:version "22.1")
(defcustom gdb-many-windows nil
- "If nil just pop up the GUD buffer unless `gdb-show-main' is t.
+ "If nil, just pop up the GUD buffer unless `gdb-show-main' is t.
In this case start with two windows: one displaying the GUD
buffer and the other with the source file with the main routine
of the debugged program. Non-nil means display the layout shown
@@ -550,7 +554,7 @@ With arg, use separate IO iff arg is positive."
gdb-error nil
gdb-macro-info nil
gdb-buffer-fringe-width (car (window-fringes))
- gdb-debug-ring nil
+ gdb-debug-log nil
gdb-signalled nil
gdb-source-window nil
gdb-inferior-status nil
@@ -721,7 +725,7 @@ With arg, enter name of variable to be watched in the minibuffer."
(message "gud-watch is a no-op in this mode."))))
(defconst gdb-var-create-regexp
- "name=\"\\(.*?\\)\",.*numchild=\"\\(.*?\\)\",.*type=\"\\(.*?\\)\"")
+ "name=\"\\(.*?\\)\",.*numchild=\"\\(.*?\\)\",\\(?:.*value=\\(\".*\"\\),\\)?.*type=\"\\(.*?\\)\"")
(defun gdb-var-create-handler (expr)
(goto-char (point-min))
@@ -733,20 +737,23 @@ With arg, enter name of variable to be watched in the minibuffer."
(setq expr (concat gdb-selected-frame "::" expr))
expr)
(match-string 2)
- (match-string 3)
- nil nil gdb-frame-address)))
+ (match-string 4)
+ (if (match-string 3) (read (match-string 3)))
+ nil gdb-frame-address)))
(push var gdb-var-list)
(unless (string-equal
speedbar-initial-expansion-list-name "GUD")
(speedbar-change-initial-expansion-list "GUD"))
- (gdb-enqueue-input
- (list
- (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba)
- (concat "server interpreter mi \"0-var-evaluate-expression "
- (car var) "\"\n")
- (concat "0-var-evaluate-expression " (car var) "\n"))
- `(lambda () (gdb-var-evaluate-expression-handler
- ,(car var) nil)))))
+ (unless (nth 4 var)
+ (gdb-enqueue-input
+ (list
+ (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
+ 'gdba)
+ (concat "server interpreter mi \"0-var-evaluate-expression "
+ (car var) "\"\n")
+ (concat "0-var-evaluate-expression " (car var) "\n"))
+ `(lambda () (gdb-var-evaluate-expression-handler
+ ,(car var) nil))))))
(if (search-forward "Undefined command" nil t)
(message-box "Watching expressions requires GDB 6.0 onwards")
(message-box "No symbol \"%s\" in current context." expr))))
@@ -896,6 +903,12 @@ Changed values are highlighted with the face `font-lock-warning-face'."
:group 'gud
:version "22.1")
+(defcustom gdb-max-children 40
+ "Maximum number of children before expansion requires confirmation."
+ :type 'integer
+ :group 'gud
+ :version "22.1")
+
(defun gdb-speedbar-expand-node (text token indent)
"Expand the node the user clicked on.
TEXT is the text of the button we clicked on, a + or - item.
@@ -904,11 +917,17 @@ INDENT is the current indentation depth."
(if (and gud-comint-buffer (buffer-name gud-comint-buffer))
(progn
(cond ((string-match "+" text) ;expand this node
- (if (and (eq (buffer-local-value
- 'gud-minor-mode gud-comint-buffer) 'gdba)
- (string-equal gdb-version "pre-6.4"))
- (gdb-var-list-children token)
- (gdb-var-list-children-1 token)))
+ (let* ((var (assoc token gdb-var-list))
+ (expr (nth 1 var)) (children (nth 2 var)))
+ (if (or (<= (string-to-number children) gdb-max-children)
+ (y-or-n-p
+ (format
+ "%s has %s children. Continue? " expr children)))
+ (if (and (eq (buffer-local-value
+ 'gud-minor-mode gud-comint-buffer) 'gdba)
+ (string-equal gdb-version "pre-6.4"))
+ (gdb-var-list-children token)
+ (gdb-var-list-children-1 token)))))
((string-match "-" text) ;contract this node
(dolist (var gdb-var-list)
(if (string-match (concat token "\\.") (car var))
@@ -1118,7 +1137,7 @@ This filter may simply queue input for a later time."
(if gud-running
(progn
(let ((item (concat string "\n")))
- (if gdb-enable-debug (push (cons 'send item) gdb-debug-ring))
+ (if gdb-enable-debug (push (cons 'send item) gdb-debug-log))
(process-send-string proc item)))
(if (and (string-match "\\\\$" string)
(not comint-input-sender-no-newline)) ;;Try to catch C-d.
@@ -1147,7 +1166,7 @@ This filter may simply queue input for a later time."
(defun gdb-send-item (item)
(setq gdb-flush-pending-output nil)
- (if gdb-enable-debug (push (cons 'send-item item) gdb-debug-ring))
+ (if gdb-enable-debug (push (cons 'send-item item) gdb-debug-log))
(setq gdb-current-item item)
(let ((process (get-buffer-process gud-comint-buffer)))
(if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba)
@@ -1498,9 +1517,10 @@ happens to be appropriate."
(if gdb-flush-pending-output
nil
(when gdb-enable-debug
- (push (cons 'recv string) gdb-debug-ring)
- (if (> (length gdb-debug-ring) gdb-debug-ring-max)
- (setcdr (nthcdr (1- gdb-debug-ring-max) gdb-debug-ring) nil)))
+ (push (cons 'recv string) gdb-debug-log)
+ (if (and gdb-debug-log-max
+ (> (length gdb-debug-log) gdb-debug-log-max))
+ (setcdr (nthcdr (1- gdb-debug-log-max) gdb-debug-log) nil)))
;; Recall the left over gud-marker-acc from last time.
(setq gud-marker-acc (concat gud-marker-acc string))
;; Start accumulating output for the GUD buffer.
@@ -2017,13 +2037,19 @@ static char *magick[] = {
;;
;; Alas, if your stack is deep, it is costly.
;;
+(defcustom gdb-max-frames 40
+ "Maximum number of frames displayed in call stack."
+ :type 'integer
+ :group 'gud
+ :version "22.1")
+
(gdb-set-buffer-rules 'gdb-stack-buffer
'gdb-stack-buffer-name
'gdb-frames-mode)
(def-gdb-auto-updated-buffer gdb-stack-buffer
gdb-invalidate-frames
- "server info stack\n"
+ (concat "server info stack " (number-to-string gdb-max-frames) "\n")
gdb-info-stack-handler
gdb-info-stack-custom)
@@ -2065,7 +2091,14 @@ static char *magick[] = {
(while (re-search-forward "\\(\\(\\sw\\|[_.]\\)+\\)=" el t)
(put-text-property (match-beginning 1) (match-end 1)
'face font-lock-variable-name-face))))
- (forward-line 1))))
+ (forward-line 1))
+ (forward-line -1)
+ (when (looking-at "(More stack frames follow...)")
+ (add-text-properties (match-beginning 0) (match-end 0)
+ '(mouse-face highlight
+ gdb-max-frames t
+ help-echo
+ "mouse-2, RET: customize gdb-max-frames to see more frames")))))
(when gdb-look-up-stack
(goto-char (point-min))
(when (re-search-forward "\\(\\S-+?\\):\\([0-9]+\\)" nil t)
@@ -2135,16 +2168,21 @@ static char *magick[] = {
(end-of-line)
(let* ((start (line-beginning-position))
(pos (re-search-backward "^#*\\([0-9]+\\)" start t))
- (n (or (and pos (match-string-no-properties 1)) "0")))
+ (n (or (and pos (match-string 1)) "0")))
n)))
(defun gdb-frames-select (&optional event)
"Select the frame and display the relevant source."
(interactive (list last-input-event))
(if event (posn-set-point (event-end event)))
- (gdb-enqueue-input
- (list (concat gdb-server-prefix "frame "
- (gdb-get-frame-number) "\n") 'ignore)))
+ (if (get-text-property (point) 'gdb-max-frames)
+ (progn
+ (message-box "After setting gdb-max-frames, you need to enter\n\
+another GDB command e.g pwd, to see new frames")
+ (customize-variable-other-window 'gdb-max-frames))
+ (gdb-enqueue-input
+ (list (concat gdb-server-prefix "frame "
+ (gdb-get-frame-number) "\n") 'ignore))))
;; Threads buffer. This displays a selectable thread list.
@@ -2569,7 +2607,7 @@ corresponding to the mode line clicked."
(propertize
"-"
'face font-lock-warning-face
- 'help-echo "mouse-1: Decrement address"
+ 'help-echo "mouse-1: decrement address"
'mouse-face 'mode-line-highlight
'local-map
(gdb-make-header-line-mouse-map
@@ -2589,7 +2627,7 @@ corresponding to the mode line clicked."
"|"
(propertize "+"
'face font-lock-warning-face
- 'help-echo "mouse-1: Increment address"
+ 'help-echo "mouse-1: increment address"
'mouse-face 'mode-line-highlight
'local-map (gdb-make-header-line-mouse-map
'mouse-1
@@ -2599,7 +2637,7 @@ corresponding to the mode line clicked."
"]: "
(propertize gdb-memory-address
'face font-lock-warning-face
- 'help-echo "mouse-1: Set memory address"
+ 'help-echo "mouse-1: set memory address"
'mouse-face 'mode-line-highlight
'local-map (gdb-make-header-line-mouse-map
'mouse-1
@@ -2607,7 +2645,7 @@ corresponding to the mode line clicked."
" Repeat Count: "
(propertize (number-to-string gdb-memory-repeat-count)
'face font-lock-warning-face
- 'help-echo "mouse-1: Set repeat count"
+ 'help-echo "mouse-1: set repeat count"
'mouse-face 'mode-line-highlight
'local-map (gdb-make-header-line-mouse-map
'mouse-1
@@ -2615,13 +2653,13 @@ corresponding to the mode line clicked."
" Display Format: "
(propertize gdb-memory-format
'face font-lock-warning-face
- 'help-echo "mouse-3: Select display format"
+ 'help-echo "mouse-3: select display format"
'mouse-face 'mode-line-highlight
'local-map gdb-memory-format-map)
" Unit Size: "
(propertize gdb-memory-unit
'face font-lock-warning-face
- 'help-echo "mouse-3: Select unit size"
+ 'help-echo "mouse-3: select unit size"
'mouse-face 'mode-line-highlight
'local-map gdb-memory-unit-map))))
(set (make-local-variable 'font-lock-defaults)
@@ -2999,7 +3037,7 @@ of the current session."
(if (member (if (string-equal gdb-version "pre-6.4")
(file-name-nondirectory buffer-file-name)
buffer-file-name)
- gdb-source-file-list)
+ gdb-source-file-list)
(with-current-buffer (find-buffer-visiting buffer-file-name)
(set (make-local-variable 'gud-minor-mode)
(buffer-local-value 'gud-minor-mode gud-comint-buffer))