pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feed[Beginner Question] How to print the call link graph?
6+ messages / 5 participants
[nested] [flat]
* [Beginner Question] How to print the call link graph?
@ 2023-07-01 07:10 Wen Yi <wen-yi@qq.com>
0 siblings, 3 replies; 6+ messages in thread
From: Wen Yi @ 2023-07-01 07:10 UTC (permalink / raw)
To: pgsql-general <pgsql-general@lists.postgresql.org>
Hi community,
I use the gdb to track the postgres like this:
...
pq_getbyte () at pqcomm.c:980
980 in pqcomm.c
(gdb) next
985 in pqcomm.c
(gdb) next
986 in pqcomm.c
(gdb) next
SocketBackend (inBuf=0x7ffc8f7e1310) at postgres.c:372
372 postgres.c: Directory not empty.
(gdb) next
403 in postgres.c
(gdb) next
406 in postgres.c
(gdb) next
407 in postgres.c
(gdb) next
...
But the question is:
It's too slow to input 'next' to run the postgres, I used to try to use the 'continut', but the gdb will run the postgres directly and not print the function name and code line
I want to it print like this:
... -> pq_getbyte () at pqcomm.c:980 -> SocketBackend (inBuf=0x7ffc8f7e1310) at postgres.c:372 -> ...
Can someone provide me some advice?
Thanks in advance!
Yours,
Wen Yi
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [Beginner Question] How to print the call link graph?
@ 2023-07-01 15:26 Ron <ronljohnsonjr@gmail.com>
parent: Wen Yi <wen-yi@qq.com>
2 siblings, 1 reply; 6+ messages in thread
From: Ron @ 2023-07-01 15:26 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 7/1/23 02:10, Wen Yi wrote:
> Hi community,
> I use the gdb to track the postgres like this:
>
> ...
> pq_getbyte () at pqcomm.c:980
> 980 in pqcomm.c
> (gdb) next
> 985 in pqcomm.c
> (gdb) next
> 986 in pqcomm.c
> (gdb) next
> SocketBackend (inBuf=0x7ffc8f7e1310) at postgres.c:372
>
> 372 postgres.c: Directory not empty.
> (gdb) next
> 403 in postgres.c
> (gdb) next
> 406 in postgres.c
> (gdb) next
> 407 in postgres.c
> (gdb) next
> ...
>
> But the question is:
> It's too slow to input 'next' to run the postgres, I used to try to use
> the 'continut', but the gdb will run the postgres directly and not print
> the function name and code line
>
> I want to it print like this:
>
> ... -> pq_getbyte () at pqcomm.c:980 -> SocketBackend
> (inBuf=0x7ffc8f7e1310) at postgres.c:372 -> ...
>
> Can someone provide me some advice?
If no one here can, then superuser.com, unix.stackexchange.com or
stackoverflow.com should be able to. (Just don't cross-post...)
--
Born in Arizona, moved to Babylonia.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [Beginner Question] How to print the call link graph?
@ 2023-07-01 16:08 Julien Rouhaud <rjuju123@gmail.com>
parent: Wen Yi <wen-yi@qq.com>
2 siblings, 0 replies; 6+ messages in thread
From: Julien Rouhaud @ 2023-07-01 16:08 UTC (permalink / raw)
To: Wen Yi <wen-yi@qq.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
On Sat, Jul 01, 2023 at 03:10:27PM +0800, Wen Yi wrote:
> Hi community,
> I use the gdb to track the postgres like this:
>
> ...
>
> pq_getbyte () at pqcomm.c:980
> 980 in pqcomm.c
> (gdb) next
> [...]
> It's too slow to input 'next' to run the postgres, I used to try to use
> the 'continut', but the gdb will run the postgres directly and not
> print the function name and code line
>
>
> I want to it print like this:
>
>
> ... -> pq_getbyte () at pqcomm.c:980 -> SocketBackend (inBuf=0x7ffc8f7e1310) at postgres.c:372 -> ...
>
> Can someone provide me some advice?
> Thanks in advance!
I'm not sure what you want to do exactly, but just in case the usual way to do
is to put a breakpoint at the function you're interested in (e.g. "break
exec_simple_query"), or a specific line (e.g. "break filename.c:42"), and then
show the backtrace (backtrace or just bt).
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [EXT] Re: [Beginner Question] How to print the call link graph?
@ 2023-07-01 17:05 Garfield Lewis <garfield.lewis@lzlabs.com>
parent: Ron <ronljohnsonjr@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: Garfield Lewis @ 2023-07-01 17:05 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
> If no one here can, then superuser.com, unix.stackexchange.com or
> stackoverflow.com should be able to. (Just don't cross-post...)
If I understand the question this is a GDB question, correct? If so, I would simply set a breakpoint in GDB at that function like so:
b SocketBackend
commands
bt 2
end
this will break then print a backtrace of the last 2 functions (you can remove the 2 to get a full backtrace or change it to some other value). You could also add a continue (c) after the bt to have it run and just print out the backtrace until all is done (save the result to a file using the set logging command)
--
Regards,
Garfield A. Lewis
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [Beginner Question] How to print the call link graph?
@ 2023-07-01 19:44 Erik Wienhold <ewie@ewie.name>
parent: Wen Yi <wen-yi@qq.com>
2 siblings, 1 reply; 6+ messages in thread
From: Erik Wienhold @ 2023-07-01 19:44 UTC (permalink / raw)
To: Wen Yi <wen-yi@qq.com>; pgsql-general <pgsql-general@lists.postgresql.org>
> On 01/07/2023 09:10 CEST Wen Yi <wen-yi@qq.com> wrote:
>
> I use the gdb to track the postgres like this:
>
> ...
> pq_getbyte () at pqcomm.c:980
> 980 in pqcomm.c
> (gdb) next
> 985 in pqcomm.c
> (gdb) next
> 986 in pqcomm.c
> (gdb) next
> SocketBackend (inBuf=0x7ffc8f7e1310) at postgres.c:372
>
> 372 postgres.c: Directory not empty.
> (gdb) next
> 403 in postgres.c
> (gdb) next
> 406 in postgres.c
> (gdb) next
> 407 in postgres.c
> (gdb) next
> ...
>
> But the question is:
> It's too slow to input 'next' to run the postgres, I used to try to use the
> 'continut', but the gdb will run the postgres directly and not print the
> function name and code line
>
> I want to it print like this:
>
> ... -> pq_getbyte () at pqcomm.c:980 -> SocketBackend (inBuf=0x7ffc8f7e1310) at postgres.c:372 -> ...
>
> Can someone provide me some advice?
> Thanks in advance!
The Postgres wiki has a page on this topic:
https://wiki.postgresql.org/wiki/Getting_a_stack_trace_of_a_running_PostgreSQL_backend_on_Linux/BSD
Look for "backtrace" and gdb's bt command.
--
Erik
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [Beginner Question] How to print the call link graph?
@ 2023-07-02 11:06 Wen Yi <wen-yi@qq.com>
parent: Erik Wienhold <ewie@ewie.name>
0 siblings, 0 replies; 6+ messages in thread
From: Wen Yi @ 2023-07-02 11:06 UTC (permalink / raw)
To: pgsql-general <pgsql-general@lists.postgresql.org>
OK, that helps me a lot.
I just want to get the trace of function call.
Thanks very much!
Yours,
Wen Yi
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2023-07-02 11:06 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-07-01 07:10 [Beginner Question] How to print the call link graph? Wen Yi <wen-yi@qq.com>
2023-07-01 15:26 ` Ron <ronljohnsonjr@gmail.com>
2023-07-01 17:05 ` Garfield Lewis <garfield.lewis@lzlabs.com>
2023-07-01 16:08 ` Julien Rouhaud <rjuju123@gmail.com>
2023-07-01 19:44 ` Erik Wienhold <ewie@ewie.name>
2023-07-02 11:06 ` Wen Yi <wen-yi@qq.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox