Re: backend debug information - Mailing list pgsql-interfaces

From Tom Lane
Subject Re: backend debug information
Date
Msg-id 19258.987456270@sss.pgh.pa.us
Whole thread Raw
In response to Re: backend debug information  (selkovjr@mcs.anl.gov)
List pgsql-interfaces
selkovjr@mcs.anl.gov writes:
> As far as debugging, short of being able to run a postgres under gdb
> while connecting clients to it (I wish I knew whether that was at all
> possible),

It's easy to attach gdb to a running backend process; I do that all the
time.  Usual procedure is:
1. Fire up psql in another window2. Determine PID of backend attached to your psql3. gdb /path/to/postgres/executable4.
"attachPID"5. Set breakpoint at desired location(s), continue6. Execute problem query in psql
 

On some platforms you don't have to mention the executable file, as
gdb can figure it out by looking at the process you attach to.  On
others you need to give it.

Setting breakpoints in dynamically loaded shared libraries (ie, user
datatype code) may be easy, painful, or impossible depending on your
platform.  However, you usually can catch a SEGV in such code in any
case; just let the failure happen while gdb is attached.

Don't forget to build your datatype code with -g, and the backend too,
or you'll not be able to learn much.
        regards, tom lane


pgsql-interfaces by date:

Previous
From: selkovjr@mcs.anl.gov
Date:
Subject: Re: backend debug information
Next
From: selkovjr@mcs.anl.gov
Date:
Subject: Re: making data types