From: Nicholas N. <nj...@ca...> - 2003-05-28 21:07:45
|
Hi, I've hacked up support for a basic gdb-style interactive shell for Valgrind. To try it out, download www.cl.cam.ac.uk/~njn25/valgrind-interactive.tar.bz2. Install as usual. It supports the basic gdb-type commands -- add, remove, list breakpoints; print values in registers/memory locations. The interesting part is that you can also query meta-data tracked by skins, if they support it. At the moment, I only added support for the Memcheck skin; you can inspect the A (addressability) and V (validity) bits for each byte, but any skin could support this. To run it, use the --interactive=yes option, then type "help" to show the available commands. It's all pretty straightforward. One unfortunate limitation is that you can't step through code line-by-line. Unlike most of the other current limitations, this one wasn't for lack of effort, but because I don't (yet?) know how to do it. The lack of ways to specify data locations is the biggest weakness ("help" tells you the currently supported ways). Ideally, it would handle local variables and allow expressions such as foo[3].bar->baz as data locations. Unfortunately, getting that to work would require beefing up Valgrind's debug info reader greatly, which is not impossible, but would be a lot of work. Another thing: it's a bit different to gdb (or other normal debuggers) in one important respect. With gdb, you start it up and then gdb can start your program, kill it, and start again -- the debugger is "outside" the program. Valgrind's shell is different. Because Valgrind effectively becomes part of your program when you use it (Valgrind and your program run as one process), Valgrind's shell is effectively "inside" your program. This means that killing your program kills the shell, so if you eg. want to restart your program, you have to restart Valgrind with it. It's very much prototype-quality code; there are bound to be bugs. I'm putting it out there to get feedback, find out if this would be useful to anyone. Hopefully yes, although there's no guarantees this will ever make it into Valgrind-proper. Nonetheless, enjoy. N |