labath created this revision.
Herald added a subscriber: ki.stfu.

It defined a couple of types (condition_t) which we don't use anymore,
as we have c++11 goodies now. I remove these definitions.

Also it unnecessarily included a couple of headers which weren't
necessary for it's operation. I remove these, and place the includes in
the relevant files (usually .cpp, usually in Host code) which use them.
This allows us to reduce namespace pollution in most of the lldb files
which don't need the OS-specific definitions.


https://reviews.llvm.org/D35113

Files:
  include/lldb/Host/MainLoop.h
  include/lldb/Host/PosixApi.h
  include/lldb/lldb-types.h
  source/Host/common/File.cpp
  source/Host/common/Socket.cpp
  source/Host/common/TCPSocket.cpp
  source/Host/linux/Host.cpp
  source/Host/linux/HostInfoLinux.cpp
  source/Host/posix/ConnectionFileDescriptorPosix.cpp
  source/Host/posix/FileSystem.cpp
  source/Host/posix/HostProcessPosix.cpp
  source/Host/posix/LockFilePosix.cpp
  source/Host/posix/ProcessLauncherPosixFork.cpp
  source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
  source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  source/Plugins/Process/Linux/NativeProcessLinux.h
  source/Plugins/Process/Linux/NativeThreadLinux.h
  source/Plugins/Process/Linux/ProcessorTrace.h
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  source/Target/Target.cpp
  tools/driver/Driver.cpp
  tools/lldb-mi/MICmnLLDBDebugger.cpp
  tools/lldb-mi/MIDriver.cpp
  tools/lldb-mi/MIDriverMain.cpp

Index: tools/lldb-mi/MIDriverMain.cpp
===================================================================
--- tools/lldb-mi/MIDriverMain.cpp
+++ tools/lldb-mi/MIDriverMain.cpp
@@ -33,6 +33,7 @@
 
 // Third party headers:
 #include "lldb/API/SBHostOS.h"
+#include <signal.h>
 #include <stdio.h>
 
 // In house headers:
Index: tools/lldb-mi/MIDriver.cpp
===================================================================
--- tools/lldb-mi/MIDriver.cpp
+++ tools/lldb-mi/MIDriver.cpp
@@ -9,7 +9,9 @@
 
 // Third party headers:
 #include "lldb/API/SBError.h"
+#include <cassert>
 #include <fstream>
+#include <signal.h>
 
 // In-house headers:
 #include "MICmdArgValFile.h"
Index: tools/lldb-mi/MICmnLLDBDebugger.cpp
===================================================================
--- tools/lldb-mi/MICmnLLDBDebugger.cpp
+++ tools/lldb-mi/MICmnLLDBDebugger.cpp
@@ -17,6 +17,7 @@
 #include "lldb/API/SBTypeCategory.h"
 #include "lldb/API/SBTypeNameSpecifier.h"
 #include "lldb/API/SBTypeSummary.h"
+#include <cassert>
 
 // In-house headers:
 #include "MICmnLLDBDebugSessionInfo.h"
Index: tools/driver/Driver.cpp
===================================================================
--- tools/driver/Driver.cpp
+++ tools/driver/Driver.cpp
@@ -11,6 +11,7 @@
 
 #include <fcntl.h>
 #include <limits.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
Index: source/Target/Target.cpp
===================================================================
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -34,6 +34,7 @@
 #include "lldb/Expression/REPL.h"
 #include "lldb/Expression/UserExpression.h"
 #include "lldb/Host/Host.h"
+#include "lldb/Host/PosixApi.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/OptionGroupWatchpoint.h"
Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -16,6 +16,7 @@
 #include <netinet/in.h>
 #include <sys/mman.h> // for mmap
 #include <sys/socket.h>
+#include <unistd.h>
 #endif
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -40,6 +41,7 @@
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostThread.h"
+#include "lldb/Host/PosixApi.h"
 #include "lldb/Host/PseudoTerminal.h"
 #include "lldb/Host/StringConvert.h"
 #include "lldb/Host/Symbols.h"
Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -29,6 +29,7 @@
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
+#include "lldb/Host/PosixApi.h"
 #include "lldb/Host/common/NativeProcessProtocol.h"
 #include "lldb/Host/common/NativeRegisterContext.h"
 #include "lldb/Host/common/NativeThreadProtocol.h"
Index: source/Plugins/Process/Linux/ProcessorTrace.h
===================================================================
--- source/Plugins/Process/Linux/ProcessorTrace.h
+++ source/Plugins/Process/Linux/ProcessorTrace.h
@@ -18,6 +18,7 @@
 
 #include <linux/perf_event.h>
 #include <sys/mman.h>
+#include <unistd.h>
 
 namespace lldb_private {
 
Index: source/Plugins/Process/Linux/NativeThreadLinux.h
===================================================================
--- source/Plugins/Process/Linux/NativeThreadLinux.h
+++ source/Plugins/Process/Linux/NativeThreadLinux.h
@@ -16,6 +16,7 @@
 
 #include <map>
 #include <memory>
+#include <signal.h>
 #include <string>
 
 namespace lldb_private {
Index: source/Plugins/Process/Linux/NativeProcessLinux.h
===================================================================
--- source/Plugins/Process/Linux/NativeProcessLinux.h
+++ source/Plugins/Process/Linux/NativeProcessLinux.h
@@ -10,7 +10,7 @@
 #ifndef liblldb_NativeProcessLinux_H_
 #define liblldb_NativeProcessLinux_H_
 
-// C++ Includes
+#include <signal.h>
 #include <unordered_set>
 
 // Other libraries and framework includes
Index: source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
===================================================================
--- source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -23,6 +23,7 @@
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
+#include "lldb/Host/PosixApi.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/FileSpec.h"
Index: source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
===================================================================
--- source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
+++ source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
@@ -7,11 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// C Includes
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
 // C++ Includes
 // Other libraries and framework includes
 #include "lldb/Target/Process.h"
Index: source/Host/posix/ProcessLauncherPosixFork.cpp
===================================================================
--- source/Host/posix/ProcessLauncherPosixFork.cpp
+++ source/Host/posix/ProcessLauncherPosixFork.cpp
@@ -19,6 +19,7 @@
 #include <limits.h>
 #include <sys/ptrace.h>
 #include <sys/wait.h>
+#include <unistd.h>
 
 #include <sstream>
 
Index: source/Host/posix/LockFilePosix.cpp
===================================================================
--- source/Host/posix/LockFilePosix.cpp
+++ source/Host/posix/LockFilePosix.cpp
@@ -10,6 +10,7 @@
 #include "lldb/Host/posix/LockFilePosix.h"
 
 #include <fcntl.h>
+#include <unistd.h>
 
 using namespace lldb;
 using namespace lldb_private;
Index: source/Host/posix/HostProcessPosix.cpp
===================================================================
--- source/Host/posix/HostProcessPosix.cpp
+++ source/Host/posix/HostProcessPosix.cpp
@@ -14,6 +14,8 @@
 #include "llvm/ADT/STLExtras.h"
 
 #include <limits.h>
+#include <signal.h>
+#include <unistd.h>
 
 using namespace lldb_private;
 
Index: source/Host/posix/FileSystem.cpp
===================================================================
--- source/Host/posix/FileSystem.cpp
+++ source/Host/posix/FileSystem.cpp
@@ -15,6 +15,7 @@
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <unistd.h>
 #ifdef __linux__
 #include <linux/magic.h>
 #include <sys/mount.h>
Index: source/Host/posix/ConnectionFileDescriptorPosix.cpp
===================================================================
--- source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -30,6 +30,7 @@
 
 #ifndef LLDB_DISABLE_POSIX
 #include <termios.h>
+#include <unistd.h>
 #endif
 
 // C++ Includes
Index: source/Host/linux/HostInfoLinux.cpp
===================================================================
--- source/Host/linux/HostInfoLinux.cpp
+++ source/Host/linux/HostInfoLinux.cpp
@@ -16,6 +16,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <sys/utsname.h>
+#include <unistd.h>
 
 #include <algorithm>
 #include <mutex> // std::once
Index: source/Host/linux/Host.cpp
===================================================================
--- source/Host/linux/Host.cpp
+++ source/Host/linux/Host.cpp
@@ -16,6 +16,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/utsname.h>
+#include <unistd.h>
 
 // C++ Includes
 // Other libraries and framework includes
Index: source/Host/common/TCPSocket.cpp
===================================================================
--- source/Host/common/TCPSocket.cpp
+++ source/Host/common/TCPSocket.cpp
@@ -34,6 +34,7 @@
 #define CLOSE_SOCKET closesocket
 typedef const char *set_socket_option_arg_type;
 #else
+#include <unistd.h>
 #define CLOSE_SOCKET ::close
 typedef const void *set_socket_option_arg_type;
 #endif
Index: source/Host/common/Socket.cpp
===================================================================
--- source/Host/common/Socket.cpp
+++ source/Host/common/Socket.cpp
@@ -29,6 +29,7 @@
 #include <netinet/tcp.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <unistd.h>
 #endif
 
 #ifdef __linux__
Index: source/Host/common/File.cpp
===================================================================
--- source/Host/common/File.cpp
+++ source/Host/common/File.cpp
@@ -21,6 +21,7 @@
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include <termios.h>
+#include <unistd.h>
 #endif
 
 #include "llvm/Support/ConvertUTF.h"
Index: include/lldb/lldb-types.h
===================================================================
--- include/lldb/lldb-types.h
+++ include/lldb/lldb-types.h
@@ -13,16 +13,10 @@
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-forward.h"
 
-#include <assert.h>
-#include <signal.h>
 #include <stdint.h>
 
 //----------------------------------------------------------------------
 // All host systems must define:
-//  lldb::condition_t       The native condition type (or a substitute class)
-//  for conditions on the host system.
-//  lldb::mutex_t           The native mutex type for mutex objects on the host
-//  system.
 //  lldb::thread_t          The native thread type for spawned threads on the
 //  system
 //  lldb::thread_arg_t      The type of the one any only thread creation
@@ -34,32 +28,22 @@
 //  #define LLDB_INVALID_PROCESS_ID ...
 //  #define LLDB_INVALID_THREAD_ID ...
 //  #define LLDB_INVALID_HOST_THREAD ...
-//  #define IS_VALID_LLDB_HOST_THREAD ...
 //----------------------------------------------------------------------
 
 // TODO: Add a bunch of ifdefs to determine the host system and what
 // things should be defined. Currently MacOSX is being assumed by default
 // since that is what lldb was first developed for.
 
-#ifndef _MSC_VER
-#include <stdbool.h>
-#include <unistd.h>
-#endif
-
 #ifdef _WIN32
 
 #include <process.h>
 
 namespace lldb {
-typedef void *mutex_t;
-typedef void *condition_t;
 typedef void *rwlock_t;
 typedef void *process_t;             // Process type is HANDLE
 typedef void *thread_t;              // Host thread type
 typedef void *file_t;                // Host file type
-typedef void *pipe_t;                // Host pipe type
 typedef unsigned int __w64 socket_t; // Host socket type
-typedef uint32_t thread_key_t;
 typedef void *thread_arg_t;                       // Host thread argument type
 typedef unsigned thread_result_t;                 // Host thread result type
 typedef thread_result_t (*thread_func_t)(void *); // Host thread function type
@@ -73,15 +57,11 @@
 //----------------------------------------------------------------------
 // MacOSX Types
 //----------------------------------------------------------------------
-typedef ::pthread_mutex_t mutex_t;
-typedef pthread_cond_t condition_t;
 typedef pthread_rwlock_t rwlock_t;
 typedef uint64_t process_t; // Process type is just a pid.
 typedef pthread_t thread_t; // Host thread type
 typedef int file_t;         // Host file type
-typedef int pipe_t;         // Host pipe type
 typedef int socket_t;       // Host socket type
-typedef pthread_key_t thread_key_t;
 typedef void *thread_arg_t;             // Host thread argument type
 typedef void *thread_result_t;          // Host thread result type
 typedef void *(*thread_func_t)(void *); // Host thread function type
@@ -100,10 +80,6 @@
 
 #define LLDB_INVALID_PROCESS ((lldb::process_t)-1)
 #define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL)
-#define IS_VALID_LLDB_HOST_THREAD(t) ((t) != LLDB_INVALID_HOST_THREAD)
-
-#define LLDB_INVALID_HOST_TIME                                                 \
-  { 0, 0 }
 
 namespace lldb {
 typedef uint64_t addr_t;
Index: include/lldb/Host/PosixApi.h
===================================================================
--- include/lldb/Host/PosixApi.h
+++ include/lldb/Host/PosixApi.h
@@ -16,6 +16,8 @@
 
 #if defined(_WIN32)
 #include "lldb/Host/windows/PosixApi.h"
+#else
+#include <unistd.h>
 #endif
 
 #endif
Index: include/lldb/Host/MainLoop.h
===================================================================
--- include/lldb/Host/MainLoop.h
+++ include/lldb/Host/MainLoop.h
@@ -12,8 +12,8 @@
 
 #include "lldb/Host/Config.h"
 #include "lldb/Host/MainLoopBase.h"
-
 #include "llvm/ADT/DenseMap.h"
+#include <signal.h>
 
 #if !HAVE_PPOLL && !HAVE_SYS_EVENT_H
 #define SIGNAL_POLLING_UNSUPPORTED 1
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to