Commit 0bca9a7c authored by Walter Erquinigo's avatar Walter Erquinigo
Browse files

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.
parent 0f290120
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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
+3 −1
Original line number Diff line number Diff line
@@ -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
+3 −3
Original line number Diff line number Diff line
@@ -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 {
+2 −2
Original line number Diff line number Diff line
@@ -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.
+2 −0
Original line number Diff line number Diff line
@@ -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>
Loading