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

#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, boolTidMap
 
typedef std::pair< lldb::pid_t, boolTidPair
 

Static Public Member Functions

static llvm::Expected< HostThreadStartMonitoringChildProcess (const MonitorChildProcessCallback &callback, lldb::pid_t pid)
 Start monitoring a child process. More...
 
static void SystemLog (llvm::StringRef message)
 Emit the given message to the operating system log. More...
 
static lldb::pid_t GetCurrentProcessID ()
 Get the process ID for the calling process. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
static bool OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no)
 
static bool IsInteractiveGraphicSession ()
 Check if we're running in an interactive graphical session. More...
 
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

Definition at line 160 of file Host.h.

◆ 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 558 of file common/Host.cpp.

◆ 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 323 of file common/Host.cpp.

References lldb_private::FileSpec::Clear().

◆ 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 225 of file common/Host.cpp.

◆ 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 229 of file common/Host.cpp.

Referenced by lldb_private::Process::CurrentThreadIsPrivateStateThread(), lldb_private::Process::GetRunLock(), 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 333 of file common/Host.cpp.

References lldb_private::FileSpec::SetFile().

◆ 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 555 of file common/Host.cpp.

◆ Kill()

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

◆ LaunchProcess()

Status Host::LaunchProcess ( ProcessLaunchInfo launch_info)
static

◆ OpenFileInExternalEditor()

bool Host::OpenFileInExternalEditor ( 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 328 of file common/Host.cpp.

Referenced by lldb_private::RemoteAwarePlatform::ResolveExecutable(), lldb_private::PlatformRemoteDarwinDevice::ResolveExecutable(), lldb_private::PlatformAppleSimulator::ResolveExecutable(), and lldb_private::Platform::ResolveRemoteExecutable().

◆ 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 398 of file common/Host.cpp.

◆ 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 377 of file common/Host.cpp.

Referenced by GetXcodeSDK(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qPlatform_shell(), and lldb_private::Platform::RunShellCommand().

◆ 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 387 of file common/Host.cpp.

◆ 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 101 of file common/Host.cpp.

References MonitorChildProcessThreadFunction(), and UINT32_MAX.

Referenced by lldb_private::ProcessLaunchInfo::MonitorProcess(), and lldb_private::HostProcessPosix::StartMonitoring().

◆ SystemLog()

void Host::SystemLog ( llvm::StringRef  message)
static

Emit the given message to the operating system log.

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

References message().


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