|
LLDB mainline
|
A class that provides host computer information. More...
#include "lldb/Host/Host.h"
Public Types | |
| typedef std::function< void(lldb::pid_t pid, int signal, int status)> | MonitorChildProcessCallback |
| typedef std::map< lldb::pid_t, bool > | TidMap |
| typedef std::pair< lldb::pid_t, bool > | TidPair |
Static Public Member Functions | |
| static llvm::Expected< HostThread > | StartMonitoringChildProcess (const MonitorChildProcessCallback &callback, lldb::pid_t pid) |
| Start monitoring a child process. | |
| static void | SystemLog (lldb::Severity severity, llvm::StringRef message) |
| Emit the given message to the operating system log. | |
| static lldb::pid_t | GetCurrentProcessID () |
| Get the process ID for the calling process. | |
| static void | Kill (lldb::pid_t pid, int signo) |
| static lldb::thread_t | GetCurrentThread () |
| Get the thread token (the one returned by ThreadCreate when the thread was created) for the calling thread in the current process. | |
| static const char * | GetSignalAsCString (int signo) |
| static FileSpec | GetModuleFileSpecForHostAddress (const void *host_addr) |
| Given an address in the current process (the process that is running the LLDB code), return the name of the module that it comes from. | |
| static bool | GetBundleDirectory (const FileSpec &file, FileSpec &bundle_directory) |
| If you have an executable that is in a bundle and want to get back to the bundle directory from the path itself, this function will change a path to a file within a bundle to the bundle directory itself. | |
| static bool | ResolveExecutableInBundle (FileSpec &file) |
| When executable files may live within a directory, where the directory represents an executable bundle (like the MacOSX app bundles), then locate the executable within the containing bundle. | |
| static uint32_t | FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &proc_infos) |
| static bool | FindProcessThreads (const lldb::pid_t pid, TidMap &tids_to_attach) |
| static bool | GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info) |
| static Status | LaunchProcess (ProcessLaunchInfo &launch_info) |
| Launch the process specified in launch_info. | |
| static Status | ShellExpandArguments (ProcessLaunchInfo &launch_info) |
| Perform expansion of the command-line for this launch info This can potentially involve wildcard expansion environment variable replacement, and whatever other argument magic the platform defines as part of its typical user experience. | |
| static Status | RunShellCommand (llvm::StringRef command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, std::string *error_output, const Timeout< std::micro > &timeout, bool run_in_shell=true) |
| Run a shell command. | |
| static Status | RunShellCommand (llvm::StringRef shell, llvm::StringRef command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, std::string *separated_error_output, const Timeout< std::micro > &timeout, bool run_in_shell=true) |
| Run a shell command. | |
| static Status | RunShellCommand (const Args &args, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, std::string *separated_error_output, const Timeout< std::micro > &timeout, bool run_in_shell=true) |
| Run a shell command. | |
| static Status | RunShellCommand (llvm::StringRef shell, const Args &args, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, std::string *separated_error_output, const Timeout< std::micro > &timeout, bool run_in_shell=true) |
| Run a shell command. | |
| static llvm::Error | OpenFileInExternalEditor (llvm::StringRef editor, const FileSpec &file_spec, uint32_t line_no, bool foreground=false) |
| static llvm::Error | OpenURL (llvm::StringRef url) |
| Open a URL with the host's default handler (Launch Services on macOS, xdg-open on other Unix). | |
| static std::string | URLEncode (llvm::StringRef str) |
| Percent-encode a string for use in a URL query component, per RFC 3986 (alphanumerics and "-_.~" are kept literal; everything else becomes HH). | |
| static bool | IsInteractiveGraphicSession () |
| Check if we're running in an interactive graphical session. | |
| static Environment | GetEnvironment () |
| static std::unique_ptr< Connection > | CreateDefaultConnection (llvm::StringRef url) |
Static Protected Member Functions | |
| static uint32_t | FindProcessesImpl (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &proc_infos) |
A class that provides host computer information.
Host is a class that answers information about the host operating system.
| typedef std::function<void(lldb::pid_t pid, int signal, int status)> lldb_private::Host::MonitorChildProcessCallback |
| typedef std::map<lldb::pid_t, bool> lldb_private::Host::TidMap |
| typedef std::pair<lldb::pid_t, bool> lldb_private::Host::TidPair |
|
static |
Definition at line 667 of file common/Host.cpp.
Referenced by lldb::SBCommunication::Connect().
|
static |
Definition at line 723 of file common/Host.cpp.
References FindProcessesImpl().
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::AttachWaitProcess(), lldb_private::Platform::FindProcesses(), lldb_private::PlatformAppleSimulator::FindProcesses(), and lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qfProcessInfo().
|
staticprotected |
Definition at line 169 of file aix/Host.cpp.
References lldb_private::ProcessInstanceInfoMatch::GetMatchAllUsers(), GetProcessAndStatInfo(), lldb_private::ProcessInfo::GetUserID(), lldb_private::ProcessInstanceInfoMatch::Matches(), and lldb_private::State.
Referenced by FindProcesses().
|
static |
Definition at line 366 of file common/Host.cpp.
Referenced by lldb_private::process_linux::NativeProcessLinux::Attach().
If you have an executable that is in a bundle and want to get back to the bundle directory from the path itself, this function will change a path to a file within a bundle to the bundle directory itself.
| [in] | file | A file spec that might point to a file in a bundle. |
| [out] | bundle_directory | An object will be filled in with the bundle directory for the bundle when true is returned. Otherwise file is left untouched and false is returned. |
Definition at line 341 of file common/Host.cpp.
References lldb_private::FileSpec::Clear().
Referenced by lldb_private::PlatformDarwin::GetSharedModule().
|
static |
Get the process ID for the calling process.
Definition at line 243 of file common/Host.cpp.
Referenced by lldb_private::HostInfoBase::ComputeProcessTempFileDirectory(), and lldb_private::Diagnostics::GetInvocation().
|
static |
Get the thread token (the one returned by ThreadCreate when the thread was created) for the calling thread in the current process.
Definition at line 247 of file common/Host.cpp.
Referenced by lldb_private::Thread::GetStackFrameList(), lldb_private::Debugger::IsIOHandlerThreadCurrentThread(), lldb_private::Thread::PopProviderFrameList(), lldb_private::Thread::PushProviderFrameList(), lldb_private::CommandInterpreter::RunCommandInterpreter(), and lldb_private::Process::RunThreadPlan().
|
static |
Definition at line 117 of file common/Host.cpp.
References environ.
Referenced by lldb_private::PlatformQemuUser::DebugProcess(), lldb_private::PlatformWasm::DebugProcess(), GetDebugserverPath(), lldb_private::Platform::GetEnvironment(), lldb_private::PlatformQemuUser::GetEnvironment(), RunShellCommand(), and lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess().
|
static |
Given an address in the current process (the process that is running the LLDB code), return the name of the module that it comes from.
This can be useful when you need to know the path to the shared library that your code is running in for loading resources that are relative to your binary.
| [in] | host_addr | The pointer to some code in the current process. |
Definition at line 351 of file common/Host.cpp.
References lldb_private::FileSystem::Instance(), lldb_private::FileSystem::Resolve(), and lldb_private::FileSpec::SetFile().
Referenced by lldb_private::HostInfoBase::ComputeSharedLibraryDirectory().
|
static |
Definition at line 211 of file aix/Host.cpp.
References GetProcessAndStatInfo(), and lldb_private::State.
Referenced by lldb_private::process_freebsd::NativeProcessFreeBSD::Manager::Attach(), lldb_private::process_netbsd::NativeProcessNetBSD::Manager::Attach(), lldb_private::Diagnostics::GetInvocation(), lldb_private::PlatformDarwin::GetOSVersion(), lldb_private::Platform::GetProcessInfo(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::Handle_qProcessInfo(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::Handle_qProcessInfo(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qProcessInfoPID(), lldb_private::process_aix::NativeProcessAIX::Manager::Launch(), lldb_private::process_freebsd::NativeProcessFreeBSD::Manager::Launch(), lldb_private::process_netbsd::NativeProcessNetBSD::Manager::Launch(), lldb_private::NativeProcessWindows::NativeProcessWindows(), and lldb_private::NativeProcessWindows::OnDebuggerConnected().
|
static |
Definition at line 251 of file common/Host.cpp.
References SIGBUS, SIGFPE, SIGILL, SIGKILL, SIGSEGV, SIGSTOP, and SIGTRAP.
Referenced by CommandObjectPlatformShell::DoExecute(), lldb_private::process_linux::NativeProcessLinux::MonitorSignal(), and lldb_private::process_linux::NativeProcessLinux::Signal().
|
static |
Check if we're running in an interactive graphical session.
Definition at line 618 of file common/Host.cpp.
Referenced by lldb_private::CommandInterpreter::SaveTranscript().
|
static |
Definition at line 606 of file common/Host.cpp.
Referenced by lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer(), lldb_private::process_gdb_remote::ProcessGDBRemote::KillDebugserverProcess(), lldb_private::Platform::KillProcess(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::KillSpawnedProcess(), RunShellCommand(), and lldb_private::PlatformWebInspectorWasm::~PlatformWebInspectorWasm().
|
static |
Launch the process specified in launch_info.
The monitoring callback in launch_info must be set, and it will be called when the process terminates.
Definition at line 585 of file common/Host.cpp.
References error(), lldb_private::HostProcess::GetProcessId(), lldb_private::MonitoringProcessLauncher::LaunchProcess(), and lldb_private::ProcessInfo::SetProcessID().
Referenced by lldb_private::PlatformQemuUser::DebugProcess(), lldb_private::PlatformWasm::DebugProcess(), lldb_private::PlatformWebInspectorWasm::LaunchPlatformServer(), lldb_private::Platform::LaunchProcess(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::LaunchProcess(), RunShellCommand(), and lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess().
|
static |
Definition at line 611 of file common/Host.cpp.
Referenced by lldb_private::Thread::GetStatus(), lldb_private::CommandInterpreter::SaveTranscript(), and lldb_private::Thread::SetSelectedFrameByIndexNoisily().
|
static |
Open a URL with the host's default handler (Launch Services on macOS, xdg-open on other Unix).
Returns an error if opening fails or the platform has no implementation (e.g. Windows).
Definition at line 620 of file common/Host.cpp.
References lldb_private::Args::AppendArgument(), error(), lldb_private::GetLog(), lldb_private::Host, LLDB_LOG, and RunShellCommand().
Referenced by lldb_private::GitHubReporter::File().
When executable files may live within a directory, where the directory represents an executable bundle (like the MacOSX app bundles), then locate the executable within the containing bundle.
| [in,out] | file | A file spec that currently points to the bundle that will be filled in with the executable path within the bundle if true is returned. Otherwise file is left untouched. |
Definition at line 346 of file common/Host.cpp.
Referenced by lldb::SBModuleSpecList::GetModuleSpecifications(), lldb_private::PlatformDarwin::GetSharedModule(), and lldb_private::Platform::ResolveExecutable().
|
static |
Run a shell command.
| [in] | args | Command to execute |
| [in] | working_dir | Pass empty FileSpec to use the current working directory |
| [out] | status_ptr | Pass nullptr if you don't want the process exit status |
| [out] | signo_ptr | Pass nullptr if you don't want the signal that caused the process to exit |
| [out] | command_output | Pass nullptr if you don't want the command output |
| [out] | separated_error_output | If a std::string is specified, error output is routed into a separate string. If nullptr is provided, command output and error text will be returned combined |
| [in] | timeout | Timeout duration to enforce |
| [in] | run_in_shell | Run in a subshell, with glob expansion of args |
Definition at line 416 of file common/Host.cpp.
References RunShellCommand().
|
static |
Run a shell command.
| [in] | command | Command to execute, should not be empty. |
| [in] | working_dir | Pass empty FileSpec to use the current working directory |
| [out] | status_ptr | Pass nullptr if you don't want the process exit status |
| [out] | signo_ptr | Pass nullptr if you don't want the signal that caused the process to exit |
| [out] | command_output | Pass nullptr if you don't want the command output |
| [out] | separated_error_output | If a std::string is specified, error output is routed into a separate string. If nullptr is provided, command output and error text will be returned combined in command_output. |
| [in] | timeout | Timeout duration to enforce |
| [in] | run_in_shell | Run in a subshell, with glob expansion of args |
Definition at line 393 of file common/Host.cpp.
References RunShellCommand().
Referenced by lldb_private::SymbolLocatorDebugSymbols::DownloadObjectAndSymbolFile(), PlatformPOSIX::GetFile(), GetXcodeSelectPath(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qPlatform_shell(), OpenURL(), PlatformPOSIX::PutFile(), RunShellCommand(), RunShellCommand(), RunShellCommand(), lldb_private::Platform::RunShellCommand(), and xcrun().
|
static |
Run a shell command.
| [in] | shell | Pass an empty string to use the default shell |
| [in] | args | Command to execute |
| [in] | working_dir | Pass empty FileSpec to use the current working directory |
| [out] | status_ptr | Pass nullptr if you don't want the process exit status |
| [out] | signo_ptr | Pass nullptr if you don't want the signal that caused the process to exit |
| [out] | command_output | Pass nullptr if you don't want the command output |
| [out] | separated_error_output | If a std::string is specified, error output is routed into a separate string. If nullptr is provided, command output and error text will be returned combined |
| [in] | timeout | Timeout duration to enforce |
| [in] | run_in_shell | Run in a subshell, with glob expansion of args |
Definition at line 427 of file common/Host.cpp.
References lldb_private::Args::AppendArguments(), lldb_private::ProcessLaunchInfo::AppendDuplicateFileAction(), lldb_private::ProcessLaunchInfo::AppendOpenFileAction(), lldb_private::ProcessLaunchInfo::AppendSuppressFileAction(), lldb_private::ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell(), lldb_private::FileSystem::CreateWritableDataBuffer(), error(), lldb_private::Status::FromErrorString(), lldb_private::Status::FromErrorStringWithFormat(), lldb_private::ProcessInfo::GetArguments(), lldb_private::FileSystem::GetByteSize(), GetEnvironment(), lldb_private::ProcessInfo::GetEnvironment(), lldb_private::FileSpec::GetPath(), lldb_private::ProcessInfo::GetProcessID(), lldb_private::FileSystem::Instance(), Kill(), LaunchProcess(), LLDB_INVALID_PROCESS_ID, MonitorShellCommand(), lldb_private::ProcessInfo::SetArchitecture(), lldb_private::ProcessInfo::SetArguments(), lldb_private::ProcessLaunchInfo::SetMonitorProcessCallback(), lldb_private::FileSpec::SetPath(), lldb_private::ProcessLaunchInfo::SetShell(), lldb_private::ProcessLaunchInfo::SetWorkingDirectory(), and SIGKILL.
|
static |
Run a shell command.
| [in] | shell | Pass an empty string to use the default shell |
| [in] | command | Command to execute, should not be empty. |
| [in] | working_dir | Pass empty FileSpec to use the current working directory |
| [out] | status_ptr | Pass nullptr if you don't want the process exit status |
| [out] | signo_ptr | Pass nullptr if you don't want the signal that caused the process to exit |
| [out] | command_output | Pass nullptr if you don't want the command output |
| [out] | separated_error_output | If a std::string is specified, error output is routed into a separate string. If nullptr is provided, command output and error text will be returned combined |
| [in] | timeout | Timeout duration to enforce |
| [in] | run_in_shell | Run in a subshell, with glob expansion of args |
Definition at line 404 of file common/Host.cpp.
References RunShellCommand().
|
static |
Perform expansion of the command-line for this launch info This can potentially involve wildcard expansion environment variable replacement, and whatever other argument magic the platform defines as part of its typical user experience.
Definition at line 216 of file aix/Host.cpp.
References lldb_private::Status.
Referenced by lldb_private::Platform::ShellExpandArguments().
|
static |
Start monitoring a child process.
Allows easy monitoring of child processes. callback will be called when the child process exits or if it dies from a signal.
| [in] | callback | A function callback to call when a child receives a signal or exits. |
| [in] | pid | The process ID of a child process to monitor. |
Definition at line 123 of file common/Host.cpp.
References lldb_private::ThreadLauncher::LaunchThread(), MonitorChildProcessThreadFunction(), and UINT32_MAX.
Referenced by lldb_private::ProcessLaunchInfo::MonitorProcess(), and lldb_private::HostProcessPosix::StartMonitoring().
|
static |
Emit the given message to the operating system log.
Definition at line 95 of file common/Host.cpp.
Referenced by lldb_private::SystemLogHandler::Emit(), and lldb_private::Debugger::ReportDiagnosticImpl().
|
static |
Percent-encode a string for use in a URL query component, per RFC 3986 (alphanumerics and "-_.~" are kept literal; everything else becomes HH).
Definition at line 660 of file common/Host.cpp.
Referenced by lldb_private::GitHubReporter::File().