1 //===-- SBTarget.cpp --------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/API/SBTarget.h"
12 #include "lldb/lldb-public.h"
14 #include "lldb/API/SBBreakpoint.h"
15 #include "lldb/API/SBDebugger.h"
16 #include "lldb/API/SBEvent.h"
17 #include "lldb/API/SBExpressionOptions.h"
18 #include "lldb/API/SBFileSpec.h"
19 #include "lldb/API/SBListener.h"
20 #include "lldb/API/SBModule.h"
21 #include "lldb/API/SBModuleSpec.h"
22 #include "lldb/API/SBProcess.h"
23 #include "lldb/API/SBSourceManager.h"
24 #include "lldb/API/SBStream.h"
25 #include "lldb/API/SBStringList.h"
26 #include "lldb/API/SBSymbolContextList.h"
27 #include "lldb/Breakpoint/BreakpointID.h"
28 #include "lldb/Breakpoint/BreakpointIDList.h"
29 #include "lldb/Breakpoint/BreakpointList.h"
30 #include "lldb/Breakpoint/BreakpointLocation.h"
31 #include "lldb/Core/Address.h"
32 #include "lldb/Core/AddressResolver.h"
33 #include "lldb/Core/AddressResolverName.h"
34 #include "lldb/Core/ArchSpec.h"
35 #include "lldb/Core/Debugger.h"
36 #include "lldb/Core/Disassembler.h"
37 #include "lldb/Core/Module.h"
38 #include "lldb/Core/ModuleSpec.h"
39 #include "lldb/Core/STLUtils.h"
40 #include "lldb/Core/SearchFilter.h"
41 #include "lldb/Core/Section.h"
42 #include "lldb/Core/ValueObjectConstResult.h"
43 #include "lldb/Core/ValueObjectList.h"
44 #include "lldb/Core/ValueObjectVariable.h"
45 #include "lldb/Host/Host.h"
46 #include "lldb/Interpreter/Args.h"
47 #include "lldb/Symbol/ClangASTContext.h"
48 #include "lldb/Symbol/DeclVendor.h"
49 #include "lldb/Symbol/ObjectFile.h"
50 #include "lldb/Symbol/SymbolFile.h"
51 #include "lldb/Symbol/SymbolVendor.h"
52 #include "lldb/Symbol/VariableList.h"
53 #include "lldb/Target/ABI.h"
54 #include "lldb/Target/Language.h"
55 #include "lldb/Target/LanguageRuntime.h"
56 #include "lldb/Target/ObjCLanguageRuntime.h"
57 #include "lldb/Target/Process.h"
58 #include "lldb/Target/StackFrame.h"
59 #include "lldb/Target/Target.h"
60 #include "lldb/Target/TargetList.h"
61 #include "lldb/Utility/FileSpec.h"
62 #include "lldb/Utility/Log.h"
63 #include "lldb/Utility/RegularExpression.h"
65 #include "../source/Commands/CommandObjectBreakpoint.h"
66 #include "lldb/Interpreter/CommandReturnObject.h"
67 #include "llvm/Support/PrettyStackTrace.h"
68 #include "llvm/Support/Regex.h"
71 using namespace lldb_private;
73 #define DEFAULT_DISASM_BYTE_SIZE 32
77 Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) {
78 std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex());
80 auto process_sp = target.GetProcessSP();
82 const auto state = process_sp->GetState();
83 if (process_sp->IsAlive() && state == eStateConnected) {
84 // If we are already connected, then we have already specified the
85 // listener, so if a valid listener is supplied, we need to error out
86 // to let the client know.
87 if (attach_info.GetListener())
88 return Status("process is connected and already has a listener, pass "
93 return target.Attach(attach_info, nullptr);
98 //----------------------------------------------------------------------
99 // SBTarget constructor
100 //----------------------------------------------------------------------
101 SBTarget::SBTarget() : m_opaque_sp() {}
103 SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) {}
105 SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) {}
107 const SBTarget &SBTarget::operator=(const SBTarget &rhs) {
109 m_opaque_sp = rhs.m_opaque_sp;
113 //----------------------------------------------------------------------
115 //----------------------------------------------------------------------
116 SBTarget::~SBTarget() {}
118 bool SBTarget::EventIsTargetEvent(const SBEvent &event) {
119 return Target::TargetEventData::GetEventDataFromEvent(event.get()) != NULL;
122 SBTarget SBTarget::GetTargetFromEvent(const SBEvent &event) {
123 return Target::TargetEventData::GetTargetFromEvent(event.get());
126 uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent &event) {
127 const ModuleList module_list =
128 Target::TargetEventData::GetModuleListFromEvent(event.get());
129 return module_list.GetSize();
132 SBModule SBTarget::GetModuleAtIndexFromEvent(const uint32_t idx,
133 const SBEvent &event) {
134 const ModuleList module_list =
135 Target::TargetEventData::GetModuleListFromEvent(event.get());
136 return SBModule(module_list.GetModuleAtIndex(idx));
139 const char *SBTarget::GetBroadcasterClassName() {
140 return Target::GetStaticBroadcasterClass().AsCString();
143 bool SBTarget::IsValid() const {
144 return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
147 SBProcess SBTarget::GetProcess() {
148 SBProcess sb_process;
149 ProcessSP process_sp;
150 TargetSP target_sp(GetSP());
152 process_sp = target_sp->GetProcessSP();
153 sb_process.SetSP(process_sp);
156 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
158 log->Printf("SBTarget(%p)::GetProcess () => SBProcess(%p)",
159 static_cast<void *>(target_sp.get()),
160 static_cast<void *>(process_sp.get()));
165 SBPlatform SBTarget::GetPlatform() {
166 TargetSP target_sp(GetSP());
171 platform.m_opaque_sp = target_sp->GetPlatform();
176 SBDebugger SBTarget::GetDebugger() const {
178 TargetSP target_sp(GetSP());
180 debugger.reset(target_sp->GetDebugger().shared_from_this());
184 SBProcess SBTarget::LoadCore(const char *core_file) {
185 SBProcess sb_process;
186 TargetSP target_sp(GetSP());
188 FileSpec filespec(core_file, true);
189 ProcessSP process_sp(target_sp->CreateProcess(
190 target_sp->GetDebugger().GetListener(), "", &filespec));
192 process_sp->LoadCore();
193 sb_process.SetSP(process_sp);
199 SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp,
200 const char *working_directory) {
201 char *stdin_path = NULL;
202 char *stdout_path = NULL;
203 char *stderr_path = NULL;
204 uint32_t launch_flags = 0;
205 bool stop_at_entry = false;
207 SBListener listener = GetDebugger().GetListener();
208 return Launch(listener, argv, envp, stdin_path, stdout_path, stderr_path,
209 working_directory, launch_flags, stop_at_entry, error);
212 SBError SBTarget::Install() {
214 TargetSP target_sp(GetSP());
216 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
217 sb_error.ref() = target_sp->Install(NULL);
222 SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
223 char const **envp, const char *stdin_path,
224 const char *stdout_path, const char *stderr_path,
225 const char *working_directory,
226 uint32_t launch_flags, // See LaunchFlags
227 bool stop_at_entry, lldb::SBError &error) {
228 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
230 SBProcess sb_process;
231 ProcessSP process_sp;
232 TargetSP target_sp(GetSP());
235 log->Printf("SBTarget(%p)::Launch (argv=%p, envp=%p, stdin=%s, stdout=%s, "
236 "stderr=%s, working-dir=%s, launch_flags=0x%x, "
237 "stop_at_entry=%i, &error (%p))...",
238 static_cast<void *>(target_sp.get()), static_cast<void *>(argv),
239 static_cast<void *>(envp), stdin_path ? stdin_path : "NULL",
240 stdout_path ? stdout_path : "NULL",
241 stderr_path ? stderr_path : "NULL",
242 working_directory ? working_directory : "NULL", launch_flags,
243 stop_at_entry, static_cast<void *>(error.get()));
246 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
249 launch_flags |= eLaunchFlagStopAtEntry;
251 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
252 launch_flags |= eLaunchFlagDisableASLR;
254 StateType state = eStateInvalid;
255 process_sp = target_sp->GetProcessSP();
257 state = process_sp->GetState();
259 if (process_sp->IsAlive() && state != eStateConnected) {
260 if (state == eStateAttaching)
261 error.SetErrorString("process attach is in progress");
263 error.SetErrorString("a process is already being debugged");
268 if (state == eStateConnected) {
269 // If we are already connected, then we have already specified the
270 // listener, so if a valid listener is supplied, we need to error out
271 // to let the client know.
272 if (listener.IsValid()) {
273 error.SetErrorString("process is connected and already has a listener, "
274 "pass empty listener");
279 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
280 launch_flags |= eLaunchFlagDisableSTDIO;
282 ProcessLaunchInfo launch_info(
283 FileSpec{stdin_path, false}, FileSpec{stdout_path, false},
284 FileSpec{stderr_path, false}, FileSpec{working_directory, false},
287 Module *exe_module = target_sp->GetExecutableModulePointer();
289 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
291 launch_info.GetArguments().AppendArguments(argv);
293 launch_info.GetEnvironmentEntries().SetArguments(envp);
295 if (listener.IsValid())
296 launch_info.SetListener(listener.GetSP());
298 error.SetError(target_sp->Launch(launch_info, NULL));
300 sb_process.SetSP(target_sp->GetProcessSP());
302 error.SetErrorString("SBTarget is invalid");
305 log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API);
307 log->Printf("SBTarget(%p)::Launch (...) => SBProcess(%p), SBError(%s)",
308 static_cast<void *>(target_sp.get()),
309 static_cast<void *>(sb_process.GetSP().get()),
315 SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) {
316 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
318 SBProcess sb_process;
319 TargetSP target_sp(GetSP());
322 log->Printf("SBTarget(%p)::Launch (launch_info, error)...",
323 static_cast<void *>(target_sp.get()));
326 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
327 StateType state = eStateInvalid;
329 ProcessSP process_sp = target_sp->GetProcessSP();
331 state = process_sp->GetState();
333 if (process_sp->IsAlive() && state != eStateConnected) {
334 if (state == eStateAttaching)
335 error.SetErrorString("process attach is in progress");
337 error.SetErrorString("a process is already being debugged");
343 lldb_private::ProcessLaunchInfo &launch_info = sb_launch_info.ref();
345 if (!launch_info.GetExecutableFile()) {
346 Module *exe_module = target_sp->GetExecutableModulePointer();
348 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
351 const ArchSpec &arch_spec = target_sp->GetArchitecture();
352 if (arch_spec.IsValid())
353 launch_info.GetArchitecture() = arch_spec;
355 error.SetError(target_sp->Launch(launch_info, NULL));
356 sb_process.SetSP(target_sp->GetProcessSP());
358 error.SetErrorString("SBTarget is invalid");
361 log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API);
363 log->Printf("SBTarget(%p)::Launch (...) => SBProcess(%p)",
364 static_cast<void *>(target_sp.get()),
365 static_cast<void *>(sb_process.GetSP().get()));
370 lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) {
371 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
373 SBProcess sb_process;
374 TargetSP target_sp(GetSP());
377 log->Printf("SBTarget(%p)::Attach (sb_attach_info, error)...",
378 static_cast<void *>(target_sp.get()));
381 ProcessAttachInfo &attach_info = sb_attach_info.ref();
382 if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid()) {
383 PlatformSP platform_sp = target_sp->GetPlatform();
384 // See if we can pre-verify if a process exists or not
385 if (platform_sp && platform_sp->IsConnected()) {
386 lldb::pid_t attach_pid = attach_info.GetProcessID();
387 ProcessInstanceInfo instance_info;
388 if (platform_sp->GetProcessInfo(attach_pid, instance_info)) {
389 attach_info.SetUserID(instance_info.GetEffectiveUserID());
391 error.ref().SetErrorStringWithFormat(
392 "no process found with process ID %" PRIu64, attach_pid);
394 log->Printf("SBTarget(%p)::Attach (...) => error %s",
395 static_cast<void *>(target_sp.get()),
402 error.SetError(AttachToProcess(attach_info, *target_sp));
404 sb_process.SetSP(target_sp->GetProcessSP());
406 error.SetErrorString("SBTarget is invalid");
410 log->Printf("SBTarget(%p)::Attach (...) => SBProcess(%p)",
411 static_cast<void *>(target_sp.get()),
412 static_cast<void *>(sb_process.GetSP().get()));
417 #if defined(__APPLE__)
419 lldb::SBProcess SBTarget::AttachToProcessWithID(SBListener &listener,
421 lldb::SBError &error) {
422 return AttachToProcessWithID(listener, (lldb::pid_t)pid, error);
425 #endif // #if defined(__APPLE__)
427 lldb::SBProcess SBTarget::AttachToProcessWithID(
428 SBListener &listener,
429 lldb::pid_t pid, // The process ID to attach to
430 SBError &error // An error explaining what went wrong if attach fails
432 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
434 SBProcess sb_process;
435 TargetSP target_sp(GetSP());
438 log->Printf("SBTarget(%p)::%s (listener, pid=%" PRId64 ", error)...",
439 static_cast<void *>(target_sp.get()), __FUNCTION__, pid);
442 ProcessAttachInfo attach_info;
443 attach_info.SetProcessID(pid);
444 if (listener.IsValid())
445 attach_info.SetListener(listener.GetSP());
447 ProcessInstanceInfo instance_info;
448 if (target_sp->GetPlatform()->GetProcessInfo(pid, instance_info))
449 attach_info.SetUserID(instance_info.GetEffectiveUserID());
451 error.SetError(AttachToProcess(attach_info, *target_sp));
453 sb_process.SetSP(target_sp->GetProcessSP());
455 error.SetErrorString("SBTarget is invalid");
458 log->Printf("SBTarget(%p)::%s (...) => SBProcess(%p)",
459 static_cast<void *>(target_sp.get()), __FUNCTION__,
460 static_cast<void *>(sb_process.GetSP().get()));
464 lldb::SBProcess SBTarget::AttachToProcessWithName(
465 SBListener &listener,
466 const char *name, // basename of process to attach to
467 bool wait_for, // if true wait for a new instance of "name" to be launched
468 SBError &error // An error explaining what went wrong if attach fails
470 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
472 SBProcess sb_process;
473 TargetSP target_sp(GetSP());
476 log->Printf("SBTarget(%p)::%s (listener, name=%s, wait_for=%s, error)...",
477 static_cast<void *>(target_sp.get()), __FUNCTION__, name,
478 wait_for ? "true" : "false");
480 if (name && target_sp) {
481 ProcessAttachInfo attach_info;
482 attach_info.GetExecutableFile().SetFile(name, false);
483 attach_info.SetWaitForLaunch(wait_for);
484 if (listener.IsValid())
485 attach_info.SetListener(listener.GetSP());
487 error.SetError(AttachToProcess(attach_info, *target_sp));
489 sb_process.SetSP(target_sp->GetProcessSP());
491 error.SetErrorString("SBTarget is invalid");
494 log->Printf("SBTarget(%p)::%s (...) => SBProcess(%p)",
495 static_cast<void *>(target_sp.get()), __FUNCTION__,
496 static_cast<void *>(sb_process.GetSP().get()));
500 lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url,
501 const char *plugin_name,
503 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
505 SBProcess sb_process;
506 ProcessSP process_sp;
507 TargetSP target_sp(GetSP());
510 log->Printf("SBTarget(%p)::ConnectRemote (listener, url=%s, "
511 "plugin_name=%s, error)...",
512 static_cast<void *>(target_sp.get()), url, plugin_name);
515 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
516 if (listener.IsValid())
518 target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, NULL);
520 process_sp = target_sp->CreateProcess(
521 target_sp->GetDebugger().GetListener(), plugin_name, NULL);
524 sb_process.SetSP(process_sp);
525 error.SetError(process_sp->ConnectRemote(NULL, url));
527 error.SetErrorString("unable to create lldb_private::Process");
530 error.SetErrorString("SBTarget is invalid");
534 log->Printf("SBTarget(%p)::ConnectRemote (...) => SBProcess(%p)",
535 static_cast<void *>(target_sp.get()),
536 static_cast<void *>(process_sp.get()));
540 SBFileSpec SBTarget::GetExecutable() {
542 SBFileSpec exe_file_spec;
543 TargetSP target_sp(GetSP());
545 Module *exe_module = target_sp->GetExecutableModulePointer();
547 exe_file_spec.SetFileSpec(exe_module->GetFileSpec());
550 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
552 log->Printf("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)",
553 static_cast<void *>(target_sp.get()),
554 static_cast<const void *>(exe_file_spec.get()));
557 return exe_file_spec;
560 bool SBTarget::operator==(const SBTarget &rhs) const {
561 return m_opaque_sp.get() == rhs.m_opaque_sp.get();
564 bool SBTarget::operator!=(const SBTarget &rhs) const {
565 return m_opaque_sp.get() != rhs.m_opaque_sp.get();
568 lldb::TargetSP SBTarget::GetSP() const { return m_opaque_sp; }
570 void SBTarget::SetSP(const lldb::TargetSP &target_sp) {
571 m_opaque_sp = target_sp;
574 lldb::SBAddress SBTarget::ResolveLoadAddress(lldb::addr_t vm_addr) {
575 lldb::SBAddress sb_addr;
576 Address &addr = sb_addr.ref();
577 TargetSP target_sp(GetSP());
579 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
580 if (target_sp->ResolveLoadAddress(vm_addr, addr))
584 // We have a load address that isn't in a section, just return an address
585 // with the offset filled in (the address) and the section set to NULL
586 addr.SetRawAddress(vm_addr);
590 lldb::SBAddress SBTarget::ResolveFileAddress(lldb::addr_t file_addr) {
591 lldb::SBAddress sb_addr;
592 Address &addr = sb_addr.ref();
593 TargetSP target_sp(GetSP());
595 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
596 if (target_sp->ResolveFileAddress(file_addr, addr))
600 addr.SetRawAddress(file_addr);
604 lldb::SBAddress SBTarget::ResolvePastLoadAddress(uint32_t stop_id,
605 lldb::addr_t vm_addr) {
606 lldb::SBAddress sb_addr;
607 Address &addr = sb_addr.ref();
608 TargetSP target_sp(GetSP());
610 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
611 if (target_sp->ResolveLoadAddress(vm_addr, addr))
615 // We have a load address that isn't in a section, just return an address
616 // with the offset filled in (the address) and the section set to NULL
617 addr.SetRawAddress(vm_addr);
622 SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr,
623 uint32_t resolve_scope) {
625 if (addr.IsValid()) {
626 TargetSP target_sp(GetSP());
628 target_sp->GetImages().ResolveSymbolContextForAddress(
629 addr.ref(), resolve_scope, sc.ref());
634 size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size,
635 lldb::SBError &error) {
637 size_t bytes_read = 0;
638 TargetSP target_sp(GetSP());
640 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
642 target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref());
644 sb_error.SetErrorString("invalid target");
650 SBBreakpoint SBTarget::BreakpointCreateByLocation(const char *file,
653 BreakpointCreateByLocation(SBFileSpec(file, false), line));
657 SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
659 return BreakpointCreateByLocation(sb_file_spec, line, 0);
663 SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
664 uint32_t line, lldb::addr_t offset) {
665 SBFileSpecList empty_list;
666 return BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list);
670 SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
671 uint32_t line, lldb::addr_t offset,
672 SBFileSpecList &sb_module_list) {
673 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
676 TargetSP target_sp(GetSP());
677 if (target_sp && line != 0) {
678 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
680 const LazyBool check_inlines = eLazyBoolCalculate;
681 const LazyBool skip_prologue = eLazyBoolCalculate;
682 const bool internal = false;
683 const bool hardware = false;
684 const LazyBool move_to_nearest_code = eLazyBoolCalculate;
685 const FileSpecList *module_list = nullptr;
686 if (sb_module_list.GetSize() > 0) {
687 module_list = sb_module_list.get();
689 sb_bp = target_sp->CreateBreakpoint(
690 module_list, *sb_file_spec, line, offset, check_inlines, skip_prologue,
691 internal, hardware, move_to_nearest_code);
696 sb_bp.GetDescription(sstr);
698 sb_file_spec->GetPath(path, sizeof(path));
699 log->Printf("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => "
700 "SBBreakpoint(%p): %s",
701 static_cast<void *>(target_sp.get()), path, line,
702 static_cast<void *>(sb_bp.GetSP().get()), sstr.GetData());
708 SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name,
709 const char *module_name) {
710 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
713 TargetSP target_sp(GetSP());
714 if (target_sp.get()) {
715 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
717 const bool internal = false;
718 const bool hardware = false;
719 const LazyBool skip_prologue = eLazyBoolCalculate;
720 const lldb::addr_t offset = 0;
721 if (module_name && module_name[0]) {
722 FileSpecList module_spec_list;
723 module_spec_list.Append(FileSpec(module_name, false));
724 sb_bp = target_sp->CreateBreakpoint(
725 &module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto,
726 eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
728 sb_bp = target_sp->CreateBreakpoint(
729 NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown,
730 offset, skip_prologue, internal, hardware);
735 log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", "
736 "module=\"%s\") => SBBreakpoint(%p)",
737 static_cast<void *>(target_sp.get()), symbol_name, module_name,
738 static_cast<void *>(sb_bp.GetSP().get()));
744 SBTarget::BreakpointCreateByName(const char *symbol_name,
745 const SBFileSpecList &module_list,
746 const SBFileSpecList &comp_unit_list) {
747 uint32_t name_type_mask = eFunctionNameTypeAuto;
748 return BreakpointCreateByName(symbol_name, name_type_mask,
749 eLanguageTypeUnknown, module_list,
753 lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
754 const char *symbol_name, uint32_t name_type_mask,
755 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
756 return BreakpointCreateByName(symbol_name, name_type_mask,
757 eLanguageTypeUnknown, module_list,
761 lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
762 const char *symbol_name, uint32_t name_type_mask,
763 LanguageType symbol_language, const SBFileSpecList &module_list,
764 const SBFileSpecList &comp_unit_list) {
765 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
768 TargetSP target_sp(GetSP());
769 if (target_sp && symbol_name && symbol_name[0]) {
770 const bool internal = false;
771 const bool hardware = false;
772 const LazyBool skip_prologue = eLazyBoolCalculate;
773 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
774 sb_bp = target_sp->CreateBreakpoint(
775 module_list.get(), comp_unit_list.get(), symbol_name, name_type_mask,
776 symbol_language, 0, skip_prologue, internal, hardware);
780 log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", "
781 "name_type: %d) => SBBreakpoint(%p)",
782 static_cast<void *>(target_sp.get()), symbol_name,
783 name_type_mask, static_cast<void *>(sb_bp.GetSP().get()));
788 lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
789 const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
790 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
791 return BreakpointCreateByNames(symbol_names, num_names, name_type_mask,
792 eLanguageTypeUnknown, module_list,
796 lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
797 const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
798 LanguageType symbol_language, const SBFileSpecList &module_list,
799 const SBFileSpecList &comp_unit_list) {
800 return BreakpointCreateByNames(symbol_names, num_names, name_type_mask,
801 eLanguageTypeUnknown, 0, module_list,
805 lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
806 const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
807 LanguageType symbol_language, lldb::addr_t offset,
808 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
809 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
812 TargetSP target_sp(GetSP());
813 if (target_sp && num_names > 0) {
814 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
815 const bool internal = false;
816 const bool hardware = false;
817 const LazyBool skip_prologue = eLazyBoolCalculate;
818 sb_bp = target_sp->CreateBreakpoint(
819 module_list.get(), comp_unit_list.get(), symbol_names, num_names,
820 name_type_mask, symbol_language, offset, skip_prologue, internal,
825 log->Printf("SBTarget(%p)::BreakpointCreateByName (symbols={",
826 static_cast<void *>(target_sp.get()));
827 for (uint32_t i = 0; i < num_names; i++) {
829 if (i < num_names - 1)
833 if (symbol_names[i] != NULL)
834 log->Printf("\"%s\"%c ", symbol_names[i], sep);
836 log->Printf("\"<NULL>\"%c ", sep);
838 log->Printf("name_type: %d) => SBBreakpoint(%p)", name_type_mask,
839 static_cast<void *>(sb_bp.GetSP().get()));
845 SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
846 const char *module_name) {
847 SBFileSpecList module_spec_list;
848 SBFileSpecList comp_unit_list;
849 if (module_name && module_name[0]) {
850 module_spec_list.Append(FileSpec(module_name, false));
852 return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown,
853 module_spec_list, comp_unit_list);
857 SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
858 const SBFileSpecList &module_list,
859 const SBFileSpecList &comp_unit_list) {
860 return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown,
861 module_list, comp_unit_list);
864 lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(
865 const char *symbol_name_regex, LanguageType symbol_language,
866 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
867 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
870 TargetSP target_sp(GetSP());
871 if (target_sp && symbol_name_regex && symbol_name_regex[0]) {
872 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
873 RegularExpression regexp((llvm::StringRef(symbol_name_regex)));
874 const bool internal = false;
875 const bool hardware = false;
876 const LazyBool skip_prologue = eLazyBoolCalculate;
878 sb_bp = target_sp->CreateFuncRegexBreakpoint(
879 module_list.get(), comp_unit_list.get(), regexp, symbol_language,
880 skip_prologue, internal, hardware);
884 log->Printf("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") "
885 "=> SBBreakpoint(%p)",
886 static_cast<void *>(target_sp.get()), symbol_name_regex,
887 static_cast<void *>(sb_bp.GetSP().get()));
892 SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) {
893 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
896 TargetSP target_sp(GetSP());
898 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
899 const bool hardware = false;
900 sb_bp = target_sp->CreateBreakpoint(address, false, hardware);
904 log->Printf("SBTarget(%p)::BreakpointCreateByAddress (address=%" PRIu64
905 ") => SBBreakpoint(%p)",
906 static_cast<void *>(target_sp.get()),
907 static_cast<uint64_t>(address),
908 static_cast<void *>(sb_bp.GetSP().get()));
913 SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) {
914 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
917 TargetSP target_sp(GetSP());
918 if (!sb_address.IsValid()) {
920 log->Printf("SBTarget(%p)::BreakpointCreateBySBAddress called with "
922 static_cast<void *>(target_sp.get()));
927 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
928 const bool hardware = false;
929 sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware);
934 sb_address.GetDescription(s);
935 log->Printf("SBTarget(%p)::BreakpointCreateBySBAddress (address=%s) => "
937 static_cast<void *>(target_sp.get()), s.GetData(),
938 static_cast<void *>(sb_bp.GetSP().get()));
945 SBTarget::BreakpointCreateBySourceRegex(const char *source_regex,
946 const lldb::SBFileSpec &source_file,
947 const char *module_name) {
948 SBFileSpecList module_spec_list;
950 if (module_name && module_name[0]) {
951 module_spec_list.Append(FileSpec(module_name, false));
954 SBFileSpecList source_file_list;
955 if (source_file.IsValid()) {
956 source_file_list.Append(source_file);
959 return BreakpointCreateBySourceRegex(source_regex, module_spec_list,
963 lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
964 const char *source_regex, const SBFileSpecList &module_list,
965 const lldb::SBFileSpecList &source_file_list) {
966 return BreakpointCreateBySourceRegex(source_regex, module_list,
967 source_file_list, SBStringList());
970 lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
971 const char *source_regex, const SBFileSpecList &module_list,
972 const lldb::SBFileSpecList &source_file_list,
973 const SBStringList &func_names) {
974 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
977 TargetSP target_sp(GetSP());
978 if (target_sp && source_regex && source_regex[0]) {
979 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
980 const bool hardware = false;
981 const LazyBool move_to_nearest_code = eLazyBoolCalculate;
982 RegularExpression regexp((llvm::StringRef(source_regex)));
983 std::unordered_set<std::string> func_names_set;
984 for (size_t i = 0; i < func_names.GetSize(); i++) {
985 func_names_set.insert(func_names.GetStringAtIndex(i));
988 sb_bp = target_sp->CreateSourceRegexBreakpoint(
989 module_list.get(), source_file_list.get(), func_names_set, regexp,
990 false, hardware, move_to_nearest_code);
994 log->Printf("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") "
995 "=> SBBreakpoint(%p)",
996 static_cast<void *>(target_sp.get()), source_regex,
997 static_cast<void *>(sb_bp.GetSP().get()));
1003 SBTarget::BreakpointCreateForException(lldb::LanguageType language,
1004 bool catch_bp, bool throw_bp) {
1005 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1008 TargetSP target_sp(GetSP());
1010 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1011 const bool hardware = false;
1012 sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp,
1017 log->Printf("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: "
1018 "%s throw: %s) => SBBreakpoint(%p)",
1019 static_cast<void *>(target_sp.get()),
1020 Language::GetNameForLanguageType(language),
1021 catch_bp ? "on" : "off", throw_bp ? "on" : "off",
1022 static_cast<void *>(sb_bp.GetSP().get()));
1027 uint32_t SBTarget::GetNumBreakpoints() const {
1028 TargetSP target_sp(GetSP());
1030 // The breakpoint list is thread safe, no need to lock
1031 return target_sp->GetBreakpointList().GetSize();
1036 SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const {
1037 SBBreakpoint sb_breakpoint;
1038 TargetSP target_sp(GetSP());
1040 // The breakpoint list is thread safe, no need to lock
1041 sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
1043 return sb_breakpoint;
1046 bool SBTarget::BreakpointDelete(break_id_t bp_id) {
1047 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1049 bool result = false;
1050 TargetSP target_sp(GetSP());
1052 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1053 result = target_sp->RemoveBreakpointByID(bp_id);
1057 log->Printf("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i",
1058 static_cast<void *>(target_sp.get()),
1059 static_cast<uint32_t>(bp_id), result);
1064 SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) {
1065 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1067 SBBreakpoint sb_breakpoint;
1068 TargetSP target_sp(GetSP());
1069 if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) {
1070 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1071 sb_breakpoint = target_sp->GetBreakpointByID(bp_id);
1076 "SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)",
1077 static_cast<void *>(target_sp.get()), static_cast<uint32_t>(bp_id),
1078 static_cast<void *>(sb_breakpoint.GetSP().get()));
1080 return sb_breakpoint;
1083 bool SBTarget::FindBreakpointsByName(const char *name,
1084 SBBreakpointList &bkpts) {
1085 TargetSP target_sp(GetSP());
1087 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1088 BreakpointList bkpt_list(false);
1090 target_sp->GetBreakpointList().FindBreakpointsByName(name, bkpt_list);
1093 for (BreakpointSP bkpt_sp : bkpt_list.Breakpoints()) {
1094 bkpts.AppendByID(bkpt_sp->GetID());
1100 bool SBTarget::EnableAllBreakpoints() {
1101 TargetSP target_sp(GetSP());
1103 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1104 target_sp->EnableAllBreakpoints();
1110 bool SBTarget::DisableAllBreakpoints() {
1111 TargetSP target_sp(GetSP());
1113 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1114 target_sp->DisableAllBreakpoints();
1120 bool SBTarget::DeleteAllBreakpoints() {
1121 TargetSP target_sp(GetSP());
1123 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1124 target_sp->RemoveAllBreakpoints();
1130 lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file,
1131 SBBreakpointList &new_bps) {
1132 SBStringList empty_name_list;
1133 return BreakpointsCreateFromFile(source_file, empty_name_list, new_bps);
1136 lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file,
1137 SBStringList &matching_names,
1138 SBBreakpointList &new_bps) {
1140 TargetSP target_sp(GetSP());
1142 sberr.SetErrorString(
1143 "BreakpointCreateFromFile called with invalid target.");
1146 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1148 BreakpointIDList bp_ids;
1150 std::vector<std::string> name_vector;
1151 size_t num_names = matching_names.GetSize();
1152 for (size_t i = 0; i < num_names; i++)
1153 name_vector.push_back(matching_names.GetStringAtIndex(i));
1155 sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(),
1156 name_vector, bp_ids);
1160 size_t num_bkpts = bp_ids.GetSize();
1161 for (size_t i = 0; i < num_bkpts; i++) {
1162 BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i);
1163 new_bps.AppendByID(bp_id.GetBreakpointID());
1168 lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file) {
1170 TargetSP target_sp(GetSP());
1172 sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
1175 SBBreakpointList bkpt_list(*this);
1176 return BreakpointsWriteToFile(dest_file, bkpt_list);
1179 lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file,
1180 SBBreakpointList &bkpt_list,
1183 TargetSP target_sp(GetSP());
1185 sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
1189 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1190 BreakpointIDList bp_id_list;
1191 bkpt_list.CopyToBreakpointIDList(bp_id_list);
1192 sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(),
1193 bp_id_list, append);
1197 uint32_t SBTarget::GetNumWatchpoints() const {
1198 TargetSP target_sp(GetSP());
1200 // The watchpoint list is thread safe, no need to lock
1201 return target_sp->GetWatchpointList().GetSize();
1206 SBWatchpoint SBTarget::GetWatchpointAtIndex(uint32_t idx) const {
1207 SBWatchpoint sb_watchpoint;
1208 TargetSP target_sp(GetSP());
1210 // The watchpoint list is thread safe, no need to lock
1211 sb_watchpoint.SetSP(target_sp->GetWatchpointList().GetByIndex(idx));
1213 return sb_watchpoint;
1216 bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) {
1217 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1219 bool result = false;
1220 TargetSP target_sp(GetSP());
1222 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1223 std::unique_lock<std::recursive_mutex> lock;
1224 target_sp->GetWatchpointList().GetListMutex(lock);
1225 result = target_sp->RemoveWatchpointByID(wp_id);
1229 log->Printf("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i",
1230 static_cast<void *>(target_sp.get()),
1231 static_cast<uint32_t>(wp_id), result);
1236 SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) {
1237 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1239 SBWatchpoint sb_watchpoint;
1240 lldb::WatchpointSP watchpoint_sp;
1241 TargetSP target_sp(GetSP());
1242 if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) {
1243 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1244 std::unique_lock<std::recursive_mutex> lock;
1245 target_sp->GetWatchpointList().GetListMutex(lock);
1246 watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id);
1247 sb_watchpoint.SetSP(watchpoint_sp);
1252 "SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)",
1253 static_cast<void *>(target_sp.get()), static_cast<uint32_t>(wp_id),
1254 static_cast<void *>(watchpoint_sp.get()));
1256 return sb_watchpoint;
1259 lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size,
1260 bool read, bool write,
1262 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1264 SBWatchpoint sb_watchpoint;
1265 lldb::WatchpointSP watchpoint_sp;
1266 TargetSP target_sp(GetSP());
1267 if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS &&
1269 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1270 uint32_t watch_type = 0;
1272 watch_type |= LLDB_WATCH_TYPE_READ;
1274 watch_type |= LLDB_WATCH_TYPE_WRITE;
1275 if (watch_type == 0) {
1276 error.SetErrorString(
1277 "Can't create a watchpoint that is neither read nor write.");
1278 return sb_watchpoint;
1281 // Target::CreateWatchpoint() is thread safe.
1283 // This API doesn't take in a type, so we can't figure out what it is.
1284 CompilerType *type = NULL;
1286 target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
1287 error.SetError(cw_error);
1288 sb_watchpoint.SetSP(watchpoint_sp);
1292 log->Printf("SBTarget(%p)::WatchAddress (addr=0x%" PRIx64
1293 ", 0x%u) => SBWatchpoint(%p)",
1294 static_cast<void *>(target_sp.get()), addr,
1295 static_cast<uint32_t>(size),
1296 static_cast<void *>(watchpoint_sp.get()));
1298 return sb_watchpoint;
1301 bool SBTarget::EnableAllWatchpoints() {
1302 TargetSP target_sp(GetSP());
1304 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1305 std::unique_lock<std::recursive_mutex> lock;
1306 target_sp->GetWatchpointList().GetListMutex(lock);
1307 target_sp->EnableAllWatchpoints();
1313 bool SBTarget::DisableAllWatchpoints() {
1314 TargetSP target_sp(GetSP());
1316 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1317 std::unique_lock<std::recursive_mutex> lock;
1318 target_sp->GetWatchpointList().GetListMutex(lock);
1319 target_sp->DisableAllWatchpoints();
1325 SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr,
1328 lldb::ValueObjectSP new_value_sp;
1329 if (IsValid() && name && *name && addr.IsValid() && type.IsValid()) {
1330 lldb::addr_t load_addr(addr.GetLoadAddress(*this));
1331 ExecutionContext exe_ctx(
1332 ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
1333 CompilerType ast_type(type.GetSP()->GetCompilerType(true));
1334 new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr,
1337 sb_value.SetSP(new_value_sp);
1338 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1341 log->Printf("SBTarget(%p)::CreateValueFromAddress => \"%s\"",
1342 static_cast<void *>(m_opaque_sp.get()),
1343 new_value_sp->GetName().AsCString());
1345 log->Printf("SBTarget(%p)::CreateValueFromAddress => NULL",
1346 static_cast<void *>(m_opaque_sp.get()));
1351 lldb::SBValue SBTarget::CreateValueFromData(const char *name, lldb::SBData data,
1352 lldb::SBType type) {
1354 lldb::ValueObjectSP new_value_sp;
1355 if (IsValid() && name && *name && data.IsValid() && type.IsValid()) {
1356 DataExtractorSP extractor(*data);
1357 ExecutionContext exe_ctx(
1358 ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
1359 CompilerType ast_type(type.GetSP()->GetCompilerType(true));
1360 new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor,
1363 sb_value.SetSP(new_value_sp);
1364 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1367 log->Printf("SBTarget(%p)::CreateValueFromData => \"%s\"",
1368 static_cast<void *>(m_opaque_sp.get()),
1369 new_value_sp->GetName().AsCString());
1371 log->Printf("SBTarget(%p)::CreateValueFromData => NULL",
1372 static_cast<void *>(m_opaque_sp.get()));
1377 lldb::SBValue SBTarget::CreateValueFromExpression(const char *name,
1380 lldb::ValueObjectSP new_value_sp;
1381 if (IsValid() && name && *name && expr && *expr) {
1382 ExecutionContext exe_ctx(
1383 ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
1385 ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx);
1387 sb_value.SetSP(new_value_sp);
1388 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1391 log->Printf("SBTarget(%p)::CreateValueFromExpression => \"%s\"",
1392 static_cast<void *>(m_opaque_sp.get()),
1393 new_value_sp->GetName().AsCString());
1395 log->Printf("SBTarget(%p)::CreateValueFromExpression => NULL",
1396 static_cast<void *>(m_opaque_sp.get()));
1401 bool SBTarget::DeleteAllWatchpoints() {
1402 TargetSP target_sp(GetSP());
1404 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1405 std::unique_lock<std::recursive_mutex> lock;
1406 target_sp->GetWatchpointList().GetListMutex(lock);
1407 target_sp->RemoveAllWatchpoints();
1413 lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
1414 const char *uuid_cstr) {
1415 return AddModule(path, triple, uuid_cstr, NULL);
1418 lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
1419 const char *uuid_cstr, const char *symfile) {
1420 lldb::SBModule sb_module;
1421 TargetSP target_sp(GetSP());
1423 ModuleSpec module_spec;
1425 module_spec.GetFileSpec().SetFile(path, false);
1428 module_spec.GetUUID().SetFromCString(uuid_cstr);
1431 module_spec.GetArchitecture().SetTriple(triple,
1432 target_sp->GetPlatform().get());
1434 module_spec.GetArchitecture() = target_sp->GetArchitecture();
1437 module_spec.GetSymbolFileSpec().SetFile(symfile, false);
1439 sb_module.SetSP(target_sp->GetSharedModule(module_spec));
1444 lldb::SBModule SBTarget::AddModule(const SBModuleSpec &module_spec) {
1445 lldb::SBModule sb_module;
1446 TargetSP target_sp(GetSP());
1448 sb_module.SetSP(target_sp->GetSharedModule(*module_spec.m_opaque_ap));
1452 bool SBTarget::AddModule(lldb::SBModule &module) {
1453 TargetSP target_sp(GetSP());
1455 target_sp->GetImages().AppendIfNeeded(module.GetSP());
1461 uint32_t SBTarget::GetNumModules() const {
1462 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1465 TargetSP target_sp(GetSP());
1467 // The module list is thread safe, no need to lock
1468 num = target_sp->GetImages().GetSize();
1472 log->Printf("SBTarget(%p)::GetNumModules () => %d",
1473 static_cast<void *>(target_sp.get()), num);
1478 void SBTarget::Clear() {
1479 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1482 log->Printf("SBTarget(%p)::Clear ()",
1483 static_cast<void *>(m_opaque_sp.get()));
1485 m_opaque_sp.reset();
1488 SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) {
1490 TargetSP target_sp(GetSP());
1491 if (target_sp && sb_file_spec.IsValid()) {
1492 ModuleSpec module_spec(*sb_file_spec);
1493 // The module list is thread safe, no need to lock
1494 sb_module.SetSP(target_sp->GetImages().FindFirstModule(module_spec));
1499 lldb::ByteOrder SBTarget::GetByteOrder() {
1500 TargetSP target_sp(GetSP());
1502 return target_sp->GetArchitecture().GetByteOrder();
1503 return eByteOrderInvalid;
1506 const char *SBTarget::GetTriple() {
1507 TargetSP target_sp(GetSP());
1509 std::string triple(target_sp->GetArchitecture().GetTriple().str());
1510 // Unique the string so we don't run into ownership issues since
1511 // the const strings put the string into the string pool once and
1512 // the strings never comes out
1513 ConstString const_triple(triple.c_str());
1514 return const_triple.GetCString();
1519 uint32_t SBTarget::GetDataByteSize() {
1520 TargetSP target_sp(GetSP());
1522 return target_sp->GetArchitecture().GetDataByteSize();
1527 uint32_t SBTarget::GetCodeByteSize() {
1528 TargetSP target_sp(GetSP());
1530 return target_sp->GetArchitecture().GetCodeByteSize();
1535 uint32_t SBTarget::GetAddressByteSize() {
1536 TargetSP target_sp(GetSP());
1538 return target_sp->GetArchitecture().GetAddressByteSize();
1539 return sizeof(void *);
1542 SBModule SBTarget::GetModuleAtIndex(uint32_t idx) {
1543 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1547 TargetSP target_sp(GetSP());
1549 // The module list is thread safe, no need to lock
1550 module_sp = target_sp->GetImages().GetModuleAtIndex(idx);
1551 sb_module.SetSP(module_sp);
1555 log->Printf("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)",
1556 static_cast<void *>(target_sp.get()), idx,
1557 static_cast<void *>(module_sp.get()));
1562 bool SBTarget::RemoveModule(lldb::SBModule module) {
1563 TargetSP target_sp(GetSP());
1565 return target_sp->GetImages().Remove(module.GetSP());
1569 SBBroadcaster SBTarget::GetBroadcaster() const {
1570 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1572 TargetSP target_sp(GetSP());
1573 SBBroadcaster broadcaster(target_sp.get(), false);
1576 log->Printf("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)",
1577 static_cast<void *>(target_sp.get()),
1578 static_cast<void *>(broadcaster.get()));
1583 bool SBTarget::GetDescription(SBStream &description,
1584 lldb::DescriptionLevel description_level) {
1585 Stream &strm = description.ref();
1587 TargetSP target_sp(GetSP());
1589 target_sp->Dump(&strm, description_level);
1591 strm.PutCString("No value");
1596 lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name,
1597 uint32_t name_type_mask) {
1598 lldb::SBSymbolContextList sb_sc_list;
1599 if (name && name[0]) {
1600 TargetSP target_sp(GetSP());
1602 const bool symbols_ok = true;
1603 const bool inlines_ok = true;
1604 const bool append = true;
1605 target_sp->GetImages().FindFunctions(ConstString(name), name_type_mask,
1606 symbols_ok, inlines_ok, append,
1613 lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name,
1614 uint32_t max_matches,
1615 MatchType matchtype) {
1616 lldb::SBSymbolContextList sb_sc_list;
1617 if (name && name[0]) {
1618 llvm::StringRef name_ref(name);
1619 TargetSP target_sp(GetSP());
1621 std::string regexstr;
1622 switch (matchtype) {
1623 case eMatchTypeRegex:
1624 target_sp->GetImages().FindFunctions(RegularExpression(name_ref), true,
1625 true, true, *sb_sc_list);
1627 case eMatchTypeStartsWith:
1628 regexstr = llvm::Regex::escape(name) + ".*";
1629 target_sp->GetImages().FindFunctions(RegularExpression(regexstr), true,
1630 true, true, *sb_sc_list);
1633 target_sp->GetImages().FindFunctions(ConstString(name),
1634 eFunctionNameTypeAny, true, true,
1643 lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
1644 TargetSP target_sp(GetSP());
1645 if (typename_cstr && typename_cstr[0] && target_sp) {
1646 ConstString const_typename(typename_cstr);
1648 const bool exact_match = false;
1650 const ModuleList &module_list = target_sp->GetImages();
1651 size_t count = module_list.GetSize();
1652 for (size_t idx = 0; idx < count; idx++) {
1653 ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
1656 module_sp->FindFirstType(sc, const_typename, exact_match));
1658 return SBType(type_sp);
1662 // Didn't find the type in the symbols; try the Objective-C runtime
1663 // if one is installed
1665 ProcessSP process_sp(target_sp->GetProcessSP());
1668 ObjCLanguageRuntime *objc_language_runtime =
1669 process_sp->GetObjCLanguageRuntime();
1671 if (objc_language_runtime) {
1672 DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
1674 if (objc_decl_vendor) {
1675 std::vector<clang::NamedDecl *> decls;
1677 if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) {
1678 if (CompilerType type = ClangASTContext::GetTypeForDecl(decls[0])) {
1679 return SBType(type);
1686 // No matches, search for basic typename matches
1687 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1689 return SBType(ClangASTContext::GetBasicType(clang_ast->getASTContext(),
1695 SBType SBTarget::GetBasicType(lldb::BasicType type) {
1696 TargetSP target_sp(GetSP());
1698 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1701 ClangASTContext::GetBasicType(clang_ast->getASTContext(), type));
1706 lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
1707 SBTypeList sb_type_list;
1708 TargetSP target_sp(GetSP());
1709 if (typename_cstr && typename_cstr[0] && target_sp) {
1710 ModuleList &images = target_sp->GetImages();
1711 ConstString const_typename(typename_cstr);
1712 bool exact_match = false;
1715 llvm::DenseSet<SymbolFile *> searched_symbol_files;
1716 uint32_t num_matches =
1717 images.FindTypes(sc, const_typename, exact_match, UINT32_MAX,
1718 searched_symbol_files, type_list);
1720 if (num_matches > 0) {
1721 for (size_t idx = 0; idx < num_matches; idx++) {
1722 TypeSP type_sp(type_list.GetTypeAtIndex(idx));
1724 sb_type_list.Append(SBType(type_sp));
1728 // Try the Objective-C runtime if one is installed
1730 ProcessSP process_sp(target_sp->GetProcessSP());
1733 ObjCLanguageRuntime *objc_language_runtime =
1734 process_sp->GetObjCLanguageRuntime();
1736 if (objc_language_runtime) {
1737 DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
1739 if (objc_decl_vendor) {
1740 std::vector<clang::NamedDecl *> decls;
1742 if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) {
1743 for (clang::NamedDecl *decl : decls) {
1744 if (CompilerType type = ClangASTContext::GetTypeForDecl(decl)) {
1745 sb_type_list.Append(SBType(type));
1753 if (sb_type_list.GetSize() == 0) {
1754 // No matches, search for basic typename matches
1755 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1757 sb_type_list.Append(SBType(ClangASTContext::GetBasicType(
1758 clang_ast->getASTContext(), const_typename)));
1761 return sb_type_list;
1764 SBValueList SBTarget::FindGlobalVariables(const char *name,
1765 uint32_t max_matches) {
1766 SBValueList sb_value_list;
1768 TargetSP target_sp(GetSP());
1769 if (name && target_sp) {
1770 VariableList variable_list;
1771 const bool append = true;
1772 const uint32_t match_count = target_sp->GetImages().FindGlobalVariables(
1773 ConstString(name), append, max_matches, variable_list);
1775 if (match_count > 0) {
1776 ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
1777 if (exe_scope == NULL)
1778 exe_scope = target_sp.get();
1779 for (uint32_t i = 0; i < match_count; ++i) {
1780 lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
1781 exe_scope, variable_list.GetVariableAtIndex(i)));
1783 sb_value_list.Append(SBValue(valobj_sp));
1788 return sb_value_list;
1791 SBValueList SBTarget::FindGlobalVariables(const char *name,
1792 uint32_t max_matches,
1793 MatchType matchtype) {
1794 SBValueList sb_value_list;
1796 TargetSP target_sp(GetSP());
1797 if (name && target_sp) {
1798 llvm::StringRef name_ref(name);
1799 VariableList variable_list;
1800 const bool append = true;
1802 std::string regexstr;
1803 uint32_t match_count;
1804 switch (matchtype) {
1805 case eMatchTypeNormal:
1806 match_count = target_sp->GetImages().FindGlobalVariables(
1807 ConstString(name), append, max_matches, variable_list);
1809 case eMatchTypeRegex:
1810 match_count = target_sp->GetImages().FindGlobalVariables(
1811 RegularExpression(name_ref), append, max_matches, variable_list);
1813 case eMatchTypeStartsWith:
1814 regexstr = llvm::Regex::escape(name) + ".*";
1815 match_count = target_sp->GetImages().FindGlobalVariables(
1816 RegularExpression(regexstr), append, max_matches, variable_list);
1820 if (match_count > 0) {
1821 ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
1822 if (exe_scope == NULL)
1823 exe_scope = target_sp.get();
1824 for (uint32_t i = 0; i < match_count; ++i) {
1825 lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
1826 exe_scope, variable_list.GetVariableAtIndex(i)));
1828 sb_value_list.Append(SBValue(valobj_sp));
1833 return sb_value_list;
1836 lldb::SBValue SBTarget::FindFirstGlobalVariable(const char *name) {
1837 SBValueList sb_value_list(FindGlobalVariables(name, 1));
1838 if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
1839 return sb_value_list.GetValueAtIndex(0);
1843 SBSourceManager SBTarget::GetSourceManager() {
1844 SBSourceManager source_manager(*this);
1845 return source_manager;
1848 lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
1850 return ReadInstructions(base_addr, count, NULL);
1853 lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
1855 const char *flavor_string) {
1856 SBInstructionList sb_instructions;
1858 TargetSP target_sp(GetSP());
1860 Address *addr_ptr = base_addr.get();
1863 DataBufferHeap data(
1864 target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0);
1865 bool prefer_file_cache = false;
1866 lldb_private::Status error;
1867 lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
1868 const size_t bytes_read =
1869 target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(),
1870 data.GetByteSize(), error, &load_addr);
1871 const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
1872 sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
1873 target_sp->GetArchitecture(), NULL, flavor_string, *addr_ptr,
1874 data.GetBytes(), bytes_read, count, data_from_file));
1878 return sb_instructions;
1881 lldb::SBInstructionList SBTarget::GetInstructions(lldb::SBAddress base_addr,
1884 return GetInstructionsWithFlavor(base_addr, NULL, buf, size);
1887 lldb::SBInstructionList
1888 SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr,
1889 const char *flavor_string, const void *buf,
1891 SBInstructionList sb_instructions;
1893 TargetSP target_sp(GetSP());
1897 if (base_addr.get())
1898 addr = *base_addr.get();
1900 const bool data_from_file = true;
1902 sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
1903 target_sp->GetArchitecture(), NULL, flavor_string, addr, buf, size,
1904 UINT32_MAX, data_from_file));
1907 return sb_instructions;
1910 lldb::SBInstructionList SBTarget::GetInstructions(lldb::addr_t base_addr,
1913 return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), NULL, buf,
1917 lldb::SBInstructionList
1918 SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr,
1919 const char *flavor_string, const void *buf,
1921 return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string,
1925 SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section,
1926 lldb::addr_t section_base_addr) {
1928 TargetSP target_sp(GetSP());
1930 if (!section.IsValid()) {
1931 sb_error.SetErrorStringWithFormat("invalid section");
1933 SectionSP section_sp(section.GetSP());
1935 if (section_sp->IsThreadSpecific()) {
1936 sb_error.SetErrorString(
1937 "thread specific sections are not yet supported");
1939 ProcessSP process_sp(target_sp->GetProcessSP());
1940 if (target_sp->SetSectionLoadAddress(section_sp, section_base_addr)) {
1941 ModuleSP module_sp(section_sp->GetModule());
1943 ModuleList module_list;
1944 module_list.Append(module_sp);
1945 target_sp->ModulesDidLoad(module_list);
1947 // Flush info in the process (stack frames, etc)
1949 process_sp->Flush();
1955 sb_error.SetErrorString("invalid target");
1960 SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) {
1963 TargetSP target_sp(GetSP());
1965 if (!section.IsValid()) {
1966 sb_error.SetErrorStringWithFormat("invalid section");
1968 SectionSP section_sp(section.GetSP());
1970 ProcessSP process_sp(target_sp->GetProcessSP());
1971 if (target_sp->SetSectionUnloaded(section_sp)) {
1972 ModuleSP module_sp(section_sp->GetModule());
1974 ModuleList module_list;
1975 module_list.Append(module_sp);
1976 target_sp->ModulesDidUnload(module_list, false);
1978 // Flush info in the process (stack frames, etc)
1980 process_sp->Flush();
1983 sb_error.SetErrorStringWithFormat("invalid section");
1987 sb_error.SetErrorStringWithFormat("invalid target");
1992 SBError SBTarget::SetModuleLoadAddress(lldb::SBModule module,
1993 int64_t slide_offset) {
1996 TargetSP target_sp(GetSP());
1998 ModuleSP module_sp(module.GetSP());
2000 bool changed = false;
2001 if (module_sp->SetLoadAddress(*target_sp, slide_offset, true, changed)) {
2002 // The load was successful, make sure that at least some sections
2003 // changed before we notify that our module was loaded.
2005 ModuleList module_list;
2006 module_list.Append(module_sp);
2007 target_sp->ModulesDidLoad(module_list);
2008 // Flush info in the process (stack frames, etc)
2009 ProcessSP process_sp(target_sp->GetProcessSP());
2011 process_sp->Flush();
2015 sb_error.SetErrorStringWithFormat("invalid module");
2019 sb_error.SetErrorStringWithFormat("invalid target");
2024 SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) {
2027 char path[PATH_MAX];
2028 TargetSP target_sp(GetSP());
2030 ModuleSP module_sp(module.GetSP());
2032 ObjectFile *objfile = module_sp->GetObjectFile();
2034 SectionList *section_list = objfile->GetSectionList();
2036 ProcessSP process_sp(target_sp->GetProcessSP());
2038 bool changed = false;
2039 const size_t num_sections = section_list->GetSize();
2040 for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
2041 SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
2043 changed |= target_sp->SetSectionUnloaded(section_sp);
2046 ModuleList module_list;
2047 module_list.Append(module_sp);
2048 target_sp->ModulesDidUnload(module_list, false);
2049 // Flush info in the process (stack frames, etc)
2050 ProcessSP process_sp(target_sp->GetProcessSP());
2052 process_sp->Flush();
2055 module_sp->GetFileSpec().GetPath(path, sizeof(path));
2056 sb_error.SetErrorStringWithFormat("no sections in object file '%s'",
2060 module_sp->GetFileSpec().GetPath(path, sizeof(path));
2061 sb_error.SetErrorStringWithFormat("no object file for module '%s'",
2065 sb_error.SetErrorStringWithFormat("invalid module");
2068 sb_error.SetErrorStringWithFormat("invalid target");
2073 lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name,
2074 lldb::SymbolType symbol_type) {
2075 SBSymbolContextList sb_sc_list;
2076 if (name && name[0]) {
2077 TargetSP target_sp(GetSP());
2080 target_sp->GetImages().FindSymbolsWithNameAndType(
2081 ConstString(name), symbol_type, *sb_sc_list, append);
2087 lldb::SBValue SBTarget::EvaluateExpression(const char *expr) {
2088 TargetSP target_sp(GetSP());
2092 SBExpressionOptions options;
2093 lldb::DynamicValueType fetch_dynamic_value =
2094 target_sp->GetPreferDynamicValue();
2095 options.SetFetchDynamicValue(fetch_dynamic_value);
2096 options.SetUnwindOnError(true);
2097 return EvaluateExpression(expr, options);
2100 lldb::SBValue SBTarget::EvaluateExpression(const char *expr,
2101 const SBExpressionOptions &options) {
2102 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
2103 #if !defined(LLDB_DISABLE_PYTHON)
2104 Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
2106 SBValue expr_result;
2107 ExpressionResults exe_results = eExpressionSetupError;
2108 ValueObjectSP expr_value_sp;
2109 TargetSP target_sp(GetSP());
2110 StackFrame *frame = NULL;
2112 if (expr == NULL || expr[0] == '\0') {
2115 "SBTarget::EvaluateExpression called with an empty expression");
2119 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
2120 ExecutionContext exe_ctx(m_opaque_sp.get());
2123 log->Printf("SBTarget()::EvaluateExpression (expr=\"%s\")...", expr);
2125 frame = exe_ctx.GetFramePtr();
2126 Target *target = exe_ctx.GetTargetPtr();
2129 #ifdef LLDB_CONFIGURATION_DEBUG
2130 StreamString frame_description;
2132 frame->DumpUsingSettingsFormat(&frame_description);
2133 llvm::PrettyStackTraceFormat stack_trace(
2134 "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = "
2136 expr, options.GetFetchDynamicValue(),
2137 frame_description.GetString().str().c_str());
2140 target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
2142 expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
2145 log->Printf("SBTarget::EvaluateExpression () => error: could not "
2146 "reconstruct frame object for this SBTarget.");
2149 #ifndef LLDB_DISABLE_PYTHON
2151 expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is "
2152 "%s, summary %s **",
2153 expr_result.GetValue(), expr_result.GetSummary());
2156 log->Printf("SBTarget(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) "
2157 "(execution result=%d)",
2158 static_cast<void *>(frame), expr,
2159 static_cast<void *>(expr_value_sp.get()), exe_results);
2165 lldb::addr_t SBTarget::GetStackRedZoneSize() {
2166 TargetSP target_sp(GetSP());
2169 ProcessSP process_sp(target_sp->GetProcessSP());
2171 abi_sp = process_sp->GetABI();
2173 abi_sp = ABI::FindPlugin(target_sp->GetArchitecture());
2175 return abi_sp->GetRedZoneSize();
2180 lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
2181 lldb::SBLaunchInfo launch_info(NULL);
2182 TargetSP target_sp(GetSP());
2184 launch_info.ref() = m_opaque_sp->GetProcessLaunchInfo();
2188 void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) {
2189 TargetSP target_sp(GetSP());
2191 m_opaque_sp->SetProcessLaunchInfo(launch_info.ref());