From c92dfed70618714faef2da83abda39a205ae4baa Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 14 Jul 2021 16:04:07 +0200 Subject: [PATCH] Fix windows builds (stacktrace pthread debug) --- libs/pbd/pbd/debug.h | 7 +++++-- libs/pbd/stacktrace.cc | 9 ++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libs/pbd/pbd/debug.h b/libs/pbd/pbd/debug.h index 9417eefef8..abb2863afd 100644 --- a/libs/pbd/pbd/debug.h +++ b/libs/pbd/pbd/debug.h @@ -30,8 +30,11 @@ #include "pbd/libpbd_visibility.h" #include "pbd/timing.h" -#if defined(COMPILER_MSVC) && !defined(PTW32_VERSION) -#include // Gets us 'PTW32_VERSION' +/* check for PTW32_VERSION */ +#ifdef COMPILER_MSVC +#include +#else +#include #endif namespace PBD { diff --git a/libs/pbd/stacktrace.cc b/libs/pbd/stacktrace.cc index 29f8074a9c..80912cdfda 100644 --- a/libs/pbd/stacktrace.cc +++ b/libs/pbd/stacktrace.cc @@ -91,10 +91,9 @@ extern "C" { void PBD::stacktrace (std::ostream& out, int levels, int start) { - unsigned int i; - void * stack[62]; // does not support more then 62 levels of stacktrace + void* stack[62]; // does not support more then 62 levels of stacktrace unsigned short frames; - SYMBOL_INFO * symbol; + SYMBOL_INFO* symbol; HANDLE process; process = GetCurrentProcess(); @@ -104,13 +103,13 @@ PBD::stacktrace (std::ostream& out, int levels, int start) frames = CaptureStackBackTrace (0, 62, stack, NULL); - out << "Backtrace frames: " << frames << std::endl; + out << "Backtrace frames: " << (int) frames << std::endl; symbol = (SYMBOL_INFO*)calloc (sizeof (SYMBOL_INFO) + 256 * sizeof (char), 1); symbol->MaxNameLen = 255; symbol->SizeOfStruct = sizeof (SYMBOL_INFO); - for (i = start; i < frames && (levels == 0 || i < levels); ++i) { + for (int i = start; i < frames && (levels == 0 || i < levels); ++i) { SymFromAddr (process, (DWORD64)(stack[i]), 0, symbol); out << string_compose (" %1: %2 - %3\n", frames - i - 1, symbol->Name, symbol->Address); }