[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using Valgrind in the GUD buffer (two modes)

From: Nick Roberts
Subject: Using Valgrind in the GUD buffer (two modes)
Date: Sun, 28 Dec 2003 14:51:55 +0000

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 <RET> if you want the mode for gdb in gdb-ui.el
`set ann 1' and press <RET> 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

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]