eran.ifrah created this revision.
eran.ifrah added a reviewer: zturner.
eran.ifrah added a subscriber: lldb-commits.
Herald added subscribers: srhines, danalbert, tberghammer.
As the title
http://reviews.llvm.org/D18519
Files:
CMakeLists.txt
cmake/modules/AddLLDB.cmake
cmake/modules/LLDBConfig.cmake
include/lldb/Host/windows/win32.h
source/Host/common/File.cpp
source/Host/common/OptionParser.cpp
source/Host/windows/EditLineWin.cpp
source/Host/windows/FileSystem.cpp
source/Host/windows/ProcessRunLock.cpp
source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
source/Plugins/Process/Windows/Common/ProcessWindowsLog.h
source/Target/ProcessLaunchInfo.cpp
source/Utility/PseudoTerminal.cpp
tools/CMakeLists.txt
tools/argdumper/CMakeLists.txt
tools/driver/CMakeLists.txt
tools/driver/Driver.cpp
tools/lldb-server/lldb-gdbserver.cpp
tools/lldb-server/lldb-platform.cpp
tools/lldb-server/lldb-server.cpp
Index: tools/lldb-server/lldb-server.cpp
===================================================================
--- tools/lldb-server/lldb-server.cpp
+++ tools/lldb-server/lldb-server.cpp
@@ -63,15 +63,20 @@
switch (argv[1][0])
{
case 'g':
+#ifdef __MINGW32__
+ case 'p':
+#endif
initialize();
main_gdbserver(argc, argv);
terminate();
break;
+#ifndef __MINGW32__
case 'p':
initialize();
main_platform(argc, argv);
terminate();
break;
+#endif
case 'v':
fprintf(stderr, "%s\n", lldb_private::GetVersion());
break;
Index: tools/lldb-server/lldb-platform.cpp
===================================================================
--- tools/lldb-server/lldb-platform.cpp
+++ tools/lldb-server/lldb-platform.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#ifndef _WIN32
// C Includes
#include <errno.h>
#if defined(__APPLE__)
@@ -414,3 +415,4 @@
return 0;
}
+#endif // WIN32
Index: tools/lldb-server/lldb-gdbserver.cpp
===================================================================
--- tools/lldb-server/lldb-gdbserver.cpp
+++ tools/lldb-server/lldb-gdbserver.cpp
@@ -6,6 +6,9 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+#ifdef __MINGW32__
+#define _BSD_SOURCE
+#endif
// C Includes
#include <errno.h>
Index: tools/driver/Driver.cpp
===================================================================
--- tools/driver/Driver.cpp
+++ tools/driver/Driver.cpp
@@ -1299,7 +1299,7 @@
}
int
-#ifdef WIN32
+#if defined(WIN32) && !defined(__MINGW32__)
wmain(int argc, wchar_t const *wargv[])
#else
main(int argc, char const *argv[])
@@ -1311,7 +1311,7 @@
setvbuf(stdin , NULL, _IONBF, 0);
#endif
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__MINGW32__)
// Convert wide arguments to UTF-8
std::vector<std::string> argvStrings(argc);
std::vector<const char *> argvPointers(argc);
Index: tools/driver/CMakeLists.txt
===================================================================
--- tools/driver/CMakeLists.txt
+++ tools/driver/CMakeLists.txt
@@ -17,7 +17,14 @@
add_dependencies(lldb debugserver)
endif()
+if(MINGW)
+ # link directly against the dll file
+ add_dependencies(lldb liblldb)
+ target_link_libraries(lldb -L"${CMAKE_BINARY_DIR}/bin" -llldb)
+else()
target_link_libraries(lldb liblldb)
+endif()
+
# TODO: why isn't this done by add_lldb_executable?
#target_link_libraries(lldb ${LLDB_USED_LIBS})
#llvm_config(lldb ${LLVM_LINK_COMPONENTS})
Index: tools/argdumper/CMakeLists.txt
===================================================================
--- tools/argdumper/CMakeLists.txt
+++ tools/argdumper/CMakeLists.txt
@@ -2,7 +2,13 @@
argdumper.cpp
)
+if(MINGW)
+ # link directly against the dll file
+ add_dependencies(lldb-argdumper liblldb)
+ target_link_libraries(lldb-argdumper -L"${CMAKE_BINARY_DIR}/bin" -llldb)
+else()
target_link_libraries(lldb-argdumper liblldb)
+endif()
install(TARGETS lldb-argdumper
RUNTIME DESTINATION bin)
Index: tools/CMakeLists.txt
===================================================================
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -4,7 +4,7 @@
endif()
add_subdirectory(argdumper)
add_subdirectory(driver)
-if (NOT __ANDROID_NDK__)
+if (NOT __ANDROID_NDK__ AND NOT MINGW)
add_subdirectory(lldb-mi)
endif()
if (LLDB_CAN_USE_LLDB_SERVER)
Index: source/Utility/PseudoTerminal.cpp
===================================================================
--- source/Utility/PseudoTerminal.cpp
+++ source/Utility/PseudoTerminal.cpp
@@ -20,7 +20,9 @@
#ifdef _WIN32
#include "lldb/Host/windows/win32.h"
+#ifndef __MINGW32__
typedef uint32_t pid_t;
+#endif
// empty functions
int posix_openpt(int flag) { return 0; }
Index: source/Target/ProcessLaunchInfo.cpp
===================================================================
--- source/Target/ProcessLaunchInfo.cpp
+++ source/Target/ProcessLaunchInfo.cpp
@@ -366,7 +366,7 @@
__FUNCTION__);
int open_flags = O_RDWR | O_NOCTTY;
-#if !defined(_MSC_VER)
+#if !defined(_MSC_VER) && !defined(__MINGW32__)
// We really shouldn't be specifying platform specific flags
// that are intended for a system call in generic code. But
// this will have to do for now.
Index: source/Plugins/Process/Windows/Common/ProcessWindowsLog.h
===================================================================
--- source/Plugins/Process/Windows/Common/ProcessWindowsLog.h
+++ source/Plugins/Process/Windows/Common/ProcessWindowsLog.h
@@ -82,6 +82,7 @@
} \
}
+#ifndef __MINGW32__
#define WINLOG_IFANY(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::Any, Printf, __VA_ARGS__)
#define WINLOG_IFALL(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::All, Printf, __VA_ARGS__)
#define WINLOGV_IFANY(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::Any, Verbose, __VA_ARGS__)
@@ -92,5 +93,17 @@
#define WINERR_IFALL(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::All, Error, __VA_ARGS__)
#define WINWARN_IFANY(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::Any, Warning, __VA_ARGS__)
#define WINWARN_IFALL(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::All, Warning, __VA_ARGS__)
+#else
+#define WINLOG_IFANY(Flags, ...)
+#define WINLOG_IFALL(Flags, ...)
+#define WINLOGV_IFANY(Flags, ...)
+#define WINLOGV_IFALL(Flags, ...)
+#define WINLOGD_IFANY(Flags, ...)
+#define WINLOGD_IFALL(Flags, ...)
+#define WINERR_IFANY(Flags, ...)
+#define WINERR_IFALL(Flags, ...)
+#define WINWARN_IFANY(Flags, ...)
+#define WINWARN_IFALL(Flags, ...)
+#endif
#endif // liblldb_ProcessWindowsLog_h_
Index: source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
===================================================================
--- source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
+++ source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
@@ -27,7 +27,7 @@
lldb_private::Error &error)
{
if (!process_sp) return false;
-#ifdef _WIN32
+#if defined(WIN32) && !defined(__MINGW32__)
HANDLE process_handle = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, process_sp->GetID());
const std::string file_name = outfile.GetCString();
std::wstring wide_name;
Index: source/Host/windows/ProcessRunLock.cpp
===================================================================
--- source/Host/windows/ProcessRunLock.cpp
+++ source/Host/windows/ProcessRunLock.cpp
@@ -1,18 +1,9 @@
#include "lldb/Host/ProcessRunLock.h"
#include "lldb/Host/windows/windows.h"
-
-namespace
-{
-#if defined(__MINGW32__)
-// Taken from WinNT.h
-typedef struct _RTL_SRWLOCK {
- PVOID Ptr;
-} RTL_SRWLOCK, *PRTL_SRWLOCK;
-
-// Taken from WinBase.h
-typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
+#ifdef __MINGW32__
+#define _WIN32_WINNT 0x0600
+#include <synchapi.h>
#endif
-}
static PSRWLOCK GetLock(lldb::rwlock_t lock)
Index: source/Host/windows/FileSystem.cpp
===================================================================
--- source/Host/windows/FileSystem.cpp
+++ source/Host/windows/FileSystem.cpp
@@ -261,8 +261,12 @@
if (!llvm::ConvertUTF8toWide(mode, wmode))
return nullptr;
FILE *file;
+#ifndef __MINGW32__
if (_wfopen_s(&file, wpath.c_str(), wmode.c_str()) != 0)
return nullptr;
+#else
+ file = fopen(path, mode);
+#endif
return file;
}
Index: source/Host/windows/EditLineWin.cpp
===================================================================
--- source/Host/windows/EditLineWin.cpp
+++ source/Host/windows/EditLineWin.cpp
@@ -42,7 +42,7 @@
// default to what we expect to receive anyway
static const char *_prompt = "(lldb) ";
-#if !defined( _WIP_INPUT_METHOD )
+#if !defined( _WIP_INPUT_METHOD ) && !defined(__MINGW32__)
static char *
el_get_s (char *buffer, int chars)
Index: source/Host/common/OptionParser.cpp
===================================================================
--- source/Host/common/OptionParser.cpp
+++ source/Host/common/OptionParser.cpp
@@ -6,6 +6,9 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
+#ifdef __MINGW32__
+#define _BSD_SOURCE
+#endif
#include "lldb/Host/OptionParser.h"
#include "lldb/Host/HostGetOpt.h"
Index: source/Host/common/File.cpp
===================================================================
--- source/Host/common/File.cpp
+++ source/Host/common/File.cpp
@@ -276,6 +276,11 @@
error.SetErrorString("Error converting path to UTF-16");
return error;
}
+
+#ifndef _SH_DENYNO
+#define _SH_DENYNO 0x40
+#endif
+
::_wsopen_s(&m_descriptor, wpath.c_str(), oflag, _SH_DENYNO, mode);
#else
m_descriptor = ::open(path, oflag, mode);
Index: include/lldb/Host/windows/win32.h
===================================================================
--- include/lldb/Host/windows/win32.h
+++ include/lldb/Host/windows/win32.h
@@ -93,7 +93,7 @@
// timespec
// MSVC 2015 and higher have timespec. Otherwise we need to define it ourselves.
-#if defined(_MSC_VER) && _MSC_VER >= 1900
+#if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || defined(__MINGW32__)
#include <time.h>
#else
struct timespec
Index: cmake/modules/LLDBConfig.cmake
===================================================================
--- cmake/modules/LLDBConfig.cmake
+++ cmake/modules/LLDBConfig.cmake
@@ -223,13 +223,13 @@
# Disable Clang warnings
check_cxx_compiler_flag("-Wno-deprecated-register"
CXX_SUPPORTS_NO_DEPRECATED_REGISTER)
-if (CXX_SUPPORTS_NO_DEPRECATED_REGISTER)
+if (CXX_SUPPORTS_NO_DEPRECATED_REGISTER AND NOT MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
endif ()
check_cxx_compiler_flag("-Wno-vla-extension"
CXX_SUPPORTS_NO_VLA_EXTENSION)
-if (CXX_SUPPORTS_NO_VLA_EXTENSION)
+if (CXX_SUPPORTS_NO_VLA_EXTENSION AND NOT MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-vla-extension")
endif ()
@@ -247,8 +247,12 @@
# Use the Unicode (UTF-16) APIs by default on Win32
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
+ if(MINGW)
+ add_definitions( -D_UNICODE -DUNICODE )
+ else()
add_definitions( /D _UNICODE /D UNICODE )
endif()
+endif()
set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
@@ -390,8 +394,14 @@
(CMAKE_SYSTEM_NAME MATCHES "NetBSD"))
set(LLDB_CAN_USE_LLDB_SERVER 1)
else()
+ if(MINGW)
+ # It seems that lldb-server is required for Windows/MINGW, I am not sure why
+ # So we allows it to built
+ set(LLDB_CAN_USE_LLDB_SERVER 1)
+ else()
set(LLDB_CAN_USE_LLDB_SERVER 0)
endif()
+endif()
# Figure out if lldb could use debugserver. If so, then we'll
# ensure we build debugserver when we build lldb.
Index: cmake/modules/AddLLDB.cmake
===================================================================
--- cmake/modules/AddLLDB.cmake
+++ cmake/modules/AddLLDB.cmake
@@ -49,7 +49,7 @@
endif()
#PIC not needed on Win
- if (NOT MSVC)
+ if (NOT MSVC AND NOT MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 2.8)
+if(MINGW)
+ set(LLDB_DISABLE_PYTHON 1)
+endif()
+
include(cmake/modules/LLDBStandalone.cmake)
include(cmake/modules/LLDBConfig.cmake)
include(cmake/modules/AddLLDB.cmake)
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits