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
11
12#include <cinttypes>
13
14#include "lldb/lldb-defines.h"
15#include "lldb/lldb-types.h"
16
18#include "lldb/Core/Debugger.h"
19#include "lldb/Core/Module.h"
24#include "lldb/Target/Process.h"
27#include "lldb/Target/Target.h"
28#include "lldb/Target/Thread.h"
29#include "lldb/Utility/Args.h"
32#include "lldb/Utility/State.h"
33#include "lldb/Utility/Stream.h"
34
37#include "lldb/API/SBDebugger.h"
38#include "lldb/API/SBEvent.h"
39#include "lldb/API/SBFile.h"
40#include "lldb/API/SBFileSpec.h"
45#include "lldb/API/SBStream.h"
48#include "lldb/API/SBThread.h"
50#include "lldb/API/SBTrace.h"
52
53using namespace lldb;
54using namespace lldb_private;
55
57
58// SBProcess constructor
59
60SBProcess::SBProcess(const SBProcess &rhs) : m_opaque_wp(rhs.m_opaque_wp) {
61 LLDB_INSTRUMENT_VA(this, rhs);
62}
63
65 : m_opaque_wp(process_sp) {
66 LLDB_INSTRUMENT_VA(this, process_sp);
67}
68
70 LLDB_INSTRUMENT_VA(this, rhs);
71
72 if (this != &rhs)
74 return *this;
75}
76
77// Destructor
78SBProcess::~SBProcess() = default;
79
82
84}
85
88
89 ProcessSP process_sp(GetSP());
90 if (process_sp) {
91 return ConstString(process_sp->GetPluginName()).GetCString();
92 }
93 return "<Unknown>";
94}
95
96const char *SBProcess::GetShortPluginName() {
98
99 ProcessSP process_sp(GetSP());
100 if (process_sp) {
101 return ConstString(process_sp->GetPluginName()).GetCString();
102 }
103 return "<Unknown>";
104}
105
107
108void SBProcess::SetSP(const ProcessSP &process_sp) { m_opaque_wp = process_sp; }
109
111 LLDB_INSTRUMENT_VA(this);
112
113 m_opaque_wp.reset();
114}
115
116bool SBProcess::IsValid() const {
117 LLDB_INSTRUMENT_VA(this);
118 return this->operator bool();
119}
120SBProcess::operator bool() const {
121 LLDB_INSTRUMENT_VA(this);
122
123 ProcessSP process_sp(m_opaque_wp.lock());
124 return ((bool)process_sp && process_sp->IsValid());
125}
126
127bool 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,
133 LLDB_INSTRUMENT_VA(this, argv, envp, stdin_path, stdout_path, stderr_path,
134 working_directory, launch_flags, stop_at_entry, error);
135
136 ProcessSP process_sp(GetSP());
137 if (process_sp) {
138 std::lock_guard<std::recursive_mutex> guard(
139 process_sp->GetTarget().GetAPIMutex());
140 if (process_sp->GetState() == eStateConnected) {
141 if (stop_at_entry)
142 launch_flags |= eLaunchFlagStopAtEntry;
143 ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path),
144 FileSpec(stderr_path),
145 FileSpec(working_directory), launch_flags);
146 Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
147 if (exe_module)
148 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
149 if (argv)
150 launch_info.GetArguments().AppendArguments(argv);
151 if (envp)
152 launch_info.GetEnvironment() = Environment(envp);
153 error.SetError(process_sp->Launch(launch_info));
154 } else {
156 "must be in eStateConnected to call RemoteLaunch");
157 }
158 } else {
159 error = Status::FromErrorString("unable to attach pid");
160 }
161
162 return error.Success();
163}
164
167 LLDB_INSTRUMENT_VA(this, pid, error);
168
169 ProcessSP process_sp(GetSP());
170 if (process_sp) {
171 std::lock_guard<std::recursive_mutex> guard(
172 process_sp->GetTarget().GetAPIMutex());
173 if (process_sp->GetState() == eStateConnected) {
174 ProcessAttachInfo attach_info;
175 attach_info.SetProcessID(pid);
176 error.SetError(process_sp->Attach(attach_info));
177 } else {
179 "must be in eStateConnected to call RemoteAttachToProcessWithID");
180 }
181 } else {
182 error = Status::FromErrorString("unable to attach pid");
183 }
184
185 return error.Success();
186}
187
189 LLDB_INSTRUMENT_VA(this);
190
191 uint32_t num_threads = 0;
192 ProcessSP process_sp(GetSP());
193 if (process_sp) {
194 Process::StopLocker stop_locker;
195
196 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
197 std::lock_guard<std::recursive_mutex> guard(
198 process_sp->GetTarget().GetAPIMutex());
199 num_threads = process_sp->GetThreadList().GetSize(can_update);
200 }
201
202 return num_threads;
203}
204
206 LLDB_INSTRUMENT_VA(this);
207
208 SBThread sb_thread;
209 ThreadSP thread_sp;
210 ProcessSP process_sp(GetSP());
211 if (process_sp) {
212 std::lock_guard<std::recursive_mutex> guard(
213 process_sp->GetTarget().GetAPIMutex());
214 thread_sp = process_sp->GetThreadList().GetSelectedThread();
215 sb_thread.SetThread(thread_sp);
216 }
217
218 return sb_thread;
219}
220
222 lldb::addr_t context) {
223 LLDB_INSTRUMENT_VA(this, tid, context);
224
225 SBThread sb_thread;
226 ThreadSP thread_sp;
227 ProcessSP process_sp(GetSP());
228 if (process_sp) {
229 std::lock_guard<std::recursive_mutex> guard(
230 process_sp->GetTarget().GetAPIMutex());
231 thread_sp = process_sp->CreateOSPluginThread(tid, context);
232 sb_thread.SetThread(thread_sp);
233 }
234
235 return sb_thread;
236}
237
239 LLDB_INSTRUMENT_VA(this);
240
241 SBTarget sb_target;
242 TargetSP target_sp;
243 ProcessSP process_sp(GetSP());
244 if (process_sp) {
245 target_sp = process_sp->GetTarget().shared_from_this();
246 sb_target.SetSP(target_sp);
247 }
248
249 return sb_target;
250}
251
252size_t SBProcess::PutSTDIN(const char *src, size_t src_len) {
253 LLDB_INSTRUMENT_VA(this, src, src_len);
254
255 size_t ret_val = 0;
256 ProcessSP process_sp(GetSP());
257 if (process_sp) {
259 ret_val = process_sp->PutSTDIN(src, src_len, error);
260 }
261
262 return ret_val;
263}
264
265size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const {
266 LLDB_INSTRUMENT_VA(this, dst, dst_len);
267
268 size_t bytes_read = 0;
269 ProcessSP process_sp(GetSP());
270 if (process_sp) {
272 bytes_read = process_sp->GetSTDOUT(dst, dst_len, error);
273 }
274
275 return bytes_read;
276}
277
278size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const {
279 LLDB_INSTRUMENT_VA(this, dst, dst_len);
280
281 size_t bytes_read = 0;
282 ProcessSP process_sp(GetSP());
283 if (process_sp) {
285 bytes_read = process_sp->GetSTDERR(dst, dst_len, error);
286 }
287
288 return bytes_read;
289}
290
291size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const {
292 LLDB_INSTRUMENT_VA(this, dst, dst_len);
293
294 size_t bytes_read = 0;
295 ProcessSP process_sp(GetSP());
296 if (process_sp) {
298 bytes_read = process_sp->GetAsyncProfileData(dst, dst_len, error);
299 }
300
301 return bytes_read;
302}
303
304void SBProcess::ReportEventState(const SBEvent &event, SBFile out) const {
305 LLDB_INSTRUMENT_VA(this, event, out);
306
307 return ReportEventState(event, out.m_opaque_sp);
308}
309
310void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const {
311 LLDB_INSTRUMENT_VA(this, event, out);
312 FileSP outfile = std::make_shared<NativeFile>(out, false);
313 return ReportEventState(event, outfile);
314}
315
316void SBProcess::ReportEventState(const SBEvent &event, FileSP out) const {
317
318 LLDB_INSTRUMENT_VA(this, event, out);
319
320 if (!out || !out->IsValid())
321 return;
322
323 ProcessSP process_sp(GetSP());
324 if (process_sp) {
325 StreamFile stream(out);
326 const StateType event_state = SBProcess::GetStateFromEvent(event);
327 stream.Printf("Process %" PRIu64 " %s\n", process_sp->GetID(),
328 SBDebugger::StateAsCString(event_state));
329 }
330}
331
333 SBCommandReturnObject &result) {
334 LLDB_INSTRUMENT_VA(this, event, result);
335
336 ProcessSP process_sp(GetSP());
337 if (process_sp) {
338 const StateType event_state = SBProcess::GetStateFromEvent(event);
339 char message[1024];
340 ::snprintf(message, sizeof(message), "Process %" PRIu64 " %s\n",
341 process_sp->GetID(), SBDebugger::StateAsCString(event_state));
342
343 result.AppendMessage(message);
344 }
345}
346
348 LLDB_INSTRUMENT_VA(this, thread);
349
350 ProcessSP process_sp(GetSP());
351 if (process_sp) {
352 std::lock_guard<std::recursive_mutex> guard(
353 process_sp->GetTarget().GetAPIMutex());
354 return process_sp->GetThreadList().SetSelectedThreadByID(
355 thread.GetThreadID());
356 }
357 return false;
358}
359
361 LLDB_INSTRUMENT_VA(this, tid);
362
363 bool ret_val = false;
364 ProcessSP process_sp(GetSP());
365 if (process_sp) {
366 std::lock_guard<std::recursive_mutex> guard(
367 process_sp->GetTarget().GetAPIMutex());
368 ret_val = process_sp->GetThreadList().SetSelectedThreadByID(tid);
369 }
370
371 return ret_val;
372}
373
375 LLDB_INSTRUMENT_VA(this, index_id);
376
377 bool ret_val = false;
378 ProcessSP process_sp(GetSP());
379 if (process_sp) {
380 std::lock_guard<std::recursive_mutex> guard(
381 process_sp->GetTarget().GetAPIMutex());
382 ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID(index_id);
383 }
384
385 return ret_val;
386}
387
389 LLDB_INSTRUMENT_VA(this, index);
390
391 SBThread sb_thread;
392 ThreadSP thread_sp;
393 ProcessSP process_sp(GetSP());
394 if (process_sp) {
395 Process::StopLocker stop_locker;
396 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
397 std::lock_guard<std::recursive_mutex> guard(
398 process_sp->GetTarget().GetAPIMutex());
399 thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, can_update);
400 sb_thread.SetThread(thread_sp);
401 }
402
403 return sb_thread;
404}
405
407 LLDB_INSTRUMENT_VA(this);
408
409 uint32_t num_queues = 0;
410 ProcessSP process_sp(GetSP());
411 if (process_sp) {
412 Process::StopLocker stop_locker;
413 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
414 std::lock_guard<std::recursive_mutex> guard(
415 process_sp->GetTarget().GetAPIMutex());
416 num_queues = process_sp->GetQueueList().GetSize();
417 }
418 }
419
420 return num_queues;
421}
422
424 LLDB_INSTRUMENT_VA(this, index);
425
426 SBQueue sb_queue;
427 QueueSP queue_sp;
428 ProcessSP process_sp(GetSP());
429 if (process_sp) {
430 Process::StopLocker stop_locker;
431 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
432 std::lock_guard<std::recursive_mutex> guard(
433 process_sp->GetTarget().GetAPIMutex());
434 queue_sp = process_sp->GetQueueList().GetQueueAtIndex(index);
435 sb_queue.SetQueue(queue_sp);
436 }
437 }
438
439 return sb_queue;
440}
441
442uint32_t SBProcess::GetStopID(bool include_expression_stops) {
443 LLDB_INSTRUMENT_VA(this, include_expression_stops);
444
445 ProcessSP process_sp(GetSP());
446 if (process_sp) {
447 std::lock_guard<std::recursive_mutex> guard(
448 process_sp->GetTarget().GetAPIMutex());
449 if (include_expression_stops)
450 return process_sp->GetStopID();
451 else
452 return process_sp->GetLastNaturalStopID();
453 }
454 return 0;
455}
456
458 LLDB_INSTRUMENT_VA(this, stop_id);
459
460 SBEvent sb_event;
461 EventSP event_sp;
462 ProcessSP process_sp(GetSP());
463 if (process_sp) {
464 std::lock_guard<std::recursive_mutex> guard(
465 process_sp->GetTarget().GetAPIMutex());
466 event_sp = process_sp->GetStopEventForStopID(stop_id);
467 sb_event.reset(event_sp);
468 }
469
470 return sb_event;
471}
472
474 LLDB_INSTRUMENT_VA(this, new_state);
475
476 if (ProcessSP process_sp = GetSP()) {
477 std::lock_guard<std::recursive_mutex> guard(
478 process_sp->GetTarget().GetAPIMutex());
479 process_sp->ForceScriptedState(new_state);
480 }
481}
482
484 LLDB_INSTRUMENT_VA(this);
485
486 StateType ret_val = eStateInvalid;
487 ProcessSP process_sp(GetSP());
488 if (process_sp) {
489 std::lock_guard<std::recursive_mutex> guard(
490 process_sp->GetTarget().GetAPIMutex());
491 ret_val = process_sp->GetState();
492 }
493
494 return ret_val;
495}
496
498 LLDB_INSTRUMENT_VA(this);
499
500 int exit_status = 0;
501 ProcessSP process_sp(GetSP());
502 if (process_sp) {
503 std::lock_guard<std::recursive_mutex> guard(
504 process_sp->GetTarget().GetAPIMutex());
505 exit_status = process_sp->GetExitStatus();
506 }
507
508 return exit_status;
509}
510
512 LLDB_INSTRUMENT_VA(this);
513
514 ProcessSP process_sp(GetSP());
515 if (!process_sp)
516 return nullptr;
517
518 std::lock_guard<std::recursive_mutex> guard(
519 process_sp->GetTarget().GetAPIMutex());
520 return ConstString(process_sp->GetExitDescription()).GetCString();
521}
522
524 LLDB_INSTRUMENT_VA(this);
525
527 ProcessSP process_sp(GetSP());
528 if (process_sp)
529 ret_val = process_sp->GetID();
530
531 return ret_val;
532}
533
535 LLDB_INSTRUMENT_VA(this);
536
537 uint32_t ret_val = 0;
538 ProcessSP process_sp(GetSP());
539 if (process_sp)
540 ret_val = process_sp->GetUniqueID();
541 return ret_val;
542}
543
545 LLDB_INSTRUMENT_VA(this);
546
547 ByteOrder byteOrder = eByteOrderInvalid;
548 ProcessSP process_sp(GetSP());
549 if (process_sp)
550 byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder();
551
552 return byteOrder;
553}
554
556 LLDB_INSTRUMENT_VA(this);
557
558 uint32_t size = 0;
559 ProcessSP process_sp(GetSP());
560 if (process_sp)
561 size = process_sp->GetTarget().GetArchitecture().GetAddressByteSize();
562
563 return size;
564}
565
567 LLDB_INSTRUMENT_VA(this);
568
569 SBError sb_error;
570 ProcessSP process_sp(GetSP());
571
572 if (process_sp) {
573 std::lock_guard<std::recursive_mutex> guard(
574 process_sp->GetTarget().GetAPIMutex());
575
576 if (process_sp->GetTarget().GetDebugger().GetAsyncExecution())
577 sb_error.ref() = process_sp->Resume();
578 else
579 sb_error.ref() = process_sp->ResumeSynchronous(nullptr);
580 } else
581 sb_error = Status::FromErrorString("SBProcess is invalid");
582
583 return sb_error;
584}
585
587 LLDB_INSTRUMENT_VA(this);
588
589 SBError sb_error;
590 ProcessSP process_sp(GetSP());
591 if (process_sp) {
592 std::lock_guard<std::recursive_mutex> guard(
593 process_sp->GetTarget().GetAPIMutex());
594 sb_error.SetError(process_sp->Destroy(false));
595 } else
596 sb_error = Status::FromErrorString("SBProcess is invalid");
597
598 return sb_error;
599}
600
602 LLDB_INSTRUMENT_VA(this);
603
604 SBError sb_error;
605 ProcessSP process_sp(GetSP());
606 if (process_sp) {
607 std::lock_guard<std::recursive_mutex> guard(
608 process_sp->GetTarget().GetAPIMutex());
609 sb_error.SetError(process_sp->Halt());
610 } else
611 sb_error = Status::FromErrorString("SBProcess is invalid");
612
613 return sb_error;
614}
615
617 LLDB_INSTRUMENT_VA(this);
618
619 SBError sb_error;
620 ProcessSP process_sp(GetSP());
621 if (process_sp) {
622 std::lock_guard<std::recursive_mutex> guard(
623 process_sp->GetTarget().GetAPIMutex());
624 sb_error.SetError(process_sp->Destroy(true));
625 } else
626 sb_error = Status::FromErrorString("SBProcess is invalid");
627
628 return sb_error;
629}
630
632 LLDB_INSTRUMENT_VA(this);
633
634 // FIXME: This should come from a process default.
635 bool keep_stopped = false;
636 return Detach(keep_stopped);
637}
638
639SBError SBProcess::Detach(bool keep_stopped) {
640 LLDB_INSTRUMENT_VA(this, keep_stopped);
641
642 SBError sb_error;
643 ProcessSP process_sp(GetSP());
644 if (process_sp) {
645 std::lock_guard<std::recursive_mutex> guard(
646 process_sp->GetTarget().GetAPIMutex());
647 sb_error.SetError(process_sp->Detach(keep_stopped));
648 } else
649 sb_error = Status::FromErrorString("SBProcess is invalid");
650
651 return sb_error;
652}
653
655 LLDB_INSTRUMENT_VA(this, signo);
656
657 SBError sb_error;
658 ProcessSP process_sp(GetSP());
659 if (process_sp) {
660 std::lock_guard<std::recursive_mutex> guard(
661 process_sp->GetTarget().GetAPIMutex());
662 sb_error.SetError(process_sp->Signal(signo));
663 } else
664 sb_error = Status::FromErrorString("SBProcess is invalid");
665
666 return sb_error;
667}
668
670 LLDB_INSTRUMENT_VA(this);
671
672 if (auto process_sp = GetSP())
673 return SBUnixSignals{process_sp};
674
675 return SBUnixSignals{};
676}
677
679 LLDB_INSTRUMENT_VA(this);
680
681 ProcessSP process_sp(GetSP());
682 if (process_sp) {
683 process_sp->SendAsyncInterrupt();
684 }
685}
686
688 LLDB_INSTRUMENT_VA(this, tid);
689
690 SBThread sb_thread;
691 ThreadSP thread_sp;
692 ProcessSP process_sp(GetSP());
693 if (process_sp) {
694 Process::StopLocker stop_locker;
695 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
696 std::lock_guard<std::recursive_mutex> guard(
697 process_sp->GetTarget().GetAPIMutex());
698 thread_sp = process_sp->GetThreadList().FindThreadByID(tid, can_update);
699 sb_thread.SetThread(thread_sp);
700 }
701
702 return sb_thread;
703}
704
706 LLDB_INSTRUMENT_VA(this, index_id);
707
708 SBThread sb_thread;
709 ThreadSP thread_sp;
710 ProcessSP process_sp(GetSP());
711 if (process_sp) {
712 Process::StopLocker stop_locker;
713 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
714 std::lock_guard<std::recursive_mutex> guard(
715 process_sp->GetTarget().GetAPIMutex());
716 thread_sp =
717 process_sp->GetThreadList().FindThreadByIndexID(index_id, can_update);
718 sb_thread.SetThread(thread_sp);
719 }
720
721 return sb_thread;
722}
723
725 LLDB_INSTRUMENT_VA(event);
726
728
729 return ret_val;
730}
731
733 LLDB_INSTRUMENT_VA(event);
734
736
737 return ret_val;
738}
739
741 LLDB_INSTRUMENT_VA(event);
742
744}
745
746const char *
748 size_t idx) {
749 LLDB_INSTRUMENT_VA(event, idx);
750
752 event.get(), idx))
753 .GetCString();
754}
755
757 LLDB_INSTRUMENT_VA(event);
758
759 ProcessSP process_sp =
761 if (!process_sp) {
762 // StructuredData events also know the process they come from. Try that.
764 }
765
766 return SBProcess(process_sp);
767}
768
770 LLDB_INSTRUMENT_VA(event);
771
773}
774
777 LLDB_INSTRUMENT_VA(event);
778
779 return SBStructuredData(event.GetSP());
780}
781
783 LLDB_INSTRUMENT_VA(event);
784
786 nullptr;
787}
788
790 LLDB_INSTRUMENT_VA(event);
791
792 EventSP event_sp = event.GetSP();
793 EventData *event_data = event_sp ? event_sp->GetData() : nullptr;
794 return event_data && (event_data->GetFlavor() ==
796}
797
799 LLDB_INSTRUMENT_VA(this);
800
801 ProcessSP process_sp(GetSP());
802
803 SBBroadcaster broadcaster(process_sp.get(), false);
804
805 return broadcaster;
806}
807
810
812}
813
815 const void *buf, uint64_t size, const SBAddressRangeList &ranges,
816 uint32_t alignment, uint32_t max_matches, SBError &error) {
817 LLDB_INSTRUMENT_VA(this, buf, size, ranges, alignment, max_matches, error);
818
820
821 ProcessSP process_sp(GetSP());
822 if (!process_sp) {
823 error = Status::FromErrorString("SBProcess is invalid");
824 return matches;
825 }
826 Process::StopLocker stop_locker;
827 if (!stop_locker.TryLock(&process_sp->GetRunLock())) {
828 error = Status::FromErrorString("process is running");
829 return matches;
830 }
831 std::lock_guard<std::recursive_mutex> guard(
832 process_sp->GetTarget().GetAPIMutex());
833 matches.m_opaque_up->ref() = process_sp->FindRangesInMemory(
834 reinterpret_cast<const uint8_t *>(buf), size, ranges.ref().ref(),
835 alignment, max_matches, error.ref());
836 return matches;
837}
838
839lldb::addr_t SBProcess::FindInMemory(const void *buf, uint64_t size,
840 const SBAddressRange &range,
841 uint32_t alignment, SBError &error) {
842 LLDB_INSTRUMENT_VA(this, buf, size, range, alignment, error);
843
844 ProcessSP process_sp(GetSP());
845
846 if (!process_sp) {
847 error = Status::FromErrorString("SBProcess is invalid");
849 }
850
851 Process::StopLocker stop_locker;
852 if (!stop_locker.TryLock(&process_sp->GetRunLock())) {
853 error = Status::FromErrorString("process is running");
855 }
856
857 std::lock_guard<std::recursive_mutex> guard(
858 process_sp->GetTarget().GetAPIMutex());
859 return process_sp->FindInMemory(reinterpret_cast<const uint8_t *>(buf), size,
860 range.ref(), alignment, error.ref());
861}
862
863size_t SBProcess::ReadMemory(addr_t addr, void *dst, size_t dst_len,
864 SBError &sb_error) {
865 LLDB_INSTRUMENT_VA(this, addr, dst, dst_len, sb_error);
866
867 if (!dst) {
869 "no buffer provided to read %zu bytes into", dst_len);
870 return 0;
871 }
872
873 size_t bytes_read = 0;
874 ProcessSP process_sp(GetSP());
875
876
877 if (process_sp) {
878 Process::StopLocker stop_locker;
879 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
880 std::lock_guard<std::recursive_mutex> guard(
881 process_sp->GetTarget().GetAPIMutex());
882 bytes_read = process_sp->ReadMemory(addr, dst, dst_len, sb_error.ref());
883 } else {
884 sb_error = Status::FromErrorString("process is running");
885 }
886 } else {
887 sb_error = Status::FromErrorString("SBProcess is invalid");
888 }
889
890 return bytes_read;
891}
892
893size_t SBProcess::ReadCStringFromMemory(addr_t addr, void *buf, size_t size,
894 lldb::SBError &sb_error) {
895 LLDB_INSTRUMENT_VA(this, addr, buf, size, sb_error);
896
897 size_t bytes_read = 0;
898 ProcessSP process_sp(GetSP());
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_read = process_sp->ReadCStringFromMemory(addr, (char *)buf, size,
905 sb_error.ref());
906 } else {
907 sb_error = Status::FromErrorString("process is running");
908 }
909 } else {
910 sb_error = Status::FromErrorString("SBProcess is invalid");
911 }
912 return bytes_read;
913}
914
915uint64_t SBProcess::ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size,
916 lldb::SBError &sb_error) {
917 LLDB_INSTRUMENT_VA(this, addr, byte_size, sb_error);
918
919 uint64_t value = 0;
920 ProcessSP process_sp(GetSP());
921 if (process_sp) {
922 Process::StopLocker stop_locker;
923 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
924 std::lock_guard<std::recursive_mutex> guard(
925 process_sp->GetTarget().GetAPIMutex());
926 value = process_sp->ReadUnsignedIntegerFromMemory(addr, byte_size, 0,
927 sb_error.ref());
928 } else {
929 sb_error = Status::FromErrorString("process is running");
930 }
931 } else {
932 sb_error = Status::FromErrorString("SBProcess is invalid");
933 }
934 return value;
935}
936
938 lldb::SBError &sb_error) {
939 LLDB_INSTRUMENT_VA(this, addr, sb_error);
940
942 ProcessSP process_sp(GetSP());
943 if (process_sp) {
944 Process::StopLocker stop_locker;
945 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
946 std::lock_guard<std::recursive_mutex> guard(
947 process_sp->GetTarget().GetAPIMutex());
948 ptr = process_sp->ReadPointerFromMemory(addr, sb_error.ref());
949 } else {
950 sb_error = Status::FromErrorString("process is running");
951 }
952 } else {
953 sb_error = Status::FromErrorString("SBProcess is invalid");
954 }
955 return ptr;
956}
957
958size_t SBProcess::WriteMemory(addr_t addr, const void *src, size_t src_len,
959 SBError &sb_error) {
960 LLDB_INSTRUMENT_VA(this, addr, src, src_len, sb_error);
961
962 size_t bytes_written = 0;
963
964 ProcessSP process_sp(GetSP());
965
966 if (process_sp) {
967 Process::StopLocker stop_locker;
968 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
969 std::lock_guard<std::recursive_mutex> guard(
970 process_sp->GetTarget().GetAPIMutex());
971 bytes_written =
972 process_sp->WriteMemory(addr, src, src_len, sb_error.ref());
973 } else {
974 sb_error = Status::FromErrorString("process is running");
975 }
976 }
977
978 return bytes_written;
979}
980
982 LLDB_INSTRUMENT_VA(this, status);
983
984 ProcessSP process_sp(GetSP());
985 if (process_sp)
986 process_sp->GetStatus(status.ref());
987}
988
990 LLDB_INSTRUMENT_VA(this, description);
991
992 Stream &strm = description.ref();
993
994 ProcessSP process_sp(GetSP());
995 if (process_sp) {
996 char path[PATH_MAX];
997 GetTarget().GetExecutable().GetPath(path, sizeof(path));
998 Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
999 const char *exe_name = nullptr;
1000 if (exe_module)
1001 exe_name = exe_module->GetFileSpec().GetFilename().AsCString();
1002
1003 strm.Printf("SBProcess: pid = %" PRIu64 ", state = %s, threads = %d%s%s",
1004 process_sp->GetID(), lldb_private::StateAsCString(GetState()),
1005 GetNumThreads(), exe_name ? ", executable = " : "",
1006 exe_name ? exe_name : "");
1007 } else
1008 strm.PutCString("No value");
1009
1010 return true;
1011}
1012
1014 LLDB_INSTRUMENT_VA(this);
1015 SBStructuredData data;
1016 ProcessSP process_sp(GetSP());
1017 if (!process_sp)
1018 return data;
1019
1020 PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
1021
1022 if (!platform_sp)
1023 return data;
1024
1025 auto expected_data =
1026 platform_sp->FetchExtendedCrashInformation(*process_sp.get());
1027
1028 if (!expected_data)
1029 return data;
1030
1031 StructuredData::ObjectSP fetched_data = *expected_data;
1032 data.m_impl_up->SetObjectSP(fetched_data);
1033 return data;
1034}
1035
1036uint32_t
1038 LLDB_INSTRUMENT_VA(this, sb_error);
1039
1040 uint32_t num = 0;
1041 ProcessSP process_sp(GetSP());
1042 if (process_sp) {
1043 std::lock_guard<std::recursive_mutex> guard(
1044 process_sp->GetTarget().GetAPIMutex());
1045 std::optional<uint32_t> actual_num = process_sp->GetWatchpointSlotCount();
1046 if (actual_num) {
1047 num = *actual_num;
1048 } else {
1049 sb_error =
1050 Status::FromErrorString("Unable to determine number of watchpoints");
1051 }
1052 } else {
1053 sb_error = Status::FromErrorString("SBProcess is invalid");
1054 }
1055 return num;
1056}
1057
1058uint32_t SBProcess::LoadImage(lldb::SBFileSpec &sb_remote_image_spec,
1059 lldb::SBError &sb_error) {
1060 LLDB_INSTRUMENT_VA(this, sb_remote_image_spec, sb_error);
1061
1062 return LoadImage(SBFileSpec(), sb_remote_image_spec, sb_error);
1063}
1064
1065uint32_t SBProcess::LoadImage(const lldb::SBFileSpec &sb_local_image_spec,
1066 const lldb::SBFileSpec &sb_remote_image_spec,
1067 lldb::SBError &sb_error) {
1068 LLDB_INSTRUMENT_VA(this, sb_local_image_spec, sb_remote_image_spec, sb_error);
1069
1070 ProcessSP process_sp(GetSP());
1071 if (process_sp) {
1072 Process::StopLocker stop_locker;
1073 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1074 std::lock_guard<std::recursive_mutex> guard(
1075 process_sp->GetTarget().GetAPIMutex());
1076 PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
1077 return platform_sp->LoadImage(process_sp.get(), *sb_local_image_spec,
1078 *sb_remote_image_spec, sb_error.ref());
1079 } else {
1080 sb_error = Status::FromErrorString("process is running");
1081 }
1082 } else {
1083 sb_error = Status::FromErrorString("process is invalid");
1084 }
1086}
1087
1089 SBStringList &paths,
1090 lldb::SBFileSpec &loaded_path,
1092 LLDB_INSTRUMENT_VA(this, image_spec, paths, loaded_path, error);
1093
1094 ProcessSP process_sp(GetSP());
1095 if (process_sp) {
1096 Process::StopLocker stop_locker;
1097 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1098 std::lock_guard<std::recursive_mutex> guard(
1099 process_sp->GetTarget().GetAPIMutex());
1100 PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
1101 size_t num_paths = paths.GetSize();
1102 std::vector<std::string> paths_vec;
1103 paths_vec.reserve(num_paths);
1104 for (size_t i = 0; i < num_paths; i++)
1105 paths_vec.push_back(paths.GetStringAtIndex(i));
1106 FileSpec loaded_spec;
1107
1108 uint32_t token = platform_sp->LoadImageUsingPaths(
1109 process_sp.get(), *image_spec, paths_vec, error.ref(), &loaded_spec);
1110 if (token != LLDB_INVALID_IMAGE_TOKEN)
1111 loaded_path = loaded_spec;
1112 return token;
1113 } else {
1114 error = Status::FromErrorString("process is running");
1115 }
1116 } else {
1117 error = Status::FromErrorString("process is invalid");
1118 }
1119
1121}
1122
1124 LLDB_INSTRUMENT_VA(this, image_token);
1125
1126 lldb::SBError sb_error;
1127 ProcessSP process_sp(GetSP());
1128 if (process_sp) {
1129 Process::StopLocker stop_locker;
1130 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1131 std::lock_guard<std::recursive_mutex> guard(
1132 process_sp->GetTarget().GetAPIMutex());
1133 PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
1134 sb_error.SetError(
1135 platform_sp->UnloadImage(process_sp.get(), image_token));
1136 } else {
1137 sb_error = Status::FromErrorString("process is running");
1138 }
1139 } else
1140 sb_error = Status::FromErrorString("invalid process");
1141 return sb_error;
1142}
1143
1145 LLDB_INSTRUMENT_VA(this, event_data);
1146
1147 lldb::SBError sb_error;
1148 ProcessSP process_sp(GetSP());
1149 if (process_sp) {
1150 Process::StopLocker stop_locker;
1151 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1152 std::lock_guard<std::recursive_mutex> guard(
1153 process_sp->GetTarget().GetAPIMutex());
1154 sb_error.SetError(process_sp->SendEventData(event_data));
1155 } else {
1156 sb_error = Status::FromErrorString("process is running");
1157 }
1158 } else
1159 sb_error = Status::FromErrorString("invalid process");
1160 return sb_error;
1161}
1162
1164 LLDB_INSTRUMENT_VA(this);
1165
1166 ProcessSP process_sp(GetSP());
1167 if (process_sp && process_sp->GetSystemRuntime()) {
1168 SystemRuntime *runtime = process_sp->GetSystemRuntime();
1169 return runtime->GetExtendedBacktraceTypes().size();
1170 }
1171 return 0;
1172}
1173
1175 LLDB_INSTRUMENT_VA(this, idx);
1176
1177 ProcessSP process_sp(GetSP());
1178 if (process_sp && process_sp->GetSystemRuntime()) {
1179 SystemRuntime *runtime = process_sp->GetSystemRuntime();
1180 const std::vector<ConstString> &names =
1181 runtime->GetExtendedBacktraceTypes();
1182 if (idx < names.size()) {
1183 return names[idx].AsCString();
1184 }
1185 }
1186 return nullptr;
1187}
1188
1190 LLDB_INSTRUMENT_VA(this, addr);
1191
1192 ProcessSP process_sp(GetSP());
1193 SBThreadCollection threads;
1194 if (process_sp) {
1195 threads = SBThreadCollection(process_sp->GetHistoryThreads(addr));
1196 }
1197 return threads;
1198}
1199
1202 LLDB_INSTRUMENT_VA(this, type);
1203
1204 ProcessSP process_sp(GetSP());
1205 if (!process_sp)
1206 return false;
1207
1208 std::lock_guard<std::recursive_mutex> guard(
1209 process_sp->GetTarget().GetAPIMutex());
1210
1211 InstrumentationRuntimeSP runtime_sp =
1212 process_sp->GetInstrumentationRuntime(type);
1213
1214 if (!runtime_sp.get())
1215 return false;
1216
1217 return runtime_sp->IsActive();
1218}
1219
1220lldb::SBError SBProcess::SaveCore(const char *file_name) {
1221 LLDB_INSTRUMENT_VA(this, file_name);
1222 SBSaveCoreOptions options;
1223 options.SetOutputFile(SBFileSpec(file_name));
1225 return SaveCore(options);
1226}
1227
1229 const char *flavor,
1230 SaveCoreStyle core_style) {
1231 LLDB_INSTRUMENT_VA(this, file_name, flavor, core_style);
1232 SBSaveCoreOptions options;
1233 options.SetOutputFile(SBFileSpec(file_name));
1234 options.SetStyle(core_style);
1235 SBError error = options.SetPluginName(flavor);
1236 if (error.Fail())
1237 return error;
1238 return SaveCore(options);
1239}
1240
1242
1243 LLDB_INSTRUMENT_VA(this, options);
1244
1246 ProcessSP process_sp(GetSP());
1247 if (!process_sp) {
1248 error = Status::FromErrorString("SBProcess is invalid");
1249 return error;
1250 }
1251
1252 std::lock_guard<std::recursive_mutex> guard(
1253 process_sp->GetTarget().GetAPIMutex());
1254
1255 if (process_sp->GetState() != eStateStopped) {
1256 error = Status::FromErrorString("the process is not stopped");
1257 return error;
1258 }
1259
1260 error.ref() = PluginManager::SaveCore(process_sp, options.ref());
1261
1262 return error;
1263}
1264
1267 SBMemoryRegionInfo &sb_region_info) {
1268 LLDB_INSTRUMENT_VA(this, load_addr, sb_region_info);
1269
1270 lldb::SBError sb_error;
1271 ProcessSP process_sp(GetSP());
1272 if (process_sp) {
1273 Process::StopLocker stop_locker;
1274 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1275 std::lock_guard<std::recursive_mutex> guard(
1276 process_sp->GetTarget().GetAPIMutex());
1277
1278 sb_error.ref() =
1279 process_sp->GetMemoryRegionInfo(load_addr, sb_region_info.ref());
1280 } else {
1281 sb_error = Status::FromErrorString("process is running");
1282 }
1283 } else {
1284 sb_error = Status::FromErrorString("SBProcess is invalid");
1285 }
1286 return sb_error;
1287}
1288
1290 LLDB_INSTRUMENT_VA(this);
1291
1292 lldb::SBMemoryRegionInfoList sb_region_list;
1293
1294 ProcessSP process_sp(GetSP());
1295 Process::StopLocker stop_locker;
1296 if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock())) {
1297 std::lock_guard<std::recursive_mutex> guard(
1298 process_sp->GetTarget().GetAPIMutex());
1299
1300 process_sp->GetMemoryRegions(sb_region_list.ref());
1301 }
1302
1303 return sb_region_list;
1304}
1305
1307 LLDB_INSTRUMENT_VA(this);
1308
1309 lldb::SBProcessInfo sb_proc_info;
1310 ProcessSP process_sp(GetSP());
1311 ProcessInstanceInfo proc_info;
1312 if (process_sp && process_sp->GetProcessInfo(proc_info)) {
1313 sb_proc_info.SetProcessInfo(proc_info);
1314 }
1315 return sb_proc_info;
1316}
1317
1319 LLDB_INSTRUMENT_VA(this);
1320
1321 ProcessSP process_sp(GetSP());
1322 FileSpec core_file;
1323 if (process_sp) {
1324 core_file = process_sp->GetCoreFile();
1325 }
1326 return SBFileSpec(core_file);
1327}
1328
1330 AddressMaskRange addr_range) {
1331 LLDB_INSTRUMENT_VA(this, type, addr_range);
1332
1333 if (ProcessSP process_sp = GetSP()) {
1334 switch (type) {
1336 if (addr_range == eAddressMaskRangeHigh)
1337 return process_sp->GetHighmemCodeAddressMask();
1338 else
1339 return process_sp->GetCodeAddressMask();
1341 if (addr_range == eAddressMaskRangeHigh)
1342 return process_sp->GetHighmemDataAddressMask();
1343 else
1344 return process_sp->GetDataAddressMask();
1346 if (addr_range == eAddressMaskRangeHigh)
1347 return process_sp->GetHighmemDataAddressMask();
1348 else
1349 return process_sp->GetDataAddressMask();
1350 }
1351 }
1353}
1354
1356 AddressMaskRange addr_range) {
1357 LLDB_INSTRUMENT_VA(this, type, mask, addr_range);
1358
1359 if (ProcessSP process_sp = GetSP()) {
1360 switch (type) {
1362 if (addr_range == eAddressMaskRangeAll) {
1363 process_sp->SetCodeAddressMask(mask);
1364 process_sp->SetHighmemCodeAddressMask(mask);
1365 } else if (addr_range == eAddressMaskRangeHigh) {
1366 process_sp->SetHighmemCodeAddressMask(mask);
1367 } else {
1368 process_sp->SetCodeAddressMask(mask);
1369 }
1370 break;
1372 if (addr_range == eAddressMaskRangeAll) {
1373 process_sp->SetDataAddressMask(mask);
1374 process_sp->SetHighmemDataAddressMask(mask);
1375 } else if (addr_range == eAddressMaskRangeHigh) {
1376 process_sp->SetHighmemDataAddressMask(mask);
1377 } else {
1378 process_sp->SetDataAddressMask(mask);
1379 }
1380 break;
1382 if (addr_range == eAddressMaskRangeAll) {
1383 process_sp->SetCodeAddressMask(mask);
1384 process_sp->SetDataAddressMask(mask);
1385 process_sp->SetHighmemCodeAddressMask(mask);
1386 process_sp->SetHighmemDataAddressMask(mask);
1387 } else if (addr_range == eAddressMaskRangeHigh) {
1388 process_sp->SetHighmemCodeAddressMask(mask);
1389 process_sp->SetHighmemDataAddressMask(mask);
1390 } else {
1391 process_sp->SetCodeAddressMask(mask);
1392 process_sp->SetDataAddressMask(mask);
1393 }
1394 break;
1395 }
1396 }
1397}
1398
1400 AddressMaskRange addr_range) {
1401 LLDB_INSTRUMENT_VA(this, type, num_bits, addr_range);
1402
1404 addr_range);
1405}
1406
1408 LLDB_INSTRUMENT_VA(this, addr, type);
1409
1410 if (ProcessSP process_sp = GetSP()) {
1411 if (type == eAddressMaskTypeAny)
1412 return process_sp->FixAnyAddress(addr);
1413 else if (type == eAddressMaskTypeData)
1414 return process_sp->FixDataAddress(addr);
1415 else if (type == eAddressMaskTypeCode)
1416 return process_sp->FixCodeAddress(addr);
1417 }
1418 return addr;
1419}
1420
1421lldb::addr_t SBProcess::AllocateMemory(size_t size, uint32_t permissions,
1422 lldb::SBError &sb_error) {
1423 LLDB_INSTRUMENT_VA(this, size, permissions, sb_error);
1424
1426 ProcessSP process_sp(GetSP());
1427 if (process_sp) {
1428 Process::StopLocker stop_locker;
1429 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1430 std::lock_guard<std::recursive_mutex> guard(
1431 process_sp->GetTarget().GetAPIMutex());
1432 addr = process_sp->AllocateMemory(size, permissions, sb_error.ref());
1433 } else {
1434 sb_error = Status::FromErrorString("process is running");
1435 }
1436 } else {
1437 sb_error = Status::FromErrorString("SBProcess is invalid");
1438 }
1439 return addr;
1440}
1441
1443 LLDB_INSTRUMENT_VA(this, ptr);
1444
1445 lldb::SBError sb_error;
1446 ProcessSP process_sp(GetSP());
1447 if (process_sp) {
1448 Process::StopLocker stop_locker;
1449 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1450 std::lock_guard<std::recursive_mutex> guard(
1451 process_sp->GetTarget().GetAPIMutex());
1452 Status error = process_sp->DeallocateMemory(ptr);
1453 sb_error.SetError(std::move(error));
1454 } else {
1455 sb_error = Status::FromErrorString("process is running");
1456 }
1457 } else {
1458 sb_error = Status::FromErrorString("SBProcess is invalid");
1459 }
1460 return sb_error;
1461}
1462
1464 LLDB_INSTRUMENT_VA(this);
1465 ProcessSP process_sp(GetSP());
1466 return lldb::SBScriptObject((process_sp) ? process_sp->GetImplementation()
1467 : nullptr,
1469}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT()
#define LLDB_INSTRUMENT_VA(...)
std::unique_ptr< lldb_private::AddressRangeListImpl > m_opaque_up
lldb_private::AddressRangeListImpl & ref() const
lldb_private::AddressRange & ref() const
void AppendMessage(const char *message)
static const char * StateAsCString(lldb::StateType state)
Definition: SBDebugger.cpp:749
void SetError(uint32_t err, lldb::ErrorType type)
Definition: SBError.cpp:110
lldb_private::Status & ref()
Definition: SBError.cpp:177
lldb_private::Event * get() const
Definition: SBEvent.cpp:134
void reset(lldb::EventSP &event_sp)
Definition: SBEvent.cpp:145
lldb::EventSP & GetSP() const
Definition: SBEvent.cpp:132
uint32_t GetPath(char *dst_path, size_t dst_len) const
Definition: SBFileSpec.cpp:140
FileSP m_opaque_sp
Definition: SBFile.h:51
lldb_private::MemoryRegionInfos & ref()
lldb_private::MemoryRegionInfo & ref()
void SetProcessInfo(const lldb_private::ProcessInstanceInfo &proc_info_ref)
const lldb::SBProcess & operator=(const lldb::SBProcess &rhs)
Definition: SBProcess.cpp:69
static size_t GetNumRestartedReasonsFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:740
lldb::SBError SendEventData(const char *data)
Definition: SBProcess.cpp:1144
lldb::SBBroadcaster GetBroadcaster() const
Definition: SBProcess.cpp:798
lldb::SBError Detach()
Definition: SBProcess.cpp:631
lldb::SBThread GetThreadAtIndex(size_t index)
Definition: SBProcess.cpp:388
static const char * GetBroadcasterClassName()
Definition: SBProcess.cpp:80
void AppendEventStateReport(const lldb::SBEvent &event, lldb::SBCommandReturnObject &result)
Definition: SBProcess.cpp:332
lldb::SBError Continue()
Definition: SBProcess.cpp:566
uint32_t GetNumThreads()
Definition: SBProcess.cpp:188
uint32_t GetNumExtendedBacktraceTypes()
Return the number of different thread-origin extended backtraces this process can support.
Definition: SBProcess.cpp:1163
size_t PutSTDIN(const char *src, size_t src_len)
Definition: SBProcess.cpp:252
lldb::SBQueue GetQueueAtIndex(size_t index)
Definition: SBProcess.cpp:423
void ReportEventState(const lldb::SBEvent &event, FILE *out) const
Definition: SBProcess.cpp:310
lldb::SBFileSpec GetCoreFile()
Get the file specification for the core file that is currently being used for the process.
Definition: SBProcess.cpp:1318
const char * GetExitDescription()
Definition: SBProcess.cpp:511
lldb::SBThread GetThreadByIndexID(uint32_t index_id)
Definition: SBProcess.cpp:705
static const char * GetBroadcasterClass()
Definition: SBProcess.cpp:808
static lldb::SBStructuredData GetStructuredDataFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:776
lldb::ProcessSP GetSP() const
Definition: SBProcess.cpp:106
lldb::addr_t FindInMemory(const void *buf, uint64_t size, const SBAddressRange &range, uint32_t alignment, SBError &error)
Definition: SBProcess.cpp:839
lldb::pid_t GetProcessID()
Gets the process ID.
Definition: SBProcess.cpp:523
lldb::addr_t AllocateMemory(size_t size, uint32_t permissions, lldb::SBError &error)
Allocate memory within the process.
Definition: SBProcess.cpp:1421
static bool EventIsStructuredDataEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:789
lldb::SBError UnloadImage(uint32_t image_token)
Definition: SBProcess.cpp:1123
lldb::SBProcessInfo GetProcessInfo()
Return information about the process.
Definition: SBProcess.cpp:1306
uint32_t GetUniqueID()
Gets the unique ID associated with this process object.
Definition: SBProcess.cpp:534
bool GetDescription(lldb::SBStream &description)
Definition: SBProcess.cpp:989
size_t GetAsyncProfileData(char *dst, size_t dst_len) const
Definition: SBProcess.cpp:291
lldb::addr_t FixAddress(lldb::addr_t addr, lldb::AddressMaskType type=lldb::eAddressMaskTypeAny)
Clear the non-address bits of an addr value and return a virtual address in memory.
Definition: SBProcess.cpp:1407
uint32_t GetNumQueues()
Definition: SBProcess.cpp:406
lldb::StateType GetState()
Definition: SBProcess.cpp:483
lldb::SBThread CreateOSPluginThread(lldb::tid_t tid, lldb::addr_t context)
Definition: SBProcess.cpp:221
lldb::SBError Destroy()
Definition: SBProcess.cpp:586
lldb::SBScriptObject GetScriptedImplementation()
Definition: SBProcess.cpp:1463
void GetStatus(SBStream &status)
Definition: SBProcess.cpp:981
lldb::ByteOrder GetByteOrder() const
Definition: SBProcess.cpp:544
size_t ReadCStringFromMemory(addr_t addr, void *char_buf, size_t size, lldb::SBError &error)
Definition: SBProcess.cpp:893
lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError &error)
Definition: SBProcess.cpp:937
lldb::SBError DeallocateMemory(lldb::addr_t ptr)
Deallocate memory in the process.
Definition: SBProcess.cpp:1442
static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:724
lldb::SBThread GetSelectedThread() const
Definition: SBProcess.cpp:205
bool SetSelectedThreadByIndexID(uint32_t index_id)
Definition: SBProcess.cpp:374
size_t ReadMemory(addr_t addr, void *buf, size_t size, lldb::SBError &error)
Definition: SBProcess.cpp:863
const char * GetExtendedBacktraceTypeAtIndex(uint32_t idx)
Return the name of one of the thread-origin extended backtrace methods.
Definition: SBProcess.cpp:1174
lldb::SBThread GetThreadByID(lldb::tid_t sb_thread_id)
Definition: SBProcess.cpp:687
bool RemoteAttachToProcessWithID(lldb::pid_t pid, lldb::SBError &error)
Remote connection related functions.
Definition: SBProcess.cpp:165
lldb::SBTarget GetTarget() const
Definition: SBProcess.cpp:238
lldb::SBAddressRangeList FindRangesInMemory(const void *buf, uint64_t size, const SBAddressRangeList &ranges, uint32_t alignment, uint32_t max_matches, SBError &error)
Definition: SBProcess.cpp:814
const char * GetPluginName()
Definition: SBProcess.cpp:86
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
void SetAddressMask(lldb::AddressMaskType type, lldb::addr_t mask, lldb::AddressMaskRange addr_range=lldb::eAddressMaskRangeLow)
Set the current address mask that can be applied to addresses before reading from memory.
Definition: SBProcess.cpp:1355
size_t GetSTDOUT(char *dst, size_t dst_len) const
Definition: SBProcess.cpp:265
lldb::SBEvent GetStopEventForStopID(uint32_t stop_id)
Gets the stop event corresponding to stop ID.
Definition: SBProcess.cpp:457
lldb::SBError Signal(int signal)
Definition: SBProcess.cpp:654
static bool GetInterruptedFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:769
lldb::SBError Stop()
Definition: SBProcess.cpp:601
lldb::addr_t GetAddressMask(lldb::AddressMaskType type, lldb::AddressMaskRange addr_range=lldb::eAddressMaskRangeLow)
Get the current address mask that will be applied to addresses before reading from memory.
Definition: SBProcess.cpp:1329
lldb::ProcessWP m_opaque_wp
Definition: SBProcess.h:608
uint32_t GetNumSupportedHardwareWatchpoints(lldb::SBError &error) const
Definition: SBProcess.cpp:1037
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:1088
uint32_t LoadImage(lldb::SBFileSpec &remote_image_spec, lldb::SBError &error)
Load a shared library into this process.
Definition: SBProcess.cpp:1058
void SetAddressableBits(AddressMaskType type, uint32_t num_bits, AddressMaskRange addr_range=lldb::eAddressMaskRangeLow)
Set the number of bits used for addressing in this Process.
Definition: SBProcess.cpp:1399
static const char * GetRestartedReasonAtIndexFromEvent(const lldb::SBEvent &event, size_t idx)
Definition: SBProcess.cpp:747
lldb::SBUnixSignals GetUnixSignals()
Definition: SBProcess.cpp:669
lldb::SBError Kill()
Definition: SBProcess.cpp:616
lldb::SBThreadCollection GetHistoryThreads(addr_t addr)
Definition: SBProcess.cpp:1189
bool IsInstrumentationRuntimePresent(InstrumentationRuntimeType type)
Definition: SBProcess.cpp:1200
bool SetSelectedThread(const lldb::SBThread &thread)
Definition: SBProcess.cpp:347
bool SetSelectedThreadByID(lldb::tid_t tid)
Definition: SBProcess.cpp:360
void SendAsyncInterrupt()
Definition: SBProcess.cpp:678
static bool GetRestartedFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:732
static bool EventIsProcessEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:782
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:1266
void SetSP(const lldb::ProcessSP &process_sp)
Definition: SBProcess.cpp:108
size_t WriteMemory(addr_t addr, const void *buf, size_t size, lldb::SBError &error)
Definition: SBProcess.cpp:958
lldb::SBError SaveCore(const char *file_name, const char *flavor, SaveCoreStyle core_style)
Save the state of the process in a core file.
Definition: SBProcess.cpp:1228
lldb::SBMemoryRegionInfoList GetMemoryRegions()
Return the list of memory regions within the process.
Definition: SBProcess.cpp:1289
uint32_t GetAddressByteSize() const
Definition: SBProcess.cpp:555
SBStructuredData GetExtendedCrashInformation()
Definition: SBProcess.cpp:1013
uint32_t GetStopID(bool include_expression_stops=false)
Definition: SBProcess.cpp:442
uint64_t ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size, lldb::SBError &error)
Definition: SBProcess.cpp:915
bool IsValid() const
Definition: SBProcess.cpp:116
void ForceScriptedState(StateType new_state)
If the process is a scripted process, changes its state to the new state.
Definition: SBProcess.cpp:473
static lldb::SBProcess GetProcessFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:756
size_t GetSTDERR(char *dst, size_t dst_len) const
Definition: SBProcess.cpp:278
void SetQueue(const lldb::QueueSP &queue_sp)
Definition: SBQueue.cpp:254
void SetStyle(lldb::SaveCoreStyle style)
Set the Core dump style.
void SetOutputFile(SBFileSpec output_file)
lldb_private::SaveCoreOptions & ref() const
SBError SetPluginName(const char *plugin)
Set the plugin name.
lldb_private::Stream & ref()
Definition: SBStream.cpp:177
uint32_t GetSize() const
const char * GetStringAtIndex(size_t idx)
StructuredDataImplUP m_impl_up
void SetSP(const lldb::TargetSP &target_sp)
Definition: SBTarget.cpp:595
lldb::SBFileSpec GetExecutable()
Definition: SBTarget.cpp:567
lldb::tid_t GetThreadID() const
Definition: SBThread.cpp:382
void SetThread(const lldb::ThreadSP &lldb_object_sp)
Definition: SBThread.cpp:378
static lldb::addr_t AddressableBitToMask(uint32_t addressable_bits)
void AppendArguments(const Args &rhs)
Definition: Args.cpp:307
A uniqued constant string class.
Definition: ConstString.h:40
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:188
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
static llvm::StringRef GetFlavorString()
Definition: Event.cpp:273
static lldb::ProcessSP GetProcessFromEvent(const Event *event_ptr)
Definition: Event.cpp:247
virtual llvm::StringRef GetFlavor() const =0
A file utility class.
Definition: FileSpec.h:56
const ConstString & GetFilename() const
Filename string const get accessor.
Definition: FileSpec.h:240
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:89
const FileSpec & GetPlatformFileSpec() const
Get accessor for the module platform file specification.
Definition: Module.h:467
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition: Module.h:453
static Status SaveCore(const lldb::ProcessSP &process_sp, lldb_private::SaveCoreOptions &core_options)
void SetExecutableFile(const FileSpec &exe_file, bool add_exe_file_as_first_arg)
Definition: ProcessInfo.cpp:65
void SetProcessID(lldb::pid_t pid)
Definition: ProcessInfo.h:70
Environment & GetEnvironment()
Definition: ProcessInfo.h:88
static bool GetRestartedFromEvent(const Event *event_ptr)
Definition: Process.cpp:4407
static lldb::ProcessSP GetProcessFromEvent(const Event *event_ptr)
Definition: Process.cpp:4391
static bool GetInterruptedFromEvent(const Event *event_ptr)
Definition: Process.cpp:4452
const char * GetRestartedReasonAtIndex(size_t idx)
Definition: Process.h:431
static lldb::StateType GetStateFromEvent(const Event *event_ptr)
Definition: Process.cpp:4399
static const Process::ProcessEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition: Process.cpp:4380
static llvm::StringRef GetStaticBroadcasterClass()
Definition: Process.cpp:413
An error handling class.
Definition: Status.h:115
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition: Status.cpp:106
static Status FromErrorString(const char *str)
Definition: Status.h:138
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:65
std::shared_ptr< Object > ObjectSP
A plug-in interface definition class for system runtimes.
Definition: SystemRuntime.h:43
virtual const std::vector< ConstString > & GetExtendedBacktraceTypes()
Return a list of thread origin extended backtraces that may be available.
#define LLDB_INVALID_ADDRESS_MASK
Address Mask Bits not used for addressing are set to 1 in the mask; all mask bits set is an invalid v...
Definition: lldb-defines.h:133
#define LLDB_INVALID_IMAGE_TOKEN
Definition: lldb-defines.h:85
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:82
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:89
A class that represents a running process on the host machine.
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
Definition: State.cpp:14
Definition: SBAddress.h:15
@ eScriptLanguageDefault
std::shared_ptr< lldb_private::Queue > QueueSP
Definition: lldb-forward.h:398
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:450
AddressMaskRange
Used in the SBProcess AddressMask/FixAddress methods.
@ eAddressMaskRangeAll
@ eAddressMaskRangeHigh
std::shared_ptr< lldb_private::Platform > PlatformSP
Definition: lldb-forward.h:388
StateType
Process and Thread States.
@ eStateConnected
Process is connected to remote debug services, but not launched or attached to anything yet.
@ eStateStopped
Process or thread is stopped and can be examined.
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:389
InstrumentationRuntimeType
std::shared_ptr< lldb_private::Event > EventSP
Definition: lldb-forward.h:345
uint64_t pid_t
Definition: lldb-types.h:83
ByteOrder
Byte ordering definitions.
@ eByteOrderInvalid
uint64_t addr_t
Definition: lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:448
AddressMaskType
Used in the SBProcess AddressMask/FixAddress methods.
@ eAddressMaskTypeData
@ eAddressMaskTypeAll
@ eAddressMaskTypeAny
@ eAddressMaskTypeCode
std::shared_ptr< lldb_private::File > FileSP
Definition: lldb-forward.h:353
std::shared_ptr< lldb_private::InstrumentationRuntime > InstrumentationRuntimeSP
Definition: lldb-forward.h:360
uint64_t tid_t
Definition: lldb-types.h:84
#define PATH_MAX