Get Backtrace ------------- Written by Athanasius Help file by Silver ## This code requires "expect" - the RedHat RPM of this can be found ## from the RedHat/RPMS directory of any redhat linux site with the ## filename 'expect-5.26-20.i386.rpm' How to set up ------------- Cut out the code between the BEGIN and the ENDs and save them in your 'pgplus/bin' directory under the names specified. Be sure to edit the 'get-bt.exp' file and change the following variables: basedir = the directory pointing to the talker pidfile = the location of the PID file logfile = the location of the file where the logs will go Compile your talker with DEBUGGING turned *on*. and USE_LIBG turned *on*. If these are undefined then the logs will be useless. Compile and boot your talker. Run the get-bt file with: nohup get-bt.exp & a log file will appear which will be blank (at the beginning). When the code crashes, this script with do a "bt" (backtrace), store this information and then do "c" (a continue). Therefore to see what code is crashing your talker, just look at this file. To get rid of get-bt, just kill the process. If you wish to reboot the talker (either hard or soft) kill get-bt first. NOTE: It is not recommended to run get-bt as a general purpose debugging tool since the use of DEBUGGING and LIBG is required which increase the size of the executables drastically. Once you have found and fixed the bugs, uncomment DEBUGGING, recompile and reboot otherwise your systems administrator may complain! --BEGIN get-bt.exp ---------------------------------------------------- #!/usr/local/bin/expect -f # # Attach a gdb to a running talker executeable: # # If it crashes get a 'bt' then 'continue'. # Attach to the NEW server process, repeat # # Base directory where the talker runs set basedir /home/username/pgplus # File holding PID of running talker server set pidfile junk/PID # Where we keep our log set logfile logs/get-bt.log # A loop: # Get talker pid # Attach gdb to it, and 'continue' # Wait for a crash, 'bt', 'continue' # Exit gdb, loop # Our log of what happened log_file $logfile # match_max 10000 # for start test next body for {} 1 {} { # Grab the pid of a running talker server while {![file readable $pidfile]} { sleep 5 } set file [open $pidfile] gets $file process_id # Fire up gdb set timeout -1 for {spawn gdb bin/surfers $process_id} 1 {} { send_log [timestamp -format "%d/%m/%y - %H:%M:%S"] expect_before "Program received signal SIGSEGV" { send "bt\r" ; send "continue\r" } expect { "Program exited " { send "quit\r" ; break } "The program is not being run" { send "quit\r" ; break } "(gdb) bt" "" "(gdb) continue" "" "(gdb)" { send "continue\r" } } } send_log [timestamp -format "%d/%m/%y - %H:%M:%S"] set timeout 10 expect "Program exited " { send "quit\r" ; break } wait sleep 5 } --END get-bt.exp ---------------------------------------------------- And in the directory you run this from: --BEGIN .gdbinit ------------------------------------------------------- handle SIGPIPE nostop handle SIGPIPE noprint handle SIGWINCH nostop handle SIGWINCH noprint handle SIGUSR1 nostop handle SIGUSR1 noprint handle SIGUSR2 nostop handle SIGUSR2 noprint --END .gdbinit -------------------------------------------------------