elog a stack trace

Started by Jeff Janesover 11 years ago4 messages
#1Jeff Janes
jeff.janes@gmail.com

Does anyone have any hints on how to get a stack trace programmatically,
rather than trying to run ps to get the pid and then attach gdb to a
ephemeral process and hoping the situation has not been changed while you
are doing that? I'd like to set

log_error_verbosity = stack

or

elog_stack(,...)

But those don't exist.

Cheers,

Jeff

#2Andres Freund
andres@2ndquadrant.com
In reply to: Jeff Janes (#1)
Re: elog a stack trace

Hi,

On 2014-05-02 08:16:39 -0700, Jeff Janes wrote:

Does anyone have any hints on how to get a stack trace programmatically,
rather than trying to run ps to get the pid and then attach gdb to a
ephemeral process and hoping the situation has not been changed while you
are doing that? I'd like to set

log_error_verbosity = stack

or

elog_stack(,...)

There's backtrace() on several platforms. The stacktraces are less
detailed than what gdb gives you tho.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3MauMau
maumau307@gmail.com
In reply to: Jeff Janes (#1)
Re: elog a stack trace

From: "Jeff Janes" <jeff.janes@gmail.com>

Does anyone have any hints on how to get a stack trace programmatically,
rather than trying to run ps to get the pid and then attach gdb to a
ephemeral process and hoping the situation has not been changed while you
are doing that? I'd like to set

log_error_verbosity = stack

or

elog_stack(,...)

But those don't exist.

On Windows, you can use Stackwalk() or Stackwalk64() Win32 API. Several
years ago, for some software, I implemented a feature that outputs the stack
trace of a crashing process to its server log file.

It would be very nice if PostgreSQL outputs the stack trace of a crashing
postgres process in the server log. That eliminates the need for users in
many cases to send the huge core files to the support staff or to use the
debugger to get the stack trace. I've recently heard that MySQL has this
feature.

Regards
MauMau

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: MauMau (#3)
Re: elog a stack trace

MauMau wrote:

On Windows, you can use Stackwalk() or Stackwalk64() Win32 API.
Several years ago, for some software, I implemented a feature that
outputs the stack trace of a crashing process to its server log
file.

It would be very nice if PostgreSQL outputs the stack trace of a
crashing postgres process in the server log. That eliminates the
need for users in many cases to send the huge core files to the
support staff or to use the debugger to get the stack trace. I've
recently heard that MySQL has this feature.

+1, assuming it can be made to work reliably and does not cause a larger
reliability problem. I see the GNU extension to get backtraces, for
instance, tries to malloc stuff in order to get a human-readable trace,
which might not be all that great.

--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers