Re: printing PGresult content with gdb

2024-07-08 Thread Lana ABADIE
 

 
 

Envoyé: mercredi 3 juillet 2024 à 17:55
De: "Tom Lane" 
À: clippe...@gmx.fr
Cc: pgsql-general@lists.postgresql.org
Objet: Re: printing PGresult content with gdb

clippe...@gmx.fr writes:
> I don't know if it is the right mailing list, but i was
> wondering if one could introspect via gdb the content of PGresult.

You might have better luck with that if you install the debuginfo
RPM corresponding to your libpq RPM. PGresult's innards are not
exposed to applications by libpq-fe.h, so your own app's debug
data is not going to contain the details of the struct. But I think
it would be available to gdb if libpq's debug symbols were installed.

regards, tom lane

 

thanks Tom

Indeed installing the debuginfo rpm on my system solves the issue, i could print the content

see trace below


(gdb) p *res
$2 = {ntups = 0, numAttributes = 0, attDescs = 0x0, tuples = 0x0, tupArrSize = 0, numParameters = 0, paramDescs = 0x0, resultStatus = PGRES_FATAL_ERROR, 
  cmdStatus = "\000ELECT 3\000\061", '\000' , binary = 0, noticeHooks = {noticeRec = 0x7f0731f40770 , noticeRecArg = 0x0, 
    noticeProc = 0x7f0731f40500 , noticeProcArg = 0x0}, events = 0x0, nEvents = 0, client_encoding = 6, 
  errMsg = 0x7f07180076e8 "server closed the connection unexpectedly\n\tThis probably means the server terminated abnormally\n\tbefore or while processing the request.\n", 
  errFields = 0x0, errQuery = 0x0, null_field = "", curBlock = 0x7f07180076e0, curOffset = 146, spaceLeft = 1902, memorySize = 2264}








Re: printing PGresult content with gdb

2024-07-03 Thread Tom Lane
clippe...@gmx.fr writes:
> I don't know if it is the right mailing list, but i was
> wondering if one could introspect via gdb the content of PGresult.

You might have better luck with that if you install the debuginfo
RPM corresponding to your libpq RPM.  PGresult's innards are not
exposed to applications by libpq-fe.h, so your own app's debug
data is not going to contain the details of the struct.  But I think
it would be available to gdb if libpq's debug symbols were installed.

regards, tom lane




Re: printing PGresult content with gdb

2024-07-03 Thread Reid Thompson
On Tue, 2024-07-02 at 18:13 +0200, clippe...@gmx.fr wrote:
>  
> Hi all
> I don't know if it is the right mailing list, but i was wondering if
> one could introspect via gdb the content of PGresult.
> In my case i got a coredump and when i tried to analyze the core and
> try to print the content of PGresult i got incomplete type
> I'm using libpq-13.3 (installed via libpq-13.3-1.el8_4.x86_64,
> RHEL8.5). Any help would be appreciated (i'm trying to get the
> errMesg value of this field)
> (gdb) p res
> $1 = (PGresult *) 0x7f0718000b80
> (gdb) p *res
> $2 = 
> (gdb) ptype res
> type = struct pg_result {
>     
> } *
> (gdb) explore res
> 'res' is a pointer to a value of type 'PGresult'
> Continue exploring it as a pointer to a single value [y/n]: y
> The value of '*res' is of type 'PGresult' which is a typedef of type
> 'pg_result'
> The value of '*res' is a struct/class of type 'pg_result' with no
> fields.
> (gdb) 
> thanks for your hints
> doris

https://wiki.postgresql.org/wiki/Developer_FAQ#Why_do_we_use_Node_and_List_to_make_data_structures.3F
may be of help.

Instead of printing values in gdb format, you can use the next two
commands to print out List, Node, and structure contents in a verbose
format that is easier to understand. Lists are unrolled into nodes, and
nodes are printed in detail. The first prints in a short format, and
the second in a long format:

(gdb) call print(any_pointer)
(gdb) call pprint(any_pointer)
The output appears in the server log file, or on your screen if you are
running a backend directly without a postmaster.




I found that from https://wiki.postgresql.org/wiki/Developer_FAQ#gdb




printing PGresult content with gdb

2024-07-03 Thread clipperDB
 

Hi all

I don't know if it is the right mailing list, but i was wondering if one could introspect via gdb the content of PGresult.

In my case i got a coredump and when i tried to analyze the core and try to print the content of PGresult i got incomplete type

I'm using libpq-13.3 (installed via libpq-13.3-1.el8_4.x86_64, RHEL8.5). Any help would be appreciated (i'm trying to get the errMesg value of this field)

(gdb) p res
$1 = (PGresult *) 0x7f0718000b80
(gdb) p *res
$2 = 
(gdb) ptype res
type = struct pg_result {
    
} *
(gdb) explore res
'res' is a pointer to a value of type 'PGresult'
Continue exploring it as a pointer to a single value [y/n]: y
The value of '*res' is of type 'PGresult' which is a typedef of type 'pg_result'
The value of '*res' is a struct/class of type 'pg_result' with no fields.
(gdb) 
thanks for your hints

doris