[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / source / API / SBProcess.cpp
blob45aaa0bd2d8a1b2b069f543ea6479da328e6029b
1 //===-- SBProcess.cpp -------------------------------------------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBProcess.h"
10 #include "SBReproducerPrivate.h"
12 #include <inttypes.h>
14 #include "lldb/lldb-defines.h"
15 #include "lldb/lldb-types.h"
17 #include "lldb/Core/Debugger.h"
18 #include "lldb/Core/Module.h"
19 #include "lldb/Core/PluginManager.h"
20 #include "lldb/Core/StreamFile.h"
21 #include "lldb/Target/MemoryRegionInfo.h"
22 #include "lldb/Target/Process.h"
23 #include "lldb/Target/RegisterContext.h"
24 #include "lldb/Target/SystemRuntime.h"
25 #include "lldb/Target/Target.h"
26 #include "lldb/Target/Thread.h"
27 #include "lldb/Utility/Args.h"
28 #include "lldb/Utility/ProcessInfo.h"
29 #include "lldb/Utility/State.h"
30 #include "lldb/Utility/Stream.h"
32 #include "lldb/API/SBBroadcaster.h"
33 #include "lldb/API/SBCommandReturnObject.h"
34 #include "lldb/API/SBDebugger.h"
35 #include "lldb/API/SBEvent.h"
36 #include "lldb/API/SBFile.h"
37 #include "lldb/API/SBFileSpec.h"
38 #include "lldb/API/SBMemoryRegionInfo.h"
39 #include "lldb/API/SBMemoryRegionInfoList.h"
40 #include "lldb/API/SBStream.h"
41 #include "lldb/API/SBStringList.h"
42 #include "lldb/API/SBStructuredData.h"
43 #include "lldb/API/SBThread.h"
44 #include "lldb/API/SBThreadCollection.h"
45 #include "lldb/API/SBTrace.h"
46 #include "lldb/API/SBTraceOptions.h"
47 #include "lldb/API/SBUnixSignals.h"
49 using namespace lldb;
50 using namespace lldb_private;
52 SBProcess::SBProcess() : m_opaque_wp() {
53 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBProcess);
56 // SBProcess constructor
58 SBProcess::SBProcess(const SBProcess &rhs) : m_opaque_wp(rhs.m_opaque_wp) {
59 LLDB_RECORD_CONSTRUCTOR(SBProcess, (const lldb::SBProcess &), rhs);
62 SBProcess::SBProcess(const lldb::ProcessSP &process_sp)
63 : m_opaque_wp(process_sp) {
64 LLDB_RECORD_CONSTRUCTOR(SBProcess, (const lldb::ProcessSP &), process_sp);
67 const SBProcess &SBProcess::operator=(const SBProcess &rhs) {
68 LLDB_RECORD_METHOD(const lldb::SBProcess &,
69 SBProcess, operator=,(const lldb::SBProcess &), rhs);
71 if (this != &rhs)
72 m_opaque_wp = rhs.m_opaque_wp;
73 return LLDB_RECORD_RESULT(*this);
76 // Destructor
77 SBProcess::~SBProcess() {}
79 const char *SBProcess::GetBroadcasterClassName() {
80 LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBProcess,
81 GetBroadcasterClassName);
83 return Process::GetStaticBroadcasterClass().AsCString();
86 const char *SBProcess::GetPluginName() {
87 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcess, GetPluginName);
89 ProcessSP process_sp(GetSP());
90 if (process_sp) {
91 return process_sp->GetPluginName().GetCString();
93 return "<Unknown>";
96 const char *SBProcess::GetShortPluginName() {
97 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcess, GetShortPluginName);
99 ProcessSP process_sp(GetSP());
100 if (process_sp) {
101 return process_sp->GetPluginName().GetCString();
103 return "<Unknown>";
106 lldb::ProcessSP SBProcess::GetSP() const { return m_opaque_wp.lock(); }
108 void SBProcess::SetSP(const ProcessSP &process_sp) { m_opaque_wp = process_sp; }
110 void SBProcess::Clear() {
111 LLDB_RECORD_METHOD_NO_ARGS(void, SBProcess, Clear);
113 m_opaque_wp.reset();
116 bool SBProcess::IsValid() const {
117 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcess, IsValid);
118 return this->operator bool();
120 SBProcess::operator bool() const {
121 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcess, operator bool);
123 ProcessSP process_sp(m_opaque_wp.lock());
124 return ((bool)process_sp && process_sp->IsValid());
127 bool SBProcess::RemoteLaunch(char const **argv, char const **envp,
128 const char *stdin_path, const char *stdout_path,
129 const char *stderr_path,
130 const char *working_directory,
131 uint32_t launch_flags, bool stop_at_entry,
132 lldb::SBError &error) {
133 LLDB_RECORD_METHOD(bool, SBProcess, RemoteLaunch,
134 (const char **, const char **, const char *, const char *,
135 const char *, const char *, uint32_t, bool,
136 lldb::SBError &),
137 argv, envp, stdin_path, stdout_path, stderr_path,
138 working_directory, launch_flags, stop_at_entry, error);
140 ProcessSP process_sp(GetSP());
141 if (process_sp) {
142 std::lock_guard<std::recursive_mutex> guard(
143 process_sp->GetTarget().GetAPIMutex());
144 if (process_sp->GetState() == eStateConnected) {
145 if (stop_at_entry)
146 launch_flags |= eLaunchFlagStopAtEntry;
147 ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path),
148 FileSpec(stderr_path),
149 FileSpec(working_directory), launch_flags);
150 Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
151 if (exe_module)
152 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
153 if (argv)
154 launch_info.GetArguments().AppendArguments(argv);
155 if (envp)
156 launch_info.GetEnvironment() = Environment(envp);
157 error.SetError(process_sp->Launch(launch_info));
158 } else {
159 error.SetErrorString("must be in eStateConnected to call RemoteLaunch");
161 } else {
162 error.SetErrorString("unable to attach pid");
165 return error.Success();
168 bool SBProcess::RemoteAttachToProcessWithID(lldb::pid_t pid,
169 lldb::SBError &error) {
170 LLDB_RECORD_METHOD(bool, SBProcess, RemoteAttachToProcessWithID,
171 (lldb::pid_t, lldb::SBError &), pid, error);
173 ProcessSP process_sp(GetSP());
174 if (process_sp) {
175 std::lock_guard<std::recursive_mutex> guard(
176 process_sp->GetTarget().GetAPIMutex());
177 if (process_sp->GetState() == eStateConnected) {
178 ProcessAttachInfo attach_info;
179 attach_info.SetProcessID(pid);
180 error.SetError(process_sp->Attach(attach_info));
181 } else {
182 error.SetErrorString(
183 "must be in eStateConnected to call RemoteAttachToProcessWithID");
185 } else {
186 error.SetErrorString("unable to attach pid");
189 return error.Success();
192 uint32_t SBProcess::GetNumThreads() {
193 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetNumThreads);
195 uint32_t num_threads = 0;
196 ProcessSP process_sp(GetSP());
197 if (process_sp) {
198 Process::StopLocker stop_locker;
200 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
201 std::lock_guard<std::recursive_mutex> guard(
202 process_sp->GetTarget().GetAPIMutex());
203 num_threads = process_sp->GetThreadList().GetSize(can_update);
206 return num_threads;
209 SBThread SBProcess::GetSelectedThread() const {
210 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBProcess,
211 GetSelectedThread);
213 SBThread sb_thread;
214 ThreadSP thread_sp;
215 ProcessSP process_sp(GetSP());
216 if (process_sp) {
217 std::lock_guard<std::recursive_mutex> guard(
218 process_sp->GetTarget().GetAPIMutex());
219 thread_sp = process_sp->GetThreadList().GetSelectedThread();
220 sb_thread.SetThread(thread_sp);
223 return LLDB_RECORD_RESULT(sb_thread);
226 SBThread SBProcess::CreateOSPluginThread(lldb::tid_t tid,
227 lldb::addr_t context) {
228 LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, CreateOSPluginThread,
229 (lldb::tid_t, lldb::addr_t), tid, context);
231 SBThread sb_thread;
232 ThreadSP thread_sp;
233 ProcessSP process_sp(GetSP());
234 if (process_sp) {
235 std::lock_guard<std::recursive_mutex> guard(
236 process_sp->GetTarget().GetAPIMutex());
237 thread_sp = process_sp->CreateOSPluginThread(tid, context);
238 sb_thread.SetThread(thread_sp);
241 return LLDB_RECORD_RESULT(sb_thread);
244 SBTarget SBProcess::GetTarget() const {
245 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBTarget, SBProcess, GetTarget);
247 SBTarget sb_target;
248 TargetSP target_sp;
249 ProcessSP process_sp(GetSP());
250 if (process_sp) {
251 target_sp = process_sp->GetTarget().shared_from_this();
252 sb_target.SetSP(target_sp);
255 return LLDB_RECORD_RESULT(sb_target);
258 size_t SBProcess::PutSTDIN(const char *src, size_t src_len) {
259 LLDB_RECORD_METHOD(size_t, SBProcess, PutSTDIN, (const char *, size_t), src,
260 src_len);
262 size_t ret_val = 0;
263 ProcessSP process_sp(GetSP());
264 if (process_sp) {
265 Status error;
266 ret_val = process_sp->PutSTDIN(src, src_len, error);
269 return ret_val;
272 size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const {
273 LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t), dst,
274 dst_len);
276 size_t bytes_read = 0;
277 ProcessSP process_sp(GetSP());
278 if (process_sp) {
279 Status error;
280 bytes_read = process_sp->GetSTDOUT(dst, dst_len, error);
283 return bytes_read;
286 size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const {
287 LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t), dst,
288 dst_len);
290 size_t bytes_read = 0;
291 ProcessSP process_sp(GetSP());
292 if (process_sp) {
293 Status error;
294 bytes_read = process_sp->GetSTDERR(dst, dst_len, error);
297 return bytes_read;
300 size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const {
301 LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData,
302 (char *, size_t), dst, dst_len);
304 size_t bytes_read = 0;
305 ProcessSP process_sp(GetSP());
306 if (process_sp) {
307 Status error;
308 bytes_read = process_sp->GetAsyncProfileData(dst, dst_len, error);
311 return bytes_read;
314 lldb::SBTrace SBProcess::StartTrace(SBTraceOptions &options,
315 lldb::SBError &error) {
316 LLDB_RECORD_METHOD(lldb::SBTrace, SBProcess, StartTrace,
317 (lldb::SBTraceOptions &, lldb::SBError &), options, error);
319 ProcessSP process_sp(GetSP());
320 error.Clear();
321 SBTrace trace_instance;
322 trace_instance.SetSP(process_sp);
323 lldb::user_id_t uid = LLDB_INVALID_UID;
325 if (!process_sp) {
326 error.SetErrorString("invalid process");
327 } else {
328 uid = process_sp->StartTrace(*(options.m_traceoptions_sp), error.ref());
329 trace_instance.SetTraceUID(uid);
331 return LLDB_RECORD_RESULT(trace_instance);
334 void SBProcess::ReportEventState(const SBEvent &event, SBFile out) const {
335 LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
336 (const SBEvent &, SBFile), event, out);
338 return ReportEventState(event, out.m_opaque_sp);
341 void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const {
342 LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
343 (const lldb::SBEvent &, FILE *), event, out);
344 FileSP outfile = std::make_shared<NativeFile>(out, false);
345 return ReportEventState(event, outfile);
348 void SBProcess::ReportEventState(const SBEvent &event, FileSP out) const {
350 LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
351 (const SBEvent &, FileSP), event, out);
353 if (!out || !out->IsValid())
354 return;
356 ProcessSP process_sp(GetSP());
357 if (process_sp) {
358 StreamFile stream(out);
359 const StateType event_state = SBProcess::GetStateFromEvent(event);
360 stream.Printf("Process %" PRIu64 " %s\n",
361 process_sp->GetID(), SBDebugger::StateAsCString(event_state));
365 void SBProcess::AppendEventStateReport(const SBEvent &event,
366 SBCommandReturnObject &result) {
367 LLDB_RECORD_METHOD(void, SBProcess, AppendEventStateReport,
368 (const lldb::SBEvent &, lldb::SBCommandReturnObject &),
369 event, result);
371 ProcessSP process_sp(GetSP());
372 if (process_sp) {
373 const StateType event_state = SBProcess::GetStateFromEvent(event);
374 char message[1024];
375 ::snprintf(message, sizeof(message), "Process %" PRIu64 " %s\n",
376 process_sp->GetID(), SBDebugger::StateAsCString(event_state));
378 result.AppendMessage(message);
382 bool SBProcess::SetSelectedThread(const SBThread &thread) {
383 LLDB_RECORD_METHOD(bool, SBProcess, SetSelectedThread,
384 (const lldb::SBThread &), thread);
386 ProcessSP process_sp(GetSP());
387 if (process_sp) {
388 std::lock_guard<std::recursive_mutex> guard(
389 process_sp->GetTarget().GetAPIMutex());
390 return process_sp->GetThreadList().SetSelectedThreadByID(
391 thread.GetThreadID());
393 return false;
396 bool SBProcess::SetSelectedThreadByID(lldb::tid_t tid) {
397 LLDB_RECORD_METHOD(bool, SBProcess, SetSelectedThreadByID, (lldb::tid_t),
398 tid);
401 bool ret_val = false;
402 ProcessSP process_sp(GetSP());
403 if (process_sp) {
404 std::lock_guard<std::recursive_mutex> guard(
405 process_sp->GetTarget().GetAPIMutex());
406 ret_val = process_sp->GetThreadList().SetSelectedThreadByID(tid);
409 return ret_val;
412 bool SBProcess::SetSelectedThreadByIndexID(uint32_t index_id) {
413 LLDB_RECORD_METHOD(bool, SBProcess, SetSelectedThreadByIndexID, (uint32_t),
414 index_id);
416 bool ret_val = false;
417 ProcessSP process_sp(GetSP());
418 if (process_sp) {
419 std::lock_guard<std::recursive_mutex> guard(
420 process_sp->GetTarget().GetAPIMutex());
421 ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID(index_id);
425 return ret_val;
428 SBThread SBProcess::GetThreadAtIndex(size_t index) {
429 LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, GetThreadAtIndex, (size_t),
430 index);
432 SBThread sb_thread;
433 ThreadSP thread_sp;
434 ProcessSP process_sp(GetSP());
435 if (process_sp) {
436 Process::StopLocker stop_locker;
437 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
438 std::lock_guard<std::recursive_mutex> guard(
439 process_sp->GetTarget().GetAPIMutex());
440 thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, can_update);
441 sb_thread.SetThread(thread_sp);
444 return LLDB_RECORD_RESULT(sb_thread);
447 uint32_t SBProcess::GetNumQueues() {
448 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetNumQueues);
450 uint32_t num_queues = 0;
451 ProcessSP process_sp(GetSP());
452 if (process_sp) {
453 Process::StopLocker stop_locker;
454 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
455 std::lock_guard<std::recursive_mutex> guard(
456 process_sp->GetTarget().GetAPIMutex());
457 num_queues = process_sp->GetQueueList().GetSize();
461 return num_queues;
464 SBQueue SBProcess::GetQueueAtIndex(size_t index) {
465 LLDB_RECORD_METHOD(lldb::SBQueue, SBProcess, GetQueueAtIndex, (size_t),
466 index);
468 SBQueue sb_queue;
469 QueueSP queue_sp;
470 ProcessSP process_sp(GetSP());
471 if (process_sp) {
472 Process::StopLocker stop_locker;
473 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
474 std::lock_guard<std::recursive_mutex> guard(
475 process_sp->GetTarget().GetAPIMutex());
476 queue_sp = process_sp->GetQueueList().GetQueueAtIndex(index);
477 sb_queue.SetQueue(queue_sp);
481 return LLDB_RECORD_RESULT(sb_queue);
484 uint32_t SBProcess::GetStopID(bool include_expression_stops) {
485 LLDB_RECORD_METHOD(uint32_t, SBProcess, GetStopID, (bool),
486 include_expression_stops);
488 ProcessSP process_sp(GetSP());
489 if (process_sp) {
490 std::lock_guard<std::recursive_mutex> guard(
491 process_sp->GetTarget().GetAPIMutex());
492 if (include_expression_stops)
493 return process_sp->GetStopID();
494 else
495 return process_sp->GetLastNaturalStopID();
497 return 0;
500 SBEvent SBProcess::GetStopEventForStopID(uint32_t stop_id) {
501 LLDB_RECORD_METHOD(lldb::SBEvent, SBProcess, GetStopEventForStopID,
502 (uint32_t), stop_id);
504 SBEvent sb_event;
505 EventSP event_sp;
506 ProcessSP process_sp(GetSP());
507 if (process_sp) {
508 std::lock_guard<std::recursive_mutex> guard(
509 process_sp->GetTarget().GetAPIMutex());
510 event_sp = process_sp->GetStopEventForStopID(stop_id);
511 sb_event.reset(event_sp);
514 return LLDB_RECORD_RESULT(sb_event);
517 StateType SBProcess::GetState() {
518 LLDB_RECORD_METHOD_NO_ARGS(lldb::StateType, SBProcess, GetState);
520 StateType ret_val = eStateInvalid;
521 ProcessSP process_sp(GetSP());
522 if (process_sp) {
523 std::lock_guard<std::recursive_mutex> guard(
524 process_sp->GetTarget().GetAPIMutex());
525 ret_val = process_sp->GetState();
528 return ret_val;
531 int SBProcess::GetExitStatus() {
532 LLDB_RECORD_METHOD_NO_ARGS(int, SBProcess, GetExitStatus);
534 int exit_status = 0;
535 ProcessSP process_sp(GetSP());
536 if (process_sp) {
537 std::lock_guard<std::recursive_mutex> guard(
538 process_sp->GetTarget().GetAPIMutex());
539 exit_status = process_sp->GetExitStatus();
542 return exit_status;
545 const char *SBProcess::GetExitDescription() {
546 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcess, GetExitDescription);
548 const char *exit_desc = nullptr;
549 ProcessSP process_sp(GetSP());
550 if (process_sp) {
551 std::lock_guard<std::recursive_mutex> guard(
552 process_sp->GetTarget().GetAPIMutex());
553 exit_desc = process_sp->GetExitDescription();
555 return exit_desc;
558 lldb::pid_t SBProcess::GetProcessID() {
559 LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBProcess, GetProcessID);
561 lldb::pid_t ret_val = LLDB_INVALID_PROCESS_ID;
562 ProcessSP process_sp(GetSP());
563 if (process_sp)
564 ret_val = process_sp->GetID();
566 return ret_val;
569 uint32_t SBProcess::GetUniqueID() {
570 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetUniqueID);
572 uint32_t ret_val = 0;
573 ProcessSP process_sp(GetSP());
574 if (process_sp)
575 ret_val = process_sp->GetUniqueID();
576 return ret_val;
579 ByteOrder SBProcess::GetByteOrder() const {
580 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ByteOrder, SBProcess, GetByteOrder);
582 ByteOrder byteOrder = eByteOrderInvalid;
583 ProcessSP process_sp(GetSP());
584 if (process_sp)
585 byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder();
588 return byteOrder;
591 uint32_t SBProcess::GetAddressByteSize() const {
592 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBProcess, GetAddressByteSize);
594 uint32_t size = 0;
595 ProcessSP process_sp(GetSP());
596 if (process_sp)
597 size = process_sp->GetTarget().GetArchitecture().GetAddressByteSize();
600 return size;
603 SBError SBProcess::Continue() {
604 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Continue);
606 SBError sb_error;
607 ProcessSP process_sp(GetSP());
609 if (process_sp) {
610 std::lock_guard<std::recursive_mutex> guard(
611 process_sp->GetTarget().GetAPIMutex());
613 if (process_sp->GetTarget().GetDebugger().GetAsyncExecution())
614 sb_error.ref() = process_sp->Resume();
615 else
616 sb_error.ref() = process_sp->ResumeSynchronous(nullptr);
617 } else
618 sb_error.SetErrorString("SBProcess is invalid");
620 return LLDB_RECORD_RESULT(sb_error);
623 SBError SBProcess::Destroy() {
624 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Destroy);
626 SBError sb_error;
627 ProcessSP process_sp(GetSP());
628 if (process_sp) {
629 std::lock_guard<std::recursive_mutex> guard(
630 process_sp->GetTarget().GetAPIMutex());
631 sb_error.SetError(process_sp->Destroy(false));
632 } else
633 sb_error.SetErrorString("SBProcess is invalid");
635 return LLDB_RECORD_RESULT(sb_error);
638 SBError SBProcess::Stop() {
639 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Stop);
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->Halt());
647 } else
648 sb_error.SetErrorString("SBProcess is invalid");
650 return LLDB_RECORD_RESULT(sb_error);
653 SBError SBProcess::Kill() {
654 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Kill);
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->Destroy(true));
662 } else
663 sb_error.SetErrorString("SBProcess is invalid");
665 return LLDB_RECORD_RESULT(sb_error);
668 SBError SBProcess::Detach() {
669 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Detach);
671 // FIXME: This should come from a process default.
672 bool keep_stopped = false;
673 return LLDB_RECORD_RESULT(Detach(keep_stopped));
676 SBError SBProcess::Detach(bool keep_stopped) {
677 LLDB_RECORD_METHOD(lldb::SBError, SBProcess, Detach, (bool), keep_stopped);
679 SBError sb_error;
680 ProcessSP process_sp(GetSP());
681 if (process_sp) {
682 std::lock_guard<std::recursive_mutex> guard(
683 process_sp->GetTarget().GetAPIMutex());
684 sb_error.SetError(process_sp->Detach(keep_stopped));
685 } else
686 sb_error.SetErrorString("SBProcess is invalid");
688 return LLDB_RECORD_RESULT(sb_error);
691 SBError SBProcess::Signal(int signo) {
692 LLDB_RECORD_METHOD(lldb::SBError, SBProcess, Signal, (int), signo);
694 SBError sb_error;
695 ProcessSP process_sp(GetSP());
696 if (process_sp) {
697 std::lock_guard<std::recursive_mutex> guard(
698 process_sp->GetTarget().GetAPIMutex());
699 sb_error.SetError(process_sp->Signal(signo));
700 } else
701 sb_error.SetErrorString("SBProcess is invalid");
703 return LLDB_RECORD_RESULT(sb_error);
706 SBUnixSignals SBProcess::GetUnixSignals() {
707 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBUnixSignals, SBProcess, GetUnixSignals);
709 if (auto process_sp = GetSP())
710 return LLDB_RECORD_RESULT(SBUnixSignals{process_sp});
712 return LLDB_RECORD_RESULT(SBUnixSignals{});
715 void SBProcess::SendAsyncInterrupt() {
716 LLDB_RECORD_METHOD_NO_ARGS(void, SBProcess, SendAsyncInterrupt);
718 ProcessSP process_sp(GetSP());
719 if (process_sp) {
720 process_sp->SendAsyncInterrupt();
724 SBThread SBProcess::GetThreadByID(tid_t tid) {
725 LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, GetThreadByID, (lldb::tid_t),
726 tid);
728 SBThread sb_thread;
729 ThreadSP thread_sp;
730 ProcessSP process_sp(GetSP());
731 if (process_sp) {
732 Process::StopLocker stop_locker;
733 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
734 std::lock_guard<std::recursive_mutex> guard(
735 process_sp->GetTarget().GetAPIMutex());
736 thread_sp = process_sp->GetThreadList().FindThreadByID(tid, can_update);
737 sb_thread.SetThread(thread_sp);
740 return LLDB_RECORD_RESULT(sb_thread);
743 SBThread SBProcess::GetThreadByIndexID(uint32_t index_id) {
744 LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, GetThreadByIndexID, (uint32_t),
745 index_id);
747 SBThread sb_thread;
748 ThreadSP thread_sp;
749 ProcessSP process_sp(GetSP());
750 if (process_sp) {
751 Process::StopLocker stop_locker;
752 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
753 std::lock_guard<std::recursive_mutex> guard(
754 process_sp->GetTarget().GetAPIMutex());
755 thread_sp =
756 process_sp->GetThreadList().FindThreadByIndexID(index_id, can_update);
757 sb_thread.SetThread(thread_sp);
760 return LLDB_RECORD_RESULT(sb_thread);
763 StateType SBProcess::GetStateFromEvent(const SBEvent &event) {
764 LLDB_RECORD_STATIC_METHOD(lldb::StateType, SBProcess, GetStateFromEvent,
765 (const lldb::SBEvent &), event);
767 StateType ret_val = Process::ProcessEventData::GetStateFromEvent(event.get());
769 return ret_val;
772 bool SBProcess::GetRestartedFromEvent(const SBEvent &event) {
773 LLDB_RECORD_STATIC_METHOD(bool, SBProcess, GetRestartedFromEvent,
774 (const lldb::SBEvent &), event);
776 bool ret_val = Process::ProcessEventData::GetRestartedFromEvent(event.get());
778 return ret_val;
781 size_t SBProcess::GetNumRestartedReasonsFromEvent(const lldb::SBEvent &event) {
782 LLDB_RECORD_STATIC_METHOD(size_t, SBProcess, GetNumRestartedReasonsFromEvent,
783 (const lldb::SBEvent &), event);
785 return Process::ProcessEventData::GetNumRestartedReasons(event.get());
788 const char *
789 SBProcess::GetRestartedReasonAtIndexFromEvent(const lldb::SBEvent &event,
790 size_t idx) {
791 LLDB_RECORD_STATIC_METHOD(const char *, SBProcess,
792 GetRestartedReasonAtIndexFromEvent,
793 (const lldb::SBEvent &, size_t), event, idx);
795 return Process::ProcessEventData::GetRestartedReasonAtIndex(event.get(), idx);
798 SBProcess SBProcess::GetProcessFromEvent(const SBEvent &event) {
799 LLDB_RECORD_STATIC_METHOD(lldb::SBProcess, SBProcess, GetProcessFromEvent,
800 (const lldb::SBEvent &), event);
802 ProcessSP process_sp =
803 Process::ProcessEventData::GetProcessFromEvent(event.get());
804 if (!process_sp) {
805 // StructuredData events also know the process they come from. Try that.
806 process_sp = EventDataStructuredData::GetProcessFromEvent(event.get());
809 return LLDB_RECORD_RESULT(SBProcess(process_sp));
812 bool SBProcess::GetInterruptedFromEvent(const SBEvent &event) {
813 LLDB_RECORD_STATIC_METHOD(bool, SBProcess, GetInterruptedFromEvent,
814 (const lldb::SBEvent &), event);
816 return Process::ProcessEventData::GetInterruptedFromEvent(event.get());
819 lldb::SBStructuredData
820 SBProcess::GetStructuredDataFromEvent(const lldb::SBEvent &event) {
821 LLDB_RECORD_STATIC_METHOD(lldb::SBStructuredData, SBProcess,
822 GetStructuredDataFromEvent, (const lldb::SBEvent &),
823 event);
825 return LLDB_RECORD_RESULT(SBStructuredData(event.GetSP()));
828 bool SBProcess::EventIsProcessEvent(const SBEvent &event) {
829 LLDB_RECORD_STATIC_METHOD(bool, SBProcess, EventIsProcessEvent,
830 (const lldb::SBEvent &), event);
832 return (event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass()) &&
833 !EventIsStructuredDataEvent(event);
836 bool SBProcess::EventIsStructuredDataEvent(const lldb::SBEvent &event) {
837 LLDB_RECORD_STATIC_METHOD(bool, SBProcess, EventIsStructuredDataEvent,
838 (const lldb::SBEvent &), event);
840 EventSP event_sp = event.GetSP();
841 EventData *event_data = event_sp ? event_sp->GetData() : nullptr;
842 return event_data && (event_data->GetFlavor() ==
843 EventDataStructuredData::GetFlavorString());
846 SBBroadcaster SBProcess::GetBroadcaster() const {
847 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBProcess,
848 GetBroadcaster);
851 ProcessSP process_sp(GetSP());
853 SBBroadcaster broadcaster(process_sp.get(), false);
856 return LLDB_RECORD_RESULT(broadcaster);
859 const char *SBProcess::GetBroadcasterClass() {
860 LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBProcess,
861 GetBroadcasterClass);
863 return Process::GetStaticBroadcasterClass().AsCString();
866 size_t SBProcess::ReadMemory(addr_t addr, void *dst, size_t dst_len,
867 SBError &sb_error) {
868 LLDB_RECORD_DUMMY(size_t, SBProcess, ReadMemory,
869 (lldb::addr_t, void *, size_t, lldb::SBError &), addr, dst,
870 dst_len, sb_error);
872 size_t bytes_read = 0;
874 ProcessSP process_sp(GetSP());
877 if (process_sp) {
878 Process::StopLocker stop_locker;
879 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
880 std::lock_guard<std::recursive_mutex> guard(
881 process_sp->GetTarget().GetAPIMutex());
882 bytes_read = process_sp->ReadMemory(addr, dst, dst_len, sb_error.ref());
883 } else {
884 sb_error.SetErrorString("process is running");
886 } else {
887 sb_error.SetErrorString("SBProcess is invalid");
890 return bytes_read;
893 size_t SBProcess::ReadCStringFromMemory(addr_t addr, void *buf, size_t size,
894 lldb::SBError &sb_error) {
895 LLDB_RECORD_DUMMY(size_t, SBProcess, ReadCStringFromMemory,
896 (lldb::addr_t, void *, size_t, lldb::SBError &), addr, buf,
897 size, sb_error);
899 size_t bytes_read = 0;
900 ProcessSP process_sp(GetSP());
901 if (process_sp) {
902 Process::StopLocker stop_locker;
903 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
904 std::lock_guard<std::recursive_mutex> guard(
905 process_sp->GetTarget().GetAPIMutex());
906 bytes_read = process_sp->ReadCStringFromMemory(addr, (char *)buf, size,
907 sb_error.ref());
908 } else {
909 sb_error.SetErrorString("process is running");
911 } else {
912 sb_error.SetErrorString("SBProcess is invalid");
914 return bytes_read;
917 uint64_t SBProcess::ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size,
918 lldb::SBError &sb_error) {
919 LLDB_RECORD_METHOD(uint64_t, SBProcess, ReadUnsignedFromMemory,
920 (lldb::addr_t, uint32_t, lldb::SBError &), addr, byte_size,
921 sb_error);
923 uint64_t value = 0;
924 ProcessSP process_sp(GetSP());
925 if (process_sp) {
926 Process::StopLocker stop_locker;
927 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
928 std::lock_guard<std::recursive_mutex> guard(
929 process_sp->GetTarget().GetAPIMutex());
930 value = process_sp->ReadUnsignedIntegerFromMemory(addr, byte_size, 0,
931 sb_error.ref());
932 } else {
933 sb_error.SetErrorString("process is running");
935 } else {
936 sb_error.SetErrorString("SBProcess is invalid");
938 return value;
941 lldb::addr_t SBProcess::ReadPointerFromMemory(addr_t addr,
942 lldb::SBError &sb_error) {
943 LLDB_RECORD_METHOD(lldb::addr_t, SBProcess, ReadPointerFromMemory,
944 (lldb::addr_t, lldb::SBError &), addr, sb_error);
946 lldb::addr_t ptr = LLDB_INVALID_ADDRESS;
947 ProcessSP process_sp(GetSP());
948 if (process_sp) {
949 Process::StopLocker stop_locker;
950 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
951 std::lock_guard<std::recursive_mutex> guard(
952 process_sp->GetTarget().GetAPIMutex());
953 ptr = process_sp->ReadPointerFromMemory(addr, sb_error.ref());
954 } else {
955 sb_error.SetErrorString("process is running");
957 } else {
958 sb_error.SetErrorString("SBProcess is invalid");
960 return ptr;
963 size_t SBProcess::WriteMemory(addr_t addr, const void *src, size_t src_len,
964 SBError &sb_error) {
965 LLDB_RECORD_DUMMY(size_t, SBProcess, WriteMemory,
966 (lldb::addr_t, const void *, size_t, lldb::SBError &), addr,
967 src, src_len, sb_error);
969 size_t bytes_written = 0;
971 ProcessSP process_sp(GetSP());
973 if (process_sp) {
974 Process::StopLocker stop_locker;
975 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
976 std::lock_guard<std::recursive_mutex> guard(
977 process_sp->GetTarget().GetAPIMutex());
978 bytes_written =
979 process_sp->WriteMemory(addr, src, src_len, sb_error.ref());
980 } else {
981 sb_error.SetErrorString("process is running");
985 return bytes_written;
988 bool SBProcess::GetDescription(SBStream &description) {
989 LLDB_RECORD_METHOD(bool, SBProcess, GetDescription, (lldb::SBStream &),
990 description);
992 Stream &strm = description.ref();
994 ProcessSP process_sp(GetSP());
995 if (process_sp) {
996 char path[PATH_MAX];
997 GetTarget().GetExecutable().GetPath(path, sizeof(path));
998 Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
999 const char *exe_name = nullptr;
1000 if (exe_module)
1001 exe_name = exe_module->GetFileSpec().GetFilename().AsCString();
1003 strm.Printf("SBProcess: pid = %" PRIu64 ", state = %s, threads = %d%s%s",
1004 process_sp->GetID(), lldb_private::StateAsCString(GetState()),
1005 GetNumThreads(), exe_name ? ", executable = " : "",
1006 exe_name ? exe_name : "");
1007 } else
1008 strm.PutCString("No value");
1010 return true;
1013 uint32_t
1014 SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const {
1015 LLDB_RECORD_METHOD_CONST(uint32_t, SBProcess,
1016 GetNumSupportedHardwareWatchpoints,
1017 (lldb::SBError &), sb_error);
1019 uint32_t num = 0;
1020 ProcessSP process_sp(GetSP());
1021 if (process_sp) {
1022 std::lock_guard<std::recursive_mutex> guard(
1023 process_sp->GetTarget().GetAPIMutex());
1024 sb_error.SetError(process_sp->GetWatchpointSupportInfo(num));
1025 } else {
1026 sb_error.SetErrorString("SBProcess is invalid");
1028 return num;
1031 uint32_t SBProcess::LoadImage(lldb::SBFileSpec &sb_remote_image_spec,
1032 lldb::SBError &sb_error) {
1033 LLDB_RECORD_METHOD(uint32_t, SBProcess, LoadImage,
1034 (lldb::SBFileSpec &, lldb::SBError &),
1035 sb_remote_image_spec, sb_error);
1037 return LoadImage(SBFileSpec(), sb_remote_image_spec, sb_error);
1040 uint32_t SBProcess::LoadImage(const lldb::SBFileSpec &sb_local_image_spec,
1041 const lldb::SBFileSpec &sb_remote_image_spec,
1042 lldb::SBError &sb_error) {
1043 LLDB_RECORD_METHOD(
1044 uint32_t, SBProcess, LoadImage,
1045 (const lldb::SBFileSpec &, const lldb::SBFileSpec &, lldb::SBError &),
1046 sb_local_image_spec, sb_remote_image_spec, sb_error);
1048 ProcessSP process_sp(GetSP());
1049 if (process_sp) {
1050 Process::StopLocker stop_locker;
1051 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1052 std::lock_guard<std::recursive_mutex> guard(
1053 process_sp->GetTarget().GetAPIMutex());
1054 PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
1055 return platform_sp->LoadImage(process_sp.get(), *sb_local_image_spec,
1056 *sb_remote_image_spec, sb_error.ref());
1057 } else {
1058 sb_error.SetErrorString("process is running");
1060 } else {
1061 sb_error.SetErrorString("process is invalid");
1063 return LLDB_INVALID_IMAGE_TOKEN;
1066 uint32_t SBProcess::LoadImageUsingPaths(const lldb::SBFileSpec &image_spec,
1067 SBStringList &paths,
1068 lldb::SBFileSpec &loaded_path,
1069 lldb::SBError &error) {
1070 LLDB_RECORD_METHOD(uint32_t, SBProcess, LoadImageUsingPaths,
1071 (const lldb::SBFileSpec &, lldb::SBStringList &,
1072 lldb::SBFileSpec &, lldb::SBError &),
1073 image_spec, paths, loaded_path, error);
1075 ProcessSP process_sp(GetSP());
1076 if (process_sp) {
1077 Process::StopLocker stop_locker;
1078 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1079 std::lock_guard<std::recursive_mutex> guard(
1080 process_sp->GetTarget().GetAPIMutex());
1081 PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
1082 size_t num_paths = paths.GetSize();
1083 std::vector<std::string> paths_vec;
1084 paths_vec.reserve(num_paths);
1085 for (size_t i = 0; i < num_paths; i++)
1086 paths_vec.push_back(paths.GetStringAtIndex(i));
1087 FileSpec loaded_spec;
1089 uint32_t token = platform_sp->LoadImageUsingPaths(
1090 process_sp.get(), *image_spec, paths_vec, error.ref(), &loaded_spec);
1091 if (token != LLDB_INVALID_IMAGE_TOKEN)
1092 loaded_path = loaded_spec;
1093 return token;
1094 } else {
1095 error.SetErrorString("process is running");
1097 } else {
1098 error.SetErrorString("process is invalid");
1101 return LLDB_INVALID_IMAGE_TOKEN;
1104 lldb::SBError SBProcess::UnloadImage(uint32_t image_token) {
1105 LLDB_RECORD_METHOD(lldb::SBError, SBProcess, UnloadImage, (uint32_t),
1106 image_token);
1108 lldb::SBError sb_error;
1109 ProcessSP process_sp(GetSP());
1110 if (process_sp) {
1111 Process::StopLocker stop_locker;
1112 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1113 std::lock_guard<std::recursive_mutex> guard(
1114 process_sp->GetTarget().GetAPIMutex());
1115 PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
1116 sb_error.SetError(
1117 platform_sp->UnloadImage(process_sp.get(), image_token));
1118 } else {
1119 sb_error.SetErrorString("process is running");
1121 } else
1122 sb_error.SetErrorString("invalid process");
1123 return LLDB_RECORD_RESULT(sb_error);
1126 lldb::SBError SBProcess::SendEventData(const char *event_data) {
1127 LLDB_RECORD_METHOD(lldb::SBError, SBProcess, SendEventData, (const char *),
1128 event_data);
1130 lldb::SBError sb_error;
1131 ProcessSP process_sp(GetSP());
1132 if (process_sp) {
1133 Process::StopLocker stop_locker;
1134 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1135 std::lock_guard<std::recursive_mutex> guard(
1136 process_sp->GetTarget().GetAPIMutex());
1137 sb_error.SetError(process_sp->SendEventData(event_data));
1138 } else {
1139 sb_error.SetErrorString("process is running");
1141 } else
1142 sb_error.SetErrorString("invalid process");
1143 return LLDB_RECORD_RESULT(sb_error);
1146 uint32_t SBProcess::GetNumExtendedBacktraceTypes() {
1147 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetNumExtendedBacktraceTypes);
1149 ProcessSP process_sp(GetSP());
1150 if (process_sp && process_sp->GetSystemRuntime()) {
1151 SystemRuntime *runtime = process_sp->GetSystemRuntime();
1152 return runtime->GetExtendedBacktraceTypes().size();
1154 return 0;
1157 const char *SBProcess::GetExtendedBacktraceTypeAtIndex(uint32_t idx) {
1158 LLDB_RECORD_METHOD(const char *, SBProcess, GetExtendedBacktraceTypeAtIndex,
1159 (uint32_t), idx);
1161 ProcessSP process_sp(GetSP());
1162 if (process_sp && process_sp->GetSystemRuntime()) {
1163 SystemRuntime *runtime = process_sp->GetSystemRuntime();
1164 const std::vector<ConstString> &names =
1165 runtime->GetExtendedBacktraceTypes();
1166 if (idx < names.size()) {
1167 return names[idx].AsCString();
1170 return nullptr;
1173 SBThreadCollection SBProcess::GetHistoryThreads(addr_t addr) {
1174 LLDB_RECORD_METHOD(lldb::SBThreadCollection, SBProcess, GetHistoryThreads,
1175 (lldb::addr_t), addr);
1177 ProcessSP process_sp(GetSP());
1178 SBThreadCollection threads;
1179 if (process_sp) {
1180 threads = SBThreadCollection(process_sp->GetHistoryThreads(addr));
1182 return LLDB_RECORD_RESULT(threads);
1185 bool SBProcess::IsInstrumentationRuntimePresent(
1186 InstrumentationRuntimeType type) {
1187 LLDB_RECORD_METHOD(bool, SBProcess, IsInstrumentationRuntimePresent,
1188 (lldb::InstrumentationRuntimeType), type);
1190 ProcessSP process_sp(GetSP());
1191 if (!process_sp)
1192 return false;
1194 std::lock_guard<std::recursive_mutex> guard(
1195 process_sp->GetTarget().GetAPIMutex());
1197 InstrumentationRuntimeSP runtime_sp =
1198 process_sp->GetInstrumentationRuntime(type);
1200 if (!runtime_sp.get())
1201 return false;
1203 return runtime_sp->IsActive();
1206 lldb::SBError SBProcess::SaveCore(const char *file_name) {
1207 LLDB_RECORD_METHOD(lldb::SBError, SBProcess, SaveCore, (const char *),
1208 file_name);
1210 lldb::SBError error;
1211 ProcessSP process_sp(GetSP());
1212 if (!process_sp) {
1213 error.SetErrorString("SBProcess is invalid");
1214 return LLDB_RECORD_RESULT(error);
1217 std::lock_guard<std::recursive_mutex> guard(
1218 process_sp->GetTarget().GetAPIMutex());
1220 if (process_sp->GetState() != eStateStopped) {
1221 error.SetErrorString("the process is not stopped");
1222 return LLDB_RECORD_RESULT(error);
1225 FileSpec core_file(file_name);
1226 error.ref() = PluginManager::SaveCore(process_sp, core_file);
1227 return LLDB_RECORD_RESULT(error);
1230 lldb::SBError
1231 SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr,
1232 SBMemoryRegionInfo &sb_region_info) {
1233 LLDB_RECORD_METHOD(lldb::SBError, SBProcess, GetMemoryRegionInfo,
1234 (lldb::addr_t, lldb::SBMemoryRegionInfo &), load_addr,
1235 sb_region_info);
1237 lldb::SBError sb_error;
1238 ProcessSP process_sp(GetSP());
1239 if (process_sp) {
1240 Process::StopLocker stop_locker;
1241 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
1242 std::lock_guard<std::recursive_mutex> guard(
1243 process_sp->GetTarget().GetAPIMutex());
1245 sb_error.ref() =
1246 process_sp->GetMemoryRegionInfo(load_addr, sb_region_info.ref());
1247 } else {
1248 sb_error.SetErrorString("process is running");
1250 } else {
1251 sb_error.SetErrorString("SBProcess is invalid");
1253 return LLDB_RECORD_RESULT(sb_error);
1256 lldb::SBMemoryRegionInfoList SBProcess::GetMemoryRegions() {
1257 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBMemoryRegionInfoList, SBProcess,
1258 GetMemoryRegions);
1260 lldb::SBMemoryRegionInfoList sb_region_list;
1262 ProcessSP process_sp(GetSP());
1263 Process::StopLocker stop_locker;
1264 if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock())) {
1265 std::lock_guard<std::recursive_mutex> guard(
1266 process_sp->GetTarget().GetAPIMutex());
1268 process_sp->GetMemoryRegions(sb_region_list.ref());
1271 return LLDB_RECORD_RESULT(sb_region_list);
1274 lldb::SBProcessInfo SBProcess::GetProcessInfo() {
1275 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcessInfo, SBProcess, GetProcessInfo);
1277 lldb::SBProcessInfo sb_proc_info;
1278 ProcessSP process_sp(GetSP());
1279 ProcessInstanceInfo proc_info;
1280 if (process_sp && process_sp->GetProcessInfo(proc_info)) {
1281 sb_proc_info.SetProcessInfo(proc_info);
1283 return LLDB_RECORD_RESULT(sb_proc_info);
1286 namespace lldb_private {
1287 namespace repro {
1289 template <>
1290 void RegisterMethods<SBProcess>(Registry &R) {
1291 LLDB_REGISTER_CONSTRUCTOR(SBProcess, ());
1292 LLDB_REGISTER_CONSTRUCTOR(SBProcess, (const lldb::SBProcess &));
1293 LLDB_REGISTER_CONSTRUCTOR(SBProcess, (const lldb::ProcessSP &));
1294 LLDB_REGISTER_METHOD(const lldb::SBProcess &,
1295 SBProcess, operator=,(const lldb::SBProcess &));
1296 LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess,
1297 GetBroadcasterClassName, ());
1298 LLDB_REGISTER_METHOD(const char *, SBProcess, GetPluginName, ());
1299 LLDB_REGISTER_METHOD(const char *, SBProcess, GetShortPluginName, ());
1300 LLDB_REGISTER_METHOD(void, SBProcess, Clear, ());
1301 LLDB_REGISTER_METHOD_CONST(bool, SBProcess, IsValid, ());
1302 LLDB_REGISTER_METHOD_CONST(bool, SBProcess, operator bool, ());
1303 LLDB_REGISTER_METHOD(bool, SBProcess, RemoteLaunch,
1304 (const char **, const char **, const char *,
1305 const char *, const char *, const char *, uint32_t,
1306 bool, lldb::SBError &));
1307 LLDB_REGISTER_METHOD(bool, SBProcess, RemoteAttachToProcessWithID,
1308 (lldb::pid_t, lldb::SBError &));
1309 LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetNumThreads, ());
1310 LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBProcess, GetSelectedThread,
1311 ());
1312 LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, CreateOSPluginThread,
1313 (lldb::tid_t, lldb::addr_t));
1314 LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBProcess, GetTarget, ());
1315 LLDB_REGISTER_METHOD(size_t, SBProcess, PutSTDIN, (const char *, size_t));
1316 LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t));
1317 LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t));
1318 LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData,
1319 (char *, size_t));
1320 LLDB_REGISTER_METHOD(lldb::SBTrace, SBProcess, StartTrace,
1321 (lldb::SBTraceOptions &, lldb::SBError &));
1322 LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
1323 (const lldb::SBEvent &, FILE *));
1324 LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
1325 (const lldb::SBEvent &, FileSP));
1326 LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
1327 (const lldb::SBEvent &, SBFile));
1328 LLDB_REGISTER_METHOD(
1329 void, SBProcess, AppendEventStateReport,
1330 (const lldb::SBEvent &, lldb::SBCommandReturnObject &));
1331 LLDB_REGISTER_METHOD(bool, SBProcess, SetSelectedThread,
1332 (const lldb::SBThread &));
1333 LLDB_REGISTER_METHOD(bool, SBProcess, SetSelectedThreadByID, (lldb::tid_t));
1334 LLDB_REGISTER_METHOD(bool, SBProcess, SetSelectedThreadByIndexID,
1335 (uint32_t));
1336 LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, GetThreadAtIndex, (size_t));
1337 LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetNumQueues, ());
1338 LLDB_REGISTER_METHOD(lldb::SBQueue, SBProcess, GetQueueAtIndex, (size_t));
1339 LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetStopID, (bool));
1340 LLDB_REGISTER_METHOD(lldb::SBEvent, SBProcess, GetStopEventForStopID,
1341 (uint32_t));
1342 LLDB_REGISTER_METHOD(lldb::StateType, SBProcess, GetState, ());
1343 LLDB_REGISTER_METHOD(int, SBProcess, GetExitStatus, ());
1344 LLDB_REGISTER_METHOD(const char *, SBProcess, GetExitDescription, ());
1345 LLDB_REGISTER_METHOD(lldb::pid_t, SBProcess, GetProcessID, ());
1346 LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetUniqueID, ());
1347 LLDB_REGISTER_METHOD_CONST(lldb::ByteOrder, SBProcess, GetByteOrder, ());
1348 LLDB_REGISTER_METHOD_CONST(uint32_t, SBProcess, GetAddressByteSize, ());
1349 LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Continue, ());
1350 LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Destroy, ());
1351 LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Stop, ());
1352 LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Kill, ());
1353 LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Detach, ());
1354 LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Detach, (bool));
1355 LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Signal, (int));
1356 LLDB_REGISTER_METHOD(lldb::SBUnixSignals, SBProcess, GetUnixSignals, ());
1357 LLDB_REGISTER_METHOD(void, SBProcess, SendAsyncInterrupt, ());
1358 LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, GetThreadByID,
1359 (lldb::tid_t));
1360 LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, GetThreadByIndexID,
1361 (uint32_t));
1362 LLDB_REGISTER_STATIC_METHOD(lldb::StateType, SBProcess, GetStateFromEvent,
1363 (const lldb::SBEvent &));
1364 LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, GetRestartedFromEvent,
1365 (const lldb::SBEvent &));
1366 LLDB_REGISTER_STATIC_METHOD(size_t, SBProcess,
1367 GetNumRestartedReasonsFromEvent,
1368 (const lldb::SBEvent &));
1369 LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess,
1370 GetRestartedReasonAtIndexFromEvent,
1371 (const lldb::SBEvent &, size_t));
1372 LLDB_REGISTER_STATIC_METHOD(lldb::SBProcess, SBProcess, GetProcessFromEvent,
1373 (const lldb::SBEvent &));
1374 LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, GetInterruptedFromEvent,
1375 (const lldb::SBEvent &));
1376 LLDB_REGISTER_STATIC_METHOD(lldb::SBStructuredData, SBProcess,
1377 GetStructuredDataFromEvent,
1378 (const lldb::SBEvent &));
1379 LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, EventIsProcessEvent,
1380 (const lldb::SBEvent &));
1381 LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, EventIsStructuredDataEvent,
1382 (const lldb::SBEvent &));
1383 LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBProcess, GetBroadcaster,
1384 ());
1385 LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess, GetBroadcasterClass,
1386 ());
1387 LLDB_REGISTER_METHOD(uint64_t, SBProcess, ReadUnsignedFromMemory,
1388 (lldb::addr_t, uint32_t, lldb::SBError &));
1389 LLDB_REGISTER_METHOD(lldb::addr_t, SBProcess, ReadPointerFromMemory,
1390 (lldb::addr_t, lldb::SBError &));
1391 LLDB_REGISTER_METHOD(bool, SBProcess, GetDescription, (lldb::SBStream &));
1392 LLDB_REGISTER_METHOD_CONST(uint32_t, SBProcess,
1393 GetNumSupportedHardwareWatchpoints,
1394 (lldb::SBError &));
1395 LLDB_REGISTER_METHOD(uint32_t, SBProcess, LoadImage,
1396 (lldb::SBFileSpec &, lldb::SBError &));
1397 LLDB_REGISTER_METHOD(
1398 uint32_t, SBProcess, LoadImage,
1399 (const lldb::SBFileSpec &, const lldb::SBFileSpec &, lldb::SBError &));
1400 LLDB_REGISTER_METHOD(uint32_t, SBProcess, LoadImageUsingPaths,
1401 (const lldb::SBFileSpec &, lldb::SBStringList &,
1402 lldb::SBFileSpec &, lldb::SBError &));
1403 LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, UnloadImage, (uint32_t));
1404 LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, SendEventData,
1405 (const char *));
1406 LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetNumExtendedBacktraceTypes, ());
1407 LLDB_REGISTER_METHOD(const char *, SBProcess,
1408 GetExtendedBacktraceTypeAtIndex, (uint32_t));
1409 LLDB_REGISTER_METHOD(lldb::SBThreadCollection, SBProcess, GetHistoryThreads,
1410 (lldb::addr_t));
1411 LLDB_REGISTER_METHOD(bool, SBProcess, IsInstrumentationRuntimePresent,
1412 (lldb::InstrumentationRuntimeType));
1413 LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, SaveCore, (const char *));
1414 LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, GetMemoryRegionInfo,
1415 (lldb::addr_t, lldb::SBMemoryRegionInfo &));
1416 LLDB_REGISTER_METHOD(lldb::SBMemoryRegionInfoList, SBProcess,
1417 GetMemoryRegions, ());
1418 LLDB_REGISTER_METHOD(lldb::SBProcessInfo, SBProcess, GetProcessInfo, ());