A script to make some bug report easier - Mailing list pgsql-patches
From | Qingqing Zhou |
---|---|
Subject | A script to make some bug report easier |
Date | |
Msg-id | Pine.LNX.4.58.0510270505090.27983@eon.cs Whole thread Raw |
Responses |
Re: A script to make some bug report easier
|
List | pgsql-patches |
I wrote a small script to make PostgreSQL bug report easier. It prints the uname, pg_config and try to backtrace all core dumps in data directory. Also, it provides a mode which you can interact with gdb. Put this shell script together in PG bin directory with other executables. It does not cover possible bugs like slow query, hang, etc, but it could be a help for core dumps errors (as we have seen several recently). There are some loose end of the script, for example, it assumes core dumps are under data directory -- for some OS, it is not the truth. If people think this is useful, I will make it complete. Also, on a wild thinking, is there any good to generate explain analyze result into XML format, which might be a step to ease the automatic analysis for suspecious query plans. Regards, Qingqing ps. Still can't send attachment -- "binary in non-binary group" :-( --- #! /bin/sh # # Bug reporter for PostgreSQL # Note: Put this file within the same directory of PostgreSQL executable programs # me=`basename $0` help="\ PostgreSQL bug reporter Usage: $me [options...] Options: --datadir=DIR the data files are in DIR (default \`./data/') --outputdir=DIR place output files in DIR (default \`.') --interact=Y/N interact with gdb ('y' or 'n', default 'n') Report bugs to <pgsql-bugs@postgresql.org>." : ${outputdir=.} : ${datadir=./data/} : ${interact="n"} # ---------- # Parse command line options # ---------- while [ "$#" -gt 0 ] do case $1 in --help|-\?) echo "$help" exit 0;; --outputdir=*) outputdir=`expr "x$1" : "x--outputdir=\(.*\)"` shift;; --datadir=*) datadir=`expr "x$1" : "x--datadir=\(.*\)"` shift;; --interact=*) interact=`expr "x$1" : "x--interact=\(.*\)"` shift;; -*) echo "$me: invalid argument $1" 1>&2 exit 1;; esac done # ---------- # Test if directories, files are ok # ---------- for i in $outputdir $datadir; do if ! test -d "$i"; then echo "Directory $outputdir does not exist" exit 1 fi done for i in ./pg_config ./postgres; do if ! test -f "$i"; then echo "File $i does not exist" exit 1 fi done report="$outputdir/bugreport.rpt" tempcmd="./temp.cmd" # ---------- # Some preparation # ---------- CC=`./pg_config | grep "CC = " | cut -d= -f2` echo "file ./postgres" > "$tempcmd" echo "bt" >> "$tempcmd" if [ "$interact" != "y" ]; then echo "q" >> "$tempcmd" fi SPACE=" ********* " { # ---------- # Print system information # ---------- echo "$SPACE System Information $SPACE" echo "uname -a: `uname -a`" echo "\$CC --version: `$CC --version | head -n 1`" echo # ---------- # Print pg_config information # ---------- echo "$SPACE pg_config Information $SPACE" ./pg_config echo # ---------- # Backtrace core dumps in datadir # ---------- echo "$SPACE Core dumps Information $SPACE" nc=0; for i in `find "$datadir" -name "core*"`; do separator="Backtrace stack of $i" echo $separator echo `echo "$separator" | sed 's/./_/g'` gdb -c $i --command "$tempcmd" nc=`expr $nc + 1` done echo if test $nc == 0; then echo "No core dump found in $datadir" else echo "$nc core dump(s) found!" fi echo # ---------- # More ... # - can we add "-l <logfile>" information # ---------- echo "$SPACE User session $SPACE" echo "Give a short description of the bug" echo echo "__________________________________" echo "Details" echo echo "___________________________________" echo echo "Bug report is generated at $report." echo "Please check it and fill the user session, then email it to <pgsql-bugs@postgresql.org>." echo "Thank you!" } | tee $report # ---------- # Cleanup # ---------- rm "$tempcmd" exit 0
pgsql-patches by date: