[lldb/Host] Use cmakedefine01 for LLDB_ENABLE_POSIX

Rename LLDB_DISABLE_POSIX to LLDB_ENABLE_POSIX and use cmakedefine01 for
consistency.
This commit is contained in:
Jonas Devlieghere 2019-12-12 10:00:45 -08:00
parent 40d72134fd
commit 3011d55f72
19 changed files with 37 additions and 35 deletions

View File

@ -24,9 +24,7 @@ check_library_exists(compression compression_encode_buffer "" HAVE_LIBCOMPRESSIO
# so that the check isn't duplicated, but we translate them into the LLDB names
# so that I don't have to change all the uses at the moment.
set(LLDB_ENABLE_TERMIOS ${HAVE_TERMIOS_H})
if(NOT UNIX)
set(LLDB_DISABLE_POSIX 1)
endif()
set(LLDB_ENABLE_POSIX NOT UNIX)
if(NOT LLDB_CONFIG_HEADER_INPUT)
set(LLDB_CONFIG_HEADER_INPUT ${LLDB_INCLUDE_ROOT}/lldb/Host/Config.h.cmake)

View File

@ -13,7 +13,6 @@
#cmakedefine01 LLDB_HAVE_EL_RFUNC_T
#cmakedefine LLDB_DISABLE_POSIX
#cmakedefine01 HAVE_SYS_TYPES_H
@ -31,6 +30,8 @@
#cmakedefine HAVE_LIBCOMPRESSION
#endif
#cmakedefine01 LLDB_ENABLE_POSIX
#cmakedefine01 LLDB_ENABLE_TERMIOS
#cmakedefine01 LLDB_ENABLE_LZMA

View File

@ -79,7 +79,7 @@ bool PseudoTerminal::OpenFirstAvailableMaster(int oflag, char *error_str,
if (error_str)
error_str[0] = '\0';
#if !defined(LLDB_DISABLE_POSIX)
#if LLDB_ENABLE_POSIX
// Open the master side of a pseudo terminal
m_master_fd = ::posix_openpt(oflag);
if (m_master_fd < 0) {
@ -193,7 +193,7 @@ lldb::pid_t PseudoTerminal::Fork(char *error_str, size_t error_len) {
if (error_str)
error_str[0] = '\0';
pid_t pid = LLDB_INVALID_PROCESS_ID;
#if !defined(LLDB_DISABLE_POSIX)
#if LLDB_ENABLE_POSIX
int flags = O_RDWR;
flags |= O_CLOEXEC;
if (OpenFirstAvailableMaster(flags, error_str, error_len)) {

View File

@ -22,7 +22,7 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/WindowsError.h"
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
#include "lldb/Host/posix/DomainSocket.h"
#include <arpa/inet.h>
@ -122,7 +122,7 @@ std::unique_ptr<Socket> Socket::Create(const SocketProtocol protocol,
std::make_unique<UDPSocket>(true, child_processes_inherit);
break;
case ProtocolUnixDomain:
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
socket_up =
std::make_unique<DomainSocket>(true, child_processes_inherit);
#else

View File

@ -20,7 +20,7 @@
#include "llvm/Support/Errno.h"
#include "llvm/Support/raw_ostream.h"
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
@ -273,7 +273,7 @@ Status TCPSocket::Accept(Socket *&conn_socket) {
// Loop until we are happy with our connection
while (!accept_connection) {
accept_loop.Run();
if (error.Fail())
return error;

View File

@ -108,7 +108,7 @@ void TerminalState::Clear() {
bool TerminalState::Save(int fd, bool save_process_group) {
m_tty.SetFileDescriptor(fd);
if (m_tty.IsATerminal()) {
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
m_tflags = ::fcntl(fd, F_GETFL, 0);
#endif
#if LLDB_ENABLE_TERMIOS
@ -118,7 +118,7 @@ bool TerminalState::Save(int fd, bool save_process_group) {
if (err != 0)
m_termios_up.reset();
#endif // #if LLDB_ENABLE_TERMIOS
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
if (save_process_group)
m_process_group = ::tcgetpgrp(0);
else
@ -138,7 +138,7 @@ bool TerminalState::Save(int fd, bool save_process_group) {
// Restore the state of the TTY using the cached values from a previous call to
// Save().
bool TerminalState::Restore() const {
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
if (IsValid()) {
const int fd = m_tty.GetFileDescriptor();
if (TFlagsIsValid())

View File

@ -11,7 +11,7 @@
#include "lldb/Host/Config.h"
#include "lldb/Utility/Log.h"
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
#include <arpa/inet.h>
#include <sys/socket.h>
#endif

View File

@ -26,7 +26,7 @@
#include <string.h>
#include <sys/types.h>
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
#include <termios.h>
#include <unistd.h>
#endif
@ -179,7 +179,7 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
// unix-abstract-connect://SOCKNAME
return UnixAbstractSocketConnect(*addr, error_ptr);
}
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
else if ((addr = GetURLAddress(path, FD_SCHEME))) {
// Just passing a native file descriptor within this current process that
// is already opened (possibly from a service or other source).

View File

@ -10,7 +10,7 @@
#include "lldb/Host/Config.h"
#include <stdio.h>
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
#include <sys/utsname.h>
#endif
@ -194,7 +194,7 @@ bool PlatformFreeBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
void PlatformFreeBSD::GetStatus(Stream &strm) {
Platform::GetStatus(strm);
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
// Display local kernel information only when we are running in host mode.
// Otherwise, we would end up printing non-FreeBSD information (when running
// on Mac OS for example).

View File

@ -10,7 +10,7 @@
#include "lldb/Host/Config.h"
#include <stdio.h>
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
#include <sys/utsname.h>
#endif
@ -199,7 +199,7 @@ bool PlatformLinux::GetSupportedArchitectureAtIndex(uint32_t idx,
void PlatformLinux::GetStatus(Stream &strm) {
Platform::GetStatus(strm);
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
// Display local kernel information only when we are running in host mode.
// Otherwise, we would end up printing non-Linux information (when running on
// Mac OS for example).

View File

@ -10,7 +10,7 @@
#include "lldb/Host/Config.h"
#include <stdio.h>
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
#include <sys/utsname.h>
#endif
@ -168,7 +168,7 @@ bool PlatformNetBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
void PlatformNetBSD::GetStatus(Stream &strm) {
Platform::GetStatus(strm);
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
// Display local kernel information only when we are running in host mode.
// Otherwise, we would end up printing non-NetBSD information (when running
// on Mac OS for example).

View File

@ -10,7 +10,7 @@
#include "lldb/Host/Config.h"
#include <stdio.h>
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
#include <sys/utsname.h>
#endif
@ -173,7 +173,7 @@ bool PlatformOpenBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
void PlatformOpenBSD::GetStatus(Stream &strm) {
Platform::GetStatus(strm);
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
// Display local kernel information only when we are running in host mode.
// Otherwise, we would end up printing non-OpenBSD information (when running
// on Mac OS for example).

View File

@ -20,7 +20,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
#include <sys/mman.h>
#else
// define them

View File

@ -429,7 +429,7 @@ GDBRemoteCommunicationServerCommon::Handle_qsProcessInfo(
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qUserName(
StringExtractorGDBRemote &packet) {
#if !defined(LLDB_DISABLE_POSIX)
#if LLDB_ENABLE_POSIX
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
LLDB_LOGF(log, "GDBRemoteCommunicationServerCommon::%s begin", __FUNCTION__);
@ -452,7 +452,7 @@ GDBRemoteCommunicationServerCommon::Handle_qUserName(
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qGroupName(
StringExtractorGDBRemote &packet) {
#if !defined(LLDB_DISABLE_POSIX)
#if LLDB_ENABLE_POSIX
// Packet format: "qGroupName:%i" where %i is the gid
packet.SetFilePos(::strlen("qGroupName:"));
uint32_t gid = packet.GetU32(UINT32_MAX);

View File

@ -10,7 +10,7 @@
#include <errno.h>
#include <stdlib.h>
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
#include <netinet/in.h>
#include <sys/mman.h>
#include <sys/socket.h>

View File

@ -22,6 +22,7 @@
#include "LLDBServerUtilities.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
#include "lldb/Host/Config.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostGetOpt.h"
@ -237,7 +238,7 @@ void ConnectToRemote(MainLoop &mainloop,
snprintf(connection_url, sizeof(connection_url), "fd://%d", connection_fd);
// Create the connection.
#if !defined LLDB_DISABLE_POSIX && !defined _WIN32
#if LLDB_ENABLE_POSIX && !defined _WIN32
::fcntl(connection_fd, F_SETFD, FD_CLOEXEC);
#endif
connection_up.reset(new ConnectionFileDescriptor);
@ -521,7 +522,7 @@ int main_gdbserver(int argc, char *argv[]) {
printf("%s-%s\n", LLGS_PROGRAM_NAME, LLGS_VERSION_STR);
ConnectToRemote(mainloop, gdb_server, reverse_connect, host_and_port,
progname, subcommand, named_pipe_path.c_str(),
progname, subcommand, named_pipe_path.c_str(),
unnamed_pipe, connection_fd);
if (!gdb_server.IsConnected()) {

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "SocketTestUtilities.h"
#include "lldb/Host/Config.h"
#include "lldb/Utility/UriParser.h"
#include "gtest/gtest.h"
@ -87,7 +88,7 @@ TEST_F(SocketTest, DecodeHostAndPort) {
EXPECT_TRUE(error.Success());
}
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
TEST_F(SocketTest, DomainListenConnectAccept) {
llvm::SmallString<64> Path;
std::error_code EC = llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
@ -191,7 +192,7 @@ TEST_F(SocketTest, UDPGetConnectURI) {
EXPECT_EQ(scheme, "udp");
}
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
TEST_F(SocketTest, DomainGetConnectURI) {
llvm::SmallString<64> domain_path;
std::error_code EC =

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "SocketTestUtilities.h"
#include "lldb/Host/Config.h"
#include "lldb/Utility/StreamString.h"
#ifdef _WIN32
@ -82,7 +83,7 @@ bool lldb_private::CreateTCPConnectedSockets(
return true;
}
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
void lldb_private::CreateDomainConnectedSockets(
llvm::StringRef path, std::unique_ptr<DomainSocket> *socket_a_up,
std::unique_ptr<DomainSocket> *socket_b_up) {

View File

@ -21,7 +21,7 @@
#include "llvm/Support/Path.h"
#include "llvm/Testing/Support/Error.h"
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
#include "lldb/Host/posix/DomainSocket.h"
#endif
@ -34,7 +34,7 @@ void CreateConnectedSockets(
bool CreateTCPConnectedSockets(std::string listen_remote_ip,
std::unique_ptr<TCPSocket> *a_up,
std::unique_ptr<TCPSocket> *b_up);
#ifndef LLDB_DISABLE_POSIX
#if LLDB_ENABLE_POSIX
void CreateDomainConnectedSockets(llvm::StringRef path,
std::unique_ptr<DomainSocket> *a_up,
std::unique_ptr<DomainSocket> *b_up);