Skip to content
Snippets Groups Projects
Commit 7df06083 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

STYLE: inline shorterPath function for printStack

parent d318a630
Branches
Tags
No related merge requests found
......@@ -50,7 +50,7 @@ string pOpen(const string& cmd, label line=0)
char *buf = nullptr;
// Read line number of lines
for (label cnt = 0; cnt <= line; cnt++)
for (label cnt = 0; cnt <= line; ++cnt)
{
size_t linecap = 0;
ssize_t linelen = ::getline(&buf, &linecap, cmdPipe);
......@@ -96,6 +96,14 @@ inline word addressToWord(const uintptr_t addr)
}
inline string& shorterPath(string& s)
{
s.replace(cwd() + '/', "");
s.replace(home(), "~");
return s;
}
void printSourceFileAndLine
(
Ostream& os,
......@@ -132,14 +140,12 @@ void printSourceFileAndLine
}
else if (line == "??:0")
{
os << " in " << filename;
line = filename;
os << " in " << shorterPath(line).c_str();
}
else
{
string cwdLine(line.replaceAll(cwd() + '/', ""));
string homeLine(cwdLine.replaceAll(home(), "~"));
os << " at " << homeLine.c_str();
os << " at " << shorterPath(line).c_str();
}
}
}
......@@ -202,7 +208,7 @@ void Foam::error::safePrintStack(std::ostream& os)
// 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++)
for (size_t i = 0; i < size; ++i)
{
string msg(strings[i]);
fileName programFile;
......@@ -226,7 +232,7 @@ void Foam::error::printStack(Ostream& os)
fileName fname = "???";
word address;
for(size_t i=0; i<size; i++)
for (size_t i=0; i<size; ++i)
{
int st = dladdr(callstack[i], info);
......
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