Created
May 10, 2019 03:27
-
-
Save yjhjstz/0f5dfd8ae74883a210a0378c6d5fc58f to your computer and use it in GitHub Desktop.
Gdblive script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Usage: gdblive [ arguments to grep output of ps ] | |
cd $HOME | |
# tee /dev/tty is for user to see the set of procs considered | |
if [ $# -eq 0 ] | |
then | |
PROCS=`ps auxww | \ | |
grep postgres: | \ | |
grep -v -e 'grep postgres:' -e 'postgres: stats' -e 'postgres: writer' -e 'postgres: wal writer' -e 'postgres: checkpointer' -e 'postgres: archiver' -e 'postgres: logger' -e 'postgres: autovacuum' | \ | |
tee /dev/tty | \ | |
awk '{print $2}'` | |
else | |
PROCS=`ps auxww | \ | |
grep postgres: | \ | |
grep -v -e 'grep postgres:' -e 'postgres: stats' -e 'postgres: writer' -e 'postgres: wal writer' -e 'postgres: checkpointer' -e 'postgres: archiver' -e 'postgres: logger' -e 'postgres: autovacuum' | \ | |
grep $@ | \ | |
tee /dev/tty | \ | |
awk '{print $2}'` | |
fi | |
if [ `echo "$PROCS" | wc -w` -eq 1 ] | |
then | |
exec gdb $PGINSTROOT/bin/postgres -silent "$PROCS" | |
else | |
exec gdb $PGINSTROOT/bin/postgres -silent | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment