LLDB  mainline
ProcessFreeBSD.cpp
Go to the documentation of this file.
1 //===-- ProcessFreeBSD.cpp ----------------------------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include <errno.h>
11 #include <pthread.h>
12 #include <pthread_np.h>
13 #include <stdlib.h>
14 #include <sys/sysctl.h>
15 #include <sys/types.h>
16 #include <sys/user.h>
17 #include <machine/elf.h>
18 
19 #include <mutex>
20 #include <unordered_map>
21 
23 #include "lldb/Host/FileSystem.h"
24 #include "lldb/Host/Host.h"
25 #include "lldb/Symbol/ObjectFile.h"
27 #include "lldb/Target/Target.h"
29 #include "lldb/Utility/State.h"
30 
31 #include "FreeBSDThread.h"
35 #include "ProcessFreeBSD.h"
36 #include "ProcessMonitor.h"
37 
40 #include "lldb/Core/Module.h"
41 #include "lldb/Core/ModuleSpec.h"
43 #include "lldb/Host/Host.h"
44 #include "lldb/Symbol/ObjectFile.h"
46 #include "lldb/Target/Platform.h"
47 #include "lldb/Target/Target.h"
49 #include "lldb/Utility/FileSpec.h"
50 #include "lldb/Utility/State.h"
51 
52 #include "lldb/Host/posix/Fcntl.h"
53 
54 #include "llvm/Support/FileSystem.h"
55 #include "llvm/Support/Threading.h"
56 
57 using namespace lldb;
58 using namespace lldb_private;
59 
60 namespace {
61 UnixSignalsSP &GetFreeBSDSignals() {
62  static UnixSignalsSP s_freebsd_signals_sp(new FreeBSDSignals());
63  return s_freebsd_signals_sp;
64 }
65 }
66 
67 // Static functions.
68 
69 lldb::ProcessSP
70 ProcessFreeBSD::CreateInstance(lldb::TargetSP target_sp,
71  lldb::ListenerSP listener_sp,
72  const FileSpec *crash_file_path) {
73  lldb::ProcessSP process_sp;
74  if (crash_file_path == NULL)
75  process_sp.reset(
76  new ProcessFreeBSD(target_sp, listener_sp, GetFreeBSDSignals()));
77  return process_sp;
78 }
79 
81  static llvm::once_flag g_once_flag;
82 
83  llvm::call_once(g_once_flag, []() {
84  PluginManager::RegisterPlugin(GetPluginNameStatic(),
85  GetPluginDescriptionStatic(), CreateInstance);
86  });
87 }
88 
90  static ConstString g_name("freebsd");
91  return g_name;
92 }
93 
95  return "Process plugin for FreeBSD";
96 }
97 
98 // ProcessInterface protocol.
99 
101  return GetPluginNameStatic();
102 }
103 
105 
107 
108 Status ProcessFreeBSD::DoDetach(bool keep_stopped) {
109  Status error;
110  if (keep_stopped) {
111  error.SetErrorString("Detaching with keep_stopped true is not currently "
112  "supported on FreeBSD.");
113  return error;
114  }
115 
116  error = m_monitor->Detach(GetID());
117 
118  if (error.Success())
119  SetPrivateState(eStateDetached);
120 
121  return error;
122 }
123 
126 
127  SetPrivateState(eStateRunning);
128 
129  std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
130  bool do_step = false;
131  bool software_single_step = !SupportHardwareSingleStepping();
132 
133  for (tid_collection::const_iterator t_pos = m_run_tids.begin(),
134  t_end = m_run_tids.end();
135  t_pos != t_end; ++t_pos) {
136  m_monitor->ThreadSuspend(*t_pos, false);
137  }
138  for (tid_collection::const_iterator t_pos = m_step_tids.begin(),
139  t_end = m_step_tids.end();
140  t_pos != t_end; ++t_pos) {
141  m_monitor->ThreadSuspend(*t_pos, false);
142  do_step = true;
143  if (software_single_step) {
144  Status error = SetupSoftwareSingleStepping(*t_pos);
145  if (error.Fail())
146  return error;
147  }
148  }
149  for (tid_collection::const_iterator t_pos = m_suspend_tids.begin(),
150  t_end = m_suspend_tids.end();
151  t_pos != t_end; ++t_pos) {
152  m_monitor->ThreadSuspend(*t_pos, true);
153  // XXX Cannot PT_CONTINUE properly with suspended threads.
154  do_step = true;
155  }
156 
157  if (log)
158  log->Printf("process %" PRIu64 " resuming (%s)", GetID(),
159  do_step ? "step" : "continue");
160  if (do_step && !software_single_step)
161  m_monitor->SingleStep(GetID(), m_resume_signo);
162  else
163  m_monitor->Resume(GetID(), m_resume_signo);
164 
165  return Status();
166 }
167 
169  ThreadList &new_thread_list) {
171  if (log)
172  log->Printf("ProcessFreeBSD::%s (pid = %" PRIu64 ")", __FUNCTION__,
173  GetID());
174 
175  std::vector<lldb::pid_t> tds;
176  if (!GetMonitor().GetCurrentThreadIDs(tds)) {
177  return false;
178  }
179 
180  ThreadList old_thread_list_copy(old_thread_list);
181  for (size_t i = 0; i < tds.size(); ++i) {
182  tid_t tid = tds[i];
183  ThreadSP thread_sp(old_thread_list_copy.RemoveThreadByID(tid, false));
184  if (!thread_sp) {
185  thread_sp.reset(new FreeBSDThread(*this, tid));
186  if (log)
187  log->Printf("ProcessFreeBSD::%s new tid = %" PRIu64, __FUNCTION__, tid);
188  } else {
189  if (log)
190  log->Printf("ProcessFreeBSD::%s existing tid = %" PRIu64, __FUNCTION__,
191  tid);
192  }
193  new_thread_list.AddThread(thread_sp);
194  }
195  for (size_t i = 0; i < old_thread_list_copy.GetSize(false); ++i) {
196  ThreadSP old_thread_sp(old_thread_list_copy.GetThreadAtIndex(i, false));
197  if (old_thread_sp) {
198  if (log)
199  log->Printf("ProcessFreeBSD::%s remove tid", __FUNCTION__);
200  }
201  }
202 
203  return true;
204 }
205 
207  m_resume_signo = 0;
208  m_suspend_tids.clear();
209  m_run_tids.clear();
210  m_step_tids.clear();
211  return Process::WillResume();
212 }
213 
215  std::lock_guard<std::recursive_mutex> guard(m_message_mutex);
216 
217  switch (message.GetKind()) {
219  return;
220 
222  SetPrivateState(eStateStopped);
223  return;
224 
227  SetExitStatus(message.GetExitStatus(), NULL);
228  break;
229 
236  SetPrivateState(eStateStopped);
237  break;
238 
240  llvm_unreachable("eNewThreadMessage unexpected on FreeBSD");
241  break;
242 
244  SetPrivateState(eStateStopped);
245  break;
246  }
247 
248  m_message_queue.push(message);
249 }
250 
251 // Constructors and destructors.
252 
253 ProcessFreeBSD::ProcessFreeBSD(lldb::TargetSP target_sp,
254  lldb::ListenerSP listener_sp,
255  UnixSignalsSP &unix_signals_sp)
256  : Process(target_sp, listener_sp, unix_signals_sp),
257  m_byte_order(endian::InlHostByteOrder()), m_monitor(NULL), m_module(NULL),
258  m_message_mutex(), m_exit_now(false), m_seen_initial_stop(),
259  m_resume_signo(0) {
260  // FIXME: Putting this code in the ctor and saving the byte order in a
261  // member variable is a hack to avoid const qual issues in GetByteOrder.
262  lldb::ModuleSP module = GetTarget().GetExecutableModule();
263  if (module && module->GetObjectFile())
264  m_byte_order = module->GetObjectFile()->GetByteOrder();
265 }
266 
268 
269 // Process protocol.
271  Process::Finalize();
272 
273  if (m_monitor)
275 }
276 
277 bool ProcessFreeBSD::CanDebug(lldb::TargetSP target_sp,
278  bool plugin_specified_by_name) {
279  // For now we are just making sure the file exists for a given module
280  ModuleSP exe_module_sp(target_sp->GetExecutableModule());
281  if (exe_module_sp.get())
282  return FileSystem::Instance().Exists(exe_module_sp->GetFileSpec());
283  // If there is no executable module, we return true since we might be
284  // preparing to attach.
285  return true;
286 }
287 
288 Status
290  const ProcessAttachInfo &attach_info) {
291  Status error;
292  assert(m_monitor == NULL);
293 
295  LLDB_LOGV(log, "pid = {0}", GetID());
296 
297  m_monitor = new ProcessMonitor(this, pid, error);
298 
299  if (!error.Success())
300  return error;
301 
302  PlatformSP platform_sp(GetTarget().GetPlatform());
303  assert(platform_sp.get());
304  if (!platform_sp)
305  return error; // FIXME: Detatch?
306 
307  // Find out what we can about this process
308  ProcessInstanceInfo process_info;
309  platform_sp->GetProcessInfo(pid, process_info);
310 
311  // Resolve the executable module
312  ModuleSP exe_module_sp;
313  FileSpecList executable_search_paths(
314  Target::GetDefaultExecutableSearchPaths());
315  ModuleSpec exe_module_spec(process_info.GetExecutableFile(),
317  error = platform_sp->ResolveExecutable(
318  exe_module_spec, exe_module_sp,
319  executable_search_paths.GetSize() ? &executable_search_paths : NULL);
320  if (!error.Success())
321  return error;
322 
323  // Fix the target architecture if necessary
324  const ArchSpec &module_arch = exe_module_sp->GetArchitecture();
325  if (module_arch.IsValid() &&
326  !GetTarget().GetArchitecture().IsExactMatch(module_arch))
327  GetTarget().SetArchitecture(module_arch);
328 
329  // Initialize the target module list
331 
333 
334  SetID(pid);
335 
336  return error;
337 }
338 
340  Status error;
341  return error;
342 }
343 
344 FileSpec
346  const FileSpec &default_file_spec,
347  const FileSpec &dbg_pts_file_spec) {
348  FileSpec file_spec{};
349 
350  if (file_action && file_action->GetAction() == FileAction::eFileActionOpen) {
351  file_spec = file_action->GetFileSpec();
352  // By default the stdio paths passed in will be pseudo-terminal (/dev/pts).
353  // If so, convert to using a different default path instead to redirect I/O
354  // to the debugger console. This should also handle user overrides to
355  // /dev/null or a different file.
356  if (!file_spec || file_spec == dbg_pts_file_spec)
357  file_spec = default_file_spec;
358  }
359  return file_spec;
360 }
361 
363  ProcessLaunchInfo &launch_info) {
364  Status error;
365  assert(m_monitor == NULL);
366 
367  FileSpec working_dir = launch_info.GetWorkingDirectory();
368  if (working_dir) {
369  FileSystem::Instance().Resolve(working_dir);
370  if (!FileSystem::Instance().IsDirectory(working_dir.GetPath())) {
371  error.SetErrorStringWithFormat("No such file or directory: %s",
372  working_dir.GetCString());
373  return error;
374  }
375  }
376 
378 
379  const lldb_private::FileAction *file_action;
380 
381  // Default of empty will mean to use existing open file descriptors
382  FileSpec stdin_file_spec{};
383  FileSpec stdout_file_spec{};
384  FileSpec stderr_file_spec{};
385 
386  const FileSpec dbg_pts_file_spec{launch_info.GetPTY().GetSlaveName(NULL, 0)};
387 
388  file_action = launch_info.GetFileActionForFD(STDIN_FILENO);
389  stdin_file_spec =
390  GetFileSpec(file_action, stdin_file_spec, dbg_pts_file_spec);
391 
392  file_action = launch_info.GetFileActionForFD(STDOUT_FILENO);
393  stdout_file_spec =
394  GetFileSpec(file_action, stdout_file_spec, dbg_pts_file_spec);
395 
396  file_action = launch_info.GetFileActionForFD(STDERR_FILENO);
397  stderr_file_spec =
398  GetFileSpec(file_action, stderr_file_spec, dbg_pts_file_spec);
399 
401  this, module, launch_info.GetArguments().GetConstArgumentVector(),
402  launch_info.GetEnvironment(), stdin_file_spec, stdout_file_spec,
403  stderr_file_spec, working_dir, launch_info, error);
404 
405  m_module = module;
406 
407  if (!error.Success())
408  return error;
409 
410  int terminal = m_monitor->GetTerminalFD();
411  if (terminal >= 0) {
412 // The reader thread will close the file descriptor when done, so we pass it a
413 // copy.
414 #ifdef F_DUPFD_CLOEXEC
415  int stdio = fcntl(terminal, F_DUPFD_CLOEXEC, 0);
416  if (stdio == -1) {
417  error.SetErrorToErrno();
418  return error;
419  }
420 #else
421  // Special case when F_DUPFD_CLOEXEC does not exist (Debian kFreeBSD)
422  int stdio = fcntl(terminal, F_DUPFD, 0);
423  if (stdio == -1) {
424  error.SetErrorToErrno();
425  return error;
426  }
427  stdio = fcntl(terminal, F_SETFD, FD_CLOEXEC);
428  if (stdio == -1) {
429  error.SetErrorToErrno();
430  return error;
431  }
432 #endif
433  SetSTDIOFileDescriptor(stdio);
434  }
435 
436  SetID(m_monitor->GetPID());
437  return error;
438 }
439 
441 
443  Target *target = &GetTarget();
444  ObjectFile *obj_file = target->GetExecutableModule()->GetObjectFile();
445  Address addr = obj_file->GetImageInfoAddress(target);
446 
447  if (addr.IsValid())
448  return addr.GetLoadAddress(target);
449  return LLDB_INVALID_ADDRESS;
450 }
451 
452 Status ProcessFreeBSD::DoHalt(bool &caused_stop) {
453  Status error;
454 
455  if (IsStopped()) {
456  caused_stop = false;
457  } else if (kill(GetID(), SIGSTOP)) {
458  caused_stop = false;
459  error.SetErrorToErrno();
460  } else {
461  caused_stop = true;
462  }
463  return error;
464 }
465 
467  Status error;
468 
469  if (kill(GetID(), signal))
470  error.SetErrorToErrno();
471 
472  return error;
473 }
474 
476  Status error;
477 
478  if (!HasExited()) {
479  assert(m_monitor);
480  m_exit_now = true;
481  if (GetID() == LLDB_INVALID_PROCESS_ID) {
482  error.SetErrorString("invalid process id");
483  return error;
484  }
485  if (!m_monitor->Kill()) {
486  error.SetErrorToErrno();
487  return error;
488  }
489 
491  }
492 
493  return error;
494 }
495 
497  Target *target = &GetTarget();
498  if (target) {
499  PlatformSP platform_sp(target->GetPlatform());
500  assert(platform_sp.get());
501  if (platform_sp) {
502  ProcessInstanceInfo process_info;
503  platform_sp->GetProcessInfo(GetID(), process_info);
504  ModuleSP exe_module_sp;
505  ModuleSpec exe_module_spec(process_info.GetExecutableFile(),
506  target->GetArchitecture());
507  FileSpecList executable_search_paths(
508  Target::GetDefaultExecutableSearchPaths());
509  Status error = platform_sp->ResolveExecutable(
510  exe_module_spec, exe_module_sp,
511  executable_search_paths.GetSize() ? &executable_search_paths : NULL);
512  if (!error.Success())
513  return;
514  target->SetExecutableModule(exe_module_sp, eLoadDependentsYes);
515  }
516  }
517 }
518 
520  bool added_to_set = false;
521  ThreadStopSet::iterator it = m_seen_initial_stop.find(stop_tid);
522  if (it == m_seen_initial_stop.end()) {
523  m_seen_initial_stop.insert(stop_tid);
524  added_to_set = true;
525  }
526  return added_to_set;
527 }
528 
530  return (m_seen_initial_stop.find(stop_tid) == m_seen_initial_stop.end());
531 }
532 
535  lldb::tid_t tid) {
536  return new FreeBSDThread(process, tid);
537 }
538 
541  LLDB_LOGV(log, "message_queue size = {0}", m_message_queue.size());
542 
543  std::lock_guard<std::recursive_mutex> guard(m_message_mutex);
544 
545  // This method used to only handle one message. Changing it to loop allows
546  // it to handle the case where we hit a breakpoint while handling a different
547  // breakpoint.
548  while (!m_message_queue.empty()) {
549  ProcessMessage &message = m_message_queue.front();
550 
551  // Resolve the thread this message corresponds to and pass it along.
552  lldb::tid_t tid = message.GetTID();
553  LLDB_LOGV(log, " message_queue size = {0}, pid = {1}",
554  m_message_queue.size(), tid);
555 
557 
558  FreeBSDThread *thread = static_cast<FreeBSDThread *>(
559  GetThreadList().FindThreadByID(tid, false).get());
560  if (thread)
561  thread->Notify(message);
562 
563  if (message.GetKind() == ProcessMessage::eExitMessage) {
564  // FIXME: We should tell the user about this, but the limbo message is
565  // probably better for that.
566  LLDB_LOG(log, "removing thread, tid = {0}", tid);
567  std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
568 
569  ThreadSP thread_sp = m_thread_list.RemoveThreadByID(tid, false);
570  thread_sp.reset();
571  m_seen_initial_stop.erase(tid);
572  }
573 
574  m_message_queue.pop();
575  }
576 }
577 
579  StateType state = GetPrivateState();
580  return state != eStateDetached && state != eStateExited &&
581  state != eStateInvalid && state != eStateUnloaded;
582 }
583 
584 size_t ProcessFreeBSD::DoReadMemory(addr_t vm_addr, void *buf, size_t size,
585  Status &error) {
586  assert(m_monitor);
587  return m_monitor->ReadMemory(vm_addr, buf, size, error);
588 }
589 
590 size_t ProcessFreeBSD::DoWriteMemory(addr_t vm_addr, const void *buf,
591  size_t size, Status &error) {
592  assert(m_monitor);
593  return m_monitor->WriteMemory(vm_addr, buf, size, error);
594 }
595 
597  Status &error) {
598  addr_t allocated_addr = LLDB_INVALID_ADDRESS;
599 
600  unsigned prot = 0;
601  if (permissions & lldb::ePermissionsReadable)
602  prot |= eMmapProtRead;
603  if (permissions & lldb::ePermissionsWritable)
604  prot |= eMmapProtWrite;
605  if (permissions & lldb::ePermissionsExecutable)
606  prot |= eMmapProtExec;
607 
608  if (InferiorCallMmap(this, allocated_addr, 0, size, prot,
609  eMmapFlagsAnon | eMmapFlagsPrivate, -1, 0)) {
610  m_addr_to_mmap_size[allocated_addr] = size;
611  error.Clear();
612  } else {
613  allocated_addr = LLDB_INVALID_ADDRESS;
615  "unable to allocate %zu bytes of memory with permissions %s", size,
616  GetPermissionsAsCString(permissions));
617  }
618 
619  return allocated_addr;
620 }
621 
623  Status error;
624  MMapMap::iterator pos = m_addr_to_mmap_size.find(addr);
625  if (pos != m_addr_to_mmap_size.end() &&
626  InferiorCallMunmap(this, addr, pos->second))
627  m_addr_to_mmap_size.erase(pos);
628  else
629  error.SetErrorStringWithFormat("unable to deallocate memory at 0x%" PRIx64,
630  addr);
631 
632  return error;
633 }
634 
635 size_t
637  static const uint8_t g_aarch64_opcode[] = {0x00, 0x00, 0x20, 0xD4};
638  static const uint8_t g_i386_opcode[] = {0xCC};
639 
641  const uint8_t *opcode = NULL;
642  size_t opcode_size = 0;
643 
644  switch (arch.GetMachine()) {
645  default:
646  assert(false && "CPU type not supported!");
647  break;
648 
649  case llvm::Triple::arm: {
650  // The ARM reference recommends the use of 0xe7fddefe and 0xdefe but the
651  // linux kernel does otherwise.
652  static const uint8_t g_arm_breakpoint_opcode[] = {0xf0, 0x01, 0xf0, 0xe7};
653  static const uint8_t g_thumb_breakpoint_opcode[] = {0x01, 0xde};
654 
655  lldb::BreakpointLocationSP bp_loc_sp(bp_site->GetOwnerAtIndex(0));
656  AddressClass addr_class = AddressClass::eUnknown;
657 
658  if (bp_loc_sp)
659  addr_class = bp_loc_sp->GetAddress().GetAddressClass();
660 
661  if (addr_class == AddressClass::eCodeAlternateISA ||
662  (addr_class == AddressClass::eUnknown &&
663  bp_loc_sp->GetAddress().GetOffset() & 1)) {
664  opcode = g_thumb_breakpoint_opcode;
665  opcode_size = sizeof(g_thumb_breakpoint_opcode);
666  } else {
667  opcode = g_arm_breakpoint_opcode;
668  opcode_size = sizeof(g_arm_breakpoint_opcode);
669  }
670  } break;
671  case llvm::Triple::aarch64:
672  opcode = g_aarch64_opcode;
673  opcode_size = sizeof(g_aarch64_opcode);
674  break;
675 
676  case llvm::Triple::x86:
677  case llvm::Triple::x86_64:
678  opcode = g_i386_opcode;
679  opcode_size = sizeof(g_i386_opcode);
680  break;
681  }
682 
683  bp_site->SetTrapOpcode(opcode, opcode_size);
684  return opcode_size;
685 }
686 
688  return EnableSoftwareBreakpoint(bp_site);
689 }
690 
692  return DisableSoftwareBreakpoint(bp_site);
693 }
694 
696  Status error;
697  if (wp) {
698  user_id_t watchID = wp->GetID();
699  addr_t addr = wp->GetLoadAddress();
701  if (log)
702  log->Printf("ProcessFreeBSD::EnableWatchpoint(watchID = %" PRIu64 ")",
703  watchID);
704  if (wp->IsEnabled()) {
705  if (log)
706  log->Printf("ProcessFreeBSD::EnableWatchpoint(watchID = %" PRIu64
707  ") addr = 0x%8.8" PRIx64 ": watchpoint already enabled.",
708  watchID, (uint64_t)addr);
709  return error;
710  }
711 
712  // Try to find a vacant watchpoint slot in the inferiors' main thread
713  uint32_t wp_hw_index = LLDB_INVALID_INDEX32;
714  std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
715  FreeBSDThread *thread = static_cast<FreeBSDThread *>(
716  m_thread_list.GetThreadAtIndex(0, false).get());
717 
718  if (thread)
719  wp_hw_index = thread->FindVacantWatchpointIndex();
720 
721  if (wp_hw_index == LLDB_INVALID_INDEX32) {
722  error.SetErrorString("Setting hardware watchpoint failed.");
723  } else {
724  wp->SetHardwareIndex(wp_hw_index);
725  bool wp_enabled = true;
726  uint32_t thread_count = m_thread_list.GetSize(false);
727  for (uint32_t i = 0; i < thread_count; ++i) {
728  thread = static_cast<FreeBSDThread *>(
729  m_thread_list.GetThreadAtIndex(i, false).get());
730  if (thread)
731  wp_enabled &= thread->EnableHardwareWatchpoint(wp);
732  else
733  wp_enabled = false;
734  }
735  if (wp_enabled) {
736  wp->SetEnabled(true, notify);
737  return error;
738  } else {
739  // Watchpoint enabling failed on at least one of the threads so roll
740  // back all of them
741  DisableWatchpoint(wp, false);
742  error.SetErrorString("Setting hardware watchpoint failed");
743  }
744  }
745  } else
746  error.SetErrorString("Watchpoint argument was NULL.");
747  return error;
748 }
749 
751  Status error;
752  if (wp) {
753  user_id_t watchID = wp->GetID();
754  addr_t addr = wp->GetLoadAddress();
756  if (log)
757  log->Printf("ProcessFreeBSD::DisableWatchpoint(watchID = %" PRIu64 ")",
758  watchID);
759  if (!wp->IsEnabled()) {
760  if (log)
761  log->Printf("ProcessFreeBSD::DisableWatchpoint(watchID = %" PRIu64
762  ") addr = 0x%8.8" PRIx64 ": watchpoint already disabled.",
763  watchID, (uint64_t)addr);
764  // This is needed (for now) to keep watchpoints disabled correctly
765  wp->SetEnabled(false, notify);
766  return error;
767  }
768 
769  if (wp->IsHardware()) {
770  bool wp_disabled = true;
771  std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
772  uint32_t thread_count = m_thread_list.GetSize(false);
773  for (uint32_t i = 0; i < thread_count; ++i) {
774  FreeBSDThread *thread = static_cast<FreeBSDThread *>(
775  m_thread_list.GetThreadAtIndex(i, false).get());
776  if (thread)
777  wp_disabled &= thread->DisableHardwareWatchpoint(wp);
778  else
779  wp_disabled = false;
780  }
781  if (wp_disabled) {
783  wp->SetEnabled(false, notify);
784  return error;
785  } else
786  error.SetErrorString("Disabling hardware watchpoint failed");
787  }
788  } else
789  error.SetErrorString("Watchpoint argument was NULL.");
790  return error;
791 }
792 
794  Status error;
795  std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
796  FreeBSDThread *thread = static_cast<FreeBSDThread *>(
797  m_thread_list.GetThreadAtIndex(0, false).get());
798  if (thread)
799  num = thread->NumSupportedHardwareWatchpoints();
800  else
801  error.SetErrorString("Process does not exist.");
802  return error;
803 }
804 
806  Status error = GetWatchpointSupportInfo(num);
807  // Watchpoints trigger and halt the inferior after the corresponding
808  // instruction has been executed.
809  after = true;
810  return error;
811 }
812 
814  std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
815  // Do not allow recursive updates.
816  return m_thread_list.GetSize(false);
817 }
818 
820  // FIXME: We should be able to extract this value directly. See comment in
821  // ProcessFreeBSD().
822  return m_byte_order;
823 }
824 
825 size_t ProcessFreeBSD::PutSTDIN(const char *buf, size_t len, Status &error) {
826  ssize_t status;
827  if ((status = write(m_monitor->GetTerminalFD(), buf, len)) < 0) {
828  error.SetErrorToErrno();
829  return 0;
830  }
831  return status;
832 }
833 
834 // Utility functions.
835 
837  switch (GetPrivateState()) {
838  default:
839  break;
840 
841  case eStateDetached:
842  case eStateExited:
843  return true;
844  }
845 
846  return false;
847 }
848 
850  switch (GetPrivateState()) {
851  default:
852  break;
853 
854  case eStateStopped:
855  case eStateCrashed:
856  case eStateSuspended:
857  return true;
858  }
859 
860  return false;
861 }
862 
864  bool is_running = false;
865  std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
866  uint32_t thread_count = m_thread_list.GetSize(false);
867  for (uint32_t i = 0; i < thread_count; ++i) {
868  FreeBSDThread *thread = static_cast<FreeBSDThread *>(
869  m_thread_list.GetThreadAtIndex(i, false).get());
870  StateType thread_state = thread->GetState();
871  if (thread_state == eStateRunning || thread_state == eStateStepping) {
872  is_running = true;
873  break;
874  }
875  }
876  return is_running;
877 }
878 
879 const DataBufferSP ProcessFreeBSD::GetAuxvData() {
880  // If we're the local platform, we can ask the host for auxv data.
881  PlatformSP platform_sp = GetTarget().GetPlatform();
882  assert(platform_sp && platform_sp->IsHost());
883 
884  int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_AUXV, (int)m_process->GetID()};
885  size_t auxv_size = AT_COUNT * sizeof(Elf_Auxinfo);
886  DataBufferSP buf_sp(new DataBufferHeap(auxv_size, 0));
887 
888  if (::sysctl(mib, 4, buf_sp->GetBytes(), &auxv_size, NULL, 0) != 0) {
889  perror("sysctl failed on auxv");
890  buf_sp.reset();
891  }
892 
893  return buf_sp;
894 }
895 
899 
900  // eRegisterKindDWARF -> RegisterValue
901  std::unordered_map<uint32_t, RegisterValue> m_register_values;
902 
904  : m_process(process), m_reg_context(reg_context) {}
905 };
906 
907 static size_t ReadMemoryCallback(EmulateInstruction *instruction, void *baton,
908  const EmulateInstruction::Context &context,
909  lldb::addr_t addr, void *dst, size_t length) {
910  EmulatorBaton *emulator_baton = static_cast<EmulatorBaton *>(baton);
911 
912  Status error;
913  size_t bytes_read =
914  emulator_baton->m_process->DoReadMemory(addr, dst, length, error);
915  if (!error.Success())
916  bytes_read = 0;
917  return bytes_read;
918 }
919 
920 static bool ReadRegisterCallback(EmulateInstruction *instruction, void *baton,
921  const RegisterInfo *reg_info,
922  RegisterValue &reg_value) {
923  EmulatorBaton *emulator_baton = static_cast<EmulatorBaton *>(baton);
924 
925  auto it = emulator_baton->m_register_values.find(
926  reg_info->kinds[eRegisterKindDWARF]);
927  if (it != emulator_baton->m_register_values.end()) {
928  reg_value = it->second;
929  return true;
930  }
931 
932  // The emulator only fills in the dwarf register numbers (and in some cases
933  // the generic register numbers). Get the full register info from the
934  // register context based on the dwarf register numbers.
935  const RegisterInfo *full_reg_info =
936  emulator_baton->m_reg_context->GetRegisterInfo(
937  eRegisterKindDWARF, reg_info->kinds[eRegisterKindDWARF]);
938 
939  bool error =
940  emulator_baton->m_reg_context->ReadRegister(full_reg_info, reg_value);
941  return error;
942 }
943 
944 static bool WriteRegisterCallback(EmulateInstruction *instruction, void *baton,
945  const EmulateInstruction::Context &context,
946  const RegisterInfo *reg_info,
947  const RegisterValue &reg_value) {
948  EmulatorBaton *emulator_baton = static_cast<EmulatorBaton *>(baton);
949  emulator_baton->m_register_values[reg_info->kinds[eRegisterKindDWARF]] =
950  reg_value;
951  return true;
952 }
953 
954 static size_t WriteMemoryCallback(EmulateInstruction *instruction, void *baton,
955  const EmulateInstruction::Context &context,
956  lldb::addr_t addr, const void *dst,
957  size_t length) {
958  return length;
959 }
960 
962  void *baton, lldb_private::StoppointCallbackContext *context,
963  lldb::user_id_t break_id, lldb::user_id_t break_loc_id) {
964  return false;
965 }
966 
968  lldb::addr_t addr) {
969  Status error;
970 
972  if (log) {
973  log->Printf("ProcessFreeBSD::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
974  log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
975  }
976 
977  // Validate the address.
978  if (addr == LLDB_INVALID_ADDRESS)
979  return Status("ProcessFreeBSD::%s invalid load address specified.",
980  __FUNCTION__);
981 
982  Breakpoint *const sw_step_break =
983  m_process->GetTarget().CreateBreakpoint(addr, true, false).get();
984  sw_step_break->SetCallback(SingleStepBreakpointHit, this, true);
985  sw_step_break->SetBreakpointKind("software-signle-step");
986 
987  if (log)
988  log->Printf("ProcessFreeBSD::%s addr = 0x%" PRIx64 " -- SUCCESS",
989  __FUNCTION__, addr);
990 
991  m_threads_stepping_with_breakpoint.insert({tid, sw_step_break->GetID()});
992  return Status();
993 }
994 
996  ThreadSP thread = GetThreadList().FindThreadByID(tid);
997  if (!thread)
998  return false;
999 
1000  assert(thread->GetRegisterContext());
1001  lldb::addr_t stop_pc = thread->GetRegisterContext()->GetPC();
1002 
1003  const auto &iter = m_threads_stepping_with_breakpoint.find(tid);
1004  if (iter == m_threads_stepping_with_breakpoint.end())
1005  return false;
1006 
1007  lldb::break_id_t bp_id = iter->second;
1008  BreakpointSP bp = GetTarget().GetBreakpointByID(bp_id);
1009  if (!bp)
1010  return false;
1011 
1012  BreakpointLocationSP bp_loc = bp->FindLocationByAddress(stop_pc);
1013  if (!bp_loc)
1014  return false;
1015 
1018  return true;
1019 }
1020 
1023  if (arch.GetMachine() == llvm::Triple::arm ||
1024  arch.GetMachine() == llvm::Triple::mips64 ||
1025  arch.GetMachine() == llvm::Triple::mips64el ||
1026  arch.GetMachine() == llvm::Triple::mips ||
1027  arch.GetMachine() == llvm::Triple::mipsel)
1028  return false;
1029  return true;
1030 }
1031 
1033  std::unique_ptr<EmulateInstruction> emulator_up(
1034  EmulateInstruction::FindPlugin(GetTarget().GetArchitecture(),
1035  eInstructionTypePCModifying, nullptr));
1036 
1037  if (emulator_up == nullptr)
1038  return Status("Instruction emulator not found!");
1039 
1040  FreeBSDThread *thread = static_cast<FreeBSDThread *>(
1041  m_thread_list.FindThreadByID(tid, false).get());
1042  if (thread == NULL)
1043  return Status("Thread not found not found!");
1044 
1045  lldb::RegisterContextSP register_context_sp = thread->GetRegisterContext();
1046 
1047  EmulatorBaton baton(this, register_context_sp.get());
1048  emulator_up->SetBaton(&baton);
1049  emulator_up->SetReadMemCallback(&ReadMemoryCallback);
1050  emulator_up->SetReadRegCallback(&ReadRegisterCallback);
1051  emulator_up->SetWriteMemCallback(&WriteMemoryCallback);
1052  emulator_up->SetWriteRegCallback(&WriteRegisterCallback);
1053 
1054  if (!emulator_up->ReadInstruction())
1055  return Status("Read instruction failed!");
1056 
1057  bool emulation_result =
1058  emulator_up->EvaluateInstruction(eEmulateInstructionOptionAutoAdvancePC);
1059  const RegisterInfo *reg_info_pc = register_context_sp->GetRegisterInfo(
1061  auto pc_it =
1062  baton.m_register_values.find(reg_info_pc->kinds[eRegisterKindDWARF]);
1063 
1064  lldb::addr_t next_pc;
1065  if (emulation_result) {
1066  assert(pc_it != baton.m_register_values.end() &&
1067  "Emulation was successful but PC wasn't updated");
1068  next_pc = pc_it->second.GetAsUInt64();
1069  } else if (pc_it == baton.m_register_values.end()) {
1070  // Emulate instruction failed and it haven't changed PC. Advance PC with
1071  // the size of the current opcode because the emulation of all
1072  // PC modifying instruction should be successful. The failure most
1073  // likely caused by a not supported instruction which don't modify PC.
1074  next_pc =
1075  register_context_sp->GetPC() + emulator_up->GetOpcode().GetByteSize();
1076  } else {
1077  // The instruction emulation failed after it modified the PC. It is an
1078  // unknown error where we can't continue because the next instruction is
1079  // modifying the PC but we don't know how.
1080  return Status("Instruction emulation failed unexpectedly");
1081  }
1082 
1083  SetSoftwareSingleStepBreakpoint(tid, next_pc);
1084  return Status();
1085 }
size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, lldb_private::Status &error)
Reads size bytes from address in the inferior process address space.
Class that manages the actual breakpoint that will be inserted into the running program.
static lldb_private::ConstString GetPluginNameStatic()
void Notify(const ProcessMessage &message)
bool IsExactMatch(const ArchSpec &rhs) const
Compare an ArchSpec to another ArchSpec, requiring an exact cpu type match between them...
Definition: ArchSpec.cpp:977
#define LLDB_REGNUM_GENERIC_PC
Definition: lldb-defines.h:63
virtual lldb_private::Address GetImageInfoAddress(Target *target)
Similar to Process::GetImageInfoAddress().
Definition: ObjectFile.h:458
bool RemoveBreakpointByID(lldb::break_id_t break_id)
Definition: Target.cpp:940
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
virtual Status EnableSoftwareBreakpoint(BreakpointSite *bp_site)
Definition: Process.cpp:1796
const ArchSpec & GetArchitecture() const
Definition: Target.h:941
bool IsSoftwareStepBreakpoint(lldb::tid_t tid)
int32_t break_id_t
Definition: lldb-types.h:88
bool SetTrapOpcode(const uint8_t *trap_opcode, uint32_t trap_opcode_size)
Sets the trap opcode.
int GetExitStatus() const
std::queue< ProcessMessage > m_message_queue
bool DisableHardwareWatchpoint(lldb_private::Watchpoint *wp)
lldb_private::Status DoResume() override
Resumes all of a process&#39;s threads as configured using the Thread run control functions.
bool IsAlive() override
Check if a process is still alive.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:292
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:92
virtual uint32_t UpdateThreadListIfNeeded()
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition: Breakpoint.h:78
virtual size_t GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite *bp_site)
void DidLaunch() override
Called after launching a process.
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const lldb_private::FileSpec *crash_file_path)
virtual uint32_t GetPluginVersion() override
lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, lldb_private::Status &error) override
Actually allocate memory in the process.
lldb_private::Status DoLaunch(lldb_private::Module *exe_module, lldb_private::ProcessLaunchInfo &launch_info) override
Launch a new process.
const char * GetSlaveName(char *error_str, size_t error_len) const
Get the name of the slave pseudo terminal.
static bool WriteRegisterCallback(EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, const RegisterInfo *reg_info, const RegisterValue &reg_value)
virtual lldb_private::ConstString GetPluginName() override
lldb_private::FileSpec GetFileSpec(const lldb_private::FileAction *file_action, const lldb_private::FileSpec &default_file_spec, const lldb_private::FileSpec &dbg_pts_file_spec)
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:49
A file utility class.
Definition: FileSpec.h:55
An architecture specification class.
Definition: ArchSpec.h:32
bool AddThreadForInitialStopIfNeeded(lldb::tid_t stop_tid)
Adds the thread to the list of threads for which we have received the initial stopping signal...
ThreadList & GetThreadList()
Definition: Process.h:2045
bool EnableHardwareWatchpoint(lldb_private::Watchpoint *wp)
bool IsAThreadRunning()
Returns true if at least one running is currently running.
A plug-in interface definition class for object file parsers.
Definition: ObjectFile.h:58
void SetBreakpointKind(const char *kind)
Set the "kind" description for a breakpoint.
Definition: Breakpoint.h:456
Action GetAction() const
Definition: FileAction.h:38
bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform=false)
Set the architecture for this target.
Definition: Target.cpp:1498
int GetTerminalFD() const
Returns a file descriptor to the controlling terminal of the inferior process.
const char * GetPermissionsAsCString(uint32_t permissions)
Definition: State.cpp:44
Process or thread is stopped and can be examined.
"lldb/Core/EmulateInstruction.h" A class that allows emulation of CPU opcodes.
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:329
bool SupportHardwareSingleStepping() const
lldb::StateType GetState() const
Definition: Thread.cpp:581
ProcessMonitor * m_monitor
Process monitor;.
#define LLDB_LOG(log,...)
Definition: Log.h:209
void SetEnabled(bool enabled, bool notify=true)
Definition: Watchpoint.cpp:228
friend class FreeBSDThread
lldb_private::Status DoDetach(bool keep_stopped) override
Detaches from a running or stopped process.
Process or thread has crashed and can be examined.
A subclass of DataBuffer that stores a data buffer on the heap.
static const char * GetPluginDescriptionStatic()
#define SIGSTOP
void SetErrorToErrno()
Set the current error to errno.
Definition: Status.cpp:223
#define POSIX_LOG_WATCHPOINTS
void SetSTDIOFileDescriptor(int file_descriptor)
Definition: Process.cpp:4471
static size_t WriteMemoryCallback(EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, lldb::addr_t addr, const void *dst, size_t length)
bool IsHardware() const override
Definition: Watchpoint.cpp:89
bool m_exit_now
Drive any exit events to completion.
Manages communication with the inferior (debugee) process.
Process has exited and can&#39;t be examined.
void SetCallback(BreakpointHitCallback callback, void *baton, bool is_synchronous=false)
Set the callback action invoked when the breakpoint is hit.
Definition: Breakpoint.cpp:421
FreeBSD specific set of Unix signals.
lldb_private::Status EnableBreakpointSite(lldb_private::BreakpointSite *bp_site) override
lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update=true)
Definition: ThreadList.cpp:90
static bool ReadRegisterCallback(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue &reg_value)
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
lldb::ThreadSP FindThreadByID(lldb::tid_t tid, bool can_update=true)
Definition: ThreadList.cpp:102
uint64_t user_id_t
Definition: lldb-types.h:84
#define LLDB_INVALID_INDEX32
Definition: lldb-defines.h:86
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
Definition: Target.cpp:297
virtual FreeBSDThread * CreateNewFreeBSDThread(lldb_private::Process &process, lldb::tid_t tid)
bool InferiorCallMunmap(Process *proc, lldb::addr_t addr, lldb::addr_t length)
ThreadStopSet m_seen_initial_stop
Every thread begins with a stop signal.
MMapMap m_addr_to_mmap_size
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:57
lldb_private::Status WillLaunch(lldb_private::Module *module) override
Called before launching to a process.
#define POSIX_LOG_PROCESS
Kind GetKind() const
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:109
void SetHardwareIndex(uint32_t index)
lldb::pid_t GetPID() const
Provides the process number of debugee.
lldb_private::Status SetSoftwareSingleStepBreakpoint(lldb::tid_t tid, lldb::addr_t addr)
Process has been detached and can&#39;t be examined.
lldb::break_id_t GetID() const
Definition: Stoppoint.cpp:22
void Clear()
Clear the object state.
Definition: Status.cpp:167
static size_t ReadMemoryCallback(EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, lldb::addr_t addr, void *dst, size_t length)
Process is in the process of launching.
uint64_t tid_t
Definition: lldb-types.h:86
lldb::RegisterContextSP GetRegisterContext() override
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:241
size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, lldb_private::Status &error) override
Actually do the writing of memory to a process.
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
Environment & GetEnvironment()
Definition: ProcessInfo.h:88
A plug-in interface definition class for debugging a process.
Definition: Process.h:353
FileSpec & GetExecutableFile()
Definition: ProcessInfo.h:43
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition: Target.cpp:1380
static void Terminate()
virtual void SendMessage(const ProcessMessage &message)
Registers the given message with this process.
const FileAction * GetFileActionForFD(int fd) const
bool Success() const
Test for success condition.
Definition: Status.cpp:287
static void Initialize()
RegisterContext * m_reg_context
Process or thread is in the process of stepping and can not be examined.
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:343
A section + offset based address class.
Definition: Address.h:80
bool HasExited()
Returns true if the process has exited.
Process is object is valid, but not currently loaded.
std::map< lldb::tid_t, lldb::break_id_t > m_threads_stepping_with_breakpoint
bool Kill()
Terminate the traced process.
lldb_private::Status DisableBreakpointSite(lldb_private::BreakpointSite *bp_site) override
bool InferiorCallMmap(Process *proc, lldb::addr_t &allocated_addr, lldb::addr_t addr, lldb::addr_t length, unsigned prot, unsigned flags, lldb::addr_t fd, lldb::addr_t offset)
lldb_private::Status DoDestroy() override
const char * GetCString(bool denormalize=true) const
Definition: FileSpec.cpp:392
void DoDidExec() override
Subclasses of Process should implement this function if they need to do anything after a process exec...
lldb::tid_t GetTID() const
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
lldb_private::Status SetupSoftwareSingleStepping(lldb::tid_t tid)
virtual Status DisableSoftwareBreakpoint(BreakpointSite *bp_site)
Definition: Process.cpp:1872
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1194
ProcessFreeBSD(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, lldb::UnixSignalsSP &unix_signals_sp)
uint64_t addr_t
Definition: lldb-types.h:83
const FileSpec & GetFileSpec() const
Definition: FileAction.cpp:31
size_t PutSTDIN(const char *buf, size_t len, lldb_private::Status &error) override
Puts data into this process&#39;s STDIN.
lldb::PlatformSP GetPlatform()
Definition: Target.h:1214
A uniqued constant string class.
Definition: ConstString.h:38
static bool SingleStepBreakpointHit(void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
virtual lldb::addr_t GetLoadAddress() const
lldb_private::Status DoDeallocateMemory(lldb::addr_t ptr) override
Actually deallocate memory in the process.
const FileSpec & GetWorkingDirectory() const
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
lldb_private::Status DoSignal(int signal) override
Sends a process a UNIX signal signal.
lldb_private::Status DoHalt(bool &caused_stop) override
Halts a running process.
void SetID(lldb::user_id_t uid)
Set accessor for the user ID.
Definition: UserID.h:55
Definition: SBAddress.h:15
EmulatorBaton(ProcessFreeBSD *process, RegisterContext *reg_context)
ThreadList m_thread_list
The threads for this process as the user will see them.
Definition: Process.h:2657
uint64_t pid_t
Definition: lldb-types.h:85
lldb::addr_t GetImageInfoAddress() override
Get the image information address for the current process.
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
void AddThread(const lldb::ThreadSP &thread_sp)
lldb_private::Status EnableWatchpoint(lldb_private::Watchpoint *wp, bool notify=true) override
lldb_private::Module * m_module
The module we are executing.
lldb_private::Status DoAttachToProcessWithID(lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info) override
Attach to an existing process using a process ID.
lldb::ByteOrder m_byte_order
Target byte order.
const char ** GetConstArgumentVector() const
Gets the argument vector.
Definition: Args.cpp:278
uint32_t GetSize(bool can_update=true)
Definition: ThreadList.cpp:82
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
Definition: Status.cpp:255
virtual lldb_private::Status WillResume() override
Called before resuming to a process.
lldb::ByteOrder InlHostByteOrder()
Definition: Endian.h:25
std::unordered_map< uint32_t, RegisterValue > m_register_values
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
virtual lldb::ByteOrder GetByteOrder() const
bool IsStopped()
Returns true if the process is stopped.
void Finalize() override
This object is about to be destroyed, do any necessary cleanup.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:376
lldb::StateType GetPrivateState()
Definition: Process.cpp:1463
size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, lldb_private::Status &error) override
Actually do the reading of memory from a process.
lldb_private::Status GetWatchpointSupportInfo(uint32_t &num) override
void SetExecutableModule(lldb::ModuleSP &module_sp, LoadDependentFiles load_dependent_files=eLoadDependentsDefault)
Set the main executable module.
Definition: Target.cpp:1431
void Printf(const char *format,...) __attribute__((format(printf
Definition: Log.cpp:113
ProcessFreeBSD * m_process
const lldb::DataBufferSP GetAuxvData() override
lldb::BreakpointLocationSP GetOwnerAtIndex(size_t idx)
This method returns the breakpoint location at index index located at this breakpoint site...
#define LLDB_LOGV(log,...)
Definition: Log.h:216
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:726
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
Definition: Target.cpp:325
lldb::ThreadSP RemoveThreadByID(lldb::tid_t tid, bool can_update=true)
Definition: ThreadList.cpp:138
lldb_private::Status DisableWatchpoint(lldb_private::Watchpoint *wp, bool notify=true) override
size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, lldb_private::Status &error)
Writes size bytes from address vm_adder in the inferior process address space.
void SetPrivateState(lldb::StateType state)
Definition: Process.cpp:1465
std::recursive_mutex m_message_mutex
Message queue notifying this instance of inferior process state changes.
std::recursive_mutex & GetMutex() const override
Definition: ThreadList.cpp:743
bool UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list) override
An error handling class.
Definition: Status.h:44
bool WaitingForInitialStop(lldb::tid_t stop_tid)
Process or thread is running and can&#39;t be examined.
lldb::break_id_t GetID() const