gh-127604: Add C stack dumps to faulthandler#128159
Conversation
|
@ZeroIntensity If you ever use the web UI, don't forget to replace my tabs with spaces... hopefully your IDE does it but I see that I have tabs instead of spaces on my suggestions (I've corrected them but just double-check) |
Co-authored-by: Bénédikt Tran <[email protected]>
Modules/faulthandler.c
Outdated
|
|
||
| if (!PyArg_ParseTupleAndKeywords(args, kwargs, | ||
| "|O:dump_c_stack", kwlist, | ||
| &file)) |
There was a problem hiding this comment.
I think this got brought up before. The rest of the file avoids the braces, it's probably better to just stay consistent.
There was a problem hiding this comment.
I respectfully disagree, we are adding new functions so it's better to go closer to the standard that deviate more from it
There was a problem hiding this comment.
As the author of the original code, I would prefer that new code respects PEP 7 (add braces) :-)
There was a problem hiding this comment.
Will do. cc @picnixz if you want to bicker about styling (I'm pretty sure you were the one that originally brought this up).
|
I tested with: import faulthandler
faulthandler.dump_c_stack()gdb is able to retrieve the function name of all frames, whereas I built Python on Fedora 41 with gdb stack output:
|
|
I'm pretty sure that's because GDB is using extra debugging information that we can't access from a signal handler. |
Yes but the functions you call should be using the GNU libbacktrace code and that can parse DWARF 4 so not sure what's going on. I guess the only thing to do here is to check if your custom functions are not missing anything here by comparing the output with the vanilla ones |
|
Maybe it's some sort of compiler flag? If you checkout 533b1db (before I started the homebrewed version), you see similar results in the output. |
Can you check if compiling with -g3 makes any difference? |
|
Replacing |
|
I'm pretty sure this is as good as we're going to get. |
gpshead
left a comment
There was a problem hiding this comment.
as much as I believe there can be better ways to do this, this is a great start to the feature. we can improve upon the capabilities in the future.
pablogsal
left a comment
There was a problem hiding this comment.
Agreed! LGTM
great job @ZeroIntensity 👌
|
Congrats @ZeroIntensity, nice enhancement. |
This only adds it for glibc right now. I think it's possible to implement it for Windows with
StackWalk64, but I'd prefer to get a solid working implementation for other systems before I dive into that.faulthandler#127604📚 Documentation preview 📚: https://cpython-previews--128159.org.readthedocs.build/en/128159/library/faulthandler.html#dumping-the-c-stack