Include backtrace in debug info in on_assert_failed
This commit is contained in:
parent
7245d2abe9
commit
e18c57cfd3
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "exception.hh"
|
#include "exception.hh"
|
||||||
#include "debug.hh"
|
#include "debug.hh"
|
||||||
|
#include "backtrace.hh"
|
||||||
|
|
||||||
#if defined(__CYGWIN__)
|
#if defined(__CYGWIN__)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -26,8 +27,10 @@ private:
|
||||||
|
|
||||||
void on_assert_failed(const char* message)
|
void on_assert_failed(const char* message)
|
||||||
{
|
{
|
||||||
String debug_info = format("pid: {}", getpid());
|
char* callstack = Backtrace{}.desc();
|
||||||
write_debug(format("assert failed: '{}' ", message, debug_info));
|
String debug_info = format("pid: {}\ncallstack:\n{}", getpid(), callstack);
|
||||||
|
free(callstack);
|
||||||
|
write_debug(format("assert failed: '{}'\n{}", message, debug_info));
|
||||||
|
|
||||||
const auto msg = format("{}\n[Debug Infos]\n{}", message, debug_info);
|
const auto msg = format("{}\n[Debug Infos]\n{}", message, debug_info);
|
||||||
#if defined(__CYGWIN__)
|
#if defined(__CYGWIN__)
|
||||||
|
|
|
@ -21,7 +21,7 @@ Backtrace::Backtrace()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Backtrace::desc() const
|
char* Backtrace::desc() const
|
||||||
{
|
{
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
char** symbols = backtrace_symbols(stackframes, num_frames);
|
char** symbols = backtrace_symbols(stackframes, num_frames);
|
||||||
|
|
|
@ -11,7 +11,7 @@ struct Backtrace
|
||||||
int num_frames = 0;
|
int num_frames = 0;
|
||||||
|
|
||||||
Backtrace();
|
Backtrace();
|
||||||
const char* desc() const;
|
char* desc() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user