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: command and doco for valgrind Date: Fri, 9 Jan 2004 21:42:15 +0000 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <16383.8247.758985.411260@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 1073706237 10611 80.91.224.253 (10 Jan 2004 03:43:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 10 Jan 2004 03:43:57 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat Jan 10 04:43:54 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 1AfA2U-0006qj-00 for ; Sat, 10 Jan 2004 04:43:54 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AfA2T-000343-00 for ; Sat, 10 Jan 2004 04:43:54 +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 1AfADH-0008LP-9u for emacs-devel@quimby.gnus.org; Fri, 09 Jan 2004 22:55:03 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AfADA-0008Kw-3N for emacs-devel@gnu.org; Fri, 09 Jan 2004 22:54:56 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AfACe-0008GN-7M for emacs-devel@gnu.org; Fri, 09 Jan 2004 22:54:55 -0500 Original-Received: from [194.247.50.190] (helo=nick.uklinux.net) by monty-python.gnu.org with esmtp (Exim 4.24) id 1Af5U8-000869-4X for emacs-devel@gnu.org; Fri, 09 Jan 2004 17:52:08 -0500 Original-Received: by nick.uklinux.net (Postfix, from userid 501) id 4BE6475FDE; Fri, 9 Jan 2004 21:42:16 +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:19123 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:19123 Here's a patch for valgrind relating to my earlier message. Any comments? Nick --- gud.el 2004-01-09 21:14:21.000000000 +0000 *************** *** 543,548 **** --- 543,553 ---- (setq gdb-first-prompt t) (run-hooks 'gdb-mode-hook)) + (defun valgrind (command-line) + (interactive (list + (read-string "Run valgrind (like this): " "valgrind --gdb-attach=yes "))) + (gdb command-line)) + ;; One of the nice features of GDB is its impressive support for ;; context-sensitive command completion. We preserve that feature ;; in the GUD buffer by using a GDB command designed just for Emacs. *** building.texi.~1.34.~ 2003-12-18 21:44:37.000000000 +0000 --- building.texi 2004-01-09 21:37:09.000000000 +0000 *************** *** 300,305 **** --- 300,306 ---- * GDB Graphical Interface:: An enhanced mode that uses GDB features to implement a graphical debugging environment through Emacs. + * Using Valgrind:: Memory management in the GUD buffer. @end menu @node Starting GUD *************** *** 798,803 **** --- 799,845 ---- gdb-frame-@var{buffertype}-buffer} respectively, where @var{buffertype} is the relevant buffer type e.g breakpoints. + @node Using Valgrind + @subsection Using Valgrind in the GUD buffer + @cindex Valgrind + + Valgrind is a tool to help you find memory-management problems in your + programs. You can use it from the command line and this section + descibes how to use it with the GUD buffer. + + To start running your program through valgrind type: + + @example + M-x valgrind @key{RET} @var{file} @key{RET} + @end example + + At a memory violation, when valgrind asks if you want to attach to gdb, type y: + + @example + ==19752== ---- Attach to GDB ? --- [Return/N/n/Y/y/C/c] ---- y + @end example + + At the prompt for GDB type: + + @example + @code{set ann 1} and type @key{RET} if you want the mode for M-x gdb. + @code{set ann 3} and type @key{RET} if you want the mode for M-x gdba. + @end example + + 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 @code{frame 6} in the GUD buffer. The source code for + this call should appear in another buffer in both cases. Just as with + operation from the command line, you can't step through your code when + it is run through valgrind. However you can move up and down the + stack and examine the values of variables. When you want to return + control to valgrind type @kbd{C-d} to quit GDB but stay in the GUD + buffer. + @node Executing Lisp @section Executing Lisp Expressions