Move FileAction, ProcessInfo and ProcessLaunchInfo from Target to Host

Summary:
These classes describe the details of the process we are about to
launch, and so they are naturally used by the launching code in the Host
module. Previously they were present in Target because that is the most
important (but by far not the only) user of the launching code.

Since the launching code has other customers, must of which do not care
about Targets, it makes sense to move these classes to the Host layer,
next to the launching code.

This move reduces the number of times that Target is included from host
to 8 (it used to be 14).

Reviewers: zturner, clayborg, jingham, davide, teemperor

Subscribers: emaste, mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D56602

llvm-svn: 353047
This commit is contained in:
Pavel Labath
2019-02-04 14:28:08 +00:00
parent 56edf3f344
commit eef758e949
29 changed files with 102 additions and 30 deletions

View File

@@ -6,8 +6,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 <string>

View File

@@ -15,10 +15,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 {

View File

@@ -28,14 +28,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"

View File

@@ -23,10 +23,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"

View File

@@ -17,6 +17,7 @@ module lldb_Host {
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 lldb_Host {
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 * }

View File

@@ -10,7 +10,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;

View File

@@ -19,6 +19,7 @@ endmacro()
add_host_subdirectory(common
common/File.cpp
common/FileAction.cpp
common/FileCache.cpp
common/FileSystem.cpp
common/GetOptInc.cpp
@@ -36,6 +37,8 @@ add_host_subdirectory(common
common/NativeThreadProtocol.cpp
common/OptionParser.cpp
common/PipeBase.cpp
common/ProcessInfo.cpp
common/ProcessLaunchInfo.cpp
common/ProcessRunLock.cpp
common/PseudoTerminal.cpp
common/Socket.cpp

View File

@@ -8,8 +8,8 @@
#include <fcntl.h>
#include "lldb/Host/FileAction.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Target/FileAction.h"
#include "lldb/Utility/Stream.h"
using namespace lldb_private;

View File

@@ -46,16 +46,16 @@
#include <csignal>
#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"

View File

@@ -9,7 +9,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"

View File

@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "lldb/Target/ProcessInfo.h"
#include "lldb/Host/ProcessInfo.h"
#include <climits>

View File

@@ -9,10 +9,10 @@
#include <climits>
#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"

View File

@@ -56,9 +56,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"

View File

@@ -10,7 +10,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"

View File

@@ -8,7 +8,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"

View File

@@ -16,7 +16,7 @@
#include <Foundation/Foundation.h>
// Project includes
#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Target/FileAction.h"
#include "lldb/Host/FileAction.h"
#include "llvm/ADT/StringRef.h"

View File

@@ -8,7 +8,6 @@
#include "PlatformPOSIX.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
@@ -22,11 +21,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"

View File

@@ -23,6 +23,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"
@@ -31,7 +32,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"

View File

@@ -21,13 +21,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"

View File

@@ -20,6 +20,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"
@@ -27,7 +28,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"

View File

@@ -21,9 +21,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"

View File

@@ -2,7 +2,6 @@ add_lldb_library(lldbTarget
ABI.cpp
CPPLanguageRuntime.cpp
ExecutionContext.cpp
FileAction.cpp
JITLoader.cpp
JITLoaderList.cpp
InstrumentationRuntime.cpp
@@ -17,8 +16,6 @@ add_lldb_library(lldbTarget
PathMappingList.cpp
Platform.cpp
Process.cpp
ProcessInfo.cpp
ProcessLaunchInfo.cpp
Queue.cpp
QueueItem.cpp
QueueList.cpp

View File

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

View File

@@ -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"));
}

View File

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

View File

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

View File

@@ -10,7 +10,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"

View File

@@ -11,7 +11,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"