mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: error: added printStack using std:: io
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
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)
|
void error::printStack(Ostream& os)
|
||||||
{
|
{
|
||||||
// Reads the starting addresses for the dynamically linked libraries
|
// Reads the starting addresses for the dynamically linked libraries
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -162,6 +162,10 @@ public:
|
|||||||
operator dictionary() const;
|
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
|
//- Helper function to print a stack
|
||||||
static void printStack(Ostream&);
|
static void printStack(Ostream&);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user