Added dump methods to stacktrace
This commit is contained in:
parent
fcc1642cad
commit
18612a3063
@ -58,17 +58,18 @@ public:
|
||||
return lines.size();
|
||||
}
|
||||
|
||||
void dump(std::ostream& stream) {
|
||||
std::string message;
|
||||
dump(message);
|
||||
stream << message;
|
||||
template <class Stream>
|
||||
void dump(Stream& stream) {
|
||||
stream << dump();
|
||||
}
|
||||
|
||||
void dump(std::string& message) {
|
||||
std::string dump() {
|
||||
std::string message;
|
||||
for (int i = 0; i < size(); i++) {
|
||||
message.append(fmt::format("at {} ({}) \n", lines[i].function,
|
||||
lines[i].location));
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -22,8 +22,7 @@ static constexpr const char* port = "7687";
|
||||
|
||||
void throw_and_stacktace(std::string message) {
|
||||
Stacktrace stacktrace;
|
||||
stacktrace.dump(message);
|
||||
logger.info(message);
|
||||
logger.info(stacktrace.dump());
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
|
@ -12,11 +12,7 @@ TEST_CASE("SignalHandler Segmentation Fault Test") {
|
||||
SignalHandler::register_handler(Signal::SegmentationFault, []() {
|
||||
std::cout << "Segmentation Fault" << std::endl;
|
||||
Stacktrace stacktrace;
|
||||
|
||||
std::string message;
|
||||
stacktrace.dump(message);
|
||||
std::cout << message << std::endl;
|
||||
|
||||
std::cout << stacktrace.dump() << std::endl;
|
||||
});
|
||||
|
||||
std::raise(SIGSEGV);
|
||||
|
Loading…
Reference in New Issue
Block a user