Skip to content
Snippets Groups Projects
Commit 3baf5d97 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Merge branch 'feature/silent-backtrace' into 'develop'

Remove automatic backtrace display on failure

See merge request !115
parents add70397 e423f7fd
No related branches found
No related tags found
1 merge request!115Remove automatic backtrace display on failure
......@@ -8,6 +8,14 @@
#include <rang.hpp>
#include <regex>
bool BacktraceManager::s_show = false;
void
BacktraceManager::setShow(bool show_backtrace)
{
s_show = show_backtrace;
}
BacktraceManager::BacktraceManager()
{
const int size = 100;
......@@ -26,6 +34,7 @@ BacktraceManager::BacktraceManager()
std::ostream&
operator<<(std::ostream& os, const BacktraceManager& btm)
{
if (BacktraceManager::s_show) {
const std::vector<std::string>& lines = btm.m_lines;
const std::regex mangled_function(R"%(\(.*\+)%");
......@@ -49,6 +58,10 @@ operator<<(std::ostream& os, const BacktraceManager& btm)
os << line << '\n';
}
}
} else {
os << rang::fg::yellow << "\n[To display backtrace launch pugs with the --backtrace option]" << rang::style::reset
<< '\n';
}
return os;
}
......@@ -7,9 +7,12 @@
class BacktraceManager
{
private:
static bool s_show;
std::vector<std::string> m_lines;
public:
static void setShow(bool show_backtrace);
BacktraceManager();
friend std::ostream& operator<<(std::ostream& os, const BacktraceManager& btm);
......
#include <utils/PugsUtils.hpp>
#include <utils/BacktraceManager.hpp>
#include <utils/BuildInfo.hpp>
#include <utils/ConsoleManager.hpp>
#include <utils/FPEManager.hpp>
......@@ -104,6 +105,9 @@ initialize(int& argc, char* argv[])
app.add_flag("--fpe,!--no-fpe", enable_fpe, "Trap floating point exceptions [default: true]");
bool show_backtrace = false;
app.add_flag("-b,--backtrace,!--no-backtrace", show_backtrace, "Show backtrace on failure [default: false]");
app.add_flag("--signal,!--no-signal", enable_signals, "Catches signals [default: true]");
bool pause_on_error = false;
......@@ -118,6 +122,7 @@ initialize(int& argc, char* argv[])
std::exit(app.exit(e, std::cout, std::cerr));
}
BacktraceManager::setShow(show_backtrace);
ConsoleManager::init(enable_color);
SignalManager::setPauseForDebug(pause_on_error);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment