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