diff --git a/platform/linuxbsd/crash_handler_linuxbsd.cpp b/platform/linuxbsd/crash_handler_linuxbsd.cpp index d35e2f994d1..7258659c003 100644 --- a/platform/linuxbsd/crash_handler_linuxbsd.cpp +++ b/platform/linuxbsd/crash_handler_linuxbsd.cpp @@ -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> script_backtraces; + if (ScriptServer::are_languages_initialized()) { + script_backtraces = ScriptServer::capture_script_backtraces(false); + } + if (!script_backtraces.is_empty()) { + for (const Ref &backtrace : script_backtraces) { + print_error(backtrace->format()); + } + print_error("-- END OF SCRIPT BACKTRACE --"); + print_error("================================================================"); + } + // Abort to pass the error to the OS abort(); } diff --git a/platform/macos/crash_handler_macos.mm b/platform/macos/crash_handler_macos.mm index 65b3cce5e59..82b8a56bb32 100644 --- a/platform/macos/crash_handler_macos.mm +++ b/platform/macos/crash_handler_macos.mm @@ -31,6 +31,7 @@ #import "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" @@ -177,6 +178,18 @@ static void handle_crash(int sig) { print_error("-- END OF BACKTRACE --"); print_error("================================================================"); + Vector> script_backtraces; + if (ScriptServer::are_languages_initialized()) { + script_backtraces = ScriptServer::capture_script_backtraces(false); + } + if (!script_backtraces.is_empty()) { + for (const Ref &backtrace : script_backtraces) { + print_error(backtrace->format()); + } + print_error("-- END OF SCRIPT BACKTRACE --"); + print_error("================================================================"); + } + // Abort to pass the error to the OS abort(); } diff --git a/platform/windows/crash_handler_windows_seh.cpp b/platform/windows/crash_handler_windows_seh.cpp index 288354ee374..af93786e6d3 100644 --- a/platform/windows/crash_handler_windows_seh.cpp +++ b/platform/windows/crash_handler_windows_seh.cpp @@ -31,6 +31,7 @@ #include "crash_handler_windows.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" @@ -230,6 +231,18 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) { SymCleanup(process); + Vector> script_backtraces; + if (ScriptServer::are_languages_initialized()) { + script_backtraces = ScriptServer::capture_script_backtraces(false); + } + if (!script_backtraces.is_empty()) { + for (const Ref &backtrace : script_backtraces) { + print_error(backtrace->format()); + } + print_error("-- END OF SCRIPT BACKTRACE --"); + print_error("================================================================"); + } + // Pass the exception to the OS return EXCEPTION_CONTINUE_SEARCH; } diff --git a/platform/windows/crash_handler_windows_signal.cpp b/platform/windows/crash_handler_windows_signal.cpp index 663848d0347..dbc4edbedc2 100644 --- a/platform/windows/crash_handler_windows_signal.cpp +++ b/platform/windows/crash_handler_windows_signal.cpp @@ -31,6 +31,7 @@ #include "crash_handler_windows.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" @@ -183,6 +184,18 @@ extern void CrashHandlerException(int signal) { print_error("-- END OF BACKTRACE --"); print_error("================================================================"); + + Vector> script_backtraces; + if (ScriptServer::are_languages_initialized()) { + script_backtraces = ScriptServer::capture_script_backtraces(false); + } + if (!script_backtraces.is_empty()) { + for (const Ref &backtrace : script_backtraces) { + print_error(backtrace->format()); + } + print_error("-- END OF SCRIPT BACKTRACE --"); + print_error("================================================================"); + } } #endif