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

enum  SystemLogType { eSystemLogWarning, eSystemLogError }
 
typedef std::function< bool(lldb::pid_t pid, bool exited, 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, bool monitor_signals)
 Start monitoring a child process. More...
 
static void SystemLog (SystemLogType type, const char *format,...) __attribute__((format(printf
 
static void static void SystemLog (SystemLogType type, const char *format, va_list args)
 
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 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 62 of file Host.h.

Member Typedef Documentation

◆ MonitorChildProcessCallback

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

Definition at line 68 of file Host.h.

◆ TidMap

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

Definition at line 180 of file Host.h.

◆ TidPair

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

Definition at line 181 of file Host.h.

Member Enumeration Documentation

◆ SystemLogType

Enumerator
eSystemLogWarning 
eSystemLogError 

Definition at line 106 of file Host.h.

Member Function Documentation

◆ CreateDefaultConnection()

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

Definition at line 649 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 412 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 314 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 318 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 422 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

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

Referenced by lldb_private::RemoteAwarePlatform::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 489 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 468 of file common/Host.cpp.

Referenced by GetXcodeSDK(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qPlatform_shell(), lldb_private::RemoteAwarePlatform::RunShellCommand(), 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 478 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,
bool  monitor_signals 
)
static

Start monitoring a child process.

Allows easy monitoring of child processes. callback will be called when the child process exits or if it gets a signal. The callback will only be called with signals if monitor_signals is true. callback will usually be called from another thread so the callback function must be thread safe.

When the callback gets called, the return value indicates if monitoring should stop. If true is returned from callback the information will be removed. If false is returned then monitoring will continue. If the child process exits, the monitoring will automatically stop after the callback returned regardless of the callback return value.

Parameters
[in]callbackA function callback to call when a child receives a signal (if monitor_signals is true) or a child exits.
[in]pidThe process ID of a child process to monitor, -1 for all processes.
[in]monitor_signalsIf true the callback will get called when the child process gets a signal. If false, the callback will only get called if the child process exits.
Returns
A thread handle that can be used to cancel the thread that was spawned to monitor pid.
See also
static void Host::StopMonitoringChildProcess (uint32_t)

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

References MonitorChildProcessThreadFunction().

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

◆ SystemLog() [1/2]

void Host::SystemLog ( SystemLogType  type,
const char *  format,
va_list  args 
)
static

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

◆ SystemLog() [2/2]

void Host::SystemLog ( SystemLogType  type,
const char *  format,
  ... 
)
static

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