Re: debugging C functions

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: debugging C functions
Дата
Msg-id 1010.1180762732@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: debugging C functions  (Joe Conway <mail@joeconway.com>)
Список pgsql-general
Joe Conway <mail@joeconway.com> writes:
> [ much good advice snipped, but I have to weigh in on one point ]

> 4. Start another console and determine the PID for the backend
>     session (this will wrap poorly -- I'll do my best to make it
>     readable)

"select pg_backend_pid()" is another alternative for finding the PID.

Personally I've gotten to the point where manually determining the
backend PID at all is tedious, and so I tend to use this script:

#!/bin/sh

# 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

This fails (but gives you a list of processes to consider attaching to)
if there's more than one candidate.

            regards, tom lane

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

Предыдущее
От: Joe Conway
Дата:
Сообщение: Re: debugging C functions
Следующее
От: "Paolo Bizzarri"
Дата:
Сообщение: Re: Corruption of files in PostgreSQL