Re: debugging C functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: debugging C functions
Date: 2003-06-20 13:50:25
Message-ID: 17641.1056117025@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Nigel J. Andrews" <nandrews(at)investsystems(dot)co(dot)uk> writes:
> Attaching the debugger to the backend process I can't set a break
> point on my function, it says 'Function "blah" not defined' and when
> it segments somewhere under SPI_execp called from my function the
> stack trace has all the postgres symbols but just a '??' at the place
> my function is obviously sitting.

You won't be able to set a breakpoint in the function if its shared
library hasn't been loaded into the process yet. I'd suggest something
like

<start fresh session>
psql=> LOAD 'libraryname';
<attach to backend with gdb>
gdb> b myfunc
gdb> cont
psql=> SELECT myfunc();

If gdb still claims not to know the function with this approach, you
probably also need to issue a "sharedlibrary" command to gdb to force
it to absorb symbol definitions from the shlib. I think on most
platforms the above sequence will work without that, though.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Johnson, Shaunn 2003-06-20 14:02:43 splitting a table?
Previous Message Doug McNaught 2003-06-20 13:11:05 Re: dropping sequences