-
-
Notifications
You must be signed in to change notification settings - Fork 23.7k
Add Logger and ability to print and log script backtraces
#91006
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
Conversation
|
Extremely wanted feature that could make it way easier to debug. Love this |
|
Not sure how reliable it will be, but it might be worth calling it from the crash handler as well (tested on macOS only and seems to be working): diff --git a/platform/macos/crash_handler_macos.mm b/platform/macos/crash_handler_macos.mm
index c370422bfa..91f76dc3b5 100644
--- a/platform/macos/crash_handler_macos.mm
+++ b/platform/macos/crash_handler_macos.mm
@@ -31,6 +31,7 @@
#include "crash_handler_macos.h"
#include "core/config/project_settings.h"
+#include "core/object/script_language.h"
#include "core/os/os.h"
#include "core/string/print_string.h"
#include "core/version.h"
@@ -171,6 +172,9 @@ static void handle_crash(int sig) {
}
print_error("-- END OF BACKTRACE --");
print_error("================================================================");
+ print_error(ScriptServer::get_current_script_backtrace());
+ print_error("-- END OF SCRIPT BACKTRACE --");
+ print_error("================================================================");
// Abort to pass the error to the OS
abort(); |
|
How does the new function relate to the existing |
|
In addition to what RedMser asked, how does this relate to #87576 ? |
|
Did a quick test script with a function that is recursively called 500 times inside a for loop. To my surprise, this branch is 5% faster than master. (Pushing the call stack beyond a depth of 506 or 507 will SIGSEGV, but that happens in master too.) |
|
Can |
|
@dalexeev I honestly don't see a lot of use for this, since the main use case is to print it, but I think adding another function |
bb26553 to
bcfa1bd
Compare
* GDScript call stack as reverse linked list with issues fixed (originally proposed in godotengineGH-91006). * This makes it fast enough to leave it enabled all the time, so this also drops "debug/settings/gdscript/always_track_call_stacks" setting. * Fix coroutine issues with call stack by resuming async call chain inside `GDScriptFunction::call()`. * This fixes corrupted line numbers for coroutines in the debugger and backtrace (godotengineGH-106758). Co-authored-by: Juan Linietsky <[email protected]>
* GDScript call stack as reverse linked list with issues fixed (originally proposed in godotengineGH-91006). * This makes it fast enough to leave it enabled all the time, so this also drops "debug/settings/gdscript/always_track_call_stacks" setting. * Fix coroutine issues with call stack by resuming async call chain inside `GDScriptFunction::call()`. * This fixes corrupted line numbers for coroutines in the debugger and backtrace (godotengineGH-106489). Co-authored-by: Juan Linietsky <[email protected]>
* GDScript call stack as reverse linked list with issues fixed (originally proposed in godotengineGH-91006). * Fix coroutine issues with call stack by resuming async call chain inside `GDScriptFunction::call()`. * This fixes corrupted line numbers for coroutines in the debugger and backtrace (godotengineGH-106489). Co-authored-by: Juan Linietsky <[email protected]>
* GDScript call stack as reverse linked list with issues fixed (originally proposed in godotengineGH-91006). * Fix coroutine issues with call stack by resuming async call chain inside `GDScriptFunction::call()`. * This fixes corrupted line numbers for coroutines in the debugger and backtrace (godotengineGH-106489). Co-authored-by: Juan Linietsky <[email protected]>
* GDScript call stack as reverse linked list with issues fixed (originally proposed in godotengineGH-91006). * Fix coroutine issues with call stack by resuming async call chain inside `GDScriptFunction::call()`. * This fixes corrupted line numbers for coroutines in the debugger and backtrace (godotengineGH-106489). Co-authored-by: Juan Linietsky <[email protected]>
* GDScript call stack as reverse linked list with issues fixed (originally proposed in godotengineGH-91006). * Fix coroutine issues with call stack by resuming async call chain inside `GDScriptFunction::call()`. * This fixes corrupted line numbers for coroutines in the debugger and backtrace (godotengineGH-106489). Co-authored-by: Juan Linietsky <[email protected]>
* GDScript call stack as reverse linked list with issues fixed (originally proposed in godotengineGH-91006). * Fix coroutine issues with call stack by resuming async call chain inside `GDScriptFunction::call()`. * This fixes corrupted line numbers for coroutines in the debugger and backtrace (godotengineGH-106489). Co-authored-by: Juan Linietsky <[email protected]>
Logger and ability to print and log script backtraces
|
Ok, I see that this is powerful tool to get a detailed bug reports from real players. As I understend, the final realisation of script_backtrace() is game developer's deal. But on exemple screenshots of the use of the presented tool I see resource addresses and function names, and I have one little question: is it safe? I mean... To protect the game from being hacked and cheated, encryption is a common solution in Godot (otherwise the game is very easy to edit). Couldn't it possibly create a hole for hacking even an encrypted application? |
The functionality introduced in this PR needs to be explicitly enabled in release builds. It is normally only available in debug builds. Variable and function names are not normally obfuscated in GDScript, mainly because it is a dynamic language and it still relies heavily on strings. For example, an Object's script can change at any time, signals can be added for any given object with
Regardless of encryption, Godot games are notoriously easy to decompile. This is not something new, and it's not something that this PR affects. Encryption only really blocks the common user. |
To be more specific, you would need to enable the |
As I know, GDRETool still require to insert an encryption key if project were encrypted. And my cheat-forums research shows that players still (likely for me :D) have problems with hacking godot games. Becouse of GDScript dinamical structure (as you mentioned allready) common strong tools became unsuitable. So the question of safity is quite relevant to this topic. |
How it looks:
using script_backtrace()
Results in the following output:
Logger
Backtraces are now added to the loggers. Here is how it looks for ANSI/Windows console loggers: