Further Windows fixes.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-08-18 19:15:00 +02:00
parent 16b083d927
commit 5eb95805f6
4 changed files with 21 additions and 16 deletions

View File

@@ -25,7 +25,7 @@ namespace ArbUt {
inline reference At(size_t index) {
#ifndef NO_ASSERT
if (index >= _vector.size() || index < 0) {
if (index >= _vector.size()) {
std::stringstream ss;
ss << "Index " << index << " is out of bounds.";
throw ArbUt::Exception(ss.str());

View File

@@ -4,7 +4,6 @@
#define BACKWARD_HAS_DW 1
#endif
#include "../extern/backward.hpp"
#include "Exception.hpp"
// Sourced from https://github.com/bombela/backward-cpp/blob/master/backward.hpp#L3849
@@ -126,6 +125,8 @@ namespace ArbUt {
#endif
}
void SetCallback(void (*callback)(const char*)) { _callback = callback; }
private:
backward::details::handle<char*> _stack_content;
bool _loaded;
@@ -153,7 +154,7 @@ namespace ArbUt {
class SignalHandling {
public:
SignalHandling(const std::vector<int>& = std::vector<int>())
SignalHandling(void(callback)(const char*) = nullptr, const std::vector<int>& = std::vector<int>())
: reporter_thread_([]() {
/* We handle crashes in a utility thread:
backward structures and some Windows functions called here
@@ -177,12 +178,13 @@ namespace ArbUt {
cv().notify_one();
}) {
SetUnhandledExceptionFilter(crash_handler);
_callback = callback;
signal(SIGABRT, signal_handler);
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
set_terminate(&terminator);
set_unexpected(&terminator);
std::set_terminate(&terminator);
std::set_unexpected(&terminator);
_set_purecall_handler(&terminator);
_set_invalid_parameter_handler(&invalid_parameter_handler);
}
@@ -199,7 +201,11 @@ namespace ArbUt {
reporter_thread_.join();
}
void SetCallback(void (*callback)(const char*)) { _callback = callback; }
private:
static void (*_callback)(const char*);
static CONTEXT* ctx() {
static CONTEXT data;
return &data;
@@ -302,9 +308,9 @@ namespace ArbUt {
// macros.
// StackTrace also requires that the PDBs are already loaded, which is done
// in the constructor of TraceResolver
Printer printer;
backward::Printer printer;
StackTrace st;
backward::StackTrace st;
st.set_machine_type(printer.resolver().machine_type());
st.set_context(ctx());
st.set_thread_handle(thread_handle());