]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/gdb-ui.el
Merge from emacs--rel--22
[gnu-emacs] / lisp / progmodes / gdb-ui.el
index c53d1092e00ff22bc745026f0d617ac3e95e058d..19710341f7151be1d29a6accf1bf848008040e55 100644 (file)
@@ -145,6 +145,8 @@ Emacs can't find.")
   "Non-nil when GDB generates frame-begin annotation.")
 (defvar gdb-printing t)
 (defvar gdb-parent-bptno-enabled nil)
+(defvar gdb-ready nil)
+(defvar gdb-early-user-input nil)
 
 (defvar gdb-buffer-type nil
   "One of the symbols bound in `gdb-buffer-rules'.")
@@ -156,7 +158,7 @@ Emacs can't find.")
 (defvar gdb-prompting nil
   "True when gdb is idle with no pending input.")
 
-(defvar gdb-output-sink 'user
+(defvar gdb-output-sink nil
   "The disposition of the output of the current gdb command.
 Possible values are these symbols:
 
@@ -291,6 +293,7 @@ session."
 
   (gud-common-init command-line nil 'gud-gdba-marker-filter)
   (set (make-local-variable 'gud-minor-mode) 'gdba)
+  (setq comint-input-sender 'gdb-send)
 
   (gud-def gud-break  "break %f:%l"  "\C-b" "Set breakpoint at current line.")
   (gud-def gud-tbreak "tbreak %f:%l" "\C-t"
@@ -321,10 +324,12 @@ session."
   (local-set-key "\C-i" 'gud-gdb-complete-command)
   (setq comint-prompt-regexp "^(.*gdb[+]?) *")
   (setq paragraph-start comint-prompt-regexp)
+  (setq gdb-output-sink 'user)
   (setq gdb-first-prompt t)
   (setq gud-running nil)
   (setq gdb-ready nil)
   (setq gdb-flush-pending-output nil)
+  (setq gdb-early-user-input nil)
   (setq gud-filter-pending-text nil)
   (run-hooks 'gdb-mode-hook))
 
@@ -585,8 +590,6 @@ otherwise do not."
   (define-key gud-minor-mode-map [left-margin C-mouse-3]
     'gdb-mouse-jump)
 
-  (setq comint-input-sender 'gdb-send)
-
   ;; (re-)initialize
   (setq gdb-pc-address (if gdb-show-main "main" nil))
   (setq gdb-previous-frame-address nil
@@ -1204,21 +1207,24 @@ The key should be one of the cars in `gdb-buffer-rules-assoc'."
 (defun gdb-send (proc string)
   "A comint send filter for gdb.
 This filter may simply queue input for a later time."
-  (when gdb-ready
-      (with-current-buffer gud-comint-buffer
-       (let ((inhibit-read-only t))
-         (remove-text-properties (point-min) (point-max) '(face))))
-      (if gud-running
-         (progn
-           (let ((item (concat string "\n")))
-             (if gdb-enable-debug (push (cons 'send item) gdb-debug-log))
-             (process-send-string proc item)))
-       (if (string-match "\\\\\\'" string)
-           (setq gdb-continuation (concat gdb-continuation string "\n"))
-         (let ((item (concat gdb-continuation string
-                             (if (not comint-input-sender-no-newline) "\n"))))
-           (gdb-enqueue-input item)
-           (setq gdb-continuation nil))))))
+  (if gdb-ready
+      (progn
+       (with-current-buffer gud-comint-buffer
+         (let ((inhibit-read-only t))
+           (remove-text-properties (point-min) (point-max) '(face))))
+       (if gud-running
+           (progn
+             (let ((item (concat string "\n")))
+               (if gdb-enable-debug (push (cons 'send item) gdb-debug-log))
+               (process-send-string proc item)))
+         (if (string-match "\\\\\\'" string)
+             (setq gdb-continuation (concat gdb-continuation string "\n"))
+           (let ((item (concat
+                        gdb-continuation string
+                        (if (not comint-input-sender-no-newline) "\n"))))
+             (gdb-enqueue-input item)
+             (setq gdb-continuation nil)))))
+    (push (concat string "\n")  gdb-early-user-input)))
 
 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it
 ;; is a query, or other non-top-level prompt.
@@ -1372,7 +1378,11 @@ This sends the next command (if any) to gdb."
        (gdb-send-item input)
       (progn
        (setq gdb-prompting t)
-       (gud-display-frame)))))
+       (gud-display-frame)
+       (setq gdb-early-user-input (nreverse gdb-early-user-input))
+       (while gdb-early-user-input
+           (gdb-enqueue-input (car gdb-early-user-input))
+           (setq gdb-early-user-input (cdr gdb-early-user-input)))))))
 
 (defun gdb-subprompt (ignored)
   "An annotation handler for non-top-level prompts."
@@ -1973,8 +1983,12 @@ static char *magick[] = {
          (end-of-line))))))
   (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom)))
 
+(declare-function gud-remove "gdb-ui" t t) ; gud-def
+(declare-function gud-break  "gdb-ui" t t) ; gud-def
+
 (defun gdb-mouse-set-clear-breakpoint (event)
-  "Set/clear breakpoint in left fringe/margin with mouse click."
+  "Set/clear breakpoint in left fringe/margin at mouse click.
+If not in a source or disassembly buffer just set point."
   (interactive "e")
   (mouse-minibuffer-check event)
   (let ((posn (event-end event)))
@@ -2195,10 +2209,7 @@ static char *magick[] = {
                    (put-text-property bl (+ bl 4)
                                       'face '(:inverse-video t))
                    (setq move-to bl)))
-               (when (re-search-forward
-                      (concat
-                       (if (string-equal (match-string 1) "0") "" " in ")
-                       "\\([^ ]+\\) (") el t)
+               (when (re-search-forward "\\([^ ]+\\) (" el t)
                  (put-text-property (match-beginning 1) (match-end 1)
                                     'face font-lock-function-name-face)
                  (setq bl (match-end 0))