print_stack and print_debug live in @GDScript, which leads me to think I can't and shouldn't use those from my C++ code. If I'm wrong please show me how, or if you know another way to print a stack trace from C++ then I'd like to know it. Thank ye kindly, anyone!
Do you want a stack trace of your C++ code or GDScript?
If it is GDScript you can take a look at how print_stack()
and get_stack()
work:
https://github.com/godotengine/godot/blob/master/modules/gdscript/gdscript_utility_functions.cpp#L437
If you can use C++23 take a look at this:
https://en.cppreference.com/w/cpp/utility/basic_stacktrace
Other than that there is something like this:
https://github.com/bombela/backward-cpp
And for Windows:
https://learn.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-stackwalk64
Yeah I'm hoping for a stack trace from C++ code, ideally with some hint of the GDScript code which called down into it, but that is not necessary.
I'm trying to hunt where a function call in label.h is coming from. The editor of course uses labels everywhere, so I can't just break on it. My thought was to check if I'm in the game and then print the stack trace.
Godot only allows a subset of C++17, so C++23 is no-go.
Those last two links could prove helpful. I will look into each of those. Thank you!
Bercy
An alternative I sometimes use is to execute a statement that causes a segmentation fault and then analyse the core dump.
© 2022 - 2024 — McMap. All rights reserved.