Re: Making the regression tests halt to attach a debugger

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Making the regression tests halt to attach a debugger
Дата
Msg-id 22351.1431968735@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Making the regression tests halt to attach a debugger  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Ответы Re: Making the regression tests halt to attach a debugger  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-hackers
Jim Nasby <Jim.Nasby@BlueTreble.com> writes:
> On 5/18/15 8:44 AM, Tom Lane wrote:
>> If your approach involves modifying a target query in a regression test,
>> it really seems unnecessary to do all this.  Just insert something like
>> "select pg_sleep(60)" into the test script before the target query.
>>
>> A variant is to insert a sleep() in the C code, in someplace you don't
>> expect will be reached except in the problematic cases.

> You still have to hunt down the PID though; it's nicer if you just get
> it spit out in the log or to the client. This would also make it easier
> to debug interactive backends since you could just embed the magic
> comment in your test statement instead of needing a separate call to
> pg_backend_pid().

Meh.  You could also add "select pg_backend_pid()" or some such.
But really, the way I generally do this is to run gdb via a script
that auto-attaches to the right postgres process if at all possible.
Removes the whole problem.

            regards, tom lane

#!/bin/sh

# Usage: gdblive

cd $HOME

# 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: wal writer' -e 'postgres:
checkpointer'-e 'postgres: archiver' -e 'postgres: logger' -e 'postgres: autovacuum' | \ 
    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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: ERROR: cannot GetMultiXactIdMembers() during recovery
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: ERROR: cannot GetMultiXactIdMembers() during recovery