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: Using Valgrind in the GUD buffer (two modes) Date: Sun, 28 Dec 2003 14:51:55 +0000 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <16366.60939.406086.646942@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 1072623724 10608 80.91.224.253 (28 Dec 2003 15:02:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 28 Dec 2003 15:02:04 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sun Dec 28 16:02:01 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AacQb-0007wS-00 for ; Sun, 28 Dec 2003 16:02:01 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AacQa-0000wd-00 for ; Sun, 28 Dec 2003 16:02:01 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AadM4-0001ow-ED for emacs-devel@quimby.gnus.org; Sun, 28 Dec 2003 11:01:24 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AadLm-0001o2-2c for emacs-devel@gnu.org; Sun, 28 Dec 2003 11:01:06 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AadLG-0001iU-9W for emacs-devel@gnu.org; Sun, 28 Dec 2003 11:01:05 -0500 Original-Received: from [194.247.51.7] (helo=nick.uklinux.net) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AadLF-0001ht-D9 for emacs-devel@gnu.org; Sun, 28 Dec 2003 11:00:34 -0500 Original-Received: by nick.uklinux.net (Postfix, from userid 501) id 72C4975FDF; Sun, 28 Dec 2003 14:51:56 +0000 (GMT) Original-To: emacs-devel@gnu.org X-Mailer: VM 6.97 under Emacs 21.2.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 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:18891 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:18891 Type M-x gdb in the minibuffer and when prompted with (something like): Run gdb (like this): gdb --annotate=3 replace it with (if your executable is ~/myprog, say): Run gdb (like this): valgrind --gdb-attach=yes ~/myprog At a memory violation, when valgrind asks if you want to atach to gdb, type y: ==19752== ---- Attach to GDB ? --- [Return/N/n/Y/y/C/c] ---- y At the prompt for GDB type: `set ann 3' and press if you want the mode for gdb in gdb-ui.el `set ann 1' and press if you want the mode for gdb in gud.el In the first case, the main routine appears in the source buffer and the resulting layout depends on the value of gdb-many-windows. In the second case, nothing happens immediately. If you now type bt, GDB prints the call stack. This also includes calls to valgrind's code. Identify the frame number of your code, 6 say, and type: (gdb) frame 6 and the code for this call should appear in the source buffer in both cases. Just as with the command line you can't step through your code under valgrind but you can move up and down the stack and examine the values of variables. When you want to return to valgrind type Ctrl-D to quit GDB but stay in the GUD buffer. I would like to add a section about this in the Emacs manual. Are there any objections? Nick http://www.nick.uklinux.net