LLDB  mainline
Public Types | Static Public 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

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 HostThread StartMonitoringChildProcess (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 (const char *command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, const Timeout< std::micro > &timeout, bool run_in_default_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_default_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)
 

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

◆ FindProcesses()

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

◆ FindProcessThreads()

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

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

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

Referenced by 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 413 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

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

References SIGKILL, SIGSTOP, and SIGTRAP.

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

◆ RunShellCommand() [1/2]

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

Run a shell command.

  • command shouldn't be NULL
  • 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 TODO: Convert this function to take a StringRef.

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

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

◆ RunShellCommand() [2/2]

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_default_shell = true,
bool  hide_stderr = false 
)
static

◆ 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 243 of file freebsd/Host.cpp.

References lldb_private::Status.

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

◆ StartMonitoringChildProcess()

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 102 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,
  ... 
)
static

◆ SystemLog() [2/2]

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

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


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