Skip to content
Snippets Groups Projects
Commit cf93009c authored by mattijs's avatar mattijs
Browse files

ENH: error: added printStack using std:: io

parent f280cd93
Branches
Tags
No related merge requests found
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -167,6 +167,26 @@ void getSymbolForRaw
}
void error::safePrintStack(std::ostream& os)
{
// Get raw stack symbols
void *array[100];
size_t size = backtrace(array, 100);
char **strings = backtrace_symbols(array, size);
// See if they contain function between () e.g. "(__libc_start_main+0xd0)"
// and see if cplus_demangle can make sense of part before +
for (size_t i = 0; i < size; i++)
{
string msg(strings[i]);
fileName programFile;
word address;
os << '#' << label(i) << '\t' << msg << std::endl;
}
}
void error::printStack(Ostream& os)
{
// Reads the starting addresses for the dynamically linked libraries
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -162,6 +162,10 @@ public:
operator dictionary() const;
//- Helper function to print a stack (if OpenFOAM IO not yet
// initialised)
static void safePrintStack(std::ostream&);
//- Helper function to print a stack
static void printStack(Ostream&);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment