all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Tip of the day: Using Valgrind in the GUD buffer
@ 2003-12-26 16:34 Nick Roberts
  0 siblings, 0 replies; 6+ messages in thread
From: Nick Roberts @ 2003-12-26 16:34 UTC (permalink / raw)



Emacs users may know that the output of valgrind can be parsed by the compilation
buffer if the executable it is operating on does not require input.

Here's a trick for running valgrind in the GUD buffer of Emacs so it that can
display the source of the executable at memory violations and examine values
under the control of GDB.

Note, however, that THIS REQUIRES THE CVS VERSION OF EMACS.

In the directory of the executable that you want to run under valgrind, put the
line:

set ann 1

in a file called .gdbinit (add the line at the end if it already exists). Type 
M-x gdb in the minibuffer and when prompted with (something like):

Run gdb (like this): gdb -fullname

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

The source does not immediately appear but if you 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 your code should appear. 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.


    Nick                                         http://www.nick.uklinux.net

^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <mailman.651.1072460978.868.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2004-01-07  1:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-26 16:34 Tip of the day: Using Valgrind in the GUD buffer Nick Roberts
     [not found] <mailman.651.1072460978.868.help-gnu-emacs@gnu.org>
2003-12-29 21:54 ` Kevin Rodgers
2003-12-30  0:56   ` Bruce Ingalls
2003-12-30 20:08     ` Kevin Rodgers
2003-12-31  4:49       ` Bruce Ingalls
2004-01-07  1:24         ` Kevin Rodgers

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.