Skip to content

Commit f2c4b8a

Browse files
author
yawzhang
committed
generate coredump file for easier debug
1 parent 3431e9e commit f2c4b8a

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class SISLConan(ConanFile):
1111
name = "sisl"
12-
version = "12.4.4"
12+
version = "12.4.5"
1313

1414
homepage = "https://github.com/eBay/sisl"
1515
description = "Library for fast data structures, utilities"

src/logging/stacktrace.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
#else
3838
#include "stacktrace_release.h"
3939
#endif
40+
#include <sisl/options/options.h>
41+
42+
43+
SISL_OPTION_GROUP(stacktrace,
44+
(enable_core_dump, "", "enable_core_dump", "Generate coredump file when crash", ::cxxopts::value<bool>(), ""))
4045

4146
namespace sisl {
4247
namespace logging {
@@ -81,11 +86,20 @@ static void exit_with_default_sighandler(const SignalType fatal_signal_id) {
8186
<< std::flush;
8287
}
8388

84-
//::kill(::getpid(), fatal_signal_id);
85-
if (fatal_signal_id == SIGABRT) {
86-
std::_Exit(fatal_signal_id);
89+
// If core dump file generation is enabled and the signal is one that generates a core dump, re-raise the signal
90+
const std::unordered_set<SignalType> core_dump_signals = {SIGABRT, SIGFPE, SIGSEGV, SIGILL};
91+
if (SISL_OPTIONS["enable_core_dump"].count() && core_dump_signals.count(fatal_signal_id) > 0) {
92+
std::cerr << "\n"
93+
<< __FUNCTION__ << ":" << __LINE__ << ". Raising signal "
94+
<< fatal_signal_id << " \n\n"
95+
<< std::flush;
96+
std::raise(fatal_signal_id);
8797
} else {
88-
std::exit(fatal_signal_id);
98+
if (fatal_signal_id == SIGABRT) {
99+
std::_Exit(fatal_signal_id);
100+
} else {
101+
std::exit(fatal_signal_id);
102+
}
89103
}
90104
}
91105

0 commit comments

Comments
 (0)