Jump to content

Recommended Posts

Posted

hello, cause i havent found a gdb-restartscript here i will post mine, which i got through looking at: http://www.trinitycore.org/forum/f5/16line-autorestarter-gdb-tracer-t3679.html

my resulting script, which is already some days in use and seems to work fine, is:

http://mangos-files.eu/patches/startmangos

and the restartscript which is also in use:

http://mangos-files.eu/patches/mangrestart

and i post the startmangosscript here too, cause i don't know if it will be always on this server

#!/bin/bash
LOGDIR="/home/dbs/server/logs/"
LOG_LOG0="log_mangos"
LOG_ERR0="err_mangos"
LOG_GDB0="gdb_mangos"


LOG_LOG=$LOGDIR$LOG_LOG0
LOG_ERR=$LOGDIR$LOG_ERR0
LOG_GDB=$LOGDIR$LOG_GDB0

echo "run" > .core.gdb
echo "bt" >> .core.gdb
echo "bt full" >> .core.gdb
echo "thread apply all backtrace full" >> .core.gdb

while true
do
   date=`date +%Y%m%d_%H.%M.%S`
   #gdb ./server/bin/mangos-worldd -x .core.gdb --batch > $LOG_LOG".log" 2> $LOG_ERR".log"
   gdb ./server/bin/mangos-worldd -x .core.gdb --batch &>$LOG_LOG".log"
   grep -B 40 -A 1800 "Program received signal SIG" $LOG_LOG".log" > $LOG_GDB$date".log"
   mv $LOG_LOG".log" $LOG_LOG$date".log"
   #mv $LOG_ERR".log" $LOG_ERR$date".log"

   rm $LOGDIR"last_"$LOG_LOG0".log"
   ln -s $LOG_LOG$date".log" $LOGDIR"last_"$LOG_LOG0".log"
   #rm $LOGDIR"last_"$LOG_ERR0".log"
   #ln -s $LOG_ERR$date".log" $LOGDIR"last_"$LOG_ERR0".log"
   rm $LOGDIR"last_"$LOG_GDB0".log"
   ln -s $LOG_GDB$date".log" $LOGDIR"last_"$LOG_GDB0".log"
   echo `date`" restarting"
   sleep 11 # let the operating system clean up some stuff, and the tester cool down a bit 
done

cause i found no way, so that mangos still can write to stdout, and cause i don't need this feature, you have to do

tail -f /path/to/mangoslog

after starting, but then you won't have the console..

if mangos doesn't write to stdout it's also realy much faster (10seconds without stdout and over 60s with stdout)

also i don't take any warranty if this script doesn't work at your computer or if this will destroy something - please read the code first

i only post it here so that other people can get inspiration how this can be done

Posted

I had a note about this somewhere on old forums .. but it got deleted. Only https://getmangos.eu/community/showpost.php?p=52615&postcount=6 remained, but the description how to make backtrace of an attached process isn't there.

Well since it's a looong time ago, I don't remember it correctly, but I had a problem to split the program's stdout and the actual backtrace. So I used a GDB option -tty and redirected mangos's stdin/out to the screen session itself (ie. virtual terminal device) while doing "&> dump.txt" with the gdb that run the worldd.

It worked. But it had a problem - IIRC the trace was messed up with screen's terminating calls (which is strange, I didn't debug screen running worldd, I used binary of worldd directly in GDB) so I didn't investigate further and used the old way instead (= saving a dump to disk + calling gdb on it + deleting the dump).

edit: yes, from what I see in your script, you probably use RA to manage mangos console, in that case, you can redirect stdin/out to /dev/null using the -tty=/dev/null and save only GDB debug trace

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use