diff options
Diffstat (limited to 'include/lldb/Host/windows')
-rw-r--r-- | include/lldb/Host/windows/AutoHandle.h | 40 | ||||
-rw-r--r-- | include/lldb/Host/windows/ConnectionGenericFileWindows.h | 68 | ||||
-rw-r--r-- | include/lldb/Host/windows/HostInfoWindows.h | 46 | ||||
-rw-r--r-- | include/lldb/Host/windows/HostProcessWindows.h | 47 | ||||
-rw-r--r-- | include/lldb/Host/windows/HostThreadWindows.h | 42 | ||||
-rw-r--r-- | include/lldb/Host/windows/LockFileWindows.h | 49 | ||||
-rw-r--r-- | include/lldb/Host/windows/PipeWindows.h | 74 | ||||
-rw-r--r-- | include/lldb/Host/windows/ProcessLauncherWindows.h | 31 | ||||
-rw-r--r-- | include/lldb/Host/windows/editlinewin.h | 123 | ||||
-rw-r--r-- | include/lldb/Host/windows/win32.h | 107 | ||||
-rw-r--r-- | include/lldb/Host/windows/windows.h | 29 |
11 files changed, 656 insertions, 0 deletions
diff --git a/include/lldb/Host/windows/AutoHandle.h b/include/lldb/Host/windows/AutoHandle.h new file mode 100644 index 000000000000..04411c47d9e2 --- /dev/null +++ b/include/lldb/Host/windows/AutoHandle.h @@ -0,0 +1,40 @@ +//===-- AutoHandle.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_Host_windows_AutoHandle_h_ +#define LLDB_lldb_Host_windows_AutoHandle_h_ + +namespace lldb_private { + +class AutoHandle { +public: + AutoHandle(HANDLE handle, HANDLE invalid_value = INVALID_HANDLE_VALUE) + : m_handle(handle) + , m_invalid_value(invalid_value) + { + } + + ~AutoHandle() + { + if (m_handle != m_invalid_value) + ::CloseHandle(m_handle); + } + + bool IsValid() const { return m_handle != m_invalid_value; } + + HANDLE get() const { return m_handle; } +private: + HANDLE m_handle; + HANDLE m_invalid_value; +}; + +} + +#endif + diff --git a/include/lldb/Host/windows/ConnectionGenericFileWindows.h b/include/lldb/Host/windows/ConnectionGenericFileWindows.h new file mode 100644 index 000000000000..bfe9b2e0c7b8 --- /dev/null +++ b/include/lldb/Host/windows/ConnectionGenericFileWindows.h @@ -0,0 +1,68 @@ +//===-- ConnectionGenericFileWindows.h --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_Host_windows_ConnectionGenericFileWindows_h_ +#define liblldb_Host_windows_ConnectionGenericFileWindows_h_ + +#include "lldb/Core/Connection.h" +#include "lldb/Host/windows/windows.h" +#include "lldb/lldb-types.h" + +namespace lldb_private +{ + +class Error; + +class ConnectionGenericFile : public lldb_private::Connection +{ + public: + ConnectionGenericFile(); + + ConnectionGenericFile(lldb::file_t file, bool owns_file); + + ~ConnectionGenericFile() override; + + bool IsConnected() const override; + + lldb::ConnectionStatus Connect(const char *s, Error *error_ptr) override; + + lldb::ConnectionStatus Disconnect(Error *error_ptr) override; + + size_t Read(void *dst, size_t dst_len, uint32_t timeout_usec, lldb::ConnectionStatus &status, Error *error_ptr) override; + + size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr) override; + + std::string GetURI() override; + + bool InterruptRead() override; + + protected: + OVERLAPPED m_overlapped; + HANDLE m_file; + HANDLE m_event_handles[2]; + bool m_owns_file; + LARGE_INTEGER m_file_position; + + enum + { + kBytesAvailableEvent, + kInterruptEvent + }; + + private: + void InitializeEventHandles(); + void IncrementFilePointer(DWORD amount); + + std::string m_uri; + + DISALLOW_COPY_AND_ASSIGN(ConnectionGenericFile); +}; +} + +#endif diff --git a/include/lldb/Host/windows/HostInfoWindows.h b/include/lldb/Host/windows/HostInfoWindows.h new file mode 100644 index 000000000000..022e15533d31 --- /dev/null +++ b/include/lldb/Host/windows/HostInfoWindows.h @@ -0,0 +1,46 @@ +//===-- HostInfoWindows.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_Host_windows_HostInfoWindows_h_ +#define lldb_Host_windows_HostInfoWindows_h_ + +#include "lldb/Host/HostInfoBase.h" +#include "lldb/Host/FileSpec.h" + +namespace lldb_private +{ + +class HostInfoWindows : public HostInfoBase +{ + friend class HostInfoBase; + + private: + // Static class, unconstructable. + HostInfoWindows(); + ~HostInfoWindows(); + + public: + static size_t GetPageSize(); + + static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update); + static bool GetOSBuildString(std::string &s); + static bool GetOSKernelDescription(std::string &s); + static bool GetHostname(std::string &s); + static FileSpec GetProgramFileSpec(); + static FileSpec GetDefaultShell(); + + protected: + static bool ComputePythonDirectory(FileSpec &file_spec); + + private: + static FileSpec m_program_filespec; +}; +} + +#endif diff --git a/include/lldb/Host/windows/HostProcessWindows.h b/include/lldb/Host/windows/HostProcessWindows.h new file mode 100644 index 000000000000..6f8ad3dc4d40 --- /dev/null +++ b/include/lldb/Host/windows/HostProcessWindows.h @@ -0,0 +1,47 @@ +//===-- HostProcessWindows.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_Host_HostProcessWindows_h_ +#define lldb_Host_HostProcessWindows_h_ + +#include "lldb/Host/HostNativeProcessBase.h" +#include "lldb/lldb-types.h" + +namespace lldb_private +{ + +class FileSpec; + +class HostProcessWindows : public HostNativeProcessBase +{ + public: + HostProcessWindows(); + explicit HostProcessWindows(lldb::process_t process); + ~HostProcessWindows(); + + void SetOwnsHandle(bool owns); + + virtual Error Terminate(); + virtual Error GetMainModule(FileSpec &file_spec) const; + + virtual lldb::pid_t GetProcessId() const; + virtual bool IsRunning() const; + + virtual HostThread StartMonitoring(HostProcess::MonitorCallback callback, void *callback_baton, bool monitor_signals); + + private: + static lldb::thread_result_t MonitorThread(void *thread_arg); + + void Close(); + + bool m_owns_handle; +}; +} + +#endif diff --git a/include/lldb/Host/windows/HostThreadWindows.h b/include/lldb/Host/windows/HostThreadWindows.h new file mode 100644 index 000000000000..e0c78c37d69a --- /dev/null +++ b/include/lldb/Host/windows/HostThreadWindows.h @@ -0,0 +1,42 @@ +//===-- HostThreadWindows.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_Host_windows_HostThreadWindows_h_ +#define lldb_Host_windows_HostThreadWindows_h_ + +#include "lldb/Host/HostNativeThreadBase.h" + +#include "llvm/ADT/SmallString.h" + +namespace lldb_private +{ + +class HostThreadWindows : public HostNativeThreadBase +{ + DISALLOW_COPY_AND_ASSIGN(HostThreadWindows); + + public: + HostThreadWindows(); + HostThreadWindows(lldb::thread_t thread); + virtual ~HostThreadWindows(); + + void SetOwnsHandle(bool owns); + + virtual Error Join(lldb::thread_result_t *result); + virtual Error Cancel(); + virtual void Reset(); + + lldb::tid_t GetThreadId() const; + + private: + bool m_owns_handle; +}; +} + +#endif diff --git a/include/lldb/Host/windows/LockFileWindows.h b/include/lldb/Host/windows/LockFileWindows.h new file mode 100644 index 000000000000..b2b8896f18c4 --- /dev/null +++ b/include/lldb/Host/windows/LockFileWindows.h @@ -0,0 +1,49 @@ +//===-- LockFileWindows.h ---------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_Host_posix_LockFileWindows_h_ +#define liblldb_Host_posix_LockFileWindows_h_ + +#include "lldb/Host/LockFileBase.h" +#include "lldb/Host/windows/windows.h" + +namespace lldb_private { + +class LockFileWindows : public LockFileBase +{ +public: + explicit LockFileWindows (int fd); + ~LockFileWindows (); + +protected: + Error + DoWriteLock (const uint64_t start, const uint64_t len) override; + + Error + DoTryWriteLock (const uint64_t start, const uint64_t len) override; + + Error + DoReadLock (const uint64_t start, const uint64_t len) override; + + Error + DoTryReadLock (const uint64_t start, const uint64_t len) override; + + Error + DoUnlock () override; + + bool + IsValidFile () const override; + +private: + HANDLE m_file; +}; + +} // namespace lldb_private + +#endif // liblldb_Host_posix_LockFileWindows_h_ diff --git a/include/lldb/Host/windows/PipeWindows.h b/include/lldb/Host/windows/PipeWindows.h new file mode 100644 index 000000000000..7170c7c36815 --- /dev/null +++ b/include/lldb/Host/windows/PipeWindows.h @@ -0,0 +1,74 @@ +//===-- PipePosix.h ---------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_Host_windows_PipeWindows_h_ +#define liblldb_Host_windows_PipeWindows_h_ + +#include "lldb/Host/PipeBase.h" +#include "lldb/Host/windows/windows.h" + +namespace lldb_private +{ + +//---------------------------------------------------------------------- +/// @class Pipe PipeWindows.h "lldb/Host/windows/PipeWindows.h" +/// @brief A windows-based implementation of Pipe, a class that abtracts +/// unix style pipes. +/// +/// A class that abstracts the LLDB core from host pipe functionality. +//---------------------------------------------------------------------- +class PipeWindows : public PipeBase +{ + public: + PipeWindows(); + ~PipeWindows() override; + + Error CreateNew(bool child_process_inherit) override; + Error CreateNew(llvm::StringRef name, bool child_process_inherit) override; + Error CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, llvm::SmallVectorImpl<char>& name) override; + Error OpenAsReader(llvm::StringRef name, bool child_process_inherit) override; + Error OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) override; + + bool CanRead() const override; + bool CanWrite() const override; + + int GetReadFileDescriptor() const override; + int GetWriteFileDescriptor() const override; + int ReleaseReadFileDescriptor() override; + int ReleaseWriteFileDescriptor() override; + void CloseReadFileDescriptor() override; + void CloseWriteFileDescriptor() override; + + void Close() override; + + Error Delete(llvm::StringRef name) override; + + Error Write(const void *buf, size_t size, size_t &bytes_written) override; + Error ReadWithTimeout(void *buf, size_t size, const std::chrono::microseconds &timeout, size_t &bytes_read) override; + + // PipeWindows specific methods. These allow access to the underlying OS handle. + HANDLE GetReadNativeHandle(); + HANDLE GetWriteNativeHandle(); + + private: + Error OpenNamedPipe(llvm::StringRef name, bool child_process_inherit, bool is_read); + + HANDLE m_read; + HANDLE m_write; + + int m_read_fd; + int m_write_fd; + + OVERLAPPED m_read_overlapped; + OVERLAPPED m_write_overlapped; +}; + +} // namespace lldb_private + +#endif // liblldb_Host_posix_PipePosix_h_ diff --git a/include/lldb/Host/windows/ProcessLauncherWindows.h b/include/lldb/Host/windows/ProcessLauncherWindows.h new file mode 100644 index 000000000000..a2fe665dcfaf --- /dev/null +++ b/include/lldb/Host/windows/ProcessLauncherWindows.h @@ -0,0 +1,31 @@ +//===-- ProcessLauncherWindows.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_Host_windows_ProcessLauncherWindows_h_ +#define lldb_Host_windows_ProcessLauncherWindows_h_ + +#include "lldb/Host/ProcessLauncher.h" +#include "lldb/Host/windows/windows.h" + +namespace lldb_private +{ + +class ProcessLaunchInfo; + +class ProcessLauncherWindows : public ProcessLauncher +{ + public: + virtual HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Error &error); + + protected: + HANDLE GetStdioHandle(const ProcessLaunchInfo &launch_info, int fd); +}; +} + +#endif diff --git a/include/lldb/Host/windows/editlinewin.h b/include/lldb/Host/windows/editlinewin.h new file mode 100644 index 000000000000..907ef373a372 --- /dev/null +++ b/include/lldb/Host/windows/editlinewin.h @@ -0,0 +1,123 @@ +//===-- ELWrapper.h ---------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#pragma once + +#include <stdio.h> + +// EditLine editor function return codes. +// For user-defined function interface +#define CC_NORM 0 +#define CC_NEWLINE 1 +#define CC_EOF 2 +#define CC_ARGHACK 3 +#define CC_REFRESH 4 +#define CC_CURSOR 5 +#define CC_ERROR 6 +#define CC_FATAL 7 +#define CC_REDISPLAY 8 +#define CC_REFRESH_BEEP 9 + +// el_set/el_get parameters +#define EL_PROMPT 0 // , el_pfunc_t +#define EL_TERMINAL 1 // , const char * +#define EL_EDITOR 2 // , const char * +#define EL_SIGNAL 3 // , int); +#define EL_BIND 4 // , const char *, ..., NULL +#define EL_TELLTC 5 // , const char *, ..., NULL +#define EL_SETTC 6 // , const char *, ..., NULL +#define EL_ECHOTC 7 // , const char *, ..., NULL +#define EL_SETTY 8 // , const char *, ..., NULL +#define EL_ADDFN 9 // , const char *, const char *, el_func_t +#define EL_HIST 10 // , hist_fun_t, const char * +#define EL_EDITMODE 11 // , int +#define EL_RPROMPT 12 // , el_pfunc_t +#define EL_GETCFN 13 // , el_rfunc_t +#define EL_CLIENTDATA 14 // , void * +#define EL_UNBUFFERED 15 // , int +#define EL_PREP_TERM 16 // , int +#define EL_GETTC 17 // , const char *, ..., NULL +#define EL_GETFP 18 // , int, FILE ** +#define EL_SETFP 19 // , int, FILE * +#define EL_REFRESH 20 // , void +#define EL_PROMPT_ESC 21 // , prompt_func, Char); set/get + +#define EL_BUILTIN_GETCFN (NULL) + +// history defines +#define H_FUNC 0 // , UTSL +#define H_SETSIZE 1 // , const int +#define H_GETSIZE 2 // , void +#define H_FIRST 3 // , void +#define H_LAST 4 // , void +#define H_PREV 5 // , void +#define H_NEXT 6 // , void +#define H_CURR 8 // , const int +#define H_SET 7 // , int +#define H_ADD 9 // , const char * +#define H_ENTER 10 // , const char * +#define H_APPEND 11 // , const char * +#define H_END 12 // , void +#define H_NEXT_STR 13 // , const char * +#define H_PREV_STR 14 // , const char * +#define H_NEXT_EVENT 15 // , const int +#define H_PREV_EVENT 16 // , const int +#define H_LOAD 17 // , const char * +#define H_SAVE 18 // , const char * +#define H_CLEAR 19 // , void +#define H_SETUNIQUE 20 // , int +#define H_GETUNIQUE 21 // , void +#define H_DEL 22 // , int + +struct EditLine +{ +}; + +struct LineInfo +{ + const char *buffer; + const char *cursor; + const char *lastchar; +}; + +struct History +{ +}; + +struct HistEvent +{ + int num; + const char *str; +}; + +extern "C" +{ + // edit line API + EditLine *el_init ( const char *, FILE *, FILE *, FILE * ); + const char *el_gets ( EditLine *, int * ); + int el_set ( EditLine *, int, ... ); + + void el_end ( EditLine * ); + void el_reset ( EditLine * ); + int el_getc ( EditLine *, char * ); + void el_push ( EditLine *, const char * ); + void el_beep ( EditLine * ); + int el_parse ( EditLine *, int, const char ** ); + int el_get ( EditLine *, int, ... ); + int el_source ( EditLine *, const char * ); + void el_resize ( EditLine * ); + const LineInfo *el_line ( EditLine * ); + int el_insertstr( EditLine *, const char * ); + void el_deletestr( EditLine *, int ); + + // history API + History *history_init( void ); + void history_end ( History * ); + int history ( History *, HistEvent *, int, ... ); +};
\ No newline at end of file diff --git a/include/lldb/Host/windows/win32.h b/include/lldb/Host/windows/win32.h new file mode 100644 index 000000000000..2789a4b84f07 --- /dev/null +++ b/include/lldb/Host/windows/win32.h @@ -0,0 +1,107 @@ +//===-- 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> +#include <time.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); + +#ifndef PATH_MAX +#define PATH_MAX 32768 +#endif + +#define O_NOCTTY 0 +#define O_NONBLOCK 0 +#define SIGTRAP 5 +#define SIGKILL 9 +#define SIGSTOP 20 + +#if defined(_MSC_VER) +# define S_IRUSR S_IREAD /* read, user */ +# define S_IWUSR S_IWRITE /* write, user */ +# define S_IXUSR 0 /* execute, user */ +#endif +#define S_IRGRP 0 /* read, group */ +#define S_IWGRP 0 /* write, group */ +#define S_IXGRP 0 /* execute, group */ +#define S_IROTH 0 /* read, others */ +#define S_IWOTH 0 /* write, others */ +#define S_IXOTH 0 /* execute, others */ +#define S_IRWXU 0 +#define S_IRWXG 0 +#define S_IRWXO 0 + +#ifdef _MSC_VER + +#include <inttypes.h> +#include <stdint.h> +#include <io.h> +typedef unsigned short mode_t; + +#ifdef LLDB_DISABLE_PYTHON +typedef uint32_t pid_t; +#endif // LLDB_DISABLE_PYTHON + +int usleep(uint32_t useconds); + +char* getcwd(char* path, int max); +int chdir(const char* path); +char* basename(char *path); +char *dirname(char *path); + +int strcasecmp(const char* s1, const char* s2); +int strncasecmp(const char* s1, const char* s2, size_t n); + +#if _MSC_VER < 1900 +namespace lldb_private { +int vsnprintf(char *buffer, size_t count, const char *format, va_list argptr); +} + +// inline to avoid linkage conflicts +int inline snprintf(char *buffer, size_t count, const char *format, ...) +{ + va_list argptr; + va_start(argptr, format); + int r = lldb_private::vsnprintf(buffer, count, format, argptr); + va_end(argptr); + return r; +} +#endif + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +#define __PRETTY_FUNCTION__ __FUNCSIG__ + +#define S_IFDIR _S_IFDIR +#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) + +#endif // _MSC_VER + +// timespec +// MSVC 2015 and higher have timespec. Otherwise we need to define it ourselves. +#if defined(_MSC_VER) && _MSC_VER >= 1900 +#include <time.h> +#else +struct timespec +{ + time_t tv_sec; + long tv_nsec; +}; +#endif + + +#endif // LLDB_lldb_win32_h_ diff --git a/include/lldb/Host/windows/windows.h b/include/lldb/Host/windows/windows.h new file mode 100644 index 000000000000..124e8de1dc90 --- /dev/null +++ b/include/lldb/Host/windows/windows.h @@ -0,0 +1,29 @@ +//===-- 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 far +#undef near +#undef FAR +#undef NEAR +#define FAR +#define NEAR + +#endif // LLDB_lldb_windows_h_ |