Print C stacktrace with `faulthandler`

The faulthandler module allows registering a SIGSEGV handler to print a Python stacktrace if the program encounters a segfault. However, if developing C/C++ extension modules that may not be particularly useful on its own, and you also want the the C stacktrace.
Printing it by default is probably an unnecessary change, so the suggestion would be to add a kwarg to cfaulthandler.enable() that enables this.

tl;dr: merge GitHub - timmaxw/cfaulthandler: Like Python's faulthandler module, but also prints the C call stack into the faulthandler module. In particular Add the actual C backtrace printing logic · timmaxw/cfaulthandler@561dbdd · GitHub is the commit that actually enables the extra functionality.

Note: I was tasked with trying to shepherd this change, and am not personally familiar with the usage of [c]faulthandler nor the implementation (yet).

The ability to get a usable stack trace is dependent on the way that code has been complied on Linux systems. Fedora changed to always use frame pointers so that stack traces are indeed useful recently.
Other distros may or may not have done this.

You will need to implement this feature for each ABI on each platform.

Add to this that to get the symbols you need you will need to know the mechanism that each platform uses to make symbols available.
For example Fedora uses debuginfod to dynamically download symbols that a debugger needs. See Debuginfod - Fedora Project Wiki

Howver if I start by running a python app under gdb, gdb knows how to format the python stack as well as the C stack. So I see the mix of python and C in context of one stack trace.

Thank you for the response!
If I’m interpreting things correctly, that means this is a non-issue on system that compile with frame pointers by default?
It appears that Ubuntu and Arch Linux have both joined in fedoras footsteps in enabling it, and hopefully others will follow suit.

You still need reliable stack unwinding software I think from what I have read, but I am not an expert on this subject.