Index: include/lldb/Host/FileAction.h =================================================================== --- include/lldb/Host/FileAction.h +++ include/lldb/Host/FileAction.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Target_FileAction_h -#define liblldb_Target_FileAction_h +#ifndef LLDB_HOST_FILEACTION_H +#define LLDB_HOST_FILEACTION_H #include "lldb/Utility/FileSpec.h" #include Index: include/lldb/Host/ProcessLaunchInfo.h =================================================================== --- include/lldb/Host/ProcessLaunchInfo.h +++ include/lldb/Host/ProcessLaunchInfo.h @@ -16,10 +16,10 @@ // LLDB Headers #include "lldb/Utility/Flags.h" +#include "lldb/Host/FileAction.h" #include "lldb/Host/Host.h" +#include "lldb/Host/ProcessInfo.h" #include "lldb/Host/PseudoTerminal.h" -#include "lldb/Target/FileAction.h" -#include "lldb/Target/ProcessInfo.h" #include "lldb/Utility/FileSpec.h" namespace lldb_private { Index: include/lldb/Target/Process.h =================================================================== --- include/lldb/Target/Process.h +++ include/lldb/Target/Process.h @@ -29,14 +29,14 @@ #include "lldb/Core/ThreadSafeValue.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Host/HostThread.h" +#include "lldb/Host/ProcessInfo.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Host/ProcessRunLock.h" #include "lldb/Interpreter/Options.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/InstrumentationRuntime.h" #include "lldb/Target/Memory.h" -#include "lldb/Target/ProcessInfo.h" -#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/QueueList.h" #include "lldb/Target/ThreadList.h" #include "lldb/Utility/ArchSpec.h" Index: include/lldb/Target/ProcessInfo.h =================================================================== --- /dev/null +++ include/lldb/Target/ProcessInfo.h @@ -1,102 +0,0 @@ -//===-- ProcessInfo.h -------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_ProcessInfo_h_ -#define liblldb_ProcessInfo_h_ - -// LLDB headers -#include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/Args.h" -#include "lldb/Utility/Environment.h" -#include "lldb/Utility/FileSpec.h" - -namespace lldb_private { -//---------------------------------------------------------------------- -// ProcessInfo -// -// A base class for information for a process. This can be used to fill -// out information for a process prior to launching it, or it can be used for -// an instance of a process and can be filled in with the existing values for -// that process. -//---------------------------------------------------------------------- -class ProcessInfo { -public: - ProcessInfo(); - - ProcessInfo(const char *name, const ArchSpec &arch, lldb::pid_t pid); - - void Clear(); - - const char *GetName() const; - - size_t GetNameLength() const; - - FileSpec &GetExecutableFile() { return m_executable; } - - void SetExecutableFile(const FileSpec &exe_file, - bool add_exe_file_as_first_arg); - - const FileSpec &GetExecutableFile() const { return m_executable; } - - uint32_t GetUserID() const { return m_uid; } - - uint32_t GetGroupID() const { return m_gid; } - - bool UserIDIsValid() const { return m_uid != UINT32_MAX; } - - bool GroupIDIsValid() const { return m_gid != UINT32_MAX; } - - void SetUserID(uint32_t uid) { m_uid = uid; } - - void SetGroupID(uint32_t gid) { m_gid = gid; } - - ArchSpec &GetArchitecture() { return m_arch; } - - const ArchSpec &GetArchitecture() const { return m_arch; } - - void SetArchitecture(const ArchSpec &arch) { m_arch = arch; } - - lldb::pid_t GetProcessID() const { return m_pid; } - - void SetProcessID(lldb::pid_t pid) { m_pid = pid; } - - bool ProcessIDIsValid() const { return m_pid != LLDB_INVALID_PROCESS_ID; } - - void Dump(Stream &s, Platform *platform) const; - - Args &GetArguments() { return m_arguments; } - - const Args &GetArguments() const { return m_arguments; } - - llvm::StringRef GetArg0() const; - - void SetArg0(llvm::StringRef arg); - - void SetArguments(const Args &args, bool first_arg_is_executable); - - void SetArguments(char const **argv, bool first_arg_is_executable); - - Environment &GetEnvironment() { return m_environment; } - const Environment &GetEnvironment() const { return m_environment; } - -protected: - FileSpec m_executable; - std::string m_arg0; // argv[0] if supported. If empty, then use m_executable. - // Not all process plug-ins support specifying an argv[0] that differs from - // the resolved platform executable (which is in m_executable) - Args m_arguments; // All program arguments except argv[0] - Environment m_environment; - uint32_t m_uid; - uint32_t m_gid; - ArchSpec m_arch; - lldb::pid_t m_pid; -}; -} - -#endif // #ifndef liblldb_ProcessInfo_h_ Index: include/lldb/Target/Target.h =================================================================== --- include/lldb/Target/Target.h +++ include/lldb/Target/Target.h @@ -24,10 +24,10 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Expression/Expression.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/PathMappingList.h" -#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/SectionLoadHistory.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Broadcaster.h" Index: include/lldb/module.modulemap =================================================================== --- include/lldb/module.modulemap +++ include/lldb/module.modulemap @@ -17,6 +17,7 @@ module Editline { header "Host/Editline.h" export * } module FileCache { header "Host/FileCache.h" export * } module File { header "Host/File.h" export * } + module FileAction { header "Host/FileAction.h" export * } module FileSystem { header "Host/FileSystem.h" export * } module HostGetOpt { header "Host/HostGetOpt.h" export * } module Host { header "Host/Host.h" export * } @@ -38,7 +39,9 @@ module PipeBase { header "Host/PipeBase.h" export * } module Pipe { header "Host/Pipe.h" export * } module PosixApi { header "Host/PosixApi.h" export * } + module ProcessInfo { header "Host/ProcessInfo.h" export * } module ProcessLauncher { header "Host/ProcessLauncher.h" export * } + module ProcessLaunchInfo { header "Host/ProcessLaunchInfo.h" export * } module ProcessRunLock { header "Host/ProcessRunLock.h" export * } module PseudoTerminal { header "Host/PseudoTerminal.h" export * } module SafeMachO { header "Host/SafeMachO.h" export * } Index: source/API/SBLaunchInfo.cpp =================================================================== --- source/API/SBLaunchInfo.cpp +++ source/API/SBLaunchInfo.cpp @@ -11,7 +11,7 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBListener.h" -#include "lldb/Target/ProcessLaunchInfo.h" +#include "lldb/Host/ProcessLaunchInfo.h" using namespace lldb; using namespace lldb_private; Index: source/Host/CMakeLists.txt =================================================================== --- source/Host/CMakeLists.txt +++ source/Host/CMakeLists.txt @@ -19,6 +19,7 @@ add_host_subdirectory(common common/File.cpp + common/FileAction.cpp common/FileCache.cpp common/FileSystem.cpp common/GetOptInc.cpp @@ -36,6 +37,8 @@ common/NativeThreadProtocol.cpp common/OptionParser.cpp common/PipeBase.cpp + common/ProcessInfo.cpp + common/ProcessLaunchInfo.cpp common/ProcessRunLock.cpp common/PseudoTerminal.cpp common/Socket.cpp Index: source/Host/common/FileAction.cpp =================================================================== --- source/Host/common/FileAction.cpp +++ source/Host/common/FileAction.cpp @@ -9,8 +9,8 @@ #include +#include "lldb/Host/FileAction.h" #include "lldb/Host/PosixApi.h" -#include "lldb/Target/FileAction.h" #include "lldb/Utility/Stream.h" using namespace lldb_private; Index: source/Host/common/Host.cpp =================================================================== --- source/Host/common/Host.cpp +++ source/Host/common/Host.cpp @@ -47,16 +47,16 @@ #include +#include "lldb/Host/FileAction.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/HostProcess.h" #include "lldb/Host/MonitoringProcessLauncher.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Host/ProcessLauncher.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Host/posix/ConnectionFileDescriptorPosix.h" -#include "lldb/Target/FileAction.h" -#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/UnixSignals.h" #include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/FileSpec.h" Index: source/Host/common/MonitoringProcessLauncher.cpp =================================================================== --- source/Host/common/MonitoringProcessLauncher.cpp +++ source/Host/common/MonitoringProcessLauncher.cpp @@ -10,7 +10,7 @@ #include "lldb/Host/MonitoringProcessLauncher.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostProcess.h" -#include "lldb/Target/ProcessLaunchInfo.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Utility/Log.h" #include "llvm/Support/FileSystem.h" Index: source/Host/common/ProcessInfo.cpp =================================================================== --- source/Host/common/ProcessInfo.cpp +++ source/Host/common/ProcessInfo.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ProcessInfo.h" +#include "lldb/Host/ProcessInfo.h" #include Index: source/Host/common/ProcessLaunchInfo.cpp =================================================================== --- source/Host/common/ProcessLaunchInfo.cpp +++ source/Host/common/ProcessLaunchInfo.cpp @@ -10,10 +10,10 @@ #include #include "lldb/Host/Config.h" +#include "lldb/Host/FileAction.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" -#include "lldb/Target/FileAction.h" -#include "lldb/Target/ProcessLaunchInfo.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" Index: source/Host/macosx/objcxx/Host.mm =================================================================== --- source/Host/macosx/objcxx/Host.mm +++ source/Host/macosx/objcxx/Host.mm @@ -57,9 +57,9 @@ #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Target/Process.h" -#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/CleanUp.h" #include "lldb/Utility/DataBufferHeap.h" Index: source/Host/posix/ProcessLauncherPosixFork.cpp =================================================================== --- source/Host/posix/ProcessLauncherPosixFork.cpp +++ source/Host/posix/ProcessLauncherPosixFork.cpp @@ -11,7 +11,7 @@ #include "lldb/Host/Host.h" #include "lldb/Host/HostProcess.h" #include "lldb/Host/Pipe.h" -#include "lldb/Target/ProcessLaunchInfo.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "llvm/Support/Errno.h" Index: source/Host/windows/ProcessLauncherWindows.cpp =================================================================== --- source/Host/windows/ProcessLauncherWindows.cpp +++ source/Host/windows/ProcessLauncherWindows.cpp @@ -9,7 +9,7 @@ #include "lldb/Host/windows/ProcessLauncherWindows.h" #include "lldb/Host/HostProcess.h" -#include "lldb/Target/ProcessLaunchInfo.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/ConvertUTF.h" Index: source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm =================================================================== --- source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm +++ source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm @@ -17,7 +17,7 @@ #include // Project includes #include "lldb/Host/PseudoTerminal.h" -#include "lldb/Target/FileAction.h" +#include "lldb/Host/FileAction.h" #include "llvm/ADT/StringRef.h" Index: source/Plugins/Platform/POSIX/PlatformPOSIX.cpp =================================================================== --- source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -9,7 +9,6 @@ #include "PlatformPOSIX.h" - #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" @@ -23,11 +22,11 @@ #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" -#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/CleanUp.h" #include "lldb/Utility/DataBufferHeap.h" Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp =================================================================== --- source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -24,6 +24,7 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostProcess.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Host/PseudoTerminal.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Host/common/NativeRegisterContext.h" @@ -32,7 +33,6 @@ #include "lldb/Host/posix/ProcessLauncherPosixFork.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/Process.h" -#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/Target.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/RegisterValue.h" Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -22,13 +22,13 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Host/Config.h" #include "lldb/Host/File.h" +#include "lldb/Host/FileAction.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/SafeMachO.h" #include "lldb/Interpreter/OptionArgParser.h" #include "lldb/Symbol/ObjectFile.h" -#include "lldb/Target/FileAction.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Utility/Endian.h" Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -21,6 +21,7 @@ #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/Debug.h" #include "lldb/Host/File.h" +#include "lldb/Host/FileAction.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" @@ -28,7 +29,6 @@ #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Host/common/NativeRegisterContext.h" #include "lldb/Host/common/NativeThreadProtocol.h" -#include "lldb/Target/FileAction.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/DataBuffer.h" Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -22,9 +22,9 @@ #include "lldb/Host/Config.h" #include "lldb/Host/ConnectionFileDescriptor.h" +#include "lldb/Host/FileAction.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" -#include "lldb/Target/FileAction.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/UnixSignals.h" Index: source/Target/CMakeLists.txt =================================================================== --- source/Target/CMakeLists.txt +++ source/Target/CMakeLists.txt @@ -2,7 +2,6 @@ ABI.cpp CPPLanguageRuntime.cpp ExecutionContext.cpp - FileAction.cpp JITLoader.cpp JITLoaderList.cpp InstrumentationRuntime.cpp @@ -17,8 +16,6 @@ PathMappingList.cpp Platform.cpp Process.cpp - ProcessInfo.cpp - ProcessLaunchInfo.cpp Queue.cpp QueueItem.cpp QueueList.cpp Index: unittests/Host/CMakeLists.txt =================================================================== --- unittests/Host/CMakeLists.txt +++ unittests/Host/CMakeLists.txt @@ -1,9 +1,12 @@ set (FILES + FileActionTest.cpp FileSystemTest.cpp HostInfoTest.cpp HostTest.cpp MainLoopTest.cpp NativeProcessProtocolTest.cpp + ProcessInfoTest.cpp + ProcessLaunchInfoTest.cpp SocketAddressTest.cpp SocketTest.cpp SymbolsTest.cpp Index: unittests/Host/FileActionTest.cpp =================================================================== --- /dev/null +++ unittests/Host/FileActionTest.cpp @@ -0,0 +1,20 @@ +//===-- FileActionTest.cpp --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Host/FileAction.h" +#include "gtest/gtest.h" + +using namespace lldb_private; + +TEST(FileActionTest, Open) { + FileAction Action; + Action.Open(47, FileSpec("/tmp"), /*read*/ true, /*write*/ false); + EXPECT_EQ(Action.GetAction(), FileAction::eFileActionOpen); + EXPECT_EQ(Action.GetFileSpec(), FileSpec("/tmp")); +} Index: unittests/Host/ProcessInfoTest.cpp =================================================================== --- /dev/null +++ unittests/Host/ProcessInfoTest.cpp @@ -0,0 +1,20 @@ +//===-- ProcessInfoTest.cpp -------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Host/ProcessInfo.h" +#include "gtest/gtest.h" + +using namespace lldb_private; + +TEST(ProcessInfoTest, Constructor) { + ProcessInfo Info("foo", ArchSpec("x86_64-pc-linux"), 47); + EXPECT_STREQ("foo", Info.GetName()); + EXPECT_EQ(ArchSpec("x86_64-pc-linux"), Info.GetArchitecture()); + EXPECT_EQ(47, Info.GetProcessID()); +} Index: unittests/Host/ProcessLaunchInfoTest.cpp =================================================================== --- /dev/null +++ unittests/Host/ProcessLaunchInfoTest.cpp @@ -0,0 +1,28 @@ +//===-- ProcessLaunchInfoTest.cpp -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Host/ProcessLaunchInfo.h" +#include "gtest/gtest.h" + +using namespace lldb_private; +using namespace lldb; + +TEST(ProcessLaunchInfoTest, Constructor) { + ProcessLaunchInfo Info(FileSpec("/stdin"), FileSpec("/stdout"), + FileSpec("/stderr"), FileSpec("/wd"), + eLaunchFlagStopAtEntry); + EXPECT_EQ(FileSpec("/stdin"), + Info.GetFileActionForFD(STDIN_FILENO)->GetFileSpec()); + EXPECT_EQ(FileSpec("/stdout"), + Info.GetFileActionForFD(STDOUT_FILENO)->GetFileSpec()); + EXPECT_EQ(FileSpec("/stderr"), + Info.GetFileActionForFD(STDERR_FILENO)->GetFileSpec()); + EXPECT_EQ(FileSpec("/wd"), Info.GetWorkingDirectory()); + EXPECT_EQ(eLaunchFlagStopAtEntry, Info.GetFlags().Get()); +} Index: unittests/tools/lldb-server/tests/TestClient.h =================================================================== --- unittests/tools/lldb-server/tests/TestClient.h +++ unittests/tools/lldb-server/tests/TestClient.h @@ -12,7 +12,7 @@ #include "MessageObjects.h" #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" -#include "lldb/Target/ProcessLaunchInfo.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Connection.h" #include "llvm/ADT/Optional.h" Index: unittests/tools/lldb-server/tests/TestClient.cpp =================================================================== --- unittests/tools/lldb-server/tests/TestClient.cpp +++ unittests/tools/lldb-server/tests/TestClient.cpp @@ -11,7 +11,6 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Host/common/TCPSocket.h" #include "lldb/Host/posix/ConnectionFileDescriptorPosix.h" -#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Utility/Args.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Path.h"