1 //===-- SBTarget.cpp --------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBTarget.h"
10 #include "SBReproducerPrivate.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/SBStructuredData.h"
27 #include "lldb/API/SBSymbolContextList.h"
28 #include "lldb/Breakpoint/BreakpointID.h"
29 #include "lldb/Breakpoint/BreakpointIDList.h"
30 #include "lldb/Breakpoint/BreakpointList.h"
31 #include "lldb/Breakpoint/BreakpointLocation.h"
32 #include "lldb/Core/Address.h"
33 #include "lldb/Core/AddressResolver.h"
34 #include "lldb/Core/AddressResolverName.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/StructuredDataImpl.h"
43 #include "lldb/Core/ValueObjectConstResult.h"
44 #include "lldb/Core/ValueObjectList.h"
45 #include "lldb/Core/ValueObjectVariable.h"
46 #include "lldb/Host/Host.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/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/Args.h"
62 #include "lldb/Utility/FileSpec.h"
63 #include "lldb/Utility/ProcessInfo.h"
64 #include "lldb/Utility/RegularExpression.h"
66 #include "Commands/CommandObjectBreakpoint.h"
67 #include "lldb/Interpreter/CommandReturnObject.h"
68 #include "llvm/Support/PrettyStackTrace.h"
69 #include "llvm/Support/Regex.h"
72 using namespace lldb_private;
74 #define DEFAULT_DISASM_BYTE_SIZE 32
78 Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) {
79 std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex());
81 auto process_sp = target.GetProcessSP();
83 const auto state = process_sp->GetState();
84 if (process_sp->IsAlive() && state == eStateConnected) {
85 // If we are already connected, then we have already specified the
86 // listener, so if a valid listener is supplied, we need to error out to
87 // let the client know.
88 if (attach_info.GetListener())
89 return Status("process is connected and already has a listener, pass "
94 return target.Attach(attach_info, nullptr);
99 // SBTarget constructor
100 SBTarget::SBTarget() : m_opaque_sp() {
101 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTarget);
104 SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) {
105 LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &), rhs);
108 SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) {
109 LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &), target_sp);
112 const SBTarget &SBTarget::operator=(const SBTarget &rhs) {
113 LLDB_RECORD_METHOD(const lldb::SBTarget &,
114 SBTarget, operator=,(const lldb::SBTarget &), rhs);
117 m_opaque_sp = rhs.m_opaque_sp;
118 return LLDB_RECORD_RESULT(*this);
122 SBTarget::~SBTarget() {}
124 bool SBTarget::EventIsTargetEvent(const SBEvent &event) {
125 LLDB_RECORD_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent,
126 (const lldb::SBEvent &), event);
128 return Target::TargetEventData::GetEventDataFromEvent(event.get()) != nullptr;
131 SBTarget SBTarget::GetTargetFromEvent(const SBEvent &event) {
132 LLDB_RECORD_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent,
133 (const lldb::SBEvent &), event);
135 return LLDB_RECORD_RESULT(
136 Target::TargetEventData::GetTargetFromEvent(event.get()));
139 uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent &event) {
140 LLDB_RECORD_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent,
141 (const lldb::SBEvent &), event);
143 const ModuleList module_list =
144 Target::TargetEventData::GetModuleListFromEvent(event.get());
145 return module_list.GetSize();
148 SBModule SBTarget::GetModuleAtIndexFromEvent(const uint32_t idx,
149 const SBEvent &event) {
150 LLDB_RECORD_STATIC_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndexFromEvent,
151 (const uint32_t, const lldb::SBEvent &), idx,
154 const ModuleList module_list =
155 Target::TargetEventData::GetModuleListFromEvent(event.get());
156 return LLDB_RECORD_RESULT(SBModule(module_list.GetModuleAtIndex(idx)));
159 const char *SBTarget::GetBroadcasterClassName() {
160 LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBTarget,
161 GetBroadcasterClassName);
163 return Target::GetStaticBroadcasterClass().AsCString();
166 bool SBTarget::IsValid() const {
167 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, IsValid);
168 return this->operator bool();
170 SBTarget::operator bool() const {
171 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, operator bool);
173 return m_opaque_sp.get() != nullptr && m_opaque_sp->IsValid();
176 SBProcess SBTarget::GetProcess() {
177 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBTarget, GetProcess);
179 SBProcess sb_process;
180 ProcessSP process_sp;
181 TargetSP target_sp(GetSP());
183 process_sp = target_sp->GetProcessSP();
184 sb_process.SetSP(process_sp);
187 return LLDB_RECORD_RESULT(sb_process);
190 SBPlatform SBTarget::GetPlatform() {
191 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBTarget, GetPlatform);
193 TargetSP target_sp(GetSP());
195 return LLDB_RECORD_RESULT(SBPlatform());
198 platform.m_opaque_sp = target_sp->GetPlatform();
200 return LLDB_RECORD_RESULT(platform);
203 SBDebugger SBTarget::GetDebugger() const {
204 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBDebugger, SBTarget, GetDebugger);
207 TargetSP target_sp(GetSP());
209 debugger.reset(target_sp->GetDebugger().shared_from_this());
210 return LLDB_RECORD_RESULT(debugger);
213 SBStructuredData SBTarget::GetStatistics() {
214 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBTarget, GetStatistics);
216 SBStructuredData data;
217 TargetSP target_sp(GetSP());
219 return LLDB_RECORD_RESULT(data);
221 auto stats_up = llvm::make_unique<StructuredData::Dictionary>();
223 for (auto &Entry : target_sp->GetStatistics()) {
224 std::string Desc = lldb_private::GetStatDescription(
225 static_cast<lldb_private::StatisticKind>(i));
226 stats_up->AddIntegerItem(Desc, Entry);
230 data.m_impl_up->SetObjectSP(std::move(stats_up));
231 return LLDB_RECORD_RESULT(data);
234 void SBTarget::SetCollectingStats(bool v) {
235 LLDB_RECORD_METHOD(void, SBTarget, SetCollectingStats, (bool), v);
237 TargetSP target_sp(GetSP());
240 return target_sp->SetCollectingStats(v);
243 bool SBTarget::GetCollectingStats() {
244 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, GetCollectingStats);
246 TargetSP target_sp(GetSP());
249 return target_sp->GetCollectingStats();
252 SBProcess SBTarget::LoadCore(const char *core_file) {
253 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *),
256 lldb::SBError error; // Ignored
257 return LLDB_RECORD_RESULT(LoadCore(core_file, error));
260 SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) {
261 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore,
262 (const char *, lldb::SBError &), core_file, error);
264 SBProcess sb_process;
265 TargetSP target_sp(GetSP());
267 FileSpec filespec(core_file);
268 FileSystem::Instance().Resolve(filespec);
269 ProcessSP process_sp(target_sp->CreateProcess(
270 target_sp->GetDebugger().GetListener(), "", &filespec));
272 error.SetError(process_sp->LoadCore());
274 sb_process.SetSP(process_sp);
276 error.SetErrorString("Failed to create the process");
279 error.SetErrorString("SBTarget is invalid");
281 return LLDB_RECORD_RESULT(sb_process);
284 SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp,
285 const char *working_directory) {
286 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LaunchSimple,
287 (const char **, const char **, const char *), argv, envp,
290 char *stdin_path = nullptr;
291 char *stdout_path = nullptr;
292 char *stderr_path = nullptr;
293 uint32_t launch_flags = 0;
294 bool stop_at_entry = false;
296 SBListener listener = GetDebugger().GetListener();
297 return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path,
298 stdout_path, stderr_path, working_directory,
299 launch_flags, stop_at_entry, error));
302 SBError SBTarget::Install() {
303 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBTarget, Install);
306 TargetSP target_sp(GetSP());
308 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
309 sb_error.ref() = target_sp->Install(nullptr);
311 return LLDB_RECORD_RESULT(sb_error);
314 SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
315 char const **envp, const char *stdin_path,
316 const char *stdout_path, const char *stderr_path,
317 const char *working_directory,
318 uint32_t launch_flags, // See LaunchFlags
319 bool stop_at_entry, lldb::SBError &error) {
320 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch,
321 (lldb::SBListener &, const char **, const char **,
322 const char *, const char *, const char *, const char *,
323 uint32_t, bool, lldb::SBError &),
324 listener, argv, envp, stdin_path, stdout_path, stderr_path,
325 working_directory, launch_flags, stop_at_entry, error);
327 SBProcess sb_process;
328 ProcessSP process_sp;
329 TargetSP target_sp(GetSP());
332 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
335 launch_flags |= eLaunchFlagStopAtEntry;
337 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
338 launch_flags |= eLaunchFlagDisableASLR;
340 StateType state = eStateInvalid;
341 process_sp = target_sp->GetProcessSP();
343 state = process_sp->GetState();
345 if (process_sp->IsAlive() && state != eStateConnected) {
346 if (state == eStateAttaching)
347 error.SetErrorString("process attach is in progress");
349 error.SetErrorString("a process is already being debugged");
350 return LLDB_RECORD_RESULT(sb_process);
354 if (state == eStateConnected) {
355 // If we are already connected, then we have already specified the
356 // listener, so if a valid listener is supplied, we need to error out to
357 // let the client know.
358 if (listener.IsValid()) {
359 error.SetErrorString("process is connected and already has a listener, "
360 "pass empty listener");
361 return LLDB_RECORD_RESULT(sb_process);
365 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
366 launch_flags |= eLaunchFlagDisableSTDIO;
368 ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path),
369 FileSpec(stderr_path),
370 FileSpec(working_directory), launch_flags);
372 Module *exe_module = target_sp->GetExecutableModulePointer();
374 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
376 launch_info.GetArguments().AppendArguments(argv);
378 launch_info.GetEnvironment() = Environment(envp);
380 if (listener.IsValid())
381 launch_info.SetListener(listener.GetSP());
383 error.SetError(target_sp->Launch(launch_info, nullptr));
385 sb_process.SetSP(target_sp->GetProcessSP());
387 error.SetErrorString("SBTarget is invalid");
390 return LLDB_RECORD_RESULT(sb_process);
393 SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) {
394 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch,
395 (lldb::SBLaunchInfo &, lldb::SBError &), sb_launch_info,
399 SBProcess sb_process;
400 TargetSP target_sp(GetSP());
403 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
404 StateType state = eStateInvalid;
406 ProcessSP process_sp = target_sp->GetProcessSP();
408 state = process_sp->GetState();
410 if (process_sp->IsAlive() && state != eStateConnected) {
411 if (state == eStateAttaching)
412 error.SetErrorString("process attach is in progress");
414 error.SetErrorString("a process is already being debugged");
415 return LLDB_RECORD_RESULT(sb_process);
420 lldb_private::ProcessLaunchInfo launch_info = sb_launch_info.ref();
422 if (!launch_info.GetExecutableFile()) {
423 Module *exe_module = target_sp->GetExecutableModulePointer();
425 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
428 const ArchSpec &arch_spec = target_sp->GetArchitecture();
429 if (arch_spec.IsValid())
430 launch_info.GetArchitecture() = arch_spec;
432 error.SetError(target_sp->Launch(launch_info, nullptr));
433 sb_launch_info.set_ref(launch_info);
434 sb_process.SetSP(target_sp->GetProcessSP());
436 error.SetErrorString("SBTarget is invalid");
439 return LLDB_RECORD_RESULT(sb_process);
442 lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) {
443 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Attach,
444 (lldb::SBAttachInfo &, lldb::SBError &), sb_attach_info,
447 SBProcess sb_process;
448 TargetSP target_sp(GetSP());
451 ProcessAttachInfo &attach_info = sb_attach_info.ref();
452 if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid()) {
453 PlatformSP platform_sp = target_sp->GetPlatform();
454 // See if we can pre-verify if a process exists or not
455 if (platform_sp && platform_sp->IsConnected()) {
456 lldb::pid_t attach_pid = attach_info.GetProcessID();
457 ProcessInstanceInfo instance_info;
458 if (platform_sp->GetProcessInfo(attach_pid, instance_info)) {
459 attach_info.SetUserID(instance_info.GetEffectiveUserID());
461 error.ref().SetErrorStringWithFormat(
462 "no process found with process ID %" PRIu64, attach_pid);
463 return LLDB_RECORD_RESULT(sb_process);
467 error.SetError(AttachToProcess(attach_info, *target_sp));
469 sb_process.SetSP(target_sp->GetProcessSP());
471 error.SetErrorString("SBTarget is invalid");
474 return LLDB_RECORD_RESULT(sb_process);
477 lldb::SBProcess SBTarget::AttachToProcessWithID(
478 SBListener &listener,
479 lldb::pid_t pid, // The process ID to attach to
480 SBError &error // An error explaining what went wrong if attach fails
482 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID,
483 (lldb::SBListener &, lldb::pid_t, lldb::SBError &),
484 listener, pid, error);
486 SBProcess sb_process;
487 TargetSP target_sp(GetSP());
490 ProcessAttachInfo attach_info;
491 attach_info.SetProcessID(pid);
492 if (listener.IsValid())
493 attach_info.SetListener(listener.GetSP());
495 ProcessInstanceInfo instance_info;
496 if (target_sp->GetPlatform()->GetProcessInfo(pid, instance_info))
497 attach_info.SetUserID(instance_info.GetEffectiveUserID());
499 error.SetError(AttachToProcess(attach_info, *target_sp));
501 sb_process.SetSP(target_sp->GetProcessSP());
503 error.SetErrorString("SBTarget is invalid");
505 return LLDB_RECORD_RESULT(sb_process);
508 lldb::SBProcess SBTarget::AttachToProcessWithName(
509 SBListener &listener,
510 const char *name, // basename of process to attach to
511 bool wait_for, // if true wait for a new instance of "name" to be launched
512 SBError &error // An error explaining what went wrong if attach fails
514 LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithName,
515 (lldb::SBListener &, const char *, bool, lldb::SBError &),
516 listener, name, wait_for, error);
518 SBProcess sb_process;
519 TargetSP target_sp(GetSP());
521 if (name && target_sp) {
522 ProcessAttachInfo attach_info;
523 attach_info.GetExecutableFile().SetFile(name, FileSpec::Style::native);
524 attach_info.SetWaitForLaunch(wait_for);
525 if (listener.IsValid())
526 attach_info.SetListener(listener.GetSP());
528 error.SetError(AttachToProcess(attach_info, *target_sp));
530 sb_process.SetSP(target_sp->GetProcessSP());
532 error.SetErrorString("SBTarget is invalid");
534 return LLDB_RECORD_RESULT(sb_process);
537 lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url,
538 const char *plugin_name,
541 lldb::SBProcess, SBTarget, ConnectRemote,
542 (lldb::SBListener &, const char *, const char *, lldb::SBError &),
543 listener, url, plugin_name, error);
545 SBProcess sb_process;
546 ProcessSP process_sp;
547 TargetSP target_sp(GetSP());
550 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
551 if (listener.IsValid())
553 target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, nullptr);
555 process_sp = target_sp->CreateProcess(
556 target_sp->GetDebugger().GetListener(), plugin_name, nullptr);
559 sb_process.SetSP(process_sp);
560 error.SetError(process_sp->ConnectRemote(nullptr, url));
562 error.SetErrorString("unable to create lldb_private::Process");
565 error.SetErrorString("SBTarget is invalid");
568 return LLDB_RECORD_RESULT(sb_process);
571 SBFileSpec SBTarget::GetExecutable() {
572 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBTarget, GetExecutable);
574 SBFileSpec exe_file_spec;
575 TargetSP target_sp(GetSP());
577 Module *exe_module = target_sp->GetExecutableModulePointer();
579 exe_file_spec.SetFileSpec(exe_module->GetFileSpec());
582 return LLDB_RECORD_RESULT(exe_file_spec);
585 bool SBTarget::operator==(const SBTarget &rhs) const {
586 LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator==,(const lldb::SBTarget &),
589 return m_opaque_sp.get() == rhs.m_opaque_sp.get();
592 bool SBTarget::operator!=(const SBTarget &rhs) const {
593 LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator!=,(const lldb::SBTarget &),
596 return m_opaque_sp.get() != rhs.m_opaque_sp.get();
599 lldb::TargetSP SBTarget::GetSP() const { return m_opaque_sp; }
601 void SBTarget::SetSP(const lldb::TargetSP &target_sp) {
602 m_opaque_sp = target_sp;
605 lldb::SBAddress SBTarget::ResolveLoadAddress(lldb::addr_t vm_addr) {
606 LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress,
607 (lldb::addr_t), vm_addr);
609 lldb::SBAddress sb_addr;
610 Address &addr = sb_addr.ref();
611 TargetSP target_sp(GetSP());
613 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
614 if (target_sp->ResolveLoadAddress(vm_addr, addr))
615 return LLDB_RECORD_RESULT(sb_addr);
618 // We have a load address that isn't in a section, just return an address
619 // with the offset filled in (the address) and the section set to NULL
620 addr.SetRawAddress(vm_addr);
621 return LLDB_RECORD_RESULT(sb_addr);
624 lldb::SBAddress SBTarget::ResolveFileAddress(lldb::addr_t file_addr) {
625 LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress,
626 (lldb::addr_t), file_addr);
628 lldb::SBAddress sb_addr;
629 Address &addr = sb_addr.ref();
630 TargetSP target_sp(GetSP());
632 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
633 if (target_sp->ResolveFileAddress(file_addr, addr))
634 return LLDB_RECORD_RESULT(sb_addr);
637 addr.SetRawAddress(file_addr);
638 return LLDB_RECORD_RESULT(sb_addr);
641 lldb::SBAddress SBTarget::ResolvePastLoadAddress(uint32_t stop_id,
642 lldb::addr_t vm_addr) {
643 LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress,
644 (uint32_t, lldb::addr_t), stop_id, vm_addr);
646 lldb::SBAddress sb_addr;
647 Address &addr = sb_addr.ref();
648 TargetSP target_sp(GetSP());
650 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
651 if (target_sp->ResolveLoadAddress(vm_addr, addr))
652 return LLDB_RECORD_RESULT(sb_addr);
655 // We have a load address that isn't in a section, just return an address
656 // with the offset filled in (the address) and the section set to NULL
657 addr.SetRawAddress(vm_addr);
658 return LLDB_RECORD_RESULT(sb_addr);
662 SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr,
663 uint32_t resolve_scope) {
664 LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBTarget,
665 ResolveSymbolContextForAddress,
666 (const lldb::SBAddress &, uint32_t), addr, resolve_scope);
669 SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
670 if (addr.IsValid()) {
671 TargetSP target_sp(GetSP());
673 target_sp->GetImages().ResolveSymbolContextForAddress(addr.ref(), scope,
676 return LLDB_RECORD_RESULT(sc);
679 size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size,
680 lldb::SBError &error) {
681 LLDB_RECORD_DUMMY(size_t, SBTarget, ReadMemory,
682 (const lldb::SBAddress, void *, size_t, lldb::SBError &),
683 addr, buf, size, error);
686 size_t bytes_read = 0;
687 TargetSP target_sp(GetSP());
689 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
691 target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref());
693 sb_error.SetErrorString("invalid target");
699 SBBreakpoint SBTarget::BreakpointCreateByLocation(const char *file,
701 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
702 (const char *, uint32_t), file, line);
704 return LLDB_RECORD_RESULT(
705 SBBreakpoint(BreakpointCreateByLocation(SBFileSpec(file, false), line)));
709 SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
711 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
712 (const lldb::SBFileSpec &, uint32_t), sb_file_spec, line);
714 return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0));
718 SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
719 uint32_t line, lldb::addr_t offset) {
720 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
721 (const lldb::SBFileSpec &, uint32_t, lldb::addr_t),
722 sb_file_spec, line, offset);
724 SBFileSpecList empty_list;
725 return LLDB_RECORD_RESULT(
726 BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list));
730 SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
731 uint32_t line, lldb::addr_t offset,
732 SBFileSpecList &sb_module_list) {
733 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
734 (const lldb::SBFileSpec &, uint32_t, lldb::addr_t,
735 lldb::SBFileSpecList &),
736 sb_file_spec, line, offset, sb_module_list);
738 return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0,
739 offset, sb_module_list));
742 SBBreakpoint SBTarget::BreakpointCreateByLocation(
743 const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
744 lldb::addr_t offset, SBFileSpecList &sb_module_list) {
745 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
746 (const lldb::SBFileSpec &, uint32_t, uint32_t,
747 lldb::addr_t, lldb::SBFileSpecList &),
748 sb_file_spec, line, column, offset, sb_module_list);
751 TargetSP target_sp(GetSP());
752 if (target_sp && line != 0) {
753 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
755 const LazyBool check_inlines = eLazyBoolCalculate;
756 const LazyBool skip_prologue = eLazyBoolCalculate;
757 const bool internal = false;
758 const bool hardware = false;
759 const LazyBool move_to_nearest_code = eLazyBoolCalculate;
760 const FileSpecList *module_list = nullptr;
761 if (sb_module_list.GetSize() > 0) {
762 module_list = sb_module_list.get();
764 sb_bp = target_sp->CreateBreakpoint(
765 module_list, *sb_file_spec, line, column, offset, check_inlines,
766 skip_prologue, internal, hardware, move_to_nearest_code);
769 return LLDB_RECORD_RESULT(sb_bp);
772 SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name,
773 const char *module_name) {
774 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
775 (const char *, const char *), symbol_name, module_name);
778 TargetSP target_sp(GetSP());
779 if (target_sp.get()) {
780 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
782 const bool internal = false;
783 const bool hardware = false;
784 const LazyBool skip_prologue = eLazyBoolCalculate;
785 const lldb::addr_t offset = 0;
786 if (module_name && module_name[0]) {
787 FileSpecList module_spec_list;
788 module_spec_list.Append(FileSpec(module_name));
789 sb_bp = target_sp->CreateBreakpoint(
790 &module_spec_list, nullptr, symbol_name, eFunctionNameTypeAuto,
791 eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
793 sb_bp = target_sp->CreateBreakpoint(
794 nullptr, nullptr, symbol_name, eFunctionNameTypeAuto,
795 eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
799 return LLDB_RECORD_RESULT(sb_bp);
803 SBTarget::BreakpointCreateByName(const char *symbol_name,
804 const SBFileSpecList &module_list,
805 const SBFileSpecList &comp_unit_list) {
806 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
807 (const char *, const lldb::SBFileSpecList &,
808 const lldb::SBFileSpecList &),
809 symbol_name, module_list, comp_unit_list);
811 lldb::FunctionNameType name_type_mask = eFunctionNameTypeAuto;
812 return LLDB_RECORD_RESULT(
813 BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown,
814 module_list, comp_unit_list));
817 lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
818 const char *symbol_name, uint32_t name_type_mask,
819 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
820 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
821 (const char *, uint32_t, const lldb::SBFileSpecList &,
822 const lldb::SBFileSpecList &),
823 symbol_name, name_type_mask, module_list, comp_unit_list);
825 return LLDB_RECORD_RESULT(
826 BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown,
827 module_list, comp_unit_list));
830 lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
831 const char *symbol_name, uint32_t name_type_mask,
832 LanguageType symbol_language, const SBFileSpecList &module_list,
833 const SBFileSpecList &comp_unit_list) {
834 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
835 (const char *, uint32_t, lldb::LanguageType,
836 const lldb::SBFileSpecList &,
837 const lldb::SBFileSpecList &),
838 symbol_name, name_type_mask, symbol_language, module_list,
842 TargetSP target_sp(GetSP());
843 if (target_sp && symbol_name && symbol_name[0]) {
844 const bool internal = false;
845 const bool hardware = false;
846 const LazyBool skip_prologue = eLazyBoolCalculate;
847 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
848 FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
849 sb_bp = target_sp->CreateBreakpoint(module_list.get(), comp_unit_list.get(),
850 symbol_name, mask, symbol_language, 0,
851 skip_prologue, internal, hardware);
854 return LLDB_RECORD_RESULT(sb_bp);
857 lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
858 const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
859 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
861 lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
862 (const char **, uint32_t, uint32_t, const lldb::SBFileSpecList &,
863 const lldb::SBFileSpecList &),
864 symbol_names, num_names, name_type_mask, module_list, comp_unit_list);
866 return LLDB_RECORD_RESULT(BreakpointCreateByNames(
867 symbol_names, num_names, name_type_mask, eLanguageTypeUnknown,
868 module_list, comp_unit_list));
871 lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
872 const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
873 LanguageType symbol_language, const SBFileSpecList &module_list,
874 const SBFileSpecList &comp_unit_list) {
875 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
876 (const char **, uint32_t, uint32_t, lldb::LanguageType,
877 const lldb::SBFileSpecList &,
878 const lldb::SBFileSpecList &),
879 symbol_names, num_names, name_type_mask, symbol_language,
880 module_list, comp_unit_list);
882 return LLDB_RECORD_RESULT(BreakpointCreateByNames(
883 symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 0,
884 module_list, comp_unit_list));
887 lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
888 const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
889 LanguageType symbol_language, lldb::addr_t offset,
890 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
891 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
892 (const char **, uint32_t, uint32_t, lldb::LanguageType,
893 lldb::addr_t, const lldb::SBFileSpecList &,
894 const lldb::SBFileSpecList &),
895 symbol_names, num_names, name_type_mask, symbol_language,
896 offset, module_list, comp_unit_list);
899 TargetSP target_sp(GetSP());
900 if (target_sp && num_names > 0) {
901 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
902 const bool internal = false;
903 const bool hardware = false;
904 FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
905 const LazyBool skip_prologue = eLazyBoolCalculate;
906 sb_bp = target_sp->CreateBreakpoint(
907 module_list.get(), comp_unit_list.get(), symbol_names, num_names, mask,
908 symbol_language, offset, skip_prologue, internal, hardware);
911 return LLDB_RECORD_RESULT(sb_bp);
914 SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
915 const char *module_name) {
916 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
917 (const char *, const char *), symbol_name_regex,
920 SBFileSpecList module_spec_list;
921 SBFileSpecList comp_unit_list;
922 if (module_name && module_name[0]) {
923 module_spec_list.Append(FileSpec(module_name));
925 return LLDB_RECORD_RESULT(
926 BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown,
927 module_spec_list, comp_unit_list));
931 SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
932 const SBFileSpecList &module_list,
933 const SBFileSpecList &comp_unit_list) {
934 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
935 (const char *, const lldb::SBFileSpecList &,
936 const lldb::SBFileSpecList &),
937 symbol_name_regex, module_list, comp_unit_list);
939 return LLDB_RECORD_RESULT(BreakpointCreateByRegex(
940 symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list));
943 lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(
944 const char *symbol_name_regex, LanguageType symbol_language,
945 const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
947 lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
948 (const char *, lldb::LanguageType, const lldb::SBFileSpecList &,
949 const lldb::SBFileSpecList &),
950 symbol_name_regex, symbol_language, module_list, comp_unit_list);
954 TargetSP target_sp(GetSP());
955 if (target_sp && symbol_name_regex && symbol_name_regex[0]) {
956 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
957 RegularExpression regexp((llvm::StringRef(symbol_name_regex)));
958 const bool internal = false;
959 const bool hardware = false;
960 const LazyBool skip_prologue = eLazyBoolCalculate;
962 sb_bp = target_sp->CreateFuncRegexBreakpoint(
963 module_list.get(), comp_unit_list.get(), regexp, symbol_language,
964 skip_prologue, internal, hardware);
967 return LLDB_RECORD_RESULT(sb_bp);
970 SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) {
971 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByAddress,
972 (lldb::addr_t), address);
975 TargetSP target_sp(GetSP());
977 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
978 const bool hardware = false;
979 sb_bp = target_sp->CreateBreakpoint(address, false, hardware);
982 return LLDB_RECORD_RESULT(sb_bp);
985 SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) {
986 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateBySBAddress,
987 (lldb::SBAddress &), sb_address);
990 TargetSP target_sp(GetSP());
991 if (!sb_address.IsValid()) {
992 return LLDB_RECORD_RESULT(sb_bp);
996 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
997 const bool hardware = false;
998 sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware);
1001 return LLDB_RECORD_RESULT(sb_bp);
1005 SBTarget::BreakpointCreateBySourceRegex(const char *source_regex,
1006 const lldb::SBFileSpec &source_file,
1007 const char *module_name) {
1008 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget,
1009 BreakpointCreateBySourceRegex,
1010 (const char *, const lldb::SBFileSpec &, const char *),
1011 source_regex, source_file, module_name);
1013 SBFileSpecList module_spec_list;
1015 if (module_name && module_name[0]) {
1016 module_spec_list.Append(FileSpec(module_name));
1019 SBFileSpecList source_file_list;
1020 if (source_file.IsValid()) {
1021 source_file_list.Append(source_file);
1024 return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex(
1025 source_regex, module_spec_list, source_file_list));
1028 lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
1029 const char *source_regex, const SBFileSpecList &module_list,
1030 const lldb::SBFileSpecList &source_file_list) {
1031 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget,
1032 BreakpointCreateBySourceRegex,
1033 (const char *, const lldb::SBFileSpecList &,
1034 const lldb::SBFileSpecList &),
1035 source_regex, module_list, source_file_list);
1037 return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex(
1038 source_regex, module_list, source_file_list, SBStringList()));
1041 lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
1042 const char *source_regex, const SBFileSpecList &module_list,
1043 const lldb::SBFileSpecList &source_file_list,
1044 const SBStringList &func_names) {
1045 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget,
1046 BreakpointCreateBySourceRegex,
1047 (const char *, const lldb::SBFileSpecList &,
1048 const lldb::SBFileSpecList &, const lldb::SBStringList &),
1049 source_regex, module_list, source_file_list, func_names);
1052 TargetSP target_sp(GetSP());
1053 if (target_sp && source_regex && source_regex[0]) {
1054 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1055 const bool hardware = false;
1056 const LazyBool move_to_nearest_code = eLazyBoolCalculate;
1057 RegularExpression regexp((llvm::StringRef(source_regex)));
1058 std::unordered_set<std::string> func_names_set;
1059 for (size_t i = 0; i < func_names.GetSize(); i++) {
1060 func_names_set.insert(func_names.GetStringAtIndex(i));
1063 sb_bp = target_sp->CreateSourceRegexBreakpoint(
1064 module_list.get(), source_file_list.get(), func_names_set, regexp,
1065 false, hardware, move_to_nearest_code);
1068 return LLDB_RECORD_RESULT(sb_bp);
1072 SBTarget::BreakpointCreateForException(lldb::LanguageType language,
1073 bool catch_bp, bool throw_bp) {
1074 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateForException,
1075 (lldb::LanguageType, bool, bool), language, catch_bp,
1079 TargetSP target_sp(GetSP());
1081 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1082 const bool hardware = false;
1083 sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp,
1087 return LLDB_RECORD_RESULT(sb_bp);
1090 lldb::SBBreakpoint SBTarget::BreakpointCreateFromScript(
1091 const char *class_name, SBStructuredData &extra_args,
1092 const SBFileSpecList &module_list, const SBFileSpecList &file_list,
1093 bool request_hardware) {
1095 lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript,
1096 (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &,
1097 const lldb::SBFileSpecList &, bool),
1098 class_name, extra_args, module_list, file_list, request_hardware);
1101 TargetSP target_sp(GetSP());
1103 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1106 StructuredData::ObjectSP obj_sp = extra_args.m_impl_up->GetObjectSP();
1108 target_sp->CreateScriptedBreakpoint(class_name,
1111 false, /* internal */
1117 return LLDB_RECORD_RESULT(sb_bp);
1120 uint32_t SBTarget::GetNumBreakpoints() const {
1121 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumBreakpoints);
1123 TargetSP target_sp(GetSP());
1125 // The breakpoint list is thread safe, no need to lock
1126 return target_sp->GetBreakpointList().GetSize();
1131 SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const {
1132 LLDB_RECORD_METHOD_CONST(lldb::SBBreakpoint, SBTarget, GetBreakpointAtIndex,
1135 SBBreakpoint sb_breakpoint;
1136 TargetSP target_sp(GetSP());
1138 // The breakpoint list is thread safe, no need to lock
1139 sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
1141 return LLDB_RECORD_RESULT(sb_breakpoint);
1144 bool SBTarget::BreakpointDelete(break_id_t bp_id) {
1145 LLDB_RECORD_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t),
1148 bool result = false;
1149 TargetSP target_sp(GetSP());
1151 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1152 result = target_sp->RemoveBreakpointByID(bp_id);
1158 SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) {
1159 LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID,
1160 (lldb::break_id_t), bp_id);
1162 SBBreakpoint sb_breakpoint;
1163 TargetSP target_sp(GetSP());
1164 if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) {
1165 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1166 sb_breakpoint = target_sp->GetBreakpointByID(bp_id);
1169 return LLDB_RECORD_RESULT(sb_breakpoint);
1172 bool SBTarget::FindBreakpointsByName(const char *name,
1173 SBBreakpointList &bkpts) {
1174 LLDB_RECORD_METHOD(bool, SBTarget, FindBreakpointsByName,
1175 (const char *, lldb::SBBreakpointList &), name, bkpts);
1177 TargetSP target_sp(GetSP());
1179 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1180 BreakpointList bkpt_list(false);
1182 target_sp->GetBreakpointList().FindBreakpointsByName(name, bkpt_list);
1185 for (BreakpointSP bkpt_sp : bkpt_list.Breakpoints()) {
1186 bkpts.AppendByID(bkpt_sp->GetID());
1192 void SBTarget::GetBreakpointNames(SBStringList &names) {
1193 LLDB_RECORD_METHOD(void, SBTarget, GetBreakpointNames, (lldb::SBStringList &),
1198 TargetSP target_sp(GetSP());
1200 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1202 std::vector<std::string> name_vec;
1203 target_sp->GetBreakpointNames(name_vec);
1204 for (auto name : name_vec)
1205 names.AppendString(name.c_str());
1209 void SBTarget::DeleteBreakpointName(const char *name) {
1210 LLDB_RECORD_METHOD(void, SBTarget, DeleteBreakpointName, (const char *),
1213 TargetSP target_sp(GetSP());
1215 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1216 target_sp->DeleteBreakpointName(ConstString(name));
1220 bool SBTarget::EnableAllBreakpoints() {
1221 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllBreakpoints);
1223 TargetSP target_sp(GetSP());
1225 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1226 target_sp->EnableAllowedBreakpoints();
1232 bool SBTarget::DisableAllBreakpoints() {
1233 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllBreakpoints);
1235 TargetSP target_sp(GetSP());
1237 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1238 target_sp->DisableAllowedBreakpoints();
1244 bool SBTarget::DeleteAllBreakpoints() {
1245 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllBreakpoints);
1247 TargetSP target_sp(GetSP());
1249 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1250 target_sp->RemoveAllowedBreakpoints();
1256 lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file,
1257 SBBreakpointList &new_bps) {
1258 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile,
1259 (lldb::SBFileSpec &, lldb::SBBreakpointList &),
1260 source_file, new_bps);
1262 SBStringList empty_name_list;
1263 return LLDB_RECORD_RESULT(
1264 BreakpointsCreateFromFile(source_file, empty_name_list, new_bps));
1267 lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file,
1268 SBStringList &matching_names,
1269 SBBreakpointList &new_bps) {
1271 lldb::SBError, SBTarget, BreakpointsCreateFromFile,
1272 (lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &),
1273 source_file, matching_names, new_bps);
1276 TargetSP target_sp(GetSP());
1278 sberr.SetErrorString(
1279 "BreakpointCreateFromFile called with invalid target.");
1280 return LLDB_RECORD_RESULT(sberr);
1282 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1284 BreakpointIDList bp_ids;
1286 std::vector<std::string> name_vector;
1287 size_t num_names = matching_names.GetSize();
1288 for (size_t i = 0; i < num_names; i++)
1289 name_vector.push_back(matching_names.GetStringAtIndex(i));
1291 sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(),
1292 name_vector, bp_ids);
1294 return LLDB_RECORD_RESULT(sberr);
1296 size_t num_bkpts = bp_ids.GetSize();
1297 for (size_t i = 0; i < num_bkpts; i++) {
1298 BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i);
1299 new_bps.AppendByID(bp_id.GetBreakpointID());
1301 return LLDB_RECORD_RESULT(sberr);
1304 lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file) {
1305 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
1306 (lldb::SBFileSpec &), dest_file);
1309 TargetSP target_sp(GetSP());
1311 sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
1312 return LLDB_RECORD_RESULT(sberr);
1314 SBBreakpointList bkpt_list(*this);
1315 return LLDB_RECORD_RESULT(BreakpointsWriteToFile(dest_file, bkpt_list));
1318 lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file,
1319 SBBreakpointList &bkpt_list,
1321 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
1322 (lldb::SBFileSpec &, lldb::SBBreakpointList &, bool),
1323 dest_file, bkpt_list, append);
1326 TargetSP target_sp(GetSP());
1328 sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
1329 return LLDB_RECORD_RESULT(sberr);
1332 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1333 BreakpointIDList bp_id_list;
1334 bkpt_list.CopyToBreakpointIDList(bp_id_list);
1335 sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(),
1336 bp_id_list, append);
1337 return LLDB_RECORD_RESULT(sberr);
1340 uint32_t SBTarget::GetNumWatchpoints() const {
1341 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumWatchpoints);
1343 TargetSP target_sp(GetSP());
1345 // The watchpoint list is thread safe, no need to lock
1346 return target_sp->GetWatchpointList().GetSize();
1351 SBWatchpoint SBTarget::GetWatchpointAtIndex(uint32_t idx) const {
1352 LLDB_RECORD_METHOD_CONST(lldb::SBWatchpoint, SBTarget, GetWatchpointAtIndex,
1355 SBWatchpoint sb_watchpoint;
1356 TargetSP target_sp(GetSP());
1358 // The watchpoint list is thread safe, no need to lock
1359 sb_watchpoint.SetSP(target_sp->GetWatchpointList().GetByIndex(idx));
1361 return LLDB_RECORD_RESULT(sb_watchpoint);
1364 bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) {
1365 LLDB_RECORD_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t),
1369 bool result = false;
1370 TargetSP target_sp(GetSP());
1372 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1373 std::unique_lock<std::recursive_mutex> lock;
1374 target_sp->GetWatchpointList().GetListMutex(lock);
1375 result = target_sp->RemoveWatchpointByID(wp_id);
1381 SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) {
1382 LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID,
1383 (lldb::watch_id_t), wp_id);
1386 SBWatchpoint sb_watchpoint;
1387 lldb::WatchpointSP watchpoint_sp;
1388 TargetSP target_sp(GetSP());
1389 if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) {
1390 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1391 std::unique_lock<std::recursive_mutex> lock;
1392 target_sp->GetWatchpointList().GetListMutex(lock);
1393 watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id);
1394 sb_watchpoint.SetSP(watchpoint_sp);
1397 return LLDB_RECORD_RESULT(sb_watchpoint);
1400 lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size,
1401 bool read, bool write,
1403 LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress,
1404 (lldb::addr_t, size_t, bool, bool, lldb::SBError &), addr,
1405 size, read, write, error);
1407 SBWatchpoint sb_watchpoint;
1408 lldb::WatchpointSP watchpoint_sp;
1409 TargetSP target_sp(GetSP());
1410 if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS &&
1412 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1413 uint32_t watch_type = 0;
1415 watch_type |= LLDB_WATCH_TYPE_READ;
1417 watch_type |= LLDB_WATCH_TYPE_WRITE;
1418 if (watch_type == 0) {
1419 error.SetErrorString(
1420 "Can't create a watchpoint that is neither read nor write.");
1421 return LLDB_RECORD_RESULT(sb_watchpoint);
1424 // Target::CreateWatchpoint() is thread safe.
1426 // This API doesn't take in a type, so we can't figure out what it is.
1427 CompilerType *type = nullptr;
1429 target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
1430 error.SetError(cw_error);
1431 sb_watchpoint.SetSP(watchpoint_sp);
1434 return LLDB_RECORD_RESULT(sb_watchpoint);
1437 bool SBTarget::EnableAllWatchpoints() {
1438 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllWatchpoints);
1440 TargetSP target_sp(GetSP());
1442 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1443 std::unique_lock<std::recursive_mutex> lock;
1444 target_sp->GetWatchpointList().GetListMutex(lock);
1445 target_sp->EnableAllWatchpoints();
1451 bool SBTarget::DisableAllWatchpoints() {
1452 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllWatchpoints);
1454 TargetSP target_sp(GetSP());
1456 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1457 std::unique_lock<std::recursive_mutex> lock;
1458 target_sp->GetWatchpointList().GetListMutex(lock);
1459 target_sp->DisableAllWatchpoints();
1465 SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr,
1467 LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress,
1468 (const char *, lldb::SBAddress, lldb::SBType), name, addr,
1472 lldb::ValueObjectSP new_value_sp;
1473 if (IsValid() && name && *name && addr.IsValid() && type.IsValid()) {
1474 lldb::addr_t load_addr(addr.GetLoadAddress(*this));
1475 ExecutionContext exe_ctx(
1476 ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
1477 CompilerType ast_type(type.GetSP()->GetCompilerType(true));
1478 new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr,
1481 sb_value.SetSP(new_value_sp);
1482 return LLDB_RECORD_RESULT(sb_value);
1485 lldb::SBValue SBTarget::CreateValueFromData(const char *name, lldb::SBData data,
1486 lldb::SBType type) {
1487 LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromData,
1488 (const char *, lldb::SBData, lldb::SBType), name, data,
1492 lldb::ValueObjectSP new_value_sp;
1493 if (IsValid() && name && *name && data.IsValid() && type.IsValid()) {
1494 DataExtractorSP extractor(*data);
1495 ExecutionContext exe_ctx(
1496 ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
1497 CompilerType ast_type(type.GetSP()->GetCompilerType(true));
1498 new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor,
1501 sb_value.SetSP(new_value_sp);
1502 return LLDB_RECORD_RESULT(sb_value);
1505 lldb::SBValue SBTarget::CreateValueFromExpression(const char *name,
1507 LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression,
1508 (const char *, const char *), name, expr);
1511 lldb::ValueObjectSP new_value_sp;
1512 if (IsValid() && name && *name && expr && *expr) {
1513 ExecutionContext exe_ctx(
1514 ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
1516 ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx);
1518 sb_value.SetSP(new_value_sp);
1519 return LLDB_RECORD_RESULT(sb_value);
1522 bool SBTarget::DeleteAllWatchpoints() {
1523 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllWatchpoints);
1525 TargetSP target_sp(GetSP());
1527 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1528 std::unique_lock<std::recursive_mutex> lock;
1529 target_sp->GetWatchpointList().GetListMutex(lock);
1530 target_sp->RemoveAllWatchpoints();
1536 void SBTarget::AppendImageSearchPath(const char *from, const char *to,
1537 lldb::SBError &error) {
1538 LLDB_RECORD_METHOD(void, SBTarget, AppendImageSearchPath,
1539 (const char *, const char *, lldb::SBError &), from, to,
1542 TargetSP target_sp(GetSP());
1544 return error.SetErrorString("invalid target");
1546 const ConstString csFrom(from), csTo(to);
1548 return error.SetErrorString("<from> path can't be empty");
1550 return error.SetErrorString("<to> path can't be empty");
1552 target_sp->GetImageSearchPathList().Append(csFrom, csTo, true);
1555 lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
1556 const char *uuid_cstr) {
1557 LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule,
1558 (const char *, const char *, const char *), path, triple,
1561 return LLDB_RECORD_RESULT(AddModule(path, triple, uuid_cstr, nullptr));
1564 lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
1565 const char *uuid_cstr, const char *symfile) {
1566 LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule,
1567 (const char *, const char *, const char *, const char *),
1568 path, triple, uuid_cstr, symfile);
1570 lldb::SBModule sb_module;
1571 TargetSP target_sp(GetSP());
1573 ModuleSpec module_spec;
1575 module_spec.GetFileSpec().SetFile(path, FileSpec::Style::native);
1578 module_spec.GetUUID().SetFromStringRef(uuid_cstr);
1581 module_spec.GetArchitecture() = Platform::GetAugmentedArchSpec(
1582 target_sp->GetPlatform().get(), triple);
1584 module_spec.GetArchitecture() = target_sp->GetArchitecture();
1587 module_spec.GetSymbolFileSpec().SetFile(symfile, FileSpec::Style::native);
1589 sb_module.SetSP(target_sp->GetOrCreateModule(module_spec, true /* notify */));
1591 return LLDB_RECORD_RESULT(sb_module);
1594 lldb::SBModule SBTarget::AddModule(const SBModuleSpec &module_spec) {
1595 LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule,
1596 (const lldb::SBModuleSpec &), module_spec);
1598 lldb::SBModule sb_module;
1599 TargetSP target_sp(GetSP());
1601 sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up,
1602 true /* notify */));
1603 return LLDB_RECORD_RESULT(sb_module);
1606 bool SBTarget::AddModule(lldb::SBModule &module) {
1607 LLDB_RECORD_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &), module);
1609 TargetSP target_sp(GetSP());
1611 target_sp->GetImages().AppendIfNeeded(module.GetSP());
1617 uint32_t SBTarget::GetNumModules() const {
1618 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumModules);
1621 TargetSP target_sp(GetSP());
1623 // The module list is thread safe, no need to lock
1624 num = target_sp->GetImages().GetSize();
1630 void SBTarget::Clear() {
1631 LLDB_RECORD_METHOD_NO_ARGS(void, SBTarget, Clear);
1633 m_opaque_sp.reset();
1636 SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) {
1637 LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, FindModule,
1638 (const lldb::SBFileSpec &), sb_file_spec);
1641 TargetSP target_sp(GetSP());
1642 if (target_sp && sb_file_spec.IsValid()) {
1643 ModuleSpec module_spec(*sb_file_spec);
1644 // The module list is thread safe, no need to lock
1645 sb_module.SetSP(target_sp->GetImages().FindFirstModule(module_spec));
1647 return LLDB_RECORD_RESULT(sb_module);
1650 SBSymbolContextList SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) {
1651 LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits,
1652 (const lldb::SBFileSpec &), sb_file_spec);
1654 SBSymbolContextList sb_sc_list;
1655 const TargetSP target_sp(GetSP());
1656 if (target_sp && sb_file_spec.IsValid()) {
1657 const bool append = true;
1658 target_sp->GetImages().FindCompileUnits(*sb_file_spec,
1659 append, *sb_sc_list);
1661 return LLDB_RECORD_RESULT(sb_sc_list);
1664 lldb::ByteOrder SBTarget::GetByteOrder() {
1665 LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBTarget, GetByteOrder);
1667 TargetSP target_sp(GetSP());
1669 return target_sp->GetArchitecture().GetByteOrder();
1670 return eByteOrderInvalid;
1673 const char *SBTarget::GetTriple() {
1674 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTarget, GetTriple);
1676 TargetSP target_sp(GetSP());
1678 std::string triple(target_sp->GetArchitecture().GetTriple().str());
1679 // Unique the string so we don't run into ownership issues since the const
1680 // strings put the string into the string pool once and the strings never
1682 ConstString const_triple(triple.c_str());
1683 return const_triple.GetCString();
1688 uint32_t SBTarget::GetDataByteSize() {
1689 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetDataByteSize);
1691 TargetSP target_sp(GetSP());
1693 return target_sp->GetArchitecture().GetDataByteSize();
1698 uint32_t SBTarget::GetCodeByteSize() {
1699 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetCodeByteSize);
1701 TargetSP target_sp(GetSP());
1703 return target_sp->GetArchitecture().GetCodeByteSize();
1708 uint32_t SBTarget::GetAddressByteSize() {
1709 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetAddressByteSize);
1711 TargetSP target_sp(GetSP());
1713 return target_sp->GetArchitecture().GetAddressByteSize();
1714 return sizeof(void *);
1717 SBModule SBTarget::GetModuleAtIndex(uint32_t idx) {
1718 LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex, (uint32_t),
1723 TargetSP target_sp(GetSP());
1725 // The module list is thread safe, no need to lock
1726 module_sp = target_sp->GetImages().GetModuleAtIndex(idx);
1727 sb_module.SetSP(module_sp);
1730 return LLDB_RECORD_RESULT(sb_module);
1733 bool SBTarget::RemoveModule(lldb::SBModule module) {
1734 LLDB_RECORD_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule), module);
1736 TargetSP target_sp(GetSP());
1738 return target_sp->GetImages().Remove(module.GetSP());
1742 SBBroadcaster SBTarget::GetBroadcaster() const {
1743 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBTarget,
1747 TargetSP target_sp(GetSP());
1748 SBBroadcaster broadcaster(target_sp.get(), false);
1751 return LLDB_RECORD_RESULT(broadcaster);
1754 bool SBTarget::GetDescription(SBStream &description,
1755 lldb::DescriptionLevel description_level) {
1756 LLDB_RECORD_METHOD(bool, SBTarget, GetDescription,
1757 (lldb::SBStream &, lldb::DescriptionLevel), description,
1760 Stream &strm = description.ref();
1762 TargetSP target_sp(GetSP());
1764 target_sp->Dump(&strm, description_level);
1766 strm.PutCString("No value");
1771 lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name,
1772 uint32_t name_type_mask) {
1773 LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions,
1774 (const char *, uint32_t), name, name_type_mask);
1776 lldb::SBSymbolContextList sb_sc_list;
1777 if (!name | !name[0])
1778 return LLDB_RECORD_RESULT(sb_sc_list);
1780 TargetSP target_sp(GetSP());
1782 return LLDB_RECORD_RESULT(sb_sc_list);
1784 const bool symbols_ok = true;
1785 const bool inlines_ok = true;
1786 const bool append = true;
1787 FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
1788 target_sp->GetImages().FindFunctions(ConstString(name), mask, symbols_ok,
1789 inlines_ok, append, *sb_sc_list);
1790 return LLDB_RECORD_RESULT(sb_sc_list);
1793 lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name,
1794 uint32_t max_matches,
1795 MatchType matchtype) {
1796 LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindGlobalFunctions,
1797 (const char *, uint32_t, lldb::MatchType), name,
1798 max_matches, matchtype);
1800 lldb::SBSymbolContextList sb_sc_list;
1801 if (name && name[0]) {
1802 llvm::StringRef name_ref(name);
1803 TargetSP target_sp(GetSP());
1805 std::string regexstr;
1806 switch (matchtype) {
1807 case eMatchTypeRegex:
1808 target_sp->GetImages().FindFunctions(RegularExpression(name_ref), true,
1809 true, true, *sb_sc_list);
1811 case eMatchTypeStartsWith:
1812 regexstr = llvm::Regex::escape(name) + ".*";
1813 target_sp->GetImages().FindFunctions(RegularExpression(regexstr), true,
1814 true, true, *sb_sc_list);
1817 target_sp->GetImages().FindFunctions(ConstString(name),
1818 eFunctionNameTypeAny, true, true,
1824 return LLDB_RECORD_RESULT(sb_sc_list);
1827 lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
1828 LLDB_RECORD_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *),
1831 TargetSP target_sp(GetSP());
1832 if (typename_cstr && typename_cstr[0] && target_sp) {
1833 ConstString const_typename(typename_cstr);
1835 const bool exact_match = false;
1837 const ModuleList &module_list = target_sp->GetImages();
1838 size_t count = module_list.GetSize();
1839 for (size_t idx = 0; idx < count; idx++) {
1840 ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
1843 module_sp->FindFirstType(sc, const_typename, exact_match));
1845 return LLDB_RECORD_RESULT(SBType(type_sp));
1849 // Didn't find the type in the symbols; Try the loaded language runtimes
1850 if (auto process_sp = target_sp->GetProcessSP()) {
1851 for (auto *runtime : process_sp->GetLanguageRuntimes()) {
1852 if (auto vendor = runtime->GetDeclVendor()) {
1853 auto types = vendor->FindTypes(const_typename, /*max_matches*/ 1);
1855 return LLDB_RECORD_RESULT(SBType(types.front()));
1860 // No matches, search for basic typename matches
1861 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1863 return LLDB_RECORD_RESULT(SBType(ClangASTContext::GetBasicType(
1864 clang_ast->getASTContext(), const_typename)));
1866 return LLDB_RECORD_RESULT(SBType());
1869 SBType SBTarget::GetBasicType(lldb::BasicType type) {
1870 LLDB_RECORD_METHOD(lldb::SBType, SBTarget, GetBasicType, (lldb::BasicType),
1873 TargetSP target_sp(GetSP());
1875 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1877 return LLDB_RECORD_RESULT(SBType(
1878 ClangASTContext::GetBasicType(clang_ast->getASTContext(), type)));
1880 return LLDB_RECORD_RESULT(SBType());
1883 lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
1884 LLDB_RECORD_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *),
1887 SBTypeList sb_type_list;
1888 TargetSP target_sp(GetSP());
1889 if (typename_cstr && typename_cstr[0] && target_sp) {
1890 ModuleList &images = target_sp->GetImages();
1891 ConstString const_typename(typename_cstr);
1892 bool exact_match = false;
1894 llvm::DenseSet<SymbolFile *> searched_symbol_files;
1895 uint32_t num_matches =
1896 images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX,
1897 searched_symbol_files, type_list);
1899 if (num_matches > 0) {
1900 for (size_t idx = 0; idx < num_matches; idx++) {
1901 TypeSP type_sp(type_list.GetTypeAtIndex(idx));
1903 sb_type_list.Append(SBType(type_sp));
1907 // Try the loaded language runtimes
1908 if (auto process_sp = target_sp->GetProcessSP()) {
1909 for (auto *runtime : process_sp->GetLanguageRuntimes()) {
1910 if (auto *vendor = runtime->GetDeclVendor()) {
1912 vendor->FindTypes(const_typename, /*max_matches*/ UINT32_MAX);
1913 for (auto type : types)
1914 sb_type_list.Append(SBType(type));
1919 if (sb_type_list.GetSize() == 0) {
1920 // No matches, search for basic typename matches
1921 ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1923 sb_type_list.Append(SBType(ClangASTContext::GetBasicType(
1924 clang_ast->getASTContext(), const_typename)));
1927 return LLDB_RECORD_RESULT(sb_type_list);
1930 SBValueList SBTarget::FindGlobalVariables(const char *name,
1931 uint32_t max_matches) {
1932 LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
1933 (const char *, uint32_t), name, max_matches);
1935 SBValueList sb_value_list;
1937 TargetSP target_sp(GetSP());
1938 if (name && target_sp) {
1939 VariableList variable_list;
1940 const uint32_t match_count = target_sp->GetImages().FindGlobalVariables(
1941 ConstString(name), max_matches, variable_list);
1943 if (match_count > 0) {
1944 ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
1945 if (exe_scope == nullptr)
1946 exe_scope = target_sp.get();
1947 for (uint32_t i = 0; i < match_count; ++i) {
1948 lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
1949 exe_scope, variable_list.GetVariableAtIndex(i)));
1951 sb_value_list.Append(SBValue(valobj_sp));
1956 return LLDB_RECORD_RESULT(sb_value_list);
1959 SBValueList SBTarget::FindGlobalVariables(const char *name,
1960 uint32_t max_matches,
1961 MatchType matchtype) {
1962 LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
1963 (const char *, uint32_t, lldb::MatchType), name,
1964 max_matches, matchtype);
1966 SBValueList sb_value_list;
1968 TargetSP target_sp(GetSP());
1969 if (name && target_sp) {
1970 llvm::StringRef name_ref(name);
1971 VariableList variable_list;
1973 std::string regexstr;
1974 uint32_t match_count;
1975 switch (matchtype) {
1976 case eMatchTypeNormal:
1977 match_count = target_sp->GetImages().FindGlobalVariables(
1978 ConstString(name), max_matches, variable_list);
1980 case eMatchTypeRegex:
1981 match_count = target_sp->GetImages().FindGlobalVariables(
1982 RegularExpression(name_ref), max_matches, variable_list);
1984 case eMatchTypeStartsWith:
1985 regexstr = llvm::Regex::escape(name) + ".*";
1986 match_count = target_sp->GetImages().FindGlobalVariables(
1987 RegularExpression(regexstr), max_matches, variable_list);
1991 if (match_count > 0) {
1992 ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
1993 if (exe_scope == nullptr)
1994 exe_scope = target_sp.get();
1995 for (uint32_t i = 0; i < match_count; ++i) {
1996 lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
1997 exe_scope, variable_list.GetVariableAtIndex(i)));
1999 sb_value_list.Append(SBValue(valobj_sp));
2004 return LLDB_RECORD_RESULT(sb_value_list);
2007 lldb::SBValue SBTarget::FindFirstGlobalVariable(const char *name) {
2008 LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable,
2009 (const char *), name);
2011 SBValueList sb_value_list(FindGlobalVariables(name, 1));
2012 if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
2013 return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0));
2014 return LLDB_RECORD_RESULT(SBValue());
2017 SBSourceManager SBTarget::GetSourceManager() {
2018 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBTarget, GetSourceManager);
2020 SBSourceManager source_manager(*this);
2021 return LLDB_RECORD_RESULT(source_manager);
2024 lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
2026 LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
2027 (lldb::SBAddress, uint32_t), base_addr, count);
2029 return LLDB_RECORD_RESULT(ReadInstructions(base_addr, count, nullptr));
2032 lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
2034 const char *flavor_string) {
2035 LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
2036 (lldb::SBAddress, uint32_t, const char *), base_addr,
2037 count, flavor_string);
2039 SBInstructionList sb_instructions;
2041 TargetSP target_sp(GetSP());
2043 Address *addr_ptr = base_addr.get();
2046 DataBufferHeap data(
2047 target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0);
2048 bool prefer_file_cache = false;
2049 lldb_private::Status error;
2050 lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
2051 const size_t bytes_read =
2052 target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(),
2053 data.GetByteSize(), error, &load_addr);
2054 const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
2055 sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
2056 target_sp->GetArchitecture(), nullptr, flavor_string, *addr_ptr,
2057 data.GetBytes(), bytes_read, count, data_from_file));
2061 return LLDB_RECORD_RESULT(sb_instructions);
2064 lldb::SBInstructionList SBTarget::GetInstructions(lldb::SBAddress base_addr,
2067 LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions,
2068 (lldb::SBAddress, const void *, size_t), base_addr, buf,
2071 return GetInstructionsWithFlavor(base_addr, nullptr, buf, size);
2074 lldb::SBInstructionList
2075 SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr,
2076 const char *flavor_string, const void *buf,
2078 LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget,
2079 GetInstructionsWithFlavor,
2080 (lldb::SBAddress, const char *, const void *, size_t),
2081 base_addr, flavor_string, buf, size);
2083 SBInstructionList sb_instructions;
2085 TargetSP target_sp(GetSP());
2089 if (base_addr.get())
2090 addr = *base_addr.get();
2092 const bool data_from_file = true;
2094 sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
2095 target_sp->GetArchitecture(), nullptr, flavor_string, addr, buf, size,
2096 UINT32_MAX, data_from_file));
2099 return sb_instructions;
2102 lldb::SBInstructionList SBTarget::GetInstructions(lldb::addr_t base_addr,
2105 LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions,
2106 (lldb::addr_t, const void *, size_t), base_addr, buf, size);
2108 return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), nullptr, buf,
2112 lldb::SBInstructionList
2113 SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr,
2114 const char *flavor_string, const void *buf,
2116 LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget,
2117 GetInstructionsWithFlavor,
2118 (lldb::addr_t, const char *, const void *, size_t),
2119 base_addr, flavor_string, buf, size);
2121 return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string,
2125 SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section,
2126 lldb::addr_t section_base_addr) {
2127 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress,
2128 (lldb::SBSection, lldb::addr_t), section,
2132 TargetSP target_sp(GetSP());
2134 if (!section.IsValid()) {
2135 sb_error.SetErrorStringWithFormat("invalid section");
2137 SectionSP section_sp(section.GetSP());
2139 if (section_sp->IsThreadSpecific()) {
2140 sb_error.SetErrorString(
2141 "thread specific sections are not yet supported");
2143 ProcessSP process_sp(target_sp->GetProcessSP());
2144 if (target_sp->SetSectionLoadAddress(section_sp, section_base_addr)) {
2145 ModuleSP module_sp(section_sp->GetModule());
2147 ModuleList module_list;
2148 module_list.Append(module_sp);
2149 target_sp->ModulesDidLoad(module_list);
2151 // Flush info in the process (stack frames, etc)
2153 process_sp->Flush();
2159 sb_error.SetErrorString("invalid target");
2161 return LLDB_RECORD_RESULT(sb_error);
2164 SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) {
2165 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress,
2166 (lldb::SBSection), section);
2170 TargetSP target_sp(GetSP());
2172 if (!section.IsValid()) {
2173 sb_error.SetErrorStringWithFormat("invalid section");
2175 SectionSP section_sp(section.GetSP());
2177 ProcessSP process_sp(target_sp->GetProcessSP());
2178 if (target_sp->SetSectionUnloaded(section_sp)) {
2179 ModuleSP module_sp(section_sp->GetModule());
2181 ModuleList module_list;
2182 module_list.Append(module_sp);
2183 target_sp->ModulesDidUnload(module_list, false);
2185 // Flush info in the process (stack frames, etc)
2187 process_sp->Flush();
2190 sb_error.SetErrorStringWithFormat("invalid section");
2194 sb_error.SetErrorStringWithFormat("invalid target");
2196 return LLDB_RECORD_RESULT(sb_error);
2199 SBError SBTarget::SetModuleLoadAddress(lldb::SBModule module,
2200 int64_t slide_offset) {
2201 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress,
2202 (lldb::SBModule, int64_t), module, slide_offset);
2206 TargetSP target_sp(GetSP());
2208 ModuleSP module_sp(module.GetSP());
2210 bool changed = false;
2211 if (module_sp->SetLoadAddress(*target_sp, slide_offset, true, changed)) {
2212 // The load was successful, make sure that at least some sections
2213 // changed before we notify that our module was loaded.
2215 ModuleList module_list;
2216 module_list.Append(module_sp);
2217 target_sp->ModulesDidLoad(module_list);
2218 // Flush info in the process (stack frames, etc)
2219 ProcessSP process_sp(target_sp->GetProcessSP());
2221 process_sp->Flush();
2225 sb_error.SetErrorStringWithFormat("invalid module");
2229 sb_error.SetErrorStringWithFormat("invalid target");
2231 return LLDB_RECORD_RESULT(sb_error);
2234 SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) {
2235 LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress,
2236 (lldb::SBModule), module);
2240 char path[PATH_MAX];
2241 TargetSP target_sp(GetSP());
2243 ModuleSP module_sp(module.GetSP());
2245 ObjectFile *objfile = module_sp->GetObjectFile();
2247 SectionList *section_list = objfile->GetSectionList();
2249 ProcessSP process_sp(target_sp->GetProcessSP());
2251 bool changed = false;
2252 const size_t num_sections = section_list->GetSize();
2253 for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
2254 SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
2256 changed |= target_sp->SetSectionUnloaded(section_sp);
2259 ModuleList module_list;
2260 module_list.Append(module_sp);
2261 target_sp->ModulesDidUnload(module_list, false);
2262 // Flush info in the process (stack frames, etc)
2263 ProcessSP process_sp(target_sp->GetProcessSP());
2265 process_sp->Flush();
2268 module_sp->GetFileSpec().GetPath(path, sizeof(path));
2269 sb_error.SetErrorStringWithFormat("no sections in object file '%s'",
2273 module_sp->GetFileSpec().GetPath(path, sizeof(path));
2274 sb_error.SetErrorStringWithFormat("no object file for module '%s'",
2278 sb_error.SetErrorStringWithFormat("invalid module");
2281 sb_error.SetErrorStringWithFormat("invalid target");
2283 return LLDB_RECORD_RESULT(sb_error);
2286 lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name,
2287 lldb::SymbolType symbol_type) {
2288 LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols,
2289 (const char *, lldb::SymbolType), name, symbol_type);
2291 SBSymbolContextList sb_sc_list;
2292 if (name && name[0]) {
2293 TargetSP target_sp(GetSP());
2296 target_sp->GetImages().FindSymbolsWithNameAndType(
2297 ConstString(name), symbol_type, *sb_sc_list, append);
2300 return LLDB_RECORD_RESULT(sb_sc_list);
2303 lldb::SBValue SBTarget::EvaluateExpression(const char *expr) {
2304 LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
2305 (const char *), expr);
2307 TargetSP target_sp(GetSP());
2309 return LLDB_RECORD_RESULT(SBValue());
2311 SBExpressionOptions options;
2312 lldb::DynamicValueType fetch_dynamic_value =
2313 target_sp->GetPreferDynamicValue();
2314 options.SetFetchDynamicValue(fetch_dynamic_value);
2315 options.SetUnwindOnError(true);
2316 return LLDB_RECORD_RESULT(EvaluateExpression(expr, options));
2319 lldb::SBValue SBTarget::EvaluateExpression(const char *expr,
2320 const SBExpressionOptions &options) {
2321 LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
2322 (const char *, const lldb::SBExpressionOptions &), expr,
2325 Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
2326 SBValue expr_result;
2327 ValueObjectSP expr_value_sp;
2328 TargetSP target_sp(GetSP());
2329 StackFrame *frame = nullptr;
2331 if (expr == nullptr || expr[0] == '\0') {
2332 return LLDB_RECORD_RESULT(expr_result);
2335 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
2336 ExecutionContext exe_ctx(m_opaque_sp.get());
2339 frame = exe_ctx.GetFramePtr();
2340 Target *target = exe_ctx.GetTargetPtr();
2343 #ifdef LLDB_CONFIGURATION_DEBUG
2344 StreamString frame_description;
2346 frame->DumpUsingSettingsFormat(&frame_description);
2347 llvm::PrettyStackTraceFormat stack_trace(
2348 "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = "
2350 expr, options.GetFetchDynamicValue(),
2351 frame_description.GetString().str().c_str());
2353 target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
2355 expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
2359 expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is "
2360 "%s, summary %s **",
2361 expr_result.GetValue(), expr_result.GetSummary());
2362 return LLDB_RECORD_RESULT(expr_result);
2365 lldb::addr_t SBTarget::GetStackRedZoneSize() {
2366 LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBTarget, GetStackRedZoneSize);
2368 TargetSP target_sp(GetSP());
2371 ProcessSP process_sp(target_sp->GetProcessSP());
2373 abi_sp = process_sp->GetABI();
2375 abi_sp = ABI::FindPlugin(ProcessSP(), target_sp->GetArchitecture());
2377 return abi_sp->GetRedZoneSize();
2382 lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
2383 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo);
2385 lldb::SBLaunchInfo launch_info(nullptr);
2386 TargetSP target_sp(GetSP());
2388 launch_info.set_ref(m_opaque_sp->GetProcessLaunchInfo());
2389 return LLDB_RECORD_RESULT(launch_info);
2392 void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) {
2393 LLDB_RECORD_METHOD(void, SBTarget, SetLaunchInfo,
2394 (const lldb::SBLaunchInfo &), launch_info);
2396 TargetSP target_sp(GetSP());
2398 m_opaque_sp->SetProcessLaunchInfo(launch_info.ref());
2401 namespace lldb_private {
2405 void RegisterMethods<SBTarget>(Registry &R) {
2406 LLDB_REGISTER_CONSTRUCTOR(SBTarget, ());
2407 LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &));
2408 LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &));
2409 LLDB_REGISTER_METHOD(const lldb::SBTarget &,
2410 SBTarget, operator=,(const lldb::SBTarget &));
2411 LLDB_REGISTER_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent,
2412 (const lldb::SBEvent &));
2413 LLDB_REGISTER_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent,
2414 (const lldb::SBEvent &));
2415 LLDB_REGISTER_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent,
2416 (const lldb::SBEvent &));
2417 LLDB_REGISTER_STATIC_METHOD(lldb::SBModule, SBTarget,
2418 GetModuleAtIndexFromEvent,
2419 (const uint32_t, const lldb::SBEvent &));
2420 LLDB_REGISTER_STATIC_METHOD(const char *, SBTarget, GetBroadcasterClassName,
2422 LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsValid, ());
2423 LLDB_REGISTER_METHOD_CONST(bool, SBTarget, operator bool, ());
2424 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, GetProcess, ());
2425 LLDB_REGISTER_METHOD(lldb::SBPlatform, SBTarget, GetPlatform, ());
2426 LLDB_REGISTER_METHOD_CONST(lldb::SBDebugger, SBTarget, GetDebugger, ());
2427 LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBTarget, GetStatistics, ());
2428 LLDB_REGISTER_METHOD(void, SBTarget, SetCollectingStats, (bool));
2429 LLDB_REGISTER_METHOD(bool, SBTarget, GetCollectingStats, ());
2430 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *));
2431 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore,
2432 (const char *, lldb::SBError &));
2433 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LaunchSimple,
2434 (const char **, const char **, const char *));
2435 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, Install, ());
2436 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch,
2437 (lldb::SBListener &, const char **, const char **,
2438 const char *, const char *, const char *,
2439 const char *, uint32_t, bool, lldb::SBError &));
2440 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch,
2441 (lldb::SBLaunchInfo &, lldb::SBError &));
2442 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Attach,
2443 (lldb::SBAttachInfo &, lldb::SBError &));
2444 LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID,
2445 (lldb::SBListener &, lldb::pid_t, lldb::SBError &));
2446 LLDB_REGISTER_METHOD(
2447 lldb::SBProcess, SBTarget, AttachToProcessWithName,
2448 (lldb::SBListener &, const char *, bool, lldb::SBError &));
2449 LLDB_REGISTER_METHOD(
2450 lldb::SBProcess, SBTarget, ConnectRemote,
2451 (lldb::SBListener &, const char *, const char *, lldb::SBError &));
2452 LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBTarget, GetExecutable, ());
2453 LLDB_REGISTER_METHOD_CONST(bool,
2454 SBTarget, operator==,(const lldb::SBTarget &));
2455 LLDB_REGISTER_METHOD_CONST(bool,
2456 SBTarget, operator!=,(const lldb::SBTarget &));
2457 LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress,
2459 LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress,
2461 LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress,
2462 (uint32_t, lldb::addr_t));
2463 LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBTarget,
2464 ResolveSymbolContextForAddress,
2465 (const lldb::SBAddress &, uint32_t));
2466 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
2467 BreakpointCreateByLocation, (const char *, uint32_t));
2468 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
2469 BreakpointCreateByLocation,
2470 (const lldb::SBFileSpec &, uint32_t));
2471 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
2472 BreakpointCreateByLocation,
2473 (const lldb::SBFileSpec &, uint32_t, lldb::addr_t));
2474 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
2475 BreakpointCreateByLocation,
2476 (const lldb::SBFileSpec &, uint32_t, lldb::addr_t,
2477 lldb::SBFileSpecList &));
2478 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
2479 BreakpointCreateByLocation,
2480 (const lldb::SBFileSpec &, uint32_t, uint32_t,
2481 lldb::addr_t, lldb::SBFileSpecList &));
2482 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
2483 (const char *, const char *));
2484 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
2485 (const char *, const lldb::SBFileSpecList &,
2486 const lldb::SBFileSpecList &));
2487 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
2488 (const char *, uint32_t, const lldb::SBFileSpecList &,
2489 const lldb::SBFileSpecList &));
2490 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
2491 (const char *, uint32_t, lldb::LanguageType,
2492 const lldb::SBFileSpecList &,
2493 const lldb::SBFileSpecList &));
2494 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
2495 (const char **, uint32_t, uint32_t,
2496 const lldb::SBFileSpecList &,
2497 const lldb::SBFileSpecList &));
2498 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
2499 (const char **, uint32_t, uint32_t, lldb::LanguageType,
2500 const lldb::SBFileSpecList &,
2501 const lldb::SBFileSpecList &));
2502 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
2503 (const char **, uint32_t, uint32_t, lldb::LanguageType,
2504 lldb::addr_t, const lldb::SBFileSpecList &,
2505 const lldb::SBFileSpecList &));
2506 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
2507 (const char *, const char *));
2508 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
2509 (const char *, const lldb::SBFileSpecList &,
2510 const lldb::SBFileSpecList &));
2511 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
2512 (const char *, lldb::LanguageType,
2513 const lldb::SBFileSpecList &,
2514 const lldb::SBFileSpecList &));
2515 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
2516 BreakpointCreateByAddress, (lldb::addr_t));
2517 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
2518 BreakpointCreateBySBAddress, (lldb::SBAddress &));
2519 LLDB_REGISTER_METHOD(
2520 lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex,
2521 (const char *, const lldb::SBFileSpec &, const char *));
2522 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
2523 BreakpointCreateBySourceRegex,
2524 (const char *, const lldb::SBFileSpecList &,
2525 const lldb::SBFileSpecList &));
2526 LLDB_REGISTER_METHOD(
2527 lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex,
2528 (const char *, const lldb::SBFileSpecList &,
2529 const lldb::SBFileSpecList &, const lldb::SBStringList &));
2530 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
2531 BreakpointCreateForException,
2532 (lldb::LanguageType, bool, bool));
2533 LLDB_REGISTER_METHOD(
2534 lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript,
2535 (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &,
2536 const lldb::SBFileSpecList &, bool));
2537 LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumBreakpoints, ());
2538 LLDB_REGISTER_METHOD_CONST(lldb::SBBreakpoint, SBTarget,
2539 GetBreakpointAtIndex, (uint32_t));
2540 LLDB_REGISTER_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t));
2541 LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID,
2542 (lldb::break_id_t));
2543 LLDB_REGISTER_METHOD(bool, SBTarget, FindBreakpointsByName,
2544 (const char *, lldb::SBBreakpointList &));
2545 LLDB_REGISTER_METHOD(void, SBTarget, GetBreakpointNames,
2546 (lldb::SBStringList &));
2547 LLDB_REGISTER_METHOD(void, SBTarget, DeleteBreakpointName, (const char *));
2548 LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllBreakpoints, ());
2549 LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllBreakpoints, ());
2550 LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllBreakpoints, ());
2551 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile,
2552 (lldb::SBFileSpec &, lldb::SBBreakpointList &));
2553 LLDB_REGISTER_METHOD(
2554 lldb::SBError, SBTarget, BreakpointsCreateFromFile,
2555 (lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &));
2556 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
2557 (lldb::SBFileSpec &));
2558 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
2559 (lldb::SBFileSpec &, lldb::SBBreakpointList &, bool));
2560 LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumWatchpoints, ());
2561 LLDB_REGISTER_METHOD_CONST(lldb::SBWatchpoint, SBTarget,
2562 GetWatchpointAtIndex, (uint32_t));
2563 LLDB_REGISTER_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t));
2564 LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID,
2565 (lldb::watch_id_t));
2566 LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress,
2567 (lldb::addr_t, size_t, bool, bool, lldb::SBError &));
2568 LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllWatchpoints, ());
2569 LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllWatchpoints, ());
2570 LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress,
2571 (const char *, lldb::SBAddress, lldb::SBType));
2572 LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromData,
2573 (const char *, lldb::SBData, lldb::SBType));
2574 LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression,
2575 (const char *, const char *));
2576 LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllWatchpoints, ());
2577 LLDB_REGISTER_METHOD(void, SBTarget, AppendImageSearchPath,
2578 (const char *, const char *, lldb::SBError &));
2579 LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule,
2580 (const char *, const char *, const char *));
2581 LLDB_REGISTER_METHOD(
2582 lldb::SBModule, SBTarget, AddModule,
2583 (const char *, const char *, const char *, const char *));
2584 LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule,
2585 (const lldb::SBModuleSpec &));
2586 LLDB_REGISTER_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &));
2587 LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumModules, ());
2588 LLDB_REGISTER_METHOD(void, SBTarget, Clear, ());
2589 LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, FindModule,
2590 (const lldb::SBFileSpec &));
2591 LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits,
2592 (const lldb::SBFileSpec &));
2593 LLDB_REGISTER_METHOD(lldb::ByteOrder, SBTarget, GetByteOrder, ());
2594 LLDB_REGISTER_METHOD(const char *, SBTarget, GetTriple, ());
2595 LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetDataByteSize, ());
2596 LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetCodeByteSize, ());
2597 LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetAddressByteSize, ());
2598 LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex,
2600 LLDB_REGISTER_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule));
2601 LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBTarget, GetBroadcaster,
2603 LLDB_REGISTER_METHOD(bool, SBTarget, GetDescription,
2604 (lldb::SBStream &, lldb::DescriptionLevel));
2605 LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions,
2606 (const char *, uint32_t));
2607 LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget,
2608 FindGlobalFunctions,
2609 (const char *, uint32_t, lldb::MatchType));
2610 LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *));
2611 LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, GetBasicType,
2613 LLDB_REGISTER_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *));
2614 LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
2615 (const char *, uint32_t));
2616 LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
2617 (const char *, uint32_t, lldb::MatchType));
2618 LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable,
2620 LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBTarget, GetSourceManager, ());
2621 LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
2622 (lldb::SBAddress, uint32_t));
2623 LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
2624 (lldb::SBAddress, uint32_t, const char *));
2625 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress,
2626 (lldb::SBSection, lldb::addr_t));
2627 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress,
2629 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress,
2630 (lldb::SBModule, int64_t));
2631 LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress,
2633 LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols,
2634 (const char *, lldb::SymbolType));
2635 LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
2637 LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
2638 (const char *, const lldb::SBExpressionOptions &));
2639 LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ());
2640 LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ());
2641 LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo,
2642 (const lldb::SBLaunchInfo &));