Skip to content

Commit f0e7ebc

Browse files
committed
add backtrace on linux,macos through backward-cpp
1 parent 510c61a commit f0e7ebc

File tree

3 files changed

+4514
-0
lines changed

3 files changed

+4514
-0
lines changed

Source/System/RTEError.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,23 @@
3030
#include <sys/utsname.h>
3131
#include <fstream>
3232
#include <filesystem>
33+
#include "backward/backward.hpp"
3334
#elif defined(__APPLE__) && defined(__MACH__)
3435
#include <sys/sysctl.h>
36+
#include "backward/backward.hpp"
3537
#endif
3638

39+
3740
using namespace RTE;
3841

3942
bool RTEError::s_CurrentlyAborting = false;
4043
bool RTEError::s_IgnoreAllAsserts = false;
4144
std::string RTEError::s_LastIgnoredAssertDescription = "";
4245
std::source_location RTEError::s_LastIgnoredAssertLocation = {};
4346

47+
#if (defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)))
48+
backward::SignalHandling sh;
49+
#endif
4450
#ifdef _WIN32
4551
/// <summary>
4652
/// Custom exception handler for Windows SEH.
@@ -347,6 +353,13 @@ void RTEError::AbortFunc(const std::string& description, const std::source_locat
347353
#ifdef _WIN32
348354
RTEStackTrace stackTrace;
349355
callstack += ("\n\n" + stackTrace.GetCallStackAsString());
356+
#else
357+
backward::StackTrace st;
358+
st.load_here();
359+
backward::Printer printer;
360+
std::ostringstream stack;
361+
printer.print(st, stack);
362+
callstack = stack.str();
350363
#endif
351364

352365
std::string consoleSaveMsg;

0 commit comments

Comments
 (0)