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