* 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
* Re: Tip of the day: Using Valgrind in the GUD buffer
[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
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Rodgers @ 2003-12-29 21:54 UTC (permalink / raw)
Nick Roberts wrote:
> 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.
Note also that *compilation* buffers can be made to accept user input:
http://groups.google.com/groups?selm=3F6A3405.8040609%40yahoo.com
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Tip of the day: Using Valgrind in the GUD buffer
2003-12-29 21:54 ` Tip of the day: Using Valgrind in the GUD buffer Kevin Rodgers
@ 2003-12-30 0:56 ` Bruce Ingalls
2003-12-30 20:08 ` Kevin Rodgers
0 siblings, 1 reply; 6+ messages in thread
From: Bruce Ingalls @ 2003-12-30 0:56 UTC (permalink / raw)
Kevin Rodgers wrote:
> Note also that *compilation* buffers can be made to accept user input:
> http://groups.google.com/groups?selm=3F6A3405.8040609%40yahoo.com
Hmm. I've added
(add-hook 'compilation-mode-hook '(lambda() (toggle-read-only t)))
to my .emacs, because I tend to use mouse2 instead of C-x ` to jump to
error-lines showing in the *compilation* buffer.
The problem is that sometimes (middle) mouse2 will _Paste_ instead of
goto-line :(
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Tip of the day: Using Valgrind in the GUD buffer
2003-12-30 0:56 ` Bruce Ingalls
@ 2003-12-30 20:08 ` Kevin Rodgers
2003-12-31 4:49 ` Bruce Ingalls
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Rodgers @ 2003-12-30 20:08 UTC (permalink / raw)
Bruce Ingalls wrote:
> Hmm. I've added
>
> (add-hook 'compilation-mode-hook '(lambda() (toggle-read-only t)))
>
> to my .emacs, because I tend to use mouse2 instead of C-x ` to jump to
> error-lines showing in the *compilation* buffer.
If your intent is to make the *compilation* buffer read-only, that should
be (toggle-read-only 1) or simply (setq buffer-read-only t).
> The problem is that sometimes (middle) mouse2 will _Paste_ instead of
> goto-line :(
Then somehow you've deleted the binding of [mouse-2] to the
compile-mouse-goto-error command in compilation-mode-map (or
in compilation-minor-mode-map, whose list structure it shares).
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Tip of the day: Using Valgrind in the GUD buffer
2003-12-30 20:08 ` Kevin Rodgers
@ 2003-12-31 4:49 ` Bruce Ingalls
2004-01-07 1:24 ` Kevin Rodgers
0 siblings, 1 reply; 6+ messages in thread
From: Bruce Ingalls @ 2003-12-31 4:49 UTC (permalink / raw)
>> The problem is that sometimes (middle) mouse2 will _Paste_ instead of
>> goto-line :(
>
> Then somehow you've deleted the binding of [mouse-2] to the
> compile-mouse-goto-error command in compilation-mode-map (or
> in compilation-minor-mode-map, whose list structure it shares).
>
Thanks for the correction. I can't find a good way of reproducing the
above error, but under conditions (typically the first click in the
buffer) if you don't have the line properly highlighted, before mouse
clicking, it will paste instead.
The next mouse click will properly goto the error line, so the
keybinding is still there.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Tip of the day: Using Valgrind in the GUD buffer
2003-12-31 4:49 ` Bruce Ingalls
@ 2004-01-07 1:24 ` Kevin Rodgers
0 siblings, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2004-01-07 1:24 UTC (permalink / raw)
Bruce Ingalls wrote:
>>> The problem is that sometimes (middle) mouse2 will _Paste_ instead of
>>> goto-line :(
>>
>>
>> Then somehow you've deleted the binding of [mouse-2] to the
>> compile-mouse-goto-error command in compilation-mode-map (or
>> in compilation-minor-mode-map, whose list structure it shares).
>>
> Thanks for the correction. I can't find a good way of reproducing the
> above error, but under conditions (typically the first click in the
> buffer) if you don't have the line properly highlighted, before mouse
> clicking, it will paste instead.
> The next mouse click will properly goto the error line, so the
> keybinding is still there.
C-h v compile-auto-highlight
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 6+ messages in thread
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 --
[not found] <mailman.651.1072460978.868.help-gnu-emacs@gnu.org>
2003-12-29 21:54 ` Tip of the day: Using Valgrind in the GUD buffer 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
2003-12-26 16:34 Nick Roberts
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).