emacs-devel
[Top][All Lists]
Advanced

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

command and doco for valgrind


From: Nick Roberts
Subject: command and doco for valgrind
Date: Fri, 9 Jan 2004 21:42:15 +0000

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 ----
  address@hidden 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
  




reply via email to

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