changeset 51617:cef03ad7bf21

(gud-display1): Keep the gdb command, "display", in the command history. (gdb-restore-windows): Make restore work when gdb-many-windows is nil. (gdb-source-info, gdba): Display assembler if there is no symbol table for main, or message if there is no main. (gdb-assembler-custom): Move point to current line of assembler.
author Nick Roberts <nickrob@snap.net.nz>
date Wed, 18 Jun 2003 22:37:40 +0000
parents 25262b54af10
children 6a5cb63d165c
files lisp/gdb-ui.el
diffstat 1 files changed, 54 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/gdb-ui.el	Wed Jun 18 22:36:40 2003 +0000
+++ b/lisp/gdb-ui.el	Wed Jun 18 22:37:40 2003 +0000
@@ -41,10 +41,10 @@
 ;; developing the mode itself, then see the Annotations section in the GDB
 ;; info manual.
 ;;
-;;  Known Bugs: 
-;;  Does not auto-display arrays of structures or structures containing arrays. 
-;;  On MS Windows, Gdb 5.1.1 from MinGW 2.0 does not flush the output from the
-;;  inferior.
+;; Known Bugs: 
+;; Does not auto-display arrays of structures or structures containing arrays. 
+;; On MS Windows, Gdb 5.1.1 from MinGW 2.0 does not flush the output from the
+;; inferior.
 
 ;;; Code:
 
@@ -60,9 +60,10 @@
   :type 'integer
   :group 'gud)
 
-(defvar gdb-current-address nil "Initialisation for Assembler buffer.")
+(defvar gdb-current-address "main" "Initialisation for Assembler buffer.")
 (defvar gdb-previous-address nil)
 (defvar gdb-previous-frame nil)
+(defvar gdb-current-frame "main")
 (defvar gdb-display-in-progress nil)
 (defvar gdb-dive nil)
 (defvar gdb-view-source t "Non-nil means that source code can be viewed")
@@ -162,6 +163,7 @@
   (setq gdb-current-address "main")
   (setq gdb-previous-address nil)
   (setq gdb-previous-frame nil)
+  (setq gdb-current-frame "main")
   (setq gdb-display-in-progress nil)
   (setq gdb-dive nil)
   (setq gdb-view-source t)
@@ -176,7 +178,7 @@
       (gdb-enqueue-input (list "set new-console off\n" 'ignore)))
   (gdb-enqueue-input (list "set height 0\n" 'ignore))
   ;; find source file and compilation directory here
-  (gdb-enqueue-input (list "server list\n" 'ignore))          ; C program
+  (gdb-enqueue-input (list "server list main\n" 'ignore))     ; C program
   (gdb-enqueue-input (list "server list MAIN__\n" 'ignore))   ; Fortran program
   (gdb-enqueue-input (list "server info source\n"
 			   'gdb-source-info))
@@ -201,9 +203,9 @@
     (goto-char (- (point-max) 1))
     (if (equal (char-before) (string-to-char "\*"))
 	(gdb-enqueue-input
-	 (list (concat "server display* " expr "\n") 'ignore))
+	 (list (concat "display* " expr "\n") 'ignore))
       (gdb-enqueue-input
-       (list (concat "server display " expr "\n") 'ignore)))))
+       (list (concat "display " expr "\n") 'ignore)))))
 
 ; this would messy because these bindings don't work with M-x gdb
 ; (define-key global-map "\C-x\C-a\C-a" 'gud-display)
@@ -744,7 +746,6 @@
   (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer))
   (setq gdb-dive nil))
 
-(defvar gdb-current-frame nil)
 (defvar gdb-nesting-level)
 (defvar gdb-expression)
 (defvar gdb-point)
@@ -2049,27 +2050,27 @@
   (gdb-display-buffer
    (gdb-get-create-buffer 'gdba)))
 
+(defvar gdb-main-file nil "Source file from which program execution begins.")
+
 (defun gdb-view-source()
-(interactive)
-(if gdb-view-source
-  (if gud-last-last-frame
-      (set-window-buffer gdb-source-window
-			 (gud-find-file (car gud-last-last-frame)))
-    (set-window-buffer gdb-source-window (gud-find-file gdb-main-file))))
-(setq gdb-selected-view 'source))
+  (interactive)
+  (if gdb-view-source
+      (if gud-last-last-frame
+	  (set-window-buffer gdb-source-window
+			     (gud-find-file (car gud-last-last-frame)))
+	(set-window-buffer gdb-source-window (gud-find-file gdb-main-file))))
+  (setq gdb-selected-view 'source))
 
 (defun gdb-view-assembler()
-(interactive)
-(set-window-buffer gdb-source-window
-		   (gdb-get-create-buffer 'gdb-assembler-buffer))
-(setq gdb-selected-view 'assembler))
+  (interactive)
+  (set-window-buffer gdb-source-window
+		     (gdb-get-create-buffer 'gdb-assembler-buffer))
+  (setq gdb-selected-view 'assembler))
 
 ;(defun gdb-view-both()
 ;(interactive)
 ;(setq gdb-selected-view 'both))
 
-(defvar gdb-main-file nil "Source file from which program execution begins.")
-
 ;; layout for all the windows
 (defun gdb-setup-windows ()
   (gdb-display-locals-buffer)
@@ -2135,6 +2136,7 @@
 	     (gud-find-file (car gud-last-last-frame))
 	   (gud-find-file gdb-main-file)))
       (switch-to-buffer (gdb-get-create-buffer 'gdb-assembler-buffer)))
+    (setq gdb-source-window (get-buffer-window (current-buffer)))
     (other-window 1)))
 
 (defun gdb-reset ()
@@ -2164,29 +2166,30 @@
   "Find the source file where the program starts and displays it with related
 buffers."
   (goto-char (point-min))
-  (when (search-forward "directory is " nil t)
-    (if (looking-at "\\S-*:\\(\\S-*\\)")
-	(setq gdb-cdir (match-string 1))
-      (looking-at "\\S-*")
-      (setq gdb-cdir (match-string 0)))
-    (search-forward "Located in ")
-    (looking-at "\\S-*")
-    (setq gdb-main-file (match-string 0))
-    ;; Make sure we are not in the minibuffer window when we try to delete
-    ;; all other windows.
-    (if (window-minibuffer-p (selected-window))
-	(other-window 1))
+  (if (search-forward "directory is " nil t)
+      (progn
+	(if (looking-at "\\S-*:\\(\\S-*\\)")
+	    (setq gdb-cdir (match-string 1))
+	  (looking-at "\\S-*")
+	  (setq gdb-cdir (match-string 0)))
+	(search-forward "Located in ")
+	(looking-at "\\S-*")
+	(setq gdb-main-file (match-string 0)))
+    (setq gdb-view-source nil))
+  (delete-other-windows)
+  (if gdb-many-windows
+      (gdb-setup-windows)
+    (gdb-display-breakpoints-buffer)
+    (gdb-display-display-buffer)
     (delete-other-windows)
-    (if gdb-many-windows
-	(gdb-setup-windows)
-      (gdb-display-breakpoints-buffer)
-      (gdb-display-display-buffer)
-      (delete-other-windows)
-      (split-window)
-      (other-window 1)
-      (switch-to-buffer (gud-find-file gdb-main-file))
-      (setq gdb-source-window (get-buffer-window (current-buffer)))
-      (other-window 1))))
+    (split-window)
+    (other-window 1)
+    (if gdb-view-source
+	(switch-to-buffer (gud-find-file gdb-main-file))
+      (switch-to-buffer (gdb-get-create-buffer 'gdb-assembler-buffer))
+      (gdb-invalidate-assembler))
+    (setq gdb-source-window (get-buffer-window (current-buffer)))
+    (other-window 1)))
 
 ;;from put-image
 (defun gdb-put-string (putstring pos)
@@ -2294,14 +2297,16 @@
 
 (defun gdb-assembler-custom ()
   (let ((buffer (gdb-get-buffer 'gdb-assembler-buffer))
-	(address) (flag))
+	(gdb-arrow-position 1) (address) (flag))
     (with-current-buffer buffer
       (if (not (equal gdb-current-address "main"))
 	  (progn
 	    (gdb-remove-arrow)
 	    (goto-char (point-min))
 	    (if (re-search-forward gdb-current-address nil t)
-		(gdb-put-arrow "=>" (point)))))
+		(progn
+		  (setq gdb-arrow-position (point))
+		  (gdb-put-arrow "=>" (point))))))
       ;; remove all breakpoint-icons in assembler buffer before updating.
       (if (eq window-system 'x)
 	  (remove-images (point-min) (point-max))
@@ -2339,7 +2344,9 @@
 			  (gdb-remove-strings start end)
 			  (if (eq ?y flag)
 			      (gdb-put-string "B" (+ start 1))
-			    (gdb-put-string "b" (+ start 1)))))))))))))
+			    (gdb-put-string "b" (+ start 1)))))))))))
+    (if (not (equal gdb-current-address "main"))
+	(set-window-point (get-buffer-window buffer) gdb-arrow-position))))
 
 (defvar gdb-assembler-mode-map
   (let ((map (make-sparse-keymap)))