@@ -66,10 +66,41 @@ Dumping the traceback
6666 Added support for passing file descriptor to this function.
6767
6868
69+ Dumping the C stack
70+ -------------------
71+
72+ .. versionadded :: next
73+
74+ .. function :: dump_c_stack(file=sys.stderr)
75+
76+ Dump the C stack trace of the current thread into *file *.
77+
78+ If the Python build does not support it or the operating system
79+ does not provide a stack trace, then this prints an error in place
80+ of a dumped C stack.
81+
82+ .. _c-stack-compatibility :
83+
84+ C Stack Compatibility
85+ *********************
86+
87+ If the system does not support the C-level :manpage: `backtrace(3)`,
88+ :manpage: `backtrace_symbols(3)`, or :manpage: `dladdr(3)`, then C stack dumps
89+ will not work. An error will be printed instead of the stack.
90+
91+ Additionally, some compilers do not support :term: `CPython's <CPython> `
92+ implementation of C stack dumps. As a result, a different error may be printed
93+ instead of the stack, even if the the operating system supports dumping stacks.
94+
95+ .. note ::
96+
97+ Dumping C stacks can be arbitrarily slow, depending on the DWARF level
98+ of the binaries in the call stack.
99+
69100Fault handler state
70101-------------------
71102
72- .. function :: enable(file=sys.stderr, all_threads=True)
103+ .. function :: enable(file=sys.stderr, all_threads=True, c_stack=True )
73104
74105 Enable the fault handler: install handlers for the :const: `~signal.SIGSEGV `,
75106 :const: `~signal.SIGFPE `, :const: `~signal.SIGABRT `, :const: `~signal.SIGBUS `
@@ -81,6 +112,10 @@ Fault handler state
81112 The *file * must be kept open until the fault handler is disabled: see
82113 :ref: `issue with file descriptors <faulthandler-fd >`.
83114
115+ If *c_stack * is ``True ``, then the C stack trace is printed after the Python
116+ traceback, unless the system does not support it. See :func: `dump_c_stack ` for
117+ more information on compatibility.
118+
84119 .. versionchanged :: 3.5
85120 Added support for passing file descriptor to this function.
86121
@@ -95,6 +130,9 @@ Fault handler state
95130 Only the current thread is dumped if the :term: `GIL ` is disabled to
96131 prevent the risk of data races.
97132
133+ .. versionchanged :: next
134+ The dump now displays the C stack trace if *c_stack * is true.
135+
98136.. function :: disable()
99137
100138 Disable the fault handler: uninstall the signal handlers installed by
0 commit comments