Skip to content
Snippets Groups Projects
Commit 6de7a4e1 authored by Chris Cantwell's avatar Chris Cantwell
Browse files

Added option to disable backtrace in ErrorUtil.

parent 2995222f
No related branches found
No related tags found
No related merge requests found
Pipeline #675 passed
......@@ -46,6 +46,7 @@ int main(int argc, char *argv[])
// Set up a stringstream to catch any error output.
std::stringstream ss;
ErrorUtil::SetErrorStream(ss);
ErrorUtil::SetPrintBacktrace(false);
// Set up output that will be overwritten with exception error (any
// non-empty string).
......
......@@ -40,5 +40,6 @@ namespace Nektar {
// Defines default outstream in library.
std::ostream *ErrorUtil::m_outStream = &std::cerr;
bool ErrorUtil::m_printBacktrace = true;
}
......@@ -74,6 +74,11 @@ public:
m_outStream = &o;
}
inline static void SetPrintBacktrace(bool b)
{
m_printBacktrace = b;
}
inline static bool HasCustomErrorStream()
{
return m_outStream != &std::cerr;
......@@ -117,18 +122,21 @@ public:
std::string btMessage("");
#if defined(NEKTAR_FULLDEBUG)
#ifndef _WIN32
void *btArray[40];
int btSize;
char **btStrings;
if (m_printBacktrace)
{
void *btArray[40];
int btSize;
char **btStrings;
btSize = backtrace(btArray, 40);
btStrings = backtrace_symbols(btArray, btSize);
btSize = backtrace(btArray, 40);
btStrings = backtrace_symbols(btArray, btSize);
for (int i = 0 ; i < btSize ; ++i)
{
btMessage += std::string(btStrings[i]) + "\n";
for (int i = 0 ; i < btSize ; ++i)
{
btMessage += std::string(btStrings[i]) + "\n";
}
free(btStrings);
}
free(btStrings);
#endif
#endif
......@@ -137,7 +145,10 @@ public:
case efatal:
if (!rank)
{
(*m_outStream) << btMessage;
if (m_printBacktrace)
{
(*m_outStream) << btMessage;
}
(*m_outStream) << "Fatal : " << baseMsg << std::endl;
}
......@@ -155,7 +166,10 @@ public:
case ewarning:
if (!rank)
{
(*m_outStream) << btMessage;
if (m_printBacktrace)
{
(*m_outStream) << btMessage;
}
(*m_outStream) << "Warning: " << baseMsg << std::endl;
}
break;
......@@ -176,6 +190,7 @@ public:
private:
LIB_UTILITIES_EXPORT static std::ostream *m_outStream;
LIB_UTILITIES_EXPORT static bool m_printBacktrace;
};
/// Assert Level 0 -- Fundamental assert which
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment