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)
117extern "C" char **environ;
118
120
121static thread_result_t
124
125llvm::Expected<HostThread> Host::StartMonitoringChildProcess(
126 const Host::MonitorChildProcessCallback &callback, lldb::pid_t pid) {
127 char thread_name[256];
128 ::snprintf(thread_name, sizeof(thread_name),
129 "<lldb.host.wait4(pid=%" PRIu64 ")>", pid);
130 assert(pid <= UINT32_MAX);
131 return ThreadLauncher::LaunchThread(thread_name, [pid, callback] {
132 return MonitorChildProcessThreadFunction(pid, callback);
133 });
134}
135
136#ifndef __linux__
137// Scoped class that will disable thread canceling when it is constructed, and
138// exception safely restore the previous value it when it goes out of scope.
140public:
142 // Disable the ability for this thread to be cancelled
143 int err = ::pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &m_old_state);
144 if (err != 0)
145 m_old_state = -1;
146 }
147
149 // Restore the ability for this thread to be cancelled to what it
150 // previously was.
151 if (m_old_state != -1)
152 ::pthread_setcancelstate(m_old_state, 0);
153 }
154
155private:
156 int m_old_state; // Save the old cancelability state.
157};
158#endif // __linux__
159
160#ifdef __linux__
161static thread_local volatile sig_atomic_t g_usr1_called;
162
163static void SigUsr1Handler(int) { g_usr1_called = 1; }
164#endif // __linux__
165
167#ifdef __linux__
168 if (g_usr1_called) {
169 g_usr1_called = 0;
170 return true;
171 }
172#else
173 ::pthread_testcancel();
174#endif
175 return false;
176}
177
178static thread_result_t
182 LLDB_LOG(log, "pid = {0}", pid);
183
184 int status = -1;
185
186#ifdef __linux__
187 // This signal is only used to interrupt the thread from waitpid
188 struct sigaction sigUsr1Action;
189 memset(&sigUsr1Action, 0, sizeof(sigUsr1Action));
190 sigUsr1Action.sa_handler = SigUsr1Handler;
191 ::sigaction(SIGUSR1, &sigUsr1Action, nullptr);
192#endif // __linux__
193
194 while (true) {
196 LLDB_LOG(log, "::waitpid({0}, &status, 0)...", pid);
197
199 return nullptr;
200
201 const ::pid_t wait_pid = ::waitpid(pid, &status, 0);
202
203 LLDB_LOG(log, "::waitpid({0}, &status, 0) => pid = {1}, status = {2:x}", pid,
204 wait_pid, status);
205
207 return nullptr;
208
209 if (wait_pid != -1)
210 break;
211 if (errno != EINTR) {
212 LLDB_LOG(log, "pid = {0}, thread exiting because waitpid failed ({1})...",
213 pid, llvm::sys::StrError());
214 return nullptr;
215 }
216 }
217
218 int signal = 0;
219 int exit_status = 0;
220 if (WIFEXITED(status)) {
221 exit_status = WEXITSTATUS(status);
222 } else if (WIFSIGNALED(status)) {
223 signal = WTERMSIG(status);
224 exit_status = -1;
225 } else {
226 llvm_unreachable("Unknown status");
227 }
228
229 // Scope for pthread_cancel_disabler
230 {
231#ifndef __linux__
232 ScopedPThreadCancelDisabler pthread_cancel_disabler;
233#endif
234
235 if (callback)
236 callback(pid, signal, exit_status);
237 }
238
239 LLDB_LOG(GetLog(LLDBLog::Process), "pid = {0} thread exiting...", pid);
240 return nullptr;
241}
242
243#endif // #if !defined (__APPLE__) && !defined (_WIN32)
244
246
247#ifndef _WIN32
248
250 return lldb::thread_t(pthread_self());
251}
252
253const char *Host::GetSignalAsCString(int signo) {
254 switch (signo) {
255 case SIGHUP:
256 return "SIGHUP"; // 1 hangup
257 case SIGINT:
258 return "SIGINT"; // 2 interrupt
259 case SIGQUIT:
260 return "SIGQUIT"; // 3 quit
261 case SIGILL:
262 return "SIGILL"; // 4 illegal instruction (not reset when caught)
263 case SIGTRAP:
264 return "SIGTRAP"; // 5 trace trap (not reset when caught)
265 case SIGABRT:
266 return "SIGABRT"; // 6 abort()
267#if defined(SIGPOLL)
268#if !defined(SIGIO) || (SIGPOLL != SIGIO)
269 // Under some GNU/Linux, SIGPOLL and SIGIO are the same. Causing the build to
270 // fail with 'multiple define cases with same value'
271 case SIGPOLL:
272 return "SIGPOLL"; // 7 pollable event ([XSR] generated, not supported)
273#endif
274#endif
275#if defined(SIGEMT)
276 case SIGEMT:
277 return "SIGEMT"; // 7 EMT instruction
278#endif
279 case SIGFPE:
280 return "SIGFPE"; // 8 floating point exception
281 case SIGKILL:
282 return "SIGKILL"; // 9 kill (cannot be caught or ignored)
283 case SIGBUS:
284 return "SIGBUS"; // 10 bus error
285 case SIGSEGV:
286 return "SIGSEGV"; // 11 segmentation violation
287 case SIGSYS:
288 return "SIGSYS"; // 12 bad argument to system call
289 case SIGPIPE:
290 return "SIGPIPE"; // 13 write on a pipe with no one to read it
291 case SIGALRM:
292 return "SIGALRM"; // 14 alarm clock
293 case SIGTERM:
294 return "SIGTERM"; // 15 software termination signal from kill
295 case SIGURG:
296 return "SIGURG"; // 16 urgent condition on IO channel
297 case SIGSTOP:
298 return "SIGSTOP"; // 17 sendable stop signal not from tty
299 case SIGTSTP:
300 return "SIGTSTP"; // 18 stop signal from tty
301 case SIGCONT:
302 return "SIGCONT"; // 19 continue a stopped process
303 case SIGCHLD:
304 return "SIGCHLD"; // 20 to parent on child stop or exit
305 case SIGTTIN:
306 return "SIGTTIN"; // 21 to readers pgrp upon background tty read
307 case SIGTTOU:
308 return "SIGTTOU"; // 22 like TTIN for output if (tp->t_local&LTOSTOP)
309#if defined(SIGIO)
310 case SIGIO:
311 return "SIGIO"; // 23 input/output possible signal
312#endif
313 case SIGXCPU:
314 return "SIGXCPU"; // 24 exceeded CPU time limit
315 case SIGXFSZ:
316 return "SIGXFSZ"; // 25 exceeded file size limit
317 case SIGVTALRM:
318 return "SIGVTALRM"; // 26 virtual time alarm
319 case SIGPROF:
320 return "SIGPROF"; // 27 profiling time alarm
321#if defined(SIGWINCH)
322 case SIGWINCH:
323 return "SIGWINCH"; // 28 window size changes
324#endif
325#if defined(SIGINFO)
326 case SIGINFO:
327 return "SIGINFO"; // 29 information request
328#endif
329 case SIGUSR1:
330 return "SIGUSR1"; // 30 user defined signal 1
331 case SIGUSR2:
332 return "SIGUSR2"; // 31 user defined signal 2
333 default:
334 break;
335 }
336 return nullptr;
337}
338
339#endif
340
341#if !defined(__APPLE__) // see Host.mm
342
343bool Host::GetBundleDirectory(const FileSpec &file, FileSpec &bundle) {
344 bundle.Clear();
345 return false;
346}
347
348bool Host::ResolveExecutableInBundle(FileSpec &file) { return false; }
349#endif
350
351#ifndef _WIN32
352
354 FileSpec module_filespec;
355#if !defined(__ANDROID__)
356 Dl_info info;
357 if (::dladdr(host_addr, &info)) {
358 if (info.dli_fname) {
359 module_filespec.SetFile(info.dli_fname, FileSpec::Style::native);
360 FileSystem::Instance().Resolve(module_filespec);
361 }
362 }
363#endif
364 return module_filespec;
365}
366
367#endif
368
369#if !defined(__linux__)
370bool Host::FindProcessThreads(const lldb::pid_t pid, TidMap &tids_to_attach) {
371 return false;
372}
373#endif
374
375struct ShellInfo {
376 ShellInfo() : process_reaped(false) {}
377
380 int signo = -1;
381 int status = -1;
382};
383
384static void
385MonitorShellCommand(std::shared_ptr<ShellInfo> shell_info, lldb::pid_t pid,
386 int signo, // Zero for no signal
387 int status) // Exit value of process if signal is zero
388{
389 shell_info->pid = pid;
390 shell_info->signo = signo;
391 shell_info->status = status;
392 // Let the thread running Host::RunShellCommand() know that the process
393 // exited and that ShellInfo has been filled in by broadcasting to it
394 shell_info->process_reaped.SetValue(true, eBroadcastAlways);
395}
396
397Status Host::RunShellCommand(llvm::StringRef command,
398 const FileSpec &working_dir, int *status_ptr,
399 int *signo_ptr, std::string *command_output_ptr,
400 const Timeout<std::micro> &timeout,
401 bool run_in_shell, bool hide_stderr) {
402 return RunShellCommand(llvm::StringRef(), Args(command), working_dir,
403 status_ptr, signo_ptr, command_output_ptr, timeout,
404 run_in_shell, hide_stderr);
405}
406
407Status Host::RunShellCommand(llvm::StringRef shell_path,
408 llvm::StringRef command,
409 const FileSpec &working_dir, int *status_ptr,
410 int *signo_ptr, std::string *command_output_ptr,
411 const Timeout<std::micro> &timeout,
412 bool run_in_shell, bool hide_stderr) {
413 return RunShellCommand(shell_path, Args(command), working_dir, status_ptr,
414 signo_ptr, command_output_ptr, timeout, run_in_shell,
415 hide_stderr);
416}
417
418Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir,
419 int *status_ptr, int *signo_ptr,
420 std::string *command_output_ptr,
421 const Timeout<std::micro> &timeout,
422 bool run_in_shell, bool hide_stderr) {
423 return RunShellCommand(llvm::StringRef(), args, working_dir, status_ptr,
424 signo_ptr, command_output_ptr, timeout, run_in_shell,
425 hide_stderr);
426}
427
428Status Host::RunShellCommand(llvm::StringRef shell_path, const Args &args,
429 const FileSpec &working_dir, int *status_ptr,
430 int *signo_ptr, std::string *command_output_ptr,
431 const Timeout<std::micro> &timeout,
432 bool run_in_shell, bool hide_stderr) {
434 ProcessLaunchInfo launch_info;
435 launch_info.SetArchitecture(HostInfo::GetArchitecture());
436 if (run_in_shell) {
437 // Run the command in a shell
438 FileSpec shell = HostInfo::GetDefaultShell();
439 if (!shell_path.empty())
440 shell.SetPath(shell_path);
441
442 launch_info.SetShell(shell);
443 launch_info.GetArguments().AppendArguments(args);
444 const bool will_debug = false;
445 const bool first_arg_is_full_shell_command = false;
447 error, will_debug, first_arg_is_full_shell_command, 0);
448 } else {
449 // No shell, just run it
450 const bool first_arg_is_executable = true;
451 launch_info.SetArguments(args, first_arg_is_executable);
452 }
453
454 launch_info.GetEnvironment() = Host::GetEnvironment();
455
456 if (working_dir)
457 launch_info.SetWorkingDirectory(working_dir);
458 llvm::SmallString<64> output_file_path;
459
460 if (command_output_ptr) {
461 // Create a temporary file to get the stdout/stderr and redirect the output
462 // of the command into this file. We will later read this file if all goes
463 // well and fill the data into "command_output_ptr"
464 if (FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir()) {
465 tmpdir_file_spec.AppendPathComponent("lldb-shell-output.%%%%%%");
466 llvm::sys::fs::createUniqueFile(tmpdir_file_spec.GetPath(),
467 output_file_path);
468 } else {
469 llvm::sys::fs::createTemporaryFile("lldb-shell-output.%%%%%%", "",
470 output_file_path);
471 }
472 }
473
474 FileSpec output_file_spec(output_file_path.str());
475 // Set up file descriptors.
476 launch_info.AppendSuppressFileAction(STDIN_FILENO, true, false);
477 if (output_file_spec)
478 launch_info.AppendOpenFileAction(STDOUT_FILENO, output_file_spec, false,
479 true);
480 else
481 launch_info.AppendSuppressFileAction(STDOUT_FILENO, false, true);
482
483 if (output_file_spec && !hide_stderr)
484 launch_info.AppendDuplicateFileAction(STDOUT_FILENO, STDERR_FILENO);
485 else
486 launch_info.AppendSuppressFileAction(STDERR_FILENO, false, true);
487
488 std::shared_ptr<ShellInfo> shell_info_sp(new ShellInfo());
489 launch_info.SetMonitorProcessCallback(
490 std::bind(MonitorShellCommand, shell_info_sp, std::placeholders::_1,
491 std::placeholders::_2, std::placeholders::_3));
492
493 error = LaunchProcess(launch_info);
494 const lldb::pid_t pid = launch_info.GetProcessID();
495
496 if (error.Success() && pid == LLDB_INVALID_PROCESS_ID)
497 error = Status::FromErrorString("failed to get process ID");
498
499 if (error.Success()) {
500 if (!shell_info_sp->process_reaped.WaitForValueEqualTo(true, timeout)) {
502 "timed out waiting for shell command to complete");
503
504 // Kill the process since it didn't complete within the timeout specified
505 Kill(pid, SIGKILL);
506 // Wait for the monitor callback to get the message
507 shell_info_sp->process_reaped.WaitForValueEqualTo(
508 true, std::chrono::seconds(1));
509 } else {
510 if (status_ptr)
511 *status_ptr = shell_info_sp->status;
512
513 if (signo_ptr)
514 *signo_ptr = shell_info_sp->signo;
515
516 if (command_output_ptr) {
517 command_output_ptr->clear();
518 uint64_t file_size =
519 FileSystem::Instance().GetByteSize(output_file_spec);
520 if (file_size > 0) {
521 if (file_size > command_output_ptr->max_size()) {
523 "shell command output is too large to fit into a std::string");
524 } else {
525 WritableDataBufferSP Buffer =
527 output_file_spec);
528 if (error.Success())
529 command_output_ptr->assign(
530 reinterpret_cast<char *>(Buffer->GetBytes()),
531 Buffer->GetByteSize());
532 }
533 }
534 }
535 }
536 }
537
538 llvm::sys::fs::remove(output_file_spec.GetPath());
539 return error;
540}
541
542// The functions below implement process launching for non-Apple-based
543// platforms
544#if !defined(__APPLE__)
546 std::unique_ptr<ProcessLauncher> delegate_launcher;
547#if defined(_WIN32)
548 delegate_launcher.reset(new ProcessLauncherWindows());
549#else
550 delegate_launcher.reset(new ProcessLauncherPosixFork());
551#endif
552 MonitoringProcessLauncher launcher(std::move(delegate_launcher));
553
555 HostProcess process = launcher.LaunchProcess(launch_info, error);
556
557 // TODO(zturner): It would be better if the entire HostProcess were returned
558 // instead of writing it into this structure.
559 launch_info.SetProcessID(process.GetProcessId());
560
561 return error;
562}
563#endif // !defined(__APPLE__)
564
565#ifndef _WIN32
566void Host::Kill(lldb::pid_t pid, int signo) { ::kill(pid, signo); }
567
568#endif
569
570#if !defined(__APPLE__)
571llvm::Error Host::OpenFileInExternalEditor(llvm::StringRef editor,
572 const FileSpec &file_spec,
573 uint32_t line_no) {
574 return llvm::errorCodeToError(
575 std::error_code(ENOTSUP, std::system_category()));
576}
577
578bool Host::IsInteractiveGraphicSession() { return false; }
579#endif
580
581std::unique_ptr<Connection> Host::CreateDefaultConnection(llvm::StringRef url) {
582#if defined(_WIN32)
583 if (url.starts_with("file://"))
584 return std::unique_ptr<Connection>(new ConnectionGenericFile());
585#endif
586 return std::unique_ptr<Connection>(new ConnectionFileDescriptor());
587}
588
589#if defined(LLVM_ON_UNIX)
590WaitStatus WaitStatus::Decode(int wstatus) {
591 if (WIFEXITED(wstatus))
592 return {Exit, uint8_t(WEXITSTATUS(wstatus))};
593 else if (WIFSIGNALED(wstatus))
594 return {Signal, uint8_t(WTERMSIG(wstatus))};
595 else if (WIFSTOPPED(wstatus))
596 return {Stop, uint8_t(WSTOPSIG(wstatus))};
597 llvm_unreachable("Unknown wait status");
598}
599#endif
600
601void llvm::format_provider<WaitStatus>::format(const WaitStatus &WS,
602 raw_ostream &OS,
603 StringRef Options) {
604 if (Options == "g") {
605 char type;
606 switch (WS.type) {
607 case WaitStatus::Exit:
608 type = 'W';
609 break;
611 type = 'X';
612 break;
613 case WaitStatus::Stop:
614 type = 'S';
615 break;
616 }
617 OS << formatv("{0}{1:x-2}", type, WS.status);
618 return;
619 }
620
621 assert(Options.empty());
622 const char *desc;
623 switch(WS.type) {
624 case WaitStatus::Exit:
625 desc = "Exited with status";
626 break;
628 desc = "Killed by signal";
629 break;
630 case WaitStatus::Stop:
631 desc = "Stopped by signal";
632 break;
633 }
634 OS << desc << " " << int(WS.status);
635}
636
638 ProcessInstanceInfoList &process_infos) {
639 return FindProcessesImpl(match_info, process_infos);
640}
641
643
645
646void SystemLogHandler::Emit(llvm::StringRef message) {
648}
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:118
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition: Status.cpp:106
static Status FromErrorString(const char *str)
Definition: Status.h:141
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)
char ** environ
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