From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Nick Roberts Newsgroups: gmane.emacs.devel Subject: RE: M-x gdb troubles Date: Wed, 21 Apr 2004 20:16:37 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <16518.51349.955232.751075@nick.uklinux.net> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1082577421 8647 80.91.224.253 (21 Apr 2004 19:57:01 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 21 Apr 2004 19:57:01 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed Apr 21 21:56:46 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BGNpt-0006LD-00 for ; Wed, 21 Apr 2004 21:56:45 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BGNpt-0001I2-00 for ; Wed, 21 Apr 2004 21:56:45 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BGNjZ-0005ip-AM for emacs-devel@quimby.gnus.org; Wed, 21 Apr 2004 15:50:13 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BGNj2-0005Zk-7m for emacs-devel@gnu.org; Wed, 21 Apr 2004 15:49:40 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BGNiV-0005Kd-Hn for emacs-devel@gnu.org; Wed, 21 Apr 2004 15:49:38 -0400 Original-Received: from [199.232.41.8] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.30) id 1BGNiU-0005Gk-Fv for emacs-devel@gnu.org; Wed, 21 Apr 2004 15:49:06 -0400 Original-Received: from [194.247.49.122] (helo=nick.uklinux.net) by mx20.gnu.org with esmtp (Exim 4.30) id 1BGNgQ-00069I-BR for emacs-devel@gnu.org; Wed, 21 Apr 2004 15:46:58 -0400 Original-Received: by nick.uklinux.net (Postfix, from userid 501) id 854F775FDE; Wed, 21 Apr 2004 20:16:38 +0100 (BST) Original-To: storm@cua.dk X-Mailer: VM 6.97 under Emacs 21.2.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:22004 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:22004 > If I have a running gdb process (M-x gdb ... run), and accidentally do > M-x gdb again (instead of switching to the gdb buffer), things get > really messy... > Maybe the second M-x gdb should just switch to the current gdb buffer > if I enter the same command line as a previous gdb run. How about this patch. The catch form would have to be added to the other debugger functions (dbx, pdb, perldb etc) to be consistent. *** gud.el.~1.19.~ 2004-04-15 20:39:43.000000000 +0100 --- gud.el 2004-04-21 19:27:43.000000000 +0100 *************** *** 526,556 **** and source-file directory for your debugger." (interactive (list (gud-query-cmdline 'gdb))) ! (gud-common-init command-line nil 'gud-gdb-marker-filter) ! (set (make-local-variable 'gud-minor-mode) 'gdb) ! ! (gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.") ! (gud-def gud-tbreak "tbreak %f:%l" "\C-t" "Set temporary breakpoint at current line.") ! (gud-def gud-remove "clear %f:%l" "\C-d" "Remove breakpoint at current line") ! (gud-def gud-step "step %p" "\C-s" "Step one source line with display.") ! (gud-def gud-stepi "stepi %p" "\C-i" "Step one instruction with display.") ! (gud-def gud-next "next %p" "\C-n" "Step one line (skip functions).") ! (gud-def gud-nexti "nexti %p" nil "Step one instruction (skip functions).") ! (gud-def gud-cont "cont" "\C-r" "Continue with display.") ! (gud-def gud-finish "finish" "\C-f" "Finish executing current function.") ! (gud-def gud-jump "tbreak %f:%l\njump %f:%l" "\C-j" "Relocate execution address to line at point in source buffer.") ! ! (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).") ! (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).") ! (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.") ! (gud-def gud-until "until %l" "\C-u" "Continue to current line.") ! (gud-def gud-run "run" nil "Run the program.") ! ! (local-set-key "\C-i" 'gud-gdb-complete-command) ! (setq comint-prompt-regexp "^(.*gdb[+]?) *") ! (setq paragraph-start comint-prompt-regexp) ! (setq gdb-first-prompt t) ! (run-hooks 'gdb-mode-hook)) ;; One of the nice features of GDB is its impressive support for ;; context-sensitive command completion. We preserve that feature --- 526,557 ---- and source-file directory for your debugger." (interactive (list (gud-query-cmdline 'gdb))) ! (catch 'existing ! (gud-common-init command-line nil 'gud-gdb-marker-filter) ! (set (make-local-variable 'gud-minor-mode) 'gdb) ! ! (gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.") ! (gud-def gud-tbreak "tbreak %f:%l" "\C-t" "Set temporary breakpoint at current line.") ! (gud-def gud-remove "clear %f:%l" "\C-d" "Remove breakpoint at current line") ! (gud-def gud-step "step %p" "\C-s" "Step one source line with display.") ! (gud-def gud-stepi "stepi %p" "\C-i" "Step one instruction with display.") ! (gud-def gud-next "next %p" "\C-n" "Step one line (skip functions).") ! (gud-def gud-nexti "nexti %p" nil "Step one instruction (skip functions).") ! (gud-def gud-cont "cont" "\C-r" "Continue with display.") ! (gud-def gud-finish "finish" "\C-f" "Finish executing current function.") ! (gud-def gud-jump "tbreak %f:%l\njump %f:%l" "\C-j" "Relocate execution address to line at point in source buffer.") ! ! (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).") ! (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).") ! (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.") ! (gud-def gud-until "until %l" "\C-u" "Continue to current line.") ! (gud-def gud-run "run" nil "Run the program.") ! ! (local-set-key "\C-i" 'gud-gdb-complete-command) ! (setq comint-prompt-regexp "^(.*gdb[+]?) *") ! (setq paragraph-start comint-prompt-regexp) ! (setq gdb-first-prompt t) ! (run-hooks 'gdb-mode-hook))) ;; One of the nice features of GDB is its impressive support for ;; context-sensitive command completion. We preserve that feature *************** *** 2384,2391 **** (if (file-name-directory file-subst) (expand-file-name file-subst) file-subst))) ! (filepart (and file-word (concat "-" (file-name-nondirectory file))))) (pop-to-buffer (concat "*gud" filepart "*")) ;; Set the dir, in case the buffer already existed with a different dir. (setq default-directory dir) ;; Set default-directory to the file's directory. --- 2385,2394 ---- (if (file-name-directory file-subst) (expand-file-name file-subst) file-subst))) ! (filepart (and file-word (concat "-" (file-name-nondirectory file)))) ! (existing-buffer (get-buffer (concat "*gud" filepart "*")))) (pop-to-buffer (concat "*gud" filepart "*")) + (if existing-buffer (throw 'existing 'existing)) ;; Set the dir, in case the buffer already existed with a different dir. (setq default-directory dir) ;; Set default-directory to the file's directory. *** gdb-ui.el.~1.9.~ 2004-04-20 00:21:06.000000000 +0100 --- gdb-ui.el 2004-04-21 19:20:40.000000000 +0100 *************** *** 119,126 **** (interactive (list (gud-query-cmdline 'gdba))) ;; ;; Let's start with a basic gud-gdb buffer and then modify it a bit. ! (gdb command-line) ! (gdb-ann3)) (defvar gdb-debug-log nil) --- 119,125 ---- (interactive (list (gud-query-cmdline 'gdba))) ;; ;; Let's start with a basic gud-gdb buffer and then modify it a bit. ! (gdb-ann3 (gdb command-line))) (defvar gdb-debug-log nil) *************** *** 134,200 **** :type 'boolean :group 'gud) ! (defun gdb-ann3 () ! (setq gdb-debug-log nil) ! (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-call "break %f:%l" arg) ! (save-excursion ! (beginning-of-line) ! (forward-char 2) ! (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-call "clear %f:%l" arg) ! (save-excursion ! (beginning-of-line) ! (forward-char 2) ! (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-call "until %f:%l" arg) ! (save-excursion ! (beginning-of-line) ! (forward-char 2) ! (gud-call "until *%a" arg))) ! "\C-u" "Continue to current line or address.") ! ! (define-key gud-minor-mode-map [left-margin mouse-1] ! 'gdb-mouse-toggle-breakpoint) ! (define-key gud-minor-mode-map [left-fringe mouse-1] ! 'gdb-mouse-toggle-breakpoint) ! (setq comint-input-sender 'gdb-send) ! ;; ! ;; (re-)initialise ! (setq gdb-current-address "main") ! (setq gdb-previous-address nil) ! (setq gdb-previous-frame nil) ! (setq gdb-current-frame "main") ! (setq gdb-view-source t) ! (setq gdb-selected-view 'source) ! (setq gdb-var-list nil) ! (setq gdb-var-changed nil) ! (setq gdb-first-prompt nil) ! ;; ! (mapc 'make-local-variable gdb-variables) ! (setq gdb-buffer-type 'gdba) ! ;; ! (if gdb-use-inferior-io-buffer (gdb-clear-inferior-io)) ! ;; ! (if (eq window-system 'w32) ! (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 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)) ! ;; ! (run-hooks 'gdba-mode-hook)) (defcustom gdb-use-colon-colon-notation nil "Non-nil means use FUNCTION::VARIABLE format to display variables in the --- 133,200 ---- :type 'boolean :group 'gud) ! (defun gdb-ann3 (arg) ! (unless (eq arg 'existing) ! (setq gdb-debug-log nil) ! (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-call "break %f:%l" arg) ! (save-excursion ! (beginning-of-line) ! (forward-char 2) ! (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-call "clear %f:%l" arg) ! (save-excursion ! (beginning-of-line) ! (forward-char 2) ! (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-call "until %f:%l" arg) ! (save-excursion ! (beginning-of-line) ! (forward-char 2) ! (gud-call "until *%a" arg))) ! "\C-u" "Continue to current line or address.") ! ! (define-key gud-minor-mode-map [left-margin mouse-1] ! 'gdb-mouse-toggle-breakpoint) ! (define-key gud-minor-mode-map [left-fringe mouse-1] ! 'gdb-mouse-toggle-breakpoint) ! (setq comint-input-sender 'gdb-send) ! ;; ! ;; (re-)initialise ! (setq gdb-current-address "main") ! (setq gdb-previous-address nil) ! (setq gdb-previous-frame nil) ! (setq gdb-current-frame "main") ! (setq gdb-view-source t) ! (setq gdb-selected-view 'source) ! (setq gdb-var-list nil) ! (setq gdb-var-changed nil) ! (setq gdb-first-prompt nil) ! ;; ! (mapc 'make-local-variable gdb-variables) ! (setq gdb-buffer-type 'gdba) ! ;; ! (if gdb-use-inferior-io-buffer (gdb-clear-inferior-io)) ! ;; ! (if (eq window-system 'w32) ! (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 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)) ! ;; ! (run-hooks 'gdba-mode-hook))) (defcustom gdb-use-colon-colon-notation nil "Non-nil means use FUNCTION::VARIABLE format to display variables in the *************** *** 721,727 **** (defun gdb-prompt (ignored) "An annotation handler for `prompt'. This sends the next command (if any) to gdb." ! (when gdb-first-prompt (gdb-ann3)) (let ((sink (gdb-get-output-sink))) (cond ((eq sink 'user) t) --- 721,727 ---- (defun gdb-prompt (ignored) "An annotation handler for `prompt'. This sends the next command (if any) to gdb." ! (when gdb-first-prompt (gdb-ann3 nil)) (let ((sink (gdb-get-output-sink))) (cond ((eq sink 'user) t)