From d481b3c5374668abae60d4ac06581244d6262f0e Mon Sep 17 00:00:00 2001 From: Igor Kulaychuk Date: Wed, 22 Aug 2018 18:58:10 +0300 Subject: [PATCH] Fix Windows compilation issues --- src/debug/netcoredbg/debugger.h | 4 ++++ src/debug/netcoredbg/frames.cpp | 6 ++++++ src/debug/netcoredbg/manageddebugger.cpp | 8 +++----- src/debug/netcoredbg/miprotocol.h | 4 ++++ src/debug/netcoredbg/symbolreader.cpp | 9 +++++++++ src/debug/netcoredbg/symbolreader.h | 11 +++++++++-- 6 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/debug/netcoredbg/debugger.h b/src/debug/netcoredbg/debugger.h index b5b2a01..064e91a 100644 --- a/src/debug/netcoredbg/debugger.h +++ b/src/debug/netcoredbg/debugger.h @@ -8,7 +8,11 @@ #include // For `HRESULT` definition +#ifdef FEATURE_PAL #include +#else +#include +#endif #include "protocol.h" diff --git a/src/debug/netcoredbg/frames.cpp b/src/debug/netcoredbg/frames.cpp index 7b3c11e..e745d76 100644 --- a/src/debug/netcoredbg/frames.cpp +++ b/src/debug/netcoredbg/frames.cpp @@ -2,6 +2,12 @@ // Distributed under the MIT License. // See the LICENSE file in the project root for more information. +#ifndef FEATURE_PAL +// Turn off macro definitions named max and min in header file +// to avoid compile error for std::numeric_limits::max(). +#define NOMINMAX +#endif + #include "frames.h" #include diff --git a/src/debug/netcoredbg/manageddebugger.cpp b/src/debug/netcoredbg/manageddebugger.cpp index 757fdfc..cbfa348 100644 --- a/src/debug/netcoredbg/manageddebugger.cpp +++ b/src/debug/netcoredbg/manageddebugger.cpp @@ -48,15 +48,13 @@ struct dbgshim_t return; std::string libName = exe.substr(0, dirSepIndex + 1); -#ifdef FEATURE_PAL -#if defined(__APPLE__) +#ifdef WIN32 + libName += "dbgshim.dll"; +#elif defined(__APPLE__) libName += "libdbgshim.dylib"; #else libName += "libdbgshim.so"; #endif -#else - libName += "dbgshim.dll"; -#endif m_module = DLOpen(libName); if (!m_module) diff --git a/src/debug/netcoredbg/miprotocol.h b/src/debug/netcoredbg/miprotocol.h index b6789d1..17ace81 100644 --- a/src/debug/netcoredbg/miprotocol.h +++ b/src/debug/netcoredbg/miprotocol.h @@ -26,7 +26,11 @@ class MIProtocol : public Protocol static std::string EscapeMIValue(const std::string &str); static HRESULT PrintBreakpoint(const Breakpoint &b, std::string &output); static void PrintVar(const std::string &varobjName, Variable &v, int threadId, int print_values, std::string &output); +#ifdef _MSC_VER + static void Printf(_Printf_format_string_ const char *fmt, ...); +#else static void Printf(const char *fmt, ...) __attribute__((format (printf, 1, 2))); +#endif public: diff --git a/src/debug/netcoredbg/symbolreader.cpp b/src/debug/netcoredbg/symbolreader.cpp index 1776a23..da9d20d 100644 --- a/src/debug/netcoredbg/symbolreader.cpp +++ b/src/debug/netcoredbg/symbolreader.cpp @@ -17,6 +17,7 @@ static const char *SymbolReaderDllName = "SymbolReader"; static const char *SymbolReaderClassName = "SOS.SymbolReader"; +#ifdef FEATURE_PAL // Suppress undefined reference // `_invalid_parameter(char16_t const*, char16_t const*, char16_t const*, unsigned int, unsigned long)': // /coreclr/src/pal/inc/rt/safecrt.h:386: undefined reference to `RaiseException' @@ -26,6 +27,7 @@ static void RaiseException(DWORD dwExceptionCode, CONST ULONG_PTR *lpArguments) { } +#endif std::string SymbolReader::coreClrPath; LoadSymbolsForModuleDelegate SymbolReader::loadSymbolsForModuleDelegate; @@ -155,10 +157,17 @@ HRESULT SymbolReader::PrepareSymbolReader() return E_FAIL; } +#ifdef FEATURE_PAL sysAllocStringLen = (SysAllocStringLen_t)DLSym(coreclrLib, "SysAllocStringLen"); sysFreeString = (SysFreeString_t)DLSym(coreclrLib, "SysFreeString"); sysStringLen = (SysStringLen_t)DLSym(coreclrLib, "SysStringLen"); coTaskMemFree = (CoTaskMemFree_t)DLSym(coreclrLib, "CoTaskMemFree"); +#else + sysAllocStringLen = SysAllocStringLen; + sysFreeString = SysFreeString; + sysStringLen = SysStringLen; + coTaskMemFree = CoTaskMemFree; +#endif if (sysAllocStringLen == nullptr) { diff --git a/src/debug/netcoredbg/symbolreader.h b/src/debug/netcoredbg/symbolreader.h index d401937..fdf4b0d 100644 --- a/src/debug/netcoredbg/symbolreader.h +++ b/src/debug/netcoredbg/symbolreader.h @@ -65,13 +65,20 @@ private: public: static const int HiddenLine; - struct __attribute__((packed)) SequencePoint { + +#ifdef _MSC_VER +#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) ) +#else +#define PACK( __Declaration__ ) __Declaration__ __attribute__((packed)) +#endif + + PACK(struct SequencePoint { int32_t startLine; int32_t startColumn; int32_t endLine; int32_t endColumn; int32_t offset; - }; + }); SymbolReader() { -- 2.7.4