Debugging custom PostgreSQL functions

I am developing a set of custom functions and custom aggregates written for PostgreSQL, and I am having difficulty diagnosing what causes a constant code break. Does anyone know if / how to use GDB with UDF written in C ++? Several Google searches did not display anything. I used ELOG before to debug UDF, but this project is complex enough that I need something more powerful.

Thanks Kevin

+5
source share
1 answer

You should be able to connect gdb to the postgresql executable server, although you probably want to make sure that your postgresql assembly has debugging symbols left in it to make it clear. If you do select pg_backend_pid(), you will get the identifier of the reverse process you are dealing with, and then you can connect gdb to it (using the -pid command or the command attach). This approach is only useful when you can reproduce the problem using psql, for example: having new backend processes automatically associated with gdb is ... more complicated. For example, you can set options such as post_auth_delayto make postgresql wait after authentication is complete, giving you the ability to attach a debugger before it continues processing.

+2
source

All Articles