From: Nick Roberts <nick@nick.uklinux.net>
Subject: command and doco for valgrind
Date: Fri, 9 Jan 2004 21:42:15 +0000 [thread overview]
Message-ID: <16383.8247.758985.411260@nick.uklinux.net> (raw)
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
next reply other threads:[~2004-01-09 21:42 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-09 21:42 Nick Roberts [this message]
2004-01-10 12:34 ` command and doco for valgrind Eli Zaretskii
2004-01-17 23:38 ` Nick Roberts
2004-01-18 7:25 ` Eli Zaretskii
2004-01-18 19:15 ` Richard Stallman
2004-01-19 6:32 ` Eli Zaretskii
2004-01-18 14:17 ` Eli Zaretskii
2004-01-18 19:15 ` Eli Zaretskii
2004-01-19 20:11 ` Richard Stallman
2004-01-19 21:33 ` Eli Zaretskii
2004-01-19 22:57 ` Nick Roberts
2004-01-20 6:21 ` EMACS and valgrind (was: command and doco for valgrind) Eli Zaretskii
2004-01-20 15:26 ` Stefan Monnier
2004-01-22 21:46 ` EMACS and valgrind Nick Roberts
2004-01-22 22:26 ` Stefan Monnier
2004-01-23 22:07 ` Nick Roberts
2004-01-24 10:25 ` Eli Zaretskii
2004-03-21 16:47 ` command and doco for valgrind Nick Roberts
2004-03-21 16:56 ` Eli Zaretskii
2004-03-22 18:27 ` Nick Roberts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16383.8247.758985.411260@nick.uklinux.net \
--to=nick@nick.uklinux.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).