Received: from sss.pgh.pa.us ([216.151.103.158]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3GLPWu92101 for ; Mon, 16 Apr 2001 17:25:32 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.3/8.11.3) with ESMTP id f3GLOUR19261; Mon, 16 Apr 2001 17:24:30 -0400 (EDT) To: selkovjr@mcs.anl.gov cc: Lonnie Cumberland , pgsql-interfaces@postgresql.org Subject: Re: backend debug information In-reply-to: <200104162044.PAA00749@selkovjr.xnet.com> References: <20010416192226.52764.qmail@web12503.mail.yahoo.com> <200104162044.PAA00749@selkovjr.xnet.com> Comments: In-reply-to selkovjr@mcs.anl.gov message dated "Mon, 16 Apr 2001 15:44:32 -0500" Date: Mon, 16 Apr 2001 17:24:30 -0400 Message-ID: <19258.987456270@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200104/61 X-Sequence-Number: 1444 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 window 2. Determine PID of backend attached to your psql 3. gdb /path/to/postgres/executable 4. "attach PID" 5. Set breakpoint at desired location(s), continue 6. 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