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);
471
472 StateType ret_val = eStateInvalid;
473 ProcessSP process_sp(GetSP());
474 if (process_sp) {
475 std::lock_guard<std::recursive_mutex> guard(
476 process_sp->GetTarget().GetAPIMutex());
477 ret_val = process_sp->GetState();
478 }
479
480 return ret_val;
481}
482
484 LLDB_INSTRUMENT_VA(this);
485
486 int exit_status = 0;
487 ProcessSP process_sp(GetSP());
488 if (process_sp) {
489 std::lock_guard<std::recursive_mutex> guard(
490 process_sp->GetTarget().GetAPIMutex());
491 exit_status = process_sp->GetExitStatus();
492 }
493
494 return exit_status;
495}
496
498 LLDB_INSTRUMENT_VA(this);
499
500 const char *exit_desc = nullptr;
501 ProcessSP process_sp(GetSP());
502 if (process_sp) {
503 std::lock_guard<std::recursive_mutex> guard(
504 process_sp->GetTarget().GetAPIMutex());
505 exit_desc = process_sp->GetExitDescription();
506 }
507 return exit_desc;
508}
509
511 LLDB_INSTRUMENT_VA(this);
512
514 ProcessSP process_sp(GetSP());
515 if (process_sp)
516 ret_val = process_sp->GetID();
517
518 return ret_val;
519}
520
522 LLDB_INSTRUMENT_VA(this);
523
524 uint32_t ret_val = 0;
525 ProcessSP process_sp(GetSP());
526 if (process_sp)
527 ret_val = process_sp->GetUniqueID();
528 return ret_val;
529}
530
532 LLDB_INSTRUMENT_VA(this);
533
534 ByteOrder byteOrder = eByteOrderInvalid;
535 ProcessSP process_sp(GetSP());
536 if (process_sp)
537 byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder();
538
539
540 return byteOrder;
541}
542
544 LLDB_INSTRUMENT_VA(this);
545
546 uint32_t size = 0;
547 ProcessSP process_sp(GetSP());
548 if (process_sp)
549 size = process_sp->GetTarget().GetArchitecture().GetAddressByteSize();
550
551
552 return size;
553}
554
556 LLDB_INSTRUMENT_VA(this);
557
558 SBError sb_error;
559 ProcessSP process_sp(GetSP());
560
561 if (process_sp) {
562 std::lock_guard<std::recursive_mutex> guard(
563 process_sp->GetTarget().GetAPIMutex());
564
565 if (process_sp->GetTarget().GetDebugger().GetAsyncExecution())
566 sb_error.ref() = process_sp->Resume();
567 else
568 sb_error.ref() = process_sp->ResumeSynchronous(nullptr);
569 } else
570 sb_error.SetErrorString("SBProcess is invalid");
571
572 return sb_error;
573}
574
576 LLDB_INSTRUMENT_VA(this);
577
578 SBError sb_error;
579 ProcessSP process_sp(GetSP());
580 if (process_sp) {
581 std::lock_guard<std::recursive_mutex> guard(
582 process_sp->GetTarget().GetAPIMutex());
583 sb_error.SetError(process_sp->Destroy(false));
584 } else
585 sb_error.SetErrorString("SBProcess is invalid");
586
587 return sb_error;
588}
589
591 LLDB_INSTRUMENT_VA(this);
592
593 SBError sb_error;
594 ProcessSP process_sp(GetSP());
595 if (process_sp) {
596 std::lock_guard<std::recursive_mutex> guard(
597 process_sp->GetTarget().GetAPIMutex());
598 sb_error.SetError(process_sp->Halt());
599 } else
600 sb_error.SetErrorString("SBProcess is invalid");
601
602 return sb_error;
603}
604
606 LLDB_INSTRUMENT_VA(this);
607
608 SBError sb_error;
609 ProcessSP process_sp(GetSP());
610 if (process_sp) {
611 std::lock_guard<std::recursive_mutex> guard(
612 process_sp->GetTarget().GetAPIMutex());
613 sb_error.SetError(process_sp->Destroy(true));
614 } else
615 sb_error.SetErrorString("SBProcess is invalid");
616
617 return sb_error;
618}
619
621 LLDB_INSTRUMENT_VA(this);
622
623 // FIXME: This should come from a process default.
624 bool keep_stopped = false;
625 return Detach(keep_stopped);
626}
627
628SBError SBProcess::Detach(bool keep_stopped) {
629 LLDB_INSTRUMENT_VA(this, keep_stopped);
630
631 SBError sb_error;
632 ProcessSP process_sp(GetSP());
633 if (process_sp) {
634 std::lock_guard<std::recursive_mutex> guard(
635 process_sp->GetTarget().GetAPIMutex());
636 sb_error.SetError(process_sp->Detach(keep_stopped));
637 } else
638 sb_error.SetErrorString("SBProcess is invalid");
639
640 return sb_error;
641}
642
644 LLDB_INSTRUMENT_VA(this, signo);
645
646 SBError sb_error;
647 ProcessSP process_sp(GetSP());
648 if (process_sp) {
649 std::lock_guard<std::recursive_mutex> guard(
650 process_sp->GetTarget().GetAPIMutex());
651 sb_error.SetError(process_sp->Signal(signo));
652 } else
653 sb_error.SetErrorString("SBProcess is invalid");
654
655 return sb_error;
656}
657
659 LLDB_INSTRUMENT_VA(this);
660
661 if (auto process_sp = GetSP())
662 return SBUnixSignals{process_sp};
663
664 return SBUnixSignals{};
665}
666
668 LLDB_INSTRUMENT_VA(this);
669
670 ProcessSP process_sp(GetSP());
671 if (process_sp) {
672 process_sp->SendAsyncInterrupt();
673 }
674}
675
677 LLDB_INSTRUMENT_VA(this, tid);
678
679 SBThread sb_thread;
680 ThreadSP thread_sp;
681 ProcessSP process_sp(GetSP());
682 if (process_sp) {
683 Process::StopLocker stop_locker;
684 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
685 std::lock_guard<std::recursive_mutex> guard(
686 process_sp->GetTarget().GetAPIMutex());
687 thread_sp = process_sp->GetThreadList().FindThreadByID(tid, can_update);
688 sb_thread.SetThread(thread_sp);
689 }
690
691 return sb_thread;
692}
693
695 LLDB_INSTRUMENT_VA(this, index_id);
696
697 SBThread sb_thread;
698 ThreadSP thread_sp;
699 ProcessSP process_sp(GetSP());
700 if (process_sp) {
701 Process::StopLocker stop_locker;
702 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
703 std::lock_guard<std::recursive_mutex> guard(
704 process_sp->GetTarget().GetAPIMutex());
705 thread_sp =
706 process_sp->GetThreadList().FindThreadByIndexID(index_id, can_update);
707 sb_thread.SetThread(thread_sp);
708 }
709
710 return sb_thread;
711}
712
714 LLDB_INSTRUMENT_VA(event);
715
717
718 return ret_val;
719}
720
722 LLDB_INSTRUMENT_VA(event);
723
725
726 return ret_val;
727}
728
730 LLDB_INSTRUMENT_VA(event);
731
733}
734
735const char *
737 size_t idx) {
738 LLDB_INSTRUMENT_VA(event, idx);
739
741}
742
744 LLDB_INSTRUMENT_VA(event);
745
746 ProcessSP process_sp =
748 if (!process_sp) {
749 // StructuredData events also know the process they come from. Try that.
751 }
752
753 return SBProcess(process_sp);
754}
755
757 LLDB_INSTRUMENT_VA(event);
758
760}
761
764 LLDB_INSTRUMENT_VA(event);
765
766 return SBStructuredData(event.GetSP());
767}
768
770 LLDB_INSTRUMENT_VA(event);
771
774}
775
777 LLDB_INSTRUMENT_VA(event);
778
779 EventSP event_sp = event.GetSP();
780 EventData *event_data = event_sp ? event_sp->GetData() : nullptr;
781 return event_data && (event_data->GetFlavor() ==
783}
784
786 LLDB_INSTRUMENT_VA(this);
787
788 ProcessSP process_sp(GetSP());
789
790 SBBroadcaster broadcaster(process_sp.get(), false);
791
792 return broadcaster;
793}
794
797
799}
800
801size_t SBProcess::ReadMemory(addr_t addr, void *dst, size_t dst_len,
802 SBError &sb_error) {
803 LLDB_INSTRUMENT_VA(this, addr, dst, dst_len, sb_error);
804
805 size_t bytes_read = 0;
806
807 ProcessSP process_sp(GetSP());
808
809
810 if (process_sp) {
811 Process::StopLocker stop_locker;
812 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
813 std::lock_guard<std::recursive_mutex> guard(
814 process_sp->GetTarget().GetAPIMutex());
815 bytes_read = process_sp->ReadMemory(addr, dst, dst_len, sb_error.ref());
816 } else {
817 sb_error.SetErrorString("process is running");
818 }
819 } else {
820 sb_error.SetErrorString("SBProcess is invalid");
821 }
822
823 return bytes_read;
824}
825
826size_t SBProcess::ReadCStringFromMemory(addr_t addr, void *buf, size_t size,
827 lldb::SBError &sb_error) {
828 LLDB_INSTRUMENT_VA(this, addr, buf, size, sb_error);
829
830 size_t bytes_read = 0;
831 ProcessSP process_sp(GetSP());
832 if (process_sp) {
833 Process::StopLocker stop_locker;
834 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
835 std::lock_guard<std::recursive_mutex> guard(
836 process_sp->GetTarget().GetAPIMutex());
837 bytes_read = process_sp->ReadCStringFromMemory(addr, (char *)buf, size,
838 sb_error.ref());
839 } else {
840 sb_error.SetErrorString("process is running");
841 }
842 } else {
843 sb_error.SetErrorString("SBProcess is invalid");
844 }
845 return bytes_read;
846}
847
849 lldb::SBError &sb_error) {
850 LLDB_INSTRUMENT_VA(this, addr, byte_size, sb_error);
851
852 uint64_t value = 0;
853 ProcessSP process_sp(GetSP());
854 if (process_sp) {
855 Process::StopLocker stop_locker;
856 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
857 std::lock_guard<std::recursive_mutex> guard(
858 process_sp->GetTarget().GetAPIMutex());
859 value = process_sp->ReadUnsignedIntegerFromMemory(addr, byte_size, 0,
860 sb_error.ref());
861 } else {
862 sb_error.SetErrorString("process is running");
863 }
864 } else {
865 sb_error.SetErrorString("SBProcess is invalid");
866 }
867 return value;
868}
869
871 lldb::SBError &sb_error) {
872 LLDB_INSTRUMENT_VA(this, addr, sb_error);
873
875 ProcessSP process_sp(GetSP());
876 if (process_sp) {
877 Process::StopLocker stop_locker;
878 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
879 std::lock_guard<std::recursive_mutex> guard(
880 process_sp->GetTarget().GetAPIMutex());
881 ptr = process_sp->ReadPointerFromMemory(addr, sb_error.ref());
882 } else {
883 sb_error.SetErrorString("process is running");
884 }
885 } else {
886 sb_error.SetErrorString("SBProcess is invalid");
887 }
888 return ptr;
889}
890
891size_t SBProcess::WriteMemory(addr_t addr, const void *src, size_t src_len,
892 SBError &sb_error) {
893 LLDB_INSTRUMENT_VA(this, addr, src, src_len, sb_error);
894
895 size_t bytes_written = 0;
896
897 ProcessSP process_sp(GetSP());
898
899 if (process_sp) {
900 Process::StopLocker stop_locker;
901 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
902 std::lock_guard<std::recursive_mutex> guard(
903 process_sp->GetTarget().GetAPIMutex());
904 bytes_written =
905 process_sp->WriteMemory(addr, src, src_len, sb_error.ref());
906 } else {
907 sb_error.SetErrorString("process is running");
908 }
909 }
910
911 return bytes_written;
912}
913
915 LLDB_INSTRUMENT_VA(this, description);
916
917 Stream &strm = description.ref();
918
919 ProcessSP process_sp(GetSP());
920 if (process_sp) {
921 char path[PATH_MAX];
922 GetTarget().GetExecutable().GetPath(path, sizeof(path));
923 Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
924 const char *exe_name = nullptr;
925 if (exe_module)
926 exe_name = exe_module->GetFileSpec().GetFilename().AsCString();
927
928 strm.Printf("SBProcess: pid = %" PRIu64 ", state = %s, threads = %d%s%s",
929 process_sp->GetID(), lldb_private::StateAsCString(GetState()),
930 GetNumThreads(), exe_name ? ", executable = " : "",
931 exe_name ? exe_name : "");
932 } else
933 strm.PutCString("No value");
934
935 return true;
936}
937
939 LLDB_INSTRUMENT_VA(this);
940 SBStructuredData data;
941 ProcessSP process_sp(GetSP());
942 if (!process_sp)
943 return data;
944
945 PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
946
947 if (!platform_sp)
948 return data;
949
950 auto expected_data =
951 platform_sp->FetchExtendedCrashInformation(*process_sp.get());
952
953 if (!expected_data)
954 return data;
955
956 StructuredData::ObjectSP fetched_data = *expected_data;
957 data.m_impl_up->SetObjectSP(fetched_data);
958 return data;
959}
960
963 LLDB_INSTRUMENT_VA(this, sb_error);
964
965 uint32_t num = 0;
966 ProcessSP process_sp(GetSP());
967 if (process_sp) {
968 std::lock_guard<std::recursive_mutex> guard(
969 process_sp->GetTarget().GetAPIMutex());
970 sb_error.SetError(process_sp->GetWatchpointSupportInfo(num));
971 } else {
972 sb_error.SetErrorString("SBProcess is invalid");
973 }
974 return num;
975}
976
978 lldb::SBError &sb_error) {
979 LLDB_INSTRUMENT_VA(this, sb_remote_image_spec, sb_error);
980
981 return LoadImage(SBFileSpec(), sb_remote_image_spec, sb_error);
982}
983
985 const lldb::SBFileSpec &sb_remote_image_spec,
986 lldb::SBError &sb_error) {
987 LLDB_INSTRUMENT_VA(this, sb_local_image_spec, sb_remote_image_spec, sb_error);
988
989 ProcessSP process_sp(GetSP());
990 if (process_sp) {
991 Process::StopLocker stop_locker;
992 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
993 std::lock_guard<std::recursive_mutex> guard(
994 process_sp->GetTarget().GetAPIMutex());
995 PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
996 return platform_sp->LoadImage(process_sp.get(), *sb_local_image_spec,
997 *sb_remote_image_spec, sb_error.ref());
998 } else {
999 sb_error.SetErrorString("process is running");
1000 }
1001 } else {
1002 sb_error.SetErrorString("process is invalid");
1003 }
1005}
1006
1008 SBStringList &paths,
1009 lldb::SBFileSpec &loaded_path,
1011 LLDB_INSTRUMENT_VA(this, image_spec, paths, loaded_path, error);
1012
1013 ProcessSP process_sp(GetSP());
1014 if (process_sp) {
1015 Process::StopLocker stop_locker;
1016 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1017 std::lock_guard<std::recursive_mutex> guard(
1018 process_sp->GetTarget().GetAPIMutex());
1019 PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
1020 size_t num_paths = paths.GetSize();
1021 std::vector<std::string> paths_vec;
1022 paths_vec.reserve(num_paths);
1023 for (size_t i = 0; i < num_paths; i++)
1024 paths_vec.push_back(paths.GetStringAtIndex(i));
1025 FileSpec loaded_spec;
1026
1027 uint32_t token = platform_sp->LoadImageUsingPaths(
1028 process_sp.get(), *image_spec, paths_vec, error.ref(), &loaded_spec);
1029 if (token != LLDB_INVALID_IMAGE_TOKEN)
1030 loaded_path = loaded_spec;
1031 return token;
1032 } else {
1033 error.SetErrorString("process is running");
1034 }
1035 } else {
1036 error.SetErrorString("process is invalid");
1037 }
1038
1040}
1041
1043 LLDB_INSTRUMENT_VA(this, image_token);
1044
1045 lldb::SBError sb_error;
1046 ProcessSP process_sp(GetSP());
1047 if (process_sp) {
1048 Process::StopLocker stop_locker;
1049 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1050 std::lock_guard<std::recursive_mutex> guard(
1051 process_sp->GetTarget().GetAPIMutex());
1052 PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
1053 sb_error.SetError(
1054 platform_sp->UnloadImage(process_sp.get(), image_token));
1055 } else {
1056 sb_error.SetErrorString("process is running");
1057 }
1058 } else
1059 sb_error.SetErrorString("invalid process");
1060 return sb_error;
1061}
1062
1064 LLDB_INSTRUMENT_VA(this, event_data);
1065
1066 lldb::SBError sb_error;
1067 ProcessSP process_sp(GetSP());
1068 if (process_sp) {
1069 Process::StopLocker stop_locker;
1070 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1071 std::lock_guard<std::recursive_mutex> guard(
1072 process_sp->GetTarget().GetAPIMutex());
1073 sb_error.SetError(process_sp->SendEventData(event_data));
1074 } else {
1075 sb_error.SetErrorString("process is running");
1076 }
1077 } else
1078 sb_error.SetErrorString("invalid process");
1079 return sb_error;
1080}
1081
1083 LLDB_INSTRUMENT_VA(this);
1084
1085 ProcessSP process_sp(GetSP());
1086 if (process_sp && process_sp->GetSystemRuntime()) {
1087 SystemRuntime *runtime = process_sp->GetSystemRuntime();
1088 return runtime->GetExtendedBacktraceTypes().size();
1089 }
1090 return 0;
1091}
1092
1094 LLDB_INSTRUMENT_VA(this, idx);
1095
1096 ProcessSP process_sp(GetSP());
1097 if (process_sp && process_sp->GetSystemRuntime()) {
1098 SystemRuntime *runtime = process_sp->GetSystemRuntime();
1099 const std::vector<ConstString> &names =
1100 runtime->GetExtendedBacktraceTypes();
1101 if (idx < names.size()) {
1102 return names[idx].AsCString();
1103 }
1104 }
1105 return nullptr;
1106}
1107
1109 LLDB_INSTRUMENT_VA(this, addr);
1110
1111 ProcessSP process_sp(GetSP());
1112 SBThreadCollection threads;
1113 if (process_sp) {
1114 threads = SBThreadCollection(process_sp->GetHistoryThreads(addr));
1115 }
1116 return threads;
1117}
1118
1121 LLDB_INSTRUMENT_VA(this, type);
1122
1123 ProcessSP process_sp(GetSP());
1124 if (!process_sp)
1125 return false;
1126
1127 std::lock_guard<std::recursive_mutex> guard(
1128 process_sp->GetTarget().GetAPIMutex());
1129
1130 InstrumentationRuntimeSP runtime_sp =
1131 process_sp->GetInstrumentationRuntime(type);
1132
1133 if (!runtime_sp.get())
1134 return false;
1135
1136 return runtime_sp->IsActive();
1137}
1138
1139lldb::SBError SBProcess::SaveCore(const char *file_name) {
1140 LLDB_INSTRUMENT_VA(this, file_name);
1141 return SaveCore(file_name, "", SaveCoreStyle::eSaveCoreFull);
1142}
1143
1145 const char *flavor,
1146 SaveCoreStyle core_style) {
1147 LLDB_INSTRUMENT_VA(this, file_name, flavor, core_style);
1148
1150 ProcessSP process_sp(GetSP());
1151 if (!process_sp) {
1152 error.SetErrorString("SBProcess is invalid");
1153 return error;
1154 }
1155
1156 std::lock_guard<std::recursive_mutex> guard(
1157 process_sp->GetTarget().GetAPIMutex());
1158
1159 if (process_sp->GetState() != eStateStopped) {
1160 error.SetErrorString("the process is not stopped");
1161 return error;
1162 }
1163
1164 FileSpec core_file(file_name);
1165 error.ref() = PluginManager::SaveCore(process_sp, core_file, core_style,
1166 flavor);
1167
1168 return error;
1169}
1170
1173 SBMemoryRegionInfo &sb_region_info) {
1174 LLDB_INSTRUMENT_VA(this, load_addr, sb_region_info);
1175
1176 lldb::SBError sb_error;
1177 ProcessSP process_sp(GetSP());
1178 if (process_sp) {
1179 Process::StopLocker stop_locker;
1180 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1181 std::lock_guard<std::recursive_mutex> guard(
1182 process_sp->GetTarget().GetAPIMutex());
1183
1184 sb_error.ref() =
1185 process_sp->GetMemoryRegionInfo(load_addr, sb_region_info.ref());
1186 } else {
1187 sb_error.SetErrorString("process is running");
1188 }
1189 } else {
1190 sb_error.SetErrorString("SBProcess is invalid");
1191 }
1192 return sb_error;
1193}
1194
1196 LLDB_INSTRUMENT_VA(this);
1197
1198 lldb::SBMemoryRegionInfoList sb_region_list;
1199
1200 ProcessSP process_sp(GetSP());
1201 Process::StopLocker stop_locker;
1202 if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock())) {
1203 std::lock_guard<std::recursive_mutex> guard(
1204 process_sp->GetTarget().GetAPIMutex());
1205
1206 process_sp->GetMemoryRegions(sb_region_list.ref());
1207 }
1208
1209 return sb_region_list;
1210}
1211
1213 LLDB_INSTRUMENT_VA(this);
1214
1215 lldb::SBProcessInfo sb_proc_info;
1216 ProcessSP process_sp(GetSP());
1217 ProcessInstanceInfo proc_info;
1218 if (process_sp && process_sp->GetProcessInfo(proc_info)) {
1219 sb_proc_info.SetProcessInfo(proc_info);
1220 }
1221 return sb_proc_info;
1222}
1223
1225 lldb::SBError &sb_error) {
1226 LLDB_INSTRUMENT_VA(this, size, permissions, sb_error);
1227
1229 ProcessSP process_sp(GetSP());
1230 if (process_sp) {
1231 Process::StopLocker stop_locker;
1232 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1233 std::lock_guard<std::recursive_mutex> guard(
1234 process_sp->GetTarget().GetAPIMutex());
1235 addr = process_sp->AllocateMemory(size, permissions, sb_error.ref());
1236 } else {
1237 sb_error.SetErrorString("process is running");
1238 }
1239 } else {
1240 sb_error.SetErrorString("SBProcess is invalid");
1241 }
1242 return addr;
1243}
1244
1246 LLDB_INSTRUMENT_VA(this, ptr);
1247
1248 lldb::SBError sb_error;
1249 ProcessSP process_sp(GetSP());
1250 if (process_sp) {
1251 Process::StopLocker stop_locker;
1252 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1253 std::lock_guard<std::recursive_mutex> guard(
1254 process_sp->GetTarget().GetAPIMutex());
1255 Status error = process_sp->DeallocateMemory(ptr);
1256 sb_error.SetError(error);
1257 } else {
1258 sb_error.SetErrorString("process is running");
1259 }
1260 } else {
1261 sb_error.SetErrorString("SBProcess is invalid");
1262 }
1263 return sb_error;
1264}
1265
1267 LLDB_INSTRUMENT_VA(this);
1268 ProcessSP process_sp(GetSP());
1269 return (process_sp) ? process_sp->GetImplementation() : nullptr;
1270}
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:734
void SetErrorString(const char *err_str)
Definition: SBError.cpp:126
void SetError(uint32_t err, lldb::ErrorType type)
Definition: SBError.cpp:100
lldb_private::Status & ref()
Definition: SBError.cpp:161
void reset(lldb::EventSP &event_sp)
lldb_private::Event * get() const
Definition: SBEvent.cpp:133
const char * GetBroadcasterClass() const
Definition: SBEvent.cpp:93
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:45
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:729
lldb::SBError SendEventData(const char *data)
Definition: SBProcess.cpp:1063
lldb::SBBroadcaster GetBroadcaster() const
Definition: SBProcess.cpp:785
lldb::SBError Detach()
Definition: SBProcess.cpp:620
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:555
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:1082
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:497
lldb::SBThread GetThreadByIndexID(uint32_t index_id)
Definition: SBProcess.cpp:694
static const char * GetBroadcasterClass()
Definition: SBProcess.cpp:795
static lldb::SBStructuredData GetStructuredDataFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:763
lldb::ProcessSP GetSP() const
Definition: SBProcess.cpp:102
lldb::pid_t GetProcessID()
Gets the process ID.
Definition: SBProcess.cpp:510
lldb::addr_t AllocateMemory(size_t size, uint32_t permissions, lldb::SBError &error)
Allocate memory within the process.
Definition: SBProcess.cpp:1224
static bool EventIsStructuredDataEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:776
const char * GetShortPluginName()
Definition: SBProcess.cpp:92
lldb::SBError UnloadImage(uint32_t image_token)
Definition: SBProcess.cpp:1042
lldb::SBProcessInfo GetProcessInfo()
Return information about the process.
Definition: SBProcess.cpp:1212
uint32_t GetUniqueID()
Gets the unique ID associated with this process object.
Definition: SBProcess.cpp:521
bool GetDescription(lldb::SBStream &description)
Definition: SBProcess.cpp:914
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:469
lldb::SBThread CreateOSPluginThread(lldb::tid_t tid, lldb::addr_t context)
Definition: SBProcess.cpp:216
lldb::SBError Destroy()
Definition: SBProcess.cpp:575
lldb::ScriptedObject GetScriptedImplementation()
Definition: SBProcess.cpp:1266
lldb::ByteOrder GetByteOrder() const
Definition: SBProcess.cpp:531
lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError &error)
Definition: SBProcess.cpp:870
lldb::SBError DeallocateMemory(lldb::addr_t ptr)
Deallocate memory in the process.
Definition: SBProcess.cpp:1245
static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:713
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:801
const char * GetExtendedBacktraceTypeAtIndex(uint32_t idx)
Return the name of one of the thread-origin extended backtrace methods.
Definition: SBProcess.cpp:1093
lldb::SBThread GetThreadByID(lldb::tid_t sb_thread_id)
Definition: SBProcess.cpp:676
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:643
static bool GetInterruptedFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:756
lldb::SBError Stop()
Definition: SBProcess.cpp:590
lldb::ProcessWP m_opaque_wp
Definition: SBProcess.h:446
uint32_t GetNumSupportedHardwareWatchpoints(lldb::SBError &error) const
Definition: SBProcess.cpp:962
uint32_t LoadImageUsingPaths(const lldb::SBFileSpec &image_spec, SBStringList &paths, lldb::SBFileSpec &loaded_path, lldb::SBError &error)
Load a shared library into this process, starting with a library name and a list of paths,...
Definition: SBProcess.cpp:1007
uint32_t LoadImage(lldb::SBFileSpec &remote_image_spec, lldb::SBError &error)
Load a shared library into this process.
Definition: SBProcess.cpp:977
static const char * GetRestartedReasonAtIndexFromEvent(const lldb::SBEvent &event, size_t idx)
Definition: SBProcess.cpp:736
lldb::SBUnixSignals GetUnixSignals()
Definition: SBProcess.cpp:658
lldb::SBError Kill()
Definition: SBProcess.cpp:605
lldb::SBThreadCollection GetHistoryThreads(addr_t addr)
Definition: SBProcess.cpp:1108
bool IsInstrumentationRuntimePresent(InstrumentationRuntimeType type)
Definition: SBProcess.cpp:1119
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:667
static bool GetRestartedFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:721
static bool EventIsProcessEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:769
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:1172
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:891
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:1144
lldb::SBMemoryRegionInfoList GetMemoryRegions()
Return the list of memory regions within the process.
Definition: SBProcess.cpp:1195
size_t ReadCStringFromMemory(addr_t addr, void *buf, size_t size, lldb::SBError &error)
Definition: SBProcess.cpp:826
uint32_t GetAddressByteSize() const
Definition: SBProcess.cpp:543
SBStructuredData GetExtendedCrashInformation()
Definition: SBProcess.cpp:938
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:848
bool IsValid() const
Definition: SBProcess.cpp:112
static lldb::SBProcess GetProcessFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:743
size_t GetSTDERR(char *dst, size_t dst_len) const
Definition: SBProcess.cpp:273
void SetQueue(const lldb::QueueSP &queue_sp)
Definition: SBQueue.cpp:256
lldb_private::Stream & ref()
Definition: SBStream.cpp:176
uint32_t GetSize() const
const char * GetStringAtIndex(size_t idx)
StructuredDataImplUP m_impl_up
void SetSP(const lldb::TargetSP &target_sp)
Definition: SBTarget.cpp:578
lldb::SBFileSpec GetExecutable()
Definition: SBTarget.cpp:550
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:298
A uniqued constant string class.
Definition: ConstString.h:39
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:192
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:215
static lldb::ProcessSP GetProcessFromEvent(const Event *event_ptr)
Definition: Event.cpp:257
static ConstString GetFlavorString()
Definition: Event.cpp:283
virtual ConstString 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:61
void SetProcessID(lldb::pid_t pid)
Definition: ProcessInfo.h:68
Environment & GetEnvironment()
Definition: ProcessInfo.h:86
static bool GetRestartedFromEvent(const Event *event_ptr)
Definition: Process.cpp:4139
static lldb::ProcessSP GetProcessFromEvent(const Event *event_ptr)
Definition: Process.cpp:4123
static bool GetInterruptedFromEvent(const Event *event_ptr)
Definition: Process.cpp:4184
const char * GetRestartedReasonAtIndex(size_t idx)
Definition: Process.h:417
static lldb::StateType GetStateFromEvent(const Event *event_ptr)
Definition: Process.cpp:4131
static ConstString & GetStaticBroadcasterClass()
Definition: Process.cpp:399
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.
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:113
InstrumentationRuntimeType
uint64_t pid_t
Definition: lldb-types.h:85
ByteOrder
Byte ordering definitions.
@ eByteOrderInvalid
uint64_t addr_t
Definition: lldb-types.h:83
uint64_t tid_t
Definition: lldb-types.h:86
#define PATH_MAX