Re: [Beginner Question] How to print the call link graph?

From: Erik Wienhold <ewie(at)ewie(dot)name>
To: Wen Yi <wen-yi(at)qq(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: [Beginner Question] How to print the call link graph?
Date: 2023-07-01 19:44:58
Message-ID: 1258483511.481646.1688240698486@office.mailbox.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On 01/07/2023 09:10 CEST Wen Yi <wen-yi(at)qq(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kirk Wolak 2023-07-01 21:41:25 Re: Adding SHOW CREATE TABLE
Previous Message Garfield Lewis 2023-07-01 17:05:29 Re: [EXT] Re: [Beginner Question] How to print the call link graph?