-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make push_error
and push_warning
print name of calling function
#93648
base: master
Are you sure you want to change the base?
Conversation
QOL improvement to allow direct construction of `List`s.
Currently, `push_error` and `push_warning` give themselve as the calling function, which is not useful for debugging. I have altered these to use the C stacktrace to get the name of the function that called them. This saves having to turn these functions into macros, which would require recompiling every single piece of code that uses them. I have also set it to, when debug symbols are available, use them with `atos` (available on macOS) to find the exact source file and line being called from. It should be possible to the same thing on Linux using `addr2line`, but I don't have a Linux box handy to test that. I am not sure how you would implement this in Windows. I have tested this on macOS Sonoma 14.5 (23F79). It should work on any *nix system. I am not sure about Windows. Fixes godotengine#76770
Could you provide screenshots on how this would look now? Also check out the static check errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be done in a platform independent fashion, you need to fix the style issues so the CI can run to verify it on all platforms, but this would need to run on all platforms with reasonable support IMO, or be put just in the specific platform
Also I'm not sure this change makes sense, this method is called from scripting, the GDScript method won't be shown, so please add some screenshots to see what this outputs We don't want it to print the c++ method that called into scripting IMO |
Also add method to print whole callstack.
The Linux build breaks on `OS_Unix` because `Dl_info` is not `typedef`ed as `struct dl_info`, so the forward declaration of that struct breaks. Changing the forward declaration to `struct Dl_info` breaks the Mac build though, so that leaves us with some `#ifdef`s. This may or may not work, I'll have to see.
Okay, there doesn't actually seem to be a way to forward declare a `typedef` to an anonymous `struct`. So, rather than include an unnecessary system header in `os_unix.h`, I am now just passing the members of `Dl_info` individually. This will be slightly less efficient, but this code is generally not called in performance-critical paths, and this should be clean, maintainable, and platform-independent.
Neither Android's NDK nor Emscripten provide `backtrace` through `execinfo.h`. There are other ways to get a stacktrace on these platforms, but I am not expert enough to implement them, so leave them unimplemented for now.
Would #91006 be of any use here? |
Currently,
push_error
andpush_warning
give themselve as the callingfunction, which is not useful for debugging. I have altered these to use the
C stacktrace to get the name of the function that called them. This saves
having to turn these functions into macros, which would require recompiling
every single piece of code that uses them. I have also set it to, when debug
symbols are available, use them with
atos
(available on macOS) to find theexact source file and line being called from. It should be possible to the same
thing on Linux using
addr2line
, but I don't have a Linux box handy to testthat. I am not sure how you would implement this in Windows.
I have tested this on macOS Sonoma 14.5 (23F79). It should work on any *nix
system. I am not sure about Windows.
Fixes #76770