public inbox for [email protected]
help / color / mirror / Atom feedprinting PGresult content with gdb
4+ messages / 4 participants
[nested] [flat]
* printing PGresult content with gdb
@ 2024-07-02 16:13 [email protected]
0 siblings, 2 replies; 4+ messages in thread
From: [email protected] @ 2024-07-02 16:13 UTC (permalink / raw)
To: [email protected]
<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div> </div>
<div class="signature">Hi all</div>
<div class="signature">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.</div>
<div class="signature">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</div>
<div class="signature">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)</div>
<div class="signature">(gdb) p res<br/>
$1 = (PGresult *) 0x7f0718000b80<br/>
(gdb) p *res<br/>
$2 = <incomplete type><br/>
(gdb) ptype res<br/>
type = struct pg_result {<br/>
<incomplete type><br/>
} *<br/>
(gdb) explore res<br/>
'res' is a pointer to a value of type 'PGresult'<br/>
Continue exploring it as a pointer to a single value [y/n]: y<br/>
The value of '*res' is of type 'PGresult' which is a typedef of type 'pg_result'<br/>
The value of '*res' is a struct/class of type 'pg_result' with no fields.<br/>
(gdb) <br/>
thanks for your hints</div>
<div class="signature">doris</div></div></body></html>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: printing PGresult content with gdb
@ 2024-07-03 12:02 Reid Thompson <[email protected]>
parent: [email protected]
1 sibling, 0 replies; 4+ messages in thread
From: Reid Thompson @ 2024-07-03 12:02 UTC (permalink / raw)
To: [email protected]; [email protected]
On Tue, 2024-07-02 at 18:13 +0200, [email protected] 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 = <incomplete type>
> (gdb) ptype res
> type = struct pg_result {
> <incomplete type>
> } *
> (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.3...
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: printing PGresult content with gdb
@ 2024-07-03 15:55 Tom Lane <[email protected]>
parent: [email protected]
1 sibling, 1 reply; 4+ messages in thread
From: Tom Lane @ 2024-07-03 15:55 UTC (permalink / raw)
To: [email protected]; +Cc: [email protected]
[email protected] 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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: printing PGresult content with gdb
@ 2024-07-04 16:11 Lana ABADIE <[email protected]>
parent: Tom Lane <[email protected]>
0 siblings, 0 replies; 4+ messages in thread
From: Lana ABADIE @ 2024-07-04 16:11 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: [email protected]
<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div> </div>
<div>
<div>
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Envoyé:</b> mercredi 3 juillet 2024 à 17:55<br/>
<b>De:</b> "Tom Lane" <[email protected]><br/>
<b>À:</b> [email protected]<br/>
<b>Cc:</b> [email protected]<br/>
<b>Objet:</b> Re: printing PGresult content with gdb</div>
<div name="quoted-content">[email protected] writes:<br/>
> I don't know if it is the right mailing list, but i was<br/>
> wondering if one could introspect via gdb the content of PGresult.<br/>
<br/>
You might have better luck with that if you install the debuginfo<br/>
RPM corresponding to your libpq RPM. PGresult's innards are not<br/>
exposed to applications by libpq-fe.h, so your own app's debug<br/>
data is not going to contain the details of the struct. But I think<br/>
it would be available to gdb if libpq's debug symbols were installed.<br/>
<br/>
regards, tom lane</div>
<div name="quoted-content"> </div>
<div name="quoted-content">thanks Tom</div>
<div name="quoted-content">Indeed installing the debuginfo rpm on my system solves the issue, i could print the content</div>
<div name="quoted-content">see trace below</div>
<div name="quoted-content">
<pre>(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' <repeats 53 times>, binary = 0, noticeHooks = {noticeRec = 0x7f0731f40770 <defaultNoticeReceiver>, noticeRecArg = 0x0,
noticeProc = 0x7f0731f40500 <defaultNoticeProcessor>, 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}</pre>
</div>
</div>
</div>
</div></div></body></html>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2024-07-04 16:11 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-07-02 16:13 printing PGresult content with gdb [email protected]
2024-07-03 12:02 ` Reid Thompson <[email protected]>
2024-07-03 15:55 ` Tom Lane <[email protected]>
2024-07-04 16:11 ` Lana ABADIE <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox