Print script backtrace in the crash handler.

This commit is contained in:
Pāvels Nadtočajevs 2025-04-25 09:15:20 +03:00
parent 28089c40c1
commit e61edcadb8
No known key found for this signature in database
GPG key ID: 8413210218EF35D2
4 changed files with 52 additions and 0 deletions

View file

@ -31,6 +31,7 @@
#include "crash_handler_linuxbsd.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"
@ -146,6 +147,18 @@ static void handle_crash(int sig) {
print_error("-- END OF BACKTRACE --");
print_error("================================================================");
Vector<Ref<ScriptBacktrace>> script_backtraces;
if (ScriptServer::are_languages_initialized()) {
script_backtraces = ScriptServer::capture_script_backtraces(false);
}
if (!script_backtraces.is_empty()) {
for (const Ref<ScriptBacktrace> &backtrace : script_backtraces) {
print_error(backtrace->format());
}
print_error("-- END OF SCRIPT BACKTRACE --");
print_error("================================================================");
}
// Abort to pass the error to the OS
abort();
}