Author: Walter Erquinigo Date: 2021-01-28T09:36:13-08:00 New Revision: 0bca9a7ce2eeaa9f1d732ffbc17769560a2b236e
URL: https://github.com/llvm/llvm-project/commit/0bca9a7ce2eeaa9f1d732ffbc17769560a2b236e DIFF: https://github.com/llvm/llvm-project/commit/0bca9a7ce2eeaa9f1d732ffbc17769560a2b236e.diff LOG: Fix lldb-vscode builds on Windows targeting POSIX @stella.stamenova found out that lldb-vscode's Win32 macros were failing when building on windows targetings POSIX platforms. I'm changing these macros for LLVM_ON_UNIX, which should be more accurate. Added: Modified: lldb/tools/lldb-vscode/IOStream.cpp lldb/tools/lldb-vscode/IOStream.h lldb/tools/lldb-vscode/RunInTerminal.cpp lldb/tools/lldb-vscode/VSCode.cpp lldb/tools/lldb-vscode/VSCode.h lldb/tools/lldb-vscode/lldb-vscode.cpp Removed: ################################################################################ diff --git a/lldb/tools/lldb-vscode/IOStream.cpp b/lldb/tools/lldb-vscode/IOStream.cpp index 4b11b90b4c2e..fdbfb554aedb 100644 --- a/lldb/tools/lldb-vscode/IOStream.cpp +++ b/lldb/tools/lldb-vscode/IOStream.cpp @@ -8,7 +8,7 @@ #include "IOStream.h" -#if defined(_WIN32) +#if !LLVM_ON_UNIX #include <io.h> #else #include <netinet/in.h> @@ -33,7 +33,7 @@ StreamDescriptor::~StreamDescriptor() { return; if (m_is_socket) -#if defined(_WIN32) +#if !LLVM_ON_UNIX ::closesocket(m_socket); #else ::close(m_socket); @@ -108,7 +108,7 @@ bool InputStream::read_full(std::ofstream *log, size_t length, } if (bytes_read < 0) { int reason = 0; -#if defined(_WIN32) +#if !LLVM_ON_UNIX if (descriptor.m_is_socket) reason = WSAGetLastError(); else diff --git a/lldb/tools/lldb-vscode/IOStream.h b/lldb/tools/lldb-vscode/IOStream.h index 603ae9adcc2a..1ec7ac3ed0f9 100644 --- a/lldb/tools/lldb-vscode/IOStream.h +++ b/lldb/tools/lldb-vscode/IOStream.h @@ -9,7 +9,9 @@ #ifndef LLDB_TOOLS_LLDB_VSCODE_IOSTREAM_H #define LLDB_TOOLS_LLDB_VSCODE_IOSTREAM_H -#if defined(_WIN32) +#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX + +#if !LLVM_ON_UNIX // We need to #define NOMINMAX in order to skip `min()` and `max()` macro // definitions that conflict with other system headers. // We also need to #undef GetObject (which is defined to GetObjectW) because diff --git a/lldb/tools/lldb-vscode/RunInTerminal.cpp b/lldb/tools/lldb-vscode/RunInTerminal.cpp index 4db2806924ca..29edf5ca381d 100644 --- a/lldb/tools/lldb-vscode/RunInTerminal.cpp +++ b/lldb/tools/lldb-vscode/RunInTerminal.cpp @@ -6,7 +6,9 @@ // //===----------------------------------------------------------------------===// -#if !defined(WIN32) +#include "RunInTerminal.h" + +#if LLVM_ON_UNIX #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> @@ -21,8 +23,6 @@ #include "lldb/lldb-defines.h" -#include "RunInTerminal.h" - using namespace llvm; namespace lldb_vscode { diff --git a/lldb/tools/lldb-vscode/VSCode.cpp b/lldb/tools/lldb-vscode/VSCode.cpp index e9fdc17f4147..4d0e281c1b8d 100644 --- a/lldb/tools/lldb-vscode/VSCode.cpp +++ b/lldb/tools/lldb-vscode/VSCode.cpp @@ -14,7 +14,7 @@ #include "VSCode.h" #include "llvm/Support/FormatVariadic.h" -#if defined(_WIN32) +#if !LLVM_ON_UNIX #define NOMINMAX #include <fcntl.h> #include <io.h> @@ -41,7 +41,7 @@ VSCode::VSCode() stop_at_entry(false), is_attach(false), reverse_request_seq(0), waiting_for_run_in_terminal(false) { const char *log_file_path = getenv("LLDBVSCODE_LOG"); -#if defined(_WIN32) +#if !LLVM_ON_UNIX // Windows opens stdout and stdin in text mode which converts \n to 13,10 // while the value is just 10 on Darwin/Linux. Setting the file mode to binary // fixes this. diff --git a/lldb/tools/lldb-vscode/VSCode.h b/lldb/tools/lldb-vscode/VSCode.h index 8e7dfc078934..a2e1cac8ecf9 100644 --- a/lldb/tools/lldb-vscode/VSCode.h +++ b/lldb/tools/lldb-vscode/VSCode.h @@ -9,6 +9,8 @@ #ifndef LLDB_TOOLS_LLDB_VSCODE_VSCODE_H #define LLDB_TOOLS_LLDB_VSCODE_VSCODE_H +#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX + #include <condition_variable> #include <iosfwd> #include <map> diff --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-vscode/lldb-vscode.cpp index 69eb2e70aa6d..b7f39cbb1cb5 100644 --- a/lldb/tools/lldb-vscode/lldb-vscode.cpp +++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "VSCode.h" + #include <assert.h> #include <limits.h> #include <stdarg.h> @@ -14,7 +16,7 @@ #include <string.h> #include <sys/stat.h> #include <sys/types.h> -#if defined(_WIN32) +#if !LLVM_ON_UNIX // We need to #define NOMINMAX in order to skip `min()` and `max()` macro // definitions that conflict with other system headers. // We also need to #undef GetObject (which is defined to GetObjectW) because @@ -52,9 +54,8 @@ #include "JSONUtils.h" #include "LLDBUtils.h" -#include "VSCode.h" -#if defined(_WIN32) +#if !LLVM_ON_UNIX #ifndef PATH_MAX #define PATH_MAX MAX_PATH #endif @@ -131,7 +132,7 @@ SOCKET AcceptConnection(int portno) { *g_vsc.log << "error: accept (" << strerror(errno) << ")" << std::endl; } -#if defined(_WIN32) +#if !LLVM_ON_UNIX closesocket(sockfd); #else close(sockfd); @@ -3084,7 +3085,7 @@ int main(int argc, char *argv[]) { } } -#if !defined(_WIN32) +#if LLVM_ON_UNIX if (input_args.hasArg(OPT_wait_for_debugger)) { printf("Paused waiting for debugger to attach (pid = %i)...\n", getpid()); pause(); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits