]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/gdb-ui.el
(gdb-many-windows): Doc fix (Nil -> nil).
[gnu-emacs] / lisp / progmodes / gdb-ui.el
index e1378f0e07e09fe0574306637e31c8531c353f24..be2b99c897553004c34338f38b0c6040e046c654 100644 (file)
@@ -115,6 +115,7 @@ address for root variables.")
 (defvar gdb-main-file nil "Source file from which program execution begins.")
 (defvar gud-old-arrow nil)
 (defvar gdb-overlay-arrow-position nil)
+(defvar gdb-stack-position nil)
 (defvar gdb-server-prefix nil)
 (defvar gdb-flush-pending-output nil)
 (defvar gdb-location-alist nil
@@ -311,10 +312,10 @@ Also display the main routine in the disassembly buffer if present."
   :version "22.1")
 
 (defcustom gdb-many-windows nil
-  "Nil means just pop up the GUD buffer unless `gdb-show-main' is t.
+  "nil means just pop up the GUD buffer unless `gdb-show-main' is t.
 In this case it starts with two windows: one displaying the GUD
 buffer and the other with the source file with the main routine
-of the inferior.  Non-nil means display the layout shown for
+of the debugged program.  Non-nil means display the layout shown for
 `gdba'."
   :type 'boolean
   :group 'gud
@@ -383,8 +384,7 @@ With arg, use separate IO iff arg is positive."
                            (list t nil) nil "-c"
                            (concat gdb-cpp-define-alist-program " "
                                    gdb-cpp-define-alist-flags)))))
-       (define-list (split-string output "\n" t))
-       (name))
+       (define-list (split-string output "\n" t)) (name))
     (setq gdb-define-alist nil)
     (dolist (define define-list)
       (setq name (nth 1 (split-string define "[( ]")))
@@ -782,7 +782,7 @@ With arg, enter name of variable to be watched in the minibuffer."
 
 (defconst gdb-var-list-children-regexp
  "child={.*?name=\"\\(.*?\\)\",.*?exp=\"\\(.*?\\)\",.*?\
-numchild=\"\\(.*?\\)\",.*?type=\"\\(.*?\\)\".*?}")
+numchild=\"\\(.*?\\)\"\\(}\\|,.*?\\(type=\"\\(.*?\\)\"\\)?.*?}\\)")
 
 (defun gdb-var-list-children-handler (varnum)
   (goto-char (point-min))
@@ -796,7 +796,7 @@ numchild=\"\\(.*?\\)\",.*?type=\"\\(.*?\\)\".*?}")
                (let ((varchild (list (match-string 1)
                                      (match-string 2)
                                      (match-string 3)
-                                     (match-string 4)
+                                     (match-string 6)
                                      nil nil)))
                  (if (assoc (car varchild) gdb-var-list)
                      (throw 'child-already-watched nil))
@@ -902,20 +902,23 @@ Changed values are highlighted with the face `font-lock-warning-face'."
 TEXT is the text of the button we clicked on, a + or - item.
 TOKEN is data related to this node.
 INDENT is the current indentation depth."
-  (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)))
-       ((string-match "-" text)        ;contract this node
-        (dolist (var gdb-var-list)
-          (if (string-match (concat token "\\.") (car var))
-              (setq gdb-var-list (delq var gdb-var-list))))
-        (speedbar-change-expand-button-char ?+)
-        (speedbar-delete-subblock indent))
-       (t (error "Ooops...  not sure what to do")))
-  (speedbar-center-buffer-smartly))
+  (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)))
+             ((string-match "-" text)  ;contract this node
+              (dolist (var gdb-var-list)
+                (if (string-match (concat token "\\.") (car var))
+                    (setq gdb-var-list (delq var gdb-var-list))))
+              (speedbar-change-expand-button-char ?+)
+              (speedbar-delete-subblock indent))
+             (t (error "Ooops...  not sure what to do")))
+       (speedbar-center-buffer-smartly))
+    (message-box "GUD session has been killed")))
 
 (defun gdb-get-target-string ()
   (with-current-buffer gud-comint-buffer
@@ -1132,7 +1135,7 @@ This filter may simply queue input for a later time."
       (if gdb-prompting
          (progn
            (gdb-send-item item)
-       (setq gdb-prompting nil))
+           (setq gdb-prompting nil))
        (push item gdb-input-queue))))
 
 (defun gdb-dequeue-input ()
@@ -1290,12 +1293,14 @@ not GDB."
       (progn
        (setq gud-running t)
        (setq gdb-inferior-status "running")
+       (setq gdb-signalled nil)
        (gdb-force-mode-line-update
         (propertize gdb-inferior-status 'face font-lock-type-face))
        (gdb-remove-text-properties)
        (setq gud-old-arrow gud-overlay-arrow-position)
        (setq gud-overlay-arrow-position nil)
        (setq gdb-overlay-arrow-position nil)
+       (setq gdb-stack-position nil)
        (if gdb-use-separate-io-buffer
            (setq gdb-output-sink 'inferior))))
      (t
@@ -1330,6 +1335,7 @@ directives."
   (setq gdb-active-process nil)
   (setq gud-overlay-arrow-position nil)
   (setq gdb-overlay-arrow-position nil)
+  (setq gdb-stack-position nil)
   (setq gud-old-arrow nil)
   (setq gdb-inferior-status "exited")
   (gdb-force-mode-line-update
@@ -2037,8 +2043,13 @@ static char *magick[] = {
            (goto-char bl)
            (when (looking-at "^#\\([0-9]+\\)")
              (when (string-equal (match-string 1) gdb-frame-number)
-               (put-text-property bl (+ bl 4)
-                                  'face '(:inverse-video t)))
+               (if (> (car (window-fringes)) 0)
+                   (progn
+                     (or gdb-stack-position
+                         (setq gdb-stack-position (make-marker)))
+                     (set-marker gdb-stack-position (point)))
+                 (put-text-property bl (+ bl 4)
+                                    'face '(:inverse-video t))))
              (when (re-search-forward
                     (concat
                      (if (string-equal (match-string 1) "0") "" " in ")
@@ -2109,6 +2120,8 @@ static char *magick[] = {
   (kill-all-local-variables)
   (setq major-mode 'gdb-frames-mode)
   (setq mode-name "Frames")
+  (setq gdb-stack-position nil)
+  (add-to-list 'overlay-arrow-variable-list 'gdb-stack-position)
   (setq buffer-read-only t)
   (use-local-map gdb-frames-mode-map)
   (run-mode-hooks 'gdb-frames-mode-hook)
@@ -2628,8 +2641,11 @@ corresponding to the mode line clicked."
 (defun gdb-frame-memory-buffer ()
   "Display memory contents in a new frame."
   (interactive)
-  (let ((special-display-regexps (append special-display-regexps '(".*")))
-       (special-display-frame-alist gdb-frame-parameters))
+  (let* ((special-display-regexps (append special-display-regexps '(".*")))
+        (special-display-frame-alist
+         (cons '(left-fringe . 0)
+               (cons '(right-fringe . 0)
+                     (cons '(width . 83) gdb-frame-parameters)))))
     (display-buffer (gdb-get-buffer-create 'gdb-memory-buffer))))
 \f
 
@@ -2646,6 +2662,7 @@ corresponding to the mode line clicked."
 
 (defvar gdb-locals-watch-map
   (let ((map (make-sparse-keymap)))
+    (suppress-keymap map)
     (define-key map "\r" (lambda () (interactive)
                           (beginning-of-line)
                           (gud-watch)))
@@ -2912,12 +2929,13 @@ Kills the gdb buffers, and resets variables and the source buffers."
              (setq gud-minor-mode nil)
              (kill-local-variable 'tool-bar-map)
              (kill-local-variable 'gdb-define-alist))))))
-  (when (markerp gdb-overlay-arrow-position)
-    (move-marker gdb-overlay-arrow-position nil)
-    (setq gdb-overlay-arrow-position nil))
+  (setq gdb-overlay-arrow-position nil)
   (setq overlay-arrow-variable-list
        (delq 'gdb-overlay-arrow-position overlay-arrow-variable-list))
   (setq fringe-indicator-alist '((overlay-arrow . right-triangle)))
+  (setq gdb-stack-position nil)
+  (setq overlay-arrow-variable-list
+       (delq 'gdb-stack-position overlay-arrow-variable-list))
   (if (boundp 'speedbar-frame) (speedbar-timer-fn))
   (setq gud-running nil)
   (setq gdb-active-process nil)
@@ -3139,8 +3157,7 @@ BUFFER nil or omitted means use the current buffer."
                            '((overlay-arrow . hollow-right-triangle))))
                    (or gdb-overlay-arrow-position
                        (setq gdb-overlay-arrow-position (make-marker)))
-                   (set-marker gdb-overlay-arrow-position
-                               (point) (current-buffer))))))
+                   (set-marker gdb-overlay-arrow-position (point))))))
        ;; remove all breakpoint-icons in assembler buffer before updating.
        (gdb-remove-breakpoint-icons (point-min) (point-max))))
     (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)
@@ -3331,7 +3348,8 @@ is set in them."
 
 (defconst gdb-var-list-children-regexp-1
   "child={.*?name=\"\\(.+?\\)\",.*?exp=\"\\(.+?\\)\",.*?\
-numchild=\"\\(.+?\\)\",.*?value=\\(\".*?\"\\),.*?type=\"\\(.+?\\)\".*?}")
+numchild=\"\\(.+?\\)\",.*?value=\\(\".*?\"\\)\
+\\(}\\|,.*?\\(type=\"\\(.+?\\)\"\\)?.*?}\\)")
 
 (defun gdb-var-list-children-handler-1 (varnum)
   (goto-char (point-min))
@@ -3345,7 +3363,7 @@ numchild=\"\\(.+?\\)\",.*?value=\\(\".*?\"\\),.*?type=\"\\(.+?\\)\".*?}")
                (let ((varchild (list (match-string 1)
                                      (match-string 2)
                                      (match-string 3)
-                                     (match-string 5)
+                                     (match-string 7)
                                      (read (match-string 4))
                                      nil)))
                  (if (assoc (car varchild) gdb-var-list)
@@ -3501,10 +3519,32 @@ in_scope=\"\\(.*?\\)\".*?}")
 
 (defvar gdb-locals-watch-map-1
   (let ((map (make-sparse-keymap)))
+    (suppress-keymap map)
+    (define-key map "\r" 'gud-watch)
     (define-key map [mouse-2] 'gud-watch)
     map)
  "Keymap to create watch expression of a complex data type local variable.")
 
+(defvar gdb-edit-locals-map-1
+  (let ((map (make-sparse-keymap)))
+    (suppress-keymap map)
+    (define-key map "\r" 'gdb-edit-locals-value)
+    (define-key map [mouse-2] 'gdb-edit-locals-value)
+    map)
+ "Keymap to edit value of a simple data type local variable.")
+
+(defun gdb-edit-locals-value (&optional event)
+  "Assign a value to a variable displayed in the locals buffer."
+  (interactive (list last-input-event))
+  (save-excursion
+    (if event (posn-set-point (event-end event)))
+    (beginning-of-line)
+    (let* ((var (current-word))
+          (value (read-string (format "New value (%s): " var))))
+      (gdb-enqueue-input
+       (list (concat  gdb-server-prefix"set variable " var " = " value "\n")
+            'ignore)))))
+
 ;; Dont display values of arrays or structures.
 ;; These can be expanded using gud-watch.
 (defun gdb-stack-list-locals-handler ()
@@ -3532,20 +3572,26 @@ in_scope=\"\\(.*?\\)\".*?}")
                   (let* ((window (get-buffer-window buf 0))
                          (start (window-start window))
                          (p (window-point window))
-                         (buffer-read-only nil))
+                         (buffer-read-only nil) (name) (value))
                     (erase-buffer)
                     (dolist (local locals-list)
                       (setq name (car local))
-                      (if (or (not (nth 2 local))
-                              (string-match "^\\0x" (nth 2 local)))
+                      (setq value (nth 2 local))
+                      (if (or (not value)
+                              (string-match "^\\0x" value))
                           (add-text-properties 0 (length name)
                                `(mouse-face highlight
                                  help-echo "mouse-2: create watch expression"
                                  local-map ,gdb-locals-watch-map-1)
-                               name))
+                               name)
+                        (add-text-properties 0 (length value)
+                             `(mouse-face highlight
+                               help-echo "mouse-2: edit value"
+                               local-map ,gdb-edit-locals-map-1)
+                             value))
                       (insert
                        (concat name "\t" (nth 1 local)
-                               "\t" (nth 2 local) "\n")))
+                               "\t" value "\n")))
                     (set-window-start window start)
                     (set-window-point window p))))))))