|
From: Jiang L. <Jia...@sy...> - 2004-10-26 01:15:57
|
Hello, I am exploring the use of Valgrind in my project. I would like to invoke gdb within Xemacs, when prompted by Valgrind. Does anyone know how to do it? Xemacs give nicer interface when going through the source files. I am using the latest xemacs-21.4.15 . Thanks very much. -Jiang |
|
From: Nick R. <ni...@sn...> - 2004-11-02 05:34:31
|
> I am exploring the use of Valgrind in my project. I would like to invoke > gdb within Xemacs, when prompted by Valgrind. Does anyone know how to do > it? Xemacs give nicer interface when going through the source files. Below is something similar to what I intended add to the Emacs manual, but didn't because there didn't seem to be much interest. You can also find an earlier reference at http://emacro.sourceforge.net/en/tips.html but the instructions below are probably better. For M-x gdba you need the CVS version of Emacs at Savannah but M-x gdb should work for XEmacs too. Nick Valgrind is a tool to help you find memory-management problems in GNU/Linux-x86 executables. If your program does not require user input, you can run valgrind in the `*compilation*' buffer where you can visit the source code for any particular memory error message in the normal way. If your program requires user input, or if you wish to attach to GDB, then this can be done in the GUD buffer by typing M-x gdb or M-x gdba and replacing the default input (e.g gdb -fullname) as shown: Run gdb (like this): valgrind --gdb-attach=yes ~/myprog At a memory violation, valgrind asks if you want to attach to gdb. If you type "y", then at GDB's prompt, type "set ann 1", if you want the mode for M-x gdb, or "set ann 3", if you want the mode for M-x gdba. In the first case, nothing happens immediately. In the second case, the main routine appears in the source buffer and the resulting layout depends on the value of gdb-many-windows. If you now type "bt" in the GUD buffer, GDB prints the call stack. This also includes calls to valgrind's code. Identify the frame number of your code, six say, and type "frame 6" in the GUD buffer. The source code for this call should appear in another buffer in both cases. 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 `C-d' to quit GDB but stay in the GUD buffer. |