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/Debugger.h"
35 #include "lldb/Core/Disassembler.h"
36 #include "lldb/Core/Module.h"
37 #include "lldb/Core/ModuleSpec.h"
38 #include "lldb/Core/STLUtils.h"
39 #include "lldb/Core/SearchFilter.h"
40 #include "lldb/Core/Section.h"
41 #include "lldb/Core/ValueObjectConstResult.h"
42 #include "lldb/Core/ValueObjectList.h"
43 #include "lldb/Core/ValueObjectVariable.h"
44 #include "lldb/Host/Host.h"
45 #include "lldb/Interpreter/Args.h"
46 #include "lldb/Symbol/ClangASTContext.h"
47 #include "lldb/Symbol/DeclVendor.h"
48 #include "lldb/Symbol/ObjectFile.h"
49 #include "lldb/Symbol/SymbolFile.h"
50 #include "lldb/Symbol/SymbolVendor.h"
51 #include "lldb/Symbol/VariableList.h"
52 #include "lldb/Target/ABI.h"
53 #include "lldb/Target/Language.h"
54 #include "lldb/Target/LanguageRuntime.h"
55 #include "lldb/Target/ObjCLanguageRuntime.h"
56 #include "lldb/Target/Process.h"
57 #include "lldb/Target/StackFrame.h"
58 #include "lldb/Target/Target.h"
59 #include "lldb/Target/TargetList.h"
60 #include "lldb/Utility/ArchSpec.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 lldb::SBProcess SBTarget::AttachToProcessWithID(
418 SBListener &listener,
419 lldb::pid_t pid, // The process ID to attach to
420 SBError &error // An error explaining what went wrong if attach fails
422 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
424 SBProcess sb_process;
425 TargetSP target_sp(GetSP());
428 log->Printf("SBTarget(%p)::%s (listener, pid=%" PRId64 ", error)...",
429 static_cast<void *>(target_sp.get()), __FUNCTION__, pid);
432 ProcessAttachInfo attach_info;
433 attach_info.SetProcessID(pid);
434 if (listener.IsValid())
435 attach_info.SetListener(listener.GetSP());
437 ProcessInstanceInfo instance_info;
438 if (target_sp->GetPlatform()->GetProcessInfo(pid, instance_info))
439 attach_info.SetUserID(instance_info.GetEffectiveUserID());
441 error.SetError(AttachToProcess(attach_info, *target_sp));
443 sb_process.SetSP(target_sp->GetProcessSP());
445 error.SetErrorString("SBTarget is invalid");
448 log->Printf("SBTarget(%p)::%s (...) => SBProcess(%p)",
449 static_cast<void *>(target_sp.get()), __FUNCTION__,
450 static_cast<void *>(sb_process.GetSP().get()));
454 lldb::SBProcess SBTarget::AttachToProcessWithName(
455 SBListener &listener,
456 const char *name, // basename of process to attach to
457 bool wait_for, // if true wait for a new instance of "name" to be launched
458 SBError &error // An error explaining what went wrong if attach fails
460 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
462 SBProcess sb_process;
463 TargetSP target_sp(GetSP());
466 log->Printf("SBTarget(%p)::%s (listener, name=%s, wait_for=%s, error)...",
467 static_cast<void *>(target_sp.get()), __FUNCTION__, name,
468 wait_for ? "true" : "false");
470 if (name && target_sp) {
471 ProcessAttachInfo attach_info;
472 attach_info.GetExecutableFile().SetFile(name, false);
473 attach_info.SetWaitForLaunch(wait_for);
474 if (listener.IsValid())
475 attach_info.SetListener(listener.GetSP());
477 error.SetError(AttachToProcess(attach_info, *target_sp));
479 sb_process.SetSP(target_sp->GetProcessSP());
481 error.SetErrorString("SBTarget is invalid");
484 log->Printf("SBTarget(%p)::%s (...) => SBProcess(%p)",
485 static_cast<void *>(target_sp.get()), __FUNCTION__,
486 static_cast<void *>(sb_process.GetSP().get()));
490 lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url,
491 const char *plugin_name,
493 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
495 SBProcess sb_process;
496 ProcessSP process_sp;
497 TargetSP target_sp(GetSP());
500 log->Printf("SBTarget(%p)::ConnectRemote (listener, url=%s, "
501 "plugin_name=%s, error)...",
502 static_cast<void *>(target_sp.get()), url, plugin_name);
505 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
506 if (listener.IsValid())
508 target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, NULL);
510 process_sp = target_sp->CreateProcess(
511 target_sp->GetDebugger().GetListener(), plugin_name, NULL);
514 sb_process.SetSP(process_sp);
515 error.SetError(process_sp->ConnectRemote(NULL, url));
517 error.SetErrorString("unable to create lldb_private::Process");
520 error.SetErrorString("SBTarget is invalid");
524 log->Printf("SBTarget(%p)::ConnectRemote (...) => SBProcess(%p)",
525 static_cast<void *>(target_sp.get()),
526 static_cast<void *>(process_sp.get()));
530 SBFileSpec SBTarget::GetExecutable() {
532 SBFileSpec exe_file_spec;
533 TargetSP target_sp(GetSP());
535 Module *exe_module = target_sp->GetExecutableModulePointer();
537 exe_file_spec.SetFileSpec(exe_module->GetFileSpec());
540 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
542 log->Printf("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)",
543 static_cast<void *>(target_sp.get()),
544 static_cast<const void *>(exe_file_spec.get()));
547 return exe_file_spec;
550 bool SBTarget::operator==(const SBTarget &rhs) const {
551 return m_opaque_sp.get() == rhs.m_opaque_sp.get();
554 bool SBTarget::operator!=(const SBTarget &rhs) const {
555 return m_opaque_sp.get() != rhs.m_opaque_sp.get();
558 lldb::TargetSP SBTarget::GetSP() const { return m_opaque_sp; }
560 void SBTarget::SetSP(const lldb::TargetSP &target_sp) {
561 m_opaque_sp = target_sp;
564 lldb::SBAddress SBTarget::ResolveLoadAddress(lldb::addr_t vm_addr) {
565 lldb::SBAddress sb_addr;
566 Address &addr = sb_addr.ref();
567 TargetSP target_sp(GetSP());
569 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
570 if (target_sp->ResolveLoadAddress(vm_addr, addr))
574 // We have a load address that isn't in a section, just return an address
575 // with the offset filled in (the address) and the section set to NULL
576 addr.SetRawAddress(vm_addr);
580 lldb::SBAddress SBTarget::ResolveFileAddress(lldb::addr_t file_addr) {
581 lldb::SBAddress sb_addr;
582 Address &addr = sb_addr.ref();
583 TargetSP target_sp(GetSP());
585 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
586 if (target_sp->ResolveFileAddress(file_addr, addr))
590 addr.SetRawAddress(file_addr);
594 lldb::SBAddress SBTarget::ResolvePastLoadAddress(uint32_t stop_id,
595 lldb::addr_t vm_addr) {
596 lldb::SBAddress sb_addr;
597 Address &addr = sb_addr.ref();
598 TargetSP target_sp(GetSP());
600 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
601 if (target_sp->ResolveLoadAddress(vm_addr, addr))
605 // We have a load address that isn't in a section, just return an address
606 // with the offset filled in (the address) and the section set to NULL
607 addr.SetRawAddress(vm_addr);
612 SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr,
613 uint32_t resolve_scope) {
615 if (addr.IsValid()) {
616 TargetSP target_sp(GetSP());
618 target_sp->GetImages().ResolveSymbolContextForAddress(
619 addr.ref(), resolve_scope, sc.ref());
624 size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size,
625 lldb::SBError &error) {
627 size_t bytes_read = 0;
628 TargetSP target_sp(GetSP());
630 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
632 target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref());
634 sb_error.SetErrorString("invalid target");
640 SBBreakpoint SBTarget::BreakpointCreateByLocation(const char *file,
643 BreakpointCreateByLocation(SBFileSpec(file, false), line));
647 SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
649 return BreakpointCreateByLocation(sb_file_spec, line, 0);
653 SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
654 uint32_t line, lldb::addr_t offset) {
655 SBFileSpecList empty_list;
656 return BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list);
660 SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
661 uint32_t line, lldb::addr_t offset,
662 SBFileSpecList &sb_module_list) {
663 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
666 TargetSP target_sp(GetSP());
667 if (target_sp && line != 0) {
668 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
670 const LazyBool check_inlines = eLazyBoolCalculate;
671 const LazyBool skip_prologue = eLazyBoolCalculate;
672 const bool internal = false;
673 const bool hardware = false;
674 const LazyBool move_to_nearest_code = eLazyBoolCalculate;
675 const FileSpecList *module_list = nullptr;
676 if (sb_module_list.GetSize() > 0) {
677 module_list = sb_module_list.get();
679 sb_bp = target_sp->CreateBreakpoint(
680 module_list, *sb_file_spec, line, offset, check_inlines, skip_prologue,
681 internal, hardware, move_to_nearest_code);
686 sb_bp.GetDescription(sstr);
688 sb_file_spec->GetPath(path, sizeof(path));
689 log->Printf("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => "
690 "SBBreakpoint(%p): %s",
691 static_cast<void *>(target_sp.get()), path, line,
692 static_cast<void *>(sb_bp.GetSP().get()), sstr.GetData());
698 SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name,
699 const char *module_name) {
700 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
703 TargetSP target_sp(GetSP());
704 if (target_sp.get()) {
705 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
707 const bool internal = false;
708 const bool hardware = false;
709 const LazyBool skip_prologue = eLazyBoolCalculate;
710 const lldb::addr_t offset = 0;
711 if (module_name && module_name[0]) {
712 FileSpecList module_spec_list;
713 module_spec_list.Append(FileSpec(module_name, false));
714 sb_bp = target_sp->CreateBreakpoint(
715 &module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto,
716 eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
718 sb_bp = target_sp->CreateBreakpoint(
719 NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown,
720 offset, skip_prologue, internal, hardware);
725 log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", "
726 "module=\"%s\") => SBBreakpoint(%p)",
727 static_cast<void *>(target_sp.get()), symbol_name, module_name,
728 static_cast<void *>(sb_bp.GetSP().get()));
734 SBTarget::BreakpointCreateByName(const char *symbol_name,
735 const SBFileSpecList &module_list,
736 const SBFileSpecList &comp_unit_list) {
737 uint32_t name_type_mask = eFunctionNameTypeAuto;
738 return BreakpointCreateByName(symbol_name, name_type_mask,
739 eLanguageTypeUnknown, module_list,
743 lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
744 const char *symbol_name, uint32_t name_type_mask,
745 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
746 return BreakpointCreateByName(symbol_name, name_type_mask,
747 eLanguageTypeUnknown, module_list,
751 lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
752 const char *symbol_name, uint32_t name_type_mask,
753 LanguageType symbol_language, const SBFileSpecList &module_list,
754 const SBFileSpecList &comp_unit_list) {
755 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
758 TargetSP target_sp(GetSP());
759 if (target_sp && symbol_name && symbol_name[0]) {
760 const bool internal = false;
761 const bool hardware = false;
762 const LazyBool skip_prologue = eLazyBoolCalculate;
763 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
764 sb_bp = target_sp->CreateBreakpoint(
765 module_list.get(), comp_unit_list.get(), symbol_name, name_type_mask,
766 symbol_language, 0, skip_prologue, internal, hardware);
770 log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", "
771 "name_type: %d) => SBBreakpoint(%p)",
772 static_cast<void *>(target_sp.get()), symbol_name,
773 name_type_mask, static_cast<void *>(sb_bp.GetSP().get()));
778 lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
779 const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
780 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
781 return BreakpointCreateByNames(symbol_names, num_names, name_type_mask,
782 eLanguageTypeUnknown, module_list,
786 lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
787 const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
788 LanguageType symbol_language, const SBFileSpecList &module_list,
789 const SBFileSpecList &comp_unit_list) {
790 return BreakpointCreateByNames(symbol_names, num_names, name_type_mask,
791 eLanguageTypeUnknown, 0, module_list,
795 lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
796 const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
797 LanguageType symbol_language, lldb::addr_t offset,
798 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
799 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
802 TargetSP target_sp(GetSP());
803 if (target_sp && num_names > 0) {
804 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
805 const bool internal = false;
806 const bool hardware = false;
807 const LazyBool skip_prologue = eLazyBoolCalculate;
808 sb_bp = target_sp->CreateBreakpoint(
809 module_list.get(), comp_unit_list.get(), symbol_names, num_names,
810 name_type_mask, symbol_language, offset, skip_prologue, internal,
815 log->Printf("SBTarget(%p)::BreakpointCreateByName (symbols={",
816 static_cast<void *>(target_sp.get()));
817 for (uint32_t i = 0; i < num_names; i++) {
819 if (i < num_names - 1)
823 if (symbol_names[i] != NULL)
824 log->Printf("\"%s\"%c ", symbol_names[i], sep);
826 log->Printf("\"<NULL>\"%c ", sep);
828 log->Printf("name_type: %d) => SBBreakpoint(%p)", name_type_mask,
829 static_cast<void *>(sb_bp.GetSP().get()));
835 SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
836 const char *module_name) {
837 SBFileSpecList module_spec_list;
838 SBFileSpecList comp_unit_list;
839 if (module_name && module_name[0]) {
840 module_spec_list.Append(FileSpec(module_name, false));
842 return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown,
843 module_spec_list, comp_unit_list);
847 SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
848 const SBFileSpecList &module_list,
849 const SBFileSpecList &comp_unit_list) {
850 return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown,
851 module_list, comp_unit_list);
854 lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(
855 const char *symbol_name_regex, LanguageType symbol_language,
856 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
857 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
860 TargetSP target_sp(GetSP());
861 if (target_sp && symbol_name_regex && symbol_name_regex[0]) {
862 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
863 RegularExpression regexp((llvm::StringRef(symbol_name_regex)));
864 const bool internal = false;
865 const bool hardware = false;
866 const LazyBool skip_prologue = eLazyBoolCalculate;
868 sb_bp = target_sp->CreateFuncRegexBreakpoint(
869 module_list.get(), comp_unit_list.get(), regexp, symbol_language,
870 skip_prologue, internal, hardware);
874 log->Printf("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") "
875 "=> SBBreakpoint(%p)",
876 static_cast<void *>(target_sp.get()), symbol_name_regex,
877 static_cast<void *>(sb_bp.GetSP().get()));
882 SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) {
883 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
886 TargetSP target_sp(GetSP());
888 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
889 const bool hardware = false;
890 sb_bp = target_sp->CreateBreakpoint(address, false, hardware);
894 log->Printf("SBTarget(%p)::BreakpointCreateByAddress (address=%" PRIu64
895 ") => SBBreakpoint(%p)",
896 static_cast<void *>(target_sp.get()),
897 static_cast<uint64_t>(address),
898 static_cast<void *>(sb_bp.GetSP().get()));
903 SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) {
904 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
907 TargetSP target_sp(GetSP());
908 if (!sb_address.IsValid()) {
910 log->Printf("SBTarget(%p)::BreakpointCreateBySBAddress called with "
912 static_cast<void *>(target_sp.get()));
917 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
918 const bool hardware = false;
919 sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware);
924 sb_address.GetDescription(s);
925 log->Printf("SBTarget(%p)::BreakpointCreateBySBAddress (address=%s) => "
927 static_cast<void *>(target_sp.get()), s.GetData(),
928 static_cast<void *>(sb_bp.GetSP().get()));
935 SBTarget::BreakpointCreateBySourceRegex(const char *source_regex,
936 const lldb::SBFileSpec &source_file,
937 const char *module_name) {
938 SBFileSpecList module_spec_list;
940 if (module_name && module_name[0]) {
941 module_spec_list.Append(FileSpec(module_name, false));
944 SBFileSpecList source_file_list;
945 if (source_file.IsValid()) {
946 source_file_list.Append(source_file);
949 return BreakpointCreateBySourceRegex(source_regex, module_spec_list,
953 lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
954 const char *source_regex, const SBFileSpecList &module_list,
955 const lldb::SBFileSpecList &source_file_list) {
956 return BreakpointCreateBySourceRegex(source_regex, module_list,
957 source_file_list, SBStringList());
960 lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
961 const char *source_regex, const SBFileSpecList &module_list,
962 const lldb::SBFileSpecList &source_file_list,
963 const SBStringList &func_names) {
964 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
967 TargetSP target_sp(GetSP());
968 if (target_sp && source_regex && source_regex[0]) {
969 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
970 const bool hardware = false;
971 const LazyBool move_to_nearest_code = eLazyBoolCalculate;
972 RegularExpression regexp((llvm::StringRef(source_regex)));
973 std::unordered_set<std::string> func_names_set;
974 for (size_t i = 0; i < func_names.GetSize(); i++) {
975 func_names_set.insert(func_names.GetStringAtIndex(i));
978 sb_bp = target_sp->CreateSourceRegexBreakpoint(
979 module_list.get(), source_file_list.get(), func_names_set, regexp,
980 false, hardware, move_to_nearest_code);
984 log->Printf("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") "
985 "=> SBBreakpoint(%p)",
986 static_cast<void *>(target_sp.get()), source_regex,
987 static_cast<void *>(sb_bp.GetSP().get()));
993 SBTarget::BreakpointCreateForException(lldb::LanguageType language,
994 bool catch_bp, bool throw_bp) {
995 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
998 TargetSP target_sp(GetSP());
1000 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1001 const bool hardware = false;
1002 sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp,
1007 log->Printf("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: "
1008 "%s throw: %s) => SBBreakpoint(%p)",
1009 static_cast<void *>(target_sp.get()),
1010 Language::GetNameForLanguageType(language),
1011 catch_bp ? "on" : "off", throw_bp ? "on" : "off",
1012 static_cast<void *>(sb_bp.GetSP().get()));
1017 uint32_t SBTarget::GetNumBreakpoints() const {
1018 TargetSP target_sp(GetSP());
1020 // The breakpoint list is thread safe, no need to lock
1021 return target_sp->GetBreakpointList().GetSize();
1026 SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const {
1027 SBBreakpoint sb_breakpoint;
1028 TargetSP target_sp(GetSP());
1030 // The breakpoint list is thread safe, no need to lock
1031 sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
1033 return sb_breakpoint;
1036 bool SBTarget::BreakpointDelete(break_id_t bp_id) {
1037 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1039 bool result = false;
1040 TargetSP target_sp(GetSP());
1042 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1043 result = target_sp->RemoveBreakpointByID(bp_id);
1047 log->Printf("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i",
1048 static_cast<void *>(target_sp.get()),
1049 static_cast<uint32_t>(bp_id), result);
1054 SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) {
1055 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1057 SBBreakpoint sb_breakpoint;
1058 TargetSP target_sp(GetSP());
1059 if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) {
1060 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1061 sb_breakpoint = target_sp->GetBreakpointByID(bp_id);
1066 "SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)",
1067 static_cast<void *>(target_sp.get()), static_cast<uint32_t>(bp_id),
1068 static_cast<void *>(sb_breakpoint.GetSP().get()));
1070 return sb_breakpoint;
1073 bool SBTarget::FindBreakpointsByName(const char *name,
1074 SBBreakpointList &bkpts) {
1075 TargetSP target_sp(GetSP());
1077 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1078 BreakpointList bkpt_list(false);
1080 target_sp->GetBreakpointList().FindBreakpointsByName(name, bkpt_list);
1083 for (BreakpointSP bkpt_sp : bkpt_list.Breakpoints()) {
1084 bkpts.AppendByID(bkpt_sp->GetID());
1090 void SBTarget::GetBreakpointNames(SBStringList &names)
1094 TargetSP target_sp(GetSP());
1096 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1098 std::vector<std::string> name_vec;
1099 target_sp->GetBreakpointNames(name_vec);
1100 for (auto name : name_vec)
1101 names.AppendString(name.c_str());
1105 void SBTarget::DeleteBreakpointName(const char *name)
1107 TargetSP target_sp(GetSP());
1109 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1110 target_sp->DeleteBreakpointName(ConstString(name));
1114 bool SBTarget::EnableAllBreakpoints() {
1115 TargetSP target_sp(GetSP());
1117 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1118 target_sp->EnableAllowedBreakpoints();
1124 bool SBTarget::DisableAllBreakpoints() {
1125 TargetSP target_sp(GetSP());
1127 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1128 target_sp->DisableAllowedBreakpoints();
1134 bool SBTarget::DeleteAllBreakpoints() {
1135 TargetSP target_sp(GetSP());
1137 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1138 target_sp->RemoveAllowedBreakpoints();
1144 lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file,
1145 SBBreakpointList &new_bps) {
1146 SBStringList empty_name_list;
1147 return BreakpointsCreateFromFile(source_file, empty_name_list, new_bps);
1150 lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file,
1151 SBStringList &matching_names,
1152 SBBreakpointList &new_bps) {
1154 TargetSP target_sp(GetSP());
1156 sberr.SetErrorString(
1157 "BreakpointCreateFromFile called with invalid target.");
1160 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1162 BreakpointIDList bp_ids;
1164 std::vector<std::string> name_vector;
1165 size_t num_names = matching_names.GetSize();
1166 for (size_t i = 0; i < num_names; i++)
1167 name_vector.push_back(matching_names.GetStringAtIndex(i));
1169 sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(),
1170 name_vector, bp_ids);
1174 size_t num_bkpts = bp_ids.GetSize();
1175 for (size_t i = 0; i < num_bkpts; i++) {
1176 BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i);
1177 new_bps.AppendByID(bp_id.GetBreakpointID());
1182 lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file) {
1184 TargetSP target_sp(GetSP());
1186 sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
1189 SBBreakpointList bkpt_list(*this);
1190 return BreakpointsWriteToFile(dest_file, bkpt_list);
1193 lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file,
1194 SBBreakpointList &bkpt_list,
1197 TargetSP target_sp(GetSP());
1199 sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
1203 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1204 BreakpointIDList bp_id_list;
1205 bkpt_list.CopyToBreakpointIDList(bp_id_list);
1206 sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(),
1207 bp_id_list, append);
1211 uint32_t SBTarget::GetNumWatchpoints() const {
1212 TargetSP target_sp(GetSP());
1214 // The watchpoint list is thread safe, no need to lock
1215 return target_sp->GetWatchpointList().GetSize();
1220 SBWatchpoint SBTarget::GetWatchpointAtIndex(uint32_t idx) const {
1221 SBWatchpoint sb_watchpoint;
1222 TargetSP target_sp(GetSP());
1224 // The watchpoint list is thread safe, no need to lock
1225 sb_watchpoint.SetSP(target_sp->GetWatchpointList().GetByIndex(idx));
1227 return sb_watchpoint;
1230 bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) {
1231 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1233 bool result = false;
1234 TargetSP target_sp(GetSP());
1236 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1237 std::unique_lock<std::recursive_mutex> lock;
1238 target_sp->GetWatchpointList().GetListMutex(lock);
1239 result = target_sp->RemoveWatchpointByID(wp_id);
1243 log->Printf("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i",
1244 static_cast<void *>(target_sp.get()),
1245 static_cast<uint32_t>(wp_id), result);
1250 SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) {
1251 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1253 SBWatchpoint sb_watchpoint;
1254 lldb::WatchpointSP watchpoint_sp;
1255 TargetSP target_sp(GetSP());
1256 if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) {
1257 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1258 std::unique_lock<std::recursive_mutex> lock;
1259 target_sp->GetWatchpointList().GetListMutex(lock);
1260 watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id);
1261 sb_watchpoint.SetSP(watchpoint_sp);
1266 "SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)",
1267 static_cast<void *>(target_sp.get()), static_cast<uint32_t>(wp_id),
1268 static_cast<void *>(watchpoint_sp.get()));
1270 return sb_watchpoint;
1273 lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size,
1274 bool read, bool write,
1276 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1278 SBWatchpoint sb_watchpoint;
1279 lldb::WatchpointSP watchpoint_sp;
1280 TargetSP target_sp(GetSP());
1281 if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS &&
1283 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1284 uint32_t watch_type = 0;
1286 watch_type |= LLDB_WATCH_TYPE_READ;
1288 watch_type |= LLDB_WATCH_TYPE_WRITE;
1289 if (watch_type == 0) {
1290 error.SetErrorString(
1291 "Can't create a watchpoint that is neither read nor write.");
1292 return sb_watchpoint;
1295 // Target::CreateWatchpoint() is thread safe.
1297 // This API doesn't take in a type, so we can't figure out what it is.
1298 CompilerType *type = NULL;
1300 target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
1301 error.SetError(cw_error);
1302 sb_watchpoint.SetSP(watchpoint_sp);
1306 log->Printf("SBTarget(%p)::WatchAddress (addr=0x%" PRIx64
1307 ", 0x%u) => SBWatchpoint(%p)",
1308 static_cast<void *>(target_sp.get()), addr,
1309 static_cast<uint32_t>(size),
1310 static_cast<void *>(watchpoint_sp.get()));
1312 return sb_watchpoint;
1315 bool SBTarget::EnableAllWatchpoints() {
1316 TargetSP target_sp(GetSP());
1318 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1319 std::unique_lock<std::recursive_mutex> lock;
1320 target_sp->GetWatchpointList().GetListMutex(lock);
1321 target_sp->EnableAllWatchpoints();
1327 bool SBTarget::DisableAllWatchpoints() {
1328 TargetSP target_sp(GetSP());
1330 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1331 std::unique_lock<std::recursive_mutex> lock;
1332 target_sp->GetWatchpointList().GetListMutex(lock);
1333 target_sp->DisableAllWatchpoints();
1339 SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr,
1342 lldb::ValueObjectSP new_value_sp;
1343 if (IsValid() && name && *name && addr.IsValid() && type.IsValid()) {
1344 lldb::addr_t load_addr(addr.GetLoadAddress(*this));
1345 ExecutionContext exe_ctx(
1346 ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
1347 CompilerType ast_type(type.GetSP()->GetCompilerType(true));
1348 new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr,
1351 sb_value.SetSP(new_value_sp);
1352 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1355 log->Printf("SBTarget(%p)::CreateValueFromAddress => \"%s\"",
1356 static_cast<void *>(m_opaque_sp.get()),
1357 new_value_sp->GetName().AsCString());
1359 log->Printf("SBTarget(%p)::CreateValueFromAddress => NULL",
1360 static_cast<void *>(m_opaque_sp.get()));
1365 lldb::SBValue SBTarget::CreateValueFromData(const char *name, lldb::SBData data,
1366 lldb::SBType type) {
1368 lldb::ValueObjectSP new_value_sp;
1369 if (IsValid() && name && *name && data.IsValid() && type.IsValid()) {
1370 DataExtractorSP extractor(*data);
1371 ExecutionContext exe_ctx(
1372 ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
1373 CompilerType ast_type(type.GetSP()->GetCompilerType(true));
1374 new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor,
1377 sb_value.SetSP(new_value_sp);
1378 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1381 log->Printf("SBTarget(%p)::CreateValueFromData => \"%s\"",
1382 static_cast<void *>(m_opaque_sp.get()),
1383 new_value_sp->GetName().AsCString());
1385 log->Printf("SBTarget(%p)::CreateValueFromData => NULL",
1386 static_cast<void *>(m_opaque_sp.get()));
1391 lldb::SBValue SBTarget::CreateValueFromExpression(const char *name,
1394 lldb::ValueObjectSP new_value_sp;
1395 if (IsValid() && name && *name && expr && *expr) {
1396 ExecutionContext exe_ctx(
1397 ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
1399 ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx);
1401 sb_value.SetSP(new_value_sp);
1402 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1405 log->Printf("SBTarget(%p)::CreateValueFromExpression => \"%s\"",
1406 static_cast<void *>(m_opaque_sp.get()),
1407 new_value_sp->GetName().AsCString());
1409 log->Printf("SBTarget(%p)::CreateValueFromExpression => NULL",
1410 static_cast<void *>(m_opaque_sp.get()));
1415 bool SBTarget::DeleteAllWatchpoints() {
1416 TargetSP target_sp(GetSP());
1418 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1419 std::unique_lock<std::recursive_mutex> lock;
1420 target_sp->GetWatchpointList().GetListMutex(lock);
1421 target_sp->RemoveAllWatchpoints();
1427 lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
1428 const char *uuid_cstr) {
1429 return AddModule(path, triple, uuid_cstr, NULL);
1432 lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
1433 const char *uuid_cstr, const char *symfile) {
1434 lldb::SBModule sb_module;
1435 TargetSP target_sp(GetSP());
1437 ModuleSpec module_spec;
1439 module_spec.GetFileSpec().SetFile(path, false);
1442 module_spec.GetUUID().SetFromCString(uuid_cstr);
1445 module_spec.GetArchitecture() = Platform::GetAugmentedArchSpec(
1446 target_sp->GetPlatform().get(), triple);
1448 module_spec.GetArchitecture() = target_sp->GetArchitecture();
1451 module_spec.GetSymbolFileSpec().SetFile(symfile, false);
1453 sb_module.SetSP(target_sp->GetSharedModule(module_spec));
1458 lldb::SBModule SBTarget::AddModule(const SBModuleSpec &module_spec) {
1459 lldb::SBModule sb_module;
1460 TargetSP target_sp(GetSP());
1462 sb_module.SetSP(target_sp->GetSharedModule(*module_spec.m_opaque_ap));
1466 bool SBTarget::AddModule(lldb::SBModule &module) {
1467 TargetSP target_sp(GetSP());
1469 target_sp->GetImages().AppendIfNeeded(module.GetSP());
1475 uint32_t SBTarget::GetNumModules() const {
1476 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1479 TargetSP target_sp(GetSP());
1481 // The module list is thread safe, no need to lock
1482 num = target_sp->GetImages().GetSize();
1486 log->Printf("SBTarget(%p)::GetNumModules () => %d",
1487 static_cast<void *>(target_sp.get()), num);
1492 void SBTarget::Clear() {
1493 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1496 log->Printf("SBTarget(%p)::Clear ()",
1497 static_cast<void *>(m_opaque_sp.get()));
1499 m_opaque_sp.reset();
1502 SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) {
1504 TargetSP target_sp(GetSP());
1505 if (target_sp && sb_file_spec.IsValid()) {
1506 ModuleSpec module_spec(*sb_file_spec);
1507 // The module list is thread safe, no need to lock
1508 sb_module.SetSP(target_sp->GetImages().FindFirstModule(module_spec));
1513 lldb::ByteOrder SBTarget::GetByteOrder() {
1514 TargetSP target_sp(GetSP());
1516 return target_sp->GetArchitecture().GetByteOrder();
1517 return eByteOrderInvalid;
1520 const char *SBTarget::GetTriple() {
1521 TargetSP target_sp(GetSP());
1523 std::string triple(target_sp->GetArchitecture().GetTriple().str());
1524 // Unique the string so we don't run into ownership issues since
1525 // the const strings put the string into the string pool once and
1526 // the strings never comes out
1527 ConstString const_triple(triple.c_str());
1528 return const_triple.GetCString();
1533 uint32_t SBTarget::GetDataByteSize() {
1534 TargetSP target_sp(GetSP());
1536 return target_sp->GetArchitecture().GetDataByteSize();
1541 uint32_t SBTarget::GetCodeByteSize() {
1542 TargetSP target_sp(GetSP());
1544 return target_sp->GetArchitecture().GetCodeByteSize();
1549 uint32_t SBTarget::GetAddressByteSize() {
1550 TargetSP target_sp(GetSP());
1552 return target_sp->GetArchitecture().GetAddressByteSize();
1553 return sizeof(void *);
1556 SBModule SBTarget::GetModuleAtIndex(uint32_t idx) {
1557 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1561 TargetSP target_sp(GetSP());
1563 // The module list is thread safe, no need to lock
1564 module_sp = target_sp->GetImages().GetModuleAtIndex(idx);
1565 sb_module.SetSP(module_sp);
1569 log->Printf("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)",
1570 static_cast<void *>(target_sp.get()), idx,
1571 static_cast<void *>(module_sp.get()));
1576 bool SBTarget::RemoveModule(lldb::SBModule module) {
1577 TargetSP target_sp(GetSP());
1579 return target_sp->GetImages().Remove(module.GetSP());
1583 SBBroadcaster SBTarget::GetBroadcaster() const {
1584 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1586 TargetSP target_sp(GetSP());
1587 SBBroadcaster broadcaster(target_sp.get(), false);
1590 log->Printf("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)",
1591 static_cast<void *>(target_sp.get()),
1592 static_cast<void *>(broadcaster.get()));
1597 bool SBTarget::GetDescription(SBStream &description,
1598 lldb::DescriptionLevel description_level) {
1599 Stream &strm = description.ref();
1601 TargetSP target_sp(GetSP());
1603 target_sp->Dump(&strm, description_level);
1605 strm.PutCString("No value");
1610 lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name,
1611 uint32_t name_type_mask) {
1612 lldb::SBSymbolContextList sb_sc_list;
1613 if (name && name[0]) {
1614 TargetSP target_sp(GetSP());
1616 const bool symbols_ok = true;
1617 const bool inlines_ok = true;
1618 const bool append = true;
1619 target_sp->GetImages().FindFunctions(ConstString(name), name_type_mask,
1620 symbols_ok, inlines_ok, append,
1627 lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name,
1628 uint32_t max_matches,
1629 MatchType matchtype) {
1630 lldb::SBSymbolContextList sb_sc_list;
1631 if (name && name[0]) {
1632 llvm::StringRef name_ref(name);
1633 TargetSP target_sp(GetSP());
1635 std::string regexstr;
1636 switch (matchtype) {
1637 case eMatchTypeRegex:
1638 target_sp->GetImages().FindFunctions(RegularExpression(name_ref), true,
1639 true, true, *sb_sc_list);
1641 case eMatchTypeStartsWith:
1642 regexstr = llvm::Regex::escape(name) + ".*";
1643 target_sp->GetImages().FindFunctions(RegularExpression(regexstr), true,
1644 true, true, *sb_sc_list);
1647 target_sp->GetImages().FindFunctions(ConstString(name),
1648 eFunctionNameTypeAny, true, true,
1657 lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
1658 TargetSP target_sp(GetSP());
1659 if (typename_cstr && typename_cstr[0] && target_sp) {
1660 ConstString const_typename(typename_cstr);
1662 const bool exact_match = false;
1664 const ModuleList &module_list = target_sp->GetImages();
1665 size_t count = module_list.GetSize();
1666 for (size_t idx = 0; idx < count; idx++) {
1667 ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
1670 module_sp->FindFirstType(sc, const_typename, exact_match));
1672 return SBType(type_sp);
1676 // Didn't find the type in the symbols; try the Objective-C runtime
1677 // if one is installed
1679 ProcessSP process_sp(target_sp->GetProcessSP());
1682 ObjCLanguageRuntime *objc_language_runtime =
1683 process_sp->GetObjCLanguageRuntime();
1685 if (objc_language_runtime) {
1686 DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
1688 if (objc_decl_vendor) {
1689 std::vector<clang::NamedDecl *> decls;
1691 if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) {
1692 if (CompilerType type = ClangASTContext::GetTypeForDecl(decls[0])) {
1693 return SBType(type);
1700 // No matches, search for basic typename matches
1701 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1703 return SBType(ClangASTContext::GetBasicType(clang_ast->getASTContext(),
1709 SBType SBTarget::GetBasicType(lldb::BasicType type) {
1710 TargetSP target_sp(GetSP());
1712 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1715 ClangASTContext::GetBasicType(clang_ast->getASTContext(), type));
1720 lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
1721 SBTypeList sb_type_list;
1722 TargetSP target_sp(GetSP());
1723 if (typename_cstr && typename_cstr[0] && target_sp) {
1724 ModuleList &images = target_sp->GetImages();
1725 ConstString const_typename(typename_cstr);
1726 bool exact_match = false;
1729 llvm::DenseSet<SymbolFile *> searched_symbol_files;
1730 uint32_t num_matches =
1731 images.FindTypes(sc, const_typename, exact_match, UINT32_MAX,
1732 searched_symbol_files, type_list);
1734 if (num_matches > 0) {
1735 for (size_t idx = 0; idx < num_matches; idx++) {
1736 TypeSP type_sp(type_list.GetTypeAtIndex(idx));
1738 sb_type_list.Append(SBType(type_sp));
1742 // Try the Objective-C runtime if one is installed
1744 ProcessSP process_sp(target_sp->GetProcessSP());
1747 ObjCLanguageRuntime *objc_language_runtime =
1748 process_sp->GetObjCLanguageRuntime();
1750 if (objc_language_runtime) {
1751 DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
1753 if (objc_decl_vendor) {
1754 std::vector<clang::NamedDecl *> decls;
1756 if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) {
1757 for (clang::NamedDecl *decl : decls) {
1758 if (CompilerType type = ClangASTContext::GetTypeForDecl(decl)) {
1759 sb_type_list.Append(SBType(type));
1767 if (sb_type_list.GetSize() == 0) {
1768 // No matches, search for basic typename matches
1769 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1771 sb_type_list.Append(SBType(ClangASTContext::GetBasicType(
1772 clang_ast->getASTContext(), const_typename)));
1775 return sb_type_list;
1778 SBValueList SBTarget::FindGlobalVariables(const char *name,
1779 uint32_t max_matches) {
1780 SBValueList sb_value_list;
1782 TargetSP target_sp(GetSP());
1783 if (name && target_sp) {
1784 VariableList variable_list;
1785 const bool append = true;
1786 const uint32_t match_count = target_sp->GetImages().FindGlobalVariables(
1787 ConstString(name), append, max_matches, variable_list);
1789 if (match_count > 0) {
1790 ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
1791 if (exe_scope == NULL)
1792 exe_scope = target_sp.get();
1793 for (uint32_t i = 0; i < match_count; ++i) {
1794 lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
1795 exe_scope, variable_list.GetVariableAtIndex(i)));
1797 sb_value_list.Append(SBValue(valobj_sp));
1802 return sb_value_list;
1805 SBValueList SBTarget::FindGlobalVariables(const char *name,
1806 uint32_t max_matches,
1807 MatchType matchtype) {
1808 SBValueList sb_value_list;
1810 TargetSP target_sp(GetSP());
1811 if (name && target_sp) {
1812 llvm::StringRef name_ref(name);
1813 VariableList variable_list;
1814 const bool append = true;
1816 std::string regexstr;
1817 uint32_t match_count;
1818 switch (matchtype) {
1819 case eMatchTypeNormal:
1820 match_count = target_sp->GetImages().FindGlobalVariables(
1821 ConstString(name), append, max_matches, variable_list);
1823 case eMatchTypeRegex:
1824 match_count = target_sp->GetImages().FindGlobalVariables(
1825 RegularExpression(name_ref), append, max_matches, variable_list);
1827 case eMatchTypeStartsWith:
1828 regexstr = llvm::Regex::escape(name) + ".*";
1829 match_count = target_sp->GetImages().FindGlobalVariables(
1830 RegularExpression(regexstr), append, max_matches, variable_list);
1834 if (match_count > 0) {
1835 ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
1836 if (exe_scope == NULL)
1837 exe_scope = target_sp.get();
1838 for (uint32_t i = 0; i < match_count; ++i) {
1839 lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
1840 exe_scope, variable_list.GetVariableAtIndex(i)));
1842 sb_value_list.Append(SBValue(valobj_sp));
1847 return sb_value_list;
1850 lldb::SBValue SBTarget::FindFirstGlobalVariable(const char *name) {
1851 SBValueList sb_value_list(FindGlobalVariables(name, 1));
1852 if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
1853 return sb_value_list.GetValueAtIndex(0);
1857 SBSourceManager SBTarget::GetSourceManager() {
1858 SBSourceManager source_manager(*this);
1859 return source_manager;
1862 lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
1864 return ReadInstructions(base_addr, count, NULL);
1867 lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
1869 const char *flavor_string) {
1870 SBInstructionList sb_instructions;
1872 TargetSP target_sp(GetSP());
1874 Address *addr_ptr = base_addr.get();
1877 DataBufferHeap data(
1878 target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0);
1879 bool prefer_file_cache = false;
1880 lldb_private::Status error;
1881 lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
1882 const size_t bytes_read =
1883 target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(),
1884 data.GetByteSize(), error, &load_addr);
1885 const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
1886 sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
1887 target_sp->GetArchitecture(), NULL, flavor_string, *addr_ptr,
1888 data.GetBytes(), bytes_read, count, data_from_file));
1892 return sb_instructions;
1895 lldb::SBInstructionList SBTarget::GetInstructions(lldb::SBAddress base_addr,
1898 return GetInstructionsWithFlavor(base_addr, NULL, buf, size);
1901 lldb::SBInstructionList
1902 SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr,
1903 const char *flavor_string, const void *buf,
1905 SBInstructionList sb_instructions;
1907 TargetSP target_sp(GetSP());
1911 if (base_addr.get())
1912 addr = *base_addr.get();
1914 const bool data_from_file = true;
1916 sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
1917 target_sp->GetArchitecture(), NULL, flavor_string, addr, buf, size,
1918 UINT32_MAX, data_from_file));
1921 return sb_instructions;
1924 lldb::SBInstructionList SBTarget::GetInstructions(lldb::addr_t base_addr,
1927 return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), NULL, buf,
1931 lldb::SBInstructionList
1932 SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr,
1933 const char *flavor_string, const void *buf,
1935 return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string,
1939 SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section,
1940 lldb::addr_t section_base_addr) {
1942 TargetSP target_sp(GetSP());
1944 if (!section.IsValid()) {
1945 sb_error.SetErrorStringWithFormat("invalid section");
1947 SectionSP section_sp(section.GetSP());
1949 if (section_sp->IsThreadSpecific()) {
1950 sb_error.SetErrorString(
1951 "thread specific sections are not yet supported");
1953 ProcessSP process_sp(target_sp->GetProcessSP());
1954 if (target_sp->SetSectionLoadAddress(section_sp, section_base_addr)) {
1955 ModuleSP module_sp(section_sp->GetModule());
1957 ModuleList module_list;
1958 module_list.Append(module_sp);
1959 target_sp->ModulesDidLoad(module_list);
1961 // Flush info in the process (stack frames, etc)
1963 process_sp->Flush();
1969 sb_error.SetErrorString("invalid target");
1974 SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) {
1977 TargetSP target_sp(GetSP());
1979 if (!section.IsValid()) {
1980 sb_error.SetErrorStringWithFormat("invalid section");
1982 SectionSP section_sp(section.GetSP());
1984 ProcessSP process_sp(target_sp->GetProcessSP());
1985 if (target_sp->SetSectionUnloaded(section_sp)) {
1986 ModuleSP module_sp(section_sp->GetModule());
1988 ModuleList module_list;
1989 module_list.Append(module_sp);
1990 target_sp->ModulesDidUnload(module_list, false);
1992 // Flush info in the process (stack frames, etc)
1994 process_sp->Flush();
1997 sb_error.SetErrorStringWithFormat("invalid section");
2001 sb_error.SetErrorStringWithFormat("invalid target");
2006 SBError SBTarget::SetModuleLoadAddress(lldb::SBModule module,
2007 int64_t slide_offset) {
2010 TargetSP target_sp(GetSP());
2012 ModuleSP module_sp(module.GetSP());
2014 bool changed = false;
2015 if (module_sp->SetLoadAddress(*target_sp, slide_offset, true, changed)) {
2016 // The load was successful, make sure that at least some sections
2017 // changed before we notify that our module was loaded.
2019 ModuleList module_list;
2020 module_list.Append(module_sp);
2021 target_sp->ModulesDidLoad(module_list);
2022 // Flush info in the process (stack frames, etc)
2023 ProcessSP process_sp(target_sp->GetProcessSP());
2025 process_sp->Flush();
2029 sb_error.SetErrorStringWithFormat("invalid module");
2033 sb_error.SetErrorStringWithFormat("invalid target");
2038 SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) {
2041 char path[PATH_MAX];
2042 TargetSP target_sp(GetSP());
2044 ModuleSP module_sp(module.GetSP());
2046 ObjectFile *objfile = module_sp->GetObjectFile();
2048 SectionList *section_list = objfile->GetSectionList();
2050 ProcessSP process_sp(target_sp->GetProcessSP());
2052 bool changed = false;
2053 const size_t num_sections = section_list->GetSize();
2054 for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
2055 SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
2057 changed |= target_sp->SetSectionUnloaded(section_sp);
2060 ModuleList module_list;
2061 module_list.Append(module_sp);
2062 target_sp->ModulesDidUnload(module_list, false);
2063 // Flush info in the process (stack frames, etc)
2064 ProcessSP process_sp(target_sp->GetProcessSP());
2066 process_sp->Flush();
2069 module_sp->GetFileSpec().GetPath(path, sizeof(path));
2070 sb_error.SetErrorStringWithFormat("no sections in object file '%s'",
2074 module_sp->GetFileSpec().GetPath(path, sizeof(path));
2075 sb_error.SetErrorStringWithFormat("no object file for module '%s'",
2079 sb_error.SetErrorStringWithFormat("invalid module");
2082 sb_error.SetErrorStringWithFormat("invalid target");
2087 lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name,
2088 lldb::SymbolType symbol_type) {
2089 SBSymbolContextList sb_sc_list;
2090 if (name && name[0]) {
2091 TargetSP target_sp(GetSP());
2094 target_sp->GetImages().FindSymbolsWithNameAndType(
2095 ConstString(name), symbol_type, *sb_sc_list, append);
2101 lldb::SBValue SBTarget::EvaluateExpression(const char *expr) {
2102 TargetSP target_sp(GetSP());
2106 SBExpressionOptions options;
2107 lldb::DynamicValueType fetch_dynamic_value =
2108 target_sp->GetPreferDynamicValue();
2109 options.SetFetchDynamicValue(fetch_dynamic_value);
2110 options.SetUnwindOnError(true);
2111 return EvaluateExpression(expr, options);
2114 lldb::SBValue SBTarget::EvaluateExpression(const char *expr,
2115 const SBExpressionOptions &options) {
2116 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
2117 #if !defined(LLDB_DISABLE_PYTHON)
2118 Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
2120 SBValue expr_result;
2121 ExpressionResults exe_results = eExpressionSetupError;
2122 ValueObjectSP expr_value_sp;
2123 TargetSP target_sp(GetSP());
2124 StackFrame *frame = NULL;
2126 if (expr == NULL || expr[0] == '\0') {
2129 "SBTarget::EvaluateExpression called with an empty expression");
2133 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
2134 ExecutionContext exe_ctx(m_opaque_sp.get());
2137 log->Printf("SBTarget()::EvaluateExpression (expr=\"%s\")...", expr);
2139 frame = exe_ctx.GetFramePtr();
2140 Target *target = exe_ctx.GetTargetPtr();
2143 #ifdef LLDB_CONFIGURATION_DEBUG
2144 StreamString frame_description;
2146 frame->DumpUsingSettingsFormat(&frame_description);
2147 llvm::PrettyStackTraceFormat stack_trace(
2148 "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = "
2150 expr, options.GetFetchDynamicValue(),
2151 frame_description.GetString().str().c_str());
2154 target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
2156 expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
2159 log->Printf("SBTarget::EvaluateExpression () => error: could not "
2160 "reconstruct frame object for this SBTarget.");
2163 #ifndef LLDB_DISABLE_PYTHON
2165 expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is "
2166 "%s, summary %s **",
2167 expr_result.GetValue(), expr_result.GetSummary());
2170 log->Printf("SBTarget(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) "
2171 "(execution result=%d)",
2172 static_cast<void *>(frame), expr,
2173 static_cast<void *>(expr_value_sp.get()), exe_results);
2179 lldb::addr_t SBTarget::GetStackRedZoneSize() {
2180 TargetSP target_sp(GetSP());
2183 ProcessSP process_sp(target_sp->GetProcessSP());
2185 abi_sp = process_sp->GetABI();
2187 abi_sp = ABI::FindPlugin(ProcessSP(), target_sp->GetArchitecture());
2189 return abi_sp->GetRedZoneSize();
2194 lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
2195 lldb::SBLaunchInfo launch_info(NULL);
2196 TargetSP target_sp(GetSP());
2198 launch_info.ref() = m_opaque_sp->GetProcessLaunchInfo();
2202 void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) {
2203 TargetSP target_sp(GetSP());
2205 m_opaque_sp->SetProcessLaunchInfo(launch_info.ref());