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