|
From: Dan K. <da...@ke...> - 2003-11-18 00:54:08
|
Per von Zweigbergk wrote: > Hi. > > Trying to get valgrind to attach to GDB at run-time -- which fails. I'm > suspecting i need to specify the string "gdb" somewhere for it to find > gdb -- since runnin 'gdb -nw /proc/13594/exe 13594' does what I want it to. > ... > ==13594== starting GDB with cmd: -nw /proc/13594/exe 13594 > /bin/sh: line 1: -nw: command not found FWIW, here are the hoops I had to jump through to get valgrind to let me launch gdb when valgrinding openoffice: http://kegel.com/openoffice/#valgrind.gdb Hopefully you won't have to do all that junk, but maybe it'll give you an idea. - Dan --- snip --- You can have valgrind launch gdb when it runs into an error; then you can do all the backtracing and printing of variabls you like. To do this, add the option --gdb-attach=yes. This doesn't work quite right, since OpenOffice appears to close stdin. Here's one way to work around that: 1. Create a little script named ~/rungdb containing #!/bin/sh XAUTHORITY=~/.Xauthority DISPLAY=127.0.0.1:0.0 /usr/X11R6/bin/xterm -e gdb "$@" Be sure to chmod +x ~/rungdb. The script is started without the normal environment variables, so you need to explicitly set any that are needed. The above is for Red Hat Linux 8.0. If the crash you're seeing happens to happen while the X display lock is held, you'll probably want to set DISPLAY to some other host's X display... that actually happened to me once. Then run OpenOffice with the command #!/bin/sh bin=/opt/OpenOffice.org1.1.0/program LD_LIBRARY_PATH=$bin valgrind -v --skin=addrcheck \ --gdb-attach=yes --gdb-command=~/rungdb \ $bin/soffice.bin That will pop up an xterm with a gdb inside it every time you say 'yes' when valgrind asks whether to start gdb. Note that all you can do in that gdb is get a backtrace; you can't continue the program. You must quit gdb before valgrind will continue. --- snip --- |