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.
This commit is contained in:
Walter Erquinigo 2021-01-28 09:24:30 -08:00
parent 0f2901201e
commit 0bca9a7ce2
6 changed files with 19 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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.

View File

@ -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>

View File

@ -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();