LLDB  mainline
SBProcess.cpp
Go to the documentation of this file.
1 //===-- SBProcess.cpp -------------------------------------------*- C++ -*-===//
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 #include "lldb/API/SBProcess.h"
10 #include "SBReproducerPrivate.h"
11 
12 #include <inttypes.h>
13 
14 #include "lldb/lldb-defines.h"
15 #include "lldb/lldb-types.h"
16 
17 #include "lldb/Core/Debugger.h"
18 #include "lldb/Core/Module.h"
20 #include "lldb/Core/StreamFile.h"
22 #include "lldb/Target/Process.h"
25 #include "lldb/Target/Target.h"
26 #include "lldb/Target/Thread.h"
27 #include "lldb/Utility/Args.h"
29 #include "lldb/Utility/State.h"
30 #include "lldb/Utility/Stream.h"
31 
32 
33 #include "lldb/API/SBBroadcaster.h"
35 #include "lldb/API/SBDebugger.h"
36 #include "lldb/API/SBEvent.h"
37 #include "lldb/API/SBFileSpec.h"
40 #include "lldb/API/SBStream.h"
41 #include "lldb/API/SBStringList.h"
43 #include "lldb/API/SBThread.h"
45 #include "lldb/API/SBTrace.h"
47 #include "lldb/API/SBUnixSignals.h"
48 
49 using namespace lldb;
50 using namespace lldb_private;
51 
52 SBProcess::SBProcess() : m_opaque_wp() {
54 }
55 
56 // SBProcess constructor
57 
60 }
61 
62 SBProcess::SBProcess(const lldb::ProcessSP &process_sp)
63  : m_opaque_wp(process_sp) {
64  LLDB_RECORD_CONSTRUCTOR(SBProcess, (const lldb::ProcessSP &), process_sp);
65 }
66 
69  SBProcess, operator=,(const lldb::SBProcess &), rhs);
70 
71  if (this != &rhs)
73  return LLDB_RECORD_RESULT(*this);
74 }
75 
76 // Destructor
78 
82 
83  return Process::GetStaticBroadcasterClass().AsCString();
84 }
85 
86 const char *SBProcess::GetPluginName() {
88 
89  ProcessSP process_sp(GetSP());
90  if (process_sp) {
91  return process_sp->GetPluginName().GetCString();
92  }
93  return "<Unknown>";
94 }
95 
98 
99  ProcessSP process_sp(GetSP());
100  if (process_sp) {
101  return process_sp->GetPluginName().GetCString();
102  }
103  return "<Unknown>";
104 }
105 
106 lldb::ProcessSP SBProcess::GetSP() const { return m_opaque_wp.lock(); }
107 
108 void SBProcess::SetSP(const ProcessSP &process_sp) { m_opaque_wp = process_sp; }
109 
112 
113  m_opaque_wp.reset();
114 }
115 
116 bool SBProcess::IsValid() const {
118  return this->operator bool();
119 }
120 SBProcess::operator bool() const {
121  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcess, operator bool);
122 
123  ProcessSP process_sp(m_opaque_wp.lock());
124  return ((bool)process_sp && process_sp->IsValid());
125 }
126 
127 bool SBProcess::RemoteLaunch(char const **argv, char const **envp,
128  const char *stdin_path, const char *stdout_path,
129  const char *stderr_path,
130  const char *working_directory,
131  uint32_t launch_flags, bool stop_at_entry,
132  lldb::SBError &error) {
134  (const char **, const char **, const char *, const char *,
135  const char *, const char *, uint32_t, bool,
136  lldb::SBError &),
137  argv, envp, stdin_path, stdout_path, stderr_path,
138  working_directory, launch_flags, stop_at_entry, error);
139 
140  ProcessSP process_sp(GetSP());
141  if (process_sp) {
142  std::lock_guard<std::recursive_mutex> guard(
143  process_sp->GetTarget().GetAPIMutex());
144  if (process_sp->GetState() == eStateConnected) {
145  if (stop_at_entry)
146  launch_flags |= eLaunchFlagStopAtEntry;
147  ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path),
148  FileSpec(stderr_path),
149  FileSpec(working_directory), launch_flags);
150  Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
151  if (exe_module)
152  launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
153  if (argv)
154  launch_info.GetArguments().AppendArguments(argv);
155  if (envp)
156  launch_info.GetEnvironment() = Environment(envp);
157  error.SetError(process_sp->Launch(launch_info));
158  } else {
159  error.SetErrorString("must be in eStateConnected to call RemoteLaunch");
160  }
161  } else {
162  error.SetErrorString("unable to attach pid");
163  }
164 
165  return error.Success();
166 }
167 
169  lldb::SBError &error) {
171  (lldb::pid_t, lldb::SBError &), pid, error);
172 
173  ProcessSP process_sp(GetSP());
174  if (process_sp) {
175  std::lock_guard<std::recursive_mutex> guard(
176  process_sp->GetTarget().GetAPIMutex());
177  if (process_sp->GetState() == eStateConnected) {
178  ProcessAttachInfo attach_info;
179  attach_info.SetProcessID(pid);
180  error.SetError(process_sp->Attach(attach_info));
181  } else {
182  error.SetErrorString(
183  "must be in eStateConnected to call RemoteAttachToProcessWithID");
184  }
185  } else {
186  error.SetErrorString("unable to attach pid");
187  }
188 
189  return error.Success();
190 }
191 
194 
195  uint32_t num_threads = 0;
196  ProcessSP process_sp(GetSP());
197  if (process_sp) {
198  Process::StopLocker stop_locker;
199 
200  const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
201  std::lock_guard<std::recursive_mutex> guard(
202  process_sp->GetTarget().GetAPIMutex());
203  num_threads = process_sp->GetThreadList().GetSize(can_update);
204  }
205 
206  return num_threads;
207 }
208 
212 
213  SBThread sb_thread;
214  ThreadSP thread_sp;
215  ProcessSP process_sp(GetSP());
216  if (process_sp) {
217  std::lock_guard<std::recursive_mutex> guard(
218  process_sp->GetTarget().GetAPIMutex());
219  thread_sp = process_sp->GetThreadList().GetSelectedThread();
220  sb_thread.SetThread(thread_sp);
221  }
222 
223  return LLDB_RECORD_RESULT(sb_thread);
224 }
225 
227  lldb::addr_t context) {
229  (lldb::tid_t, lldb::addr_t), tid, context);
230 
231  SBThread sb_thread;
232  ThreadSP thread_sp;
233  ProcessSP process_sp(GetSP());
234  if (process_sp) {
235  std::lock_guard<std::recursive_mutex> guard(
236  process_sp->GetTarget().GetAPIMutex());
237  thread_sp = process_sp->CreateOSPluginThread(tid, context);
238  sb_thread.SetThread(thread_sp);
239  }
240 
241  return LLDB_RECORD_RESULT(sb_thread);
242 }
243 
246 
247  SBTarget sb_target;
248  TargetSP target_sp;
249  ProcessSP process_sp(GetSP());
250  if (process_sp) {
251  target_sp = process_sp->GetTarget().shared_from_this();
252  sb_target.SetSP(target_sp);
253  }
254 
255  return LLDB_RECORD_RESULT(sb_target);
256 }
257 
258 size_t SBProcess::PutSTDIN(const char *src, size_t src_len) {
259  LLDB_RECORD_METHOD(size_t, SBProcess, PutSTDIN, (const char *, size_t), src,
260  src_len);
261 
262  size_t ret_val = 0;
263  ProcessSP process_sp(GetSP());
264  if (process_sp) {
265  Status error;
266  ret_val = process_sp->PutSTDIN(src, src_len, error);
267  }
268 
269  return ret_val;
270 }
271 
272 size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const {
273  LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t), dst,
274  dst_len);
275 
276  size_t bytes_read = 0;
277  ProcessSP process_sp(GetSP());
278  if (process_sp) {
279  Status error;
280  bytes_read = process_sp->GetSTDOUT(dst, dst_len, error);
281  }
282 
283  return bytes_read;
284 }
285 
286 size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const {
287  LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t), dst,
288  dst_len);
289 
290  size_t bytes_read = 0;
291  ProcessSP process_sp(GetSP());
292  if (process_sp) {
293  Status error;
294  bytes_read = process_sp->GetSTDERR(dst, dst_len, error);
295  }
296 
297  return bytes_read;
298 }
299 
300 size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const {
302  (char *, size_t), dst, dst_len);
303 
304  size_t bytes_read = 0;
305  ProcessSP process_sp(GetSP());
306  if (process_sp) {
307  Status error;
308  bytes_read = process_sp->GetAsyncProfileData(dst, dst_len, error);
309  }
310 
311  return bytes_read;
312 }
313 
315  lldb::SBError &error) {
317  (lldb::SBTraceOptions &, lldb::SBError &), options, error);
318 
319  ProcessSP process_sp(GetSP());
320  error.Clear();
321  SBTrace trace_instance;
322  trace_instance.SetSP(process_sp);
324 
325  if (!process_sp) {
326  error.SetErrorString("invalid process");
327  } else {
328  uid = process_sp->StartTrace(*(options.m_traceoptions_sp), error.ref());
329  trace_instance.SetTraceUID(uid);
330  }
331  return LLDB_RECORD_RESULT(trace_instance);
332 }
333 
334 void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const {
336  (const lldb::SBEvent &, FILE *), event, out);
337 
338  if (out == NULL)
339  return;
340 
341  ProcessSP process_sp(GetSP());
342  if (process_sp) {
343  const StateType event_state = SBProcess::GetStateFromEvent(event);
344  char message[1024];
345  int message_len = ::snprintf(
346  message, sizeof(message), "Process %" PRIu64 " %s\n",
347  process_sp->GetID(), SBDebugger::StateAsCString(event_state));
348 
349  if (message_len > 0)
350  ::fwrite(message, 1, message_len, out);
351  }
352 }
353 
355  SBCommandReturnObject &result) {
358  event, result);
359 
360  ProcessSP process_sp(GetSP());
361  if (process_sp) {
362  const StateType event_state = SBProcess::GetStateFromEvent(event);
363  char message[1024];
364  ::snprintf(message, sizeof(message), "Process %" PRIu64 " %s\n",
365  process_sp->GetID(), SBDebugger::StateAsCString(event_state));
366 
367  result.AppendMessage(message);
368  }
369 }
370 
373  (const lldb::SBThread &), thread);
374 
375  ProcessSP process_sp(GetSP());
376  if (process_sp) {
377  std::lock_guard<std::recursive_mutex> guard(
378  process_sp->GetTarget().GetAPIMutex());
379  return process_sp->GetThreadList().SetSelectedThreadByID(
380  thread.GetThreadID());
381  }
382  return false;
383 }
384 
387  tid);
388 
389 
390  bool ret_val = false;
391  ProcessSP process_sp(GetSP());
392  if (process_sp) {
393  std::lock_guard<std::recursive_mutex> guard(
394  process_sp->GetTarget().GetAPIMutex());
395  ret_val = process_sp->GetThreadList().SetSelectedThreadByID(tid);
396  }
397 
398  return ret_val;
399 }
400 
403  index_id);
404 
405  bool ret_val = false;
406  ProcessSP process_sp(GetSP());
407  if (process_sp) {
408  std::lock_guard<std::recursive_mutex> guard(
409  process_sp->GetTarget().GetAPIMutex());
410  ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID(index_id);
411  }
412 
413 
414  return ret_val;
415 }
416 
419  index);
420 
421  SBThread sb_thread;
422  ThreadSP thread_sp;
423  ProcessSP process_sp(GetSP());
424  if (process_sp) {
425  Process::StopLocker stop_locker;
426  const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
427  std::lock_guard<std::recursive_mutex> guard(
428  process_sp->GetTarget().GetAPIMutex());
429  thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, can_update);
430  sb_thread.SetThread(thread_sp);
431  }
432 
433  return LLDB_RECORD_RESULT(sb_thread);
434 }
435 
438 
439  uint32_t num_queues = 0;
440  ProcessSP process_sp(GetSP());
441  if (process_sp) {
442  Process::StopLocker stop_locker;
443  if (stop_locker.TryLock(&process_sp->GetRunLock())) {
444  std::lock_guard<std::recursive_mutex> guard(
445  process_sp->GetTarget().GetAPIMutex());
446  num_queues = process_sp->GetQueueList().GetSize();
447  }
448  }
449 
450  return num_queues;
451 }
452 
455  index);
456 
457  SBQueue sb_queue;
458  QueueSP queue_sp;
459  ProcessSP process_sp(GetSP());
460  if (process_sp) {
461  Process::StopLocker stop_locker;
462  if (stop_locker.TryLock(&process_sp->GetRunLock())) {
463  std::lock_guard<std::recursive_mutex> guard(
464  process_sp->GetTarget().GetAPIMutex());
465  queue_sp = process_sp->GetQueueList().GetQueueAtIndex(index);
466  sb_queue.SetQueue(queue_sp);
467  }
468  }
469 
470  return LLDB_RECORD_RESULT(sb_queue);
471 }
472 
473 uint32_t SBProcess::GetStopID(bool include_expression_stops) {
475  include_expression_stops);
476 
477  ProcessSP process_sp(GetSP());
478  if (process_sp) {
479  std::lock_guard<std::recursive_mutex> guard(
480  process_sp->GetTarget().GetAPIMutex());
481  if (include_expression_stops)
482  return process_sp->GetStopID();
483  else
484  return process_sp->GetLastNaturalStopID();
485  }
486  return 0;
487 }
488 
491  (uint32_t), stop_id);
492 
493  SBEvent sb_event;
494  EventSP event_sp;
495  ProcessSP process_sp(GetSP());
496  if (process_sp) {
497  std::lock_guard<std::recursive_mutex> guard(
498  process_sp->GetTarget().GetAPIMutex());
499  event_sp = process_sp->GetStopEventForStopID(stop_id);
500  sb_event.reset(event_sp);
501  }
502 
503  return LLDB_RECORD_RESULT(sb_event);
504 }
505 
508 
509  StateType ret_val = eStateInvalid;
510  ProcessSP process_sp(GetSP());
511  if (process_sp) {
512  std::lock_guard<std::recursive_mutex> guard(
513  process_sp->GetTarget().GetAPIMutex());
514  ret_val = process_sp->GetState();
515  }
516 
517  return ret_val;
518 }
519 
522 
523  int exit_status = 0;
524  ProcessSP process_sp(GetSP());
525  if (process_sp) {
526  std::lock_guard<std::recursive_mutex> guard(
527  process_sp->GetTarget().GetAPIMutex());
528  exit_status = process_sp->GetExitStatus();
529  }
530 
531  return exit_status;
532 }
533 
536 
537  const char *exit_desc = NULL;
538  ProcessSP process_sp(GetSP());
539  if (process_sp) {
540  std::lock_guard<std::recursive_mutex> guard(
541  process_sp->GetTarget().GetAPIMutex());
542  exit_desc = process_sp->GetExitDescription();
543  }
544  return exit_desc;
545 }
546 
549 
551  ProcessSP process_sp(GetSP());
552  if (process_sp)
553  ret_val = process_sp->GetID();
554 
555  return ret_val;
556 }
557 
560 
561  uint32_t ret_val = 0;
562  ProcessSP process_sp(GetSP());
563  if (process_sp)
564  ret_val = process_sp->GetUniqueID();
565  return ret_val;
566 }
567 
570 
571  ByteOrder byteOrder = eByteOrderInvalid;
572  ProcessSP process_sp(GetSP());
573  if (process_sp)
574  byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder();
575 
576 
577  return byteOrder;
578 }
579 
582 
583  uint32_t size = 0;
584  ProcessSP process_sp(GetSP());
585  if (process_sp)
586  size = process_sp->GetTarget().GetArchitecture().GetAddressByteSize();
587 
588 
589  return size;
590 }
591 
594 
595  SBError sb_error;
596  ProcessSP process_sp(GetSP());
597 
598  if (process_sp) {
599  std::lock_guard<std::recursive_mutex> guard(
600  process_sp->GetTarget().GetAPIMutex());
601 
602  if (process_sp->GetTarget().GetDebugger().GetAsyncExecution())
603  sb_error.ref() = process_sp->Resume();
604  else
605  sb_error.ref() = process_sp->ResumeSynchronous(NULL);
606  } else
607  sb_error.SetErrorString("SBProcess is invalid");
608 
609  return LLDB_RECORD_RESULT(sb_error);
610 }
611 
614 
615  SBError sb_error;
616  ProcessSP process_sp(GetSP());
617  if (process_sp) {
618  std::lock_guard<std::recursive_mutex> guard(
619  process_sp->GetTarget().GetAPIMutex());
620  sb_error.SetError(process_sp->Destroy(false));
621  } else
622  sb_error.SetErrorString("SBProcess is invalid");
623 
624  return LLDB_RECORD_RESULT(sb_error);
625 }
626 
629 
630  SBError sb_error;
631  ProcessSP process_sp(GetSP());
632  if (process_sp) {
633  std::lock_guard<std::recursive_mutex> guard(
634  process_sp->GetTarget().GetAPIMutex());
635  sb_error.SetError(process_sp->Halt());
636  } else
637  sb_error.SetErrorString("SBProcess is invalid");
638 
639  return LLDB_RECORD_RESULT(sb_error);
640 }
641 
644 
645  SBError sb_error;
646  ProcessSP process_sp(GetSP());
647  if (process_sp) {
648  std::lock_guard<std::recursive_mutex> guard(
649  process_sp->GetTarget().GetAPIMutex());
650  sb_error.SetError(process_sp->Destroy(true));
651  } else
652  sb_error.SetErrorString("SBProcess is invalid");
653 
654  return LLDB_RECORD_RESULT(sb_error);
655 }
656 
659 
660  // FIXME: This should come from a process default.
661  bool keep_stopped = false;
662  return LLDB_RECORD_RESULT(Detach(keep_stopped));
663 }
664 
665 SBError SBProcess::Detach(bool keep_stopped) {
666  LLDB_RECORD_METHOD(lldb::SBError, SBProcess, Detach, (bool), keep_stopped);
667 
668  SBError sb_error;
669  ProcessSP process_sp(GetSP());
670  if (process_sp) {
671  std::lock_guard<std::recursive_mutex> guard(
672  process_sp->GetTarget().GetAPIMutex());
673  sb_error.SetError(process_sp->Detach(keep_stopped));
674  } else
675  sb_error.SetErrorString("SBProcess is invalid");
676 
677  return LLDB_RECORD_RESULT(sb_error);
678 }
679 
682 
683  SBError sb_error;
684  ProcessSP process_sp(GetSP());
685  if (process_sp) {
686  std::lock_guard<std::recursive_mutex> guard(
687  process_sp->GetTarget().GetAPIMutex());
688  sb_error.SetError(process_sp->Signal(signo));
689  } else
690  sb_error.SetErrorString("SBProcess is invalid");
691 
692  return LLDB_RECORD_RESULT(sb_error);
693 }
694 
697 
698  if (auto process_sp = GetSP())
699  return LLDB_RECORD_RESULT(SBUnixSignals{process_sp});
700 
702 }
703 
706 
707  ProcessSP process_sp(GetSP());
708  if (process_sp) {
709  process_sp->SendAsyncInterrupt();
710  }
711 }
712 
715  tid);
716 
717  SBThread sb_thread;
718  ThreadSP thread_sp;
719  ProcessSP process_sp(GetSP());
720  if (process_sp) {
721  Process::StopLocker stop_locker;
722  const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
723  std::lock_guard<std::recursive_mutex> guard(
724  process_sp->GetTarget().GetAPIMutex());
725  thread_sp = process_sp->GetThreadList().FindThreadByID(tid, can_update);
726  sb_thread.SetThread(thread_sp);
727  }
728 
729  return LLDB_RECORD_RESULT(sb_thread);
730 }
731 
734  index_id);
735 
736  SBThread sb_thread;
737  ThreadSP thread_sp;
738  ProcessSP process_sp(GetSP());
739  if (process_sp) {
740  Process::StopLocker stop_locker;
741  const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
742  std::lock_guard<std::recursive_mutex> guard(
743  process_sp->GetTarget().GetAPIMutex());
744  thread_sp =
745  process_sp->GetThreadList().FindThreadByIndexID(index_id, can_update);
746  sb_thread.SetThread(thread_sp);
747  }
748 
749  return LLDB_RECORD_RESULT(sb_thread);
750 }
751 
754  (const lldb::SBEvent &), event);
755 
756  StateType ret_val = Process::ProcessEventData::GetStateFromEvent(event.get());
757 
758  return ret_val;
759 }
760 
763  (const lldb::SBEvent &), event);
764 
765  bool ret_val = Process::ProcessEventData::GetRestartedFromEvent(event.get());
766 
767  return ret_val;
768 }
769 
772  (const lldb::SBEvent &), event);
773 
774  return Process::ProcessEventData::GetNumRestartedReasons(event.get());
775 }
776 
777 const char *
779  size_t idx) {
780  LLDB_RECORD_STATIC_METHOD(const char *, SBProcess,
782  (const lldb::SBEvent &, size_t), event, idx);
783 
784  return Process::ProcessEventData::GetRestartedReasonAtIndex(event.get(), idx);
785 }
786 
789  (const lldb::SBEvent &), event);
790 
791  ProcessSP process_sp =
792  Process::ProcessEventData::GetProcessFromEvent(event.get());
793  if (!process_sp) {
794  // StructuredData events also know the process they come from. Try that.
795  process_sp = EventDataStructuredData::GetProcessFromEvent(event.get());
796  }
797 
798  return LLDB_RECORD_RESULT(SBProcess(process_sp));
799 }
800 
803  (const lldb::SBEvent &), event);
804 
805  return Process::ProcessEventData::GetInterruptedFromEvent(event.get());
806 }
807 
812  event);
813 
814  return LLDB_RECORD_RESULT(SBStructuredData(event.GetSP()));
815 }
816 
819  (const lldb::SBEvent &), event);
820 
821  return (event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass()) &&
823 }
824 
827  (const lldb::SBEvent &), event);
828 
829  EventSP event_sp = event.GetSP();
830  EventData *event_data = event_sp ? event_sp->GetData() : nullptr;
831  return event_data && (event_data->GetFlavor() ==
832  EventDataStructuredData::GetFlavorString());
833 }
834 
838 
839 
840  ProcessSP process_sp(GetSP());
841 
842  SBBroadcaster broadcaster(process_sp.get(), false);
843 
844 
845  return LLDB_RECORD_RESULT(broadcaster);
846 }
847 
851 
852  return Process::GetStaticBroadcasterClass().AsCString();
853 }
854 
855 size_t SBProcess::ReadMemory(addr_t addr, void *dst, size_t dst_len,
856  SBError &sb_error) {
858  (lldb::addr_t, void *, size_t, lldb::SBError &), addr, dst,
859  dst_len, sb_error);
860 
861  size_t bytes_read = 0;
862 
863  ProcessSP process_sp(GetSP());
864 
865 
866  if (process_sp) {
867  Process::StopLocker stop_locker;
868  if (stop_locker.TryLock(&process_sp->GetRunLock())) {
869  std::lock_guard<std::recursive_mutex> guard(
870  process_sp->GetTarget().GetAPIMutex());
871  bytes_read = process_sp->ReadMemory(addr, dst, dst_len, sb_error.ref());
872  } else {
873  sb_error.SetErrorString("process is running");
874  }
875  } else {
876  sb_error.SetErrorString("SBProcess is invalid");
877  }
878 
879  return bytes_read;
880 }
881 
882 size_t SBProcess::ReadCStringFromMemory(addr_t addr, void *buf, size_t size,
883  lldb::SBError &sb_error) {
885  (lldb::addr_t, void *, size_t, lldb::SBError &), addr, buf,
886  size, sb_error);
887 
888  size_t bytes_read = 0;
889  ProcessSP process_sp(GetSP());
890  if (process_sp) {
891  Process::StopLocker stop_locker;
892  if (stop_locker.TryLock(&process_sp->GetRunLock())) {
893  std::lock_guard<std::recursive_mutex> guard(
894  process_sp->GetTarget().GetAPIMutex());
895  bytes_read = process_sp->ReadCStringFromMemory(addr, (char *)buf, size,
896  sb_error.ref());
897  } else {
898  sb_error.SetErrorString("process is running");
899  }
900  } else {
901  sb_error.SetErrorString("SBProcess is invalid");
902  }
903  return bytes_read;
904 }
905 
907  lldb::SBError &sb_error) {
909  (lldb::addr_t, uint32_t, lldb::SBError &), addr, byte_size,
910  sb_error);
911 
912  uint64_t value = 0;
913  ProcessSP process_sp(GetSP());
914  if (process_sp) {
915  Process::StopLocker stop_locker;
916  if (stop_locker.TryLock(&process_sp->GetRunLock())) {
917  std::lock_guard<std::recursive_mutex> guard(
918  process_sp->GetTarget().GetAPIMutex());
919  value = process_sp->ReadUnsignedIntegerFromMemory(addr, byte_size, 0,
920  sb_error.ref());
921  } else {
922  sb_error.SetErrorString("process is running");
923  }
924  } else {
925  sb_error.SetErrorString("SBProcess is invalid");
926  }
927  return value;
928 }
929 
931  lldb::SBError &sb_error) {
933  (lldb::addr_t, lldb::SBError &), addr, sb_error);
934 
936  ProcessSP process_sp(GetSP());
937  if (process_sp) {
938  Process::StopLocker stop_locker;
939  if (stop_locker.TryLock(&process_sp->GetRunLock())) {
940  std::lock_guard<std::recursive_mutex> guard(
941  process_sp->GetTarget().GetAPIMutex());
942  ptr = process_sp->ReadPointerFromMemory(addr, sb_error.ref());
943  } else {
944  sb_error.SetErrorString("process is running");
945  }
946  } else {
947  sb_error.SetErrorString("SBProcess is invalid");
948  }
949  return ptr;
950 }
951 
952 size_t SBProcess::WriteMemory(addr_t addr, const void *src, size_t src_len,
953  SBError &sb_error) {
955  (lldb::addr_t, const void *, size_t, lldb::SBError &), addr,
956  src, src_len, sb_error);
957 
958  size_t bytes_written = 0;
959 
960  ProcessSP process_sp(GetSP());
961 
962  if (process_sp) {
963  Process::StopLocker stop_locker;
964  if (stop_locker.TryLock(&process_sp->GetRunLock())) {
965  std::lock_guard<std::recursive_mutex> guard(
966  process_sp->GetTarget().GetAPIMutex());
967  bytes_written =
968  process_sp->WriteMemory(addr, src, src_len, sb_error.ref());
969  } else {
970  sb_error.SetErrorString("process is running");
971  }
972  }
973 
974  return bytes_written;
975 }
976 
979  description);
980 
981  Stream &strm = description.ref();
982 
983  ProcessSP process_sp(GetSP());
984  if (process_sp) {
985  char path[PATH_MAX];
986  GetTarget().GetExecutable().GetPath(path, sizeof(path));
987  Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
988  const char *exe_name = NULL;
989  if (exe_module)
990  exe_name = exe_module->GetFileSpec().GetFilename().AsCString();
991 
992  strm.Printf("SBProcess: pid = %" PRIu64 ", state = %s, threads = %d%s%s",
993  process_sp->GetID(), lldb_private::StateAsCString(GetState()),
994  GetNumThreads(), exe_name ? ", executable = " : "",
995  exe_name ? exe_name : "");
996  } else
997  strm.PutCString("No value");
998 
999  return true;
1000 }
1001 
1002 uint32_t
1006  (lldb::SBError &), sb_error);
1007 
1008  uint32_t num = 0;
1009  ProcessSP process_sp(GetSP());
1010  if (process_sp) {
1011  std::lock_guard<std::recursive_mutex> guard(
1012  process_sp->GetTarget().GetAPIMutex());
1013  sb_error.SetError(process_sp->GetWatchpointSupportInfo(num));
1014  } else {
1015  sb_error.SetErrorString("SBProcess is invalid");
1016  }
1017  return num;
1018 }
1019 
1021  lldb::SBError &sb_error) {
1024  sb_remote_image_spec, sb_error);
1025 
1026  return LoadImage(SBFileSpec(), sb_remote_image_spec, sb_error);
1027 }
1028 
1030  const lldb::SBFileSpec &sb_remote_image_spec,
1031  lldb::SBError &sb_error) {
1034  (const lldb::SBFileSpec &, const lldb::SBFileSpec &, lldb::SBError &),
1035  sb_local_image_spec, sb_remote_image_spec, sb_error);
1036 
1037  ProcessSP process_sp(GetSP());
1038  if (process_sp) {
1039  Process::StopLocker stop_locker;
1040  if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1041  std::lock_guard<std::recursive_mutex> guard(
1042  process_sp->GetTarget().GetAPIMutex());
1043  PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
1044  return platform_sp->LoadImage(process_sp.get(), *sb_local_image_spec,
1045  *sb_remote_image_spec, sb_error.ref());
1046  } else {
1047  sb_error.SetErrorString("process is running");
1048  }
1049  } else {
1050  sb_error.SetErrorString("process is invalid");
1051  }
1052  return LLDB_INVALID_IMAGE_TOKEN;
1053 }
1054 
1056  SBStringList &paths,
1057  lldb::SBFileSpec &loaded_path,
1058  lldb::SBError &error) {
1062  image_spec, paths, loaded_path, error);
1063 
1064  ProcessSP process_sp(GetSP());
1065  if (process_sp) {
1066  Process::StopLocker stop_locker;
1067  if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1068  std::lock_guard<std::recursive_mutex> guard(
1069  process_sp->GetTarget().GetAPIMutex());
1070  PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
1071  size_t num_paths = paths.GetSize();
1072  std::vector<std::string> paths_vec;
1073  paths_vec.reserve(num_paths);
1074  for (size_t i = 0; i < num_paths; i++)
1075  paths_vec.push_back(paths.GetStringAtIndex(i));
1076  FileSpec loaded_spec;
1077 
1078  uint32_t token = platform_sp->LoadImageUsingPaths(
1079  process_sp.get(), *image_spec, paths_vec, error.ref(), &loaded_spec);
1080  if (token != LLDB_INVALID_IMAGE_TOKEN)
1081  loaded_path = loaded_spec;
1082  return token;
1083  } else {
1084  error.SetErrorString("process is running");
1085  }
1086  } else {
1087  error.SetErrorString("process is invalid");
1088  }
1089 
1090  return LLDB_INVALID_IMAGE_TOKEN;
1091 }
1092 
1095  image_token);
1096 
1097  lldb::SBError sb_error;
1098  ProcessSP process_sp(GetSP());
1099  if (process_sp) {
1100  Process::StopLocker stop_locker;
1101  if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1102  std::lock_guard<std::recursive_mutex> guard(
1103  process_sp->GetTarget().GetAPIMutex());
1104  PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
1105  sb_error.SetError(
1106  platform_sp->UnloadImage(process_sp.get(), image_token));
1107  } else {
1108  sb_error.SetErrorString("process is running");
1109  }
1110  } else
1111  sb_error.SetErrorString("invalid process");
1112  return LLDB_RECORD_RESULT(sb_error);
1113 }
1114 
1115 lldb::SBError SBProcess::SendEventData(const char *event_data) {
1117  event_data);
1118 
1119  lldb::SBError sb_error;
1120  ProcessSP process_sp(GetSP());
1121  if (process_sp) {
1122  Process::StopLocker stop_locker;
1123  if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1124  std::lock_guard<std::recursive_mutex> guard(
1125  process_sp->GetTarget().GetAPIMutex());
1126  sb_error.SetError(process_sp->SendEventData(event_data));
1127  } else {
1128  sb_error.SetErrorString("process is running");
1129  }
1130  } else
1131  sb_error.SetErrorString("invalid process");
1132  return LLDB_RECORD_RESULT(sb_error);
1133 }
1134 
1137 
1138  ProcessSP process_sp(GetSP());
1139  if (process_sp && process_sp->GetSystemRuntime()) {
1140  SystemRuntime *runtime = process_sp->GetSystemRuntime();
1141  return runtime->GetExtendedBacktraceTypes().size();
1142  }
1143  return 0;
1144 }
1145 
1148  (uint32_t), idx);
1149 
1150  ProcessSP process_sp(GetSP());
1151  if (process_sp && process_sp->GetSystemRuntime()) {
1152  SystemRuntime *runtime = process_sp->GetSystemRuntime();
1153  const std::vector<ConstString> &names =
1154  runtime->GetExtendedBacktraceTypes();
1155  if (idx < names.size()) {
1156  return names[idx].AsCString();
1157  }
1158  }
1159  return NULL;
1160 }
1161 
1164  (lldb::addr_t), addr);
1165 
1166  ProcessSP process_sp(GetSP());
1167  SBThreadCollection threads;
1168  if (process_sp) {
1169  threads = SBThreadCollection(process_sp->GetHistoryThreads(addr));
1170  }
1171  return LLDB_RECORD_RESULT(threads);
1172 }
1173 
1178 
1179  ProcessSP process_sp(GetSP());
1180  if (!process_sp)
1181  return false;
1182 
1183  InstrumentationRuntimeSP runtime_sp =
1184  process_sp->GetInstrumentationRuntime(type);
1185 
1186  if (!runtime_sp.get())
1187  return false;
1188 
1189  return runtime_sp->IsActive();
1190 }
1191 
1192 lldb::SBError SBProcess::SaveCore(const char *file_name) {
1194  file_name);
1195 
1196  lldb::SBError error;
1197  ProcessSP process_sp(GetSP());
1198  if (!process_sp) {
1199  error.SetErrorString("SBProcess is invalid");
1200  return LLDB_RECORD_RESULT(error);
1201  }
1202 
1203  std::lock_guard<std::recursive_mutex> guard(
1204  process_sp->GetTarget().GetAPIMutex());
1205 
1206  if (process_sp->GetState() != eStateStopped) {
1207  error.SetErrorString("the process is not stopped");
1208  return LLDB_RECORD_RESULT(error);
1209  }
1210 
1211  FileSpec core_file(file_name);
1212  error.ref() = PluginManager::SaveCore(process_sp, core_file);
1213  return LLDB_RECORD_RESULT(error);
1214 }
1215 
1218  SBMemoryRegionInfo &sb_region_info) {
1220  (lldb::addr_t, lldb::SBMemoryRegionInfo &), load_addr,
1221  sb_region_info);
1222 
1223  lldb::SBError sb_error;
1224  ProcessSP process_sp(GetSP());
1225  if (process_sp) {
1226  Process::StopLocker stop_locker;
1227  if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1228  std::lock_guard<std::recursive_mutex> guard(
1229  process_sp->GetTarget().GetAPIMutex());
1230 
1231  sb_error.ref() =
1232  process_sp->GetMemoryRegionInfo(load_addr, sb_region_info.ref());
1233  } else {
1234  sb_error.SetErrorString("process is running");
1235  }
1236  } else {
1237  sb_error.SetErrorString("SBProcess is invalid");
1238  }
1239  return LLDB_RECORD_RESULT(sb_error);
1240 }
1241 
1245 
1246  lldb::SBMemoryRegionInfoList sb_region_list;
1247 
1248  ProcessSP process_sp(GetSP());
1249  Process::StopLocker stop_locker;
1250  if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock())) {
1251  std::lock_guard<std::recursive_mutex> guard(
1252  process_sp->GetTarget().GetAPIMutex());
1253 
1254  process_sp->GetMemoryRegions(sb_region_list.ref());
1255  }
1256 
1257  return LLDB_RECORD_RESULT(sb_region_list);
1258 }
1259 
1262 
1263  lldb::SBProcessInfo sb_proc_info;
1264  ProcessSP process_sp(GetSP());
1265  ProcessInstanceInfo proc_info;
1266  if (process_sp && process_sp->GetProcessInfo(proc_info)) {
1267  sb_proc_info.SetProcessInfo(proc_info);
1268  }
1269  return LLDB_RECORD_RESULT(sb_proc_info);
1270 }
1271 
1272 namespace lldb_private {
1273 namespace repro {
1274 
1275 template <>
1279  LLDB_REGISTER_CONSTRUCTOR(SBProcess, (const lldb::ProcessSP &));
1281  SBProcess, operator=,(const lldb::SBProcess &));
1282  LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess,
1284  LLDB_REGISTER_METHOD(const char *, SBProcess, GetPluginName, ());
1286  LLDB_REGISTER_METHOD(void, SBProcess, Clear, ());
1288  LLDB_REGISTER_METHOD_CONST(bool, SBProcess, operator bool, ());
1290  (const char **, const char **, const char *,
1291  const char *, const char *, const char *, uint32_t,
1292  bool, lldb::SBError &));
1294  (lldb::pid_t, lldb::SBError &));
1297  ());
1301  LLDB_REGISTER_METHOD(size_t, SBProcess, PutSTDIN, (const char *, size_t));
1302  LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t));
1303  LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t));
1305  (char *, size_t));
1309  (const lldb::SBEvent &, FILE *));
1314  (const lldb::SBThread &));
1317  (uint32_t));
1323  (uint32_t));
1341  (lldb::tid_t));
1343  (uint32_t));
1345  (const lldb::SBEvent &));
1347  (const lldb::SBEvent &));
1350  (const lldb::SBEvent &));
1351  LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess,
1353  (const lldb::SBEvent &, size_t));
1355  (const lldb::SBEvent &));
1357  (const lldb::SBEvent &));
1360  (const lldb::SBEvent &));
1362  (const lldb::SBEvent &));
1364  (const lldb::SBEvent &));
1366  ());
1368  ());
1376  (lldb::SBError &));
1381  (const lldb::SBFileSpec &, const lldb::SBFileSpec &, lldb::SBError &));
1387  (const char *));
1389  LLDB_REGISTER_METHOD(const char *, SBProcess,
1392  (lldb::addr_t));
1399  GetMemoryRegions, ());
1401 }
1402 
1403 }
1404 }
void RegisterMethods< SBProcess >(Registry &R)
Definition: SBProcess.cpp:1276
ConstString & GetFilename()
Filename string get accessor.
Definition: FileSpec.cpp:369
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:61
static const char * GetRestartedReasonAtIndexFromEvent(const lldb::SBEvent &event, size_t idx)
Definition: SBProcess.cpp:778
The registry contains a unique mapping between functions and their ID.
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
Definition: State.cpp:14
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
static const char * StateAsCString(lldb::StateType state)
Definition: SBDebugger.cpp:586
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:224
void SetExecutableFile(const FileSpec &exe_file, bool add_exe_file_as_first_arg)
Definition: ProcessInfo.cpp:61
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t ReadCStringFromMemory(addr_t addr, void *buf, size_t size, lldb::SBError &error)
Definition: SBProcess.cpp:882
void ReportEventState(const lldb::SBEvent &event, FILE *out) const
Definition: SBProcess.cpp:334
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition: Module.h:531
size_t GetSTDOUT(char *dst, size_t dst_len) const
Definition: SBProcess.cpp:272
void SetSP(const lldb::ProcessSP &process_sp)
Definition: SBProcess.cpp:108
static bool GetRestartedFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:761
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:92
lldb::SBError Detach()
Definition: SBProcess.cpp:657
bool Success() const
Definition: SBError.cpp:65
void SetSP(const ProcessSP &process_sp)
Definition: SBTrace.cpp:115
#define LLDB_RECORD_STATIC_METHOD(Result, Class, Method, Signature,...)
#define LLDB_RECORD_DUMMY(Result, Class, Method, Signature,...)
The LLDB_RECORD_DUMMY macro is special because it doesn&#39;t actually record anything.
lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError &error)
Definition: SBProcess.cpp:930
#define LLDB_RECORD_STATIC_METHOD_NO_ARGS(Result, Class, Method)
void Clear()
Definition: SBError.cpp:47
void SetProcessID(lldb::pid_t pid)
Definition: ProcessInfo.h:70
lldb::SBError UnloadImage(uint32_t image_token)
Definition: SBProcess.cpp:1093
const char * GetBroadcasterClass() const
Definition: SBEvent.cpp:99
A file utility class.
Definition: FileSpec.h:55
static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:752
lldb::SBError Kill()
Definition: SBProcess.cpp:642
void SetError(uint32_t err, lldb::ErrorType type)
Definition: SBError.cpp:97
lldb::ByteOrder GetByteOrder() const
Definition: SBProcess.cpp:568
lldb::SBQueue GetQueueAtIndex(size_t index)
Definition: SBProcess.cpp:453
lldb::EventSP & GetSP() const
Definition: SBEvent.cpp:139
lldb::pid_t GetProcessID()
Gets the process ID.
Definition: SBProcess.cpp:547
Process or thread is stopped and can be examined.
lldb::SBThread CreateOSPluginThread(lldb::tid_t tid, lldb::addr_t context)
Definition: SBProcess.cpp:226
#define LLDB_INVALID_UID
Definition: lldb-defines.h:91
bool SetSelectedThreadByIndexID(uint32_t index_id)
Definition: SBProcess.cpp:401
size_t GetSTDERR(char *dst, size_t dst_len) const
Definition: SBProcess.cpp:286
lldb_private::Event * get() const
Definition: SBEvent.cpp:141
void SendAsyncInterrupt()
Definition: SBProcess.cpp:704
const char * GetPluginName()
Definition: SBProcess.cpp:86
#define LLDB_REGISTER_STATIC_METHOD(Result, Class, Method, Signature)
lldb::SBThreadCollection GetHistoryThreads(addr_t addr)
Definition: SBProcess.cpp:1162
uint32_t GetNumSupportedHardwareWatchpoints(lldb::SBError &error) const
Definition: SBProcess.cpp:1003
uint32_t LoadImageUsingPaths(const lldb::SBFileSpec &image_spec, SBStringList &paths, lldb::SBFileSpec &loaded_path, lldb::SBError &error)
Load a shared library into this process, starting with a library name and a list of paths...
Definition: SBProcess.cpp:1055
void SetErrorString(const char *err_str)
Definition: SBError.cpp:124
lldb::SBMemoryRegionInfoList GetMemoryRegions()
Return the list of memory regions within the process.
Definition: SBProcess.cpp:1242
lldb::SBError Continue()
Definition: SBProcess.cpp:592
class LLDB_API SBFileSpec
Definition: SBDefines.h:44
void SetSP(const lldb::TargetSP &target_sp)
Definition: SBTarget.cpp:602
void SetQueue(const lldb::QueueSP &queue_sp)
Definition: SBQueue.cpp:264
lldb::SBEvent GetStopEventForStopID(uint32_t stop_id)
Gets the stop event corresponding to stop ID.
Definition: SBProcess.cpp:489
lldb::SBUnixSignals GetUnixSignals()
Definition: SBProcess.cpp:695
lldb::SBError SendEventData(const char *data)
Definition: SBProcess.cpp:1115
lldb::TraceOptionsSP m_traceoptions_sp
bool GetDescription(lldb::SBStream &description)
Definition: SBProcess.cpp:977
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
lldb::SBBroadcaster GetBroadcaster() const
Definition: SBProcess.cpp:835
uint64_t user_id_t
Definition: lldb-types.h:84
class LLDB_API SBStructuredData
Definition: SBDefines.h:68
const char * GetShortPluginName()
Definition: SBProcess.cpp:96
lldb::ProcessWP m_opaque_wp
Definition: SBProcess.h:410
lldb_private::Status & ref()
Definition: SBError.cpp:159
uint32_t GetNumExtendedBacktraceTypes()
Return the number of different thread-origin extended backtraces this process can support...
Definition: SBProcess.cpp:1135
static lldb::SBProcess GetProcessFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:787
InstrumentationRuntimeType
lldb::tid_t GetThreadID() const
Definition: SBThread.cpp:434
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
size_t PutSTDIN(const char *src, size_t src_len)
Definition: SBProcess.cpp:258
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:109
Process is connected to remote debug services, but not launched or attached to anything yet...
uint32_t GetSize() const
bool RemoteLaunch(char const **argv, char const **envp, const char *stdin_path, const char *stdout_path, const char *stderr_path, const char *working_directory, uint32_t launch_flags, bool stop_at_entry, lldb::SBError &error)
Definition: SBProcess.cpp:127
uint64_t tid_t
Definition: lldb-types.h:86
size_t ReadMemory(addr_t addr, void *buf, size_t size, lldb::SBError &error)
Definition: SBProcess.cpp:855
void reset(lldb::EventSP &event_sp)
void AppendEventStateReport(const lldb::SBEvent &event, lldb::SBCommandReturnObject &result)
Definition: SBProcess.cpp:354
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
lldb::ProcessSP GetSP() const
Definition: SBProcess.cpp:106
lldb::SBTrace StartTrace(SBTraceOptions &options, lldb::SBError &error)
Start Tracing with the given SBTraceOptions.
Definition: SBProcess.cpp:314
lldb::SBProcessInfo GetProcessInfo()
Return information about the process.
Definition: SBProcess.cpp:1260
Environment & GetEnvironment()
Definition: ProcessInfo.h:88
uint32_t GetUniqueID()
Gets the unique ID associated with this process object.
Definition: SBProcess.cpp:558
class LLDB_API SBThreadCollection
Definition: SBDefines.h:74
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
uint32_t LoadImage(lldb::SBFileSpec &remote_image_spec, lldb::SBError &error)
Load a shared library into this process.
Definition: SBProcess.cpp:1020
lldb::SBError SaveCore(const char *file_name)
Save the state of the process in a core file (or mini dump on Windows).
Definition: SBProcess.cpp:1192
static bool EventIsProcessEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:817
const char * GetExtendedBacktraceTypeAtIndex(uint32_t idx)
Return the name of one of the thread-origin extended backtrace methods.
Definition: SBProcess.cpp:1146
static lldb::SBStructuredData GetStructuredDataFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:809
lldb_private::Stream & ref()
Definition: SBStream.cpp:162
void SetTraceUID(lldb::user_id_t uid)
Definition: SBTrace.cpp:102
bool SetSelectedThreadByID(lldb::tid_t tid)
Definition: SBProcess.cpp:385
lldb::SBFileSpec GetExecutable()
Definition: SBTarget.cpp:572
#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature,...)
#define LLDB_INVALID_IMAGE_TOKEN
Definition: lldb-defines.h:88
void AppendMessage(const char *message)
lldb::SBError Destroy()
Definition: SBProcess.cpp:612
uint32_t GetAddressByteSize() const
Definition: SBProcess.cpp:580
static const char * GetBroadcasterClass()
Definition: SBProcess.cpp:848
const char * GetStringAtIndex(size_t idx)
lldb::SBThread GetThreadByIndexID(uint32_t index_id)
Definition: SBProcess.cpp:732
uint64_t addr_t
Definition: lldb-types.h:83
uint64_t ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size, lldb::SBError &error)
Definition: SBProcess.cpp:906
lldb::SBError Stop()
Definition: SBProcess.cpp:627
const FileSpec & GetPlatformFileSpec() const
Get accessor for the module platform file specification.
Definition: Module.h:545
uint32_t GetPath(char *dst_path, size_t dst_len) const
Definition: SBFileSpec.cpp:145
virtual const std::vector< ConstString > & GetExtendedBacktraceTypes()
Return a list of thread origin extended backtraces that may be available.
bool RemoteAttachToProcessWithID(lldb::pid_t pid, lldb::SBError &error)
Remote connection related functions.
Definition: SBProcess.cpp:168
uint32_t GetStopID(bool include_expression_stops=false)
Definition: SBProcess.cpp:473
lldb::SBThread GetThreadByID(lldb::tid_t sb_thread_id)
Definition: SBProcess.cpp:713
Definition: SBAddress.h:15
static size_t GetNumRestartedReasonsFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:770
uint64_t pid_t
Definition: lldb-types.h:85
const lldb::SBProcess & operator=(const lldb::SBProcess &rhs)
Definition: SBProcess.cpp:67
lldb::SBThread GetSelectedThread() const
Definition: SBProcess.cpp:209
#define PATH_MAX
lldb::SBError Signal(int signal)
Definition: SBProcess.cpp:680
const char * GetExitDescription()
Definition: SBProcess.cpp:534
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
uint32_t GetNumQueues()
Definition: SBProcess.cpp:436
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
static const char * GetBroadcasterClassName()
Definition: SBProcess.cpp:79
size_t WriteMemory(addr_t addr, const void *buf, size_t size, lldb::SBError &error)
Definition: SBProcess.cpp:952
bool SetSelectedThread(const lldb::SBThread &thread)
Definition: SBProcess.cpp:371
uint32_t GetNumThreads()
Definition: SBProcess.cpp:192
static bool EventIsStructuredDataEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:825
static bool GetInterruptedFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:801
lldb::SBTarget GetTarget() const
Definition: SBProcess.cpp:244
lldb::SBThread GetThreadAtIndex(size_t index)
Definition: SBProcess.cpp:417
void AppendArguments(const Args &rhs)
Definition: Args.cpp:296
size_t GetAsyncProfileData(char *dst, size_t dst_len) const
Definition: SBProcess.cpp:300
bool IsInstrumentationRuntimePresent(InstrumentationRuntimeType type)
Definition: SBProcess.cpp:1174
virtual ConstString GetFlavor() const =0
#define LLDB_RECORD_RESULT(Result)
lldb::StateType GetState()
Definition: SBProcess.cpp:506
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)
bool IsValid() const
Definition: SBProcess.cpp:116
An error handling class.
Definition: Status.h:44
A plug-in interface definition class for system runtimes.
Definition: SystemRuntime.h:42
lldb::SBError GetMemoryRegionInfo(lldb::addr_t load_addr, lldb::SBMemoryRegionInfo &region_info)
Query the address load_addr and store the details of the memory region that contains it in the suppli...
Definition: SBProcess.cpp:1217