mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
add debug function which prints the callstack to stderr, disabled by default
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38334 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
08e69e57bf
commit
0a48051f27
@ -22,6 +22,15 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
|
//#define LYX_CALLSTACK_PRINTING
|
||||||
|
#ifdef LYX_CALLSTACK_PRINTING
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <execinfo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace lyx::support;
|
using namespace lyx::support;
|
||||||
|
|
||||||
@ -242,4 +251,23 @@ LyXErr & operator<<(LyXErr & l, ios_base &(*t)(ios_base &))
|
|||||||
// The global instance
|
// The global instance
|
||||||
LyXErr lyxerr;
|
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
|
} // namespace lyx
|
||||||
|
@ -124,6 +124,9 @@ namespace Debug {
|
|||||||
/// Show all the possible tags that can be used for debugging
|
/// Show all the possible tags that can be used for debugging
|
||||||
void showTags(std::ostream & os);
|
void showTags(std::ostream & os);
|
||||||
|
|
||||||
|
/// Print simple callstack to stderr
|
||||||
|
void printCallStack();
|
||||||
|
|
||||||
} // namespace Debug
|
} // namespace Debug
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user