Fix Windows compilation issues
authorIgor Kulaychuk <i.kulaychuk@samsung.com>
Wed, 22 Aug 2018 15:58:10 +0000 (18:58 +0300)
committerIgor Kulaychuk <i.kulaychuk@samsung.com>
Fri, 24 Aug 2018 15:36:22 +0000 (18:36 +0300)
src/debug/netcoredbg/debugger.h
src/debug/netcoredbg/frames.cpp
src/debug/netcoredbg/manageddebugger.cpp
src/debug/netcoredbg/miprotocol.h
src/debug/netcoredbg/symbolreader.cpp
src/debug/netcoredbg/symbolreader.h

index b5b2a01..064e91a 100644 (file)
@@ -8,7 +8,11 @@
 #include <vector>
 
 // For `HRESULT` definition
+#ifdef FEATURE_PAL
 #include <pal_mstypes.h>
+#else
+#include <windows.h>
+#endif
 
 #include "protocol.h"
 
index 7b3c11e..e745d76 100644 (file)
@@ -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 <windows.h> header file
+// to avoid compile error for std::numeric_limits<uint64_t>::max().
+#define NOMINMAX
+#endif
+
 #include "frames.h"
 
 #include <sstream>
index 757fdfc..cbfa348 100644 (file)
@@ -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)
index b6789d1..17ace81 100644 (file)
@@ -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:
 
index 1776a23..da9d20d 100644 (file)
@@ -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)
     {
index d401937..fdf4b0d 100644 (file)
@@ -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()
     {