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 <errno.h>
11 #include <limits.h>
12 #include <stdlib.h>
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__)
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 
49 #include "lldb/Host/FileAction.h"
50 #include "lldb/Host/FileSystem.h"
51 #include "lldb/Host/Host.h"
52 #include "lldb/Host/HostInfo.h"
53 #include "lldb/Host/HostProcess.h"
60 #include "lldb/Utility/FileSpec.h"
61 #include "lldb/Utility/Log.h"
62 #include "lldb/Utility/Predicate.h"
63 #include "lldb/Utility/Status.h"
65 #include "llvm/ADT/SmallString.h"
66 #include "llvm/ADT/StringSwitch.h"
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 
82 extern "C" {
83 int __pthread_chdir(const char *path);
84 int __pthread_fchdir(int fildes);
85 }
86 
87 #endif
88 
89 using namespace lldb;
90 using namespace lldb_private;
91 
92 #if !defined(__APPLE__) && !defined(_WIN32)
93 struct MonitorInfo {
94  lldb::pid_t pid; // The process ID to monitor
96  callback; // The callback function to call when "pid" exits or signals
97  bool monitor_signals; // If true, call the callback when "pid" gets signaled.
98 };
99 
101 
102 llvm::Expected<HostThread> Host::StartMonitoringChildProcess(
103  const Host::MonitorChildProcessCallback &callback, lldb::pid_t pid,
104  bool monitor_signals) {
105  MonitorInfo *info_ptr = new MonitorInfo();
106 
107  info_ptr->pid = pid;
108  info_ptr->callback = callback;
109  info_ptr->monitor_signals = monitor_signals;
110 
111  char thread_name[256];
112  ::snprintf(thread_name, sizeof(thread_name),
113  "<lldb.host.wait4(pid=%" PRIu64 ")>", pid);
114  return ThreadLauncher::LaunchThread(
115  thread_name, MonitorChildProcessThreadFunction, info_ptr, 0);
116 }
117 
118 #ifndef __linux__
119 // Scoped class that will disable thread canceling when it is constructed, and
120 // exception safely restore the previous value it when it goes out of scope.
122 public:
124  // Disable the ability for this thread to be cancelled
125  int err = ::pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &m_old_state);
126  if (err != 0)
127  m_old_state = -1;
128  }
129 
131  // Restore the ability for this thread to be cancelled to what it
132  // previously was.
133  if (m_old_state != -1)
134  ::pthread_setcancelstate(m_old_state, 0);
135  }
136 
137 private:
138  int m_old_state; // Save the old cancelability state.
139 };
140 #endif // __linux__
141 
142 #ifdef __linux__
143 #if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8))
144 static __thread volatile sig_atomic_t g_usr1_called;
145 #else
146 static thread_local volatile sig_atomic_t g_usr1_called;
147 #endif
148 
149 static void SigUsr1Handler(int) { g_usr1_called = 1; }
150 #endif // __linux__
151 
153 #ifdef __linux__
154  if (g_usr1_called) {
155  g_usr1_called = 0;
156  return true;
157  }
158 #else
159  ::pthread_testcancel();
160 #endif
161  return false;
162 }
163 
166  const char *function = __FUNCTION__;
167  LLDB_LOGF(log, "%s (arg = %p) thread starting...", function, arg);
168 
169  MonitorInfo *info = (MonitorInfo *)arg;
170 
171  const Host::MonitorChildProcessCallback callback = info->callback;
172  const bool monitor_signals = info->monitor_signals;
173 
174  assert(info->pid <= UINT32_MAX);
175  const ::pid_t pid = monitor_signals ? -1 * getpgid(info->pid) : info->pid;
176 
177  delete info;
178 
179  int status = -1;
180 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
181 #define __WALL 0
182 #endif
183  const int options = __WALL;
184 
185 #ifdef __linux__
186  // This signal is only used to interrupt the thread from waitpid
187  struct sigaction sigUsr1Action;
188  memset(&sigUsr1Action, 0, sizeof(sigUsr1Action));
189  sigUsr1Action.sa_handler = SigUsr1Handler;
190  ::sigaction(SIGUSR1, &sigUsr1Action, nullptr);
191 #endif // __linux__
192 
193  while (1) {
195  LLDB_LOGF(log, "%s ::waitpid (pid = %" PRIi32 ", &status, options = %i)...",
196  function, pid, options);
197 
199  break;
200 
201  // Get signals from all children with same process group of pid
202  const ::pid_t wait_pid = ::waitpid(pid, &status, options);
203 
205  break;
206 
207  if (wait_pid == -1) {
208  if (errno == EINTR)
209  continue;
210  else {
211  LLDB_LOG(log,
212  "arg = {0}, thread exiting because waitpid failed ({1})...",
213  arg, llvm::sys::StrError());
214  break;
215  }
216  } else if (wait_pid > 0) {
217  bool exited = false;
218  int signal = 0;
219  int exit_status = 0;
220  const char *status_cstr = nullptr;
221  if (WIFSTOPPED(status)) {
222  signal = WSTOPSIG(status);
223  status_cstr = "STOPPED";
224  } else if (WIFEXITED(status)) {
225  exit_status = WEXITSTATUS(status);
226  status_cstr = "EXITED";
227  exited = true;
228  } else if (WIFSIGNALED(status)) {
229  signal = WTERMSIG(status);
230  status_cstr = "SIGNALED";
231  if (wait_pid == abs(pid)) {
232  exited = true;
233  exit_status = -1;
234  }
235  } else {
236  status_cstr = "(\?\?\?)";
237  }
238 
239  // Scope for pthread_cancel_disabler
240  {
241 #ifndef __linux__
242  ScopedPThreadCancelDisabler pthread_cancel_disabler;
243 #endif
244 
246  LLDB_LOGF(log,
247  "%s ::waitpid (pid = %" PRIi32
248  ", &status, options = %i) => pid = %" PRIi32
249  ", status = 0x%8.8x (%s), signal = %i, exit_state = %i",
250  function, pid, options, wait_pid, status, status_cstr, signal,
251  exit_status);
252 
253  if (exited || (signal != 0 && monitor_signals)) {
254  bool callback_return = false;
255  if (callback)
256  callback_return = callback(wait_pid, exited, signal, exit_status);
257 
258  // If our process exited, then this thread should exit
259  if (exited && wait_pid == abs(pid)) {
260  LLDB_LOGF(log,
261  "%s (arg = %p) thread exiting because pid received "
262  "exit signal...",
263  __FUNCTION__, arg);
264  break;
265  }
266  // If the callback returns true, it means this process should exit
267  if (callback_return) {
268  LLDB_LOGF(log,
269  "%s (arg = %p) thread exiting because callback "
270  "returned true...",
271  __FUNCTION__, arg);
272  break;
273  }
274  }
275  }
276  }
277  }
278 
280  LLDB_LOGF(log, "%s (arg = %p) thread exiting...", __FUNCTION__, arg);
281 
282  return nullptr;
283 }
284 
285 #endif // #if !defined (__APPLE__) && !defined (_WIN32)
286 
287 #if !defined(__APPLE__)
288 
289 void Host::SystemLog(SystemLogType type, const char *format, va_list args) {
290  vfprintf(stderr, format, args);
291 }
292 
293 #endif
294 
295 void Host::SystemLog(SystemLogType type, const char *format, ...) {
296  {
297  va_list args;
298  va_start(args, format);
299  SystemLog(type, format, args);
300  va_end(args);
301  }
302 
304  if (log && log->GetVerbose()) {
305  // Log to log channel. This allows testcases to grep for log output.
306  va_list args;
307  va_start(args, format);
308  log->VAPrintf(format, args);
309  va_end(args);
310  }
311 }
312 
313 lldb::pid_t Host::GetCurrentProcessID() { return ::getpid(); }
314 
315 #ifndef _WIN32
316 
317 lldb::thread_t Host::GetCurrentThread() {
318  return lldb::thread_t(pthread_self());
319 }
320 
321 const char *Host::GetSignalAsCString(int signo) {
322  switch (signo) {
323  case SIGHUP:
324  return "SIGHUP"; // 1 hangup
325  case SIGINT:
326  return "SIGINT"; // 2 interrupt
327  case SIGQUIT:
328  return "SIGQUIT"; // 3 quit
329  case SIGILL:
330  return "SIGILL"; // 4 illegal instruction (not reset when caught)
331  case SIGTRAP:
332  return "SIGTRAP"; // 5 trace trap (not reset when caught)
333  case SIGABRT:
334  return "SIGABRT"; // 6 abort()
335 #if defined(SIGPOLL)
336 #if !defined(SIGIO) || (SIGPOLL != SIGIO)
337  // Under some GNU/Linux, SIGPOLL and SIGIO are the same. Causing the build to
338  // fail with 'multiple define cases with same value'
339  case SIGPOLL:
340  return "SIGPOLL"; // 7 pollable event ([XSR] generated, not supported)
341 #endif
342 #endif
343 #if defined(SIGEMT)
344  case SIGEMT:
345  return "SIGEMT"; // 7 EMT instruction
346 #endif
347  case SIGFPE:
348  return "SIGFPE"; // 8 floating point exception
349  case SIGKILL:
350  return "SIGKILL"; // 9 kill (cannot be caught or ignored)
351  case SIGBUS:
352  return "SIGBUS"; // 10 bus error
353  case SIGSEGV:
354  return "SIGSEGV"; // 11 segmentation violation
355  case SIGSYS:
356  return "SIGSYS"; // 12 bad argument to system call
357  case SIGPIPE:
358  return "SIGPIPE"; // 13 write on a pipe with no one to read it
359  case SIGALRM:
360  return "SIGALRM"; // 14 alarm clock
361  case SIGTERM:
362  return "SIGTERM"; // 15 software termination signal from kill
363  case SIGURG:
364  return "SIGURG"; // 16 urgent condition on IO channel
365  case SIGSTOP:
366  return "SIGSTOP"; // 17 sendable stop signal not from tty
367  case SIGTSTP:
368  return "SIGTSTP"; // 18 stop signal from tty
369  case SIGCONT:
370  return "SIGCONT"; // 19 continue a stopped process
371  case SIGCHLD:
372  return "SIGCHLD"; // 20 to parent on child stop or exit
373  case SIGTTIN:
374  return "SIGTTIN"; // 21 to readers pgrp upon background tty read
375  case SIGTTOU:
376  return "SIGTTOU"; // 22 like TTIN for output if (tp->t_local&LTOSTOP)
377 #if defined(SIGIO)
378  case SIGIO:
379  return "SIGIO"; // 23 input/output possible signal
380 #endif
381  case SIGXCPU:
382  return "SIGXCPU"; // 24 exceeded CPU time limit
383  case SIGXFSZ:
384  return "SIGXFSZ"; // 25 exceeded file size limit
385  case SIGVTALRM:
386  return "SIGVTALRM"; // 26 virtual time alarm
387  case SIGPROF:
388  return "SIGPROF"; // 27 profiling time alarm
389 #if defined(SIGWINCH)
390  case SIGWINCH:
391  return "SIGWINCH"; // 28 window size changes
392 #endif
393 #if defined(SIGINFO)
394  case SIGINFO:
395  return "SIGINFO"; // 29 information request
396 #endif
397  case SIGUSR1:
398  return "SIGUSR1"; // 30 user defined signal 1
399  case SIGUSR2:
400  return "SIGUSR2"; // 31 user defined signal 2
401  default:
402  break;
403  }
404  return nullptr;
405 }
406 
407 #endif
408 
409 #if !defined(__APPLE__) // see Host.mm
410 
411 bool Host::GetBundleDirectory(const FileSpec &file, FileSpec &bundle) {
412  bundle.Clear();
413  return false;
414 }
415 
416 bool Host::ResolveExecutableInBundle(FileSpec &file) { return false; }
417 #endif
418 
419 #ifndef _WIN32
420 
421 FileSpec Host::GetModuleFileSpecForHostAddress(const void *host_addr) {
422  FileSpec module_filespec;
423 #if !defined(__ANDROID__)
424  Dl_info info;
425  if (::dladdr(host_addr, &info)) {
426  if (info.dli_fname) {
427  module_filespec.SetFile(info.dli_fname, FileSpec::Style::native);
428  FileSystem::Instance().Resolve(module_filespec);
429  }
430  }
431 #endif
432  return module_filespec;
433 }
434 
435 #endif
436 
437 #if !defined(__linux__)
438 bool Host::FindProcessThreads(const lldb::pid_t pid, TidMap &tids_to_attach) {
439  return false;
440 }
441 #endif
442 
443 struct ShellInfo {
445  : process_reaped(false), pid(LLDB_INVALID_PROCESS_ID), signo(-1),
446  status(-1) {}
447 
450  int signo;
451  int status;
452 };
453 
454 static bool
455 MonitorShellCommand(std::shared_ptr<ShellInfo> shell_info, lldb::pid_t pid,
456  bool exited, // True if the process did exit
457  int signo, // Zero for no signal
458  int status) // Exit value of process if signal is zero
459 {
460  shell_info->pid = pid;
461  shell_info->signo = signo;
462  shell_info->status = status;
463  // Let the thread running Host::RunShellCommand() know that the process
464  // exited and that ShellInfo has been filled in by broadcasting to it
465  shell_info->process_reaped.SetValue(true, eBroadcastAlways);
466  return true;
467 }
468 
469 Status Host::RunShellCommand(const char *command, const FileSpec &working_dir,
470  int *status_ptr, int *signo_ptr,
471  std::string *command_output_ptr,
472  const Timeout<std::micro> &timeout,
473  bool run_in_default_shell,
474  bool hide_stderr) {
475  return RunShellCommand(Args(command), working_dir, status_ptr, signo_ptr,
476  command_output_ptr, timeout, run_in_default_shell,
477  hide_stderr);
478 }
479 
480 Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir,
481  int *status_ptr, int *signo_ptr,
482  std::string *command_output_ptr,
483  const Timeout<std::micro> &timeout,
484  bool run_in_default_shell,
485  bool hide_stderr) {
486  Status error;
487  ProcessLaunchInfo launch_info;
488  launch_info.SetArchitecture(HostInfo::GetArchitecture());
489  if (run_in_default_shell) {
490  // Run the command in a shell
491  launch_info.SetShell(HostInfo::GetDefaultShell());
492  launch_info.GetArguments().AppendArguments(args);
493  const bool localhost = true;
494  const bool will_debug = false;
495  const bool first_arg_is_full_shell_command = false;
497  error, localhost, will_debug, first_arg_is_full_shell_command, 0);
498  } else {
499  // No shell, just run it
500  const bool first_arg_is_executable = true;
501  launch_info.SetArguments(args, first_arg_is_executable);
502  }
503 
504  launch_info.GetEnvironment() = Host::GetEnvironment();
505 
506  if (working_dir)
507  launch_info.SetWorkingDirectory(working_dir);
508  llvm::SmallString<64> output_file_path;
509 
510  if (command_output_ptr) {
511  // Create a temporary file to get the stdout/stderr and redirect the output
512  // of the command into this file. We will later read this file if all goes
513  // well and fill the data into "command_output_ptr"
514  if (FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir()) {
515  tmpdir_file_spec.AppendPathComponent("lldb-shell-output.%%%%%%");
516  llvm::sys::fs::createUniqueFile(tmpdir_file_spec.GetPath(),
517  output_file_path);
518  } else {
519  llvm::sys::fs::createTemporaryFile("lldb-shell-output.%%%%%%", "",
520  output_file_path);
521  }
522  }
523 
524  FileSpec output_file_spec(output_file_path.str());
525  // Set up file descriptors.
526  launch_info.AppendSuppressFileAction(STDIN_FILENO, true, false);
527  if (output_file_spec)
528  launch_info.AppendOpenFileAction(STDOUT_FILENO, output_file_spec, false,
529  true);
530  else
531  launch_info.AppendSuppressFileAction(STDOUT_FILENO, false, true);
532 
533  if (output_file_spec && !hide_stderr)
534  launch_info.AppendDuplicateFileAction(STDOUT_FILENO, STDERR_FILENO);
535  else
536  launch_info.AppendSuppressFileAction(STDERR_FILENO, false, true);
537 
538  std::shared_ptr<ShellInfo> shell_info_sp(new ShellInfo());
539  const bool monitor_signals = false;
540  launch_info.SetMonitorProcessCallback(
541  std::bind(MonitorShellCommand, shell_info_sp, std::placeholders::_1,
542  std::placeholders::_2, std::placeholders::_3,
543  std::placeholders::_4),
544  monitor_signals);
545 
546  error = LaunchProcess(launch_info);
547  const lldb::pid_t pid = launch_info.GetProcessID();
548 
549  if (error.Success() && pid == LLDB_INVALID_PROCESS_ID)
550  error.SetErrorString("failed to get process ID");
551 
552  if (error.Success()) {
553  if (!shell_info_sp->process_reaped.WaitForValueEqualTo(true, timeout)) {
554  error.SetErrorString("timed out waiting for shell command to complete");
555 
556  // Kill the process since it didn't complete within the timeout specified
557  Kill(pid, SIGKILL);
558  // Wait for the monitor callback to get the message
559  shell_info_sp->process_reaped.WaitForValueEqualTo(
560  true, std::chrono::seconds(1));
561  } else {
562  if (status_ptr)
563  *status_ptr = shell_info_sp->status;
564 
565  if (signo_ptr)
566  *signo_ptr = shell_info_sp->signo;
567 
568  if (command_output_ptr) {
569  command_output_ptr->clear();
570  uint64_t file_size =
571  FileSystem::Instance().GetByteSize(output_file_spec);
572  if (file_size > 0) {
573  if (file_size > command_output_ptr->max_size()) {
575  "shell command output is too large to fit into a std::string");
576  } else {
577  auto Buffer =
578  FileSystem::Instance().CreateDataBuffer(output_file_spec);
579  if (error.Success())
580  command_output_ptr->assign(Buffer->GetChars(),
581  Buffer->GetByteSize());
582  }
583  }
584  }
585  }
586  }
587 
588  llvm::sys::fs::remove(output_file_spec.GetPath());
589  return error;
590 }
591 
592 // The functions below implement process launching for non-Apple-based
593 // platforms
594 #if !defined(__APPLE__)
595 Status Host::LaunchProcess(ProcessLaunchInfo &launch_info) {
596  std::unique_ptr<ProcessLauncher> delegate_launcher;
597 #if defined(_WIN32)
598  delegate_launcher.reset(new ProcessLauncherWindows());
599 #else
600  delegate_launcher.reset(new ProcessLauncherPosixFork());
601 #endif
602  MonitoringProcessLauncher launcher(std::move(delegate_launcher));
603 
604  Status error;
605  HostProcess process = launcher.LaunchProcess(launch_info, error);
606 
607  // TODO(zturner): It would be better if the entire HostProcess were returned
608  // instead of writing it into this structure.
609  launch_info.SetProcessID(process.GetProcessId());
610 
611  return error;
612 }
613 #endif // !defined(__APPLE__)
614 
615 #ifndef _WIN32
616 void Host::Kill(lldb::pid_t pid, int signo) { ::kill(pid, signo); }
617 
618 #endif
619 
620 #if !defined(__APPLE__)
621 bool Host::OpenFileInExternalEditor(const FileSpec &file_spec,
622  uint32_t line_no) {
623  return false;
624 }
625 
626 #endif
627 
628 std::unique_ptr<Connection> Host::CreateDefaultConnection(llvm::StringRef url) {
629 #if defined(_WIN32)
630  if (url.startswith("file://"))
631  return std::unique_ptr<Connection>(new ConnectionGenericFile());
632 #endif
633  return std::unique_ptr<Connection>(new ConnectionFileDescriptor());
634 }
635 
636 #if defined(LLVM_ON_UNIX)
637 WaitStatus WaitStatus::Decode(int wstatus) {
638  if (WIFEXITED(wstatus))
639  return {Exit, uint8_t(WEXITSTATUS(wstatus))};
640  else if (WIFSIGNALED(wstatus))
641  return {Signal, uint8_t(WTERMSIG(wstatus))};
642  else if (WIFSTOPPED(wstatus))
643  return {Stop, uint8_t(WSTOPSIG(wstatus))};
644  llvm_unreachable("Unknown wait status");
645 }
646 #endif
647 
648 void llvm::format_provider<WaitStatus>::format(const WaitStatus &WS,
649  raw_ostream &OS,
650  StringRef Options) {
651  if (Options == "g") {
652  char type;
653  switch (WS.type) {
654  case WaitStatus::Exit:
655  type = 'W';
656  break;
657  case WaitStatus::Signal:
658  type = 'X';
659  break;
660  case WaitStatus::Stop:
661  type = 'S';
662  break;
663  }
664  OS << formatv("{0}{1:x-2}", type, WS.status);
665  return;
666  }
667 
668  assert(Options.empty());
669  const char *desc;
670  switch(WS.type) {
671  case WaitStatus::Exit:
672  desc = "Exited with status";
673  break;
674  case WaitStatus::Signal:
675  desc = "Killed by signal";
676  break;
677  case WaitStatus::Stop:
678  desc = "Stopped by signal";
679  break;
680  }
681  OS << desc << " " << int(WS.status);
682 }
683 
684 uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
685  ProcessInstanceInfoList &process_infos) {
686 
687  if (llvm::Optional<ProcessInstanceInfoList> infos =
689  process_infos = *infos;
690  return process_infos.size();
691  }
692 
693  uint32_t result = FindProcessesImpl(match_info, process_infos);
694 
695  if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) {
696  g->GetOrCreate<repro::ProcessInfoProvider>()
697  .GetNewProcessInfoRecorder()
698  ->Record(process_infos);
699  }
700 
701  return result;
702 }
A command line argument class.
Definition: Args.h:33
static bool MonitorShellCommand(std::shared_ptr< ShellInfo > shell_info, lldb::pid_t pid, bool exited, int signo, int status)
#define LIBLLDB_LOG_PROCESS
Definition: Logging.h:15
A class that represents a running process on the host machine.
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
Definition: Host.h:30
void SetArchitecture(const ArchSpec &arch)
Definition: ProcessInfo.h:66
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:92
lldb::pid_t pid
bool AppendSuppressFileAction(int fd, bool read, bool write)
int __pthread_fchdir(int fildes)
void SetProcessID(lldb::pid_t pid)
Definition: ProcessInfo.h:70
A file utility class.
Definition: FileSpec.h:56
bool monitor_signals
Definition: common/Host.cpp:97
void Clear()
Clears the object state.
Definition: FileSpec.cpp:261
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:242
void SetArguments(const Args &args, bool first_arg_is_executable)
Definition: ProcessInfo.cpp:97
#define SIGSTOP
#define UINT32_MAX
Definition: lldb-defines.h:31
lldb_private::Predicate< bool > process_reaped
#define LIBLLDB_LOG_HOST
Definition: Logging.h:28
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:58
HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Status &error) override
Launch the process specified in launch_info.
bool AppendOpenFileAction(int fd, const FileSpec &file_spec, bool read, bool write)
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:242
Environment & GetEnvironment()
Definition: ProcessInfo.h:88
bool GetVerbose() const
Definition: Log.cpp:275
bool Success() const
Test for success condition.
Definition: Status.cpp:288
Always send a broadcast when the value is modified.
Definition: Predicate.h:28
llvm::Optional< ProcessInstanceInfoList > GetReplayProcessInstanceInfoList()
int __pthread_chdir(const char *path)
#define SIGKILL
#define LLDB_LOGF(log,...)
Definition: Log.h:249
pthread_t thread_t
Definition: lldb-types.h:58
A command line option parsing protocol class.
Definition: Options.h:62
bool ConvertArgumentsForLaunchingInShell(Status &error, bool localhost, bool will_debug, bool first_arg_is_full_shell_command, int32_t num_resumes)
The generator is responsible for the logic needed to generate a reproducer.
Definition: Reproducer.h:225
void SetWorkingDirectory(const FileSpec &working_dir)
Definition: SBAddress.h:15
uint64_t pid_t
Definition: lldb-types.h:85
std::map< lldb::pid_t, bool > TidMap
Definition: Host.h:180
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
Definition: Status.cpp:256
static bool CheckForMonitorCancellation()
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition: FileSpec.cpp:174
#define SIGTRAP
std::function< bool(lldb::pid_t pid, bool exited, int signal, int status)> MonitorChildProcessCallback
Definition: Host.h:68
void AppendArguments(const Args &rhs)
Definition: Args.cpp:290
void SetMonitorProcessCallback(const Host::MonitorChildProcessCallback &callback, bool monitor_signals)
lldb::pid_t GetProcessId() const
Definition: HostProcess.cpp:29
void SetShell(const FileSpec &shell)
lldb::pid_t GetProcessID() const
Definition: ProcessInfo.h:68
static thread_result_t MonitorChildProcessThreadFunction(void *arg)
lldb::pid_t pid
Definition: common/Host.cpp:94
void VAPrintf(const char *format, va_list args)
Definition: Log.cpp:131
bool AppendDuplicateFileAction(int fd, int dup_fd)
Host::MonitorChildProcessCallback callback
Definition: common/Host.cpp:96
An error handling class.
Definition: Status.h:44
void * thread_result_t
Definition: lldb-types.h:62