diff lisp/progmodes/gdb-ui.el @ 90188:01137c1fdbe9

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-57 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 324-352) - Merge from gnus--rel--5.10 - Update from CVS - etc/emacs-buffer.gdb: Remove RCS keywords * gnus--rel--5.10 (patch 70-79) - Update from CVS - Merge from emacs--cvs-trunk--0
author Miles Bader <miles@gnu.org>
date Mon, 06 Jun 2005 02:39:45 +0000
parents 5b029ff3b08d bd3ecd5ebdff
children a1b34dec1104
line wrap: on
line diff
--- a/lisp/progmodes/gdb-ui.el	Sun Jun 05 01:58:02 2005 +0000
+++ b/lisp/progmodes/gdb-ui.el	Mon Jun 06 02:39:45 2005 +0000
@@ -66,15 +66,16 @@
 
 (require 'gud)
 
-(defvar gdb-current-address "main" "Initialisation for Assembler buffer.")
-(defvar gdb-previous-address nil)
+(defvar gdb-frame-address "main" "Initialisation for Assembler buffer.")
+(defvar gdb-previous-frame-address nil)
 (defvar gdb-memory-address "main")
 (defvar gdb-previous-frame nil)
-(defvar gdb-current-frame nil)
-(defvar gdb-current-stack-level nil)
+(defvar gdb-selected-frame nil)
+(defvar gdb-frame-number nil)
 (defvar gdb-current-language nil)
 (defvar gdb-var-list nil "List of variables in watch window.")
 (defvar gdb-var-changed nil "Non-nil means that gdb-var-list has changed.")
+(defvar gdb-main-file nil "Source file from which program execution begins.")
 (defvar gdb-buffer-type nil)
 (defvar gdb-overlay-arrow-position nil)
 (defvar gdb-server-prefix nil)
@@ -211,11 +212,18 @@
   :version "22.1")
 
 (defcustom gdb-cpp-define-alist-flags ""
-  "*Preprocessor flags for `gdb-cpp-define-alist-program'."
+  "Preprocessor flags for `gdb-cpp-define-alist-program'."
   :type 'string
   :group 'gud
   :version "22.1")
 
+(defcustom gdb-show-main nil
+  "Non-nil means display source file containing the main routine at startup.
+Also display the main routine in the disassembly buffer if present."
+  :type 'boolean
+  :group 'gud
+  :version "22.1")
+
 (defvar gdb-define-alist nil "Alist of #define directives for GUD tooltips.")
 
 (defun gdb-create-define-alist ()
@@ -269,7 +277,7 @@
 (defun gdb-set-gud-minor-mode-1 (buffer)
   (goto-char (point-min))
   (when (and (search-forward "Located in " nil t)
-	     (looking-at "\\S-*")
+	     (looking-at "\\S-+")
 	     (string-equal (buffer-file-name buffer)
 			   (match-string 0)))
     (with-current-buffer buffer
@@ -295,7 +303,7 @@
   (set (make-local-variable 'gud-minor-mode) 'gdba)
   (set (make-local-variable 'gud-marker-filter) 'gud-gdba-marker-filter)
   ;;
-  (gud-def gud-break (if (not (string-equal mode-name "Machine"))
+  (gud-def gud-break (if (not (string-match "Machine" mode-name))
 			 (gud-call "break %f:%l" arg)
 		       (save-excursion
 			 (beginning-of-line)
@@ -303,7 +311,7 @@
 			 (gud-call "break *%a" arg)))
 	   "\C-b" "Set breakpoint at current line or address.")
   ;;
-  (gud-def gud-remove (if (not (string-equal mode-name "Machine"))
+  (gud-def gud-remove (if (not (string-match "Machine" mode-name))
 			  (gud-call "clear %f:%l" arg)
 			(save-excursion
 			  (beginning-of-line)
@@ -311,7 +319,7 @@
 			  (gud-call "clear *%a" arg)))
 	   "\C-d" "Remove breakpoint at current line or address.")
   ;;
-  (gud-def gud-until  (if (not (string-equal mode-name "Machine"))
+  (gud-def gud-until  (if (not (string-match "Machine" mode-name))
 			  (gud-call "until %f:%l" arg)
 			(save-excursion
 			  (beginning-of-line)
@@ -332,25 +340,26 @@
   (setq comint-input-sender 'gdb-send)
   ;;
   ;; (re-)initialize
-  (setq gdb-current-address "main")
-  (setq gdb-previous-address nil)
-  (setq gdb-memory-address "main")
-  (setq gdb-previous-frame nil)
-  (setq gdb-current-frame nil)
-  (setq gdb-current-stack-level nil)
-  (setq gdb-var-list nil)
-  (setq gdb-var-changed nil)
-  (setq gdb-first-prompt nil)
-  (setq gdb-prompting nil)
-  (setq gdb-input-queue nil)
-  (setq gdb-current-item nil)
-  (setq gdb-pending-triggers nil)
-  (setq gdb-output-sink 'user)
-  (setq gdb-server-prefix "server ")
-  (setq gdb-flush-pending-output nil)
-  (setq gdb-location-alist nil)
-  (setq gdb-find-file-unhook nil)
-  (setq gdb-macro-info nil)
+  (setq gdb-frame-address (if gdb-show-main "main" nil))
+  (setq gdb-previous-frame-address nil
+	gdb-memory-address "main"
+	gdb-previous-frame nil
+	gdb-selected-frame nil
+	gdb-current-language nil
+	gdb-frame-number nil
+	gdb-var-list nil
+	gdb-var-changed nil
+	gdb-first-prompt nil
+	gdb-prompting nil
+	gdb-input-queue nil
+	gdb-current-item nil
+	gdb-pending-triggers nil
+	gdb-output-sink 'user
+	gdb-server-prefix "server "
+	gdb-flush-pending-output nil
+	gdb-location-alist nil
+	gdb-find-file-unhook nil
+	gdb-macro-info nil)
   ;;
   (setq gdb-buffer-type 'gdba)
   ;;
@@ -380,8 +389,8 @@
   (require 'tooltip)
   (let ((expr (tooltip-identifier-from-point (point))))
     (if (and (string-equal gdb-current-language "c")
-	     gdb-use-colon-colon-notation gdb-current-frame)
-	(setq expr (concat gdb-current-frame "::" expr)))
+	     gdb-use-colon-colon-notation gdb-selected-frame)
+	(setq expr (concat gdb-selected-frame "::" expr)))
     (catch 'already-watched
       (dolist (var gdb-var-list)
 	(if (string-equal expr (car var)) (throw 'already-watched nil)))
@@ -862,7 +871,7 @@
   (setq gdb-prompting t))
 
 (defconst gdb-source-spec-regexp
-  "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:\\(0x[a-f0-9]*\\)")
+  "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:0x0*\\([a-f0-9]*\\)")
 
 ;; Do not use this except as an annotation handler.
 (defun gdb-source (args)
@@ -872,7 +881,7 @@
 	(cons
 	 (match-string 1 args)
 	 (string-to-number (match-string 2 args))))
-  (setq gdb-current-address (match-string 3 args))
+  (setq gdb-frame-address (match-string 3 args))
   ;; cover for auto-display output which comes *before*
   ;; stopped annotation
   (if (eq gdb-output-sink 'inferior) (setq gdb-output-sink 'user)))
@@ -985,10 +994,12 @@
 This begins the collection of output from the current command if that
 happens to be appropriate."
   (unless gdb-pending-triggers
-	(gdb-get-current-frame)
+	(gdb-get-selected-frame)
 	(gdb-invalidate-frames)
 	(gdb-invalidate-breakpoints)
-	(gdb-invalidate-assembler)
+	;; Do this through gdb-get-selected-frame -> gdb-frame-handler
+	;; so gdb-frame-address is updated.
+	;; (gdb-invalidate-assembler)
 	(gdb-invalidate-registers)
 	(gdb-invalidate-memory)
 	(gdb-invalidate-locals)
@@ -1150,12 +1161,12 @@
      (let ((buf (gdb-get-buffer ',buf-key)))
        (and buf
 	    (with-current-buffer buf
-	      (let ((p (point))
+	      (let ((p (window-point (get-buffer-window buf 0)))
 		    (buffer-read-only nil))
 		(erase-buffer)
 		(insert-buffer-substring (gdb-get-create-buffer
 					  'gdb-partial-output-buffer))
-		(goto-char p)))))
+		(set-window-point (get-buffer-window buf 0) p)))))
      ;; put customisation here
      (,custom-defun)))
 
@@ -1293,7 +1304,7 @@
 	(goto-char (point-min))
 	(while (< (point) (- (point-max) 1))
 	  (forward-line 1)
-	  (if (looking-at "[^\t].*breakpoint")
+	  (if (looking-at "[^\t].*?breakpoint")
 	      (progn
 		(looking-at "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)")
 		(setq bptno (match-string 1))
@@ -1435,9 +1446,9 @@
   (save-excursion
     (beginning-of-line 1)
     (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
-	    (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")
+	    (looking-at "\\([0-9]+\\).*?point\\s-+\\S-+\\s-+\\(.\\)\\s-+")
 	  (looking-at
-     "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*\\S-*\\s-*\\S-*:[0-9]+"))
+     "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+\\S-+\\s-+\\S-+:[0-9]+"))
 	(gdb-enqueue-input
 	 (list
 	  (concat gdb-server-prefix
@@ -1452,9 +1463,9 @@
   (interactive)
   (beginning-of-line 1)
   (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
-	  (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")
+	  (looking-at "\\([0-9]+\\).*?point\\s-+\\S-+\\s-+\\(.\\)")
 	(looking-at
-	 "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*.\\s-*\\S-*\\s-*\\S-*:[0-9]+"))
+	 "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\s-+\\S-+\\s-+\\S-+:[0-9]+"))
       (gdb-enqueue-input
        (list
 	(concat gdb-server-prefix "delete " (match-string 1) "\n") 'ignore))
@@ -1467,10 +1478,10 @@
   (save-excursion
     (beginning-of-line 1)
     (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
-	    (looking-at "\\([0-9]+\\) .* in .* at\\s-+\\(\\S-*\\):\\([0-9]+\\)")
+	    (looking-at "\\([0-9]+\\) .+ in .+ at\\s-+\\(\\S-+\\):\\([0-9]+\\)")
 	  (looking-at
-	   "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*.\\s-*\\S-*\\s-*\
-\\(\\S-*\\):\\([0-9]+\\)"))
+	   "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+.\\s-+\\S-+\\s-+\
+\\(\\S-+\\):\\([0-9]+\\)"))
 	(let ((bptno (match-string 1))
 	      (file  (match-string 2))
 	      (line  (match-string 3)))
@@ -1511,7 +1522,7 @@
 			       help-echo "mouse-2, RET: Select frame"))
 	  (beginning-of-line)
 	  (when (and (looking-at "^#\\([0-9]+\\)")
-		     (equal (match-string 1) gdb-current-stack-level))
+		     (equal (match-string 1) gdb-frame-number))
 	    (put-text-property (line-beginning-position) (line-end-position)
 			       'face '(:inverse-video t)))
 	  (forward-line 1))))))
@@ -1648,13 +1659,20 @@
 
 ;; Registers buffer.
 ;;
+(defcustom gdb-all-registers nil
+  "Non-nil means include floating-point registers."
+  :type 'boolean
+  :group 'gud
+  :version "22.1")
+
 (gdb-set-buffer-rules 'gdb-registers-buffer
 		      'gdb-registers-buffer-name
 		      'gdb-registers-mode)
 
 (def-gdb-auto-updated-buffer gdb-registers-buffer
   gdb-invalidate-registers
-  (concat gdb-server-prefix "info registers\n")
+  (concat
+   gdb-server-prefix "info " (if gdb-all-registers "all-") "registers\n")
   gdb-info-registers-handler
   gdb-info-registers-custom)
 
@@ -1663,6 +1681,7 @@
 (defvar gdb-registers-mode-map
   (let ((map (make-sparse-keymap)))
     (suppress-keymap map)
+    (define-key map " " 'toggle-gdb-all-registers)
     (define-key map "q" 'kill-this-buffer)
      map))
 
@@ -1672,7 +1691,7 @@
 \\{gdb-registers-mode-map}"
   (kill-all-local-variables)
   (setq major-mode 'gdb-registers-mode)
-  (setq mode-name "Registers")
+  (setq mode-name "Registers:")
   (setq buffer-read-only t)
   (use-local-map gdb-registers-mode-map)
   (run-mode-hooks 'gdb-registers-mode-hook)
@@ -1695,6 +1714,20 @@
 	(special-display-frame-alist gdb-frame-parameters))
     (display-buffer (gdb-get-create-buffer 'gdb-registers-buffer))))
 
+(defun toggle-gdb-all-registers ()
+  "Toggle the display of floating-point registers."
+  (interactive)
+  (if gdb-all-registers
+      (progn
+	(setq gdb-all-registers nil)
+	(with-current-buffer (gdb-get-buffer 'gdb-registers-buffer)
+	  (setq mode-name "Registers:")))
+	(setq gdb-all-registers t)
+	(with-current-buffer (gdb-get-buffer 'gdb-registers-buffer)
+	  (setq mode-name "Registers:All")))
+  (gdb-invalidate-registers))
+
+
 ;; Memory buffer.
 ;;
 (defcustom gdb-memory-repeat-count 32
@@ -1733,7 +1766,11 @@
   gdb-read-memory-handler
   gdb-read-memory-custom)
 
-(defun gdb-read-memory-custom ())
+(defun gdb-read-memory-custom ()
+  (save-excursion
+    (goto-char (point-min))
+    (if (looking-at "0x[[:xdigit:]]+")
+	(setq gdb-memory-address (match-string 0)))))
 
 (defvar gdb-memory-mode-map
   (let ((map (make-sparse-keymap)))
@@ -1757,8 +1794,8 @@
     (select-window (posn-window (event-start event)))
     (let* ((arg (read-from-minibuffer "Repeat count: "))
 	  (count (string-to-number arg)))
-      (if (< count 0)
-	  (error "Non-negative numbers only")
+      (if (<= count 0)
+	  (error "Positive numbers only")
 	(customize-set-variable 'gdb-memory-repeat-count count)
 	(gdb-invalidate-memory)))))
 
@@ -1911,10 +1948,42 @@
   (setq header-line-format
 	'(:eval
 	  (concat
-	   "Read address: "
+	   "Read address["
+	   (propertize
+	    "-"
+	    'face font-lock-warning-face
+	    'help-echo "mouse-1: Decrement address"
+	    'mouse-face 'mode-line-highlight
+	    'local-map
+	    (gdb-make-header-line-mouse-map
+	     'mouse-1
+	     #'(lambda () (interactive)
+		 (let ((gdb-memory-address
+			;; let GDB do the arithmetic
+			(concat
+			 gdb-memory-address " - "
+			 (number-to-string
+			  (* gdb-memory-repeat-count
+			     (cond ((string= gdb-memory-unit "b") 1)
+				   ((string= gdb-memory-unit "h") 2)
+				   ((string= gdb-memory-unit "w") 4)
+				   ((string= gdb-memory-unit "g") 8)))))))
+		       (gdb-invalidate-memory)))))
+	   "|"
+	   (propertize "+"
+		       'face font-lock-warning-face
+		       'help-echo "mouse-1: Increment address"
+		       'mouse-face 'mode-line-highlight
+		       'local-map (gdb-make-header-line-mouse-map
+				   'mouse-1
+				   #'(lambda () (interactive)
+				       (let ((gdb-memory-address nil))
+					 (gdb-invalidate-memory)))))
+	   "]: "
 	   (propertize gdb-memory-address
 		       'face font-lock-warning-face
 		       'help-echo "mouse-1: Set memory address"
+		       'mouse-face 'mode-line-highlight
 		       'local-map (gdb-make-header-line-mouse-map
 				   'mouse-1
 				   #'gdb-memory-set-address))
@@ -1922,6 +1991,7 @@
 	   (propertize (number-to-string gdb-memory-repeat-count)
 		       'face font-lock-warning-face
 		       'help-echo "mouse-1: Set repeat count"
+		       'mouse-face 'mode-line-highlight
 		       'local-map (gdb-make-header-line-mouse-map
 				   'mouse-1
 				   #'gdb-memory-set-repeat-count))
@@ -1929,11 +1999,13 @@
 	   (propertize gdb-memory-format
 		       'face font-lock-warning-face
 		       'help-echo "mouse-3: Select display format"
+		       'mouse-face 'mode-line-highlight
 		       'local-map gdb-memory-format-keymap)
 	   "  Unit Size: "
 	   (propertize gdb-memory-unit
 		       'face font-lock-warning-face
 		       'help-echo "mouse-3: Select unit size"
+		       'mouse-face 'mode-line-highlight
 		       'local-map gdb-memory-unit-keymap))))
   (run-mode-hooks 'gdb-memory-mode-hook)
   'gdb-invalidate-memory)
@@ -1986,12 +2058,12 @@
 	(replace-match " (array);\n" nil nil))))
   (let ((buf (gdb-get-buffer 'gdb-locals-buffer)))
     (and buf (with-current-buffer buf
-	       (let ((p (point))
+	       (let ((p (window-point (get-buffer-window buf 0)))
 		     (buffer-read-only nil))
-		 (delete-region (point-min) (point-max))
+		 (erase-buffer)
 		 (insert-buffer-substring (gdb-get-create-buffer
 					   'gdb-partial-output-buffer))
-		 (goto-char p)))))
+		(set-window-point (get-buffer-window buf 0) p)))))
   (run-hooks 'gdb-info-locals-hook))
 
 (defun gdb-info-locals-custom ()
@@ -2009,7 +2081,7 @@
 \\{gdb-locals-mode-map}"
   (kill-all-local-variables)
   (setq major-mode 'gdb-locals-mode)
-  (setq mode-name (concat "Locals:" gdb-current-frame))
+  (setq mode-name (concat "Locals:" gdb-selected-frame))
   (setq buffer-read-only t)
   (use-local-map gdb-locals-mode-map)
   (run-mode-hooks 'gdb-locals-mode-hook)
@@ -2069,7 +2141,8 @@
   (define-key menu [gdb] '("Gdb" . gdb-display-gdb-buffer))
   (define-key menu [threads] '("Threads" . gdb-display-threads-buffer))
   (define-key menu [memory] '("Memory" . gdb-display-memory-buffer))
-  (define-key menu [assembler] '("Machine" . gdb-display-assembler-buffer))
+  (define-key menu [disassembly]
+    '("Disassembly" . gdb-display-assembler-buffer))
   (define-key menu [registers] '("Registers" . gdb-display-registers-buffer))
   (define-key menu [inferior]
     '(menu-item "Inferior IO" gdb-display-inferior-io-buffer
@@ -2086,7 +2159,7 @@
   (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer))
   (define-key menu [threads] '("Threads" . gdb-frame-threads-buffer))
   (define-key menu [memory] '("Memory" . gdb-frame-memory-buffer))
-  (define-key menu [assembler] '("Machine" . gdb-frame-assembler-buffer))
+  (define-key menu [disassembly] '("Disassembiy" . gdb-frame-assembler-buffer))
   (define-key menu [registers] '("Registers" . gdb-frame-registers-buffer))
   (define-key menu [inferior]
     '(menu-item "Inferior IO" gdb-frame-inferior-io-buffer
@@ -2129,14 +2202,6 @@
   (gdb-display-buffer
    (gdb-get-create-buffer 'gdba)))
 
-(defvar gdb-main-file nil "Source file from which program execution begins.")
-
-(defcustom gdb-show-main nil
-  "Nil means don't display source file containing the main routine."
-  :type 'boolean
-  :group 'gud
-  :version "22.1")
-
 (defun gdb-set-window-buffer (name)
   (set-window-buffer (selected-window) (get-buffer name))
   (set-window-dedicated-p (selected-window) t))
@@ -2236,7 +2301,7 @@
 buffers."
   (goto-char (point-min))
   (if (and (search-forward "Located in " nil t)
-	   (looking-at "\\S-*"))
+	   (looking-at "\\S-+"))
       (setq gdb-main-file (match-string 0)))
   (goto-char (point-min))
   (if (search-forward "Includes preprocessor macro info." nil t)
@@ -2254,7 +2319,7 @@
   (goto-char (point-min))
   (catch 'file-not-found
     (if (search-forward "Located in " nil t)
-	(when (looking-at "\\S-*")
+	(when (looking-at "\\S-+")
 	  (delete (cons bptno "File not found") gdb-location-alist)
 	  (push (cons bptno (match-string 0)) gdb-location-alist))
       (gdb-resync)
@@ -2276,6 +2341,8 @@
 (add-hook 'find-file-hook 'gdb-find-file-hook)
 
 (defun gdb-find-file-hook ()
+"Set up buffer for debugging if file is part of the source code
+of the current session."
   (if (and (not gdb-find-file-unhook)
 	   ;; in case gud or gdb-ui is just loaded
 	   gud-comint-buffer
@@ -2399,7 +2466,9 @@
 
 (def-gdb-auto-updated-buffer gdb-assembler-buffer
   gdb-invalidate-assembler
-  (concat gdb-server-prefix "disassemble " gdb-current-address "\n")
+  (concat gdb-server-prefix "disassemble " 
+	  (if (member gdb-frame-address '(nil "main")) nil "0x")
+	  gdb-frame-address "\n")
   gdb-assembler-handler
   gdb-assembler-custom)
 
@@ -2407,38 +2476,38 @@
   (let ((buffer (gdb-get-buffer 'gdb-assembler-buffer))
 	(pos 1) (address) (flag) (bptno))
     (with-current-buffer buffer
-      (if (not (equal gdb-current-address "main"))
-	  (progn
-	    (goto-char (point-min))
-	    (if (re-search-forward gdb-current-address nil t)
-		(progn
-		  (setq pos (point))
-		  (beginning-of-line)
-		  (or gdb-overlay-arrow-position
-		      (setq gdb-overlay-arrow-position (make-marker)))
-		  (set-marker gdb-overlay-arrow-position
-			      (point) (current-buffer))))))
-      ;; remove all breakpoint-icons in assembler buffer before updating.
-      (gdb-remove-breakpoint-icons (point-min) (point-max)))
+      (save-excursion
+	(if (not (equal gdb-frame-address "main"))
+	    (progn
+	      (goto-char (point-min))
+	      (if (and gdb-frame-address
+		       (re-search-forward gdb-frame-address nil t))
+		  (progn
+		    (setq pos (point))
+		    (beginning-of-line)
+		    (or gdb-overlay-arrow-position
+			(setq gdb-overlay-arrow-position (make-marker)))
+		    (set-marker gdb-overlay-arrow-position
+				(point) (current-buffer))))))
+	;; 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)
       (goto-char (point-min))
       (while (< (point) (- (point-max) 1))
 	(forward-line 1)
-	(if (looking-at "[^\t].*breakpoint")
+	(if (looking-at "[^\t].*?breakpoint")
 	    (progn
 	      (looking-at
-	       "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+0x\\(\\S-+\\)")
+	    "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+0x0*\\(\\S-+\\)")
 	      (setq bptno (match-string 1))
 	      (setq flag (char-after (match-beginning 2)))
 	      (setq address (match-string 3))
-	      ;; remove leading 0s from output of info break.
-	      (if (string-match "^0+\\(.*\\)" address)
-		  (setq address (match-string 1 address)))
 	      (with-current-buffer buffer
+		(save-excursion
 		  (goto-char (point-min))
 		  (if (re-search-forward address nil t)
-		      (gdb-put-breakpoint-icon (eq flag ?y) bptno)))))))
-    (if (not (equal gdb-current-address "main"))
+		      (gdb-put-breakpoint-icon (eq flag ?y) bptno))))))))
+    (if (not (equal gdb-frame-address "main"))
 	(set-window-point (get-buffer-window buffer 0) pos))))
 
 (defvar gdb-assembler-mode-map
@@ -2468,7 +2537,7 @@
 \\{gdb-assembler-mode-map}"
   (kill-all-local-variables)
   (setq major-mode 'gdb-assembler-mode)
-  (setq mode-name "Machine")
+  (setq mode-name (concat "Machine:" gdb-selected-frame))
   (setq gdb-overlay-arrow-position nil)
   (add-to-list 'overlay-arrow-variable-list 'gdb-overlay-arrow-position)
   (setq fringes-outside-margins t)
@@ -2482,33 +2551,36 @@
 
 (defun gdb-assembler-buffer-name ()
   (with-current-buffer gud-comint-buffer
-    (concat "*Machine Code " (gdb-get-target-string) "*")))
+    (concat "*Disassembly of " (gdb-get-target-string) "*")))
 
 (defun gdb-display-assembler-buffer ()
   "Display disassembly view."
   (interactive)
+  (setq gdb-previous-frame nil)
   (gdb-display-buffer
    (gdb-get-create-buffer 'gdb-assembler-buffer)))
 
 (defun gdb-frame-assembler-buffer ()
   "Display disassembly view in a new frame."
   (interactive)
+  (setq gdb-previous-frame nil)
   (let ((special-display-regexps (append special-display-regexps '(".*")))
 	(special-display-frame-alist gdb-frame-parameters))
     (display-buffer (gdb-get-create-buffer 'gdb-assembler-buffer))))
 
-;; modified because if gdb-current-address has changed value a new command
+;; modified because if gdb-frame-address has changed value a new command
 ;; must be enqueued to update the buffer with the new output
 (defun gdb-invalidate-assembler (&optional ignored)
   (if (gdb-get-buffer 'gdb-assembler-buffer)
       (progn
-	(unless (string-equal gdb-current-frame gdb-previous-frame)
+	(unless (and gdb-selected-frame
+		     (string-equal gdb-selected-frame gdb-previous-frame))
 	  (if (or (not (member 'gdb-invalidate-assembler
 			       gdb-pending-triggers))
-		  (not (string-equal gdb-current-address
-				     gdb-previous-address)))
+		  (not (string-equal gdb-frame-address
+				     gdb-previous-frame-address)))
 	  (progn
-	    ;; take previous disassemble command off the queue
+	    ;; take previous disassemble command, if any, off the queue
 	    (with-current-buffer gud-comint-buffer
 	      (let ((queue gdb-input-queue))
 		(dolist (item queue)
@@ -2516,46 +2588,46 @@
 		      (setq gdb-input-queue
 			    (delete item gdb-input-queue))))))
 	    (gdb-enqueue-input
-	     (list (concat gdb-server-prefix "disassemble "
-			   gdb-current-address "\n")
+	     (list
+	      (concat gdb-server-prefix "disassemble "
+		      (if (member gdb-frame-address '(nil "main")) nil "0x")
+			   gdb-frame-address "\n")
 		   'gdb-assembler-handler))
 	    (push 'gdb-invalidate-assembler gdb-pending-triggers)
-	    (setq gdb-previous-address gdb-current-address)
-	    (setq gdb-previous-frame gdb-current-frame)))))))
+	    (setq gdb-previous-frame-address gdb-frame-address)
+	    (setq gdb-previous-frame gdb-selected-frame)))))))
 
-(defun gdb-get-current-frame ()
-  (if (not (member 'gdb-get-current-frame gdb-pending-triggers))
+(defun gdb-get-selected-frame ()
+  (if (not (member 'gdb-get-selected-frame gdb-pending-triggers))
       (progn
 	(gdb-enqueue-input
 	 (list (concat gdb-server-prefix "info frame\n") 'gdb-frame-handler))
-	(push 'gdb-get-current-frame
+	(push 'gdb-get-selected-frame
 	       gdb-pending-triggers))))
 
 (defun gdb-frame-handler ()
   (setq gdb-pending-triggers
-   (delq 'gdb-get-current-frame gdb-pending-triggers))
+	(delq 'gdb-get-selected-frame gdb-pending-triggers))
   (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
     (goto-char (point-min))
-    (if (looking-at "Stack level \\([0-9]+\\)")
-	(setq gdb-current-stack-level (match-string 1)))
-    (forward-line)
-    (if (looking-at ".*=\\s-+0x\\(\\S-*\\)\\s-+in\\s-+\\(\\S-*?\\);? ")
+    (if (re-search-forward  "Stack level \\([0-9]+\\)" nil t)
+	(setq gdb-frame-number (match-string 1)))
+    (goto-char (point-min))
+    (if (re-search-forward
+	 ".*=\\s-+0x0*\\(\\S-*\\)\\s-+in\\s-+\\(\\S-*?\\);? " nil t)
 	(progn
-	  (setq gdb-current-frame (match-string 2))
+	  (setq gdb-selected-frame (match-string 2))
 	  (if (gdb-get-buffer 'gdb-locals-buffer)
 	      (with-current-buffer (gdb-get-buffer 'gdb-locals-buffer)
-		(setq mode-name (concat "Locals:" gdb-current-frame))))
-	  (let ((address (match-string 1)))
-	    ;; remove leading 0s from output of info frame command.
-	    (if (string-match "^0+\\(.*\\)" address)
-		(setq gdb-current-address
-		      (concat "0x" (match-string 1 address)))
-	      (setq gdb-current-address (concat "0x" address))))
-	  (if (not (re-search-forward "(\\S-*:[0-9]*);" nil t))
-		;;update with new frame for machine code if necessary
-		(gdb-invalidate-assembler)))))
+		(setq mode-name (concat "Locals:" gdb-selected-frame))))
+	  (if (gdb-get-buffer 'gdb-assembler-buffer)
+	      (with-current-buffer (gdb-get-buffer 'gdb-assembler-buffer)
+		(setq mode-name (concat "Machine:" gdb-selected-frame))))
+	  (setq gdb-frame-address (match-string 1))))
+    (goto-char (point-min))
     (if (re-search-forward " source language \\(\\S-*\\)\." nil t)
 	(setq gdb-current-language (match-string 1))))
+    (gdb-invalidate-assembler))
 
 (provide 'gdb-ui)