From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: vignesh C <vignesh21@gmail.com>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: torikoshia <torikoshia@oss.nttdata.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Printing backtrace of postgres processes
Date: Fri, 26 Jan 2024 11:41:04 +0100
Message-ID: <202401261041.tnf6wsga2zvm@alvherre.pgsql> (raw)
In-Reply-To: <CALDaNm1K8wAQ-zTmbyVuHXJszgKfUQh6tGrdfDuWm2Fe=jfobQ@mail.gmail.com>
On 2022-Jan-27, vignesh C wrote:
> diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
> index 0ee6974f1c..855ccc8902 100644
> --- a/doc/src/sgml/func.sgml
> +++ b/doc/src/sgml/func.sgml
> + You can get the file name and line number from the logged details by using
> + gdb/addr2line in linux platforms (users must ensure gdb/addr2line is
> + already installed).
This doesn't read great. I mean, what is gdb/addr2line? I think you
mean either GDB or addr2line; this could be clearer.
> diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
> index 7402696986..522a525741 100644
> --- a/src/backend/utils/error/elog.c
> +++ b/src/backend/utils/error/elog.c
> @@ -944,9 +943,10 @@ errbacktrace(void)
> * Compute backtrace data and add it to the supplied ErrorData. num_skip
> * specifies how many inner frames to skip. Use this to avoid showing the
> * internal backtrace support functions in the backtrace. This requires that
> - * this and related functions are not inlined.
> + * this and related functions are not inlined. If the edata pointer is valid,
> + * backtrace information will be set in edata.
> */
> -static void
> +void
> set_backtrace(ErrorData *edata, int num_skip)
> {
> StringInfoData errtrace;
This seems like a terrible API choice, and the comment change is no
good. I suggest you need to create a function that deals only with a
StringInfo, maybe
append_backtrace(StringInfo buf, int num_skip)
which is used by set_backtrace to print the backtrace in
edata->backtrace, and a new function log_backtrace() that does the
ereport(LOG_SERVER_ONLY) thing.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"Before you were born your parents weren't as boring as they are now. They
got that way paying your bills, cleaning up your room and listening to you
tell them how idealistic you are." -- Charles J. Sykes' advice to teenagers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@alvh.no-ip.org, vignesh21@gmail.com, bharath.rupireddyforpostgres@gmail.com, torikoshia@oss.nttdata.com, pgsql-hackers@lists.postgresql.org
Subject: Re: Printing backtrace of postgres processes
In-Reply-To: <202401261041.tnf6wsga2zvm@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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