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/SearchFilter.h"
40 #include "lldb/Core/Section.h"
41 #include "lldb/Core/StructuredDataImpl.h"
42 #include "lldb/Core/ValueObjectConstResult.h"
43 #include "lldb/Core/ValueObjectList.h"
44 #include "lldb/Core/ValueObjectVariable.h"
45 #include "lldb/Host/Host.h"
46 #include "lldb/Symbol/DeclVendor.h"
47 #include "lldb/Symbol/ObjectFile.h"
48 #include "lldb/Symbol/SymbolFile.h"
49 #include "lldb/Symbol/SymbolVendor.h"
50 #include "lldb/Symbol/TypeSystem.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/Process.h"
56 #include "lldb/Target/StackFrame.h"
57 #include "lldb/Target/Target.h"
58 #include "lldb/Target/TargetList.h"
59 #include "lldb/Utility/ArchSpec.h"
60 #include "lldb/Utility/Args.h"
61 #include "lldb/Utility/FileSpec.h"
62 #include "lldb/Utility/ProcessInfo.h"
63 #include "lldb/Utility/RegularExpression.h"
65 #include "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 to
86 // 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 // SBTarget constructor
99 SBTarget::SBTarget() : m_opaque_sp() {
100 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTarget
);
103 SBTarget::SBTarget(const SBTarget
&rhs
) : m_opaque_sp(rhs
.m_opaque_sp
) {
104 LLDB_RECORD_CONSTRUCTOR(SBTarget
, (const lldb::SBTarget
&), rhs
);
107 SBTarget::SBTarget(const TargetSP
&target_sp
) : m_opaque_sp(target_sp
) {
108 LLDB_RECORD_CONSTRUCTOR(SBTarget
, (const lldb::TargetSP
&), target_sp
);
111 const SBTarget
&SBTarget::operator=(const SBTarget
&rhs
) {
112 LLDB_RECORD_METHOD(const lldb::SBTarget
&,
113 SBTarget
, operator=,(const lldb::SBTarget
&), rhs
);
116 m_opaque_sp
= rhs
.m_opaque_sp
;
117 return LLDB_RECORD_RESULT(*this);
121 SBTarget::~SBTarget() {}
123 bool SBTarget::EventIsTargetEvent(const SBEvent
&event
) {
124 LLDB_RECORD_STATIC_METHOD(bool, SBTarget
, EventIsTargetEvent
,
125 (const lldb::SBEvent
&), event
);
127 return Target::TargetEventData::GetEventDataFromEvent(event
.get()) != nullptr;
130 SBTarget
SBTarget::GetTargetFromEvent(const SBEvent
&event
) {
131 LLDB_RECORD_STATIC_METHOD(lldb::SBTarget
, SBTarget
, GetTargetFromEvent
,
132 (const lldb::SBEvent
&), event
);
134 return LLDB_RECORD_RESULT(
135 Target::TargetEventData::GetTargetFromEvent(event
.get()));
138 uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent
&event
) {
139 LLDB_RECORD_STATIC_METHOD(uint32_t, SBTarget
, GetNumModulesFromEvent
,
140 (const lldb::SBEvent
&), event
);
142 const ModuleList module_list
=
143 Target::TargetEventData::GetModuleListFromEvent(event
.get());
144 return module_list
.GetSize();
147 SBModule
SBTarget::GetModuleAtIndexFromEvent(const uint32_t idx
,
148 const SBEvent
&event
) {
149 LLDB_RECORD_STATIC_METHOD(lldb::SBModule
, SBTarget
, GetModuleAtIndexFromEvent
,
150 (const uint32_t, const lldb::SBEvent
&), idx
,
153 const ModuleList module_list
=
154 Target::TargetEventData::GetModuleListFromEvent(event
.get());
155 return LLDB_RECORD_RESULT(SBModule(module_list
.GetModuleAtIndex(idx
)));
158 const char *SBTarget::GetBroadcasterClassName() {
159 LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBTarget
,
160 GetBroadcasterClassName
);
162 return Target::GetStaticBroadcasterClass().AsCString();
165 bool SBTarget::IsValid() const {
166 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget
, IsValid
);
167 return this->operator bool();
169 SBTarget::operator bool() const {
170 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget
, operator bool);
172 return m_opaque_sp
.get() != nullptr && m_opaque_sp
->IsValid();
175 SBProcess
SBTarget::GetProcess() {
176 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess
, SBTarget
, GetProcess
);
178 SBProcess sb_process
;
179 ProcessSP process_sp
;
180 TargetSP
target_sp(GetSP());
182 process_sp
= target_sp
->GetProcessSP();
183 sb_process
.SetSP(process_sp
);
186 return LLDB_RECORD_RESULT(sb_process
);
189 SBPlatform
SBTarget::GetPlatform() {
190 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform
, SBTarget
, GetPlatform
);
192 TargetSP
target_sp(GetSP());
194 return LLDB_RECORD_RESULT(SBPlatform());
197 platform
.m_opaque_sp
= target_sp
->GetPlatform();
199 return LLDB_RECORD_RESULT(platform
);
202 SBDebugger
SBTarget::GetDebugger() const {
203 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBDebugger
, SBTarget
, GetDebugger
);
206 TargetSP
target_sp(GetSP());
208 debugger
.reset(target_sp
->GetDebugger().shared_from_this());
209 return LLDB_RECORD_RESULT(debugger
);
212 SBStructuredData
SBTarget::GetStatistics() {
213 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData
, SBTarget
, GetStatistics
);
215 SBStructuredData data
;
216 TargetSP
target_sp(GetSP());
218 return LLDB_RECORD_RESULT(data
);
220 auto stats_up
= std::make_unique
<StructuredData::Dictionary
>();
222 for (auto &Entry
: target_sp
->GetStatistics()) {
223 std::string Desc
= lldb_private::GetStatDescription(
224 static_cast<lldb_private::StatisticKind
>(i
));
225 stats_up
->AddIntegerItem(Desc
, Entry
);
229 data
.m_impl_up
->SetObjectSP(std::move(stats_up
));
230 return LLDB_RECORD_RESULT(data
);
233 void SBTarget::SetCollectingStats(bool v
) {
234 LLDB_RECORD_METHOD(void, SBTarget
, SetCollectingStats
, (bool), v
);
236 TargetSP
target_sp(GetSP());
239 return target_sp
->SetCollectingStats(v
);
242 bool SBTarget::GetCollectingStats() {
243 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget
, GetCollectingStats
);
245 TargetSP
target_sp(GetSP());
248 return target_sp
->GetCollectingStats();
251 SBProcess
SBTarget::LoadCore(const char *core_file
) {
252 LLDB_RECORD_METHOD(lldb::SBProcess
, SBTarget
, LoadCore
, (const char *),
255 lldb::SBError error
; // Ignored
256 return LLDB_RECORD_RESULT(LoadCore(core_file
, error
));
259 SBProcess
SBTarget::LoadCore(const char *core_file
, lldb::SBError
&error
) {
260 LLDB_RECORD_METHOD(lldb::SBProcess
, SBTarget
, LoadCore
,
261 (const char *, lldb::SBError
&), core_file
, error
);
263 SBProcess sb_process
;
264 TargetSP
target_sp(GetSP());
266 FileSpec
filespec(core_file
);
267 FileSystem::Instance().Resolve(filespec
);
268 ProcessSP
process_sp(target_sp
->CreateProcess(
269 target_sp
->GetDebugger().GetListener(), "", &filespec
));
271 error
.SetError(process_sp
->LoadCore());
273 sb_process
.SetSP(process_sp
);
275 error
.SetErrorString("Failed to create the process");
278 error
.SetErrorString("SBTarget is invalid");
280 return LLDB_RECORD_RESULT(sb_process
);
283 SBProcess
SBTarget::LaunchSimple(char const **argv
, char const **envp
,
284 const char *working_directory
) {
285 LLDB_RECORD_METHOD(lldb::SBProcess
, SBTarget
, LaunchSimple
,
286 (const char **, const char **, const char *), argv
, envp
,
289 char *stdin_path
= nullptr;
290 char *stdout_path
= nullptr;
291 char *stderr_path
= nullptr;
292 uint32_t launch_flags
= 0;
293 bool stop_at_entry
= false;
295 SBListener listener
= GetDebugger().GetListener();
296 return LLDB_RECORD_RESULT(Launch(listener
, argv
, envp
, stdin_path
,
297 stdout_path
, stderr_path
, working_directory
,
298 launch_flags
, stop_at_entry
, error
));
301 SBError
SBTarget::Install() {
302 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError
, SBTarget
, Install
);
305 TargetSP
target_sp(GetSP());
307 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
308 sb_error
.ref() = target_sp
->Install(nullptr);
310 return LLDB_RECORD_RESULT(sb_error
);
313 SBProcess
SBTarget::Launch(SBListener
&listener
, char const **argv
,
314 char const **envp
, const char *stdin_path
,
315 const char *stdout_path
, const char *stderr_path
,
316 const char *working_directory
,
317 uint32_t launch_flags
, // See LaunchFlags
318 bool stop_at_entry
, lldb::SBError
&error
) {
319 LLDB_RECORD_METHOD(lldb::SBProcess
, SBTarget
, Launch
,
320 (lldb::SBListener
&, const char **, const char **,
321 const char *, const char *, const char *, const char *,
322 uint32_t, bool, lldb::SBError
&),
323 listener
, argv
, envp
, stdin_path
, stdout_path
, stderr_path
,
324 working_directory
, launch_flags
, stop_at_entry
, error
);
326 SBProcess sb_process
;
327 ProcessSP process_sp
;
328 TargetSP
target_sp(GetSP());
331 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
334 launch_flags
|= eLaunchFlagStopAtEntry
;
336 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
337 launch_flags
|= eLaunchFlagDisableASLR
;
339 StateType state
= eStateInvalid
;
340 process_sp
= target_sp
->GetProcessSP();
342 state
= process_sp
->GetState();
344 if (process_sp
->IsAlive() && state
!= eStateConnected
) {
345 if (state
== eStateAttaching
)
346 error
.SetErrorString("process attach is in progress");
348 error
.SetErrorString("a process is already being debugged");
349 return LLDB_RECORD_RESULT(sb_process
);
353 if (state
== eStateConnected
) {
354 // If we are already connected, then we have already specified the
355 // listener, so if a valid listener is supplied, we need to error out to
356 // let the client know.
357 if (listener
.IsValid()) {
358 error
.SetErrorString("process is connected and already has a listener, "
359 "pass empty listener");
360 return LLDB_RECORD_RESULT(sb_process
);
364 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
365 launch_flags
|= eLaunchFlagDisableSTDIO
;
367 ProcessLaunchInfo
launch_info(FileSpec(stdin_path
), FileSpec(stdout_path
),
368 FileSpec(stderr_path
),
369 FileSpec(working_directory
), launch_flags
);
371 Module
*exe_module
= target_sp
->GetExecutableModulePointer();
373 launch_info
.SetExecutableFile(exe_module
->GetPlatformFileSpec(), true);
375 launch_info
.GetArguments().AppendArguments(argv
);
377 launch_info
.GetEnvironment() = Environment(envp
);
379 if (listener
.IsValid())
380 launch_info
.SetListener(listener
.GetSP());
382 error
.SetError(target_sp
->Launch(launch_info
, nullptr));
384 sb_process
.SetSP(target_sp
->GetProcessSP());
386 error
.SetErrorString("SBTarget is invalid");
389 return LLDB_RECORD_RESULT(sb_process
);
392 SBProcess
SBTarget::Launch(SBLaunchInfo
&sb_launch_info
, SBError
&error
) {
393 LLDB_RECORD_METHOD(lldb::SBProcess
, SBTarget
, Launch
,
394 (lldb::SBLaunchInfo
&, lldb::SBError
&), sb_launch_info
,
398 SBProcess sb_process
;
399 TargetSP
target_sp(GetSP());
402 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
403 StateType state
= eStateInvalid
;
405 ProcessSP process_sp
= target_sp
->GetProcessSP();
407 state
= process_sp
->GetState();
409 if (process_sp
->IsAlive() && state
!= eStateConnected
) {
410 if (state
== eStateAttaching
)
411 error
.SetErrorString("process attach is in progress");
413 error
.SetErrorString("a process is already being debugged");
414 return LLDB_RECORD_RESULT(sb_process
);
419 lldb_private::ProcessLaunchInfo launch_info
= sb_launch_info
.ref();
421 if (!launch_info
.GetExecutableFile()) {
422 Module
*exe_module
= target_sp
->GetExecutableModulePointer();
424 launch_info
.SetExecutableFile(exe_module
->GetPlatformFileSpec(), true);
427 const ArchSpec
&arch_spec
= target_sp
->GetArchitecture();
428 if (arch_spec
.IsValid())
429 launch_info
.GetArchitecture() = arch_spec
;
431 error
.SetError(target_sp
->Launch(launch_info
, nullptr));
432 sb_launch_info
.set_ref(launch_info
);
433 sb_process
.SetSP(target_sp
->GetProcessSP());
435 error
.SetErrorString("SBTarget is invalid");
438 return LLDB_RECORD_RESULT(sb_process
);
441 lldb::SBProcess
SBTarget::Attach(SBAttachInfo
&sb_attach_info
, SBError
&error
) {
442 LLDB_RECORD_METHOD(lldb::SBProcess
, SBTarget
, Attach
,
443 (lldb::SBAttachInfo
&, lldb::SBError
&), sb_attach_info
,
446 SBProcess sb_process
;
447 TargetSP
target_sp(GetSP());
450 ProcessAttachInfo
&attach_info
= sb_attach_info
.ref();
451 if (attach_info
.ProcessIDIsValid() && !attach_info
.UserIDIsValid()) {
452 PlatformSP platform_sp
= target_sp
->GetPlatform();
453 // See if we can pre-verify if a process exists or not
454 if (platform_sp
&& platform_sp
->IsConnected()) {
455 lldb::pid_t attach_pid
= attach_info
.GetProcessID();
456 ProcessInstanceInfo instance_info
;
457 if (platform_sp
->GetProcessInfo(attach_pid
, instance_info
)) {
458 attach_info
.SetUserID(instance_info
.GetEffectiveUserID());
460 error
.ref().SetErrorStringWithFormat(
461 "no process found with process ID %" PRIu64
, attach_pid
);
462 return LLDB_RECORD_RESULT(sb_process
);
466 error
.SetError(AttachToProcess(attach_info
, *target_sp
));
468 sb_process
.SetSP(target_sp
->GetProcessSP());
470 error
.SetErrorString("SBTarget is invalid");
473 return LLDB_RECORD_RESULT(sb_process
);
476 lldb::SBProcess
SBTarget::AttachToProcessWithID(
477 SBListener
&listener
,
478 lldb::pid_t pid
, // The process ID to attach to
479 SBError
&error
// An error explaining what went wrong if attach fails
481 LLDB_RECORD_METHOD(lldb::SBProcess
, SBTarget
, AttachToProcessWithID
,
482 (lldb::SBListener
&, lldb::pid_t
, lldb::SBError
&),
483 listener
, pid
, error
);
485 SBProcess sb_process
;
486 TargetSP
target_sp(GetSP());
489 ProcessAttachInfo attach_info
;
490 attach_info
.SetProcessID(pid
);
491 if (listener
.IsValid())
492 attach_info
.SetListener(listener
.GetSP());
494 ProcessInstanceInfo instance_info
;
495 if (target_sp
->GetPlatform()->GetProcessInfo(pid
, instance_info
))
496 attach_info
.SetUserID(instance_info
.GetEffectiveUserID());
498 error
.SetError(AttachToProcess(attach_info
, *target_sp
));
500 sb_process
.SetSP(target_sp
->GetProcessSP());
502 error
.SetErrorString("SBTarget is invalid");
504 return LLDB_RECORD_RESULT(sb_process
);
507 lldb::SBProcess
SBTarget::AttachToProcessWithName(
508 SBListener
&listener
,
509 const char *name
, // basename of process to attach to
510 bool wait_for
, // if true wait for a new instance of "name" to be launched
511 SBError
&error
// An error explaining what went wrong if attach fails
513 LLDB_RECORD_METHOD(lldb::SBProcess
, SBTarget
, AttachToProcessWithName
,
514 (lldb::SBListener
&, const char *, bool, lldb::SBError
&),
515 listener
, name
, wait_for
, error
);
517 SBProcess sb_process
;
518 TargetSP
target_sp(GetSP());
520 if (name
&& target_sp
) {
521 ProcessAttachInfo attach_info
;
522 attach_info
.GetExecutableFile().SetFile(name
, FileSpec::Style::native
);
523 attach_info
.SetWaitForLaunch(wait_for
);
524 if (listener
.IsValid())
525 attach_info
.SetListener(listener
.GetSP());
527 error
.SetError(AttachToProcess(attach_info
, *target_sp
));
529 sb_process
.SetSP(target_sp
->GetProcessSP());
531 error
.SetErrorString("SBTarget is invalid");
533 return LLDB_RECORD_RESULT(sb_process
);
536 lldb::SBProcess
SBTarget::ConnectRemote(SBListener
&listener
, const char *url
,
537 const char *plugin_name
,
540 lldb::SBProcess
, SBTarget
, ConnectRemote
,
541 (lldb::SBListener
&, const char *, const char *, lldb::SBError
&),
542 listener
, url
, plugin_name
, error
);
544 SBProcess sb_process
;
545 ProcessSP process_sp
;
546 TargetSP
target_sp(GetSP());
549 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
550 if (listener
.IsValid())
552 target_sp
->CreateProcess(listener
.m_opaque_sp
, plugin_name
, nullptr);
554 process_sp
= target_sp
->CreateProcess(
555 target_sp
->GetDebugger().GetListener(), plugin_name
, nullptr);
558 sb_process
.SetSP(process_sp
);
559 error
.SetError(process_sp
->ConnectRemote(nullptr, url
));
561 error
.SetErrorString("unable to create lldb_private::Process");
564 error
.SetErrorString("SBTarget is invalid");
567 return LLDB_RECORD_RESULT(sb_process
);
570 SBFileSpec
SBTarget::GetExecutable() {
571 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec
, SBTarget
, GetExecutable
);
573 SBFileSpec exe_file_spec
;
574 TargetSP
target_sp(GetSP());
576 Module
*exe_module
= target_sp
->GetExecutableModulePointer();
578 exe_file_spec
.SetFileSpec(exe_module
->GetFileSpec());
581 return LLDB_RECORD_RESULT(exe_file_spec
);
584 bool SBTarget::operator==(const SBTarget
&rhs
) const {
585 LLDB_RECORD_METHOD_CONST(bool, SBTarget
, operator==,(const lldb::SBTarget
&),
588 return m_opaque_sp
.get() == rhs
.m_opaque_sp
.get();
591 bool SBTarget::operator!=(const SBTarget
&rhs
) const {
592 LLDB_RECORD_METHOD_CONST(bool, SBTarget
, operator!=,(const lldb::SBTarget
&),
595 return m_opaque_sp
.get() != rhs
.m_opaque_sp
.get();
598 lldb::TargetSP
SBTarget::GetSP() const { return m_opaque_sp
; }
600 void SBTarget::SetSP(const lldb::TargetSP
&target_sp
) {
601 m_opaque_sp
= target_sp
;
604 lldb::SBAddress
SBTarget::ResolveLoadAddress(lldb::addr_t vm_addr
) {
605 LLDB_RECORD_METHOD(lldb::SBAddress
, SBTarget
, ResolveLoadAddress
,
606 (lldb::addr_t
), vm_addr
);
608 lldb::SBAddress sb_addr
;
609 Address
&addr
= sb_addr
.ref();
610 TargetSP
target_sp(GetSP());
612 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
613 if (target_sp
->ResolveLoadAddress(vm_addr
, addr
))
614 return LLDB_RECORD_RESULT(sb_addr
);
617 // We have a load address that isn't in a section, just return an address
618 // with the offset filled in (the address) and the section set to NULL
619 addr
.SetRawAddress(vm_addr
);
620 return LLDB_RECORD_RESULT(sb_addr
);
623 lldb::SBAddress
SBTarget::ResolveFileAddress(lldb::addr_t file_addr
) {
624 LLDB_RECORD_METHOD(lldb::SBAddress
, SBTarget
, ResolveFileAddress
,
625 (lldb::addr_t
), file_addr
);
627 lldb::SBAddress sb_addr
;
628 Address
&addr
= sb_addr
.ref();
629 TargetSP
target_sp(GetSP());
631 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
632 if (target_sp
->ResolveFileAddress(file_addr
, addr
))
633 return LLDB_RECORD_RESULT(sb_addr
);
636 addr
.SetRawAddress(file_addr
);
637 return LLDB_RECORD_RESULT(sb_addr
);
640 lldb::SBAddress
SBTarget::ResolvePastLoadAddress(uint32_t stop_id
,
641 lldb::addr_t vm_addr
) {
642 LLDB_RECORD_METHOD(lldb::SBAddress
, SBTarget
, ResolvePastLoadAddress
,
643 (uint32_t, lldb::addr_t
), stop_id
, vm_addr
);
645 lldb::SBAddress sb_addr
;
646 Address
&addr
= sb_addr
.ref();
647 TargetSP
target_sp(GetSP());
649 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
650 if (target_sp
->ResolveLoadAddress(vm_addr
, addr
))
651 return LLDB_RECORD_RESULT(sb_addr
);
654 // We have a load address that isn't in a section, just return an address
655 // with the offset filled in (the address) and the section set to NULL
656 addr
.SetRawAddress(vm_addr
);
657 return LLDB_RECORD_RESULT(sb_addr
);
661 SBTarget::ResolveSymbolContextForAddress(const SBAddress
&addr
,
662 uint32_t resolve_scope
) {
663 LLDB_RECORD_METHOD(lldb::SBSymbolContext
, SBTarget
,
664 ResolveSymbolContextForAddress
,
665 (const lldb::SBAddress
&, uint32_t), addr
, resolve_scope
);
668 SymbolContextItem scope
= static_cast<SymbolContextItem
>(resolve_scope
);
669 if (addr
.IsValid()) {
670 TargetSP
target_sp(GetSP());
672 target_sp
->GetImages().ResolveSymbolContextForAddress(addr
.ref(), scope
,
675 return LLDB_RECORD_RESULT(sc
);
678 size_t SBTarget::ReadMemory(const SBAddress addr
, void *buf
, size_t size
,
679 lldb::SBError
&error
) {
680 LLDB_RECORD_DUMMY(size_t, SBTarget
, ReadMemory
,
681 (const lldb::SBAddress
, void *, size_t, lldb::SBError
&),
682 addr
, buf
, size
, error
);
685 size_t bytes_read
= 0;
686 TargetSP
target_sp(GetSP());
688 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
690 target_sp
->ReadMemory(addr
.ref(), false, buf
, size
, sb_error
.ref());
692 sb_error
.SetErrorString("invalid target");
698 SBBreakpoint
SBTarget::BreakpointCreateByLocation(const char *file
,
700 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByLocation
,
701 (const char *, uint32_t), file
, line
);
703 return LLDB_RECORD_RESULT(
704 SBBreakpoint(BreakpointCreateByLocation(SBFileSpec(file
, false), line
)));
708 SBTarget::BreakpointCreateByLocation(const SBFileSpec
&sb_file_spec
,
710 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByLocation
,
711 (const lldb::SBFileSpec
&, uint32_t), sb_file_spec
, line
);
713 return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec
, line
, 0));
717 SBTarget::BreakpointCreateByLocation(const SBFileSpec
&sb_file_spec
,
718 uint32_t line
, lldb::addr_t offset
) {
719 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByLocation
,
720 (const lldb::SBFileSpec
&, uint32_t, lldb::addr_t
),
721 sb_file_spec
, line
, offset
);
723 SBFileSpecList empty_list
;
724 return LLDB_RECORD_RESULT(
725 BreakpointCreateByLocation(sb_file_spec
, line
, offset
, empty_list
));
729 SBTarget::BreakpointCreateByLocation(const SBFileSpec
&sb_file_spec
,
730 uint32_t line
, lldb::addr_t offset
,
731 SBFileSpecList
&sb_module_list
) {
732 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByLocation
,
733 (const lldb::SBFileSpec
&, uint32_t, lldb::addr_t
,
734 lldb::SBFileSpecList
&),
735 sb_file_spec
, line
, offset
, sb_module_list
);
737 return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec
, line
, 0,
738 offset
, sb_module_list
));
741 SBBreakpoint
SBTarget::BreakpointCreateByLocation(
742 const SBFileSpec
&sb_file_spec
, uint32_t line
, uint32_t column
,
743 lldb::addr_t offset
, SBFileSpecList
&sb_module_list
) {
744 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByLocation
,
745 (const lldb::SBFileSpec
&, uint32_t, uint32_t,
746 lldb::addr_t
, lldb::SBFileSpecList
&),
747 sb_file_spec
, line
, column
, offset
, sb_module_list
);
750 TargetSP
target_sp(GetSP());
751 if (target_sp
&& line
!= 0) {
752 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
754 const LazyBool check_inlines
= eLazyBoolCalculate
;
755 const LazyBool skip_prologue
= eLazyBoolCalculate
;
756 const bool internal
= false;
757 const bool hardware
= false;
758 const LazyBool move_to_nearest_code
= eLazyBoolCalculate
;
759 const FileSpecList
*module_list
= nullptr;
760 if (sb_module_list
.GetSize() > 0) {
761 module_list
= sb_module_list
.get();
763 sb_bp
= target_sp
->CreateBreakpoint(
764 module_list
, *sb_file_spec
, line
, column
, offset
, check_inlines
,
765 skip_prologue
, internal
, hardware
, move_to_nearest_code
);
768 return LLDB_RECORD_RESULT(sb_bp
);
771 SBBreakpoint
SBTarget::BreakpointCreateByName(const char *symbol_name
,
772 const char *module_name
) {
773 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByName
,
774 (const char *, const char *), symbol_name
, module_name
);
777 TargetSP
target_sp(GetSP());
778 if (target_sp
.get()) {
779 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
781 const bool internal
= false;
782 const bool hardware
= false;
783 const LazyBool skip_prologue
= eLazyBoolCalculate
;
784 const lldb::addr_t offset
= 0;
785 if (module_name
&& module_name
[0]) {
786 FileSpecList module_spec_list
;
787 module_spec_list
.Append(FileSpec(module_name
));
788 sb_bp
= target_sp
->CreateBreakpoint(
789 &module_spec_list
, nullptr, symbol_name
, eFunctionNameTypeAuto
,
790 eLanguageTypeUnknown
, offset
, skip_prologue
, internal
, hardware
);
792 sb_bp
= target_sp
->CreateBreakpoint(
793 nullptr, nullptr, symbol_name
, eFunctionNameTypeAuto
,
794 eLanguageTypeUnknown
, offset
, skip_prologue
, internal
, hardware
);
798 return LLDB_RECORD_RESULT(sb_bp
);
802 SBTarget::BreakpointCreateByName(const char *symbol_name
,
803 const SBFileSpecList
&module_list
,
804 const SBFileSpecList
&comp_unit_list
) {
805 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByName
,
806 (const char *, const lldb::SBFileSpecList
&,
807 const lldb::SBFileSpecList
&),
808 symbol_name
, module_list
, comp_unit_list
);
810 lldb::FunctionNameType name_type_mask
= eFunctionNameTypeAuto
;
811 return LLDB_RECORD_RESULT(
812 BreakpointCreateByName(symbol_name
, name_type_mask
, eLanguageTypeUnknown
,
813 module_list
, comp_unit_list
));
816 lldb::SBBreakpoint
SBTarget::BreakpointCreateByName(
817 const char *symbol_name
, uint32_t name_type_mask
,
818 const SBFileSpecList
&module_list
, const SBFileSpecList
&comp_unit_list
) {
819 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByName
,
820 (const char *, uint32_t, const lldb::SBFileSpecList
&,
821 const lldb::SBFileSpecList
&),
822 symbol_name
, name_type_mask
, module_list
, comp_unit_list
);
824 return LLDB_RECORD_RESULT(
825 BreakpointCreateByName(symbol_name
, name_type_mask
, eLanguageTypeUnknown
,
826 module_list
, comp_unit_list
));
829 lldb::SBBreakpoint
SBTarget::BreakpointCreateByName(
830 const char *symbol_name
, uint32_t name_type_mask
,
831 LanguageType symbol_language
, const SBFileSpecList
&module_list
,
832 const SBFileSpecList
&comp_unit_list
) {
833 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByName
,
834 (const char *, uint32_t, lldb::LanguageType
,
835 const lldb::SBFileSpecList
&,
836 const lldb::SBFileSpecList
&),
837 symbol_name
, name_type_mask
, symbol_language
, module_list
,
841 TargetSP
target_sp(GetSP());
842 if (target_sp
&& symbol_name
&& symbol_name
[0]) {
843 const bool internal
= false;
844 const bool hardware
= false;
845 const LazyBool skip_prologue
= eLazyBoolCalculate
;
846 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
847 FunctionNameType mask
= static_cast<FunctionNameType
>(name_type_mask
);
848 sb_bp
= target_sp
->CreateBreakpoint(module_list
.get(), comp_unit_list
.get(),
849 symbol_name
, mask
, symbol_language
, 0,
850 skip_prologue
, internal
, hardware
);
853 return LLDB_RECORD_RESULT(sb_bp
);
856 lldb::SBBreakpoint
SBTarget::BreakpointCreateByNames(
857 const char *symbol_names
[], uint32_t num_names
, uint32_t name_type_mask
,
858 const SBFileSpecList
&module_list
, const SBFileSpecList
&comp_unit_list
) {
860 lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByNames
,
861 (const char **, uint32_t, uint32_t, const lldb::SBFileSpecList
&,
862 const lldb::SBFileSpecList
&),
863 symbol_names
, num_names
, name_type_mask
, module_list
, comp_unit_list
);
865 return LLDB_RECORD_RESULT(BreakpointCreateByNames(
866 symbol_names
, num_names
, name_type_mask
, eLanguageTypeUnknown
,
867 module_list
, comp_unit_list
));
870 lldb::SBBreakpoint
SBTarget::BreakpointCreateByNames(
871 const char *symbol_names
[], uint32_t num_names
, uint32_t name_type_mask
,
872 LanguageType symbol_language
, const SBFileSpecList
&module_list
,
873 const SBFileSpecList
&comp_unit_list
) {
874 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByNames
,
875 (const char **, uint32_t, uint32_t, lldb::LanguageType
,
876 const lldb::SBFileSpecList
&,
877 const lldb::SBFileSpecList
&),
878 symbol_names
, num_names
, name_type_mask
, symbol_language
,
879 module_list
, comp_unit_list
);
881 return LLDB_RECORD_RESULT(BreakpointCreateByNames(
882 symbol_names
, num_names
, name_type_mask
, eLanguageTypeUnknown
, 0,
883 module_list
, comp_unit_list
));
886 lldb::SBBreakpoint
SBTarget::BreakpointCreateByNames(
887 const char *symbol_names
[], uint32_t num_names
, uint32_t name_type_mask
,
888 LanguageType symbol_language
, lldb::addr_t offset
,
889 const SBFileSpecList
&module_list
, const SBFileSpecList
&comp_unit_list
) {
890 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByNames
,
891 (const char **, uint32_t, uint32_t, lldb::LanguageType
,
892 lldb::addr_t
, const lldb::SBFileSpecList
&,
893 const lldb::SBFileSpecList
&),
894 symbol_names
, num_names
, name_type_mask
, symbol_language
,
895 offset
, module_list
, comp_unit_list
);
898 TargetSP
target_sp(GetSP());
899 if (target_sp
&& num_names
> 0) {
900 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
901 const bool internal
= false;
902 const bool hardware
= false;
903 FunctionNameType mask
= static_cast<FunctionNameType
>(name_type_mask
);
904 const LazyBool skip_prologue
= eLazyBoolCalculate
;
905 sb_bp
= target_sp
->CreateBreakpoint(
906 module_list
.get(), comp_unit_list
.get(), symbol_names
, num_names
, mask
,
907 symbol_language
, offset
, skip_prologue
, internal
, hardware
);
910 return LLDB_RECORD_RESULT(sb_bp
);
913 SBBreakpoint
SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex
,
914 const char *module_name
) {
915 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByRegex
,
916 (const char *, const char *), symbol_name_regex
,
919 SBFileSpecList module_spec_list
;
920 SBFileSpecList comp_unit_list
;
921 if (module_name
&& module_name
[0]) {
922 module_spec_list
.Append(FileSpec(module_name
));
924 return LLDB_RECORD_RESULT(
925 BreakpointCreateByRegex(symbol_name_regex
, eLanguageTypeUnknown
,
926 module_spec_list
, comp_unit_list
));
930 SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex
,
931 const SBFileSpecList
&module_list
,
932 const SBFileSpecList
&comp_unit_list
) {
933 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByRegex
,
934 (const char *, const lldb::SBFileSpecList
&,
935 const lldb::SBFileSpecList
&),
936 symbol_name_regex
, module_list
, comp_unit_list
);
938 return LLDB_RECORD_RESULT(BreakpointCreateByRegex(
939 symbol_name_regex
, eLanguageTypeUnknown
, module_list
, comp_unit_list
));
942 lldb::SBBreakpoint
SBTarget::BreakpointCreateByRegex(
943 const char *symbol_name_regex
, LanguageType symbol_language
,
944 const SBFileSpecList
&module_list
, const SBFileSpecList
&comp_unit_list
) {
946 lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByRegex
,
947 (const char *, lldb::LanguageType
, const lldb::SBFileSpecList
&,
948 const lldb::SBFileSpecList
&),
949 symbol_name_regex
, symbol_language
, module_list
, comp_unit_list
);
953 TargetSP
target_sp(GetSP());
954 if (target_sp
&& symbol_name_regex
&& symbol_name_regex
[0]) {
955 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
956 RegularExpression
regexp((llvm::StringRef(symbol_name_regex
)));
957 const bool internal
= false;
958 const bool hardware
= false;
959 const LazyBool skip_prologue
= eLazyBoolCalculate
;
961 sb_bp
= target_sp
->CreateFuncRegexBreakpoint(
962 module_list
.get(), comp_unit_list
.get(), std::move(regexp
),
963 symbol_language
, skip_prologue
, internal
, hardware
);
966 return LLDB_RECORD_RESULT(sb_bp
);
969 SBBreakpoint
SBTarget::BreakpointCreateByAddress(addr_t address
) {
970 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByAddress
,
971 (lldb::addr_t
), address
);
974 TargetSP
target_sp(GetSP());
976 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
977 const bool hardware
= false;
978 sb_bp
= target_sp
->CreateBreakpoint(address
, false, hardware
);
981 return LLDB_RECORD_RESULT(sb_bp
);
984 SBBreakpoint
SBTarget::BreakpointCreateBySBAddress(SBAddress
&sb_address
) {
985 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateBySBAddress
,
986 (lldb::SBAddress
&), sb_address
);
989 TargetSP
target_sp(GetSP());
990 if (!sb_address
.IsValid()) {
991 return LLDB_RECORD_RESULT(sb_bp
);
995 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
996 const bool hardware
= false;
997 sb_bp
= target_sp
->CreateBreakpoint(sb_address
.ref(), false, hardware
);
1000 return LLDB_RECORD_RESULT(sb_bp
);
1004 SBTarget::BreakpointCreateBySourceRegex(const char *source_regex
,
1005 const lldb::SBFileSpec
&source_file
,
1006 const char *module_name
) {
1007 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
,
1008 BreakpointCreateBySourceRegex
,
1009 (const char *, const lldb::SBFileSpec
&, const char *),
1010 source_regex
, source_file
, module_name
);
1012 SBFileSpecList module_spec_list
;
1014 if (module_name
&& module_name
[0]) {
1015 module_spec_list
.Append(FileSpec(module_name
));
1018 SBFileSpecList source_file_list
;
1019 if (source_file
.IsValid()) {
1020 source_file_list
.Append(source_file
);
1023 return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex(
1024 source_regex
, module_spec_list
, source_file_list
));
1027 lldb::SBBreakpoint
SBTarget::BreakpointCreateBySourceRegex(
1028 const char *source_regex
, const SBFileSpecList
&module_list
,
1029 const lldb::SBFileSpecList
&source_file_list
) {
1030 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
,
1031 BreakpointCreateBySourceRegex
,
1032 (const char *, const lldb::SBFileSpecList
&,
1033 const lldb::SBFileSpecList
&),
1034 source_regex
, module_list
, source_file_list
);
1036 return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex(
1037 source_regex
, module_list
, source_file_list
, SBStringList()));
1040 lldb::SBBreakpoint
SBTarget::BreakpointCreateBySourceRegex(
1041 const char *source_regex
, const SBFileSpecList
&module_list
,
1042 const lldb::SBFileSpecList
&source_file_list
,
1043 const SBStringList
&func_names
) {
1044 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
,
1045 BreakpointCreateBySourceRegex
,
1046 (const char *, const lldb::SBFileSpecList
&,
1047 const lldb::SBFileSpecList
&, const lldb::SBStringList
&),
1048 source_regex
, module_list
, source_file_list
, func_names
);
1051 TargetSP
target_sp(GetSP());
1052 if (target_sp
&& source_regex
&& source_regex
[0]) {
1053 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1054 const bool hardware
= false;
1055 const LazyBool move_to_nearest_code
= eLazyBoolCalculate
;
1056 RegularExpression
regexp((llvm::StringRef(source_regex
)));
1057 std::unordered_set
<std::string
> func_names_set
;
1058 for (size_t i
= 0; i
< func_names
.GetSize(); i
++) {
1059 func_names_set
.insert(func_names
.GetStringAtIndex(i
));
1062 sb_bp
= target_sp
->CreateSourceRegexBreakpoint(
1063 module_list
.get(), source_file_list
.get(), func_names_set
,
1064 std::move(regexp
), false, hardware
, move_to_nearest_code
);
1067 return LLDB_RECORD_RESULT(sb_bp
);
1071 SBTarget::BreakpointCreateForException(lldb::LanguageType language
,
1072 bool catch_bp
, bool throw_bp
) {
1073 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateForException
,
1074 (lldb::LanguageType
, bool, bool), language
, catch_bp
,
1078 TargetSP
target_sp(GetSP());
1080 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1081 const bool hardware
= false;
1082 sb_bp
= target_sp
->CreateExceptionBreakpoint(language
, catch_bp
, throw_bp
,
1086 return LLDB_RECORD_RESULT(sb_bp
);
1089 lldb::SBBreakpoint
SBTarget::BreakpointCreateFromScript(
1090 const char *class_name
, SBStructuredData
&extra_args
,
1091 const SBFileSpecList
&module_list
, const SBFileSpecList
&file_list
,
1092 bool request_hardware
) {
1094 lldb::SBBreakpoint
, SBTarget
, BreakpointCreateFromScript
,
1095 (const char *, lldb::SBStructuredData
&, const lldb::SBFileSpecList
&,
1096 const lldb::SBFileSpecList
&, bool),
1097 class_name
, extra_args
, module_list
, file_list
, request_hardware
);
1100 TargetSP
target_sp(GetSP());
1102 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1105 StructuredData::ObjectSP obj_sp
= extra_args
.m_impl_up
->GetObjectSP();
1107 target_sp
->CreateScriptedBreakpoint(class_name
,
1110 false, /* internal */
1116 return LLDB_RECORD_RESULT(sb_bp
);
1119 uint32_t SBTarget::GetNumBreakpoints() const {
1120 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget
, GetNumBreakpoints
);
1122 TargetSP
target_sp(GetSP());
1124 // The breakpoint list is thread safe, no need to lock
1125 return target_sp
->GetBreakpointList().GetSize();
1130 SBBreakpoint
SBTarget::GetBreakpointAtIndex(uint32_t idx
) const {
1131 LLDB_RECORD_METHOD_CONST(lldb::SBBreakpoint
, SBTarget
, GetBreakpointAtIndex
,
1134 SBBreakpoint sb_breakpoint
;
1135 TargetSP
target_sp(GetSP());
1137 // The breakpoint list is thread safe, no need to lock
1138 sb_breakpoint
= target_sp
->GetBreakpointList().GetBreakpointAtIndex(idx
);
1140 return LLDB_RECORD_RESULT(sb_breakpoint
);
1143 bool SBTarget::BreakpointDelete(break_id_t bp_id
) {
1144 LLDB_RECORD_METHOD(bool, SBTarget
, BreakpointDelete
, (lldb::break_id_t
),
1147 bool result
= false;
1148 TargetSP
target_sp(GetSP());
1150 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1151 result
= target_sp
->RemoveBreakpointByID(bp_id
);
1157 SBBreakpoint
SBTarget::FindBreakpointByID(break_id_t bp_id
) {
1158 LLDB_RECORD_METHOD(lldb::SBBreakpoint
, SBTarget
, FindBreakpointByID
,
1159 (lldb::break_id_t
), bp_id
);
1161 SBBreakpoint sb_breakpoint
;
1162 TargetSP
target_sp(GetSP());
1163 if (target_sp
&& bp_id
!= LLDB_INVALID_BREAK_ID
) {
1164 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1165 sb_breakpoint
= target_sp
->GetBreakpointByID(bp_id
);
1168 return LLDB_RECORD_RESULT(sb_breakpoint
);
1171 bool SBTarget::FindBreakpointsByName(const char *name
,
1172 SBBreakpointList
&bkpts
) {
1173 LLDB_RECORD_METHOD(bool, SBTarget
, FindBreakpointsByName
,
1174 (const char *, lldb::SBBreakpointList
&), name
, bkpts
);
1176 TargetSP
target_sp(GetSP());
1178 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1179 llvm::Expected
<std::vector
<BreakpointSP
>> expected_vector
=
1180 target_sp
->GetBreakpointList().FindBreakpointsByName(name
);
1181 if (!expected_vector
) {
1182 LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS
),
1183 "invalid breakpoint name: {}",
1184 llvm::toString(expected_vector
.takeError()));
1187 for (BreakpointSP bkpt_sp
: *expected_vector
) {
1188 bkpts
.AppendByID(bkpt_sp
->GetID());
1194 void SBTarget::GetBreakpointNames(SBStringList
&names
) {
1195 LLDB_RECORD_METHOD(void, SBTarget
, GetBreakpointNames
, (lldb::SBStringList
&),
1200 TargetSP
target_sp(GetSP());
1202 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1204 std::vector
<std::string
> name_vec
;
1205 target_sp
->GetBreakpointNames(name_vec
);
1206 for (auto name
: name_vec
)
1207 names
.AppendString(name
.c_str());
1211 void SBTarget::DeleteBreakpointName(const char *name
) {
1212 LLDB_RECORD_METHOD(void, SBTarget
, DeleteBreakpointName
, (const char *),
1215 TargetSP
target_sp(GetSP());
1217 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1218 target_sp
->DeleteBreakpointName(ConstString(name
));
1222 bool SBTarget::EnableAllBreakpoints() {
1223 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget
, EnableAllBreakpoints
);
1225 TargetSP
target_sp(GetSP());
1227 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1228 target_sp
->EnableAllowedBreakpoints();
1234 bool SBTarget::DisableAllBreakpoints() {
1235 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget
, DisableAllBreakpoints
);
1237 TargetSP
target_sp(GetSP());
1239 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1240 target_sp
->DisableAllowedBreakpoints();
1246 bool SBTarget::DeleteAllBreakpoints() {
1247 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget
, DeleteAllBreakpoints
);
1249 TargetSP
target_sp(GetSP());
1251 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1252 target_sp
->RemoveAllowedBreakpoints();
1258 lldb::SBError
SBTarget::BreakpointsCreateFromFile(SBFileSpec
&source_file
,
1259 SBBreakpointList
&new_bps
) {
1260 LLDB_RECORD_METHOD(lldb::SBError
, SBTarget
, BreakpointsCreateFromFile
,
1261 (lldb::SBFileSpec
&, lldb::SBBreakpointList
&),
1262 source_file
, new_bps
);
1264 SBStringList empty_name_list
;
1265 return LLDB_RECORD_RESULT(
1266 BreakpointsCreateFromFile(source_file
, empty_name_list
, new_bps
));
1269 lldb::SBError
SBTarget::BreakpointsCreateFromFile(SBFileSpec
&source_file
,
1270 SBStringList
&matching_names
,
1271 SBBreakpointList
&new_bps
) {
1273 lldb::SBError
, SBTarget
, BreakpointsCreateFromFile
,
1274 (lldb::SBFileSpec
&, lldb::SBStringList
&, lldb::SBBreakpointList
&),
1275 source_file
, matching_names
, new_bps
);
1278 TargetSP
target_sp(GetSP());
1280 sberr
.SetErrorString(
1281 "BreakpointCreateFromFile called with invalid target.");
1282 return LLDB_RECORD_RESULT(sberr
);
1284 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1286 BreakpointIDList bp_ids
;
1288 std::vector
<std::string
> name_vector
;
1289 size_t num_names
= matching_names
.GetSize();
1290 for (size_t i
= 0; i
< num_names
; i
++)
1291 name_vector
.push_back(matching_names
.GetStringAtIndex(i
));
1293 sberr
.ref() = target_sp
->CreateBreakpointsFromFile(source_file
.ref(),
1294 name_vector
, bp_ids
);
1296 return LLDB_RECORD_RESULT(sberr
);
1298 size_t num_bkpts
= bp_ids
.GetSize();
1299 for (size_t i
= 0; i
< num_bkpts
; i
++) {
1300 BreakpointID bp_id
= bp_ids
.GetBreakpointIDAtIndex(i
);
1301 new_bps
.AppendByID(bp_id
.GetBreakpointID());
1303 return LLDB_RECORD_RESULT(sberr
);
1306 lldb::SBError
SBTarget::BreakpointsWriteToFile(SBFileSpec
&dest_file
) {
1307 LLDB_RECORD_METHOD(lldb::SBError
, SBTarget
, BreakpointsWriteToFile
,
1308 (lldb::SBFileSpec
&), dest_file
);
1311 TargetSP
target_sp(GetSP());
1313 sberr
.SetErrorString("BreakpointWriteToFile called with invalid target.");
1314 return LLDB_RECORD_RESULT(sberr
);
1316 SBBreakpointList
bkpt_list(*this);
1317 return LLDB_RECORD_RESULT(BreakpointsWriteToFile(dest_file
, bkpt_list
));
1320 lldb::SBError
SBTarget::BreakpointsWriteToFile(SBFileSpec
&dest_file
,
1321 SBBreakpointList
&bkpt_list
,
1323 LLDB_RECORD_METHOD(lldb::SBError
, SBTarget
, BreakpointsWriteToFile
,
1324 (lldb::SBFileSpec
&, lldb::SBBreakpointList
&, bool),
1325 dest_file
, bkpt_list
, append
);
1328 TargetSP
target_sp(GetSP());
1330 sberr
.SetErrorString("BreakpointWriteToFile called with invalid target.");
1331 return LLDB_RECORD_RESULT(sberr
);
1334 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1335 BreakpointIDList bp_id_list
;
1336 bkpt_list
.CopyToBreakpointIDList(bp_id_list
);
1337 sberr
.ref() = target_sp
->SerializeBreakpointsToFile(dest_file
.ref(),
1338 bp_id_list
, append
);
1339 return LLDB_RECORD_RESULT(sberr
);
1342 uint32_t SBTarget::GetNumWatchpoints() const {
1343 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget
, GetNumWatchpoints
);
1345 TargetSP
target_sp(GetSP());
1347 // The watchpoint list is thread safe, no need to lock
1348 return target_sp
->GetWatchpointList().GetSize();
1353 SBWatchpoint
SBTarget::GetWatchpointAtIndex(uint32_t idx
) const {
1354 LLDB_RECORD_METHOD_CONST(lldb::SBWatchpoint
, SBTarget
, GetWatchpointAtIndex
,
1357 SBWatchpoint sb_watchpoint
;
1358 TargetSP
target_sp(GetSP());
1360 // The watchpoint list is thread safe, no need to lock
1361 sb_watchpoint
.SetSP(target_sp
->GetWatchpointList().GetByIndex(idx
));
1363 return LLDB_RECORD_RESULT(sb_watchpoint
);
1366 bool SBTarget::DeleteWatchpoint(watch_id_t wp_id
) {
1367 LLDB_RECORD_METHOD(bool, SBTarget
, DeleteWatchpoint
, (lldb::watch_id_t
),
1371 bool result
= false;
1372 TargetSP
target_sp(GetSP());
1374 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1375 std::unique_lock
<std::recursive_mutex
> lock
;
1376 target_sp
->GetWatchpointList().GetListMutex(lock
);
1377 result
= target_sp
->RemoveWatchpointByID(wp_id
);
1383 SBWatchpoint
SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id
) {
1384 LLDB_RECORD_METHOD(lldb::SBWatchpoint
, SBTarget
, FindWatchpointByID
,
1385 (lldb::watch_id_t
), wp_id
);
1388 SBWatchpoint sb_watchpoint
;
1389 lldb::WatchpointSP watchpoint_sp
;
1390 TargetSP
target_sp(GetSP());
1391 if (target_sp
&& wp_id
!= LLDB_INVALID_WATCH_ID
) {
1392 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1393 std::unique_lock
<std::recursive_mutex
> lock
;
1394 target_sp
->GetWatchpointList().GetListMutex(lock
);
1395 watchpoint_sp
= target_sp
->GetWatchpointList().FindByID(wp_id
);
1396 sb_watchpoint
.SetSP(watchpoint_sp
);
1399 return LLDB_RECORD_RESULT(sb_watchpoint
);
1402 lldb::SBWatchpoint
SBTarget::WatchAddress(lldb::addr_t addr
, size_t size
,
1403 bool read
, bool write
,
1405 LLDB_RECORD_METHOD(lldb::SBWatchpoint
, SBTarget
, WatchAddress
,
1406 (lldb::addr_t
, size_t, bool, bool, lldb::SBError
&), addr
,
1407 size
, read
, write
, error
);
1409 SBWatchpoint sb_watchpoint
;
1410 lldb::WatchpointSP watchpoint_sp
;
1411 TargetSP
target_sp(GetSP());
1412 if (target_sp
&& (read
|| write
) && addr
!= LLDB_INVALID_ADDRESS
&&
1414 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1415 uint32_t watch_type
= 0;
1417 watch_type
|= LLDB_WATCH_TYPE_READ
;
1419 watch_type
|= LLDB_WATCH_TYPE_WRITE
;
1420 if (watch_type
== 0) {
1421 error
.SetErrorString(
1422 "Can't create a watchpoint that is neither read nor write.");
1423 return LLDB_RECORD_RESULT(sb_watchpoint
);
1426 // Target::CreateWatchpoint() is thread safe.
1428 // This API doesn't take in a type, so we can't figure out what it is.
1429 CompilerType
*type
= nullptr;
1431 target_sp
->CreateWatchpoint(addr
, size
, type
, watch_type
, cw_error
);
1432 error
.SetError(cw_error
);
1433 sb_watchpoint
.SetSP(watchpoint_sp
);
1436 return LLDB_RECORD_RESULT(sb_watchpoint
);
1439 bool SBTarget::EnableAllWatchpoints() {
1440 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget
, EnableAllWatchpoints
);
1442 TargetSP
target_sp(GetSP());
1444 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1445 std::unique_lock
<std::recursive_mutex
> lock
;
1446 target_sp
->GetWatchpointList().GetListMutex(lock
);
1447 target_sp
->EnableAllWatchpoints();
1453 bool SBTarget::DisableAllWatchpoints() {
1454 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget
, DisableAllWatchpoints
);
1456 TargetSP
target_sp(GetSP());
1458 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1459 std::unique_lock
<std::recursive_mutex
> lock
;
1460 target_sp
->GetWatchpointList().GetListMutex(lock
);
1461 target_sp
->DisableAllWatchpoints();
1467 SBValue
SBTarget::CreateValueFromAddress(const char *name
, SBAddress addr
,
1469 LLDB_RECORD_METHOD(lldb::SBValue
, SBTarget
, CreateValueFromAddress
,
1470 (const char *, lldb::SBAddress
, lldb::SBType
), name
, addr
,
1474 lldb::ValueObjectSP new_value_sp
;
1475 if (IsValid() && name
&& *name
&& addr
.IsValid() && type
.IsValid()) {
1476 lldb::addr_t
load_addr(addr
.GetLoadAddress(*this));
1477 ExecutionContext
exe_ctx(
1478 ExecutionContextRef(ExecutionContext(m_opaque_sp
.get(), false)));
1479 CompilerType
ast_type(type
.GetSP()->GetCompilerType(true));
1480 new_value_sp
= ValueObject::CreateValueObjectFromAddress(name
, load_addr
,
1483 sb_value
.SetSP(new_value_sp
);
1484 return LLDB_RECORD_RESULT(sb_value
);
1487 lldb::SBValue
SBTarget::CreateValueFromData(const char *name
, lldb::SBData data
,
1488 lldb::SBType type
) {
1489 LLDB_RECORD_METHOD(lldb::SBValue
, SBTarget
, CreateValueFromData
,
1490 (const char *, lldb::SBData
, lldb::SBType
), name
, data
,
1494 lldb::ValueObjectSP new_value_sp
;
1495 if (IsValid() && name
&& *name
&& data
.IsValid() && type
.IsValid()) {
1496 DataExtractorSP
extractor(*data
);
1497 ExecutionContext
exe_ctx(
1498 ExecutionContextRef(ExecutionContext(m_opaque_sp
.get(), false)));
1499 CompilerType
ast_type(type
.GetSP()->GetCompilerType(true));
1500 new_value_sp
= ValueObject::CreateValueObjectFromData(name
, *extractor
,
1503 sb_value
.SetSP(new_value_sp
);
1504 return LLDB_RECORD_RESULT(sb_value
);
1507 lldb::SBValue
SBTarget::CreateValueFromExpression(const char *name
,
1509 LLDB_RECORD_METHOD(lldb::SBValue
, SBTarget
, CreateValueFromExpression
,
1510 (const char *, const char *), name
, expr
);
1513 lldb::ValueObjectSP new_value_sp
;
1514 if (IsValid() && name
&& *name
&& expr
&& *expr
) {
1515 ExecutionContext
exe_ctx(
1516 ExecutionContextRef(ExecutionContext(m_opaque_sp
.get(), false)));
1518 ValueObject::CreateValueObjectFromExpression(name
, expr
, exe_ctx
);
1520 sb_value
.SetSP(new_value_sp
);
1521 return LLDB_RECORD_RESULT(sb_value
);
1524 bool SBTarget::DeleteAllWatchpoints() {
1525 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget
, DeleteAllWatchpoints
);
1527 TargetSP
target_sp(GetSP());
1529 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
1530 std::unique_lock
<std::recursive_mutex
> lock
;
1531 target_sp
->GetWatchpointList().GetListMutex(lock
);
1532 target_sp
->RemoveAllWatchpoints();
1538 void SBTarget::AppendImageSearchPath(const char *from
, const char *to
,
1539 lldb::SBError
&error
) {
1540 LLDB_RECORD_METHOD(void, SBTarget
, AppendImageSearchPath
,
1541 (const char *, const char *, lldb::SBError
&), from
, to
,
1544 TargetSP
target_sp(GetSP());
1546 return error
.SetErrorString("invalid target");
1548 const ConstString
csFrom(from
), csTo(to
);
1550 return error
.SetErrorString("<from> path can't be empty");
1552 return error
.SetErrorString("<to> path can't be empty");
1554 target_sp
->GetImageSearchPathList().Append(csFrom
, csTo
, true);
1557 lldb::SBModule
SBTarget::AddModule(const char *path
, const char *triple
,
1558 const char *uuid_cstr
) {
1559 LLDB_RECORD_METHOD(lldb::SBModule
, SBTarget
, AddModule
,
1560 (const char *, const char *, const char *), path
, triple
,
1563 return LLDB_RECORD_RESULT(AddModule(path
, triple
, uuid_cstr
, nullptr));
1566 lldb::SBModule
SBTarget::AddModule(const char *path
, const char *triple
,
1567 const char *uuid_cstr
, const char *symfile
) {
1568 LLDB_RECORD_METHOD(lldb::SBModule
, SBTarget
, AddModule
,
1569 (const char *, const char *, const char *, const char *),
1570 path
, triple
, uuid_cstr
, symfile
);
1572 lldb::SBModule sb_module
;
1573 TargetSP
target_sp(GetSP());
1575 ModuleSpec module_spec
;
1577 module_spec
.GetFileSpec().SetFile(path
, FileSpec::Style::native
);
1580 module_spec
.GetUUID().SetFromStringRef(uuid_cstr
);
1583 module_spec
.GetArchitecture() = Platform::GetAugmentedArchSpec(
1584 target_sp
->GetPlatform().get(), triple
);
1586 module_spec
.GetArchitecture() = target_sp
->GetArchitecture();
1589 module_spec
.GetSymbolFileSpec().SetFile(symfile
, FileSpec::Style::native
);
1591 sb_module
.SetSP(target_sp
->GetOrCreateModule(module_spec
, true /* notify */));
1593 return LLDB_RECORD_RESULT(sb_module
);
1596 lldb::SBModule
SBTarget::AddModule(const SBModuleSpec
&module_spec
) {
1597 LLDB_RECORD_METHOD(lldb::SBModule
, SBTarget
, AddModule
,
1598 (const lldb::SBModuleSpec
&), module_spec
);
1600 lldb::SBModule sb_module
;
1601 TargetSP
target_sp(GetSP());
1603 sb_module
.SetSP(target_sp
->GetOrCreateModule(*module_spec
.m_opaque_up
,
1604 true /* notify */));
1605 return LLDB_RECORD_RESULT(sb_module
);
1608 bool SBTarget::AddModule(lldb::SBModule
&module
) {
1609 LLDB_RECORD_METHOD(bool, SBTarget
, AddModule
, (lldb::SBModule
&), module
);
1611 TargetSP
target_sp(GetSP());
1613 target_sp
->GetImages().AppendIfNeeded(module
.GetSP());
1619 uint32_t SBTarget::GetNumModules() const {
1620 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget
, GetNumModules
);
1623 TargetSP
target_sp(GetSP());
1625 // The module list is thread safe, no need to lock
1626 num
= target_sp
->GetImages().GetSize();
1632 void SBTarget::Clear() {
1633 LLDB_RECORD_METHOD_NO_ARGS(void, SBTarget
, Clear
);
1635 m_opaque_sp
.reset();
1638 SBModule
SBTarget::FindModule(const SBFileSpec
&sb_file_spec
) {
1639 LLDB_RECORD_METHOD(lldb::SBModule
, SBTarget
, FindModule
,
1640 (const lldb::SBFileSpec
&), sb_file_spec
);
1643 TargetSP
target_sp(GetSP());
1644 if (target_sp
&& sb_file_spec
.IsValid()) {
1645 ModuleSpec
module_spec(*sb_file_spec
);
1646 // The module list is thread safe, no need to lock
1647 sb_module
.SetSP(target_sp
->GetImages().FindFirstModule(module_spec
));
1649 return LLDB_RECORD_RESULT(sb_module
);
1652 SBSymbolContextList
SBTarget::FindCompileUnits(const SBFileSpec
&sb_file_spec
) {
1653 LLDB_RECORD_METHOD(lldb::SBSymbolContextList
, SBTarget
, FindCompileUnits
,
1654 (const lldb::SBFileSpec
&), sb_file_spec
);
1656 SBSymbolContextList sb_sc_list
;
1657 const TargetSP
target_sp(GetSP());
1658 if (target_sp
&& sb_file_spec
.IsValid())
1659 target_sp
->GetImages().FindCompileUnits(*sb_file_spec
, *sb_sc_list
);
1660 return LLDB_RECORD_RESULT(sb_sc_list
);
1663 lldb::ByteOrder
SBTarget::GetByteOrder() {
1664 LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder
, SBTarget
, GetByteOrder
);
1666 TargetSP
target_sp(GetSP());
1668 return target_sp
->GetArchitecture().GetByteOrder();
1669 return eByteOrderInvalid
;
1672 const char *SBTarget::GetTriple() {
1673 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTarget
, GetTriple
);
1675 TargetSP
target_sp(GetSP());
1677 std::string
triple(target_sp
->GetArchitecture().GetTriple().str());
1678 // Unique the string so we don't run into ownership issues since the const
1679 // strings put the string into the string pool once and the strings never
1681 ConstString
const_triple(triple
.c_str());
1682 return const_triple
.GetCString();
1687 uint32_t SBTarget::GetDataByteSize() {
1688 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget
, GetDataByteSize
);
1690 TargetSP
target_sp(GetSP());
1692 return target_sp
->GetArchitecture().GetDataByteSize();
1697 uint32_t SBTarget::GetCodeByteSize() {
1698 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget
, GetCodeByteSize
);
1700 TargetSP
target_sp(GetSP());
1702 return target_sp
->GetArchitecture().GetCodeByteSize();
1707 uint32_t SBTarget::GetAddressByteSize() {
1708 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget
, GetAddressByteSize
);
1710 TargetSP
target_sp(GetSP());
1712 return target_sp
->GetArchitecture().GetAddressByteSize();
1713 return sizeof(void *);
1716 SBModule
SBTarget::GetModuleAtIndex(uint32_t idx
) {
1717 LLDB_RECORD_METHOD(lldb::SBModule
, SBTarget
, GetModuleAtIndex
, (uint32_t),
1722 TargetSP
target_sp(GetSP());
1724 // The module list is thread safe, no need to lock
1725 module_sp
= target_sp
->GetImages().GetModuleAtIndex(idx
);
1726 sb_module
.SetSP(module_sp
);
1729 return LLDB_RECORD_RESULT(sb_module
);
1732 bool SBTarget::RemoveModule(lldb::SBModule module
) {
1733 LLDB_RECORD_METHOD(bool, SBTarget
, RemoveModule
, (lldb::SBModule
), module
);
1735 TargetSP
target_sp(GetSP());
1737 return target_sp
->GetImages().Remove(module
.GetSP());
1741 SBBroadcaster
SBTarget::GetBroadcaster() const {
1742 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster
, SBTarget
,
1746 TargetSP
target_sp(GetSP());
1747 SBBroadcaster
broadcaster(target_sp
.get(), false);
1750 return LLDB_RECORD_RESULT(broadcaster
);
1753 bool SBTarget::GetDescription(SBStream
&description
,
1754 lldb::DescriptionLevel description_level
) {
1755 LLDB_RECORD_METHOD(bool, SBTarget
, GetDescription
,
1756 (lldb::SBStream
&, lldb::DescriptionLevel
), description
,
1759 Stream
&strm
= description
.ref();
1761 TargetSP
target_sp(GetSP());
1763 target_sp
->Dump(&strm
, description_level
);
1765 strm
.PutCString("No value");
1770 lldb::SBSymbolContextList
SBTarget::FindFunctions(const char *name
,
1771 uint32_t name_type_mask
) {
1772 LLDB_RECORD_METHOD(lldb::SBSymbolContextList
, SBTarget
, FindFunctions
,
1773 (const char *, uint32_t), name
, name_type_mask
);
1775 lldb::SBSymbolContextList sb_sc_list
;
1776 if (!name
| !name
[0])
1777 return LLDB_RECORD_RESULT(sb_sc_list
);
1779 TargetSP
target_sp(GetSP());
1781 return LLDB_RECORD_RESULT(sb_sc_list
);
1783 const bool symbols_ok
= true;
1784 const bool inlines_ok
= true;
1785 FunctionNameType mask
= static_cast<FunctionNameType
>(name_type_mask
);
1786 target_sp
->GetImages().FindFunctions(ConstString(name
), mask
, symbols_ok
,
1787 inlines_ok
, *sb_sc_list
);
1788 return LLDB_RECORD_RESULT(sb_sc_list
);
1791 lldb::SBSymbolContextList
SBTarget::FindGlobalFunctions(const char *name
,
1792 uint32_t max_matches
,
1793 MatchType matchtype
) {
1794 LLDB_RECORD_METHOD(lldb::SBSymbolContextList
, SBTarget
, FindGlobalFunctions
,
1795 (const char *, uint32_t, lldb::MatchType
), name
,
1796 max_matches
, matchtype
);
1798 lldb::SBSymbolContextList sb_sc_list
;
1799 if (name
&& name
[0]) {
1800 llvm::StringRef
name_ref(name
);
1801 TargetSP
target_sp(GetSP());
1803 std::string regexstr
;
1804 switch (matchtype
) {
1805 case eMatchTypeRegex
:
1806 target_sp
->GetImages().FindFunctions(RegularExpression(name_ref
), true,
1809 case eMatchTypeStartsWith
:
1810 regexstr
= llvm::Regex::escape(name
) + ".*";
1811 target_sp
->GetImages().FindFunctions(RegularExpression(regexstr
), true,
1815 target_sp
->GetImages().FindFunctions(
1816 ConstString(name
), eFunctionNameTypeAny
, true, true, *sb_sc_list
);
1821 return LLDB_RECORD_RESULT(sb_sc_list
);
1824 lldb::SBType
SBTarget::FindFirstType(const char *typename_cstr
) {
1825 LLDB_RECORD_METHOD(lldb::SBType
, SBTarget
, FindFirstType
, (const char *),
1828 TargetSP
target_sp(GetSP());
1829 if (typename_cstr
&& typename_cstr
[0] && target_sp
) {
1830 ConstString
const_typename(typename_cstr
);
1832 const bool exact_match
= false;
1834 const ModuleList
&module_list
= target_sp
->GetImages();
1835 size_t count
= module_list
.GetSize();
1836 for (size_t idx
= 0; idx
< count
; idx
++) {
1837 ModuleSP
module_sp(module_list
.GetModuleAtIndex(idx
));
1840 module_sp
->FindFirstType(sc
, const_typename
, exact_match
));
1842 return LLDB_RECORD_RESULT(SBType(type_sp
));
1846 // Didn't find the type in the symbols; Try the loaded language runtimes
1847 if (auto process_sp
= target_sp
->GetProcessSP()) {
1848 for (auto *runtime
: process_sp
->GetLanguageRuntimes()) {
1849 if (auto vendor
= runtime
->GetDeclVendor()) {
1850 auto types
= vendor
->FindTypes(const_typename
, /*max_matches*/ 1);
1852 return LLDB_RECORD_RESULT(SBType(types
.front()));
1857 // No matches, search for basic typename matches
1858 for (auto *type_system
: target_sp
->GetScratchTypeSystems())
1859 if (auto type
= type_system
->GetBuiltinTypeByName(const_typename
))
1860 return LLDB_RECORD_RESULT(SBType(type
));
1863 return LLDB_RECORD_RESULT(SBType());
1866 SBType
SBTarget::GetBasicType(lldb::BasicType type
) {
1867 LLDB_RECORD_METHOD(lldb::SBType
, SBTarget
, GetBasicType
, (lldb::BasicType
),
1870 TargetSP
target_sp(GetSP());
1872 for (auto *type_system
: target_sp
->GetScratchTypeSystems())
1873 if (auto compiler_type
= type_system
->GetBasicTypeFromAST(type
))
1874 return LLDB_RECORD_RESULT(SBType(compiler_type
));
1876 return LLDB_RECORD_RESULT(SBType());
1879 lldb::SBTypeList
SBTarget::FindTypes(const char *typename_cstr
) {
1880 LLDB_RECORD_METHOD(lldb::SBTypeList
, SBTarget
, FindTypes
, (const char *),
1883 SBTypeList sb_type_list
;
1884 TargetSP
target_sp(GetSP());
1885 if (typename_cstr
&& typename_cstr
[0] && target_sp
) {
1886 ModuleList
&images
= target_sp
->GetImages();
1887 ConstString
const_typename(typename_cstr
);
1888 bool exact_match
= false;
1890 llvm::DenseSet
<SymbolFile
*> searched_symbol_files
;
1891 images
.FindTypes(nullptr, const_typename
, exact_match
, UINT32_MAX
,
1892 searched_symbol_files
, type_list
);
1894 for (size_t idx
= 0; idx
< type_list
.GetSize(); idx
++) {
1895 TypeSP
type_sp(type_list
.GetTypeAtIndex(idx
));
1897 sb_type_list
.Append(SBType(type_sp
));
1900 // Try the loaded language runtimes
1901 if (auto process_sp
= target_sp
->GetProcessSP()) {
1902 for (auto *runtime
: process_sp
->GetLanguageRuntimes()) {
1903 if (auto *vendor
= runtime
->GetDeclVendor()) {
1905 vendor
->FindTypes(const_typename
, /*max_matches*/ UINT32_MAX
);
1906 for (auto type
: types
)
1907 sb_type_list
.Append(SBType(type
));
1912 if (sb_type_list
.GetSize() == 0) {
1913 // No matches, search for basic typename matches
1914 for (auto *type_system
: target_sp
->GetScratchTypeSystems())
1915 if (auto compiler_type
=
1916 type_system
->GetBuiltinTypeByName(const_typename
))
1917 sb_type_list
.Append(SBType(compiler_type
));
1920 return LLDB_RECORD_RESULT(sb_type_list
);
1923 SBValueList
SBTarget::FindGlobalVariables(const char *name
,
1924 uint32_t max_matches
) {
1925 LLDB_RECORD_METHOD(lldb::SBValueList
, SBTarget
, FindGlobalVariables
,
1926 (const char *, uint32_t), name
, max_matches
);
1928 SBValueList sb_value_list
;
1930 TargetSP
target_sp(GetSP());
1931 if (name
&& target_sp
) {
1932 VariableList variable_list
;
1933 target_sp
->GetImages().FindGlobalVariables(ConstString(name
), max_matches
,
1935 if (!variable_list
.Empty()) {
1936 ExecutionContextScope
*exe_scope
= target_sp
->GetProcessSP().get();
1937 if (exe_scope
== nullptr)
1938 exe_scope
= target_sp
.get();
1939 for (const VariableSP
&var_sp
: variable_list
) {
1940 lldb::ValueObjectSP
valobj_sp(
1941 ValueObjectVariable::Create(exe_scope
, var_sp
));
1943 sb_value_list
.Append(SBValue(valobj_sp
));
1948 return LLDB_RECORD_RESULT(sb_value_list
);
1951 SBValueList
SBTarget::FindGlobalVariables(const char *name
,
1952 uint32_t max_matches
,
1953 MatchType matchtype
) {
1954 LLDB_RECORD_METHOD(lldb::SBValueList
, SBTarget
, FindGlobalVariables
,
1955 (const char *, uint32_t, lldb::MatchType
), name
,
1956 max_matches
, matchtype
);
1958 SBValueList sb_value_list
;
1960 TargetSP
target_sp(GetSP());
1961 if (name
&& target_sp
) {
1962 llvm::StringRef
name_ref(name
);
1963 VariableList variable_list
;
1965 std::string regexstr
;
1966 switch (matchtype
) {
1967 case eMatchTypeNormal
:
1968 target_sp
->GetImages().FindGlobalVariables(ConstString(name
), max_matches
,
1971 case eMatchTypeRegex
:
1972 target_sp
->GetImages().FindGlobalVariables(RegularExpression(name_ref
),
1973 max_matches
, variable_list
);
1975 case eMatchTypeStartsWith
:
1976 regexstr
= llvm::Regex::escape(name
) + ".*";
1977 target_sp
->GetImages().FindGlobalVariables(RegularExpression(regexstr
),
1978 max_matches
, variable_list
);
1981 if (!variable_list
.Empty()) {
1982 ExecutionContextScope
*exe_scope
= target_sp
->GetProcessSP().get();
1983 if (exe_scope
== nullptr)
1984 exe_scope
= target_sp
.get();
1985 for (const VariableSP
&var_sp
: variable_list
) {
1986 lldb::ValueObjectSP
valobj_sp(
1987 ValueObjectVariable::Create(exe_scope
, var_sp
));
1989 sb_value_list
.Append(SBValue(valobj_sp
));
1994 return LLDB_RECORD_RESULT(sb_value_list
);
1997 lldb::SBValue
SBTarget::FindFirstGlobalVariable(const char *name
) {
1998 LLDB_RECORD_METHOD(lldb::SBValue
, SBTarget
, FindFirstGlobalVariable
,
1999 (const char *), name
);
2001 SBValueList
sb_value_list(FindGlobalVariables(name
, 1));
2002 if (sb_value_list
.IsValid() && sb_value_list
.GetSize() > 0)
2003 return LLDB_RECORD_RESULT(sb_value_list
.GetValueAtIndex(0));
2004 return LLDB_RECORD_RESULT(SBValue());
2007 SBSourceManager
SBTarget::GetSourceManager() {
2008 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager
, SBTarget
, GetSourceManager
);
2010 SBSourceManager
source_manager(*this);
2011 return LLDB_RECORD_RESULT(source_manager
);
2014 lldb::SBInstructionList
SBTarget::ReadInstructions(lldb::SBAddress base_addr
,
2016 LLDB_RECORD_METHOD(lldb::SBInstructionList
, SBTarget
, ReadInstructions
,
2017 (lldb::SBAddress
, uint32_t), base_addr
, count
);
2019 return LLDB_RECORD_RESULT(ReadInstructions(base_addr
, count
, nullptr));
2022 lldb::SBInstructionList
SBTarget::ReadInstructions(lldb::SBAddress base_addr
,
2024 const char *flavor_string
) {
2025 LLDB_RECORD_METHOD(lldb::SBInstructionList
, SBTarget
, ReadInstructions
,
2026 (lldb::SBAddress
, uint32_t, const char *), base_addr
,
2027 count
, flavor_string
);
2029 SBInstructionList sb_instructions
;
2031 TargetSP
target_sp(GetSP());
2033 Address
*addr_ptr
= base_addr
.get();
2036 DataBufferHeap
data(
2037 target_sp
->GetArchitecture().GetMaximumOpcodeByteSize() * count
, 0);
2038 bool prefer_file_cache
= false;
2039 lldb_private::Status error
;
2040 lldb::addr_t load_addr
= LLDB_INVALID_ADDRESS
;
2041 const size_t bytes_read
=
2042 target_sp
->ReadMemory(*addr_ptr
, prefer_file_cache
, data
.GetBytes(),
2043 data
.GetByteSize(), error
, &load_addr
);
2044 const bool data_from_file
= load_addr
== LLDB_INVALID_ADDRESS
;
2045 sb_instructions
.SetDisassembler(Disassembler::DisassembleBytes(
2046 target_sp
->GetArchitecture(), nullptr, flavor_string
, *addr_ptr
,
2047 data
.GetBytes(), bytes_read
, count
, data_from_file
));
2051 return LLDB_RECORD_RESULT(sb_instructions
);
2054 lldb::SBInstructionList
SBTarget::GetInstructions(lldb::SBAddress base_addr
,
2057 LLDB_RECORD_DUMMY(lldb::SBInstructionList
, SBTarget
, GetInstructions
,
2058 (lldb::SBAddress
, const void *, size_t), base_addr
, buf
,
2061 return GetInstructionsWithFlavor(base_addr
, nullptr, buf
, size
);
2064 lldb::SBInstructionList
2065 SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr
,
2066 const char *flavor_string
, const void *buf
,
2068 LLDB_RECORD_DUMMY(lldb::SBInstructionList
, SBTarget
,
2069 GetInstructionsWithFlavor
,
2070 (lldb::SBAddress
, const char *, const void *, size_t),
2071 base_addr
, flavor_string
, buf
, size
);
2073 SBInstructionList sb_instructions
;
2075 TargetSP
target_sp(GetSP());
2079 if (base_addr
.get())
2080 addr
= *base_addr
.get();
2082 const bool data_from_file
= true;
2084 sb_instructions
.SetDisassembler(Disassembler::DisassembleBytes(
2085 target_sp
->GetArchitecture(), nullptr, flavor_string
, addr
, buf
, size
,
2086 UINT32_MAX
, data_from_file
));
2089 return sb_instructions
;
2092 lldb::SBInstructionList
SBTarget::GetInstructions(lldb::addr_t base_addr
,
2095 LLDB_RECORD_DUMMY(lldb::SBInstructionList
, SBTarget
, GetInstructions
,
2096 (lldb::addr_t
, const void *, size_t), base_addr
, buf
, size
);
2098 return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr
), nullptr, buf
,
2102 lldb::SBInstructionList
2103 SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr
,
2104 const char *flavor_string
, const void *buf
,
2106 LLDB_RECORD_DUMMY(lldb::SBInstructionList
, SBTarget
,
2107 GetInstructionsWithFlavor
,
2108 (lldb::addr_t
, const char *, const void *, size_t),
2109 base_addr
, flavor_string
, buf
, size
);
2111 return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr
), flavor_string
,
2115 SBError
SBTarget::SetSectionLoadAddress(lldb::SBSection section
,
2116 lldb::addr_t section_base_addr
) {
2117 LLDB_RECORD_METHOD(lldb::SBError
, SBTarget
, SetSectionLoadAddress
,
2118 (lldb::SBSection
, lldb::addr_t
), section
,
2122 TargetSP
target_sp(GetSP());
2124 if (!section
.IsValid()) {
2125 sb_error
.SetErrorStringWithFormat("invalid section");
2127 SectionSP
section_sp(section
.GetSP());
2129 if (section_sp
->IsThreadSpecific()) {
2130 sb_error
.SetErrorString(
2131 "thread specific sections are not yet supported");
2133 ProcessSP
process_sp(target_sp
->GetProcessSP());
2134 if (target_sp
->SetSectionLoadAddress(section_sp
, section_base_addr
)) {
2135 ModuleSP
module_sp(section_sp
->GetModule());
2137 ModuleList module_list
;
2138 module_list
.Append(module_sp
);
2139 target_sp
->ModulesDidLoad(module_list
);
2141 // Flush info in the process (stack frames, etc)
2143 process_sp
->Flush();
2149 sb_error
.SetErrorString("invalid target");
2151 return LLDB_RECORD_RESULT(sb_error
);
2154 SBError
SBTarget::ClearSectionLoadAddress(lldb::SBSection section
) {
2155 LLDB_RECORD_METHOD(lldb::SBError
, SBTarget
, ClearSectionLoadAddress
,
2156 (lldb::SBSection
), section
);
2160 TargetSP
target_sp(GetSP());
2162 if (!section
.IsValid()) {
2163 sb_error
.SetErrorStringWithFormat("invalid section");
2165 SectionSP
section_sp(section
.GetSP());
2167 ProcessSP
process_sp(target_sp
->GetProcessSP());
2168 if (target_sp
->SetSectionUnloaded(section_sp
)) {
2169 ModuleSP
module_sp(section_sp
->GetModule());
2171 ModuleList module_list
;
2172 module_list
.Append(module_sp
);
2173 target_sp
->ModulesDidUnload(module_list
, false);
2175 // Flush info in the process (stack frames, etc)
2177 process_sp
->Flush();
2180 sb_error
.SetErrorStringWithFormat("invalid section");
2184 sb_error
.SetErrorStringWithFormat("invalid target");
2186 return LLDB_RECORD_RESULT(sb_error
);
2189 SBError
SBTarget::SetModuleLoadAddress(lldb::SBModule module
,
2190 int64_t slide_offset
) {
2191 LLDB_RECORD_METHOD(lldb::SBError
, SBTarget
, SetModuleLoadAddress
,
2192 (lldb::SBModule
, int64_t), module
, slide_offset
);
2196 TargetSP
target_sp(GetSP());
2198 ModuleSP
module_sp(module
.GetSP());
2200 bool changed
= false;
2201 if (module_sp
->SetLoadAddress(*target_sp
, slide_offset
, true, changed
)) {
2202 // The load was successful, make sure that at least some sections
2203 // changed before we notify that our module was loaded.
2205 ModuleList module_list
;
2206 module_list
.Append(module_sp
);
2207 target_sp
->ModulesDidLoad(module_list
);
2208 // Flush info in the process (stack frames, etc)
2209 ProcessSP
process_sp(target_sp
->GetProcessSP());
2211 process_sp
->Flush();
2215 sb_error
.SetErrorStringWithFormat("invalid module");
2219 sb_error
.SetErrorStringWithFormat("invalid target");
2221 return LLDB_RECORD_RESULT(sb_error
);
2224 SBError
SBTarget::ClearModuleLoadAddress(lldb::SBModule module
) {
2225 LLDB_RECORD_METHOD(lldb::SBError
, SBTarget
, ClearModuleLoadAddress
,
2226 (lldb::SBModule
), module
);
2230 char path
[PATH_MAX
];
2231 TargetSP
target_sp(GetSP());
2233 ModuleSP
module_sp(module
.GetSP());
2235 ObjectFile
*objfile
= module_sp
->GetObjectFile();
2237 SectionList
*section_list
= objfile
->GetSectionList();
2239 ProcessSP
process_sp(target_sp
->GetProcessSP());
2241 bool changed
= false;
2242 const size_t num_sections
= section_list
->GetSize();
2243 for (size_t sect_idx
= 0; sect_idx
< num_sections
; ++sect_idx
) {
2244 SectionSP
section_sp(section_list
->GetSectionAtIndex(sect_idx
));
2246 changed
|= target_sp
->SetSectionUnloaded(section_sp
);
2249 ModuleList module_list
;
2250 module_list
.Append(module_sp
);
2251 target_sp
->ModulesDidUnload(module_list
, false);
2252 // Flush info in the process (stack frames, etc)
2253 ProcessSP
process_sp(target_sp
->GetProcessSP());
2255 process_sp
->Flush();
2258 module_sp
->GetFileSpec().GetPath(path
, sizeof(path
));
2259 sb_error
.SetErrorStringWithFormat("no sections in object file '%s'",
2263 module_sp
->GetFileSpec().GetPath(path
, sizeof(path
));
2264 sb_error
.SetErrorStringWithFormat("no object file for module '%s'",
2268 sb_error
.SetErrorStringWithFormat("invalid module");
2271 sb_error
.SetErrorStringWithFormat("invalid target");
2273 return LLDB_RECORD_RESULT(sb_error
);
2276 lldb::SBSymbolContextList
SBTarget::FindSymbols(const char *name
,
2277 lldb::SymbolType symbol_type
) {
2278 LLDB_RECORD_METHOD(lldb::SBSymbolContextList
, SBTarget
, FindSymbols
,
2279 (const char *, lldb::SymbolType
), name
, symbol_type
);
2281 SBSymbolContextList sb_sc_list
;
2282 if (name
&& name
[0]) {
2283 TargetSP
target_sp(GetSP());
2285 target_sp
->GetImages().FindSymbolsWithNameAndType(
2286 ConstString(name
), symbol_type
, *sb_sc_list
);
2288 return LLDB_RECORD_RESULT(sb_sc_list
);
2291 lldb::SBValue
SBTarget::EvaluateExpression(const char *expr
) {
2292 LLDB_RECORD_METHOD(lldb::SBValue
, SBTarget
, EvaluateExpression
,
2293 (const char *), expr
);
2295 TargetSP
target_sp(GetSP());
2297 return LLDB_RECORD_RESULT(SBValue());
2299 SBExpressionOptions options
;
2300 lldb::DynamicValueType fetch_dynamic_value
=
2301 target_sp
->GetPreferDynamicValue();
2302 options
.SetFetchDynamicValue(fetch_dynamic_value
);
2303 options
.SetUnwindOnError(true);
2304 return LLDB_RECORD_RESULT(EvaluateExpression(expr
, options
));
2307 lldb::SBValue
SBTarget::EvaluateExpression(const char *expr
,
2308 const SBExpressionOptions
&options
) {
2309 LLDB_RECORD_METHOD(lldb::SBValue
, SBTarget
, EvaluateExpression
,
2310 (const char *, const lldb::SBExpressionOptions
&), expr
,
2313 Log
*expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS
));
2314 SBValue expr_result
;
2315 ValueObjectSP expr_value_sp
;
2316 TargetSP
target_sp(GetSP());
2317 StackFrame
*frame
= nullptr;
2319 if (expr
== nullptr || expr
[0] == '\0') {
2320 return LLDB_RECORD_RESULT(expr_result
);
2323 std::lock_guard
<std::recursive_mutex
> guard(target_sp
->GetAPIMutex());
2324 ExecutionContext
exe_ctx(m_opaque_sp
.get());
2327 frame
= exe_ctx
.GetFramePtr();
2328 Target
*target
= exe_ctx
.GetTargetPtr();
2331 #ifdef LLDB_CONFIGURATION_DEBUG
2332 StreamString frame_description
;
2334 frame
->DumpUsingSettingsFormat(&frame_description
);
2335 llvm::PrettyStackTraceFormat
stack_trace(
2336 "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = "
2338 expr
, options
.GetFetchDynamicValue(),
2339 frame_description
.GetString().str().c_str());
2341 target
->EvaluateExpression(expr
, frame
, expr_value_sp
, options
.ref());
2343 expr_result
.SetSP(expr_value_sp
, options
.GetFetchDynamicValue());
2347 "** [SBTarget::EvaluateExpression] Expression result is "
2348 "%s, summary %s **",
2349 expr_result
.GetValue(), expr_result
.GetSummary());
2350 return LLDB_RECORD_RESULT(expr_result
);
2353 lldb::addr_t
SBTarget::GetStackRedZoneSize() {
2354 LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t
, SBTarget
, GetStackRedZoneSize
);
2356 TargetSP
target_sp(GetSP());
2359 ProcessSP
process_sp(target_sp
->GetProcessSP());
2361 abi_sp
= process_sp
->GetABI();
2363 abi_sp
= ABI::FindPlugin(ProcessSP(), target_sp
->GetArchitecture());
2365 return abi_sp
->GetRedZoneSize();
2370 lldb::SBLaunchInfo
SBTarget::GetLaunchInfo() const {
2371 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo
, SBTarget
, GetLaunchInfo
);
2373 lldb::SBLaunchInfo
launch_info(nullptr);
2374 TargetSP
target_sp(GetSP());
2376 launch_info
.set_ref(m_opaque_sp
->GetProcessLaunchInfo());
2377 return LLDB_RECORD_RESULT(launch_info
);
2380 void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo
&launch_info
) {
2381 LLDB_RECORD_METHOD(void, SBTarget
, SetLaunchInfo
,
2382 (const lldb::SBLaunchInfo
&), launch_info
);
2384 TargetSP
target_sp(GetSP());
2386 m_opaque_sp
->SetProcessLaunchInfo(launch_info
.ref());
2389 namespace lldb_private
{
2393 void RegisterMethods
<SBTarget
>(Registry
&R
) {
2394 LLDB_REGISTER_CONSTRUCTOR(SBTarget
, ());
2395 LLDB_REGISTER_CONSTRUCTOR(SBTarget
, (const lldb::SBTarget
&));
2396 LLDB_REGISTER_CONSTRUCTOR(SBTarget
, (const lldb::TargetSP
&));
2397 LLDB_REGISTER_METHOD(const lldb::SBTarget
&,
2398 SBTarget
, operator=,(const lldb::SBTarget
&));
2399 LLDB_REGISTER_STATIC_METHOD(bool, SBTarget
, EventIsTargetEvent
,
2400 (const lldb::SBEvent
&));
2401 LLDB_REGISTER_STATIC_METHOD(lldb::SBTarget
, SBTarget
, GetTargetFromEvent
,
2402 (const lldb::SBEvent
&));
2403 LLDB_REGISTER_STATIC_METHOD(uint32_t, SBTarget
, GetNumModulesFromEvent
,
2404 (const lldb::SBEvent
&));
2405 LLDB_REGISTER_STATIC_METHOD(lldb::SBModule
, SBTarget
,
2406 GetModuleAtIndexFromEvent
,
2407 (const uint32_t, const lldb::SBEvent
&));
2408 LLDB_REGISTER_STATIC_METHOD(const char *, SBTarget
, GetBroadcasterClassName
,
2410 LLDB_REGISTER_METHOD_CONST(bool, SBTarget
, IsValid
, ());
2411 LLDB_REGISTER_METHOD_CONST(bool, SBTarget
, operator bool, ());
2412 LLDB_REGISTER_METHOD(lldb::SBProcess
, SBTarget
, GetProcess
, ());
2413 LLDB_REGISTER_METHOD(lldb::SBPlatform
, SBTarget
, GetPlatform
, ());
2414 LLDB_REGISTER_METHOD_CONST(lldb::SBDebugger
, SBTarget
, GetDebugger
, ());
2415 LLDB_REGISTER_METHOD(lldb::SBStructuredData
, SBTarget
, GetStatistics
, ());
2416 LLDB_REGISTER_METHOD(void, SBTarget
, SetCollectingStats
, (bool));
2417 LLDB_REGISTER_METHOD(bool, SBTarget
, GetCollectingStats
, ());
2418 LLDB_REGISTER_METHOD(lldb::SBProcess
, SBTarget
, LoadCore
, (const char *));
2419 LLDB_REGISTER_METHOD(lldb::SBProcess
, SBTarget
, LoadCore
,
2420 (const char *, lldb::SBError
&));
2421 LLDB_REGISTER_METHOD(lldb::SBProcess
, SBTarget
, LaunchSimple
,
2422 (const char **, const char **, const char *));
2423 LLDB_REGISTER_METHOD(lldb::SBError
, SBTarget
, Install
, ());
2424 LLDB_REGISTER_METHOD(lldb::SBProcess
, SBTarget
, Launch
,
2425 (lldb::SBListener
&, const char **, const char **,
2426 const char *, const char *, const char *,
2427 const char *, uint32_t, bool, lldb::SBError
&));
2428 LLDB_REGISTER_METHOD(lldb::SBProcess
, SBTarget
, Launch
,
2429 (lldb::SBLaunchInfo
&, lldb::SBError
&));
2430 LLDB_REGISTER_METHOD(lldb::SBProcess
, SBTarget
, Attach
,
2431 (lldb::SBAttachInfo
&, lldb::SBError
&));
2432 LLDB_REGISTER_METHOD(lldb::SBProcess
, SBTarget
, AttachToProcessWithID
,
2433 (lldb::SBListener
&, lldb::pid_t
, lldb::SBError
&));
2434 LLDB_REGISTER_METHOD(
2435 lldb::SBProcess
, SBTarget
, AttachToProcessWithName
,
2436 (lldb::SBListener
&, const char *, bool, lldb::SBError
&));
2437 LLDB_REGISTER_METHOD(
2438 lldb::SBProcess
, SBTarget
, ConnectRemote
,
2439 (lldb::SBListener
&, const char *, const char *, lldb::SBError
&));
2440 LLDB_REGISTER_METHOD(lldb::SBFileSpec
, SBTarget
, GetExecutable
, ());
2441 LLDB_REGISTER_METHOD_CONST(bool,
2442 SBTarget
, operator==,(const lldb::SBTarget
&));
2443 LLDB_REGISTER_METHOD_CONST(bool,
2444 SBTarget
, operator!=,(const lldb::SBTarget
&));
2445 LLDB_REGISTER_METHOD(lldb::SBAddress
, SBTarget
, ResolveLoadAddress
,
2447 LLDB_REGISTER_METHOD(lldb::SBAddress
, SBTarget
, ResolveFileAddress
,
2449 LLDB_REGISTER_METHOD(lldb::SBAddress
, SBTarget
, ResolvePastLoadAddress
,
2450 (uint32_t, lldb::addr_t
));
2451 LLDB_REGISTER_METHOD(lldb::SBSymbolContext
, SBTarget
,
2452 ResolveSymbolContextForAddress
,
2453 (const lldb::SBAddress
&, uint32_t));
2454 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
,
2455 BreakpointCreateByLocation
, (const char *, uint32_t));
2456 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
,
2457 BreakpointCreateByLocation
,
2458 (const lldb::SBFileSpec
&, uint32_t));
2459 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
,
2460 BreakpointCreateByLocation
,
2461 (const lldb::SBFileSpec
&, uint32_t, lldb::addr_t
));
2462 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
,
2463 BreakpointCreateByLocation
,
2464 (const lldb::SBFileSpec
&, uint32_t, lldb::addr_t
,
2465 lldb::SBFileSpecList
&));
2466 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
,
2467 BreakpointCreateByLocation
,
2468 (const lldb::SBFileSpec
&, uint32_t, uint32_t,
2469 lldb::addr_t
, lldb::SBFileSpecList
&));
2470 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByName
,
2471 (const char *, const char *));
2472 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByName
,
2473 (const char *, const lldb::SBFileSpecList
&,
2474 const lldb::SBFileSpecList
&));
2475 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByName
,
2476 (const char *, uint32_t, const lldb::SBFileSpecList
&,
2477 const lldb::SBFileSpecList
&));
2478 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByName
,
2479 (const char *, uint32_t, lldb::LanguageType
,
2480 const lldb::SBFileSpecList
&,
2481 const lldb::SBFileSpecList
&));
2482 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByNames
,
2483 (const char **, uint32_t, uint32_t,
2484 const lldb::SBFileSpecList
&,
2485 const lldb::SBFileSpecList
&));
2486 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByNames
,
2487 (const char **, uint32_t, uint32_t, lldb::LanguageType
,
2488 const lldb::SBFileSpecList
&,
2489 const lldb::SBFileSpecList
&));
2490 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByNames
,
2491 (const char **, uint32_t, uint32_t, lldb::LanguageType
,
2492 lldb::addr_t
, const lldb::SBFileSpecList
&,
2493 const lldb::SBFileSpecList
&));
2494 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByRegex
,
2495 (const char *, const char *));
2496 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByRegex
,
2497 (const char *, const lldb::SBFileSpecList
&,
2498 const lldb::SBFileSpecList
&));
2499 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
, BreakpointCreateByRegex
,
2500 (const char *, lldb::LanguageType
,
2501 const lldb::SBFileSpecList
&,
2502 const lldb::SBFileSpecList
&));
2503 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
,
2504 BreakpointCreateByAddress
, (lldb::addr_t
));
2505 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
,
2506 BreakpointCreateBySBAddress
, (lldb::SBAddress
&));
2507 LLDB_REGISTER_METHOD(
2508 lldb::SBBreakpoint
, SBTarget
, BreakpointCreateBySourceRegex
,
2509 (const char *, const lldb::SBFileSpec
&, const char *));
2510 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
,
2511 BreakpointCreateBySourceRegex
,
2512 (const char *, const lldb::SBFileSpecList
&,
2513 const lldb::SBFileSpecList
&));
2514 LLDB_REGISTER_METHOD(
2515 lldb::SBBreakpoint
, SBTarget
, BreakpointCreateBySourceRegex
,
2516 (const char *, const lldb::SBFileSpecList
&,
2517 const lldb::SBFileSpecList
&, const lldb::SBStringList
&));
2518 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
,
2519 BreakpointCreateForException
,
2520 (lldb::LanguageType
, bool, bool));
2521 LLDB_REGISTER_METHOD(
2522 lldb::SBBreakpoint
, SBTarget
, BreakpointCreateFromScript
,
2523 (const char *, lldb::SBStructuredData
&, const lldb::SBFileSpecList
&,
2524 const lldb::SBFileSpecList
&, bool));
2525 LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget
, GetNumBreakpoints
, ());
2526 LLDB_REGISTER_METHOD_CONST(lldb::SBBreakpoint
, SBTarget
,
2527 GetBreakpointAtIndex
, (uint32_t));
2528 LLDB_REGISTER_METHOD(bool, SBTarget
, BreakpointDelete
, (lldb::break_id_t
));
2529 LLDB_REGISTER_METHOD(lldb::SBBreakpoint
, SBTarget
, FindBreakpointByID
,
2530 (lldb::break_id_t
));
2531 LLDB_REGISTER_METHOD(bool, SBTarget
, FindBreakpointsByName
,
2532 (const char *, lldb::SBBreakpointList
&));
2533 LLDB_REGISTER_METHOD(void, SBTarget
, GetBreakpointNames
,
2534 (lldb::SBStringList
&));
2535 LLDB_REGISTER_METHOD(void, SBTarget
, DeleteBreakpointName
, (const char *));
2536 LLDB_REGISTER_METHOD(bool, SBTarget
, EnableAllBreakpoints
, ());
2537 LLDB_REGISTER_METHOD(bool, SBTarget
, DisableAllBreakpoints
, ());
2538 LLDB_REGISTER_METHOD(bool, SBTarget
, DeleteAllBreakpoints
, ());
2539 LLDB_REGISTER_METHOD(lldb::SBError
, SBTarget
, BreakpointsCreateFromFile
,
2540 (lldb::SBFileSpec
&, lldb::SBBreakpointList
&));
2541 LLDB_REGISTER_METHOD(
2542 lldb::SBError
, SBTarget
, BreakpointsCreateFromFile
,
2543 (lldb::SBFileSpec
&, lldb::SBStringList
&, lldb::SBBreakpointList
&));
2544 LLDB_REGISTER_METHOD(lldb::SBError
, SBTarget
, BreakpointsWriteToFile
,
2545 (lldb::SBFileSpec
&));
2546 LLDB_REGISTER_METHOD(lldb::SBError
, SBTarget
, BreakpointsWriteToFile
,
2547 (lldb::SBFileSpec
&, lldb::SBBreakpointList
&, bool));
2548 LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget
, GetNumWatchpoints
, ());
2549 LLDB_REGISTER_METHOD_CONST(lldb::SBWatchpoint
, SBTarget
,
2550 GetWatchpointAtIndex
, (uint32_t));
2551 LLDB_REGISTER_METHOD(bool, SBTarget
, DeleteWatchpoint
, (lldb::watch_id_t
));
2552 LLDB_REGISTER_METHOD(lldb::SBWatchpoint
, SBTarget
, FindWatchpointByID
,
2553 (lldb::watch_id_t
));
2554 LLDB_REGISTER_METHOD(lldb::SBWatchpoint
, SBTarget
, WatchAddress
,
2555 (lldb::addr_t
, size_t, bool, bool, lldb::SBError
&));
2556 LLDB_REGISTER_METHOD(bool, SBTarget
, EnableAllWatchpoints
, ());
2557 LLDB_REGISTER_METHOD(bool, SBTarget
, DisableAllWatchpoints
, ());
2558 LLDB_REGISTER_METHOD(lldb::SBValue
, SBTarget
, CreateValueFromAddress
,
2559 (const char *, lldb::SBAddress
, lldb::SBType
));
2560 LLDB_REGISTER_METHOD(lldb::SBValue
, SBTarget
, CreateValueFromData
,
2561 (const char *, lldb::SBData
, lldb::SBType
));
2562 LLDB_REGISTER_METHOD(lldb::SBValue
, SBTarget
, CreateValueFromExpression
,
2563 (const char *, const char *));
2564 LLDB_REGISTER_METHOD(bool, SBTarget
, DeleteAllWatchpoints
, ());
2565 LLDB_REGISTER_METHOD(void, SBTarget
, AppendImageSearchPath
,
2566 (const char *, const char *, lldb::SBError
&));
2567 LLDB_REGISTER_METHOD(lldb::SBModule
, SBTarget
, AddModule
,
2568 (const char *, const char *, const char *));
2569 LLDB_REGISTER_METHOD(
2570 lldb::SBModule
, SBTarget
, AddModule
,
2571 (const char *, const char *, const char *, const char *));
2572 LLDB_REGISTER_METHOD(lldb::SBModule
, SBTarget
, AddModule
,
2573 (const lldb::SBModuleSpec
&));
2574 LLDB_REGISTER_METHOD(bool, SBTarget
, AddModule
, (lldb::SBModule
&));
2575 LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget
, GetNumModules
, ());
2576 LLDB_REGISTER_METHOD(void, SBTarget
, Clear
, ());
2577 LLDB_REGISTER_METHOD(lldb::SBModule
, SBTarget
, FindModule
,
2578 (const lldb::SBFileSpec
&));
2579 LLDB_REGISTER_METHOD(lldb::SBSymbolContextList
, SBTarget
, FindCompileUnits
,
2580 (const lldb::SBFileSpec
&));
2581 LLDB_REGISTER_METHOD(lldb::ByteOrder
, SBTarget
, GetByteOrder
, ());
2582 LLDB_REGISTER_METHOD(const char *, SBTarget
, GetTriple
, ());
2583 LLDB_REGISTER_METHOD(uint32_t, SBTarget
, GetDataByteSize
, ());
2584 LLDB_REGISTER_METHOD(uint32_t, SBTarget
, GetCodeByteSize
, ());
2585 LLDB_REGISTER_METHOD(uint32_t, SBTarget
, GetAddressByteSize
, ());
2586 LLDB_REGISTER_METHOD(lldb::SBModule
, SBTarget
, GetModuleAtIndex
,
2588 LLDB_REGISTER_METHOD(bool, SBTarget
, RemoveModule
, (lldb::SBModule
));
2589 LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster
, SBTarget
, GetBroadcaster
,
2591 LLDB_REGISTER_METHOD(bool, SBTarget
, GetDescription
,
2592 (lldb::SBStream
&, lldb::DescriptionLevel
));
2593 LLDB_REGISTER_METHOD(lldb::SBSymbolContextList
, SBTarget
, FindFunctions
,
2594 (const char *, uint32_t));
2595 LLDB_REGISTER_METHOD(lldb::SBSymbolContextList
, SBTarget
,
2596 FindGlobalFunctions
,
2597 (const char *, uint32_t, lldb::MatchType
));
2598 LLDB_REGISTER_METHOD(lldb::SBType
, SBTarget
, FindFirstType
, (const char *));
2599 LLDB_REGISTER_METHOD(lldb::SBType
, SBTarget
, GetBasicType
,
2601 LLDB_REGISTER_METHOD(lldb::SBTypeList
, SBTarget
, FindTypes
, (const char *));
2602 LLDB_REGISTER_METHOD(lldb::SBValueList
, SBTarget
, FindGlobalVariables
,
2603 (const char *, uint32_t));
2604 LLDB_REGISTER_METHOD(lldb::SBValueList
, SBTarget
, FindGlobalVariables
,
2605 (const char *, uint32_t, lldb::MatchType
));
2606 LLDB_REGISTER_METHOD(lldb::SBValue
, SBTarget
, FindFirstGlobalVariable
,
2608 LLDB_REGISTER_METHOD(lldb::SBSourceManager
, SBTarget
, GetSourceManager
, ());
2609 LLDB_REGISTER_METHOD(lldb::SBInstructionList
, SBTarget
, ReadInstructions
,
2610 (lldb::SBAddress
, uint32_t));
2611 LLDB_REGISTER_METHOD(lldb::SBInstructionList
, SBTarget
, ReadInstructions
,
2612 (lldb::SBAddress
, uint32_t, const char *));
2613 LLDB_REGISTER_METHOD(lldb::SBError
, SBTarget
, SetSectionLoadAddress
,
2614 (lldb::SBSection
, lldb::addr_t
));
2615 LLDB_REGISTER_METHOD(lldb::SBError
, SBTarget
, ClearSectionLoadAddress
,
2617 LLDB_REGISTER_METHOD(lldb::SBError
, SBTarget
, SetModuleLoadAddress
,
2618 (lldb::SBModule
, int64_t));
2619 LLDB_REGISTER_METHOD(lldb::SBError
, SBTarget
, ClearModuleLoadAddress
,
2621 LLDB_REGISTER_METHOD(lldb::SBSymbolContextList
, SBTarget
, FindSymbols
,
2622 (const char *, lldb::SymbolType
));
2623 LLDB_REGISTER_METHOD(lldb::SBValue
, SBTarget
, EvaluateExpression
,
2625 LLDB_REGISTER_METHOD(lldb::SBValue
, SBTarget
, EvaluateExpression
,
2626 (const char *, const lldb::SBExpressionOptions
&));
2627 LLDB_REGISTER_METHOD(lldb::addr_t
, SBTarget
, GetStackRedZoneSize
, ());
2628 LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo
, SBTarget
, GetLaunchInfo
, ());
2629 LLDB_REGISTER_METHOD(void, SBTarget
, SetLaunchInfo
,
2630 (const lldb::SBLaunchInfo
&));