X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2Fdebug.cpp;h=3a6f9018feb3926549c5af73e125c406b6279d7f;hb=3f59d7e2cc6a3f9a09631c804b49b6d28e05d857;hp=11dd243e1ae0deecb1cac5f372d28610f5f1196f;hpb=0a48051f27e88ac7477ca5f3752c5ac2e6bf992a;p=lyx.git diff --git a/src/support/debug.cpp b/src/support/debug.cpp index 11dd243e1a..3a6f9018fe 100644 --- a/src/support/debug.cpp +++ b/src/support/debug.cpp @@ -14,22 +14,15 @@ #include "support/convert.h" #include "support/debug.h" +#include "support/FileName.h" #include "support/gettext.h" #include "support/lstrings.h" -#include "support/FileName.h" #include "support/ProgressInterface.h" +#include "support/regex.h" #include #include -//#define LYX_CALLSTACK_PRINTING -#ifdef LYX_CALLSTACK_PRINTING -#include -#include -#include -#endif - - using namespace std; using namespace lyx::support; @@ -205,13 +198,29 @@ void LyXErr::endl() } +char const * LyXErr::stripName(char const * n) +{ + string const name = n; + // find the last occurence of /src/ in name + static regex re("[\\/]src[\\/]"); + string::const_iterator const begin = name.begin(); + string::const_iterator it = begin; + string::const_iterator const end = name.end(); + smatch results; + while (regex_search(it, end, results, re)) { + it = results[0].second; + } + return n + std::distance(begin, it); +} + + // It seems not possible to instantiate operator template out of class body template LyXErr & toStream(LyXErr & l, T t) { if (l.enabled()){ l.stream() << t; - if (l.secondEnabled()) { + if (l.secondEnabled()) { l.secondStream() << t; ProgressInterface::instance()->lyxerrFlush(); } @@ -252,22 +261,5 @@ LyXErr & operator<<(LyXErr & l, ios_base &(*t)(ios_base &)) LyXErr lyxerr; -void Debug::printCallStack() -{ -#ifdef LYX_CALLSTACK_PRINTING - const int depth = 50; - - // get void*'s for all entries on the stack - void* array[depth]; - size_t size = backtrace(array, depth); - - char** messages = backtrace_symbols(array, size); - - for (size_t i = 0; i < size && messages != NULL; i++) { - fprintf(stderr, "[LyX's bt]: (%d) %s\n", i, messages[i]); - } -#endif -} - } // namespace lyx