Unconditionally enable stacktrace for windows builds

This also fixes an issue introduced 7d39205350
(duplicate variable name "levels".
This commit is contained in:
Robin Gareus 2021-07-13 13:47:26 +02:00
parent ab6d46c24c
commit 4651ec8382
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -70,13 +70,13 @@ PBD::stacktrace (std::ostream& out, int levels, int start)
free (strings); free (strings);
} }
} else { } else {
out << "no stacktrace available!" << std::endl; out << "No stacktrace available!" << std::endl;
} }
} }
#elif defined (PLATFORM_WINDOWS) #elif defined (PLATFORM_WINDOWS)
#if defined DEBUG && !defined CaptureStackBackTrace #if !defined CaptureStackBackTrace
#define CaptureStackBackTrace RtlCaptureStackBackTrace #define CaptureStackBackTrace RtlCaptureStackBackTrace
extern "C" { extern "C" {
@ -91,22 +91,20 @@ extern "C" {
void void
PBD::stacktrace (std::ostream& out, int levels, int start) PBD::stacktrace (std::ostream& out, int levels, int start)
{ {
#ifdef DEBUG
const size_t levels = 62; // does not support more then 62 levels of stacktrace
unsigned int i; unsigned int i;
void * stack[ levels ]; void * stack[62]; // does not support more then 62 levels of stacktrace
unsigned short frames; unsigned short frames;
SYMBOL_INFO * symbol; SYMBOL_INFO * symbol;
HANDLE process; HANDLE process;
process = GetCurrentProcess(); process = GetCurrentProcess();
out << "+++++Backtrace process: " << DEBUG_THREAD_SELF << std::endl; out << "Backtrace thread: " << DEBUG_THREAD_SELF << std::endl;
SymInitialize (process, NULL, TRUE); SymInitialize (process, NULL, TRUE);
frames = CaptureStackBackTrace (0, levels, stack, NULL); frames = CaptureStackBackTrace (0, 62, stack, NULL);
out << "+++++Backtrace frames: " << frames << 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->MaxNameLen = 255;
@ -120,21 +118,14 @@ PBD::stacktrace (std::ostream& out, int levels, int start)
out.flush (); out.flush ();
free (symbol); free (symbol);
#endif
} }
#else #else
void void
PBD::stacktrace (std::ostream& out, int /*levels*/) PBD::stacktrace (std::ostream& out, int, int)
{ {
out << "stack tracing is not enabled on this platform" << std::endl; out << "stack tracing is not enabled on this platform" << std::endl;
} }
#endif #endif
#if 0 // unused
extern "C" {
void c_stacktrace () { PBD::stacktrace (std::cout); }
}
#endif