Debugging extension with gdb?

Started by Paul Jonesover 12 years ago3 messagesgeneral
Jump to latest
#1Paul Jones
pbj@cmicdo.com

Can someone point me to information on how to debug a Postgres extension

with gdb?

I have been able to attach to one but getting breakpoints to work right
and getting the addresses to properly relocate (since the extension
could be loaded anywhere) has been the problem for me.

I have not found anything very definitive yet in searching the net.

Thanks,
PJ

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Paul Jones (#1)
Re: Debugging extension with gdb?

Paul Jones <pbj@cmicdo.com> writes:

Can someone point me to information on how to debug a Postgres extension
with gdb?

I've noticed that on some platforms, it works better to attach gdb to the
backend process before you load the extension, but on others, it works
better to attach afterwards. You might try the opposite procedure from
whatever you were doing. Other than that, it's mostly Just Worked for
me on any remotely modern platform. Be sure both the backend and the
extension are compiled with -g, of course.

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Paul Jones
pbj@cmicdo.com
In reply to: Tom Lane (#2)
Re: Debugging extension with gdb?

________________________________
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Paul Jones <pbj@cmicdo.com>
Cc: "pgsql-general@postgresql.org" <pgsql-general@postgresql.org>
Sent: Wednesday, November 20, 2013 9:13 AM
Subject: Re: [GENERAL] Debugging extension with gdb?

Paul Jones <pbj@cmicdo.com> writes:

Can someone point me to information on how to debug a Postgres extension
with gdb?

I've noticed that on some platforms, it works better to attach gdb to the
backend process before you load the extension, but on others, it works
better to attach afterwards.  You might try the opposite procedure from
whatever you were doing.  Other than that, it's mostly Just Worked for
me on any remotely modern platform.  Be sure both the backend and the
extension are compiled with -g, of course.

            regards, tom lane

After I *carefully* re-read your mail, I realized that I did not have
the entire postgresql compiled with '-g'.  So I went back and re-built
all of it and, behold, I set and caught a breakpoint in the extension.

Thanks!
PJ

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general