LLDB mainline
common/Host.cpp
Go to the documentation of this file.
1//===-- Host.cpp ----------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// C includes
10#include <cerrno>
11#include <climits>
12#include <cstdlib>
13#include <sys/types.h>
14#ifndef _WIN32
15#include <dlfcn.h>
16#include <grp.h>
17#include <netdb.h>
18#include <pwd.h>
19#include <sys/stat.h>
20#include <unistd.h>
21#endif
22
23#if defined(__APPLE__)
24#include <mach-o/dyld.h>
25#include <mach/mach_init.h>
26#include <mach/mach_port.h>
27#endif
28
29#if defined(__linux__) || defined(__FreeBSD__) || \
30 defined(__FreeBSD_kernel__) || defined(__APPLE__) || \
31 defined(__NetBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
32#if !defined(__ANDROID__)
33#include <spawn.h>
34#endif
35#include <sys/syscall.h>
36#include <sys/wait.h>
37#endif
38
39#if defined(__FreeBSD__)
40#include <pthread_np.h>
41#endif
42
43#if defined(__NetBSD__)
44#include <lwp.h>
45#endif
46
47#include <csignal>
48
51#include "lldb/Host/Host.h"
52#include "lldb/Host/HostInfo.h"
61#include "lldb/Utility/Log.h"
63#include "lldb/Utility/Status.h"
65#include "llvm/ADT/SmallString.h"
66#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
67#include "llvm/Support/Errno.h"
68#include "llvm/Support/FileSystem.h"
69
70#if defined(_WIN32)
73#else
75#endif
76
77#if defined(__APPLE__)
78#ifndef _POSIX_SPAWN_DISABLE_ASLR
79#define _POSIX_SPAWN_DISABLE_ASLR 0x0100
80#endif
81
82extern "C" {
83int __pthread_chdir(const char *path);
84int __pthread_fchdir(int fildes);
85}
86
87#endif
88
89using namespace lldb;
90using namespace lldb_private;
91
92#if !defined(__APPLE__)
93// The system log is currently only meaningful on Darwin, where this means
94// os_log. The meaning of a "system log" isn't as clear on other platforms, and
95// therefore we don't providate a default implementation. Vendors are free to
96// to implement this function if they have a use for it.
97void Host::SystemLog(Severity severity, llvm::StringRef message) {}
98#endif
99
100static constexpr Log::Category g_categories[] = {
101 {{"system"}, {"system log"}, SystemLog::System}};
102
105
107 return g_system_channel;
108}
109
111 g_system_log.Enable(std::make_shared<SystemLogHandler>());
112}
113
115
116#if !defined(__APPLE__) && !defined(_WIN32)
117static thread_result_t
120
121llvm::Expected<HostThread> Host::StartMonitoringChildProcess(
122 const Host::MonitorChildProcessCallback &callback, lldb::pid_t pid) {
123 char thread_name[256];
124 ::snprintf(thread_name, sizeof(thread_name),
125 "<lldb.host.wait4(pid=%" PRIu64 ")>", pid);
126 assert(pid <= UINT32_MAX);
127 return ThreadLauncher::LaunchThread(thread_name, [pid, callback] {
128 return MonitorChildProcessThreadFunction(pid, callback);
129 });
130}
131
132#ifndef __linux__
133// Scoped class that will disable thread canceling when it is constructed, and
134// exception safely restore the previous value it when it goes out of scope.
136public:
138 // Disable the ability for this thread to be cancelled
139 int err = ::pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &m_old_state);
140 if (err != 0)
141 m_old_state = -1;
142 }
143
145 // Restore the ability for this thread to be cancelled to what it
146 // previously was.
147 if (m_old_state != -1)
148 ::pthread_setcancelstate(m_old_state, 0);
149 }
150
151private:
152 int m_old_state; // Save the old cancelability state.
153};
154#endif // __linux__
155
156#ifdef __linux__
157static thread_local volatile sig_atomic_t g_usr1_called;
158
159static void SigUsr1Handler(int) { g_usr1_called = 1; }
160#endif // __linux__
161
163#ifdef __linux__
164 if (g_usr1_called) {
165 g_usr1_called = 0;
166 return true;
167 }
168#else
169 ::pthread_testcancel();
170#endif
171 return false;
172}
173
174static thread_result_t
178 LLDB_LOG(log, "pid = {0}", pid);
179
180 int status = -1;
181
182#ifdef __linux__
183 // This signal is only used to interrupt the thread from waitpid
184 struct sigaction sigUsr1Action;
185 memset(&sigUsr1Action, 0, sizeof(sigUsr1Action));
186 sigUsr1Action.sa_handler = SigUsr1Handler;
187 ::sigaction(SIGUSR1, &sigUsr1Action, nullptr);
188#endif // __linux__
189
190 while (true) {
192 LLDB_LOG(log, "::waitpid({0}, &status, 0)...", pid);
193
195 return nullptr;
196
197 const ::pid_t wait_pid = ::waitpid(pid, &status, 0);
198
199 LLDB_LOG(log, "::waitpid({0}, &status, 0) => pid = {1}, status = {2:x}", pid,
200 wait_pid, status);
201
203 return nullptr;
204
205 if (wait_pid != -1)
206 break;
207 if (errno != EINTR) {
208 LLDB_LOG(log, "pid = {0}, thread exiting because waitpid failed ({1})...",
209 pid, llvm::sys::StrError());
210 return nullptr;
211 }
212 }
213
214 int signal = 0;
215 int exit_status = 0;
216 if (WIFEXITED(status)) {
217 exit_status = WEXITSTATUS(status);
218 } else if (WIFSIGNALED(status)) {
219 signal = WTERMSIG(status);
220 exit_status = -1;
221 } else {
222 llvm_unreachable("Unknown status");
223 }
224
225 // Scope for pthread_cancel_disabler
226 {
227#ifndef __linux__
228 ScopedPThreadCancelDisabler pthread_cancel_disabler;
229#endif
230
231 if (callback)
232 callback(pid, signal, exit_status);
233 }
234
235 LLDB_LOG(GetLog(LLDBLog::Process), "pid = {0} thread exiting...", pid);
236 return nullptr;
237}
238
239#endif // #if !defined (__APPLE__) && !defined (_WIN32)
240
242
243#ifndef _WIN32
244
246 return lldb::thread_t(pthread_self());
247}
248
249const char *Host::GetSignalAsCString(int signo) {
250 switch (signo) {
251 case SIGHUP:
252 return "SIGHUP"; // 1 hangup
253 case SIGINT:
254 return "SIGINT"; // 2 interrupt
255 case SIGQUIT:
256 return "SIGQUIT"; // 3 quit
257 case SIGILL:
258 return "SIGILL"; // 4 illegal instruction (not reset when caught)
259 case SIGTRAP:
260 return "SIGTRAP"; // 5 trace trap (not reset when caught)
261 case SIGABRT:
262 return "SIGABRT"; // 6 abort()
263#if defined(SIGPOLL)
264#if !defined(SIGIO) || (SIGPOLL != SIGIO)
265 // Under some GNU/Linux, SIGPOLL and SIGIO are the same. Causing the build to
266 // fail with 'multiple define cases with same value'
267 case SIGPOLL:
268 return "SIGPOLL"; // 7 pollable event ([XSR] generated, not supported)
269#endif
270#endif
271#if defined(SIGEMT)
272 case SIGEMT:
273 return "SIGEMT"; // 7 EMT instruction
274#endif
275 case SIGFPE:
276 return "SIGFPE"; // 8 floating point exception
277 case SIGKILL:
278 return "SIGKILL"; // 9 kill (cannot be caught or ignored)
279 case SIGBUS:
280 return "SIGBUS"; // 10 bus error
281 case SIGSEGV:
282 return "SIGSEGV"; // 11 segmentation violation
283 case SIGSYS:
284 return "SIGSYS"; // 12 bad argument to system call
285 case SIGPIPE:
286 return "SIGPIPE"; // 13 write on a pipe with no one to read it
287 case SIGALRM:
288 return "SIGALRM"; // 14 alarm clock
289 case SIGTERM:
290 return "SIGTERM"; // 15 software termination signal from kill
291 case SIGURG:
292 return "SIGURG"; // 16 urgent condition on IO channel
293 case SIGSTOP:
294 return "SIGSTOP"; // 17 sendable stop signal not from tty
295 case SIGTSTP:
296 return "SIGTSTP"; // 18 stop signal from tty
297 case SIGCONT:
298 return "SIGCONT"; // 19 continue a stopped process
299 case SIGCHLD:
300 return "SIGCHLD"; // 20 to parent on child stop or exit
301 case SIGTTIN:
302 return "SIGTTIN"; // 21 to readers pgrp upon background tty read
303 case SIGTTOU:
304 return "SIGTTOU"; // 22 like TTIN for output if (tp->t_local&LTOSTOP)
305#if defined(SIGIO)
306 case SIGIO:
307 return "SIGIO"; // 23 input/output possible signal
308#endif
309 case SIGXCPU:
310 return "SIGXCPU"; // 24 exceeded CPU time limit
311 case SIGXFSZ:
312 return "SIGXFSZ"; // 25 exceeded file size limit
313 case SIGVTALRM:
314 return "SIGVTALRM"; // 26 virtual time alarm
315 case SIGPROF:
316 return "SIGPROF"; // 27 profiling time alarm
317#if defined(SIGWINCH)
318 case SIGWINCH:
319 return "SIGWINCH"; // 28 window size changes
320#endif
321#if defined(SIGINFO)
322 case SIGINFO:
323 return "SIGINFO"; // 29 information request
324#endif
325 case SIGUSR1:
326 return "SIGUSR1"; // 30 user defined signal 1
327 case SIGUSR2:
328 return "SIGUSR2"; // 31 user defined signal 2
329 default:
330 break;
331 }
332 return nullptr;
333}
334
335#endif
336
337#if !defined(__APPLE__) // see Host.mm
338
339bool Host::GetBundleDirectory(const FileSpec &file, FileSpec &bundle) {
340 bundle.Clear();
341 return false;
342}
343
344bool Host::ResolveExecutableInBundle(FileSpec &file) { return false; }
345#endif
346
347#ifndef _WIN32
348
350 FileSpec module_filespec;
351#if !defined(__ANDROID__)
352 Dl_info info;
353 if (::dladdr(host_addr, &info)) {
354 if (info.dli_fname) {
355 module_filespec.SetFile(info.dli_fname, FileSpec::Style::native);
356 FileSystem::Instance().Resolve(module_filespec);
357 }
358 }
359#endif
360 return module_filespec;
361}
362
363#endif
364
365#if !defined(__linux__)
366bool Host::FindProcessThreads(const lldb::pid_t pid, TidMap &tids_to_attach) {
367 return false;
368}
369#endif
370
371struct ShellInfo {
372 ShellInfo() : process_reaped(false) {}
373
376 int signo = -1;
377 int status = -1;
378};
379
380static void
381MonitorShellCommand(std::shared_ptr<ShellInfo> shell_info, lldb::pid_t pid,
382 int signo, // Zero for no signal
383 int status) // Exit value of process if signal is zero
384{
385 shell_info->pid = pid;
386 shell_info->signo = signo;
387 shell_info->status = status;
388 // Let the thread running Host::RunShellCommand() know that the process
389 // exited and that ShellInfo has been filled in by broadcasting to it
390 shell_info->process_reaped.SetValue(true, eBroadcastAlways);
391}
392
393Status Host::RunShellCommand(llvm::StringRef command,
394 const FileSpec &working_dir, int *status_ptr,
395 int *signo_ptr, std::string *command_output_ptr,
396 const Timeout<std::micro> &timeout,
397 bool run_in_shell, bool hide_stderr) {
398 return RunShellCommand(llvm::StringRef(), Args(command), working_dir,
399 status_ptr, signo_ptr, command_output_ptr, timeout,
400 run_in_shell, hide_stderr);
401}
402
403Status Host::RunShellCommand(llvm::StringRef shell_path,
404 llvm::StringRef command,
405 const FileSpec &working_dir, int *status_ptr,
406 int *signo_ptr, std::string *command_output_ptr,
407 const Timeout<std::micro> &timeout,
408 bool run_in_shell, bool hide_stderr) {
409 return RunShellCommand(shell_path, Args(command), working_dir, status_ptr,
410 signo_ptr, command_output_ptr, timeout, run_in_shell,
411 hide_stderr);
412}
413
414Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir,
415 int *status_ptr, int *signo_ptr,
416 std::string *command_output_ptr,
417 const Timeout<std::micro> &timeout,
418 bool run_in_shell, bool hide_stderr) {
419 return RunShellCommand(llvm::StringRef(), args, working_dir, status_ptr,
420 signo_ptr, command_output_ptr, timeout, run_in_shell,
421 hide_stderr);
422}
423
424Status Host::RunShellCommand(llvm::StringRef shell_path, const Args &args,
425 const FileSpec &working_dir, int *status_ptr,
426 int *signo_ptr, std::string *command_output_ptr,
427 const Timeout<std::micro> &timeout,
428 bool run_in_shell, bool hide_stderr) {
430 ProcessLaunchInfo launch_info;
431 launch_info.SetArchitecture(HostInfo::GetArchitecture());
432 if (run_in_shell) {
433 // Run the command in a shell
434 FileSpec shell = HostInfo::GetDefaultShell();
435 if (!shell_path.empty())
436 shell.SetPath(shell_path);
437
438 launch_info.SetShell(shell);
439 launch_info.GetArguments().AppendArguments(args);
440 const bool will_debug = false;
441 const bool first_arg_is_full_shell_command = false;
443 error, will_debug, first_arg_is_full_shell_command, 0);
444 } else {
445 // No shell, just run it
446 const bool first_arg_is_executable = true;
447 launch_info.SetArguments(args, first_arg_is_executable);
448 }
449
450 launch_info.GetEnvironment() = Host::GetEnvironment();
451
452 if (working_dir)
453 launch_info.SetWorkingDirectory(working_dir);
454 llvm::SmallString<64> output_file_path;
455
456 if (command_output_ptr) {
457 // Create a temporary file to get the stdout/stderr and redirect the output
458 // of the command into this file. We will later read this file if all goes
459 // well and fill the data into "command_output_ptr"
460 if (FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir()) {
461 tmpdir_file_spec.AppendPathComponent("lldb-shell-output.%%%%%%");
462 llvm::sys::fs::createUniqueFile(tmpdir_file_spec.GetPath(),
463 output_file_path);
464 } else {
465 llvm::sys::fs::createTemporaryFile("lldb-shell-output.%%%%%%", "",
466 output_file_path);
467 }
468 }
469
470 FileSpec output_file_spec(output_file_path.str());
471 // Set up file descriptors.
472 launch_info.AppendSuppressFileAction(STDIN_FILENO, true, false);
473 if (output_file_spec)
474 launch_info.AppendOpenFileAction(STDOUT_FILENO, output_file_spec, false,
475 true);
476 else
477 launch_info.AppendSuppressFileAction(STDOUT_FILENO, false, true);
478
479 if (output_file_spec && !hide_stderr)
480 launch_info.AppendDuplicateFileAction(STDOUT_FILENO, STDERR_FILENO);
481 else
482 launch_info.AppendSuppressFileAction(STDERR_FILENO, false, true);
483
484 std::shared_ptr<ShellInfo> shell_info_sp(new ShellInfo());
485 launch_info.SetMonitorProcessCallback(
486 std::bind(MonitorShellCommand, shell_info_sp, std::placeholders::_1,
487 std::placeholders::_2, std::placeholders::_3));
488
489 error = LaunchProcess(launch_info);
490 const lldb::pid_t pid = launch_info.GetProcessID();
491
492 if (error.Success() && pid == LLDB_INVALID_PROCESS_ID)
493 error = Status::FromErrorString("failed to get process ID");
494
495 if (error.Success()) {
496 if (!shell_info_sp->process_reaped.WaitForValueEqualTo(true, timeout)) {
498 "timed out waiting for shell command to complete");
499
500 // Kill the process since it didn't complete within the timeout specified
501 Kill(pid, SIGKILL);
502 // Wait for the monitor callback to get the message
503 shell_info_sp->process_reaped.WaitForValueEqualTo(
504 true, std::chrono::seconds(1));
505 } else {
506 if (status_ptr)
507 *status_ptr = shell_info_sp->status;
508
509 if (signo_ptr)
510 *signo_ptr = shell_info_sp->signo;
511
512 if (command_output_ptr) {
513 command_output_ptr->clear();
514 uint64_t file_size =
515 FileSystem::Instance().GetByteSize(output_file_spec);
516 if (file_size > 0) {
517 if (file_size > command_output_ptr->max_size()) {
519 "shell command output is too large to fit into a std::string");
520 } else {
521 WritableDataBufferSP Buffer =
523 output_file_spec);
524 if (error.Success())
525 command_output_ptr->assign(
526 reinterpret_cast<char *>(Buffer->GetBytes()),
527 Buffer->GetByteSize());
528 }
529 }
530 }
531 }
532 }
533
534 llvm::sys::fs::remove(output_file_spec.GetPath());
535 return error;
536}
537
538// The functions below implement process launching for non-Apple-based
539// platforms
540#if !defined(__APPLE__)
542 std::unique_ptr<ProcessLauncher> delegate_launcher;
543#if defined(_WIN32)
544 delegate_launcher.reset(new ProcessLauncherWindows());
545#else
546 delegate_launcher.reset(new ProcessLauncherPosixFork());
547#endif
548 MonitoringProcessLauncher launcher(std::move(delegate_launcher));
549
551 HostProcess process = launcher.LaunchProcess(launch_info, error);
552
553 // TODO(zturner): It would be better if the entire HostProcess were returned
554 // instead of writing it into this structure.
555 launch_info.SetProcessID(process.GetProcessId());
556
557 return error;
558}
559#endif // !defined(__APPLE__)
560
561#ifndef _WIN32
562void Host::Kill(lldb::pid_t pid, int signo) { ::kill(pid, signo); }
563
564#endif
565
566#if !defined(__APPLE__)
567llvm::Error Host::OpenFileInExternalEditor(llvm::StringRef editor,
568 const FileSpec &file_spec,
569 uint32_t line_no) {
570 return llvm::errorCodeToError(
571 std::error_code(ENOTSUP, std::system_category()));
572}
573
574bool Host::IsInteractiveGraphicSession() { return false; }
575#endif
576
577std::unique_ptr<Connection> Host::CreateDefaultConnection(llvm::StringRef url) {
578#if defined(_WIN32)
579 if (url.starts_with("file://"))
580 return std::unique_ptr<Connection>(new ConnectionGenericFile());
581#endif
582 return std::unique_ptr<Connection>(new ConnectionFileDescriptor());
583}
584
585#if defined(LLVM_ON_UNIX)
586WaitStatus WaitStatus::Decode(int wstatus) {
587 if (WIFEXITED(wstatus))
588 return {Exit, uint8_t(WEXITSTATUS(wstatus))};
589 else if (WIFSIGNALED(wstatus))
590 return {Signal, uint8_t(WTERMSIG(wstatus))};
591 else if (WIFSTOPPED(wstatus))
592 return {Stop, uint8_t(WSTOPSIG(wstatus))};
593 llvm_unreachable("Unknown wait status");
594}
595#endif
596
597void llvm::format_provider<WaitStatus>::format(const WaitStatus &WS,
598 raw_ostream &OS,
599 StringRef Options) {
600 if (Options == "g") {
601 char type;
602 switch (WS.type) {
603 case WaitStatus::Exit:
604 type = 'W';
605 break;
607 type = 'X';
608 break;
609 case WaitStatus::Stop:
610 type = 'S';
611 break;
612 }
613 OS << formatv("{0}{1:x-2}", type, WS.status);
614 return;
615 }
616
617 assert(Options.empty());
618 const char *desc;
619 switch(WS.type) {
620 case WaitStatus::Exit:
621 desc = "Exited with status";
622 break;
624 desc = "Killed by signal";
625 break;
626 case WaitStatus::Stop:
627 desc = "Stopped by signal";
628 break;
629 }
630 OS << desc << " " << int(WS.status);
631}
632
634 ProcessInstanceInfoList &process_infos) {
635 return FindProcessesImpl(match_info, process_infos);
636}
637
639
641
642void SystemLogHandler::Emit(llvm::StringRef message) {
644}
static llvm::raw_ostream & error(Stream &strm)
int __pthread_chdir(const char *path)
int __pthread_fchdir(int fildes)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:369
A command line argument class.
Definition: Args.h:33
void AppendArguments(const Args &rhs)
Definition: Args.cpp:307
A file utility class.
Definition: FileSpec.h:56
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition: FileSpec.cpp:174
void SetPath(llvm::StringRef p)
Temporary helper for FileSystem change.
Definition: FileSpec.h:279
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:367
void Clear()
Clears the object state.
Definition: FileSpec.cpp:259
uint64_t GetByteSize(const FileSpec &file_spec) const
Returns the on-disk size of the given file in bytes.
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
std::shared_ptr< WritableDataBuffer > CreateWritableDataBuffer(const llvm::Twine &path, uint64_t size=0, uint64_t offset=0)
static FileSystem & Instance()
lldb::pid_t GetProcessId() const
Definition: HostProcess.cpp:25
static Status LaunchProcess(ProcessLaunchInfo &launch_info)
Launch the process specified in launch_info.
static bool FindProcessThreads(const lldb::pid_t pid, TidMap &tids_to_attach)
static bool ResolveExecutableInBundle(FileSpec &file)
When executable files may live within a directory, where the directory represents an executable bundl...
static void SystemLog(lldb::Severity severity, llvm::StringRef message)
Emit the given message to the operating system log.
Definition: common/Host.cpp:97
std::map< lldb::pid_t, bool > TidMap
Definition: Host.h:179
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 lldb::thread_t GetCurrentThread()
Get the thread token (the one returned by ThreadCreate when the thread was created) for the calling t...
static Environment GetEnvironment()
static lldb::pid_t GetCurrentProcessID()
Get the process ID for the calling process.
static uint32_t FindProcessesImpl(const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &proc_infos)
static FileSpec GetModuleFileSpecForHostAddress(const void *host_addr)
Given an address in the current process (the process that is running the LLDB code),...
std::function< void(lldb::pid_t pid, int signal, int status)> MonitorChildProcessCallback
Definition: Host.h:88
static uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &proc_infos)
static std::unique_ptr< Connection > CreateDefaultConnection(llvm::StringRef url)
static llvm::Expected< HostThread > StartMonitoringChildProcess(const MonitorChildProcessCallback &callback, lldb::pid_t pid)
Start monitoring a child process.
static void Kill(lldb::pid_t pid, int signo)
static const char * GetSignalAsCString(int signo)
static bool IsInteractiveGraphicSession()
Check if we're running in an interactive graphical session.
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 p...
static llvm::Error OpenFileInExternalEditor(llvm::StringRef editor, const FileSpec &file_spec, uint32_t line_no)
void Disable(std::optional< MaskType > flags=std::nullopt)
Definition: Log.cpp:114
void Enable(const std::shared_ptr< LogHandler > &handler_sp, std::optional< MaskType > flags=std::nullopt, uint32_t options=0)
Definition: Log.cpp:99
HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Status &error) override
Launch the process specified in launch_info.
A command line option parsing protocol class.
Definition: Options.h:58
A C++ wrapper class for providing threaded access to a value of type T.
Definition: Predicate.h:42
void SetArchitecture(const ArchSpec &arch)
Definition: ProcessInfo.h:66
lldb::pid_t GetProcessID() const
Definition: ProcessInfo.h:68
void SetArguments(const Args &args, bool first_arg_is_executable)
void SetProcessID(lldb::pid_t pid)
Definition: ProcessInfo.h:70
Environment & GetEnvironment()
Definition: ProcessInfo.h:88
bool AppendOpenFileAction(int fd, const FileSpec &file_spec, bool read, bool write)
bool AppendSuppressFileAction(int fd, bool read, bool write)
void SetShell(const FileSpec &shell)
void SetMonitorProcessCallback(Host::MonitorChildProcessCallback callback)
bool ConvertArgumentsForLaunchingInShell(Status &error, bool will_debug, bool first_arg_is_full_shell_command, uint32_t num_resumes)
bool AppendDuplicateFileAction(int fd, int dup_fd)
void SetWorkingDirectory(const FileSpec &working_dir)
An error handling class.
Definition: Status.h:115
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition: Status.cpp:106
static Status FromErrorString(const char *str)
Definition: Status.h:138
void Emit(llvm::StringRef message) override
static llvm::Expected< HostThread > LaunchThread(llvm::StringRef name, std::function< lldb::thread_result_t()> thread_function, size_t min_stack_byte_size=0)
static constexpr Log::Category g_categories[]
static bool CheckForMonitorCancellation()
static void MonitorShellCommand(std::shared_ptr< ShellInfo > shell_info, lldb::pid_t pid, int signo, int status)
static Log g_system_log(g_system_channel)
static thread_result_t MonitorChildProcessThreadFunction(::pid_t pid, Host::MonitorChildProcessCallback callback)
static Log::Channel g_system_channel(g_categories, SystemLog::System)
#define UINT32_MAX
Definition: lldb-defines.h:19
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:89
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:332
Log::Channel & LogChannelFor< SystemLog >()
@ eBroadcastAlways
Always send a broadcast when the value is modified.
Definition: Predicate.h:29
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
Definition: Host.h:32
Definition: SBAddress.h:15
Severity
Used for expressing severity in logs and diagnostics.
void * thread_result_t
Definition: lldb-types.h:62
pthread_t thread_t
Definition: lldb-types.h:58
uint64_t pid_t
Definition: lldb-types.h:83
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
Definition: lldb-forward.h:337
lldb_private::Predicate< bool > process_reaped
static WaitStatus Decode(int wstatus)
#define SIGSTOP
#define SIGTRAP
#define SIGKILL