Re: [HACKERS] postgres under gdb

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] postgres under gdb
Дата
Msg-id 10619.949071095@sss.pgh.pa.us
обсуждение исходный текст
Ответ на postgres under gdb  (Chris <chris@bitmead.com>)
Ответы Re: [HACKERS] postgres under gdb  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: postgres under gdb  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-hackers
Chris <chris@bitmead.com> writes:
> How do you run postgres under gdb?

If you are running a standalone backend, you just fire it up.
For normal use under a postmaster, the easiest thing I've found is to
start psql (or your favorite client) in one window, start gdb on the
postgres executable in another, and then "attach" to the already-started
backend process.  (Use "ps" to discover the backend's PID.)  You must
run gdb as postgres, of course, but the client process can belong to
anyone.

It gets a little tricky if you are trying to debug part of the
backend startup sequence.  We have a kluge for that: start psql
with PGOPTIONS="-W n".  That causes the backend to sleep() for n
seconds fairly early in its startup, giving you time to attach to it
before anything really interesting happens.

In theory you can debug one backend in a live production system
this way, but I wouldn't recommend doing that except in dire need.
If you use gdb to stop the backend while it is holding a lock, you'll
block other backends too --- and holding a spinlock is even worse,
because those other backends will time out after a minute or so.
Better to use a playpen installation.

(Hey Bruce, shouldn't this info be in FAQ_DEV?)
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] OO and tuples of different types
Следующее
От: The Hermit Hacker
Дата:
Сообщение: Re: [HACKERS] Re: ORDBMS