Grzegorz Piotr Jaskiewicz <[EMAIL PROTECTED]> writes:
> can I just run postgres, in non forking mode, on gdb?

Just start a normal session and then attach to the backend process with
gdb in a separate window.  There's no reason to fool with a standalone
backend for 99.99% of debugging problems.  With a regular session, you
can use psql to input the SQL commands, which is MUCH friendlier than a
standalone backend, and you can run additional sessions in case you'd
like to examine the state of the database while you've got your debug
backend pinned down someplace.

I tend to use the attached script so that I don't even need to manually
discover the PID to attach to, assuming there's only one backend running
(else it shows me all the plausible candidates to attach to).

Dunno about the gist-specific issue, Oleg or Teodor will have to answer
that.

                        regards, tom lane

#!/bin/sh

# Usage: gdblive

# tee /dev/tty is for user to see the set of procs considered
PROCS=`ps auxww | \
    grep postgres: | \
    grep -v -e 'grep postgres:' -e 'postgres: stats' -e 'postgres: writer' -e 
'postgres: archiver' -e 'postgres: logger' | \
    tee /dev/tty | \
    awk '{print $2}'`

if [ `echo "$PROCS" | wc -w` -eq 1 ]
then
    exec gdb $PGINSTROOT/bin/postgres -silent "$PROCS"
else
    exec gdb $PGINSTROOT/bin/postgres -silent
fi

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to