[Lldb-commits] [lldb] r189107 - MingW compilation (windows). Includes various refactoring to improve portability.
Virgile Bello
virgile.bello at gmail.com
Fri Aug 23 05:44:06 PDT 2013
Author: xen2
Date: Fri Aug 23 07:44:05 2013
New Revision: 189107
URL: http://llvm.org/viewvc/llvm-project?rev=189107&view=rev
Log:
MingW compilation (windows). Includes various refactoring to improve portability.
Added:
lldb/trunk/include/lldb/Host/windows/
lldb/trunk/include/lldb/Host/windows/win32.h
lldb/trunk/include/lldb/Host/windows/windows.h
lldb/trunk/source/Host/common/ProcessRunLock.cpp
lldb/trunk/source/Host/windows/
lldb/trunk/source/Host/windows/CMakeLists.txt
lldb/trunk/source/Host/windows/Condition.cpp
- copied, changed from r189082, lldb/trunk/source/Host/common/Condition.cpp
lldb/trunk/source/Host/windows/Host.cpp
lldb/trunk/source/Host/windows/Makefile
- copied, changed from r189082, lldb/trunk/tools/Makefile
lldb/trunk/source/Host/windows/Mutex.cpp
lldb/trunk/source/Host/windows/ProcessRunLock.cpp
lldb/trunk/source/Host/windows/Windows.cpp
Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/Makefile
lldb/trunk/include/lldb/API/SBHostOS.h
lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h
lldb/trunk/include/lldb/Core/RegularExpression.h
lldb/trunk/include/lldb/Core/Value.h
lldb/trunk/include/lldb/Host/Condition.h
lldb/trunk/include/lldb/Host/Host.h
lldb/trunk/include/lldb/Host/Mutex.h
lldb/trunk/include/lldb/Host/ProcessRunLock.h
lldb/trunk/include/lldb/Host/SocketAddress.h
lldb/trunk/include/lldb/Host/Terminal.h
lldb/trunk/include/lldb/Host/mingw/Config.h
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/include/lldb/lldb-private.h
lldb/trunk/include/lldb/lldb-types.h
lldb/trunk/lib/Makefile
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/API/SBHostOS.cpp
lldb/trunk/source/CMakeLists.txt
lldb/trunk/source/Commands/CommandCompletions.cpp
lldb/trunk/source/Core/CMakeLists.txt
lldb/trunk/source/Core/Communication.cpp
lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
lldb/trunk/source/Core/ConnectionSharedMemory.cpp
lldb/trunk/source/Core/DataBufferMemoryMap.cpp
lldb/trunk/source/Core/Log.cpp
lldb/trunk/source/Core/Timer.cpp
lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
lldb/trunk/source/Expression/IRMemoryMap.cpp
lldb/trunk/source/Host/CMakeLists.txt
lldb/trunk/source/Host/Makefile
lldb/trunk/source/Host/common/CMakeLists.txt
lldb/trunk/source/Host/common/Condition.cpp
lldb/trunk/source/Host/common/File.cpp
lldb/trunk/source/Host/common/FileSpec.cpp
lldb/trunk/source/Host/common/Host.cpp
lldb/trunk/source/Host/common/Mutex.cpp
lldb/trunk/source/Host/common/Terminal.cpp
lldb/trunk/source/Host/common/TimeValue.cpp
lldb/trunk/source/Interpreter/Args.cpp
lldb/trunk/source/Interpreter/Makefile
lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
lldb/trunk/source/Plugins/Makefile
lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/trunk/source/Symbol/ObjectFile.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Utility/PseudoTerminal.cpp
lldb/trunk/tools/CMakeLists.txt
lldb/trunk/tools/Makefile
Modified: lldb/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Fri Aug 23 07:44:05 2013
@@ -71,6 +71,10 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
endif()
endif()
+if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
+ add_definitions( -DLLDB_DISABLE_PYTHON )
+endif ()
+
macro(add_lldb_definitions)
# We don't want no semicolons on LLDB_DEFINITIONS:
foreach(arg ${ARGN})
@@ -182,7 +186,7 @@ macro(add_lldb_library name)
#endif()
if(LLDB_USED_LIBS)
- if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "Windows")
target_link_libraries(${name} -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
else()
target_link_libraries(${name} ${LLDB_USED_LIBS})
@@ -260,7 +264,9 @@ endif()
#add_subdirectory(include)
add_subdirectory(docs)
-add_subdirectory(scripts)
+if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
+ add_subdirectory(scripts)
+endif()
add_subdirectory(source)
add_subdirectory(test)
add_subdirectory(tools)
Modified: lldb/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/Makefile?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/Makefile (original)
+++ lldb/trunk/Makefile Fri Aug 23 07:44:05 2013
@@ -28,18 +28,22 @@ LEVEL := $(LLDB_LEVEL)/../..
# Include LLVM common makefile.
include $(LEVEL)/Makefile.common
-# Set Python include directory
-PYTHON_INC_DIR = $(shell python-config --includes)
# Set common LLDB build flags.
CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include
CPP.Flags += -I$(PROJ_OBJ_DIR)/$(LLDB_LEVEL)/include
CPP.Flags += -I$(LLVM_SRC_ROOT)/tools/clang/include
CPP.Flags += -I$(LLVM_OBJ_ROOT)/tools/clang/include
-CPP.Flags += $(PYTHON_INC_DIR)
CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/source
CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/source/Utility
CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/source/Plugins/Process/Utility
CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/source/Plugins/Process/POSIX
+
+ifeq (,$(findstring -DLLDB_DISABLE_PYTHON,$(CXXFLAGS)))
+# Set Python include directory
+PYTHON_INC_DIR = $(shell python-config --includes)
+CPP.Flags += $(PYTHON_INC_DIR)
+endif
+
ifeq ($(HOST_OS),Darwin)
CPP.Flags += -F/System/Library/Frameworks -F/System/Library/PrivateFrameworks
CPP.Flags += -I/usr/include/libxml2
Modified: lldb/trunk/include/lldb/API/SBHostOS.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBHostOS.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBHostOS.h (original)
+++ lldb/trunk/include/lldb/API/SBHostOS.h Fri Aug 23 07:44:05 2013
@@ -30,7 +30,7 @@ public:
static lldb::thread_t
ThreadCreate (const char *name,
- void *(*thread_function)(void *),
+ thread_func_t thread_function,
void *thread_arg,
lldb::SBError *err);
@@ -43,7 +43,7 @@ public:
lldb::SBError *err);
static bool
ThreadJoin (lldb::thread_t thread,
- void **result,
+ thread_result_t *result,
lldb::SBError *err);
Modified: lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h (original)
+++ lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h Fri Aug 23 07:44:05 2013
@@ -11,9 +11,13 @@
#define liblldb_ConnectionFileDescriptor_h_
// C Includes
+#ifdef _WIN32
+typedef unsigned short in_port_t;
+#else
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
+#endif
// C++ Includes
// Other libraries and framework includes
Modified: lldb/trunk/include/lldb/Core/RegularExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegularExpression.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/RegularExpression.h (original)
+++ lldb/trunk/include/lldb/Core/RegularExpression.h Fri Aug 23 07:44:05 2013
@@ -11,7 +11,36 @@
#define liblldb_DBRegex_h_
#if defined(__cplusplus)
+#ifdef _WIN32
+#include "../lib/Support/regex_impl.h"
+
+typedef llvm_regmatch_t regmatch_t;
+typedef llvm_regex_t regex_t;
+
+inline int regcomp(llvm_regex_t * a, const char *b, int c)
+{
+ return llvm_regcomp(a, b, c);
+}
+
+inline size_t regerror(int a, const llvm_regex_t *b, char *c, size_t d)
+{
+ return llvm_regerror(a, b, c, d);
+}
+
+inline int regexec(const llvm_regex_t * a, const char * b, size_t c,
+ llvm_regmatch_t d [], int e)
+{
+ return llvm_regexec(a, b, c, d, e);
+}
+
+inline void regfree(llvm_regex_t * a)
+{
+ llvm_regfree(a);
+}
+
+#else
#include <regex.h>
+#endif
#include <stdint.h>
#include <string>
Modified: lldb/trunk/include/lldb/Core/Value.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Value.h (original)
+++ lldb/trunk/include/lldb/Core/Value.h Fri Aug 23 07:44:05 2013
@@ -114,7 +114,7 @@ public:
#if defined (ENABLE_128_BIT_SUPPORT)
else if (length >= 16) scalar = *(const __uint128_t *)bytes;
#else
- else if (length >= 16) scalar = *(const __uint64_t *)bytes;
+ else if (length >= 16) scalar = *(const uint64_t *)bytes;
#endif
}
return scalar;
Modified: lldb/trunk/include/lldb/Host/Condition.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Condition.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Condition.h (original)
+++ lldb/trunk/include/lldb/Host/Condition.h Fri Aug 23 07:44:05 2013
@@ -12,7 +12,7 @@
#if defined(__cplusplus)
-#include <pthread.h>
+#include "lldb/lldb-types.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private {
@@ -105,7 +105,7 @@ protected:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
- pthread_cond_t m_condition; ///< The condition variable.
+ lldb::condition_t m_condition; ///< The condition variable.
//------------------------------------------------------------------
/// Get accessor to the pthread condition object.
@@ -113,7 +113,7 @@ protected:
/// @return
/// A pointer to the condition variable owned by this object.
//------------------------------------------------------------------
- pthread_cond_t *
+ lldb::condition_t *
GetCondition ();
};
Modified: lldb/trunk/include/lldb/Host/Host.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Host.h (original)
+++ lldb/trunk/include/lldb/Host/Host.h Fri Aug 23 07:44:05 2013
@@ -209,6 +209,9 @@ public:
static lldb::pid_t
GetCurrentProcessID ();
+ static void
+ Kill(lldb::pid_t pid, int signo);
+
//------------------------------------------------------------------
/// Get the thread ID for the calling thread in the current process.
///
@@ -264,6 +267,17 @@ public:
lldb::thread_result_t *thread_result_ptr,
Error *error);
+ typedef void (*ThreadLocalStorageCleanupCallback) (void *p);
+
+ static lldb::thread_key_t
+ ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback);
+
+ static void*
+ ThreadLocalStorageGet(lldb::thread_key_t key);
+
+ static void
+ ThreadLocalStorageSet(lldb::thread_key_t key, void *value);
+
//------------------------------------------------------------------
/// Gets the name of a thread in a process.
///
Modified: lldb/trunk/include/lldb/Host/Mutex.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Mutex.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Mutex.h (original)
+++ lldb/trunk/include/lldb/Host/Mutex.h Fri Aug 23 07:44:05 2013
@@ -11,7 +11,7 @@
#define liblldb_Mutex_h_
#if defined(__cplusplus)
-#include <pthread.h>
+#include "lldb/lldb-types.h"
#include <assert.h>
#ifdef LLDB_CONFIGURATION_DEBUG
@@ -238,7 +238,7 @@ protected:
//------------------------------------------------------------------
// TODO: Hide the mutex in the implementation file in case we ever need to port to an
// architecture that doesn't have pthread mutexes.
- pthread_mutex_t m_mutex; ///< The pthread mutex object.
+ lldb::mutex_t m_mutex; ///< The OS mutex object.
private:
//------------------------------------------------------------------
@@ -247,7 +247,7 @@ private:
/// @return
/// A pointer to the pthread mutex object owned by this object.
//------------------------------------------------------------------
- pthread_mutex_t *
+ lldb::mutex_t *
GetMutex();
Mutex(const Mutex&);
Modified: lldb/trunk/include/lldb/Host/ProcessRunLock.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/ProcessRunLock.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/ProcessRunLock.h (original)
+++ lldb/trunk/include/lldb/Host/ProcessRunLock.h Fri Aug 23 07:44:05 2013
@@ -11,9 +11,9 @@
#define liblldb_ProcessRunLock_h_
#if defined(__cplusplus)
+#include "lldb/lldb-defines.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Condition.h"
-#include <pthread.h>
#include <stdint.h>
#include <time.h>
@@ -32,75 +32,14 @@ namespace lldb_private {
class ProcessRunLock
{
public:
- ProcessRunLock () :
- m_rwlock(),
- m_running(false)
- {
- int err = ::pthread_rwlock_init(&m_rwlock, NULL); (void)err;
-//#if LLDB_CONFIGURATION_DEBUG
-// assert(err == 0);
-//#endif
- }
-
- ~ProcessRunLock ()
- {
- int err = ::pthread_rwlock_destroy (&m_rwlock); (void)err;
-//#if LLDB_CONFIGURATION_DEBUG
-// assert(err == 0);
-//#endif
- }
-
- bool
- ReadTryLock ()
- {
- ::pthread_rwlock_rdlock (&m_rwlock);
- if (m_running == false)
- {
- return true;
- }
- ::pthread_rwlock_unlock (&m_rwlock);
- return false;
- }
-
- bool
- ReadUnlock ()
- {
- return ::pthread_rwlock_unlock (&m_rwlock) == 0;
- }
-
- bool
- SetRunning()
- {
- ::pthread_rwlock_wrlock (&m_rwlock);
- m_running = true;
- ::pthread_rwlock_unlock (&m_rwlock);
- return true;
- }
-
- bool
- TrySetRunning()
- {
- bool r;
-
- if (::pthread_rwlock_trywrlock (&m_rwlock) == 0)
- {
- r = !m_running;
- m_running = true;
- ::pthread_rwlock_unlock (&m_rwlock);
- return r;
- }
- return false;
- }
-
- bool
- SetStopped ()
- {
- ::pthread_rwlock_wrlock (&m_rwlock);
- m_running = false;
- ::pthread_rwlock_unlock (&m_rwlock);
- return true;
- }
-
+ ProcessRunLock();
+ ~ProcessRunLock();
+ bool ReadTryLock ();
+ bool ReadUnlock ();
+ bool SetRunning ();
+ bool TrySetRunning ();
+ bool SetStopped ();
+public:
class ProcessRunLocker
{
public:
@@ -153,7 +92,7 @@ public:
};
protected:
- pthread_rwlock_t m_rwlock;
+ lldb::rwlock_t m_rwlock;
bool m_running;
private:
DISALLOW_COPY_AND_ASSIGN(ProcessRunLock);
Modified: lldb/trunk/include/lldb/Host/SocketAddress.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/SocketAddress.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/SocketAddress.h (original)
+++ lldb/trunk/include/lldb/Host/SocketAddress.h Fri Aug 23 07:44:05 2013
@@ -12,9 +12,18 @@
// C Includes
#include <stdint.h>
+
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#include <winsock2.h>
+#include <WS2tcpip.h>
+typedef ADDRESS_FAMILY sa_family_t;
+typedef USHORT in_port_t;
+#else
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
+#endif
#if defined(__FreeBSD__)
#include <sys/types.h>
Modified: lldb/trunk/include/lldb/Host/Terminal.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Terminal.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Terminal.h (original)
+++ lldb/trunk/include/lldb/Host/Terminal.h Fri Aug 23 07:44:05 2013
@@ -12,6 +12,7 @@
#if defined(__cplusplus)
#include "lldb/lldb-private.h"
+#include "lldb/Host/Config.h"
struct termios;
@@ -173,7 +174,9 @@ protected:
//------------------------------------------------------------------
Terminal m_tty; ///< A terminal
int m_tflags; ///< Cached tflags information.
+#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
std::unique_ptr<struct termios> m_termios_ap; ///< Cached terminal state information.
+#endif
lldb::pid_t m_process_group;///< Cached process group information.
};
Modified: lldb/trunk/include/lldb/Host/mingw/Config.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/mingw/Config.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/mingw/Config.h (original)
+++ lldb/trunk/include/lldb/Host/mingw/Config.h Fri Aug 23 07:44:05 2013
@@ -17,6 +17,8 @@
#ifndef liblldb_Platform_Config_h_
#define liblldb_Platform_Config_h_
+#define LLDB_DISABLE_POSIX
+
//#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
//#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
Added: lldb/trunk/include/lldb/Host/windows/win32.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/windows/win32.h?rev=189107&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/windows/win32.h (added)
+++ lldb/trunk/include/lldb/Host/windows/win32.h Fri Aug 23 07:44:05 2013
@@ -0,0 +1,27 @@
+//===-- lldb-win32.h --------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_lldb_win32_h_
+#define LLDB_lldb_win32_h_
+
+#include <stdarg.h>
+
+// posix utilities
+int vasprintf(char **ret, const char *fmt, va_list ap);
+char * strcasestr(const char *s, const char* find);
+char* realpath(const char * name, char * resolved);
+
+#define PATH_MAX MAX_PATH
+
+#define O_NOCTTY 0
+#define SIGTRAP 5
+#define SIGKILL 9
+#define SIGSTOP 20
+
+#endif // LLDB_lldb_win32_h_
Added: lldb/trunk/include/lldb/Host/windows/windows.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/windows/windows.h?rev=189107&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/windows/windows.h (added)
+++ lldb/trunk/include/lldb/Host/windows/windows.h Fri Aug 23 07:44:05 2013
@@ -0,0 +1,26 @@
+//===-- lldb-windows.h ------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_lldb_windows_h_
+#define LLDB_lldb_windows_h_
+
+#define NTDDI_VERSION NTDDI_VISTA
+#define _WIN32_WINNT _WIN32_WINNT_VISTA
+#define WIN32_LEAN_AND_MEAN
+#define NOGDI
+#define NOMINMAX
+#include <Windows.h>
+#undef GetUserName
+#undef LoadImage
+#undef CreateProcess
+#undef LoadImage
+#undef GetUserName
+#undef far
+
+#endif // LLDB_lldb_windows_h_
Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Fri Aug 23 07:44:05 2013
@@ -10,9 +10,13 @@
#ifndef liblldb_Process_h_
#define liblldb_Process_h_
+#include "lldb/Host/Config.h"
+
// C Includes
#include <limits.h>
+#ifndef LLDB_DISABLE_POSIX
#include <spawn.h>
+#endif
// C++ Includes
#include <list>
@@ -475,11 +479,13 @@ public:
bool
Open (int fd, const char *path, bool read, bool write);
+#ifndef LLDB_DISABLE_POSIX
static bool
AddPosixSpawnFileAction (posix_spawn_file_actions_t *file_actions,
const FileAction *info,
Log *log,
Error& error);
+#endif
int
GetFD () const
@@ -3711,10 +3717,10 @@ protected:
void
ResumePrivateStateThread ();
- static void *
+ static lldb::thread_result_t
PrivateStateThread (void *arg);
- void *
+ lldb::thread_result_t
RunPrivateStateThread ();
void
Modified: lldb/trunk/include/lldb/lldb-private.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private.h (original)
+++ lldb/trunk/include/lldb/lldb-private.h Fri Aug 23 07:44:05 2013
@@ -12,6 +12,10 @@
#if defined(__cplusplus)
+#ifdef _WIN32
+#include "lldb/Host/windows/win32.h"
+#endif
+
#include "lldb/lldb-public.h"
#include "lldb/lldb-private-enumerations.h"
#include "lldb/lldb-private-interfaces.h"
Modified: lldb/trunk/include/lldb/lldb-types.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-types.h (original)
+++ lldb/trunk/include/lldb/lldb-types.h Fri Aug 23 07:44:05 2013
@@ -14,11 +14,8 @@
#include "lldb/lldb-forward.h"
#include <assert.h>
-#include <pthread.h>
#include <signal.h>
#include <stdint.h>
-#include <stdbool.h>
-#include <unistd.h>
//----------------------------------------------------------------------
// All host systems must define:
@@ -38,13 +35,40 @@
// things should be defined. Currently MacOSX is being assumed by default
// since that is what lldb was first developed for.
+#ifdef _WIN32
+
+#include "lldb/Host/windows/windows.h"
+#include <process.h>
+
+namespace lldb
+{
+ typedef CRITICAL_SECTION mutex_t;
+ typedef CONDITION_VARIABLE condition_t;
+ typedef void* rwlock_t;
+ typedef uintptr_t thread_t; // Host thread type
+ typedef DWORD thread_key_t;
+ typedef void * thread_arg_t; // Host thread argument type
+ typedef unsigned thread_result_t; // Host thread result type
+ typedef thread_result_t (*thread_func_t)(void *); // Host thread function type
+ typedef void (*LogOutputCallback) (const char *, void *baton);
+ typedef bool (*CommandOverrideCallback)(void *baton, const char **argv);
+}
+
+#else
+
+#include <pthread.h>
+#include <stdbool.h>
+#include <unistd.h>
+
namespace lldb {
//----------------------------------------------------------------------
// MacOSX Types
//----------------------------------------------------------------------
typedef ::pthread_mutex_t mutex_t;
typedef pthread_cond_t condition_t;
+ typedef pthread_rwlock_t rwlock_t;
typedef pthread_t thread_t; // Host thread type
+ typedef pthread_key_t thread_key_t;
typedef void * thread_arg_t; // Host thread argument type
typedef void * thread_result_t; // Host thread result type
typedef void * (*thread_func_t)(void *); // Host thread function type
@@ -52,19 +76,11 @@ namespace lldb {
typedef bool (*CommandOverrideCallback)(void *baton, const char **argv);
} // namespace lldb
-#if defined(__MINGW32__)
-
-const lldb::thread_t lldb_invalid_host_thread_const = { NULL, 0 } ;
-#define LLDB_INVALID_HOST_THREAD (lldb_invalid_host_thread_const)
-#define IS_VALID_LLDB_HOST_THREAD(t) (!(NULL == (t).p && 0 == (t).x))
-
-#else
+#endif
#define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL)
#define IS_VALID_LLDB_HOST_THREAD(t) ((t) != LLDB_INVALID_HOST_THREAD)
-#endif
-
#define LLDB_INVALID_HOST_TIME { 0, 0 }
namespace lldb
Modified: lldb/trunk/lib/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/lib/Makefile (original)
+++ lldb/trunk/lib/Makefile Fri Aug 23 07:44:05 2013
@@ -17,7 +17,9 @@ NO_BUILD_ARCHIVE = 1
LINK_LIBS_IN_SHARED = 1
SHARED_LIBRARY = 1
+ifeq (,$(findstring -DLLDB_DISABLE_PYTHON,$(CXXFLAGS)))
PYTHON_BUILD_FLAGS = $(shell python-config --ldflags)
+endif
# Include all archives in liblldb.so file
USEDLIBS = lldbAPI.a \
@@ -72,7 +74,7 @@ USEDLIBS = lldbAPI.a \
# Because GCC requires RTTI enabled for lldbCore (see source/Core/Makefile) it is
# necessary to also link the clang rewriter libraries so vtable references can
# be resolved correctly, if we are building with GCC.
-ifeq (g++,$(shell basename $(CXX) | colrm 4))
+ifeq (g++,$(shell basename $(CXX) | cut -c 1-4))
USEDLIBS += clangRewriteCore.a \
clangRewriteFrontend.a
endif
Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Fri Aug 23 07:44:05 2013
@@ -480,7 +480,7 @@ SBDebugger::GetScriptingLanguage (const
const char *
SBDebugger::GetVersionString ()
{
- return GetVersion();
+ return lldb_private::GetVersion();
}
const char *
Modified: lldb/trunk/source/API/SBHostOS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBHostOS.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/API/SBHostOS.cpp (original)
+++ lldb/trunk/source/API/SBHostOS.cpp Fri Aug 23 07:44:05 2013
@@ -42,7 +42,7 @@ lldb::thread_t
SBHostOS::ThreadCreate
(
const char *name,
- void *(*thread_function)(void *),
+ thread_func_t thread_function,
void *thread_arg,
SBError *error_ptr
)
@@ -77,7 +77,7 @@ SBHostOS::ThreadDetach (lldb::thread_t t
}
bool
-SBHostOS::ThreadJoin (lldb::thread_t thread, void **result, SBError *error_ptr)
+SBHostOS::ThreadJoin (lldb::thread_t thread, thread_result_t *result, SBError *error_ptr)
{
return Host::ThreadJoin (thread, result, error_ptr ? error_ptr->get() : NULL);
}
Modified: lldb/trunk/source/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/CMakeLists.txt?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/CMakeLists.txt (original)
+++ lldb/trunk/source/CMakeLists.txt Fri Aug 23 07:44:05 2013
@@ -78,9 +78,9 @@ set( LLDB_USED_LIBS
# Windows-only libraries
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
list(APPEND LLDB_USED_LIBS
- #lldbHostWindows
+ lldbHostWindows
#lldbPluginPlatformWindows
- #Ws2_32
+ Ws2_32
)
endif ()
@@ -137,10 +137,12 @@ set( CLANG_USED_LIBS
clangSerialization
)
-set( LLDB_SYSTEM_LIBS
- edit
- python2.7
- )
+if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
+ set( LLDB_SYSTEM_LIBS
+ edit
+ python2.7
+ )
+endif()
set( LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
@@ -164,10 +166,14 @@ set( LLVM_LINK_COMPONENTS
set_source_files_properties(${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp PROPERTIES GENERATED 1)
set(SHARED_LIBRARY 1)
+if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
+ set(LLDB_WRAP_PYTHON ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp)
+endif()
+
add_lldb_library(liblldb
lldb.cpp
lldb-log.cpp
- ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp
+ ${LLDB_WRAP_PYTHON}
${LLDB_VERS_GENERATED_FILE}
)
set_target_properties(liblldb
@@ -175,10 +181,12 @@ set_target_properties(liblldb
OUTPUT_NAME lldb
VERSION ${LLDB_VERSION}
)
-add_dependencies(liblldb
- ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp
- ${LLDB_VERS_GENERATED_FILE}
- )
+if (LLDB_WRAP_PYTHON OR LLDB_VERS_GENERATED_FILE)
+ add_dependencies(liblldb
+ ${LLDB_WRAP_PYTHON}
+ ${LLDB_VERS_GENERATED_FILE}
+ )
+endif()
target_link_libraries(liblldb ${LLDB_SYSTEM_LIBS})
# Determine LLDB revision and repository. GetSourceVersion and GetRepositoryPath are shell-scripts, and as
@@ -209,4 +217,5 @@ endif ()
install(TARGETS liblldb
+ RUNTIME DESTINATION bin
LIBRARY DESTINATION lib)
Modified: lldb/trunk/source/Commands/CommandCompletions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandCompletions.cpp (original)
+++ lldb/trunk/source/Commands/CommandCompletions.cpp Fri Aug 23 07:44:05 2013
@@ -11,7 +11,6 @@
// C Includes
#include <sys/stat.h>
-#include <dirent.h>
#if defined(__APPLE__) || defined(__linux__)
#include <pwd.h>
#endif
@@ -121,6 +120,72 @@ CommandCompletions::SourceFiles
return matches.GetSize();
}
+typedef struct DiskFilesOrDirectoriesBaton
+{
+ const char *remainder;
+ char *partial_name_copy;
+ bool only_directories;
+ bool *saw_directory;
+ StringList *matches;
+ char *end_ptr;
+ size_t baselen;
+};
+
+FileSpec::EnumerateDirectoryResult DiskFilesOrDirectoriesCallback(void *baton, FileSpec::FileType file_type, const FileSpec &spec)
+{
+ const char *name = spec.GetFilename().AsCString();
+
+ const DiskFilesOrDirectoriesBaton *parameters = (DiskFilesOrDirectoriesBaton*)baton;
+ char *end_ptr = parameters->end_ptr;
+ char *partial_name_copy = parameters->partial_name_copy;
+ size_t baselen = end_ptr - partial_name_copy;
+ const char *remainder = parameters->remainder;
+
+ // Omit ".", ".." and any . files if the match string doesn't start with .
+ if (name[0] == '.')
+ {
+ if (name[1] == '\0')
+ return FileSpec::eEnumerateDirectoryResultNext;
+ else if (name[1] == '.' && name[2] == '\0')
+ return FileSpec::eEnumerateDirectoryResultNext;
+ else if (remainder[0] != '.')
+ return FileSpec::eEnumerateDirectoryResultNext;
+ }
+
+ // If we found a directory, we put a "/" at the end of the name.
+
+ if (remainder[0] == '\0' || strstr(name, remainder) == name)
+ {
+ if (strlen(name) + parameters->baselen >= PATH_MAX)
+ return FileSpec::eEnumerateDirectoryResultNext;
+
+ strcpy(end_ptr, name);
+
+ bool isa_directory = false;
+ if (file_type == FileSpec::eFileTypeDirectory)
+ isa_directory = true;
+ else if (file_type == FileSpec::eFileTypeSymbolicLink)
+ {
+ struct stat stat_buf;
+ if ((stat(partial_name_copy, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode))
+ isa_directory = true;
+ }
+
+ if (isa_directory)
+ {
+ *parameters->saw_directory = true;
+ size_t len = strlen(parameters->partial_name_copy);
+ partial_name_copy[len] = '/';
+ partial_name_copy[len + 1] = '\0';
+ }
+ if (parameters->only_directories && !isa_directory)
+ return FileSpec::eEnumerateDirectoryResultNext;
+ parameters->matches->AppendString(partial_name_copy);
+ }
+
+ return FileSpec::eEnumerateDirectoryResultNext;
+}
+
static int
DiskFilesOrDirectories
(
@@ -239,60 +304,18 @@ DiskFilesOrDirectories
// Okay, containing_part is now the directory we want to open and look for files:
- lldb_utility::CleanUp <DIR *, int> dir_stream (opendir(containing_part), NULL, closedir);
- if (!dir_stream.is_valid())
- return matches.GetSize();
-
- struct dirent *dirent_buf;
-
size_t baselen = end_ptr - partial_name_copy;
- while ((dirent_buf = readdir(dir_stream.get())) != NULL)
- {
- char *name = dirent_buf->d_name;
-
- // Omit ".", ".." and any . files if the match string doesn't start with .
- if (name[0] == '.')
- {
- if (name[1] == '\0')
- continue;
- else if (name[1] == '.' && name[2] == '\0')
- continue;
- else if (remainder[0] != '.')
- continue;
- }
-
- // If we found a directory, we put a "/" at the end of the name.
-
- if (remainder[0] == '\0' || strstr(dirent_buf->d_name, remainder) == name)
- {
- if (strlen(name) + baselen >= PATH_MAX)
- continue;
-
- strcpy(end_ptr, name);
-
- bool isa_directory = false;
- if (dirent_buf->d_type & DT_DIR)
- isa_directory = true;
- else if (dirent_buf->d_type & DT_LNK)
- {
- struct stat stat_buf;
- if ((stat(partial_name_copy, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode))
- isa_directory = true;
- }
-
- if (isa_directory)
- {
- saw_directory = true;
- size_t len = strlen(partial_name_copy);
- partial_name_copy[len] = '/';
- partial_name_copy[len + 1] = '\0';
- }
- if (only_directories && !isa_directory)
- continue;
- matches.AppendString(partial_name_copy);
- }
- }
+ DiskFilesOrDirectoriesBaton parameters;
+ parameters.remainder = remainder;
+ parameters.partial_name_copy = partial_name_copy;
+ parameters.only_directories = only_directories;
+ parameters.saw_directory = &saw_directory;
+ parameters.matches = &matches;
+ parameters.end_ptr = end_ptr;
+ parameters.baselen = baselen;
+
+ FileSpec::EnumerateDirectory(containing_part, true, true, true, DiskFilesOrDirectoriesCallback, ¶meters);
return matches.GetSize();
}
Modified: lldb/trunk/source/Core/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/CMakeLists.txt?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Core/CMakeLists.txt (original)
+++ lldb/trunk/source/Core/CMakeLists.txt Fri Aug 23 07:44:05 2013
@@ -71,6 +71,5 @@ add_lldb_library(lldbCore
ValueObjectSyntheticFilter.cpp
ValueObjectVariable.cpp
VMRange.cpp
- #Windows.cpp
)
Modified: lldb/trunk/source/Core/Communication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Core/Communication.cpp (original)
+++ lldb/trunk/source/Core/Communication.cpp Fri Aug 23 07:44:05 2013
@@ -333,8 +333,8 @@ Communication::ReadThreadIsRunning ()
return m_read_thread_enabled;
}
-void *
-Communication::ReadThread (void *p)
+lldb::thread_result_t
+Communication::ReadThread (lldb::thread_arg_t p)
{
Communication *comm = (Communication *)p;
Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original)
+++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Fri Aug 23 07:44:05 2013
@@ -15,10 +15,15 @@
#endif
#include "lldb/Core/ConnectionFileDescriptor.h"
+#include "lldb/Host/Config.h"
// C Includes
#include <errno.h>
#include <fcntl.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#ifndef LLDB_DISABLE_POSIX
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
@@ -26,10 +31,8 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <termios.h>
-#include <sys/types.h>
-#include <string.h>
-#include <stdlib.h>
#include <unistd.h>
+#endif
// C++ Includes
// Other libraries and framework includes
@@ -135,7 +138,11 @@ ConnectionFileDescriptor::OpenCommandPip
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
// Make the command file descriptor here:
int filedes[2];
+#ifndef LLDB_DISABLE_POSIX
int result = pipe (filedes);
+#else
+ int result = -1;
+#endif
if (result != 0)
{
if (log)
@@ -223,7 +230,11 @@ ConnectionFileDescriptor::Connect (const
// get the flags from the file descriptor and making sure it
// isn't a bad fd.
errno = 0;
+#ifndef LLDB_DISABLE_POSIX
int flags = ::fcntl (m_fd_send, F_GETFL, 0);
+#else
+ int flags = -1;
+#endif
if (flags == -1 || errno == EBADF)
{
if (error_ptr)
@@ -262,6 +273,7 @@ ConnectionFileDescriptor::Connect (const
{
// file:///PATH
const char *path = s + strlen("file://");
+#ifndef LLDB_DISABLE_POSIX
do
{
m_fd_send = m_fd_recv = ::open (path, O_RDWR);
@@ -304,6 +316,9 @@ ConnectionFileDescriptor::Connect (const
}
m_should_close_fd = true;
return eConnectionStatusSuccess;
+#else
+ return eConnectionStatusError;
+#endif
}
if (error_ptr)
error_ptr->SetErrorStringWithFormat ("unsupported connection URL: '%s'", s);
@@ -420,7 +435,21 @@ ConnectionFileDescriptor::Read (void *ds
{
do
{
+#ifndef LLDB_DISABLE_POSIX
bytes_read = ::read (m_fd_recv, dst, dst_len);
+#else
+ switch (m_fd_send_type) {
+ case eFDTypeSocket:
+ case eFDTypeSocketUDP:
+ bytes_read = ::recv (m_fd_recv, (char*)dst, dst_len, 0);
+ break;
+ default:
+ bytes_read = -1;
+ break;
+
+ }
+
+#endif
} while (bytes_read < 0 && errno == EINTR);
}
@@ -523,17 +552,18 @@ ConnectionFileDescriptor::Write (const v
switch (m_fd_send_type)
{
+#ifndef LLDB_DISABLE_POSIX
case eFDTypeFile: // Other FD requireing read/write
do
{
bytes_sent = ::write (m_fd_send, src, src_len);
} while (bytes_sent < 0 && errno == EINTR);
break;
-
+#endif
case eFDTypeSocket: // Socket requiring send/recv
do
{
- bytes_sent = ::send (m_fd_send, src, src_len, 0);
+ bytes_sent = ::send (m_fd_send, (char*)src, src_len, 0);
} while (bytes_sent < 0 && errno == EINTR);
break;
@@ -542,7 +572,7 @@ ConnectionFileDescriptor::Write (const v
do
{
bytes_sent = ::sendto (m_fd_send,
- src,
+ (char*)src,
src_len,
0,
m_udp_send_sockaddr,
@@ -1115,6 +1145,7 @@ ConnectionFileDescriptor::Close (int& fd
ConnectionStatus
ConnectionFileDescriptor::NamedSocketAccept (const char *socket_name, Error *error_ptr)
{
+#ifndef LLDB_DISABLE_POSIX
ConnectionStatus result = eConnectionStatusError;
struct sockaddr_un saddr_un;
@@ -1159,11 +1190,15 @@ ConnectionFileDescriptor::NamedSocketAcc
// We are done with the listen port
Close (listen_socket, NULL);
return result;
+#else
+ return eConnectionStatusError;
+#endif
}
ConnectionStatus
ConnectionFileDescriptor::NamedSocketConnect (const char *socket_name, Error *error_ptr)
{
+#ifndef LLDB_DISABLE_POSIX
Disconnect (NULL);
m_fd_send_type = m_fd_recv_type = eFDTypeSocket;
@@ -1194,6 +1229,9 @@ ConnectionFileDescriptor::NamedSocketCon
if (error_ptr)
error_ptr->Clear();
return eConnectionStatusSuccess;
+#else
+ return eConnectionStatusError;
+#endif
}
ConnectionStatus
@@ -1430,18 +1468,18 @@ ConnectionFileDescriptor::ConnectUDP (co
return eConnectionStatusSuccess;
}
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(_WIN32)
typedef const char * set_socket_option_arg_type;
typedef char * get_socket_option_arg_type;
-#else // #if defined(__MINGW32__) || defined(__MINGW64__)
+#else // #if defined(_WIN32)
typedef const void * set_socket_option_arg_type;
typedef void * get_socket_option_arg_type;
-#endif // #if defined(__MINGW32__) || defined(__MINGW64__)
+#endif // #if defined(_WIN32)
int
ConnectionFileDescriptor::GetSocketOption(int fd, int level, int option_name, int &option_value)
{
- get_socket_option_arg_type option_value_p = static_cast<get_socket_option_arg_type>(&option_value);
+ get_socket_option_arg_type option_value_p = reinterpret_cast<get_socket_option_arg_type>(&option_value);
socklen_t option_value_size = sizeof(int);
return ::getsockopt(fd, level, option_name, option_value_p, &option_value_size);
}
@@ -1449,7 +1487,7 @@ ConnectionFileDescriptor::GetSocketOptio
int
ConnectionFileDescriptor::SetSocketOption(int fd, int level, int option_name, int option_value)
{
- set_socket_option_arg_type option_value_p = static_cast<get_socket_option_arg_type>(&option_value);
+ set_socket_option_arg_type option_value_p = reinterpret_cast<get_socket_option_arg_type>(&option_value);
return ::setsockopt(fd, level, option_name, option_value_p, sizeof(option_value));
}
@@ -1487,7 +1525,7 @@ ConnectionFileDescriptor::SetSocketRecei
timeout.tv_sec = timeout_usec / TimeValue::MicroSecPerSec;
timeout.tv_usec = timeout_usec % TimeValue::MicroSecPerSec;
}
- if (::setsockopt (m_fd_recv, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) == 0)
+ if (::setsockopt (m_fd_recv, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast<get_socket_option_arg_type>(&timeout), sizeof(timeout)) == 0)
{
m_socket_timeout_usec = timeout_usec;
return true;
Modified: lldb/trunk/source/Core/ConnectionSharedMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionSharedMemory.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConnectionSharedMemory.cpp (original)
+++ lldb/trunk/source/Core/ConnectionSharedMemory.cpp Fri Aug 23 07:44:05 2013
@@ -11,12 +11,15 @@
// C Includes
#include <errno.h>
-#include <pthread.h>
#include <stdlib.h>
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#else
#include <sys/file.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
+#endif
// C++ Includes
// Other libraries and framework includes
@@ -73,7 +76,12 @@ ConnectionSharedMemory::Disconnect (Erro
m_mmap.Clear();
if (!m_name.empty())
{
+#ifdef _WIN32
+ close(m_fd);
+ m_fd = -1;
+#else
shm_unlink (m_name.c_str());
+#endif
m_name.clear();
}
return eConnectionStatusSuccess;
@@ -114,6 +122,16 @@ ConnectionSharedMemory::Open (bool creat
}
m_name.assign (name);
+
+#ifdef _WIN32
+ HANDLE handle;
+ if (create)
+ handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, (DWORD)(size >> 32), (DWORD)(size), name);
+ else
+ handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, name);
+
+ m_fd = _open_osfhandle((intptr_t)handle, 0);
+#else
int oflag = O_RDWR;
if (create)
oflag |= O_CREAT;
@@ -121,6 +139,7 @@ ConnectionSharedMemory::Open (bool creat
if (create)
::ftruncate (m_fd, size);
+#endif
if (m_mmap.MemoryMapFromFileDescriptor(m_fd, 0, size, true, false) == size)
return eConnectionStatusSuccess;
Modified: lldb/trunk/source/Core/DataBufferMemoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataBufferMemoryMap.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataBufferMemoryMap.cpp (original)
+++ lldb/trunk/source/Core/DataBufferMemoryMap.cpp Fri Aug 23 07:44:05 2013
@@ -12,7 +12,11 @@
#include <fcntl.h>
#include <limits.h>
#include <sys/stat.h>
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#else
#include <sys/mman.h>
+#endif
#include "lldb/Core/DataBufferMemoryMap.h"
#include "lldb/Core/Error.h"
@@ -86,7 +90,11 @@ DataBufferMemoryMap::Clear()
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP));
if (log)
log->Printf("DataBufferMemoryMap::Clear() m_mmap_addr = %p, m_mmap_size = %zu", m_mmap_addr, m_mmap_size);
+#ifdef _WIN32
+ UnmapViewOfFile(m_mmap_addr);
+#else
::munmap((void *)m_mmap_addr, m_mmap_size);
+#endif
m_mmap_addr = NULL;
m_mmap_size = 0;
m_data = NULL;
@@ -166,13 +174,49 @@ DataBufferMemoryMap::MemoryMapFromFileDe
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP|LIBLLDB_LOG_VERBOSE));
if (log)
{
+#ifdef _WIN32
+ log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(fd=%p, offset=0x%" PRIx64 ", length=0x%" PRIx64 ", writeable=%i, fd_is_file=%i)",
+#else
log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(fd=%i, offset=0x%" PRIx64 ", length=0x%" PRIx64 ", writeable=%i, fd_is_file=%i)",
+#endif
fd,
offset,
length,
writeable,
fd_is_file);
}
+#ifdef _WIN32
+ HANDLE handle = (HANDLE)_get_osfhandle(fd);
+ DWORD file_size_low, file_size_high;
+ file_size_low = GetFileSize(handle, &file_size_high);
+ const size_t file_size = (file_size_high << 32) | file_size_low;
+ const size_t max_bytes_available = file_size - offset;
+ if (length == SIZE_MAX)
+ {
+ length = max_bytes_available;
+ }
+ else if (length > max_bytes_available)
+ {
+ // Cap the length if too much data was requested
+ length = max_bytes_available;
+ }
+
+ if (length > 0)
+ {
+ HANDLE fileMapping = CreateFileMapping(handle, NULL, writeable ? PAGE_READWRITE : PAGE_READONLY, file_size_high, file_size_low, NULL);
+ if (fileMapping != NULL)
+ {
+ m_mmap_addr = (uint8_t*)MapViewOfFile(fileMapping, writeable ? FILE_MAP_ALL_ACCESS : FILE_MAP_READ, (DWORD)(offset >> 32), (DWORD)(offset), length);
+ if (m_mmap_addr != NULL)
+ {
+ m_mmap_size = length;
+ m_data = m_mmap_addr;
+ m_size = length;
+ }
+ CloseHandle(fileMapping);
+ }
+ }
+#else
struct stat stat;
if (::fstat(fd, &stat) == 0)
{
@@ -253,6 +297,7 @@ DataBufferMemoryMap::MemoryMapFromFileDe
}
}
}
+#endif
}
return GetByteSize ();
}
Modified: lldb/trunk/source/Core/Log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Core/Log.cpp (original)
+++ lldb/trunk/source/Core/Log.cpp Fri Aug 23 07:44:05 2013
@@ -10,7 +10,6 @@
#include "lldb/lldb-python.h"
// C Includes
-#include <pthread.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
Modified: lldb/trunk/source/Core/Timer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Timer.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Core/Timer.cpp (original)
+++ lldb/trunk/source/Core/Timer.cpp Fri Aug 23 07:44:05 2013
@@ -14,6 +14,7 @@
#include "lldb/Core/Stream.h"
#include "lldb/Host/Mutex.h"
+#include "lldb/Host/Host.h"
#include <stdio.h>
@@ -26,7 +27,7 @@ uint32_t Timer::g_display_depth = 0;
FILE * Timer::g_file = NULL;
typedef std::vector<Timer *> TimerStack;
typedef std::map<const char *, uint64_t> TimerCategoryMap;
-static pthread_key_t g_key;
+static lldb::thread_key_t g_key;
static Mutex &
GetCategoryMutex()
@@ -46,11 +47,11 @@ GetCategoryMap()
static TimerStack *
GetTimerStackForCurrentThread ()
{
- void *timer_stack = ::pthread_getspecific (g_key);
+ void *timer_stack = Host::ThreadLocalStorageGet(g_key);
if (timer_stack == NULL)
{
- ::pthread_setspecific (g_key, new TimerStack);
- timer_stack = ::pthread_getspecific (g_key);
+ Host::ThreadLocalStorageSet(g_key, new TimerStack);
+ timer_stack = Host::ThreadLocalStorageGet(g_key);
}
return (TimerStack *)timer_stack;
}
@@ -71,8 +72,7 @@ void
Timer::Initialize ()
{
Timer::g_file = stdout;
- ::pthread_key_create (&g_key, ThreadSpecificCleanup);
-
+ g_key = Host::ThreadLocalStorageCreate(ThreadSpecificCleanup);
}
Timer::Timer (const char *category, const char *format, ...) :
Modified: lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp (original)
+++ lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp Fri Aug 23 07:44:05 2013
@@ -1237,6 +1237,7 @@ lldb_private::formatters::GetOSXEpoch ()
static time_t epoch = 0;
if (!epoch)
{
+#ifndef _WIN32
tzset();
tm tm_epoch;
tm_epoch.tm_sec = 0;
@@ -1249,6 +1250,7 @@ lldb_private::formatters::GetOSXEpoch ()
tm_epoch.tm_gmtoff = 0;
tm_epoch.tm_zone = NULL;
epoch = timegm(&tm_epoch);
+#endif
}
return epoch;
}
Modified: lldb/trunk/source/Expression/IRMemoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRMemoryMap.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRMemoryMap.cpp (original)
+++ lldb/trunk/source/Expression/IRMemoryMap.cpp Fri Aug 23 07:44:05 2013
@@ -74,15 +74,15 @@ IRMemoryMap::FindSpace (size_t size)
{
case 4:
{
- uint32_t random_data = random();
+ uint32_t random_data = rand();
candidate = random_data;
candidate &= ~0xfffull;
break;
}
case 8:
{
- uint32_t random_low = random();
- uint32_t random_high = random();
+ uint32_t random_low = rand();
+ uint32_t random_high = rand();
candidate = random_high;
candidate <<= 32ull;
candidate |= random_low;
Modified: lldb/trunk/source/Host/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/CMakeLists.txt?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Host/CMakeLists.txt (original)
+++ lldb/trunk/source/Host/CMakeLists.txt Fri Aug 23 07:44:05 2013
@@ -6,6 +6,6 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "Linux
add_subdirectory(linux)
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_subdirectory(freebsd)
-#elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
-# add_subdirectory(windows)
+elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
+ add_subdirectory(windows)
endif()
Modified: lldb/trunk/source/Host/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/Makefile?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Host/Makefile (original)
+++ lldb/trunk/source/Host/Makefile Fri Aug 23 07:44:05 2013
@@ -25,4 +25,8 @@ ifneq (,$(filter $(HOST_OS), FreeBSD GNU
DIRS += freebsd
endif
+ifeq ($(HOST_OS),MingW)
+DIRS += windows
+endif
+
include $(LLDB_LEVEL)/Makefile
Modified: lldb/trunk/source/Host/common/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/CMakeLists.txt?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/CMakeLists.txt (original)
+++ lldb/trunk/source/Host/common/CMakeLists.txt Fri Aug 23 07:44:05 2013
@@ -7,6 +7,7 @@ add_lldb_library(lldbHostCommon
FileSpec.cpp
Host.cpp
Mutex.cpp
+ ProcessRunLock.cpp
SocketAddress.cpp
Symbols.cpp
Terminal.cpp
Modified: lldb/trunk/source/Host/common/Condition.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Condition.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Condition.cpp (original)
+++ lldb/trunk/source/Host/common/Condition.cpp Fri Aug 23 07:44:05 2013
@@ -15,6 +15,8 @@
using namespace lldb_private;
+#ifndef _WIN32
+
//----------------------------------------------------------------------
// Default constructor
//
@@ -47,15 +49,6 @@ Condition::Broadcast ()
}
//----------------------------------------------------------------------
-// Get accessor to the pthread condition object
-//----------------------------------------------------------------------
-pthread_cond_t *
-Condition::GetCondition ()
-{
- return &m_condition;
-}
-
-//----------------------------------------------------------------------
// Unblocks one thread waiting for the condition variable
//----------------------------------------------------------------------
int
@@ -64,6 +57,11 @@ Condition::Signal ()
return ::pthread_cond_signal (&m_condition);
}
+/* convert struct timeval to ms(milliseconds) */
+static unsigned long int tv2ms(struct timeval a) {
+ return ((a.tv_sec * 1000) + (a.tv_usec / 1000));
+}
+
//----------------------------------------------------------------------
// The Wait() function atomically blocks the current thread
// waiting on the owned condition variable, and unblocks the mutex
@@ -100,7 +98,16 @@ Condition::Wait (Mutex &mutex, const Tim
*timed_out = false;
}
-
return err;
}
+#endif
+
+//----------------------------------------------------------------------
+// Get accessor to the pthread condition object
+//----------------------------------------------------------------------
+lldb::condition_t *
+Condition::GetCondition()
+{
+ return &m_condition;
+}
Modified: lldb/trunk/source/Host/common/File.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/File.cpp (original)
+++ lldb/trunk/source/Host/common/File.cpp Fri Aug 23 07:44:05 2013
@@ -16,6 +16,10 @@
#include <stdarg.h>
#include <sys/stat.h>
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#endif
+
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/Config.h"
@@ -167,7 +171,11 @@ File::Duplicate (const File &rhs)
if (rhs.DescriptorIsValid())
{
+#ifdef _WIN32
+ m_descriptor = ::_dup(rhs.GetDescriptor());
+#else
m_descriptor = ::fcntl(rhs.GetDescriptor(), F_DUPFD);
+#endif
if (!DescriptorIsValid())
error.SetErrorToErrno();
else
@@ -217,8 +225,12 @@ File::Open (const char *path, uint32_t o
oflag |= O_RDONLY;
}
+#ifndef _WIN32
if (options & eOpenOptionNonBlocking)
oflag |= O_NONBLOCK;
+#else
+ oflag |= O_BINARY;
+#endif
mode_t mode = 0;
if (oflag & O_CREAT)
@@ -226,12 +238,14 @@ File::Open (const char *path, uint32_t o
if (permissions & ePermissionsUserRead) mode |= S_IRUSR;
if (permissions & ePermissionsUserWrite) mode |= S_IWUSR;
if (permissions & ePermissionsUserExecute) mode |= S_IXUSR;
+#ifndef _WIN32
if (permissions & ePermissionsGroupRead) mode |= S_IRGRP;
if (permissions & ePermissionsGroupWrite) mode |= S_IWGRP;
if (permissions & ePermissionsGroupExecute) mode |= S_IXGRP;
if (permissions & ePermissionsWorldRead) mode |= S_IROTH;
if (permissions & ePermissionsWorldWrite) mode |= S_IWOTH;
if (permissions & ePermissionsWorldExecute) mode |= S_IXOTH;
+#endif
}
do
@@ -452,6 +466,11 @@ File::Sync ()
Error error;
if (DescriptorIsValid())
{
+#ifdef _WIN32
+ int err = FlushFileBuffers((HANDLE)_get_osfhandle(m_descriptor));
+ if (err == 0)
+ error.SetErrorToGenericError();
+#else
int err = 0;
do
{
@@ -460,6 +479,7 @@ File::Sync ()
if (err == -1)
error.SetErrorToErrno();
+#endif
}
else
{
@@ -559,6 +579,7 @@ File::Write (const void *buf, size_t &nu
Error
File::Read (void *buf, size_t &num_bytes, off_t &offset)
{
+#ifndef _WIN32
Error error;
int fd = GetDescriptor();
if (fd != kInvalidDescriptor)
@@ -586,6 +607,14 @@ File::Read (void *buf, size_t &num_bytes
error.SetErrorString("invalid file handle");
}
return error;
+#else
+ long cur = ::lseek(m_descriptor, 0, SEEK_CUR);
+ SeekFromStart(offset);
+ Error error = Read(buf, num_bytes);
+ if (!error.Fail())
+ SeekFromStart(cur);
+ return error;
+#endif
}
Error
@@ -648,6 +677,7 @@ File::Write (const void *buf, size_t &nu
int fd = GetDescriptor();
if (fd != kInvalidDescriptor)
{
+#ifndef _WIN32
ssize_t bytes_written = -1;
do
{
@@ -664,6 +694,17 @@ File::Write (const void *buf, size_t &nu
offset += bytes_written;
num_bytes = bytes_written;
}
+#else
+ long cur = ::lseek(m_descriptor, 0, SEEK_CUR);
+ error = Write(buf, num_bytes);
+ long after = ::lseek(m_descriptor, 0, SEEK_CUR);
+
+ if (!error.Fail())
+ SeekFromStart(cur);
+
+ ssize_t bytes_written = after - cur;
+ offset = after;
+#endif
}
else
{
Modified: lldb/trunk/source/Host/common/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSpec.cpp (original)
+++ lldb/trunk/source/Host/common/FileSpec.cpp Fri Aug 23 07:44:05 2013
@@ -8,7 +8,11 @@
//===----------------------------------------------------------------------===//
+#ifndef _WIN32
#include <dirent.h>
+#else
+#include "lldb/Host/windows/windows.h"
+#endif
#include <fcntl.h>
#include <libgen.h>
#include <sys/stat.h>
@@ -616,10 +620,12 @@ FileSpec::GetFileType () const
switch (file_type)
{
case S_IFDIR: return eFileTypeDirectory;
- case S_IFIFO: return eFileTypePipe;
case S_IFREG: return eFileTypeRegular;
+#ifndef _WIN32
+ case S_IFIFO: return eFileTypePipe;
case S_IFSOCK: return eFileTypeSocket;
case S_IFLNK: return eFileTypeSymbolicLink;
+#endif
default:
break;
}
@@ -907,7 +913,94 @@ FileSpec::EnumerateDirectory
{
if (dir_path && dir_path[0])
{
- lldb_utility::CleanUp <DIR *, int> dir_path_dir (opendir(dir_path), NULL, closedir);
+#if _WIN32
+ char szDir[MAX_PATH];
+ strcpy_s(szDir, MAX_PATH, dir_path);
+ strcat_s(szDir, MAX_PATH, "\\*");
+
+ WIN32_FIND_DATA ffd;
+ HANDLE hFind = FindFirstFile(szDir, &ffd);
+
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ return eEnumerateDirectoryResultNext;
+ }
+
+ do
+ {
+ bool call_callback = false;
+ FileSpec::FileType file_type = eFileTypeUnknown;
+ if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ size_t len = strlen(ffd.cFileName);
+
+ if (len == 1 && ffd.cFileName[0] == '.')
+ continue;
+
+ if (len == 2 && ffd.cFileName[0] == '.' && ffd.cFileName[1] == '.')
+ continue;
+
+ file_type = eFileTypeDirectory;
+ call_callback = find_directories;
+ }
+ else if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DEVICE)
+ {
+ file_type = eFileTypeOther;
+ call_callback = find_other;
+ }
+ else
+ {
+ file_type = eFileTypeRegular;
+ call_callback = find_files;
+ }
+ if (call_callback)
+ {
+ char child_path[MAX_PATH];
+ const int child_path_len = ::snprintf (child_path, sizeof(child_path), "%s\\%s", dir_path, ffd.cFileName);
+ if (child_path_len < (int)(sizeof(child_path) - 1))
+ {
+ // Don't resolve the file type or path
+ FileSpec child_path_spec (child_path, false);
+
+ EnumerateDirectoryResult result = callback (callback_baton, file_type, child_path_spec);
+
+ switch (result)
+ {
+ case eEnumerateDirectoryResultNext:
+ // Enumerate next entry in the current directory. We just
+ // exit this switch and will continue enumerating the
+ // current directory as we currently are...
+ break;
+
+ case eEnumerateDirectoryResultEnter: // Recurse into the current entry if it is a directory or symlink, or next if not
+ if (FileSpec::EnumerateDirectory(child_path,
+ find_directories,
+ find_files,
+ find_other,
+ callback,
+ callback_baton) == eEnumerateDirectoryResultQuit)
+ {
+ // The subdirectory returned Quit, which means to
+ // stop all directory enumerations at all levels.
+ return eEnumerateDirectoryResultQuit;
+ }
+ break;
+
+ case eEnumerateDirectoryResultExit: // Exit from the current directory at the current level.
+ // Exit from this directory level and tell parent to
+ // keep enumerating.
+ return eEnumerateDirectoryResultNext;
+
+ case eEnumerateDirectoryResultQuit: // Stop directory enumerations at any level
+ return eEnumerateDirectoryResultQuit;
+ }
+ }
+ }
+ } while (FindNextFile(hFind, &ffd) != 0);
+
+ FindClose(hFind);
+#else
+ lldb_utility::CleanUp <DIR *, int> dir_path_dir(opendir(dir_path), NULL, closedir);
if (dir_path_dir.is_valid())
{
long path_max = fpathconf (dirfd (dir_path_dir.get()), _PC_NAME_MAX);
@@ -1006,6 +1099,7 @@ FileSpec::EnumerateDirectory
free (buf);
}
}
+#endif
}
// By default when exiting a directory, we tell the parent enumeration
// to continue enumerating.
Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Fri Aug 23 07:44:05 2013
@@ -10,15 +10,21 @@
#include "lldb/lldb-python.h"
// C includes
-#include <dlfcn.h>
#include <errno.h>
-#include <grp.h>
#include <limits.h>
+#include <sys/types.h>
+#include <unistd.h>
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#include <winsock2.h>
+#include <WS2tcpip.h>
+#else
+#include <dlfcn.h>
+#include <grp.h>
#include <netdb.h>
#include <pwd.h>
-#include <sys/types.h>
#include <sys/sysctl.h>
-#include <unistd.h>
+#endif
#if defined (__APPLE__)
@@ -66,7 +72,7 @@ using namespace lldb;
using namespace lldb_private;
-#if !defined (__APPLE__)
+#if !defined (__APPLE__) && !defined (_WIN32)
struct MonitorInfo
{
lldb::pid_t pid; // The process ID to monitor
@@ -75,7 +81,7 @@ struct MonitorInfo
bool monitor_signals; // If true, call the callback when "pid" gets signaled.
};
-static void *
+static thread_result_t
MonitorChildProcessThreadFunction (void *arg);
lldb::thread_t
@@ -133,7 +139,7 @@ private:
int m_old_state; // Save the old cancelability state.
};
-static void *
+static thread_result_t
MonitorChildProcessThreadFunction (void *arg)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
@@ -259,6 +265,9 @@ MonitorChildProcessThreadFunction (void
return NULL;
}
+#endif // #if !defined (__APPLE__) && !defined (_WIN32)
+
+#if !defined (__APPLE__)
void
Host::SystemLog (SystemLogType type, const char *format, va_list args)
@@ -266,7 +275,7 @@ Host::SystemLog (SystemLogType type, con
vfprintf (stderr, format, args);
}
-#endif // #if !defined (__APPLE__)
+#endif
void
Host::SystemLog (SystemLogType type, const char *format, ...)
@@ -277,12 +286,6 @@ Host::SystemLog (SystemLogType type, con
va_end (args);
}
-size_t
-Host::GetPageSize()
-{
- return ::getpagesize();
-}
-
const ArchSpec &
Host::GetArchitecture (SystemDefaultArchitecture arch_kind)
{
@@ -445,6 +448,8 @@ Host::GetCurrentProcessID()
return ::getpid();
}
+#ifndef _WIN32
+
lldb::tid_t
Host::GetCurrentThreadID()
{
@@ -521,6 +526,8 @@ Host::GetSignalAsCString (int signo)
return NULL;
}
+#endif
+
void
Host::WillTerminate ()
{
@@ -563,6 +570,9 @@ struct HostThreadCreateInfo
};
static thread_result_t
+#ifdef _WIN32
+__stdcall
+#endif
ThreadCreateTrampoline (thread_arg_t arg)
{
HostThreadCreateInfo *info = (HostThreadCreateInfo *)arg;
@@ -592,7 +602,12 @@ Host::ThreadCreate
// Host::ThreadCreateTrampoline will delete this pointer for us.
HostThreadCreateInfo *info_ptr = new HostThreadCreateInfo (thread_name, thread_fptr, thread_arg);
+#ifdef _WIN32
+ thread = ::_beginthreadex(0, 0, ThreadCreateTrampoline, info_ptr, 0, NULL);
+ int err = thread <= 0 ? GetLastError() : 0;
+#else
int err = ::pthread_create (&thread, NULL, ThreadCreateTrampoline, info_ptr);
+#endif
if (err == 0)
{
if (error)
@@ -606,6 +621,8 @@ Host::ThreadCreate
return LLDB_INVALID_HOST_THREAD;
}
+#ifndef _WIN32
+
bool
Host::ThreadCancel (lldb::thread_t thread, Error *error)
{
@@ -633,6 +650,26 @@ Host::ThreadJoin (lldb::thread_t thread,
return err == 0;
}
+lldb::thread_key_t
+Host::ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback)
+{
+ pthread_key_t key;
+ ::pthread_key_create (&key, callback);
+ return key;
+}
+
+void*
+Host::ThreadLocalStorageGet(lldb::thread_key_t key)
+{
+ return ::pthread_getspecific (key);
+}
+
+void
+Host::ThreadLocalStorageSet(lldb::thread_key_t key, void *value)
+{
+ ::pthread_setspecific (key, value);
+}
+
bool
Host::SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name)
{
@@ -726,6 +763,8 @@ Host::SetShortThreadName (lldb::pid_t pi
return false;
}
+#endif
+
FileSpec
Host::GetProgramFileSpec ()
{
@@ -771,19 +810,6 @@ Host::GetProgramFileSpec ()
return g_program_filespec;
}
-FileSpec
-Host::GetModuleFileSpecForHostAddress (const void *host_addr)
-{
- FileSpec module_filespec;
- Dl_info info;
- if (::dladdr (host_addr, &info))
- {
- if (info.dli_fname)
- module_filespec.SetFile(info.dli_fname, true);
- }
- return module_filespec;
-}
-
#if !defined (__APPLE__) // see Host.mm
bool
@@ -800,6 +826,8 @@ Host::ResolveExecutableInBundle (FileSpe
}
#endif
+#ifndef _WIN32
+
// Opaque info that tracks a dynamic library that was loaded
struct DynamicLibraryInfo
{
@@ -924,6 +952,21 @@ Host::DynamicLibraryGetSymbol (void *opa
return NULL;
}
+FileSpec
+Host::GetModuleFileSpecForHostAddress (const void *host_addr)
+{
+ FileSpec module_filespec;
+ Dl_info info;
+ if (::dladdr (host_addr, &info))
+ {
+ if (info.dli_fname)
+ module_filespec.SetFile(info.dli_fname, true);
+ }
+ return module_filespec;
+}
+
+#endif
+
bool
Host::GetLLDBPath (PathType path_type, FileSpec &file_spec)
{
@@ -1175,6 +1218,8 @@ Host::GetHostname (std::string &s)
return false;
}
+#ifndef _WIN32
+
const char *
Host::GetUserName (uint32_t uid, std::string &user_name)
{
@@ -1234,22 +1279,6 @@ Host::GetGroupName (uint32_t gid, std::s
return NULL;
}
-#if !defined (__APPLE__) && !defined (__FreeBSD__) && !defined (__FreeBSD_kernel__) // see macosx/Host.mm
-bool
-Host::GetOSBuildString (std::string &s)
-{
- s.clear();
- return false;
-}
-
-bool
-Host::GetOSKernelDescription (std::string &s)
-{
- s.clear();
- return false;
-}
-#endif
-
uint32_t
Host::GetUserID ()
{
@@ -1274,6 +1303,24 @@ Host::GetEffectiveGroupID ()
return getegid();
}
+#endif
+
+#if !defined (__APPLE__) && !defined (__FreeBSD__) && !defined (__FreeBSD_kernel__) // see macosx/Host.mm
+bool
+Host::GetOSBuildString (std::string &s)
+{
+ s.clear();
+ return false;
+}
+
+bool
+Host::GetOSKernelDescription (std::string &s)
+{
+ s.clear();
+ return false;
+}
+#endif
+
#if !defined (__APPLE__) && !defined(__linux__)
uint32_t
Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos)
@@ -1441,7 +1488,7 @@ Host::RunShellCommand (const char *comma
error.SetErrorString("timed out waiting for shell command to complete");
// Kill the process since it didn't complete withint the timeout specified
- ::kill (pid, SIGKILL);
+ Kill (pid, SIGKILL);
// Wait for the monitor callback to get the message
timeout_time = TimeValue::Now();
timeout_time.OffsetWithSeconds(1);
@@ -1490,6 +1537,13 @@ Host::RunShellCommand (const char *comma
return error;
}
+#ifndef _WIN32
+
+size_t
+Host::GetPageSize()
+{
+ return ::getpagesize();
+}
uint32_t
Host::GetNumberCPUS ()
@@ -1500,14 +1554,7 @@ Host::GetNumberCPUS ()
#if defined(__APPLE__) or defined (__linux__) or defined (__FreeBSD__) or defined (__FreeBSD_kernel__)
g_num_cores = ::sysconf(_SC_NPROCESSORS_ONLN);
-
-#elif defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-
- // Header file for this might need to be included at the top of this file
- SYSTEM_INFO system_info;
- ::GetSystemInfo (&system_info);
- g_num_cores = system_info.dwNumberOfProcessors;
-
+
#else
// Assume POSIX support if a host specific case has not been supplied above
@@ -1540,7 +1587,13 @@ Host::GetNumberCPUS ()
return g_num_cores;
}
+void
+Host::Kill(lldb::pid_t pid, int signo)
+{
+ ::kill(pid, signo);
+}
+#endif
#if !defined (__APPLE__)
bool
Modified: lldb/trunk/source/Host/common/Mutex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Mutex.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Mutex.cpp (original)
+++ lldb/trunk/source/Host/common/Mutex.cpp Fri Aug 23 07:44:05 2013
@@ -10,6 +10,9 @@
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Host.h"
+#ifndef _WIN32
+#include <pthread.h>
+#endif
#include <string.h>
#include <stdio.h>
#include <unistd.h>
@@ -177,6 +180,8 @@ Mutex::Locker::TryLock (Mutex &mutex, co
return m_mutex_ptr != NULL;
}
+#ifndef _WIN32
+
//----------------------------------------------------------------------
// Default constructor.
//
@@ -253,15 +258,6 @@ Mutex::~Mutex()
}
//----------------------------------------------------------------------
-// Mutex get accessor.
-//----------------------------------------------------------------------
-pthread_mutex_t *
-Mutex::GetMutex()
-{
- return &m_mutex;
-}
-
-//----------------------------------------------------------------------
// Locks the mutex owned by this object, if the mutex is already
// locked, the calling thread will block until the mutex becomes
// available.
@@ -341,6 +337,17 @@ Mutex::Unlock()
return err;
}
+#endif
+
+//----------------------------------------------------------------------
+// Mutex get accessor.
+//----------------------------------------------------------------------
+lldb::mutex_t *
+Mutex::GetMutex()
+{
+ return &m_mutex;
+}
+
#ifdef LLDB_CONFIGURATION_DEBUG
int
TrackingMutex::Unlock ()
Added: lldb/trunk/source/Host/common/ProcessRunLock.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/ProcessRunLock.cpp?rev=189107&view=auto
==============================================================================
--- lldb/trunk/source/Host/common/ProcessRunLock.cpp (added)
+++ lldb/trunk/source/Host/common/ProcessRunLock.cpp Fri Aug 23 07:44:05 2013
@@ -0,0 +1,71 @@
+#ifndef _WIN32
+
+#include "lldb/Host/ProcessRunLock.h"
+
+namespace lldb_private {
+
+ ProcessRunLock::ProcessRunLock()
+ : m_running(false)
+ {
+ int err = ::pthread_rwlock_init(&m_rwlock, NULL); (void) err;
+ //#if LLDB_CONFIGURATION_DEBUG
+ // assert(err == 0);
+ //#endif
+ }
+
+ ProcessRunLock::~ProcessRunLock()
+ {
+ int err = ::pthread_rwlock_destroy(&m_rwlock); (void) err;
+ //#if LLDB_CONFIGURATION_DEBUG
+ // assert(err == 0);
+ //#endif
+ }
+
+ bool ProcessRunLock::ReadTryLock()
+ {
+ ::pthread_rwlock_rdlock(&m_rwlock);
+ if (m_running == false)
+ {
+ return true;
+ }
+ ::pthread_rwlock_unlock(&m_rwlock);
+ return false;
+ }
+
+ bool ProcessRunLock::ReadUnlock()
+ {
+ return ::pthread_rwlock_unlock(&m_rwlock) == 0;
+ }
+
+ bool ProcessRunLock::SetRunning()
+ {
+ ::pthread_rwlock_wrlock(&m_rwlock);
+ m_running = true;
+ ::pthread_rwlock_unlock(&m_rwlock);
+ return true;
+ }
+
+ bool ProcessRunLock::TrySetRunning()
+ {
+ bool r;
+
+ if (::pthread_rwlock_trywrlock(&m_rwlock) == 0)
+ {
+ r = !m_running;
+ m_running = true;
+ ::pthread_rwlock_unlock(&m_rwlock);
+ return r;
+ }
+ return false;
+ }
+
+ bool ProcessRunLock::SetStopped()
+ {
+ ::pthread_rwlock_wrlock(&m_rwlock);
+ m_running = false;
+ ::pthread_rwlock_unlock(&m_rwlock);
+ return true;
+ }
+}
+
+#endif
Modified: lldb/trunk/source/Host/common/Terminal.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Terminal.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Terminal.cpp (original)
+++ lldb/trunk/source/Host/common/Terminal.cpp Fri Aug 23 07:44:05 2013
@@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/Terminal.h"
-#include "lldb/Host/Config.h"
#include <fcntl.h>
#include <unistd.h>
@@ -24,6 +23,7 @@ using namespace lldb_private;
bool
Terminal::IsATerminal () const
{
+
return m_fd >= 0 && ::isatty (m_fd);
}
@@ -108,7 +108,9 @@ Terminal::SetCanonical (bool enabled)
TerminalState::TerminalState() :
m_tty(),
m_tflags(-1),
+#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
m_termios_ap(),
+#endif
m_process_group(-1)
{
}
@@ -125,7 +127,9 @@ TerminalState::Clear ()
{
m_tty.Clear();
m_tflags = -1;
+#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
m_termios_ap.reset();
+#endif
m_process_group = -1;
}
@@ -140,7 +144,9 @@ TerminalState::Save (int fd, bool save_p
m_tty.SetFileDescriptor(fd);
if (m_tty.IsATerminal())
{
+#ifndef LLDB_DISABLE_POSIX
m_tflags = ::fcntl (fd, F_GETFL, 0);
+#endif
#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
if (m_termios_ap.get() == NULL)
m_termios_ap.reset (new struct termios);
@@ -148,16 +154,20 @@ TerminalState::Save (int fd, bool save_p
if (err != 0)
m_termios_ap.reset();
#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#ifndef LLDB_DISABLE_POSIX
if (save_process_group)
m_process_group = ::tcgetpgrp (0);
else
m_process_group = -1;
+#endif
}
else
{
m_tty.Clear();
m_tflags = -1;
+#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
m_termios_ap.reset();
+#endif
m_process_group = -1;
}
return IsValid();
@@ -173,14 +183,17 @@ TerminalState::Restore () const
if (IsValid())
{
const int fd = m_tty.GetFileDescriptor();
+#ifndef LLDB_DISABLE_POSIX
if (TFlagsIsValid())
fcntl (fd, F_SETFL, m_tflags);
+#endif
#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
if (TTYStateIsValid())
tcsetattr (fd, TCSANOW, m_termios_ap.get());
#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
+#ifndef LLDB_DISABLE_POSIX
if (ProcessGroupIsValid())
{
// Save the original signal handler.
@@ -191,6 +204,7 @@ TerminalState::Restore () const
// Restore the original signal handler.
signal (SIGTTOU, saved_sigttou_callback);
}
+#endif
return true;
}
return false;
@@ -224,7 +238,11 @@ TerminalState::TFlagsIsValid() const
bool
TerminalState::TTYStateIsValid() const
{
+#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
return m_termios_ap.get() != 0;
+#else
+ return false;
+#endif
}
//----------------------------------------------------------------------
Modified: lldb/trunk/source/Host/common/TimeValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TimeValue.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/TimeValue.cpp (original)
+++ lldb/trunk/source/Host/common/TimeValue.cpp Fri Aug 23 07:44:05 2013
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/TimeValue.h"
+#include "lldb/Host/Config.h"
// C Includes
#include <stddef.h>
@@ -148,6 +149,7 @@ TimeValue::Dump (Stream *s, uint32_t wid
if (s == NULL)
return;
+#ifndef LLDB_DISABLE_POSIX
char time_buf[32];
time_t time = GetAsSecondsSinceJan1_1970();
char *time_cstr = ::ctime_r(&time, time_buf);
@@ -163,6 +165,7 @@ TimeValue::Dump (Stream *s, uint32_t wid
}
else if (width > 0)
s->Printf("%-*s", width, "");
+#endif
}
bool
Added: lldb/trunk/source/Host/windows/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/CMakeLists.txt?rev=189107&view=auto
==============================================================================
--- lldb/trunk/source/Host/windows/CMakeLists.txt (added)
+++ lldb/trunk/source/Host/windows/CMakeLists.txt Fri Aug 23 07:44:05 2013
@@ -0,0 +1,9 @@
+set(LLVM_NO_RTTI 1)
+
+add_lldb_library(lldbHostWindows
+ Host.cpp
+ ProcessRunLock.cpp
+ Mutex.cpp
+ Condition.cpp
+ Windows.cpp
+ )
Copied: lldb/trunk/source/Host/windows/Condition.cpp (from r189082, lldb/trunk/source/Host/common/Condition.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Condition.cpp?p2=lldb/trunk/source/Host/windows/Condition.cpp&p1=lldb/trunk/source/Host/common/Condition.cpp&r1=189082&r2=189107&rev=189107&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Condition.cpp (original)
+++ lldb/trunk/source/Host/windows/Condition.cpp Fri Aug 23 07:44:05 2013
@@ -24,7 +24,7 @@ using namespace lldb_private;
Condition::Condition () :
m_condition()
{
- ::pthread_cond_init (&m_condition, NULL);
+ InitializeConditionVariable(&m_condition);
}
//----------------------------------------------------------------------
@@ -34,7 +34,6 @@ Condition::Condition () :
//----------------------------------------------------------------------
Condition::~Condition ()
{
- ::pthread_cond_destroy (&m_condition);
}
//----------------------------------------------------------------------
@@ -43,16 +42,8 @@ Condition::~Condition ()
int
Condition::Broadcast ()
{
- return ::pthread_cond_broadcast (&m_condition);
-}
-
-//----------------------------------------------------------------------
-// Get accessor to the pthread condition object
-//----------------------------------------------------------------------
-pthread_cond_t *
-Condition::GetCondition ()
-{
- return &m_condition;
+ WakeAllConditionVariable(&m_condition);
+ return 0;
}
//----------------------------------------------------------------------
@@ -61,7 +52,8 @@ Condition::GetCondition ()
int
Condition::Signal ()
{
- return ::pthread_cond_signal (&m_condition);
+ WakeConditionVariable(&m_condition);
+ return 0;
}
//----------------------------------------------------------------------
@@ -80,27 +72,24 @@ Condition::Signal ()
int
Condition::Wait (Mutex &mutex, const TimeValue *abstime, bool *timed_out)
{
- int err = 0;
- do
- {
- if (abstime && abstime->IsValid())
- {
- struct timespec abstime_ts = abstime->GetAsTimeSpec();
- err = ::pthread_cond_timedwait (&m_condition, mutex.GetMutex(), &abstime_ts);
- }
- else
- err = ::pthread_cond_wait (&m_condition, mutex.GetMutex());
- } while (err == EINTR);
+ DWORD wait = INFINITE;
+ if (abstime != NULL) {
+ int wval = (*abstime - TimeValue::Now()) / 1000000;
+ if (wval < 0) wval = 0;
+
+ wait = wval;
+ }
+
+ int err = SleepConditionVariableCS(&m_condition, &mutex.m_mutex, wait);
if (timed_out != NULL)
{
- if (err == ETIMEDOUT)
+ if ((err == 0) && GetLastError() == ERROR_TIMEOUT)
*timed_out = true;
else
*timed_out = false;
}
-
- return err;
+ return err != 0;
}
Added: lldb/trunk/source/Host/windows/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Host.cpp?rev=189107&view=auto
==============================================================================
--- lldb/trunk/source/Host/windows/Host.cpp (added)
+++ lldb/trunk/source/Host/windows/Host.cpp Fri Aug 23 07:44:05 2013
@@ -0,0 +1,245 @@
+//===-- source/Host/windows/Host.cpp ----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// C Includes
+#include <stdio.h>
+#include "lldb/Host/windows/windows.h"
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Target/Process.h"
+
+#include "lldb/Host/Host.h"
+#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/DataExtractor.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+bool
+Host::GetOSVersion(uint32_t &major,
+ uint32_t &minor,
+ uint32_t &update)
+{
+ OSVERSIONINFOEX info;
+
+ ZeroMemory(&info, sizeof(OSVERSIONINFOEX));
+ info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+
+ if (GetVersionEx((LPOSVERSIONINFO) &info) == 0) {
+ return false;
+ }
+
+ major = (uint32_t) info.dwMajorVersion;
+ minor = (uint32_t) info.dwMinorVersion;
+ update = (uint32_t) info.wServicePackMajor;
+
+ return true;
+}
+
+Error
+Host::LaunchProcess (ProcessLaunchInfo &launch_info)
+{
+ Error error;
+ assert(!"Not implemented yet!!!");
+ return error;
+}
+
+lldb::DataBufferSP
+Host::GetAuxvData(lldb_private::Process *process)
+{
+ return 0;
+}
+
+std::string
+Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid)
+{
+ return std::string();
+}
+
+lldb::tid_t
+Host::GetCurrentThreadID()
+{
+ return lldb::tid_t(::GetCurrentThreadId());
+}
+
+lldb::thread_t
+Host::GetCurrentThread ()
+{
+ return lldb::thread_t(::GetCurrentThread());
+}
+
+bool
+Host::ThreadCancel (lldb::thread_t thread, Error *error)
+{
+ int err = ::TerminateThread((HANDLE)thread, 0);
+ return err == 0;
+}
+
+bool
+Host::ThreadDetach (lldb::thread_t thread, Error *error)
+{
+ return ThreadCancel(thread, error);
+}
+
+bool
+Host::ThreadJoin (lldb::thread_t thread, thread_result_t *thread_result_ptr, Error *error)
+{
+ WaitForSingleObject((HANDLE) thread, INFINITE);
+ return true;
+}
+
+lldb::thread_key_t
+Host::ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback)
+{
+ return TlsAlloc();
+}
+
+void*
+Host::ThreadLocalStorageGet(lldb::thread_key_t key)
+{
+ return ::TlsGetValue (key);
+}
+
+void
+Host::ThreadLocalStorageSet(lldb::thread_key_t key, void *value)
+{
+ ::TlsSetValue (key, value);
+}
+
+bool
+Host::SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name)
+{
+ return false;
+}
+
+bool
+Host::SetShortThreadName (lldb::pid_t pid, lldb::tid_t tid,
+ const char *thread_name, size_t len)
+{
+ return false;
+}
+
+void
+Host::Kill(lldb::pid_t pid, int signo)
+{
+ TerminateProcess((HANDLE) pid, 1);
+}
+
+uint32_t
+Host::GetNumberCPUS()
+{
+ static uint32_t g_num_cores = UINT32_MAX;
+ if (g_num_cores == UINT32_MAX)
+ {
+ SYSTEM_INFO system_info;
+ ::GetSystemInfo(&system_info);
+ g_num_cores = system_info.dwNumberOfProcessors;
+ }
+ return g_num_cores;
+}
+
+size_t
+Host::GetPageSize()
+{
+ static long g_pagesize = 0;
+ if (!g_pagesize)
+ {
+ SYSTEM_INFO systemInfo;
+ GetNativeSystemInfo(&systemInfo);
+ g_pagesize = systemInfo.dwPageSize;
+ }
+ return g_pagesize;
+}
+
+const char *
+Host::GetSignalAsCString(int signo)
+{
+ return NULL;
+}
+
+FileSpec
+Host::GetModuleFileSpecForHostAddress (const void *host_addr)
+{
+ FileSpec module_filespec;
+ return module_filespec;
+}
+
+void *
+Host::DynamicLibraryOpen(const FileSpec &file_spec, uint32_t options, Error &error)
+{
+ error.SetErrorString("not implemented");
+ return NULL;
+}
+
+Error
+Host::DynamicLibraryClose (void *opaque)
+{
+ Error error;
+ error.SetErrorString("not implemented");
+ return error;
+}
+
+void *
+Host::DynamicLibraryGetSymbol(void *opaque, const char *symbol_name, Error &error)
+{
+ error.SetErrorString("not implemented");
+ return NULL;
+}
+
+const char *
+Host::GetUserName (uint32_t uid, std::string &user_name)
+{
+ return NULL;
+}
+
+const char *
+Host::GetGroupName (uint32_t gid, std::string &group_name)
+{
+ return NULL;
+}
+
+uint32_t
+Host::GetUserID ()
+{
+ return 0;
+}
+
+uint32_t
+Host::GetGroupID ()
+{
+ return 0;
+}
+
+uint32_t
+Host::GetEffectiveUserID ()
+{
+ return 0;
+}
+
+uint32_t
+Host::GetEffectiveGroupID ()
+{
+ return 0;
+}
+
+lldb::thread_t
+Host::StartMonitoringChildProcess
+(
+ Host::MonitorChildProcessCallback callback,
+ void *callback_baton,
+ lldb::pid_t pid,
+ bool monitor_signals
+)
+{
+ return LLDB_INVALID_HOST_THREAD;
+}
\ No newline at end of file
Copied: lldb/trunk/source/Host/windows/Makefile (from r189082, lldb/trunk/tools/Makefile)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Makefile?p2=lldb/trunk/source/Host/windows/Makefile&p1=lldb/trunk/tools/Makefile&r1=189082&r2=189107&rev=189107&view=diff
==============================================================================
--- lldb/trunk/tools/Makefile (original)
+++ lldb/trunk/source/Host/windows/Makefile Fri Aug 23 07:44:05 2013
@@ -1,4 +1,4 @@
-##===- source/Makefile -------------------------------------*- Makefile -*-===##
+##===- source/Host/windows/Makefile ------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
@@ -7,7 +7,8 @@
#
##===----------------------------------------------------------------------===##
-LLDB_LEVEL := ..
-DIRS := driver lldb-platform
+LLDB_LEVEL := ../../..
+LIBRARYNAME := lldbHostWindows
+BUILD_ARCHIVE = 1
include $(LLDB_LEVEL)/Makefile
Added: lldb/trunk/source/Host/windows/Mutex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Mutex.cpp?rev=189107&view=auto
==============================================================================
--- lldb/trunk/source/Host/windows/Mutex.cpp (added)
+++ lldb/trunk/source/Host/windows/Mutex.cpp Fri Aug 23 07:44:05 2013
@@ -0,0 +1,106 @@
+//===-- Mutex.cpp -----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/Mutex.h"
+#include "lldb/Host/Host.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#if 0
+// This logging is way too verbose to enable even for a log channel.
+// This logging can be enabled by changing the "#if 0", but should be
+// reverted prior to checking in.
+#include <cstdio>
+#define DEBUG_LOG(fmt, ...) printf(fmt, ## __VA_ARGS__)
+#else
+#define DEBUG_LOG(fmt, ...)
+#endif
+
+using namespace lldb_private;
+
+//----------------------------------------------------------------------
+// Default constructor.
+//
+// Creates a pthread mutex with no attributes.
+//----------------------------------------------------------------------
+Mutex::Mutex () :
+ m_mutex()
+{
+ InitializeCriticalSection(&m_mutex);
+}
+
+//----------------------------------------------------------------------
+// Default constructor.
+//
+// Creates a pthread mutex with "type" as the mutex type.
+//----------------------------------------------------------------------
+Mutex::Mutex (Mutex::Type type) :
+ m_mutex()
+{
+ InitializeCriticalSection(&m_mutex);
+}
+
+//----------------------------------------------------------------------
+// Destructor.
+//
+// Destroys the mutex owned by this object.
+//----------------------------------------------------------------------
+Mutex::~Mutex()
+{
+ DeleteCriticalSection(&m_mutex);
+}
+
+//----------------------------------------------------------------------
+// Locks the mutex owned by this object, if the mutex is already
+// locked, the calling thread will block until the mutex becomes
+// available.
+//
+// RETURNS
+// The error code from the pthread_mutex_lock() function call.
+//----------------------------------------------------------------------
+int
+Mutex::Lock()
+{
+ DEBUG_LOG ("[%4.4" PRIx64 "/%4.4" PRIx64 "] pthread_mutex_lock (%p)...\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(), &m_mutex);
+
+ EnterCriticalSection(&m_mutex);
+ return 0;
+}
+
+//----------------------------------------------------------------------
+// Attempts to lock the mutex owned by this object without blocking.
+// If the mutex is already locked, TryLock() will not block waiting
+// for the mutex, but will return an error condition.
+//
+// RETURNS
+// The error code from the pthread_mutex_trylock() function call.
+//----------------------------------------------------------------------
+int
+Mutex::TryLock(const char *failure_message)
+{
+ return TryEnterCriticalSection(&m_mutex) == 0;
+}
+
+//----------------------------------------------------------------------
+// If the current thread holds the lock on the owned mutex, then
+// Unlock() will unlock the mutex. Calling Unlock() on this object
+// that the calling thread does not hold will result in undefined
+// behavior.
+//
+// RETURNS
+// The error code from the pthread_mutex_unlock() function call.
+//----------------------------------------------------------------------
+int
+Mutex::Unlock()
+{
+ LeaveCriticalSection(&m_mutex);
+ return 0;
+}
Added: lldb/trunk/source/Host/windows/ProcessRunLock.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/ProcessRunLock.cpp?rev=189107&view=auto
==============================================================================
--- lldb/trunk/source/Host/windows/ProcessRunLock.cpp (added)
+++ lldb/trunk/source/Host/windows/ProcessRunLock.cpp Fri Aug 23 07:44:05 2013
@@ -0,0 +1,240 @@
+#ifdef _WIN32
+
+#include "lldb/Host/ProcessRunLock.h"
+
+namespace lldb_private {
+
+ // Windows has slim read-writer lock support on Vista and higher, so we
+ // will attempt to load the APIs. If they exist, we will use them, and
+ // if not, we will fall back on critical sections. When we drop support
+ // for XP, we can stop lazy-loading these APIs and just use them directly.
+#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;
+#endif
+
+
+ typedef struct Win32RWLOCK
+ {
+ unsigned long int readlockcount;
+ HANDLE writable;
+ CRITICAL_SECTION writelock;
+ unsigned long int writelocked;
+ } Win32RWLOCK;
+
+ typedef Win32RWLOCK* PWin32RWLOCK;
+
+ static VOID (WINAPI *fpInitializeSRWLock)(PSRWLOCK lock) = NULL;
+ static VOID (WINAPI *fpAcquireSRWLockExclusive)(PSRWLOCK lock) = NULL;
+ static VOID (WINAPI *fpAcquireSRWLockShared)(PSRWLOCK lock) = NULL;
+ static VOID (WINAPI *fpReleaseSRWLockExclusive)(PSRWLOCK lock) = NULL;
+ static VOID (WINAPI *fpReleaseSRWLockShared)(PSRWLOCK lock) = NULL;
+ static BOOL (WINAPI *fpTryAcquireSRWLockExclusive)(PSRWLOCK lock) = NULL;
+ static BOOL (WINAPI *fpTryAcquireSRWLockShared)(PSRWLOCK lock) = NULL;
+
+ static bool sHasSRW = false;
+
+ static bool loadSRW()
+ {
+ static bool sChecked = false;
+ if (!sChecked)
+ {
+ sChecked = true;
+ return false;
+
+ HMODULE hLib = ::LoadLibrary(TEXT("Kernel32"));
+ if (hLib)
+ {
+ fpInitializeSRWLock =
+ (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "InitializeSRWLock");
+ fpAcquireSRWLockExclusive =
+ (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "AcquireSRWLockExclusive");
+ fpAcquireSRWLockShared =
+ (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "AcquireSRWLockShared");
+ fpReleaseSRWLockExclusive =
+ (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "ReleaseSRWLockExclusive");
+ fpReleaseSRWLockShared =
+ (VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "ReleaseSRWLockShared");
+ fpTryAcquireSRWLockExclusive =
+ (BOOL (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "TryAcquireSRWLockExclusive");
+ fpTryAcquireSRWLockShared =
+ (BOOL (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
+ "TryAcquireSRWLockShared");
+
+ ::FreeLibrary(hLib);
+
+ if (fpInitializeSRWLock != NULL) {
+ sHasSRW = true;
+ }
+ }
+ }
+ return sHasSRW;
+ }
+
+ ProcessRunLock::ProcessRunLock ()
+ : m_running(false)
+ {
+ if (loadSRW())
+ {
+ m_rwlock = calloc(1, sizeof(SRWLOCK));
+ fpInitializeSRWLock(static_cast<PSRWLOCK>(m_rwlock));
+ }
+ else
+ {
+ m_rwlock = calloc(1, sizeof(Win32RWLOCK));
+ static_cast<PWin32RWLOCK>(m_rwlock)->readlockcount = 0;
+ static_cast<PWin32RWLOCK>(m_rwlock)->writable = CreateEvent(NULL, true, true, NULL);
+ InitializeCriticalSection(&static_cast<PWin32RWLOCK>(m_rwlock)->writelock);
+ }
+ }
+
+ ProcessRunLock::~ProcessRunLock ()
+ {
+ if (!sHasSRW)
+ {
+ CloseHandle(static_cast<PWin32RWLOCK>(m_rwlock)->writable);
+ DeleteCriticalSection(&static_cast<PWin32RWLOCK>(m_rwlock)->writelock);
+ }
+ free(m_rwlock);
+ }
+
+ bool ReadLock (lldb::rwlock_t rwlock)
+ {
+ if (sHasSRW)
+ {
+ fpAcquireSRWLockShared(static_cast<PSRWLOCK>(rwlock));
+ return true;
+ }
+ else
+ {
+ EnterCriticalSection(&static_cast<PWin32RWLOCK>(rwlock)->writelock);
+ InterlockedIncrement(&static_cast<PWin32RWLOCK>(rwlock)->readlockcount);
+ ResetEvent(static_cast<PWin32RWLOCK>(rwlock)->writable);
+ LeaveCriticalSection(&static_cast<PWin32RWLOCK>(rwlock)->writelock);
+ return true;
+ }
+ }
+
+ bool ProcessRunLock::ReadTryLock ()
+ {
+ ReadLock(m_rwlock);
+ if (m_running == false)
+ return true;
+ ReadUnlock();
+ return false;
+ }
+
+ bool ProcessRunLock::ReadUnlock ()
+ {
+ if (sHasSRW)
+ {
+ fpReleaseSRWLockShared(static_cast<PSRWLOCK>(m_rwlock));
+ return true;
+ }
+ else
+ {
+ unsigned long int value = InterlockedDecrement(&static_cast<PWin32RWLOCK>(m_rwlock)->readlockcount);
+ assert(((int)value) >= 0);
+ if (value == 0)
+ SetEvent(static_cast<PWin32RWLOCK>(m_rwlock)->writable);
+ return true;
+ }
+ }
+
+ bool WriteLock(lldb::rwlock_t rwlock)
+ {
+ if (sHasSRW)
+ {
+ fpAcquireSRWLockExclusive(static_cast<PSRWLOCK>(rwlock));
+ return true;
+ }
+ else
+ {
+ EnterCriticalSection(&static_cast<PWin32RWLOCK>(rwlock)->writelock);
+ WaitForSingleObject(static_cast<PWin32RWLOCK>(rwlock)->writable, INFINITE);
+ int res = InterlockedExchange(&static_cast<PWin32RWLOCK>(rwlock)->writelocked, 1);
+ assert(res == 0);
+ return true;
+ }
+ }
+
+ bool WriteTryLock(lldb::rwlock_t rwlock)
+ {
+ if (sHasSRW)
+ {
+ return fpTryAcquireSRWLockExclusive(static_cast<PSRWLOCK>(rwlock)) != 0;
+ }
+ else
+ {
+ if (TryEnterCriticalSection(&static_cast<PWin32RWLOCK>(rwlock)->writelock)) {
+ if (WaitForSingleObject(static_cast<PWin32RWLOCK>(rwlock)->writable, 0)) {
+ LeaveCriticalSection(&static_cast<PWin32RWLOCK>(rwlock)->writelock);
+ return false;
+ }
+ int res = InterlockedExchange(&static_cast<PWin32RWLOCK>(rwlock)->writelocked, 1);
+ assert(res == 0);
+ return true;
+ }
+ return false;
+ }
+ }
+
+ bool WriteUnlock(lldb::rwlock_t rwlock)
+ {
+ if (sHasSRW)
+ {
+ fpReleaseSRWLockExclusive(static_cast<PSRWLOCK>(rwlock));
+ return true;
+ }
+ else
+ {
+ int res = InterlockedExchange(&static_cast<PWin32RWLOCK>(rwlock)->writelocked, 0);
+ if (res == 1) {
+ LeaveCriticalSection(&static_cast<PWin32RWLOCK>(rwlock)->writelock);
+ return true;
+ }
+ return false;
+ }
+ }
+
+ bool ProcessRunLock::SetRunning ()
+ {
+ WriteLock(m_rwlock);
+ m_running = true;
+ WriteUnlock(m_rwlock);
+ return true;
+ }
+
+ bool ProcessRunLock::TrySetRunning ()
+ {
+ if (WriteTryLock(m_rwlock))
+ {
+ bool r = !m_running;
+ m_running = true;
+ WriteUnlock(m_rwlock);
+ return r;
+ }
+ return false;
+ }
+
+ bool ProcessRunLock::SetStopped ()
+ {
+ WriteLock(m_rwlock);
+ m_running = false;
+ WriteUnlock(m_rwlock);
+ return true;
+ }
+}
+
+#endif
Added: lldb/trunk/source/Host/windows/Windows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Windows.cpp?rev=189107&view=auto
==============================================================================
--- lldb/trunk/source/Host/windows/Windows.cpp (added)
+++ lldb/trunk/source/Host/windows/Windows.cpp Fri Aug 23 07:44:05 2013
@@ -0,0 +1,146 @@
+//===-- Windows.cpp ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// This file provides Windows support functions
+
+#include "lldb/Host/windows/windows.h"
+#include "lldb/Host/windows/win32.h"
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
+#include <io.h>
+#include <cerrno>
+
+int vasprintf(char **ret, const char *fmt, va_list ap)
+{
+ char *buf;
+ int len;
+ size_t buflen;
+ va_list ap2;
+
+#if defined(_MSC_VER) || defined(__MINGW64)
+ ap2 = ap;
+ len = _vscprintf(fmt, ap2);
+#else
+ va_copy(ap2, ap);
+ len = vsnprintf(NULL, 0, fmt, ap2);
+#endif
+
+ if (len >= 0 && (buf = (char*) malloc ((buflen = (size_t) (len + 1)))) != NULL) {
+ len = vsnprintf(buf, buflen, fmt, ap);
+ *ret = buf;
+ } else {
+ *ret = NULL;
+ len = -1;
+ }
+
+ va_end(ap2);
+ return len;
+}
+
+char * strcasestr(const char *s, const char* find)
+{
+ char c, sc;
+ size_t len;
+
+ if ((c = *find++) != 0) {
+ c = tolower((unsigned char) c);
+ len = strlen(find);
+ do {
+ do {
+ if ((sc = *s++) == 0)
+ return 0;
+ } while ((char) tolower((unsigned char) sc) != c);
+ } while (strncasecmp(s, find, len) != 0);
+ s--;
+ }
+ return ((char *) s);
+}
+
+char* __cdecl realpath(const char * name, char * resolved)
+{
+ char *retname = NULL; /* we will return this, if we fail */
+
+ /* SUSv3 says we must set `errno = EINVAL', and return NULL,
+ * if `name' is passed as a NULL pointer.
+ */
+
+ if (name == NULL)
+ errno = EINVAL;
+
+ /* Otherwise, `name' must refer to a readable filesystem object,
+ * if we are going to resolve its absolute path name.
+ */
+
+ else if (access(name, 4) == 0)
+ {
+ /* If `name' didn't point to an existing entity,
+ * then we don't get to here; we simply fall past this block,
+ * returning NULL, with `errno' appropriately set by `access'.
+ *
+ * When we _do_ get to here, then we can use `_fullpath' to
+ * resolve the full path for `name' into `resolved', but first,
+ * check that we have a suitable buffer, in which to return it.
+ */
+
+ if ((retname = resolved) == NULL)
+ {
+ /* Caller didn't give us a buffer, so we'll exercise the
+ * option granted by SUSv3, and allocate one.
+ *
+ * `_fullpath' would do this for us, but it uses `malloc', and
+ * Microsoft's implementation doesn't set `errno' on failure.
+ * If we don't do this explicitly ourselves, then we will not
+ * know if `_fullpath' fails on `malloc' failure, or for some
+ * other reason, and we want to set `errno = ENOMEM' for the
+ * `malloc' failure case.
+ */
+
+ retname = (char*) malloc(_MAX_PATH);
+ }
+
+ /* By now, we should have a valid buffer.
+ * If we don't, then we know that `malloc' failed,
+ * so we can set `errno = ENOMEM' appropriately.
+ */
+
+ if (retname == NULL)
+ errno = ENOMEM;
+
+ /* Otherwise, when we do have a valid buffer,
+ * `_fullpath' should only fail if the path name is too long.
+ */
+
+ else if ((retname = _fullpath(retname, name, _MAX_PATH)) == NULL)
+ errno = ENAMETOOLONG;
+ }
+
+ /* By the time we get to here,
+ * `retname' either points to the required resolved path name,
+ * or it is NULL, with `errno' set appropriately, either of which
+ * is our required return condition.
+ */
+
+ if (retname != NULL)
+ {
+ // Do a LongPath<->ShortPath roundtrip so that case is resolved by OS
+ int initialLength = strlen(retname);
+ TCHAR buffer[MAX_PATH];
+ GetShortPathName(retname, buffer, MAX_PATH);
+ GetLongPathName(buffer, retname, initialLength + 1);
+
+ // Force drive to be upper case
+ if (retname[1] == ':')
+ retname[0] = toupper(retname[0]);
+ }
+
+ return retname;
+}
Modified: lldb/trunk/source/Interpreter/Args.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Args.cpp (original)
+++ lldb/trunk/source/Interpreter/Args.cpp Fri Aug 23 07:44:05 2013
@@ -10,6 +10,9 @@
#include "lldb/lldb-python.h"
// C Includes
+#ifdef _WIN32
+#define _BSD_SOURCE // Required so that getopt.h defines optreset
+#endif
#include <getopt.h>
#include <cstdlib>
// C++ Includes
Modified: lldb/trunk/source/Interpreter/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Makefile?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Makefile (original)
+++ lldb/trunk/source/Interpreter/Makefile Fri Aug 23 07:44:05 2013
@@ -11,7 +11,9 @@ LLDB_LEVEL := ../..
LIBRARYNAME := lldbInterpreter
BUILD_ARCHIVE = 1
+ifeq (,$(findstring -DLLDB_DISABLE_PYTHON,$(CXXFLAGS)))
BUILT_SOURCES := LLDBWrapPython.cpp
+endif
include $(LLDB_LEVEL)/Makefile
-include $(PROJ_OBJ_DIR)/LLDBWrapPython.cpp.d
Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp (original)
+++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp Fri Aug 23 07:44:05 2013
@@ -38,7 +38,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/StackFrame.h"
-#include <regex.h>
+#include "lldb/Core/RegularExpression.h"
using namespace lldb;
using namespace lldb_private;
@@ -369,20 +369,17 @@ public:
}
}
- if (!s_regex_compiled)
+ if (!s_regex.IsValid())
{
- ::regcomp(&s_regex, "[ \t]*([^ ^\t]+)[ \t]*([^ ^\t].*)?", REG_EXTENDED);
- s_regex_compiled = true;
+ s_regex.Compile("[ \t]*([^ ^\t]+)[ \t]*([^ ^\t].*)?", REG_EXTENDED);
}
- ::regmatch_t matches[3];
+ RegularExpression::Match matches(3);
- if (!::regexec(&s_regex, out_string, sizeof(matches) / sizeof(::regmatch_t), matches, 0))
+ if (s_regex.Execute(out_string, &matches))
{
- if (matches[1].rm_so != -1)
- m_opcode_name.assign(out_string + matches[1].rm_so, matches[1].rm_eo - matches[1].rm_so);
- if (matches[2].rm_so != -1)
- m_mnemonics.assign(out_string + matches[2].rm_so, matches[2].rm_eo - matches[2].rm_so);
+ matches.GetMatchAtIndex(out_string, 1, m_opcode_name);
+ matches.GetMatchAtIndex(out_string, 2, m_mnemonics);
}
}
}
@@ -416,12 +413,10 @@ protected:
bool m_is_valid;
bool m_using_file_addr;
- static bool s_regex_compiled;
- static ::regex_t s_regex;
+ static RegularExpression s_regex;
};
-bool InstructionLLVMC::s_regex_compiled = false;
-::regex_t InstructionLLVMC::s_regex;
+RegularExpression InstructionLLVMC::s_regex;
DisassemblerLLVMC::LLVMCDisassembler::LLVMCDisassembler (const char *triple, unsigned flavor, DisassemblerLLVMC &owner):
m_is_valid(true)
@@ -796,7 +791,7 @@ int DisassemblerLLVMC::OpInfo (uint64_t
default:
break;
case 1:
- bzero (tag_bug, sizeof(::LLVMOpInfo1));
+ memset (tag_bug, 0, sizeof(::LLVMOpInfo1));
break;
}
return 0;
Modified: lldb/trunk/source/Plugins/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Makefile?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Makefile (original)
+++ lldb/trunk/source/Plugins/Makefile Fri Aug 23 07:44:05 2013
@@ -22,6 +22,10 @@ DIRS := ABI/MacOSX-arm ABI/MacOSX-i386 A
DynamicLoader/POSIX-DYLD \
OperatingSystem/Python
+ifeq ($(HOST_OS),MingW)
+DIRS += SymbolVendor/ELF
+endif
+
ifeq ($(HOST_OS),Darwin)
DIRS += Process/MacOSX-Kernel
DIRS += DynamicLoader/MacOSX-DYLD DynamicLoader/Darwin-Kernel
Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Fri Aug 23 07:44:05 2013
@@ -9,7 +9,24 @@
#include "ObjectContainerBSDArchive.h"
+#ifdef _WIN32
+// Defines from ar, missing on Windows
+#define ARMAG "!<arch>\n"
+#define SARMAG 8
+#define ARFMAG "`\n"
+
+typedef struct ar_hdr
+{
+ char ar_name[16];
+ char ar_date[12];
+ char ar_uid[6], ar_gid[6];
+ char ar_mode[8];
+ char ar_size[10];
+ char ar_fmag[2];
+} ar_hdr;
+#else
#include <ar.h>
+#endif
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataBuffer.h"
Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Aug 23 07:44:05 2013
@@ -1545,7 +1545,7 @@ ObjectFileMachO::ParseSymtab ()
function_starts_load_command.cmd = lc.cmd;
function_starts_load_command.cmdsize = lc.cmdsize;
if (m_data.GetU32(&offset, &function_starts_load_command.dataoff, 2) == NULL) // fill in symoff, nsyms, stroff, strsize fields
- bzero (&function_starts_load_command, sizeof(function_starts_load_command));
+ memset (&function_starts_load_command, 0, sizeof(function_starts_load_command));
break;
default:
Modified: lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp Fri Aug 23 07:44:05 2013
@@ -10,10 +10,13 @@
#include "lldb/lldb-python.h"
#include "PlatformFreeBSD.h"
+#include "lldb/Host/Config.h"
// C Includes
#include <stdio.h>
+#ifndef LLDB_DISABLE_POSIX
#include <sys/utsname.h>
+#endif
// C++ Includes
// Other libraries and framework includes
@@ -636,6 +639,7 @@ PlatformFreeBSD::GetSupportedArchitectur
void
PlatformFreeBSD::GetStatus (Stream &strm)
{
+#ifndef LLDB_DISABLE_POSIX
struct utsname un;
if (uname(&un)) {
@@ -644,5 +648,7 @@ PlatformFreeBSD::GetStatus (Stream &strm
}
strm << "Host: " << un.sysname << ' ' << un.release << ' ' << un.version << '\n';
+#endif
+
Platform::GetStatus(strm);
}
Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Fri Aug 23 07:44:05 2013
@@ -10,10 +10,13 @@
#include "lldb/lldb-python.h"
#include "PlatformLinux.h"
+#include "lldb/Host/Config.h"
// C Includes
#include <stdio.h>
+#ifndef LLDB_DISABLE_POSIX
#include <sys/utsname.h>
+#endif
// C++ Includes
// Other libraries and framework includes
@@ -357,16 +360,18 @@ PlatformLinux::GetSupportedArchitectureA
void
PlatformLinux::GetStatus (Stream &strm)
{
- struct utsname un;
-
Platform::GetStatus(strm);
+#ifndef LLDB_DISABLE_POSIX
+ struct utsname un;
+
if (uname(&un))
return;
strm.Printf (" Kernel: %s\n", un.sysname);
strm.Printf (" Release: %s\n", un.release);
strm.Printf (" Version: %s\n", un.version);
+#endif
}
size_t
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Fri Aug 23 07:44:05 2013
@@ -8,9 +8,12 @@
//===----------------------------------------------------------------------===//
#include "PlatformMacOSX.h"
+#include "lldb/Host/Config.h"
// C Includes
+#ifndef LLDB_DISABLE_POSIX
#include <sys/sysctl.h>
+#endif
// C++ Includes
// Other libraries and framework includes
Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Fri Aug 23 07:44:05 2013
@@ -10,9 +10,12 @@
#include "lldb/lldb-python.h"
#include "PlatformRemoteGDBServer.h"
+#include "lldb/Host/Config.h"
// C Includes
+#ifndef LLDB_DISABLE_POSIX
#include <sys/sysctl.h>
+#endif
// C++ Includes
// Other libraries and framework includes
Modified: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Fri Aug 23 07:44:05 2013
@@ -17,8 +17,19 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
+#include "lldb/Host/Config.h"
+#ifndef LLDB_DISABLE_POSIX
#include <sys/mman.h>
+#else
+// define them
+#define PROT_NONE 0
+#define PROT_READ 1
+#define PROT_WRITE 2
+#define PROT_EXEC 4
+#define MAP_PRIVATE 2
+#define MAP_ANON 0x1000
+#endif
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Fri Aug 23 07:44:05 2013
@@ -29,10 +29,15 @@
#include "Utility/StringExtractorGDBRemote.h"
#include "ProcessGDBRemote.h"
#include "ProcessGDBRemoteLog.h"
+#include "lldb/Host/Config.h"
using namespace lldb;
using namespace lldb_private;
+#ifdef LLDB_DISABLE_POSIX
+#define SIGSTOP 17
+#endif
+
//----------------------------------------------------------------------
// GDBRemoteCommunicationClient constructor
//----------------------------------------------------------------------
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Fri Aug 23 07:44:05 2013
@@ -668,6 +668,10 @@ GDBRemoteCommunicationServer::Handle_qC
bool
GDBRemoteCommunicationServer::Handle_qLaunchGDBServer (StringExtractorGDBRemote &packet)
{
+#ifdef _WIN32
+ // No unix sockets on windows
+ return false;
+#else
// Spawn a local debugserver as a platform so we can then attach or launch
// a process...
@@ -731,6 +735,7 @@ GDBRemoteCommunicationServer::Handle_qLa
}
}
return SendErrorResponse (13);
+#endif
}
bool
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Aug 23 07:44:05 2013
@@ -8,13 +8,16 @@
//===----------------------------------------------------------------------===//
#include "lldb/lldb-python.h"
+#include "lldb/Host/Config.h"
// C Includes
#include <errno.h>
-#include <spawn.h>
#include <stdlib.h>
+#ifndef LLDB_DISABLE_POSIX
+#include <spawn.h>
#include <netinet/in.h>
#include <sys/mman.h> // for mmap
+#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
@@ -2687,7 +2690,7 @@ ProcessGDBRemote::KillDebugserverProcess
{
if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID)
{
- ::kill (m_debugserver_pid, SIGINT);
+ Host::Kill (m_debugserver_pid, SIGINT);
m_debugserver_pid = LLDB_INVALID_PROCESS_ID;
}
}
@@ -2794,7 +2797,7 @@ ProcessGDBRemote::StopAsyncThread ()
}
-void *
+thread_result_t
ProcessGDBRemote::AsyncThread (void *arg)
{
ProcessGDBRemote *process = (ProcessGDBRemote*) arg;
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Fri Aug 23 07:44:05 2013
@@ -340,7 +340,7 @@ protected:
void
StopAsyncThread ();
- static void *
+ static lldb::thread_result_t
AsyncThread (void *arg);
static bool
Modified: lldb/trunk/source/Symbol/ObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ObjectFile.cpp (original)
+++ lldb/trunk/source/Symbol/ObjectFile.cpp Fri Aug 23 07:44:05 2013
@@ -501,7 +501,7 @@ ObjectFile::ReadSectionData (const Secti
uint64_t section_dst_len = dst_len;
if (section_dst_len > section_bytes_left)
section_dst_len = section_bytes_left;
- bzero(dst, section_dst_len);
+ memset(dst, 0, section_dst_len);
return section_dst_len;
}
}
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Fri Aug 23 07:44:05 2013
@@ -663,6 +663,7 @@ ProcessLaunchInfo::FileAction::Duplicate
+#ifndef LLDB_DISABLE_POSIX
bool
ProcessLaunchInfo::FileAction::AddPosixSpawnFileAction (posix_spawn_file_actions_t *file_actions,
const FileAction *info,
@@ -733,6 +734,7 @@ ProcessLaunchInfo::FileAction::AddPosixS
}
return error.Success();
}
+#endif
Error
ProcessLaunchCommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
@@ -3968,15 +3970,15 @@ Process::HandlePrivateEvent (EventSP &ev
m_currently_handling_event.SetValue(false, eBroadcastAlways);
}
-void *
+thread_result_t
Process::PrivateStateThread (void *arg)
{
Process *proc = static_cast<Process*> (arg);
- void *result = proc->RunPrivateStateThread ();
+ thread_result_t result = proc->RunPrivateStateThread();
return result;
}
-void *
+thread_result_t
Process::RunPrivateStateThread ()
{
bool control_only = true;
Modified: lldb/trunk/source/Utility/PseudoTerminal.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/PseudoTerminal.cpp?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/source/Utility/PseudoTerminal.cpp (original)
+++ lldb/trunk/source/Utility/PseudoTerminal.cpp Fri Aug 23 07:44:05 2013
@@ -17,6 +17,21 @@
#include <sys/ioctl.h>
#endif
+#ifdef _WIN32
+#include "lldb/Host/windows/win32.h"
+// empty functions
+int posix_openpt(int flag) { return 0; }
+
+int strerror_r(int errnum, char *buf, size_t buflen) { return 0; }
+
+int unlockpt(int fd) { return 0; }
+int grantpt(int fd) { return 0; }
+char *ptsname(int fd) { return 0; }
+
+pid_t fork(void) { return 0; }
+pid_t setsid(void) { return 0; }
+#endif
+
using namespace lldb_utility;
//----------------------------------------------------------------------
Modified: lldb/trunk/tools/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/CMakeLists.txt?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/tools/CMakeLists.txt (original)
+++ lldb/trunk/tools/CMakeLists.txt Fri Aug 23 07:44:05 2013
@@ -1,4 +1,7 @@
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_subdirectory(debugserver)
endif()
-add_subdirectory(driver)
+if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
+ add_subdirectory(driver)
+endif()
+
Modified: lldb/trunk/tools/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/Makefile?rev=189107&r1=189106&r2=189107&view=diff
==============================================================================
--- lldb/trunk/tools/Makefile (original)
+++ lldb/trunk/tools/Makefile Fri Aug 23 07:44:05 2013
@@ -8,6 +8,10 @@
##===----------------------------------------------------------------------===##
LLDB_LEVEL := ..
+include $(LLDB_LEVEL)/../../Makefile.config
+
+ifneq ($(HOST_OS),MingW)
DIRS := driver lldb-platform
+endif
include $(LLDB_LEVEL)/Makefile
More information about the lldb-commits
mailing list