]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/API/SBTarget.cpp
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / API / SBTarget.cpp
1 //===-- SBTarget.cpp --------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "lldb/API/SBTarget.h"
10 #include "SBReproducerPrivate.h"
11
12 #include "lldb/lldb-public.h"
13
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"
65
66 #include "Commands/CommandObjectBreakpoint.h"
67 #include "lldb/Interpreter/CommandReturnObject.h"
68 #include "llvm/Support/PrettyStackTrace.h"
69 #include "llvm/Support/Regex.h"
70
71 using namespace lldb;
72 using namespace lldb_private;
73
74 #define DEFAULT_DISASM_BYTE_SIZE 32
75
76 namespace {
77
78 Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) {
79   std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex());
80
81   auto process_sp = target.GetProcessSP();
82   if (process_sp) {
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 "
90                       "empty listener");
91     }
92   }
93
94   return target.Attach(attach_info, nullptr);
95 }
96
97 } // namespace
98
99 // SBTarget constructor
100 SBTarget::SBTarget() : m_opaque_sp() {
101   LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTarget);
102 }
103
104 SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) {
105   LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &), rhs);
106 }
107
108 SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) {
109   LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &), target_sp);
110 }
111
112 const SBTarget &SBTarget::operator=(const SBTarget &rhs) {
113   LLDB_RECORD_METHOD(const lldb::SBTarget &,
114                      SBTarget, operator=,(const lldb::SBTarget &), rhs);
115
116   if (this != &rhs)
117     m_opaque_sp = rhs.m_opaque_sp;
118   return LLDB_RECORD_RESULT(*this);
119 }
120
121 // Destructor
122 SBTarget::~SBTarget() {}
123
124 bool SBTarget::EventIsTargetEvent(const SBEvent &event) {
125   LLDB_RECORD_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent,
126                             (const lldb::SBEvent &), event);
127
128   return Target::TargetEventData::GetEventDataFromEvent(event.get()) != nullptr;
129 }
130
131 SBTarget SBTarget::GetTargetFromEvent(const SBEvent &event) {
132   LLDB_RECORD_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent,
133                             (const lldb::SBEvent &), event);
134
135   return LLDB_RECORD_RESULT(
136       Target::TargetEventData::GetTargetFromEvent(event.get()));
137 }
138
139 uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent &event) {
140   LLDB_RECORD_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent,
141                             (const lldb::SBEvent &), event);
142
143   const ModuleList module_list =
144       Target::TargetEventData::GetModuleListFromEvent(event.get());
145   return module_list.GetSize();
146 }
147
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,
152                             event);
153
154   const ModuleList module_list =
155       Target::TargetEventData::GetModuleListFromEvent(event.get());
156   return LLDB_RECORD_RESULT(SBModule(module_list.GetModuleAtIndex(idx)));
157 }
158
159 const char *SBTarget::GetBroadcasterClassName() {
160   LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBTarget,
161                                     GetBroadcasterClassName);
162
163   return Target::GetStaticBroadcasterClass().AsCString();
164 }
165
166 bool SBTarget::IsValid() const {
167   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, IsValid);
168   return this->operator bool();
169 }
170 SBTarget::operator bool() const {
171   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, operator bool);
172
173   return m_opaque_sp.get() != nullptr && m_opaque_sp->IsValid();
174 }
175
176 SBProcess SBTarget::GetProcess() {
177   LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBTarget, GetProcess);
178
179   SBProcess sb_process;
180   ProcessSP process_sp;
181   TargetSP target_sp(GetSP());
182   if (target_sp) {
183     process_sp = target_sp->GetProcessSP();
184     sb_process.SetSP(process_sp);
185   }
186
187   return LLDB_RECORD_RESULT(sb_process);
188 }
189
190 SBPlatform SBTarget::GetPlatform() {
191   LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBTarget, GetPlatform);
192
193   TargetSP target_sp(GetSP());
194   if (!target_sp)
195     return LLDB_RECORD_RESULT(SBPlatform());
196
197   SBPlatform platform;
198   platform.m_opaque_sp = target_sp->GetPlatform();
199
200   return LLDB_RECORD_RESULT(platform);
201 }
202
203 SBDebugger SBTarget::GetDebugger() const {
204   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBDebugger, SBTarget, GetDebugger);
205
206   SBDebugger debugger;
207   TargetSP target_sp(GetSP());
208   if (target_sp)
209     debugger.reset(target_sp->GetDebugger().shared_from_this());
210   return LLDB_RECORD_RESULT(debugger);
211 }
212
213 SBStructuredData SBTarget::GetStatistics() {
214   LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBTarget, GetStatistics);
215
216   SBStructuredData data;
217   TargetSP target_sp(GetSP());
218   if (!target_sp)
219     return LLDB_RECORD_RESULT(data);
220
221   auto stats_up = llvm::make_unique<StructuredData::Dictionary>();
222   int i = 0;
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);
227     i += 1;
228   }
229
230   data.m_impl_up->SetObjectSP(std::move(stats_up));
231   return LLDB_RECORD_RESULT(data);
232 }
233
234 void SBTarget::SetCollectingStats(bool v) {
235   LLDB_RECORD_METHOD(void, SBTarget, SetCollectingStats, (bool), v);
236
237   TargetSP target_sp(GetSP());
238   if (!target_sp)
239     return;
240   return target_sp->SetCollectingStats(v);
241 }
242
243 bool SBTarget::GetCollectingStats() {
244   LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, GetCollectingStats);
245
246   TargetSP target_sp(GetSP());
247   if (!target_sp)
248     return false;
249   return target_sp->GetCollectingStats();
250 }
251
252 SBProcess SBTarget::LoadCore(const char *core_file) {
253   LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *),
254                      core_file);
255
256   lldb::SBError error; // Ignored
257   return LLDB_RECORD_RESULT(LoadCore(core_file, error));
258 }
259
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);
263
264   SBProcess sb_process;
265   TargetSP target_sp(GetSP());
266   if (target_sp) {
267     FileSpec filespec(core_file);
268     FileSystem::Instance().Resolve(filespec);
269     ProcessSP process_sp(target_sp->CreateProcess(
270         target_sp->GetDebugger().GetListener(), "", &filespec));
271     if (process_sp) {
272       error.SetError(process_sp->LoadCore());
273       if (error.Success())
274         sb_process.SetSP(process_sp);
275     } else {
276       error.SetErrorString("Failed to create the process");
277     }
278   } else {
279     error.SetErrorString("SBTarget is invalid");
280   }
281   return LLDB_RECORD_RESULT(sb_process);
282 }
283
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,
288                      working_directory);
289
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;
295   SBError error;
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));
300 }
301
302 SBError SBTarget::Install() {
303   LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBTarget, Install);
304
305   SBError sb_error;
306   TargetSP target_sp(GetSP());
307   if (target_sp) {
308     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
309     sb_error.ref() = target_sp->Install(nullptr);
310   }
311   return LLDB_RECORD_RESULT(sb_error);
312 }
313
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);
326
327   SBProcess sb_process;
328   ProcessSP process_sp;
329   TargetSP target_sp(GetSP());
330
331   if (target_sp) {
332     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
333
334     if (stop_at_entry)
335       launch_flags |= eLaunchFlagStopAtEntry;
336
337     if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
338       launch_flags |= eLaunchFlagDisableASLR;
339
340     StateType state = eStateInvalid;
341     process_sp = target_sp->GetProcessSP();
342     if (process_sp) {
343       state = process_sp->GetState();
344
345       if (process_sp->IsAlive() && state != eStateConnected) {
346         if (state == eStateAttaching)
347           error.SetErrorString("process attach is in progress");
348         else
349           error.SetErrorString("a process is already being debugged");
350         return LLDB_RECORD_RESULT(sb_process);
351       }
352     }
353
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);
362       }
363     }
364
365     if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
366       launch_flags |= eLaunchFlagDisableSTDIO;
367
368     ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path),
369                                   FileSpec(stderr_path),
370                                   FileSpec(working_directory), launch_flags);
371
372     Module *exe_module = target_sp->GetExecutableModulePointer();
373     if (exe_module)
374       launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
375     if (argv)
376       launch_info.GetArguments().AppendArguments(argv);
377     if (envp)
378       launch_info.GetEnvironment() = Environment(envp);
379
380     if (listener.IsValid())
381       launch_info.SetListener(listener.GetSP());
382
383     error.SetError(target_sp->Launch(launch_info, nullptr));
384
385     sb_process.SetSP(target_sp->GetProcessSP());
386   } else {
387     error.SetErrorString("SBTarget is invalid");
388   }
389
390   return LLDB_RECORD_RESULT(sb_process);
391 }
392
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,
396                      error);
397
398
399   SBProcess sb_process;
400   TargetSP target_sp(GetSP());
401
402   if (target_sp) {
403     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
404     StateType state = eStateInvalid;
405     {
406       ProcessSP process_sp = target_sp->GetProcessSP();
407       if (process_sp) {
408         state = process_sp->GetState();
409
410         if (process_sp->IsAlive() && state != eStateConnected) {
411           if (state == eStateAttaching)
412             error.SetErrorString("process attach is in progress");
413           else
414             error.SetErrorString("a process is already being debugged");
415           return LLDB_RECORD_RESULT(sb_process);
416         }
417       }
418     }
419
420     lldb_private::ProcessLaunchInfo launch_info = sb_launch_info.ref();
421
422     if (!launch_info.GetExecutableFile()) {
423       Module *exe_module = target_sp->GetExecutableModulePointer();
424       if (exe_module)
425         launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
426     }
427
428     const ArchSpec &arch_spec = target_sp->GetArchitecture();
429     if (arch_spec.IsValid())
430       launch_info.GetArchitecture() = arch_spec;
431
432     error.SetError(target_sp->Launch(launch_info, nullptr));
433     sb_launch_info.set_ref(launch_info);
434     sb_process.SetSP(target_sp->GetProcessSP());
435   } else {
436     error.SetErrorString("SBTarget is invalid");
437   }
438
439   return LLDB_RECORD_RESULT(sb_process);
440 }
441
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,
445                      error);
446
447   SBProcess sb_process;
448   TargetSP target_sp(GetSP());
449
450   if (target_sp) {
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());
460         } else {
461           error.ref().SetErrorStringWithFormat(
462               "no process found with process ID %" PRIu64, attach_pid);
463           return LLDB_RECORD_RESULT(sb_process);
464         }
465       }
466     }
467     error.SetError(AttachToProcess(attach_info, *target_sp));
468     if (error.Success())
469       sb_process.SetSP(target_sp->GetProcessSP());
470   } else {
471     error.SetErrorString("SBTarget is invalid");
472   }
473
474   return LLDB_RECORD_RESULT(sb_process);
475 }
476
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
481 ) {
482   LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID,
483                      (lldb::SBListener &, lldb::pid_t, lldb::SBError &),
484                      listener, pid, error);
485
486   SBProcess sb_process;
487   TargetSP target_sp(GetSP());
488
489   if (target_sp) {
490     ProcessAttachInfo attach_info;
491     attach_info.SetProcessID(pid);
492     if (listener.IsValid())
493       attach_info.SetListener(listener.GetSP());
494
495     ProcessInstanceInfo instance_info;
496     if (target_sp->GetPlatform()->GetProcessInfo(pid, instance_info))
497       attach_info.SetUserID(instance_info.GetEffectiveUserID());
498
499     error.SetError(AttachToProcess(attach_info, *target_sp));
500     if (error.Success())
501       sb_process.SetSP(target_sp->GetProcessSP());
502   } else
503     error.SetErrorString("SBTarget is invalid");
504
505   return LLDB_RECORD_RESULT(sb_process);
506 }
507
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
513 ) {
514   LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithName,
515                      (lldb::SBListener &, const char *, bool, lldb::SBError &),
516                      listener, name, wait_for, error);
517
518   SBProcess sb_process;
519   TargetSP target_sp(GetSP());
520
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());
527
528     error.SetError(AttachToProcess(attach_info, *target_sp));
529     if (error.Success())
530       sb_process.SetSP(target_sp->GetProcessSP());
531   } else
532     error.SetErrorString("SBTarget is invalid");
533
534   return LLDB_RECORD_RESULT(sb_process);
535 }
536
537 lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url,
538                                         const char *plugin_name,
539                                         SBError &error) {
540   LLDB_RECORD_METHOD(
541       lldb::SBProcess, SBTarget, ConnectRemote,
542       (lldb::SBListener &, const char *, const char *, lldb::SBError &),
543       listener, url, plugin_name, error);
544
545   SBProcess sb_process;
546   ProcessSP process_sp;
547   TargetSP target_sp(GetSP());
548
549   if (target_sp) {
550     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
551     if (listener.IsValid())
552       process_sp =
553           target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, nullptr);
554     else
555       process_sp = target_sp->CreateProcess(
556           target_sp->GetDebugger().GetListener(), plugin_name, nullptr);
557
558     if (process_sp) {
559       sb_process.SetSP(process_sp);
560       error.SetError(process_sp->ConnectRemote(nullptr, url));
561     } else {
562       error.SetErrorString("unable to create lldb_private::Process");
563     }
564   } else {
565     error.SetErrorString("SBTarget is invalid");
566   }
567
568   return LLDB_RECORD_RESULT(sb_process);
569 }
570
571 SBFileSpec SBTarget::GetExecutable() {
572   LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBTarget, GetExecutable);
573
574   SBFileSpec exe_file_spec;
575   TargetSP target_sp(GetSP());
576   if (target_sp) {
577     Module *exe_module = target_sp->GetExecutableModulePointer();
578     if (exe_module)
579       exe_file_spec.SetFileSpec(exe_module->GetFileSpec());
580   }
581
582   return LLDB_RECORD_RESULT(exe_file_spec);
583 }
584
585 bool SBTarget::operator==(const SBTarget &rhs) const {
586   LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator==,(const lldb::SBTarget &),
587                            rhs);
588
589   return m_opaque_sp.get() == rhs.m_opaque_sp.get();
590 }
591
592 bool SBTarget::operator!=(const SBTarget &rhs) const {
593   LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator!=,(const lldb::SBTarget &),
594                            rhs);
595
596   return m_opaque_sp.get() != rhs.m_opaque_sp.get();
597 }
598
599 lldb::TargetSP SBTarget::GetSP() const { return m_opaque_sp; }
600
601 void SBTarget::SetSP(const lldb::TargetSP &target_sp) {
602   m_opaque_sp = target_sp;
603 }
604
605 lldb::SBAddress SBTarget::ResolveLoadAddress(lldb::addr_t vm_addr) {
606   LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress,
607                      (lldb::addr_t), vm_addr);
608
609   lldb::SBAddress sb_addr;
610   Address &addr = sb_addr.ref();
611   TargetSP target_sp(GetSP());
612   if (target_sp) {
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);
616   }
617
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);
622 }
623
624 lldb::SBAddress SBTarget::ResolveFileAddress(lldb::addr_t file_addr) {
625   LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress,
626                      (lldb::addr_t), file_addr);
627
628   lldb::SBAddress sb_addr;
629   Address &addr = sb_addr.ref();
630   TargetSP target_sp(GetSP());
631   if (target_sp) {
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);
635   }
636
637   addr.SetRawAddress(file_addr);
638   return LLDB_RECORD_RESULT(sb_addr);
639 }
640
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);
645
646   lldb::SBAddress sb_addr;
647   Address &addr = sb_addr.ref();
648   TargetSP target_sp(GetSP());
649   if (target_sp) {
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);
653   }
654
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);
659 }
660
661 SBSymbolContext
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);
667
668   SBSymbolContext sc;
669   SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
670   if (addr.IsValid()) {
671     TargetSP target_sp(GetSP());
672     if (target_sp)
673       target_sp->GetImages().ResolveSymbolContextForAddress(addr.ref(), scope,
674                                                             sc.ref());
675   }
676   return LLDB_RECORD_RESULT(sc);
677 }
678
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);
684
685   SBError sb_error;
686   size_t bytes_read = 0;
687   TargetSP target_sp(GetSP());
688   if (target_sp) {
689     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
690     bytes_read =
691         target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref());
692   } else {
693     sb_error.SetErrorString("invalid target");
694   }
695
696   return bytes_read;
697 }
698
699 SBBreakpoint SBTarget::BreakpointCreateByLocation(const char *file,
700                                                   uint32_t line) {
701   LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
702                      (const char *, uint32_t), file, line);
703
704   return LLDB_RECORD_RESULT(
705       SBBreakpoint(BreakpointCreateByLocation(SBFileSpec(file, false), line)));
706 }
707
708 SBBreakpoint
709 SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
710                                      uint32_t line) {
711   LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
712                      (const lldb::SBFileSpec &, uint32_t), sb_file_spec, line);
713
714   return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0));
715 }
716
717 SBBreakpoint
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);
723
724   SBFileSpecList empty_list;
725   return LLDB_RECORD_RESULT(
726       BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list));
727 }
728
729 SBBreakpoint
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);
737
738   return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0,
739                                                        offset, sb_module_list));
740 }
741
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);
749
750   SBBreakpoint sb_bp;
751   TargetSP target_sp(GetSP());
752   if (target_sp && line != 0) {
753     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
754
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();
763     }
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);
767   }
768
769   return LLDB_RECORD_RESULT(sb_bp);
770 }
771
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);
776
777   SBBreakpoint sb_bp;
778   TargetSP target_sp(GetSP());
779   if (target_sp.get()) {
780     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
781
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);
792     } else {
793       sb_bp = target_sp->CreateBreakpoint(
794           nullptr, nullptr, symbol_name, eFunctionNameTypeAuto,
795           eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
796     }
797   }
798
799   return LLDB_RECORD_RESULT(sb_bp);
800 }
801
802 lldb::SBBreakpoint
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);
810
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));
815 }
816
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);
824
825   return LLDB_RECORD_RESULT(
826       BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown,
827                              module_list, comp_unit_list));
828 }
829
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,
839                      comp_unit_list);
840
841   SBBreakpoint sb_bp;
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);
852   }
853
854   return LLDB_RECORD_RESULT(sb_bp);
855 }
856
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) {
860   LLDB_RECORD_METHOD(
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);
865
866   return LLDB_RECORD_RESULT(BreakpointCreateByNames(
867       symbol_names, num_names, name_type_mask, eLanguageTypeUnknown,
868       module_list, comp_unit_list));
869 }
870
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);
881
882   return LLDB_RECORD_RESULT(BreakpointCreateByNames(
883       symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 0,
884       module_list, comp_unit_list));
885 }
886
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);
897
898   SBBreakpoint sb_bp;
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);
909   }
910
911   return LLDB_RECORD_RESULT(sb_bp);
912 }
913
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,
918                      module_name);
919
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));
924   }
925   return LLDB_RECORD_RESULT(
926       BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown,
927                               module_spec_list, comp_unit_list));
928 }
929
930 lldb::SBBreakpoint
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);
938
939   return LLDB_RECORD_RESULT(BreakpointCreateByRegex(
940       symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list));
941 }
942
943 lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(
944     const char *symbol_name_regex, LanguageType symbol_language,
945     const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
946   LLDB_RECORD_METHOD(
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);
951
952
953   SBBreakpoint sb_bp;
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;
961
962     sb_bp = target_sp->CreateFuncRegexBreakpoint(
963         module_list.get(), comp_unit_list.get(), regexp, symbol_language,
964         skip_prologue, internal, hardware);
965   }
966
967   return LLDB_RECORD_RESULT(sb_bp);
968 }
969
970 SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) {
971   LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByAddress,
972                      (lldb::addr_t), address);
973
974   SBBreakpoint sb_bp;
975   TargetSP target_sp(GetSP());
976   if (target_sp) {
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);
980   }
981
982   return LLDB_RECORD_RESULT(sb_bp);
983 }
984
985 SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) {
986   LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateBySBAddress,
987                      (lldb::SBAddress &), sb_address);
988
989   SBBreakpoint sb_bp;
990   TargetSP target_sp(GetSP());
991   if (!sb_address.IsValid()) {
992     return LLDB_RECORD_RESULT(sb_bp);
993   }
994
995   if (target_sp) {
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);
999   }
1000
1001   return LLDB_RECORD_RESULT(sb_bp);
1002 }
1003
1004 lldb::SBBreakpoint
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);
1012
1013   SBFileSpecList module_spec_list;
1014
1015   if (module_name && module_name[0]) {
1016     module_spec_list.Append(FileSpec(module_name));
1017   }
1018
1019   SBFileSpecList source_file_list;
1020   if (source_file.IsValid()) {
1021     source_file_list.Append(source_file);
1022   }
1023
1024   return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex(
1025       source_regex, module_spec_list, source_file_list));
1026 }
1027
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);
1036
1037   return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex(
1038       source_regex, module_list, source_file_list, SBStringList()));
1039 }
1040
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);
1050
1051   SBBreakpoint sb_bp;
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));
1061     }
1062
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);
1066   }
1067
1068   return LLDB_RECORD_RESULT(sb_bp);
1069 }
1070
1071 lldb::SBBreakpoint
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,
1076                      throw_bp);
1077
1078   SBBreakpoint sb_bp;
1079   TargetSP target_sp(GetSP());
1080   if (target_sp) {
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,
1084                                                   hardware);
1085   }
1086
1087   return LLDB_RECORD_RESULT(sb_bp);
1088 }
1089
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) {
1094   LLDB_RECORD_METHOD(
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);
1099
1100   SBBreakpoint sb_bp;
1101   TargetSP target_sp(GetSP());
1102   if (target_sp) {
1103     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1104     Status error;
1105
1106     StructuredData::ObjectSP obj_sp = extra_args.m_impl_up->GetObjectSP();
1107     sb_bp =
1108         target_sp->CreateScriptedBreakpoint(class_name,
1109                                             module_list.get(),
1110                                             file_list.get(),
1111                                             false, /* internal */
1112                                             request_hardware,
1113                                             obj_sp,
1114                                             &error);
1115   }
1116
1117   return LLDB_RECORD_RESULT(sb_bp);
1118 }
1119
1120 uint32_t SBTarget::GetNumBreakpoints() const {
1121   LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumBreakpoints);
1122
1123   TargetSP target_sp(GetSP());
1124   if (target_sp) {
1125     // The breakpoint list is thread safe, no need to lock
1126     return target_sp->GetBreakpointList().GetSize();
1127   }
1128   return 0;
1129 }
1130
1131 SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const {
1132   LLDB_RECORD_METHOD_CONST(lldb::SBBreakpoint, SBTarget, GetBreakpointAtIndex,
1133                            (uint32_t), idx);
1134
1135   SBBreakpoint sb_breakpoint;
1136   TargetSP target_sp(GetSP());
1137   if (target_sp) {
1138     // The breakpoint list is thread safe, no need to lock
1139     sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
1140   }
1141   return LLDB_RECORD_RESULT(sb_breakpoint);
1142 }
1143
1144 bool SBTarget::BreakpointDelete(break_id_t bp_id) {
1145   LLDB_RECORD_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t),
1146                      bp_id);
1147
1148   bool result = false;
1149   TargetSP target_sp(GetSP());
1150   if (target_sp) {
1151     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1152     result = target_sp->RemoveBreakpointByID(bp_id);
1153   }
1154
1155   return result;
1156 }
1157
1158 SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) {
1159   LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID,
1160                      (lldb::break_id_t), bp_id);
1161
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);
1167   }
1168
1169   return LLDB_RECORD_RESULT(sb_breakpoint);
1170 }
1171
1172 bool SBTarget::FindBreakpointsByName(const char *name,
1173                                      SBBreakpointList &bkpts) {
1174   LLDB_RECORD_METHOD(bool, SBTarget, FindBreakpointsByName,
1175                      (const char *, lldb::SBBreakpointList &), name, bkpts);
1176
1177   TargetSP target_sp(GetSP());
1178   if (target_sp) {
1179     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1180     BreakpointList bkpt_list(false);
1181     bool is_valid =
1182         target_sp->GetBreakpointList().FindBreakpointsByName(name, bkpt_list);
1183     if (!is_valid)
1184       return false;
1185     for (BreakpointSP bkpt_sp : bkpt_list.Breakpoints()) {
1186       bkpts.AppendByID(bkpt_sp->GetID());
1187     }
1188   }
1189   return true;
1190 }
1191
1192 void SBTarget::GetBreakpointNames(SBStringList &names) {
1193   LLDB_RECORD_METHOD(void, SBTarget, GetBreakpointNames, (lldb::SBStringList &),
1194                      names);
1195
1196   names.Clear();
1197
1198   TargetSP target_sp(GetSP());
1199   if (target_sp) {
1200     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1201
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());
1206   }
1207 }
1208
1209 void SBTarget::DeleteBreakpointName(const char *name) {
1210   LLDB_RECORD_METHOD(void, SBTarget, DeleteBreakpointName, (const char *),
1211                      name);
1212
1213   TargetSP target_sp(GetSP());
1214   if (target_sp) {
1215     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1216     target_sp->DeleteBreakpointName(ConstString(name));
1217   }
1218 }
1219
1220 bool SBTarget::EnableAllBreakpoints() {
1221   LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllBreakpoints);
1222
1223   TargetSP target_sp(GetSP());
1224   if (target_sp) {
1225     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1226     target_sp->EnableAllowedBreakpoints();
1227     return true;
1228   }
1229   return false;
1230 }
1231
1232 bool SBTarget::DisableAllBreakpoints() {
1233   LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllBreakpoints);
1234
1235   TargetSP target_sp(GetSP());
1236   if (target_sp) {
1237     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1238     target_sp->DisableAllowedBreakpoints();
1239     return true;
1240   }
1241   return false;
1242 }
1243
1244 bool SBTarget::DeleteAllBreakpoints() {
1245   LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllBreakpoints);
1246
1247   TargetSP target_sp(GetSP());
1248   if (target_sp) {
1249     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1250     target_sp->RemoveAllowedBreakpoints();
1251     return true;
1252   }
1253   return false;
1254 }
1255
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);
1261
1262   SBStringList empty_name_list;
1263   return LLDB_RECORD_RESULT(
1264       BreakpointsCreateFromFile(source_file, empty_name_list, new_bps));
1265 }
1266
1267 lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file,
1268                                                   SBStringList &matching_names,
1269                                                   SBBreakpointList &new_bps) {
1270   LLDB_RECORD_METHOD(
1271       lldb::SBError, SBTarget, BreakpointsCreateFromFile,
1272       (lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &),
1273       source_file, matching_names, new_bps);
1274
1275   SBError sberr;
1276   TargetSP target_sp(GetSP());
1277   if (!target_sp) {
1278     sberr.SetErrorString(
1279         "BreakpointCreateFromFile called with invalid target.");
1280     return LLDB_RECORD_RESULT(sberr);
1281   }
1282   std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1283
1284   BreakpointIDList bp_ids;
1285
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));
1290
1291   sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(),
1292                                                      name_vector, bp_ids);
1293   if (sberr.Fail())
1294     return LLDB_RECORD_RESULT(sberr);
1295
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());
1300   }
1301   return LLDB_RECORD_RESULT(sberr);
1302 }
1303
1304 lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file) {
1305   LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
1306                      (lldb::SBFileSpec &), dest_file);
1307
1308   SBError sberr;
1309   TargetSP target_sp(GetSP());
1310   if (!target_sp) {
1311     sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
1312     return LLDB_RECORD_RESULT(sberr);
1313   }
1314   SBBreakpointList bkpt_list(*this);
1315   return LLDB_RECORD_RESULT(BreakpointsWriteToFile(dest_file, bkpt_list));
1316 }
1317
1318 lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file,
1319                                                SBBreakpointList &bkpt_list,
1320                                                bool append) {
1321   LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
1322                      (lldb::SBFileSpec &, lldb::SBBreakpointList &, bool),
1323                      dest_file, bkpt_list, append);
1324
1325   SBError sberr;
1326   TargetSP target_sp(GetSP());
1327   if (!target_sp) {
1328     sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
1329     return LLDB_RECORD_RESULT(sberr);
1330   }
1331
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);
1338 }
1339
1340 uint32_t SBTarget::GetNumWatchpoints() const {
1341   LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumWatchpoints);
1342
1343   TargetSP target_sp(GetSP());
1344   if (target_sp) {
1345     // The watchpoint list is thread safe, no need to lock
1346     return target_sp->GetWatchpointList().GetSize();
1347   }
1348   return 0;
1349 }
1350
1351 SBWatchpoint SBTarget::GetWatchpointAtIndex(uint32_t idx) const {
1352   LLDB_RECORD_METHOD_CONST(lldb::SBWatchpoint, SBTarget, GetWatchpointAtIndex,
1353                            (uint32_t), idx);
1354
1355   SBWatchpoint sb_watchpoint;
1356   TargetSP target_sp(GetSP());
1357   if (target_sp) {
1358     // The watchpoint list is thread safe, no need to lock
1359     sb_watchpoint.SetSP(target_sp->GetWatchpointList().GetByIndex(idx));
1360   }
1361   return LLDB_RECORD_RESULT(sb_watchpoint);
1362 }
1363
1364 bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) {
1365   LLDB_RECORD_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t),
1366                      wp_id);
1367
1368
1369   bool result = false;
1370   TargetSP target_sp(GetSP());
1371   if (target_sp) {
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);
1376   }
1377
1378   return result;
1379 }
1380
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);
1384
1385
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);
1395   }
1396
1397   return LLDB_RECORD_RESULT(sb_watchpoint);
1398 }
1399
1400 lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size,
1401                                           bool read, bool write,
1402                                           SBError &error) {
1403   LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress,
1404                      (lldb::addr_t, size_t, bool, bool, lldb::SBError &), addr,
1405                      size, read, write, error);
1406
1407   SBWatchpoint sb_watchpoint;
1408   lldb::WatchpointSP watchpoint_sp;
1409   TargetSP target_sp(GetSP());
1410   if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS &&
1411       size > 0) {
1412     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1413     uint32_t watch_type = 0;
1414     if (read)
1415       watch_type |= LLDB_WATCH_TYPE_READ;
1416     if (write)
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);
1422     }
1423
1424     // Target::CreateWatchpoint() is thread safe.
1425     Status cw_error;
1426     // This API doesn't take in a type, so we can't figure out what it is.
1427     CompilerType *type = nullptr;
1428     watchpoint_sp =
1429         target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
1430     error.SetError(cw_error);
1431     sb_watchpoint.SetSP(watchpoint_sp);
1432   }
1433
1434   return LLDB_RECORD_RESULT(sb_watchpoint);
1435 }
1436
1437 bool SBTarget::EnableAllWatchpoints() {
1438   LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllWatchpoints);
1439
1440   TargetSP target_sp(GetSP());
1441   if (target_sp) {
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();
1446     return true;
1447   }
1448   return false;
1449 }
1450
1451 bool SBTarget::DisableAllWatchpoints() {
1452   LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllWatchpoints);
1453
1454   TargetSP target_sp(GetSP());
1455   if (target_sp) {
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();
1460     return true;
1461   }
1462   return false;
1463 }
1464
1465 SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr,
1466                                          SBType type) {
1467   LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress,
1468                      (const char *, lldb::SBAddress, lldb::SBType), name, addr,
1469                      type);
1470
1471   SBValue sb_value;
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,
1479                                                              exe_ctx, ast_type);
1480   }
1481   sb_value.SetSP(new_value_sp);
1482   return LLDB_RECORD_RESULT(sb_value);
1483 }
1484
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,
1489                      type);
1490
1491   SBValue sb_value;
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,
1499                                                           exe_ctx, ast_type);
1500   }
1501   sb_value.SetSP(new_value_sp);
1502   return LLDB_RECORD_RESULT(sb_value);
1503 }
1504
1505 lldb::SBValue SBTarget::CreateValueFromExpression(const char *name,
1506                                                   const char *expr) {
1507   LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression,
1508                      (const char *, const char *), name, expr);
1509
1510   SBValue sb_value;
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)));
1515     new_value_sp =
1516         ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx);
1517   }
1518   sb_value.SetSP(new_value_sp);
1519   return LLDB_RECORD_RESULT(sb_value);
1520 }
1521
1522 bool SBTarget::DeleteAllWatchpoints() {
1523   LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllWatchpoints);
1524
1525   TargetSP target_sp(GetSP());
1526   if (target_sp) {
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();
1531     return true;
1532   }
1533   return false;
1534 }
1535
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,
1540                      error);
1541
1542   TargetSP target_sp(GetSP());
1543   if (!target_sp)
1544     return error.SetErrorString("invalid target");
1545
1546   const ConstString csFrom(from), csTo(to);
1547   if (!csFrom)
1548     return error.SetErrorString("<from> path can't be empty");
1549   if (!csTo)
1550     return error.SetErrorString("<to> path can't be empty");
1551
1552   target_sp->GetImageSearchPathList().Append(csFrom, csTo, true);
1553 }
1554
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,
1559                      uuid_cstr);
1560
1561   return LLDB_RECORD_RESULT(AddModule(path, triple, uuid_cstr, nullptr));
1562 }
1563
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);
1569
1570   lldb::SBModule sb_module;
1571   TargetSP target_sp(GetSP());
1572   if (target_sp) {
1573     ModuleSpec module_spec;
1574     if (path)
1575       module_spec.GetFileSpec().SetFile(path, FileSpec::Style::native);
1576
1577     if (uuid_cstr)
1578       module_spec.GetUUID().SetFromStringRef(uuid_cstr);
1579
1580     if (triple)
1581       module_spec.GetArchitecture() = Platform::GetAugmentedArchSpec(
1582           target_sp->GetPlatform().get(), triple);
1583     else
1584       module_spec.GetArchitecture() = target_sp->GetArchitecture();
1585
1586     if (symfile)
1587       module_spec.GetSymbolFileSpec().SetFile(symfile, FileSpec::Style::native);
1588
1589     sb_module.SetSP(target_sp->GetOrCreateModule(module_spec, true /* notify */));
1590   }
1591   return LLDB_RECORD_RESULT(sb_module);
1592 }
1593
1594 lldb::SBModule SBTarget::AddModule(const SBModuleSpec &module_spec) {
1595   LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule,
1596                      (const lldb::SBModuleSpec &), module_spec);
1597
1598   lldb::SBModule sb_module;
1599   TargetSP target_sp(GetSP());
1600   if (target_sp)
1601     sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up, 
1602                                                  true /* notify */));
1603   return LLDB_RECORD_RESULT(sb_module);
1604 }
1605
1606 bool SBTarget::AddModule(lldb::SBModule &module) {
1607   LLDB_RECORD_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &), module);
1608
1609   TargetSP target_sp(GetSP());
1610   if (target_sp) {
1611     target_sp->GetImages().AppendIfNeeded(module.GetSP());
1612     return true;
1613   }
1614   return false;
1615 }
1616
1617 uint32_t SBTarget::GetNumModules() const {
1618   LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumModules);
1619
1620   uint32_t num = 0;
1621   TargetSP target_sp(GetSP());
1622   if (target_sp) {
1623     // The module list is thread safe, no need to lock
1624     num = target_sp->GetImages().GetSize();
1625   }
1626
1627   return num;
1628 }
1629
1630 void SBTarget::Clear() {
1631   LLDB_RECORD_METHOD_NO_ARGS(void, SBTarget, Clear);
1632
1633   m_opaque_sp.reset();
1634 }
1635
1636 SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) {
1637   LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, FindModule,
1638                      (const lldb::SBFileSpec &), sb_file_spec);
1639
1640   SBModule sb_module;
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));
1646   }
1647   return LLDB_RECORD_RESULT(sb_module);
1648 }
1649
1650 SBSymbolContextList SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) {
1651   LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits,
1652                      (const lldb::SBFileSpec &), sb_file_spec);
1653
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);
1660   }
1661   return LLDB_RECORD_RESULT(sb_sc_list);
1662 }
1663
1664 lldb::ByteOrder SBTarget::GetByteOrder() {
1665   LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBTarget, GetByteOrder);
1666
1667   TargetSP target_sp(GetSP());
1668   if (target_sp)
1669     return target_sp->GetArchitecture().GetByteOrder();
1670   return eByteOrderInvalid;
1671 }
1672
1673 const char *SBTarget::GetTriple() {
1674   LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTarget, GetTriple);
1675
1676   TargetSP target_sp(GetSP());
1677   if (target_sp) {
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
1681     // comes out
1682     ConstString const_triple(triple.c_str());
1683     return const_triple.GetCString();
1684   }
1685   return nullptr;
1686 }
1687
1688 uint32_t SBTarget::GetDataByteSize() {
1689   LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetDataByteSize);
1690
1691   TargetSP target_sp(GetSP());
1692   if (target_sp) {
1693     return target_sp->GetArchitecture().GetDataByteSize();
1694   }
1695   return 0;
1696 }
1697
1698 uint32_t SBTarget::GetCodeByteSize() {
1699   LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetCodeByteSize);
1700
1701   TargetSP target_sp(GetSP());
1702   if (target_sp) {
1703     return target_sp->GetArchitecture().GetCodeByteSize();
1704   }
1705   return 0;
1706 }
1707
1708 uint32_t SBTarget::GetAddressByteSize() {
1709   LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetAddressByteSize);
1710
1711   TargetSP target_sp(GetSP());
1712   if (target_sp)
1713     return target_sp->GetArchitecture().GetAddressByteSize();
1714   return sizeof(void *);
1715 }
1716
1717 SBModule SBTarget::GetModuleAtIndex(uint32_t idx) {
1718   LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex, (uint32_t),
1719                      idx);
1720
1721   SBModule sb_module;
1722   ModuleSP module_sp;
1723   TargetSP target_sp(GetSP());
1724   if (target_sp) {
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);
1728   }
1729
1730   return LLDB_RECORD_RESULT(sb_module);
1731 }
1732
1733 bool SBTarget::RemoveModule(lldb::SBModule module) {
1734   LLDB_RECORD_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule), module);
1735
1736   TargetSP target_sp(GetSP());
1737   if (target_sp)
1738     return target_sp->GetImages().Remove(module.GetSP());
1739   return false;
1740 }
1741
1742 SBBroadcaster SBTarget::GetBroadcaster() const {
1743   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBTarget,
1744                                    GetBroadcaster);
1745
1746
1747   TargetSP target_sp(GetSP());
1748   SBBroadcaster broadcaster(target_sp.get(), false);
1749
1750
1751   return LLDB_RECORD_RESULT(broadcaster);
1752 }
1753
1754 bool SBTarget::GetDescription(SBStream &description,
1755                               lldb::DescriptionLevel description_level) {
1756   LLDB_RECORD_METHOD(bool, SBTarget, GetDescription,
1757                      (lldb::SBStream &, lldb::DescriptionLevel), description,
1758                      description_level);
1759
1760   Stream &strm = description.ref();
1761
1762   TargetSP target_sp(GetSP());
1763   if (target_sp) {
1764     target_sp->Dump(&strm, description_level);
1765   } else
1766     strm.PutCString("No value");
1767
1768   return true;
1769 }
1770
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);
1775
1776   lldb::SBSymbolContextList sb_sc_list;
1777   if (!name | !name[0])
1778     return LLDB_RECORD_RESULT(sb_sc_list);
1779
1780   TargetSP target_sp(GetSP());
1781   if (!target_sp)
1782     return LLDB_RECORD_RESULT(sb_sc_list);
1783
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);
1791 }
1792
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);
1799
1800   lldb::SBSymbolContextList sb_sc_list;
1801   if (name && name[0]) {
1802     llvm::StringRef name_ref(name);
1803     TargetSP target_sp(GetSP());
1804     if (target_sp) {
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);
1810         break;
1811       case eMatchTypeStartsWith:
1812         regexstr = llvm::Regex::escape(name) + ".*";
1813         target_sp->GetImages().FindFunctions(RegularExpression(regexstr), true,
1814                                              true, true, *sb_sc_list);
1815         break;
1816       default:
1817         target_sp->GetImages().FindFunctions(ConstString(name),
1818                                              eFunctionNameTypeAny, true, true,
1819                                              true, *sb_sc_list);
1820         break;
1821       }
1822     }
1823   }
1824   return LLDB_RECORD_RESULT(sb_sc_list);
1825 }
1826
1827 lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
1828   LLDB_RECORD_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *),
1829                      typename_cstr);
1830
1831   TargetSP target_sp(GetSP());
1832   if (typename_cstr && typename_cstr[0] && target_sp) {
1833     ConstString const_typename(typename_cstr);
1834     SymbolContext sc;
1835     const bool exact_match = false;
1836
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));
1841       if (module_sp) {
1842         TypeSP type_sp(
1843             module_sp->FindFirstType(sc, const_typename, exact_match));
1844         if (type_sp)
1845           return LLDB_RECORD_RESULT(SBType(type_sp));
1846       }
1847     }
1848
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);
1854           if (!types.empty())
1855             return LLDB_RECORD_RESULT(SBType(types.front()));
1856         }
1857       }
1858     }
1859
1860     // No matches, search for basic typename matches
1861     ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1862     if (clang_ast)
1863       return LLDB_RECORD_RESULT(SBType(ClangASTContext::GetBasicType(
1864           clang_ast->getASTContext(), const_typename)));
1865   }
1866   return LLDB_RECORD_RESULT(SBType());
1867 }
1868
1869 SBType SBTarget::GetBasicType(lldb::BasicType type) {
1870   LLDB_RECORD_METHOD(lldb::SBType, SBTarget, GetBasicType, (lldb::BasicType),
1871                      type);
1872
1873   TargetSP target_sp(GetSP());
1874   if (target_sp) {
1875     ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1876     if (clang_ast)
1877       return LLDB_RECORD_RESULT(SBType(
1878           ClangASTContext::GetBasicType(clang_ast->getASTContext(), type)));
1879   }
1880   return LLDB_RECORD_RESULT(SBType());
1881 }
1882
1883 lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
1884   LLDB_RECORD_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *),
1885                      typename_cstr);
1886
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;
1893     TypeList type_list;
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);
1898
1899     if (num_matches > 0) {
1900       for (size_t idx = 0; idx < num_matches; idx++) {
1901         TypeSP type_sp(type_list.GetTypeAtIndex(idx));
1902         if (type_sp)
1903           sb_type_list.Append(SBType(type_sp));
1904       }
1905     }
1906
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()) {
1911           auto types =
1912               vendor->FindTypes(const_typename, /*max_matches*/ UINT32_MAX);
1913           for (auto type : types)
1914             sb_type_list.Append(SBType(type));
1915         }
1916       }
1917     }
1918
1919     if (sb_type_list.GetSize() == 0) {
1920       // No matches, search for basic typename matches
1921       ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1922       if (clang_ast)
1923         sb_type_list.Append(SBType(ClangASTContext::GetBasicType(
1924             clang_ast->getASTContext(), const_typename)));
1925     }
1926   }
1927   return LLDB_RECORD_RESULT(sb_type_list);
1928 }
1929
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);
1934
1935   SBValueList sb_value_list;
1936
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);
1942
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)));
1950         if (valobj_sp)
1951           sb_value_list.Append(SBValue(valobj_sp));
1952       }
1953     }
1954   }
1955
1956   return LLDB_RECORD_RESULT(sb_value_list);
1957 }
1958
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);
1965
1966   SBValueList sb_value_list;
1967
1968   TargetSP target_sp(GetSP());
1969   if (name && target_sp) {
1970     llvm::StringRef name_ref(name);
1971     VariableList variable_list;
1972
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);
1979       break;
1980     case eMatchTypeRegex:
1981       match_count = target_sp->GetImages().FindGlobalVariables(
1982           RegularExpression(name_ref), max_matches, variable_list);
1983       break;
1984     case eMatchTypeStartsWith:
1985       regexstr = llvm::Regex::escape(name) + ".*";
1986       match_count = target_sp->GetImages().FindGlobalVariables(
1987           RegularExpression(regexstr), max_matches, variable_list);
1988       break;
1989     }
1990
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)));
1998         if (valobj_sp)
1999           sb_value_list.Append(SBValue(valobj_sp));
2000       }
2001     }
2002   }
2003
2004   return LLDB_RECORD_RESULT(sb_value_list);
2005 }
2006
2007 lldb::SBValue SBTarget::FindFirstGlobalVariable(const char *name) {
2008   LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable,
2009                      (const char *), name);
2010
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());
2015 }
2016
2017 SBSourceManager SBTarget::GetSourceManager() {
2018   LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBTarget, GetSourceManager);
2019
2020   SBSourceManager source_manager(*this);
2021   return LLDB_RECORD_RESULT(source_manager);
2022 }
2023
2024 lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
2025                                                    uint32_t count) {
2026   LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
2027                      (lldb::SBAddress, uint32_t), base_addr, count);
2028
2029   return LLDB_RECORD_RESULT(ReadInstructions(base_addr, count, nullptr));
2030 }
2031
2032 lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
2033                                                    uint32_t count,
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);
2038
2039   SBInstructionList sb_instructions;
2040
2041   TargetSP target_sp(GetSP());
2042   if (target_sp) {
2043     Address *addr_ptr = base_addr.get();
2044
2045     if (addr_ptr) {
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));
2058     }
2059   }
2060
2061   return LLDB_RECORD_RESULT(sb_instructions);
2062 }
2063
2064 lldb::SBInstructionList SBTarget::GetInstructions(lldb::SBAddress base_addr,
2065                                                   const void *buf,
2066                                                   size_t size) {
2067   LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions,
2068                     (lldb::SBAddress, const void *, size_t), base_addr, buf,
2069                     size);
2070
2071   return GetInstructionsWithFlavor(base_addr, nullptr, buf, size);
2072 }
2073
2074 lldb::SBInstructionList
2075 SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr,
2076                                     const char *flavor_string, const void *buf,
2077                                     size_t size) {
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);
2082
2083   SBInstructionList sb_instructions;
2084
2085   TargetSP target_sp(GetSP());
2086   if (target_sp) {
2087     Address addr;
2088
2089     if (base_addr.get())
2090       addr = *base_addr.get();
2091
2092     const bool data_from_file = true;
2093
2094     sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
2095         target_sp->GetArchitecture(), nullptr, flavor_string, addr, buf, size,
2096         UINT32_MAX, data_from_file));
2097   }
2098
2099   return sb_instructions;
2100 }
2101
2102 lldb::SBInstructionList SBTarget::GetInstructions(lldb::addr_t base_addr,
2103                                                   const void *buf,
2104                                                   size_t size) {
2105   LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions,
2106                     (lldb::addr_t, const void *, size_t), base_addr, buf, size);
2107
2108   return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), nullptr, buf,
2109                                    size);
2110 }
2111
2112 lldb::SBInstructionList
2113 SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr,
2114                                     const char *flavor_string, const void *buf,
2115                                     size_t size) {
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);
2120
2121   return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string,
2122                                    buf, size);
2123 }
2124
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,
2129                      section_base_addr);
2130
2131   SBError sb_error;
2132   TargetSP target_sp(GetSP());
2133   if (target_sp) {
2134     if (!section.IsValid()) {
2135       sb_error.SetErrorStringWithFormat("invalid section");
2136     } else {
2137       SectionSP section_sp(section.GetSP());
2138       if (section_sp) {
2139         if (section_sp->IsThreadSpecific()) {
2140           sb_error.SetErrorString(
2141               "thread specific sections are not yet supported");
2142         } else {
2143           ProcessSP process_sp(target_sp->GetProcessSP());
2144           if (target_sp->SetSectionLoadAddress(section_sp, section_base_addr)) {
2145             ModuleSP module_sp(section_sp->GetModule());
2146             if (module_sp) {
2147               ModuleList module_list;
2148               module_list.Append(module_sp);
2149               target_sp->ModulesDidLoad(module_list);
2150             }
2151             // Flush info in the process (stack frames, etc)
2152             if (process_sp)
2153               process_sp->Flush();
2154           }
2155         }
2156       }
2157     }
2158   } else {
2159     sb_error.SetErrorString("invalid target");
2160   }
2161   return LLDB_RECORD_RESULT(sb_error);
2162 }
2163
2164 SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) {
2165   LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress,
2166                      (lldb::SBSection), section);
2167
2168   SBError sb_error;
2169
2170   TargetSP target_sp(GetSP());
2171   if (target_sp) {
2172     if (!section.IsValid()) {
2173       sb_error.SetErrorStringWithFormat("invalid section");
2174     } else {
2175       SectionSP section_sp(section.GetSP());
2176       if (section_sp) {
2177         ProcessSP process_sp(target_sp->GetProcessSP());
2178         if (target_sp->SetSectionUnloaded(section_sp)) {
2179           ModuleSP module_sp(section_sp->GetModule());
2180           if (module_sp) {
2181             ModuleList module_list;
2182             module_list.Append(module_sp);
2183             target_sp->ModulesDidUnload(module_list, false);
2184           }
2185           // Flush info in the process (stack frames, etc)
2186           if (process_sp)
2187             process_sp->Flush();
2188         }
2189       } else {
2190         sb_error.SetErrorStringWithFormat("invalid section");
2191       }
2192     }
2193   } else {
2194     sb_error.SetErrorStringWithFormat("invalid target");
2195   }
2196   return LLDB_RECORD_RESULT(sb_error);
2197 }
2198
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);
2203
2204   SBError sb_error;
2205
2206   TargetSP target_sp(GetSP());
2207   if (target_sp) {
2208     ModuleSP module_sp(module.GetSP());
2209     if (module_sp) {
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.
2214         if (changed) {
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());
2220           if (process_sp)
2221             process_sp->Flush();
2222         }
2223       }
2224     } else {
2225       sb_error.SetErrorStringWithFormat("invalid module");
2226     }
2227
2228   } else {
2229     sb_error.SetErrorStringWithFormat("invalid target");
2230   }
2231   return LLDB_RECORD_RESULT(sb_error);
2232 }
2233
2234 SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) {
2235   LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress,
2236                      (lldb::SBModule), module);
2237
2238   SBError sb_error;
2239
2240   char path[PATH_MAX];
2241   TargetSP target_sp(GetSP());
2242   if (target_sp) {
2243     ModuleSP module_sp(module.GetSP());
2244     if (module_sp) {
2245       ObjectFile *objfile = module_sp->GetObjectFile();
2246       if (objfile) {
2247         SectionList *section_list = objfile->GetSectionList();
2248         if (section_list) {
2249           ProcessSP process_sp(target_sp->GetProcessSP());
2250
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));
2255             if (section_sp)
2256               changed |= target_sp->SetSectionUnloaded(section_sp);
2257           }
2258           if (changed) {
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());
2264             if (process_sp)
2265               process_sp->Flush();
2266           }
2267         } else {
2268           module_sp->GetFileSpec().GetPath(path, sizeof(path));
2269           sb_error.SetErrorStringWithFormat("no sections in object file '%s'",
2270                                             path);
2271         }
2272       } else {
2273         module_sp->GetFileSpec().GetPath(path, sizeof(path));
2274         sb_error.SetErrorStringWithFormat("no object file for module '%s'",
2275                                           path);
2276       }
2277     } else {
2278       sb_error.SetErrorStringWithFormat("invalid module");
2279     }
2280   } else {
2281     sb_error.SetErrorStringWithFormat("invalid target");
2282   }
2283   return LLDB_RECORD_RESULT(sb_error);
2284 }
2285
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);
2290
2291   SBSymbolContextList sb_sc_list;
2292   if (name && name[0]) {
2293     TargetSP target_sp(GetSP());
2294     if (target_sp) {
2295       bool append = true;
2296       target_sp->GetImages().FindSymbolsWithNameAndType(
2297           ConstString(name), symbol_type, *sb_sc_list, append);
2298     }
2299   }
2300   return LLDB_RECORD_RESULT(sb_sc_list);
2301 }
2302
2303 lldb::SBValue SBTarget::EvaluateExpression(const char *expr) {
2304   LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
2305                      (const char *), expr);
2306
2307   TargetSP target_sp(GetSP());
2308   if (!target_sp)
2309     return LLDB_RECORD_RESULT(SBValue());
2310
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));
2317 }
2318
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,
2323                      options);
2324
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;
2330   if (target_sp) {
2331     if (expr == nullptr || expr[0] == '\0') {
2332       return LLDB_RECORD_RESULT(expr_result);
2333     }
2334
2335     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
2336     ExecutionContext exe_ctx(m_opaque_sp.get());
2337
2338
2339     frame = exe_ctx.GetFramePtr();
2340     Target *target = exe_ctx.GetTargetPtr();
2341
2342     if (target) {
2343 #ifdef LLDB_CONFIGURATION_DEBUG
2344       StreamString frame_description;
2345       if (frame)
2346         frame->DumpUsingSettingsFormat(&frame_description);
2347       llvm::PrettyStackTraceFormat stack_trace(
2348           "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = "
2349           "%u) %s",
2350           expr, options.GetFetchDynamicValue(),
2351           frame_description.GetString().str().c_str());
2352 #endif
2353       target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
2354
2355       expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
2356     }
2357   }
2358   if (expr_log)
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);
2363 }
2364
2365 lldb::addr_t SBTarget::GetStackRedZoneSize() {
2366   LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBTarget, GetStackRedZoneSize);
2367
2368   TargetSP target_sp(GetSP());
2369   if (target_sp) {
2370     ABISP abi_sp;
2371     ProcessSP process_sp(target_sp->GetProcessSP());
2372     if (process_sp)
2373       abi_sp = process_sp->GetABI();
2374     else
2375       abi_sp = ABI::FindPlugin(ProcessSP(), target_sp->GetArchitecture());
2376     if (abi_sp)
2377       return abi_sp->GetRedZoneSize();
2378   }
2379   return 0;
2380 }
2381
2382 lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
2383   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo);
2384
2385   lldb::SBLaunchInfo launch_info(nullptr);
2386   TargetSP target_sp(GetSP());
2387   if (target_sp)
2388     launch_info.set_ref(m_opaque_sp->GetProcessLaunchInfo());
2389   return LLDB_RECORD_RESULT(launch_info);
2390 }
2391
2392 void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) {
2393   LLDB_RECORD_METHOD(void, SBTarget, SetLaunchInfo,
2394                      (const lldb::SBLaunchInfo &), launch_info);
2395
2396   TargetSP target_sp(GetSP());
2397   if (target_sp)
2398     m_opaque_sp->SetProcessLaunchInfo(launch_info.ref());
2399 }
2400
2401 namespace lldb_private {
2402 namespace repro {
2403
2404 template <>
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,
2421                               ());
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,
2458                        (lldb::addr_t));
2459   LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress,
2460                        (lldb::addr_t));
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,
2599                        (uint32_t));
2600   LLDB_REGISTER_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule));
2601   LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBTarget, GetBroadcaster,
2602                              ());
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,
2612                        (lldb::BasicType));
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,
2619                        (const char *));
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,
2628                        (lldb::SBSection));
2629   LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress,
2630                        (lldb::SBModule, int64_t));
2631   LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress,
2632                        (lldb::SBModule));
2633   LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols,
2634                        (const char *, lldb::SymbolType));
2635   LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
2636                        (const char *));
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 &));
2643 }
2644
2645 }
2646 }