Thread: Debugging Postgresql 9.3 with Eclipse CDT and GDB

Debugging Postgresql 9.3 with Eclipse CDT and GDB

From
venkateshwaran S
Date:

Hi,
I need some help with attaching debugger to postgresql .

i am from java background and have used debugger in eclipse(java).

i have installed postgresql 9.3 as stated in this link: https://wiki.postgresql.org/wiki/Working_with_Eclipse

The debugger works fine for the server(which waits and accepts incoming client connections).

1. When i connect a client with: **$ psql test** .Does the server create a new thread for the client?

2. Is it possible to attach debugger and set breakpoints in parser.c or executor.c in postgresql source files so that i can analyse how postgresql queries are executed?

I have tried attaching debugger and set breakpoints in parser.c and executed some queries in the client.But it doesnt stop at the breakpoint.

Thanks in Advance

with regards,
Venkateshwaran S

Re: Debugging Postgresql 9.3 with Eclipse CDT and GDB

From
Tom Lane
Date:
venkateshwaran S <venkateshwaracholan@gmail.com> writes:
> i have installed postgresql 9.3 as stated in this link:
> https://wiki.postgresql.org/wiki/Working_with_Eclipse
> The debugger works fine for the server(which waits and accepts incoming
> client connections).
> 1. When i connect a client with: **$ psql test** .Does the server create a
> new thread for the client?

It creates a new child process.  Read
http://www.postgresql.org/docs/devel/static/overview.html
particularly section 48.2.

> 2. Is it possible to attach debugger and set breakpoints in parser.c or
> executor.c in postgresql source files so that i can analyse how postgresql
> queries are executed?

It sounds like you're setting breakpoints in the postmaster process,
which will never be hit.  Attach to the relevant backend process instead.
(Select pg_backend_pid() in your client if you're not sure which that is,
or you can discover it from "ps auxww" output.)

            regards, tom lane