Re: debugging C functions - Mailing list pgsql-general

From Tom Lane
Subject Re: debugging C functions
Date
Msg-id 17641.1056117025@sss.pgh.pa.us
Whole thread Raw
In response to debugging C functions  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
List pgsql-general
"Nigel J. Andrews" <nandrews@investsystems.co.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

pgsql-general by date:

Previous
From: Doug McNaught
Date:
Subject: Re: dropping sequences
Next
From: "Johnson, Shaunn"
Date:
Subject: splitting a table?