LLDB mainline
Public Types | Static Public Member Functions | Static Protected Member Functions | List of all members
lldb_private::Host Class Reference

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< HostThreadStartMonitoringChildProcess (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, const Timeout< std::micro > &timeout, bool run_in_shell=true, bool hide_stderr=false)
 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, const Timeout< std::micro > &timeout, bool run_in_shell=true, bool hide_stderr=false)
 Run a shell command.
 
static Status RunShellCommand (const Args &args, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, const Timeout< std::micro > &timeout, bool run_in_shell=true, bool hide_stderr=false)
 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, const Timeout< std::micro > &timeout, bool run_in_shell=true, bool hide_stderr=false)
 Run a shell command.
 
static llvm::Error OpenFileInExternalEditor (llvm::StringRef editor, const FileSpec &file_spec, uint32_t line_no)
 
static bool IsInteractiveGraphicSession ()
 Check if we're running in an interactive graphical session.
 
static Environment GetEnvironment ()
 
static std::unique_ptr< ConnectionCreateDefaultConnection (llvm::StringRef url)
 

Static Protected Member Functions

static uint32_t FindProcessesImpl (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &proc_infos)
 

Detailed Description

A class that provides host computer information.

Host is a class that answers information about the host operating system.

Definition at line 63 of file Host.h.

Member Typedef Documentation

◆ MonitorChildProcessCallback

typedef std::function<void(lldb::pid_t pid, int signal, int status)> lldb_private::Host::MonitorChildProcessCallback

Definition at line 69 of file Host.h.

◆ TidMap

typedef std::map<lldb::pid_t, bool> lldb_private::Host::TidMap

Definition at line 160 of file Host.h.

◆ TidPair

typedef std::pair<lldb::pid_t, bool> lldb_private::Host::TidPair

Definition at line 161 of file Host.h.

Member Function Documentation

◆ CreateDefaultConnection()

std::unique_ptr< Connection > Host::CreateDefaultConnection ( llvm::StringRef  url)
static

Definition at line 587 of file common/Host.cpp.

Referenced by lldb::SBCommunication::Connect().

◆ FindProcesses()

uint32_t Host::FindProcesses ( const ProcessInstanceInfoMatch match_info,
ProcessInstanceInfoList proc_infos 
)
static

◆ FindProcessesImpl()

uint32_t Host::FindProcessesImpl ( const ProcessInstanceInfoMatch match_info,
ProcessInstanceInfoList proc_infos 
)
staticprotected

◆ FindProcessThreads()

bool Host::FindProcessThreads ( const lldb::pid_t  pid,
TidMap tids_to_attach 
)
static

◆ GetBundleDirectory()

bool Host::GetBundleDirectory ( const FileSpec file,
FileSpec bundle_directory 
)
static

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.

Parameters
[in]fileA file spec that might point to a file in a bundle.
[out]bundle_directoryAn 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.
Returns
true if file was resolved in bundle_directory, false otherwise.

Definition at line 350 of file common/Host.cpp.

References lldb_private::FileSpec::Clear().

Referenced by lldb_private::PlatformDarwin::GetSharedModule().

◆ GetCurrentProcessID()

lldb::pid_t Host::GetCurrentProcessID ( )
static

Get the process ID for the calling process.

Returns
The process ID for the current process.

Definition at line 252 of file common/Host.cpp.

Referenced by lldb_private::HostInfoBase::ComputeProcessTempFileDirectory().

◆ GetCurrentThread()

lldb::thread_t Host::GetCurrentThread ( )
static

Get the thread token (the one returned by ThreadCreate when the thread was created) for the calling thread in the current process.

Returns
The thread token for the calling thread in the current process.

Definition at line 256 of file common/Host.cpp.

Referenced by lldb_private::Process::CurrentThreadIsPrivateStateThread(), lldb_private::Process::GetRunLock(), lldb_private::Debugger::IsIOHandlerThreadCurrentThread(), lldb_private::CommandInterpreter::RunCommandInterpreter(), and lldb_private::Process::RunThreadPlan().

◆ GetEnvironment()

Environment Host::GetEnvironment ( )
static

◆ GetModuleFileSpecForHostAddress()

FileSpec Host::GetModuleFileSpecForHostAddress ( const void *  host_addr)
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.

Parameters
[in]host_addrThe pointer to some code in the current process.
Returns
A file spec with the module that contains host_addr, which may be invalid if host_addr doesn't fall into any valid module address range.

Definition at line 360 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().

◆ GetProcessInfo()

bool Host::GetProcessInfo ( lldb::pid_t  pid,
ProcessInstanceInfo proc_info 
)
static

◆ GetSignalAsCString()

const char * Host::GetSignalAsCString ( int  signo)
static

◆ IsInteractiveGraphicSession()

bool Host::IsInteractiveGraphicSession ( )
static

Check if we're running in an interactive graphical session.

Returns
True if we're running in an interactive graphical session. False if we're not or don't know.

Definition at line 584 of file common/Host.cpp.

Referenced by lldb_private::CommandInterpreter::SaveTranscript().

◆ Kill()

void Host::Kill ( lldb::pid_t  pid,
int  signo 
)
static

◆ LaunchProcess()

Status Host::LaunchProcess ( ProcessLaunchInfo launch_info)
static

◆ OpenFileInExternalEditor()

llvm::Error Host::OpenFileInExternalEditor ( llvm::StringRef  editor,
const FileSpec file_spec,
uint32_t  line_no 
)
static

◆ ResolveExecutableInBundle()

bool Host::ResolveExecutableInBundle ( FileSpec file)
static

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.

Parameters
[in,out]fileA 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.
Returns
true if file was resolved, false if this function was not able to resolve the path.

Definition at line 355 of file common/Host.cpp.

Referenced by lldb_private::TargetList::CreateTargetInternal(), lldb::SBModuleSpecList::GetModuleSpecifications(), lldb_private::PlatformDarwin::GetSharedModule(), and lldb_private::Platform::ResolveExecutable().

◆ RunShellCommand() [1/4]

Status Host::RunShellCommand ( const Args args,
const FileSpec working_dir,
int *  status_ptr,
int *  signo_ptr,
std::string *  command_output,
const Timeout< std::micro > &  timeout,
bool  run_in_shell = true,
bool  hide_stderr = false 
)
static

Run a shell command.

  • working_dir Pass empty FileSpec to use the current working directory
  • status_ptr Pass NULL if you don't want the process exit status
  • signo_ptr Pass NULL if you don't want the signal that caused the process to exit
  • command_output Pass NULL if you don't want the command output
  • hide_stderr if this is false, redirect stderr to stdout

Definition at line 425 of file common/Host.cpp.

References RunShellCommand().

◆ RunShellCommand() [2/4]

Status Host::RunShellCommand ( llvm::StringRef  command,
const FileSpec working_dir,
int *  status_ptr,
int *  signo_ptr,
std::string *  command_output,
const Timeout< std::micro > &  timeout,
bool  run_in_shell = true,
bool  hide_stderr = false 
)
static

Run a shell command.

  • command shouldn't be empty
  • working_dir Pass empty FileSpec to use the current working directory
  • status_ptr Pass NULL if you don't want the process exit status
  • signo_ptr Pass NULL if you don't want the signal that caused the process to exit
  • command_output Pass NULL if you don't want the command output
  • hide_stderr if this is false, redirect stderr to stdout

Definition at line 404 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(), PlatformPOSIX::PutFile(), RunShellCommand(), lldb_private::Platform::RunShellCommand(), and xcrun().

◆ RunShellCommand() [3/4]

Status Host::RunShellCommand ( llvm::StringRef  shell,
const Args args,
const FileSpec working_dir,
int *  status_ptr,
int *  signo_ptr,
std::string *  command_output,
const Timeout< std::micro > &  timeout,
bool  run_in_shell = true,
bool  hide_stderr = false 
)
static

◆ RunShellCommand() [4/4]

Status Host::RunShellCommand ( llvm::StringRef  shell,
llvm::StringRef  command,
const FileSpec working_dir,
int *  status_ptr,
int *  signo_ptr,
std::string *  command_output,
const Timeout< std::micro > &  timeout,
bool  run_in_shell = true,
bool  hide_stderr = false 
)
static

Run a shell command.

  • shell Pass an empty string if you want to use the default shell interpreter
  • command
  • working_dir Pass empty FileSpec to use the current working directory
  • status_ptr Pass NULL if you don't want the process exit status
  • signo_ptr Pass NULL if you don't want the signal that caused the process to exit
  • command_output Pass NULL if you don't want the command output
  • hide_stderr If this is false, redirect stderr to stdout

Definition at line 414 of file common/Host.cpp.

References RunShellCommand().

◆ ShellExpandArguments()

Status Host::ShellExpandArguments ( ProcessLaunchInfo launch_info)
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 246 of file freebsd/Host.cpp.

Referenced by lldb_private::Platform::ShellExpandArguments().

◆ StartMonitoringChildProcess()

llvm::Expected< HostThread > Host::StartMonitoringChildProcess ( const MonitorChildProcessCallback callback,
lldb::pid_t  pid 
)
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.

Parameters
[in]callbackA function callback to call when a child receives a signal or exits.
[in]pidThe process ID of a child process to monitor.
Returns
A thread handle that can be used to cancel the thread that was spawned to monitor pid.

Definition at line 132 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().

◆ SystemLog()

void Host::SystemLog ( lldb::Severity  severity,
llvm::StringRef  message 
)
static

Emit the given message to the operating system log.

Definition at line 94 of file common/Host.cpp.

References lldb::eSeverityError, lldb::eSeverityInfo, and lldb::eSeverityWarning.

Referenced by lldb_private::SystemLogHandler::Emit(), and lldb_private::Debugger::ReportDiagnosticImpl().


The documentation for this class was generated from the following files: