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