Go to the documentation of this file.
50 FILE *cmdPipe = popen(cmd.c_str(),
"r");
56 for (label cnt = 0; cnt <=
line; ++cnt)
59 ssize_t linelen = ::getline(&buf, &linecap, cmdPipe);
72 res.resize(res.size()-1);
94 os <<
"0x" <<
hex << uint64_t(addr);
96 os <<
"0x" <<
hex << addr;
104 s.replace(
cwd() +
'/',
"");
105 s.replace(
home(),
"~");
118 uintptr_t address = uintptr_t(addr);
126 if (filename.
hasExt(
"so"))
130 uintptr_t offset = uintptr_t(info->dli_fbase);
131 intptr_t relativeAddress = address - offset;
135 if (filename[0] ==
'/')
139 "addr2line -f --demangle=auto --exe "
148 os <<
" addr2line failed";
150 else if (
line ==
"??:0")
167 if (fname[0] !=
'/' && fname[0] !=
'~')
169 string tmp =
pOpen(
"which " + fname);
171 if (
tmp[0] ==
'/' ||
tmp[0] ==
'~')
184 char* cxx_sname = abi::__cxa_demangle
192 if (st == 0 && cxx_sname)
194 word demangled(cxx_sname);
215 size_t size = backtrace(array, 100);
216 char **strings = backtrace_symbols(array, size);
220 for (
size_t i = 0; i < size; ++i)
222 string msg(strings[i]);
223 fileName programFile;
226 os <<
'#' << label(i) <<
'\t' << msg <<
std::endl;
234 const size_t CALLSTACK_SIZE = 128;
236 void *callstack[CALLSTACK_SIZE];
237 size_t size = backtrace(callstack, CALLSTACK_SIZE);
239 Dl_info *info =
new Dl_info;
241 fileName fname =
"???";
244 for (
size_t i=0; i<size; ++i)
246 int st = dladdr(callstack[i], info);
248 os <<
'#' << label(i) <<
" ";
249 if (st != 0 && info->dli_fname !=
nullptr && info->dli_fname[0] !=
'\0')
255 (info->dli_sname !=
nullptr)
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
static void printStack(Ostream &os)
Helper function to print a stack.
A class for handling words, derived from Foam::string.
A class for handling file names.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A class for managing temporary objects.
word demangleSymbol(const char *sn)
Input/output from string buffers.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A class for handling character strings derived from std::string.
word addressToWord(const uintptr_t addr)
bool hasExt() const
Return true if it has an extension or simply ends with a '.'.
IOstream & hex(IOstream &io)
Foam::string str() const
Get the string - as Foam::string rather than std::string.
fileName home()
Return home directory path name for the current user.
Output to string buffer, using a OSstream.
string pOpen(const string &cmd, label line=0)
fileName cwd()
The physical or logical current working directory path name.
void printSourceFileAndLine(Ostream &os, const fileName &filename, Dl_info *info, void *addr)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
fileName absolutePath(const char *fn)
static void safePrintStack(std::ostream &os)
string & shorterPath(string &s)