Re: To connect a debbuger... - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: To connect a debbuger...
Date
Msg-id 87slcaxrjj.fsf@stark.xeocode.com
Whole thread Raw
In response to To connect a debbuger...  (Jonathan Scher <js@oxado.com>)
List pgsql-hackers
"Jonathan Scher" <js@oxado.com> writes:

> I attach gdb to /usr/.../bin/postgres, then I put a breakpoint. Whenever
> postgres stop on that breakpoint, it just kills/restarts the server instead of
> asking me what to do.

Not sure why it's crashing but you don't want to run postgres itself under the
debugger, at least not usually. What you have to do is start postgres up
normally, connect to it with psql or whatever client you want, then in a
separate shell run something like:

(gdb) shell ps auxww | grep [i]dle
stark     3724  0.0  0.1  36180  2044 ?        Ts   18:07   0:00 postgres: stark postgres [local] idle       
(gdb) attach 3724
Attaching to process 3724
Reading symbols from /usr/local/pgsql/bin/postgres...done.
...

> Reading symbols from /usr/local/pgsql/bin/postgres...(no debugging symbols
> found)...done.

Also, you'll want to configure with --enable-debug or else your gdb session
isn't going to be very enlightening.

Personally I suggest:

CFLAGS='-O0 -g' ./configure --enable-debug --enable-depend --enable-cassert

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Updating large postgresql database with blobs
Next
From: "Simon Riggs"
Date:
Subject: Re: Bug: Buffer cache is not scan resistant