NO-OP: whitespace & revert samples -> [stack]frames
This commit is contained in:
parent
eeb2cddd26
commit
e4f18c1771
@ -45,71 +45,71 @@ namespace PBD {
|
||||
template<typename T>
|
||||
class /*LIBPBD_API*/ thing_with_backtrace
|
||||
{
|
||||
public:
|
||||
thing_with_backtrace () {
|
||||
trace_twb();
|
||||
public:
|
||||
thing_with_backtrace () {
|
||||
trace_twb();
|
||||
#ifdef HAVE_EXECINFO
|
||||
allocation_backtrace = new void*[50];
|
||||
allocation_backtrace_size = backtrace (allocation_backtrace, 50);
|
||||
allocation_backtrace = new void*[50];
|
||||
allocation_backtrace_size = backtrace (allocation_backtrace, 50);
|
||||
#else
|
||||
allocation_backtrace_size = 0;
|
||||
allocation_backtrace_size = 0;
|
||||
#endif
|
||||
Glib::Threads::Mutex::Lock lm (all_mutex);
|
||||
all.push_back (this);
|
||||
}
|
||||
Glib::Threads::Mutex::Lock lm (all_mutex);
|
||||
all.push_back (this);
|
||||
}
|
||||
|
||||
thing_with_backtrace (const thing_with_backtrace<T>& other) {
|
||||
trace_twb();
|
||||
thing_with_backtrace (const thing_with_backtrace<T>& other) {
|
||||
trace_twb();
|
||||
#ifdef HAVE_EXECINFO
|
||||
allocation_backtrace = new void*[50];
|
||||
allocation_backtrace_size = backtrace (allocation_backtrace, 50);
|
||||
allocation_backtrace = new void*[50];
|
||||
allocation_backtrace_size = backtrace (allocation_backtrace, 50);
|
||||
#else
|
||||
allocation_backtrace_size = 0;
|
||||
allocation_backtrace_size = 0;
|
||||
#endif
|
||||
Glib::Threads::Mutex::Lock lm (all_mutex);
|
||||
all.push_back (this);
|
||||
}
|
||||
Glib::Threads::Mutex::Lock lm (all_mutex);
|
||||
all.push_back (this);
|
||||
}
|
||||
|
||||
~thing_with_backtrace() {
|
||||
if (allocation_backtrace_size) {
|
||||
delete [] allocation_backtrace;
|
||||
}
|
||||
Glib::Threads::Mutex::Lock lm (all_mutex);
|
||||
all.remove (this);
|
||||
}
|
||||
~thing_with_backtrace() {
|
||||
if (allocation_backtrace_size) {
|
||||
delete [] allocation_backtrace;
|
||||
}
|
||||
Glib::Threads::Mutex::Lock lm (all_mutex);
|
||||
all.remove (this);
|
||||
}
|
||||
|
||||
thing_with_backtrace<T>& operator= (const thing_with_backtrace<T>& other) {
|
||||
/* no copyable members */
|
||||
return *this;
|
||||
}
|
||||
thing_with_backtrace<T>& operator= (const thing_with_backtrace<T>& other) {
|
||||
/* no copyable members */
|
||||
return *this;
|
||||
}
|
||||
|
||||
static void peek_a_boo (std::ostream& stream) {
|
||||
static void peek_a_boo (std::ostream& stream) {
|
||||
#ifdef HAVE_EXECINFO
|
||||
typename std::list<thing_with_backtrace<T>*>::iterator x;
|
||||
for (x = all.begin(); x != all.end(); ++x) {
|
||||
char **strings;
|
||||
size_t i;
|
||||
typename std::list<thing_with_backtrace<T>*>::iterator x;
|
||||
for (x = all.begin(); x != all.end(); ++x) {
|
||||
char **strings;
|
||||
size_t i;
|
||||
|
||||
strings = backtrace_symbols ((*x)->allocation_backtrace, (*x)->allocation_backtrace_size);
|
||||
strings = backtrace_symbols ((*x)->allocation_backtrace, (*x)->allocation_backtrace_size);
|
||||
|
||||
if (strings) {
|
||||
stream << "--- ALLOCATED SHARED_PTR @ " << (*x) << std::endl;
|
||||
for (i = 0; i < (*x)->allocation_backtrace_size && i < 50U; i++) {
|
||||
stream << strings[i] << std::endl;
|
||||
}
|
||||
free (strings);
|
||||
}
|
||||
}
|
||||
if (strings) {
|
||||
stream << "--- ALLOCATED SHARED_PTR @ " << (*x) << std::endl;
|
||||
for (i = 0; i < (*x)->allocation_backtrace_size && i < 50U; i++) {
|
||||
stream << strings[i] << std::endl;
|
||||
}
|
||||
free (strings);
|
||||
}
|
||||
}
|
||||
#else
|
||||
stream << "execinfo not defined for this platform" << std::endl;
|
||||
stream << "execinfo not defined for this platform" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void** allocation_backtrace;
|
||||
int allocation_backtrace_size;
|
||||
static std::list<thing_with_backtrace<T>* > all;
|
||||
static Glib::Threads::Mutex all_mutex;
|
||||
void** allocation_backtrace;
|
||||
int allocation_backtrace_size;
|
||||
static std::list<thing_with_backtrace<T>* > all;
|
||||
static Glib::Threads::Mutex all_mutex;
|
||||
};
|
||||
|
||||
template<typename T> /*LIBPBD_API*/ std::list<PBD::thing_with_backtrace<T> *> PBD::thing_with_backtrace<T>::all;
|
||||
|
@ -77,48 +77,46 @@ PBD::stacktrace (std::ostream& out, int levels)
|
||||
#define CaptureStackBackTrace RtlCaptureStackBackTrace
|
||||
|
||||
extern "C" {
|
||||
__declspec(dllimport) USHORT WINAPI CaptureStackBackTrace (
|
||||
ULONG SamplesToSkip,
|
||||
ULONG SamplesToCapture,
|
||||
PVOID *BackTrace,
|
||||
PULONG BackTraceHash
|
||||
);
|
||||
__declspec(dllimport) USHORT WINAPI CaptureStackBackTrace (
|
||||
ULONG FramesToSkip,
|
||||
ULONG FramesToCapture,
|
||||
PVOID *BackTrace,
|
||||
PULONG BackTraceHash);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
PBD::stacktrace( std::ostream& out, int)
|
||||
PBD::stacktrace (std::ostream& out, int)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
const size_t levels = 62; // does not support more then 62 levels of stacktrace
|
||||
unsigned int i;
|
||||
void * stack[ levels ];
|
||||
unsigned short samples;
|
||||
unsigned short frames;
|
||||
SYMBOL_INFO * symbol;
|
||||
HANDLE process;
|
||||
|
||||
process = GetCurrentProcess();
|
||||
out << "+++++Backtrace process: " << DEBUG_THREAD_SELF << std::endl;
|
||||
|
||||
SymInitialize( process, NULL, TRUE );
|
||||
SymInitialize (process, NULL, TRUE);
|
||||
|
||||
samples = CaptureStackBackTrace( 0, levels, stack, NULL );
|
||||
frames = CaptureStackBackTrace (0, levels, stack, NULL);
|
||||
|
||||
out << "+++++Backtrace samples: " << samples << std::endl;
|
||||
out << "+++++Backtrace frames: " << frames << std::endl;
|
||||
|
||||
symbol = ( SYMBOL_INFO * )calloc( sizeof( SYMBOL_INFO ) + 256 * sizeof( char ), 1 );
|
||||
symbol = (SYMBOL_INFO*)calloc (sizeof (SYMBOL_INFO) + 256 * sizeof (char), 1);
|
||||
symbol->MaxNameLen = 255;
|
||||
symbol->SizeOfStruct = sizeof( SYMBOL_INFO );
|
||||
symbol->SizeOfStruct = sizeof (SYMBOL_INFO);
|
||||
|
||||
for( i = 0; i < samples; i++ )
|
||||
{
|
||||
SymFromAddr( process, ( DWORD64 )( stack[ i ] ), 0, symbol );
|
||||
out << string_compose( "%1: %2 - %3\n", samples - i - 1, symbol->Name, symbol->Address );
|
||||
for (i = 0; i < frames; ++i) {
|
||||
SymFromAddr (process, (DWORD64)(stack[i]), 0, symbol);
|
||||
out << string_compose ("%1: %2 - %3\n", samples - i - 1, symbol->Name, symbol->Address);
|
||||
}
|
||||
|
||||
out.flush();
|
||||
out.flush ();
|
||||
|
||||
free( symbol );
|
||||
free (symbol);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user