LLDB  mainline
SBTarget.cpp
Go to the documentation of this file.
1 //===-- SBTarget.cpp ------------------------------------------------------===//
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/SBEnvironment.h"
17 #include "lldb/API/SBEvent.h"
19 #include "lldb/API/SBFileSpec.h"
20 #include "lldb/API/SBListener.h"
21 #include "lldb/API/SBModule.h"
22 #include "lldb/API/SBModuleSpec.h"
23 #include "lldb/API/SBProcess.h"
25 #include "lldb/API/SBStream.h"
26 #include "lldb/API/SBStringList.h"
29 #include "lldb/API/SBTrace.h"
34 #include "lldb/Core/Address.h"
36 #include "lldb/Core/Debugger.h"
37 #include "lldb/Core/Disassembler.h"
38 #include "lldb/Core/Module.h"
39 #include "lldb/Core/ModuleSpec.h"
40 #include "lldb/Core/SearchFilter.h"
41 #include "lldb/Core/Section.h"
46 #include "lldb/Host/Host.h"
47 #include "lldb/Symbol/DeclVendor.h"
48 #include "lldb/Symbol/ObjectFile.h"
49 #include "lldb/Symbol/SymbolFile.h"
51 #include "lldb/Symbol/TypeSystem.h"
53 #include "lldb/Target/ABI.h"
54 #include "lldb/Target/Language.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"
65 
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 static Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) {
77  std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex());
78 
79  auto process_sp = target.GetProcessSP();
80  if (process_sp) {
81  const auto state = process_sp->GetState();
82  if (process_sp->IsAlive() && state == eStateConnected) {
83  // If we are already connected, then we have already specified the
84  // listener, so if a valid listener is supplied, we need to error out to
85  // let the client know.
86  if (attach_info.GetListener())
87  return Status("process is connected and already has a listener, pass "
88  "empty listener");
89  }
90  }
91 
92  return target.Attach(attach_info, nullptr);
93 }
94 
95 // SBTarget constructor
96 SBTarget::SBTarget() : m_opaque_sp() {
98 }
99 
100 SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) {
102 }
103 
104 SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) {
105  LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &), target_sp);
106 }
107 
110  SBTarget, operator=,(const lldb::SBTarget &), rhs);
111 
112  if (this != &rhs)
113  m_opaque_sp = rhs.m_opaque_sp;
114  return LLDB_RECORD_RESULT(*this);
115 }
116 
117 // Destructor
118 SBTarget::~SBTarget() = default;
119 
122  (const lldb::SBEvent &), event);
123 
124  return Target::TargetEventData::GetEventDataFromEvent(event.get()) != nullptr;
125 }
126 
129  (const lldb::SBEvent &), event);
130 
131  return LLDB_RECORD_RESULT(
132  Target::TargetEventData::GetTargetFromEvent(event.get()));
133 }
134 
137  (const lldb::SBEvent &), event);
138 
139  const ModuleList module_list =
140  Target::TargetEventData::GetModuleListFromEvent(event.get());
141  return module_list.GetSize();
142 }
143 
145  const SBEvent &event) {
147  (const uint32_t, const lldb::SBEvent &), idx,
148  event);
149 
150  const ModuleList module_list =
151  Target::TargetEventData::GetModuleListFromEvent(event.get());
152  return LLDB_RECORD_RESULT(SBModule(module_list.GetModuleAtIndex(idx)));
153 }
154 
158 
159  return Target::GetStaticBroadcasterClass().AsCString();
160 }
161 
162 bool SBTarget::IsValid() const {
164  return this->operator bool();
165 }
166 SBTarget::operator bool() const {
167  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, operator bool);
168 
169  return m_opaque_sp.get() != nullptr && m_opaque_sp->IsValid();
170 }
171 
174 
175  SBProcess sb_process;
176  ProcessSP process_sp;
177  TargetSP target_sp(GetSP());
178  if (target_sp) {
179  process_sp = target_sp->GetProcessSP();
180  sb_process.SetSP(process_sp);
181  }
182 
183  return LLDB_RECORD_RESULT(sb_process);
184 }
185 
188 
189  TargetSP target_sp(GetSP());
190  if (!target_sp)
191  return LLDB_RECORD_RESULT(SBPlatform());
192 
193  SBPlatform platform;
194  platform.m_opaque_sp = target_sp->GetPlatform();
195 
196  return LLDB_RECORD_RESULT(platform);
197 }
198 
201 
202  SBDebugger debugger;
203  TargetSP target_sp(GetSP());
204  if (target_sp)
205  debugger.reset(target_sp->GetDebugger().shared_from_this());
206  return LLDB_RECORD_RESULT(debugger);
207 }
208 
211 
212  SBStructuredData data;
213  TargetSP target_sp(GetSP());
214  if (!target_sp)
215  return LLDB_RECORD_RESULT(data);
216  std::string json_str =
217  llvm::formatv("{0:2}",
218  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
219  target_sp.get())).str();
220  data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
221  return LLDB_RECORD_RESULT(data);
222 }
223 
226 
227  TargetSP target_sp(GetSP());
228  if (!target_sp)
229  return;
230  return DebuggerStats::SetCollectingStats(v);
231 }
232 
235 
236  TargetSP target_sp(GetSP());
237  if (!target_sp)
238  return false;
239  return DebuggerStats::GetCollectingStats();
240 }
241 
242 SBProcess SBTarget::LoadCore(const char *core_file) {
244  core_file);
245 
246  lldb::SBError error; // Ignored
247  return LLDB_RECORD_RESULT(LoadCore(core_file, error));
248 }
249 
252  (const char *, lldb::SBError &), core_file, error);
253 
254  SBProcess sb_process;
255  TargetSP target_sp(GetSP());
256  if (target_sp) {
257  FileSpec filespec(core_file);
258  FileSystem::Instance().Resolve(filespec);
259  ProcessSP process_sp(target_sp->CreateProcess(
260  target_sp->GetDebugger().GetListener(), "", &filespec, false));
261  if (process_sp) {
262  error.SetError(process_sp->LoadCore());
263  if (error.Success())
264  sb_process.SetSP(process_sp);
265  } else {
266  error.SetErrorString("Failed to create the process");
267  }
268  } else {
269  error.SetErrorString("SBTarget is invalid");
270  }
271  return LLDB_RECORD_RESULT(sb_process);
272 }
273 
274 SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp,
275  const char *working_directory) {
277  (const char **, const char **, const char *), argv, envp,
278  working_directory);
279 
280  TargetSP target_sp = GetSP();
281  if (!target_sp)
282  return LLDB_RECORD_RESULT(SBProcess());
283 
284  SBLaunchInfo launch_info = GetLaunchInfo();
285 
286  if (Module *exe_module = target_sp->GetExecutableModulePointer())
287  launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(),
288  /*add_as_first_arg*/ true);
289  if (argv)
290  launch_info.SetArguments(argv, /*append*/ true);
291  if (envp)
292  launch_info.SetEnvironmentEntries(envp, /*append*/ false);
293  if (working_directory)
294  launch_info.SetWorkingDirectory(working_directory);
295 
296  SBError error;
297  return LLDB_RECORD_RESULT(Launch(launch_info, error));
298 }
299 
302 
303  SBError sb_error;
304  TargetSP target_sp(GetSP());
305  if (target_sp) {
306  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
307  sb_error.ref() = target_sp->Install(nullptr);
308  }
309  return LLDB_RECORD_RESULT(sb_error);
310 }
311 
312 SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
313  char const **envp, const char *stdin_path,
314  const char *stdout_path, const char *stderr_path,
315  const char *working_directory,
316  uint32_t launch_flags, // See LaunchFlags
317  bool stop_at_entry, lldb::SBError &error) {
319  (lldb::SBListener &, const char **, const char **,
320  const char *, const char *, const char *, const char *,
321  uint32_t, bool, lldb::SBError &),
322  listener, argv, envp, stdin_path, stdout_path, stderr_path,
323  working_directory, launch_flags, stop_at_entry, error);
324 
325  SBProcess sb_process;
326  ProcessSP process_sp;
327  TargetSP target_sp(GetSP());
328 
329  if (target_sp) {
330  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
331 
332  if (stop_at_entry)
333  launch_flags |= eLaunchFlagStopAtEntry;
334 
335  if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
336  launch_flags |= eLaunchFlagDisableASLR;
337 
338  StateType state = eStateInvalid;
339  process_sp = target_sp->GetProcessSP();
340  if (process_sp) {
341  state = process_sp->GetState();
342 
343  if (process_sp->IsAlive() && state != eStateConnected) {
344  if (state == eStateAttaching)
345  error.SetErrorString("process attach is in progress");
346  else
347  error.SetErrorString("a process is already being debugged");
348  return LLDB_RECORD_RESULT(sb_process);
349  }
350  }
351 
352  if (state == eStateConnected) {
353  // If we are already connected, then we have already specified the
354  // listener, so if a valid listener is supplied, we need to error out to
355  // let the client know.
356  if (listener.IsValid()) {
357  error.SetErrorString("process is connected and already has a listener, "
358  "pass empty listener");
359  return LLDB_RECORD_RESULT(sb_process);
360  }
361  }
362 
363  if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
364  launch_flags |= eLaunchFlagDisableSTDIO;
365 
366  ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path),
367  FileSpec(stderr_path),
368  FileSpec(working_directory), launch_flags);
369 
370  Module *exe_module = target_sp->GetExecutableModulePointer();
371  if (exe_module)
372  launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
373  if (argv) {
374  launch_info.GetArguments().AppendArguments(argv);
375  } else {
376  auto default_launch_info = target_sp->GetProcessLaunchInfo();
377  launch_info.GetArguments().AppendArguments(
378  default_launch_info.GetArguments());
379  }
380  if (envp) {
381  launch_info.GetEnvironment() = Environment(envp);
382  } else {
383  auto default_launch_info = target_sp->GetProcessLaunchInfo();
384  launch_info.GetEnvironment() = default_launch_info.GetEnvironment();
385  }
386 
387  if (listener.IsValid())
388  launch_info.SetListener(listener.GetSP());
389 
390  error.SetError(target_sp->Launch(launch_info, nullptr));
391 
392  sb_process.SetSP(target_sp->GetProcessSP());
393  } else {
394  error.SetErrorString("SBTarget is invalid");
395  }
396 
397  return LLDB_RECORD_RESULT(sb_process);
398 }
399 
402  (lldb::SBLaunchInfo &, lldb::SBError &), sb_launch_info,
403  error);
404 
405 
406  SBProcess sb_process;
407  TargetSP target_sp(GetSP());
408 
409  if (target_sp) {
410  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
411  StateType state = eStateInvalid;
412  {
413  ProcessSP process_sp = target_sp->GetProcessSP();
414  if (process_sp) {
415  state = process_sp->GetState();
416 
417  if (process_sp->IsAlive() && state != eStateConnected) {
418  if (state == eStateAttaching)
419  error.SetErrorString("process attach is in progress");
420  else
421  error.SetErrorString("a process is already being debugged");
422  return LLDB_RECORD_RESULT(sb_process);
423  }
424  }
425  }
426 
427  lldb_private::ProcessLaunchInfo launch_info = sb_launch_info.ref();
428 
429  if (!launch_info.GetExecutableFile()) {
430  Module *exe_module = target_sp->GetExecutableModulePointer();
431  if (exe_module)
432  launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
433  }
434 
435  const ArchSpec &arch_spec = target_sp->GetArchitecture();
436  if (arch_spec.IsValid())
437  launch_info.GetArchitecture() = arch_spec;
438 
439  error.SetError(target_sp->Launch(launch_info, nullptr));
440  sb_launch_info.set_ref(launch_info);
441  sb_process.SetSP(target_sp->GetProcessSP());
442  } else {
443  error.SetErrorString("SBTarget is invalid");
444  }
445 
446  return LLDB_RECORD_RESULT(sb_process);
447 }
448 
451  (lldb::SBAttachInfo &, lldb::SBError &), sb_attach_info,
452  error);
453 
454  SBProcess sb_process;
455  TargetSP target_sp(GetSP());
456 
457  if (target_sp) {
458  ProcessAttachInfo &attach_info = sb_attach_info.ref();
459  if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid()) {
460  PlatformSP platform_sp = target_sp->GetPlatform();
461  // See if we can pre-verify if a process exists or not
462  if (platform_sp && platform_sp->IsConnected()) {
463  lldb::pid_t attach_pid = attach_info.GetProcessID();
464  ProcessInstanceInfo instance_info;
465  if (platform_sp->GetProcessInfo(attach_pid, instance_info)) {
466  attach_info.SetUserID(instance_info.GetEffectiveUserID());
467  } else {
468  error.ref().SetErrorStringWithFormat(
469  "no process found with process ID %" PRIu64, attach_pid);
470  return LLDB_RECORD_RESULT(sb_process);
471  }
472  }
473  }
474  error.SetError(AttachToProcess(attach_info, *target_sp));
475  if (error.Success())
476  sb_process.SetSP(target_sp->GetProcessSP());
477  } else {
478  error.SetErrorString("SBTarget is invalid");
479  }
480 
481  return LLDB_RECORD_RESULT(sb_process);
482 }
483 
485  SBListener &listener,
486  lldb::pid_t pid, // The process ID to attach to
487  SBError &error // An error explaining what went wrong if attach fails
488 ) {
491  listener, pid, error);
492 
493  SBProcess sb_process;
494  TargetSP target_sp(GetSP());
495 
496  if (target_sp) {
497  ProcessAttachInfo attach_info;
498  attach_info.SetProcessID(pid);
499  if (listener.IsValid())
500  attach_info.SetListener(listener.GetSP());
501 
502  ProcessInstanceInfo instance_info;
503  if (target_sp->GetPlatform()->GetProcessInfo(pid, instance_info))
504  attach_info.SetUserID(instance_info.GetEffectiveUserID());
505 
506  error.SetError(AttachToProcess(attach_info, *target_sp));
507  if (error.Success())
508  sb_process.SetSP(target_sp->GetProcessSP());
509  } else
510  error.SetErrorString("SBTarget is invalid");
511 
512  return LLDB_RECORD_RESULT(sb_process);
513 }
514 
516  SBListener &listener,
517  const char *name, // basename of process to attach to
518  bool wait_for, // if true wait for a new instance of "name" to be launched
519  SBError &error // An error explaining what went wrong if attach fails
520 ) {
522  (lldb::SBListener &, const char *, bool, lldb::SBError &),
523  listener, name, wait_for, error);
524 
525  SBProcess sb_process;
526  TargetSP target_sp(GetSP());
527 
528  if (name && target_sp) {
529  ProcessAttachInfo attach_info;
530  attach_info.GetExecutableFile().SetFile(name, FileSpec::Style::native);
531  attach_info.SetWaitForLaunch(wait_for);
532  if (listener.IsValid())
533  attach_info.SetListener(listener.GetSP());
534 
535  error.SetError(AttachToProcess(attach_info, *target_sp));
536  if (error.Success())
537  sb_process.SetSP(target_sp->GetProcessSP());
538  } else
539  error.SetErrorString("SBTarget is invalid");
540 
541  return LLDB_RECORD_RESULT(sb_process);
542 }
543 
545  const char *plugin_name,
546  SBError &error) {
549  (lldb::SBListener &, const char *, const char *, lldb::SBError &),
550  listener, url, plugin_name, error);
551 
552  SBProcess sb_process;
553  ProcessSP process_sp;
554  TargetSP target_sp(GetSP());
555 
556  if (target_sp) {
557  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
558  if (listener.IsValid())
559  process_sp =
560  target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, nullptr,
561  true);
562  else
563  process_sp = target_sp->CreateProcess(
564  target_sp->GetDebugger().GetListener(), plugin_name, nullptr, true);
565 
566  if (process_sp) {
567  sb_process.SetSP(process_sp);
568  error.SetError(process_sp->ConnectRemote(url));
569  } else {
570  error.SetErrorString("unable to create lldb_private::Process");
571  }
572  } else {
573  error.SetErrorString("SBTarget is invalid");
574  }
575 
576  return LLDB_RECORD_RESULT(sb_process);
577 }
578 
581 
582  SBFileSpec exe_file_spec;
583  TargetSP target_sp(GetSP());
584  if (target_sp) {
585  Module *exe_module = target_sp->GetExecutableModulePointer();
586  if (exe_module)
587  exe_file_spec.SetFileSpec(exe_module->GetFileSpec());
588  }
589 
590  return LLDB_RECORD_RESULT(exe_file_spec);
591 }
592 
593 bool SBTarget::operator==(const SBTarget &rhs) const {
594  LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator==,(const lldb::SBTarget &),
595  rhs);
596 
597  return m_opaque_sp.get() == rhs.m_opaque_sp.get();
598 }
599 
600 bool SBTarget::operator!=(const SBTarget &rhs) const {
601  LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator!=,(const lldb::SBTarget &),
602  rhs);
603 
604  return m_opaque_sp.get() != rhs.m_opaque_sp.get();
605 }
606 
607 lldb::TargetSP SBTarget::GetSP() const { return m_opaque_sp; }
608 
609 void SBTarget::SetSP(const lldb::TargetSP &target_sp) {
610  m_opaque_sp = target_sp;
611 }
612 
615  (lldb::addr_t), vm_addr);
616 
617  lldb::SBAddress sb_addr;
618  Address &addr = sb_addr.ref();
619  TargetSP target_sp(GetSP());
620  if (target_sp) {
621  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
622  if (target_sp->ResolveLoadAddress(vm_addr, addr))
623  return LLDB_RECORD_RESULT(sb_addr);
624  }
625 
626  // We have a load address that isn't in a section, just return an address
627  // with the offset filled in (the address) and the section set to NULL
628  addr.SetRawAddress(vm_addr);
629  return LLDB_RECORD_RESULT(sb_addr);
630 }
631 
634  (lldb::addr_t), file_addr);
635 
636  lldb::SBAddress sb_addr;
637  Address &addr = sb_addr.ref();
638  TargetSP target_sp(GetSP());
639  if (target_sp) {
640  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
641  if (target_sp->ResolveFileAddress(file_addr, addr))
642  return LLDB_RECORD_RESULT(sb_addr);
643  }
644 
645  addr.SetRawAddress(file_addr);
646  return LLDB_RECORD_RESULT(sb_addr);
647 }
648 
650  lldb::addr_t vm_addr) {
652  (uint32_t, lldb::addr_t), stop_id, vm_addr);
653 
654  lldb::SBAddress sb_addr;
655  Address &addr = sb_addr.ref();
656  TargetSP target_sp(GetSP());
657  if (target_sp) {
658  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
659  if (target_sp->ResolveLoadAddress(vm_addr, addr))
660  return LLDB_RECORD_RESULT(sb_addr);
661  }
662 
663  // We have a load address that isn't in a section, just return an address
664  // with the offset filled in (the address) and the section set to NULL
665  addr.SetRawAddress(vm_addr);
666  return LLDB_RECORD_RESULT(sb_addr);
667 }
668 
671  uint32_t resolve_scope) {
674  (const lldb::SBAddress &, uint32_t), addr, resolve_scope);
675 
676  SBSymbolContext sc;
677  SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
678  if (addr.IsValid()) {
679  TargetSP target_sp(GetSP());
680  if (target_sp)
681  target_sp->GetImages().ResolveSymbolContextForAddress(addr.ref(), scope,
682  sc.ref());
683  }
684  return LLDB_RECORD_RESULT(sc);
685 }
686 
687 size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size,
688  lldb::SBError &error) {
690  (const lldb::SBAddress, void *, size_t, lldb::SBError &),
691  addr, buf, size, error);
692 
693  SBError sb_error;
694  size_t bytes_read = 0;
695  TargetSP target_sp(GetSP());
696  if (target_sp) {
697  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
698  bytes_read =
699  target_sp->ReadMemory(addr.ref(), buf, size, sb_error.ref(), true);
700  } else {
701  sb_error.SetErrorString("invalid target");
702  }
703 
704  return bytes_read;
705 }
706 
708  uint32_t line) {
710  (const char *, uint32_t), file, line);
711 
712  return LLDB_RECORD_RESULT(
713  SBBreakpoint(BreakpointCreateByLocation(SBFileSpec(file, false), line)));
714 }
715 
718  uint32_t line) {
720  (const lldb::SBFileSpec &, uint32_t), sb_file_spec, line);
721 
722  return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0));
723 }
724 
727  uint32_t line, lldb::addr_t offset) {
730  sb_file_spec, line, offset);
731 
732  SBFileSpecList empty_list;
733  return LLDB_RECORD_RESULT(
734  BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list));
735 }
736 
739  uint32_t line, lldb::addr_t offset,
740  SBFileSpecList &sb_module_list) {
744  sb_file_spec, line, offset, sb_module_list);
745 
746  return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0,
747  offset, sb_module_list));
748 }
749 
751  const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
752  lldb::addr_t offset, SBFileSpecList &sb_module_list) {
756  sb_file_spec, line, column, offset, sb_module_list);
757 
758  SBBreakpoint sb_bp;
759  TargetSP target_sp(GetSP());
760  if (target_sp && line != 0) {
761  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
762 
763  const LazyBool check_inlines = eLazyBoolCalculate;
764  const LazyBool skip_prologue = eLazyBoolCalculate;
765  const bool internal = false;
766  const bool hardware = false;
767  const LazyBool move_to_nearest_code = eLazyBoolCalculate;
768  const FileSpecList *module_list = nullptr;
769  if (sb_module_list.GetSize() > 0) {
770  module_list = sb_module_list.get();
771  }
772  sb_bp = target_sp->CreateBreakpoint(
773  module_list, *sb_file_spec, line, column, offset, check_inlines,
774  skip_prologue, internal, hardware, move_to_nearest_code);
775  }
776 
777  return LLDB_RECORD_RESULT(sb_bp);
778 }
779 
781  const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
782  lldb::addr_t offset, SBFileSpecList &sb_module_list,
783  bool move_to_nearest_code) {
787  sb_file_spec, line, column, offset, sb_module_list,
788  move_to_nearest_code);
789 
790  SBBreakpoint sb_bp;
791  TargetSP target_sp(GetSP());
792  if (target_sp && line != 0) {
793  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
794 
795  const LazyBool check_inlines = eLazyBoolCalculate;
796  const LazyBool skip_prologue = eLazyBoolCalculate;
797  const bool internal = false;
798  const bool hardware = false;
799  const FileSpecList *module_list = nullptr;
800  if (sb_module_list.GetSize() > 0) {
801  module_list = sb_module_list.get();
802  }
803  sb_bp = target_sp->CreateBreakpoint(
804  module_list, *sb_file_spec, line, column, offset, check_inlines,
805  skip_prologue, internal, hardware,
806  move_to_nearest_code ? eLazyBoolYes : eLazyBoolNo);
807  }
808 
809  return LLDB_RECORD_RESULT(sb_bp);
810 }
811 
813  const char *module_name) {
815  (const char *, const char *), symbol_name, module_name);
816 
817  SBBreakpoint sb_bp;
818  TargetSP target_sp(GetSP());
819  if (target_sp.get()) {
820  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
821 
822  const bool internal = false;
823  const bool hardware = false;
824  const LazyBool skip_prologue = eLazyBoolCalculate;
825  const lldb::addr_t offset = 0;
826  if (module_name && module_name[0]) {
827  FileSpecList module_spec_list;
828  module_spec_list.Append(FileSpec(module_name));
829  sb_bp = target_sp->CreateBreakpoint(
830  &module_spec_list, nullptr, symbol_name, eFunctionNameTypeAuto,
831  eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
832  } else {
833  sb_bp = target_sp->CreateBreakpoint(
834  nullptr, nullptr, symbol_name, eFunctionNameTypeAuto,
835  eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
836  }
837  }
838 
839  return LLDB_RECORD_RESULT(sb_bp);
840 }
841 
843 SBTarget::BreakpointCreateByName(const char *symbol_name,
844  const SBFileSpecList &module_list,
845  const SBFileSpecList &comp_unit_list) {
847  (const char *, const lldb::SBFileSpecList &,
848  const lldb::SBFileSpecList &),
849  symbol_name, module_list, comp_unit_list);
850 
851  lldb::FunctionNameType name_type_mask = eFunctionNameTypeAuto;
852  return LLDB_RECORD_RESULT(
853  BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown,
854  module_list, comp_unit_list));
855 }
856 
858  const char *symbol_name, uint32_t name_type_mask,
859  const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
861  (const char *, uint32_t, const lldb::SBFileSpecList &,
862  const lldb::SBFileSpecList &),
863  symbol_name, name_type_mask, module_list, comp_unit_list);
864 
865  return LLDB_RECORD_RESULT(
866  BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown,
867  module_list, comp_unit_list));
868 }
869 
871  const char *symbol_name, uint32_t name_type_mask,
872  LanguageType symbol_language, const SBFileSpecList &module_list,
873  const SBFileSpecList &comp_unit_list) {
875  (const char *, uint32_t, lldb::LanguageType,
876  const lldb::SBFileSpecList &,
877  const lldb::SBFileSpecList &),
878  symbol_name, name_type_mask, symbol_language, module_list,
879  comp_unit_list);
880 
881  SBBreakpoint sb_bp;
882  TargetSP target_sp(GetSP());
883  if (target_sp && symbol_name && symbol_name[0]) {
884  const bool internal = false;
885  const bool hardware = false;
886  const LazyBool skip_prologue = eLazyBoolCalculate;
887  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
888  FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
889  sb_bp = target_sp->CreateBreakpoint(module_list.get(), comp_unit_list.get(),
890  symbol_name, mask, symbol_language, 0,
891  skip_prologue, internal, hardware);
892  }
893 
894  return LLDB_RECORD_RESULT(sb_bp);
895 }
896 
898  const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
899  const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
902  (const char **, uint32_t, uint32_t, const lldb::SBFileSpecList &,
903  const lldb::SBFileSpecList &),
904  symbol_names, num_names, name_type_mask, module_list, comp_unit_list);
905 
907  symbol_names, num_names, name_type_mask, eLanguageTypeUnknown,
908  module_list, comp_unit_list));
909 }
910 
912  const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
913  LanguageType symbol_language, const SBFileSpecList &module_list,
914  const SBFileSpecList &comp_unit_list) {
916  (const char **, uint32_t, uint32_t, lldb::LanguageType,
917  const lldb::SBFileSpecList &,
918  const lldb::SBFileSpecList &),
919  symbol_names, num_names, name_type_mask, symbol_language,
920  module_list, comp_unit_list);
921 
923  symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 0,
924  module_list, comp_unit_list));
925 }
926 
928  const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
929  LanguageType symbol_language, lldb::addr_t offset,
930  const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
932  (const char **, uint32_t, uint32_t, lldb::LanguageType,
934  const lldb::SBFileSpecList &),
935  symbol_names, num_names, name_type_mask, symbol_language,
936  offset, module_list, comp_unit_list);
937 
938  SBBreakpoint sb_bp;
939  TargetSP target_sp(GetSP());
940  if (target_sp && num_names > 0) {
941  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
942  const bool internal = false;
943  const bool hardware = false;
944  FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
945  const LazyBool skip_prologue = eLazyBoolCalculate;
946  sb_bp = target_sp->CreateBreakpoint(
947  module_list.get(), comp_unit_list.get(), symbol_names, num_names, mask,
948  symbol_language, offset, skip_prologue, internal, hardware);
949  }
950 
951  return LLDB_RECORD_RESULT(sb_bp);
952 }
953 
954 SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
955  const char *module_name) {
957  (const char *, const char *), symbol_name_regex,
958  module_name);
959 
960  SBFileSpecList module_spec_list;
961  SBFileSpecList comp_unit_list;
962  if (module_name && module_name[0]) {
963  module_spec_list.Append(FileSpec(module_name));
964  }
965  return LLDB_RECORD_RESULT(
967  module_spec_list, comp_unit_list));
968 }
969 
971 SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
972  const SBFileSpecList &module_list,
973  const SBFileSpecList &comp_unit_list) {
975  (const char *, const lldb::SBFileSpecList &,
976  const lldb::SBFileSpecList &),
977  symbol_name_regex, module_list, comp_unit_list);
978 
980  symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list));
981 }
982 
984  const char *symbol_name_regex, LanguageType symbol_language,
985  const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
988  (const char *, lldb::LanguageType, const lldb::SBFileSpecList &,
989  const lldb::SBFileSpecList &),
990  symbol_name_regex, symbol_language, module_list, comp_unit_list);
991 
992 
993  SBBreakpoint sb_bp;
994  TargetSP target_sp(GetSP());
995  if (target_sp && symbol_name_regex && symbol_name_regex[0]) {
996  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
997  RegularExpression regexp((llvm::StringRef(symbol_name_regex)));
998  const bool internal = false;
999  const bool hardware = false;
1000  const LazyBool skip_prologue = eLazyBoolCalculate;
1001 
1002  sb_bp = target_sp->CreateFuncRegexBreakpoint(
1003  module_list.get(), comp_unit_list.get(), std::move(regexp),
1004  symbol_language, skip_prologue, internal, hardware);
1005  }
1006 
1007  return LLDB_RECORD_RESULT(sb_bp);
1008 }
1009 
1012  (lldb::addr_t), address);
1013 
1014  SBBreakpoint sb_bp;
1015  TargetSP target_sp(GetSP());
1016  if (target_sp) {
1017  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1018  const bool hardware = false;
1019  sb_bp = target_sp->CreateBreakpoint(address, false, hardware);
1020  }
1021 
1022  return LLDB_RECORD_RESULT(sb_bp);
1023 }
1024 
1027  (lldb::SBAddress &), sb_address);
1028 
1029  SBBreakpoint sb_bp;
1030  TargetSP target_sp(GetSP());
1031  if (!sb_address.IsValid()) {
1032  return LLDB_RECORD_RESULT(sb_bp);
1033  }
1034 
1035  if (target_sp) {
1036  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1037  const bool hardware = false;
1038  sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware);
1039  }
1040 
1041  return LLDB_RECORD_RESULT(sb_bp);
1042 }
1043 
1046  const lldb::SBFileSpec &source_file,
1047  const char *module_name) {
1050  (const char *, const lldb::SBFileSpec &, const char *),
1051  source_regex, source_file, module_name);
1052 
1053  SBFileSpecList module_spec_list;
1054 
1055  if (module_name && module_name[0]) {
1056  module_spec_list.Append(FileSpec(module_name));
1057  }
1058 
1059  SBFileSpecList source_file_list;
1060  if (source_file.IsValid()) {
1061  source_file_list.Append(source_file);
1062  }
1063 
1065  source_regex, module_spec_list, source_file_list));
1066 }
1067 
1069  const char *source_regex, const SBFileSpecList &module_list,
1070  const lldb::SBFileSpecList &source_file_list) {
1073  (const char *, const lldb::SBFileSpecList &,
1074  const lldb::SBFileSpecList &),
1075  source_regex, module_list, source_file_list);
1076 
1078  source_regex, module_list, source_file_list, SBStringList()));
1079 }
1080 
1082  const char *source_regex, const SBFileSpecList &module_list,
1083  const lldb::SBFileSpecList &source_file_list,
1084  const SBStringList &func_names) {
1087  (const char *, const lldb::SBFileSpecList &,
1088  const lldb::SBFileSpecList &, const lldb::SBStringList &),
1089  source_regex, module_list, source_file_list, func_names);
1090 
1091  SBBreakpoint sb_bp;
1092  TargetSP target_sp(GetSP());
1093  if (target_sp && source_regex && source_regex[0]) {
1094  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1095  const bool hardware = false;
1096  const LazyBool move_to_nearest_code = eLazyBoolCalculate;
1097  RegularExpression regexp((llvm::StringRef(source_regex)));
1098  std::unordered_set<std::string> func_names_set;
1099  for (size_t i = 0; i < func_names.GetSize(); i++) {
1100  func_names_set.insert(func_names.GetStringAtIndex(i));
1101  }
1102 
1103  sb_bp = target_sp->CreateSourceRegexBreakpoint(
1104  module_list.get(), source_file_list.get(), func_names_set,
1105  std::move(regexp), false, hardware, move_to_nearest_code);
1106  }
1107 
1108  return LLDB_RECORD_RESULT(sb_bp);
1109 }
1110 
1113  bool catch_bp, bool throw_bp) {
1115  (lldb::LanguageType, bool, bool), language, catch_bp,
1116  throw_bp);
1117 
1118  SBBreakpoint sb_bp;
1119  TargetSP target_sp(GetSP());
1120  if (target_sp) {
1121  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1122  const bool hardware = false;
1123  sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp,
1124  hardware);
1125  }
1126 
1127  return LLDB_RECORD_RESULT(sb_bp);
1128 }
1129 
1131  const char *class_name, SBStructuredData &extra_args,
1132  const SBFileSpecList &module_list, const SBFileSpecList &file_list,
1133  bool request_hardware) {
1136  (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &,
1137  const lldb::SBFileSpecList &, bool),
1138  class_name, extra_args, module_list, file_list, request_hardware);
1139 
1140  SBBreakpoint sb_bp;
1141  TargetSP target_sp(GetSP());
1142  if (target_sp) {
1143  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1144  Status error;
1145 
1146  StructuredData::ObjectSP obj_sp = extra_args.m_impl_up->GetObjectSP();
1147  sb_bp =
1148  target_sp->CreateScriptedBreakpoint(class_name,
1149  module_list.get(),
1150  file_list.get(),
1151  false, /* internal */
1152  request_hardware,
1153  obj_sp,
1154  &error);
1155  }
1156 
1157  return LLDB_RECORD_RESULT(sb_bp);
1158 }
1159 
1162 
1163  TargetSP target_sp(GetSP());
1164  if (target_sp) {
1165  // The breakpoint list is thread safe, no need to lock
1166  return target_sp->GetBreakpointList().GetSize();
1167  }
1168  return 0;
1169 }
1170 
1173  (uint32_t), idx);
1174 
1175  SBBreakpoint sb_breakpoint;
1176  TargetSP target_sp(GetSP());
1177  if (target_sp) {
1178  // The breakpoint list is thread safe, no need to lock
1179  sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
1180  }
1181  return LLDB_RECORD_RESULT(sb_breakpoint);
1182 }
1183 
1186  bp_id);
1187 
1188  bool result = false;
1189  TargetSP target_sp(GetSP());
1190  if (target_sp) {
1191  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1192  result = target_sp->RemoveBreakpointByID(bp_id);
1193  }
1194 
1195  return result;
1196 }
1197 
1200  (lldb::break_id_t), bp_id);
1201 
1202  SBBreakpoint sb_breakpoint;
1203  TargetSP target_sp(GetSP());
1204  if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) {
1205  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1206  sb_breakpoint = target_sp->GetBreakpointByID(bp_id);
1207  }
1208 
1209  return LLDB_RECORD_RESULT(sb_breakpoint);
1210 }
1211 
1212 bool SBTarget::FindBreakpointsByName(const char *name,
1213  SBBreakpointList &bkpts) {
1215  (const char *, lldb::SBBreakpointList &), name, bkpts);
1216 
1217  TargetSP target_sp(GetSP());
1218  if (target_sp) {
1219  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1220  llvm::Expected<std::vector<BreakpointSP>> expected_vector =
1221  target_sp->GetBreakpointList().FindBreakpointsByName(name);
1222  if (!expected_vector) {
1224  "invalid breakpoint name: {}",
1225  llvm::toString(expected_vector.takeError()));
1226  return false;
1227  }
1228  for (BreakpointSP bkpt_sp : *expected_vector) {
1229  bkpts.AppendByID(bkpt_sp->GetID());
1230  }
1231  }
1232  return true;
1233 }
1234 
1237  names);
1238 
1239  names.Clear();
1240 
1241  TargetSP target_sp(GetSP());
1242  if (target_sp) {
1243  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1244 
1245  std::vector<std::string> name_vec;
1246  target_sp->GetBreakpointNames(name_vec);
1247  for (auto name : name_vec)
1248  names.AppendString(name.c_str());
1249  }
1250 }
1251 
1252 void SBTarget::DeleteBreakpointName(const char *name) {
1253  LLDB_RECORD_METHOD(void, SBTarget, DeleteBreakpointName, (const char *),
1254  name);
1255 
1256  TargetSP target_sp(GetSP());
1257  if (target_sp) {
1258  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1259  target_sp->DeleteBreakpointName(ConstString(name));
1260  }
1261 }
1262 
1265 
1266  TargetSP target_sp(GetSP());
1267  if (target_sp) {
1268  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1269  target_sp->EnableAllowedBreakpoints();
1270  return true;
1271  }
1272  return false;
1273 }
1274 
1277 
1278  TargetSP target_sp(GetSP());
1279  if (target_sp) {
1280  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1281  target_sp->DisableAllowedBreakpoints();
1282  return true;
1283  }
1284  return false;
1285 }
1286 
1289 
1290  TargetSP target_sp(GetSP());
1291  if (target_sp) {
1292  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1293  target_sp->RemoveAllowedBreakpoints();
1294  return true;
1295  }
1296  return false;
1297 }
1298 
1300  SBBreakpointList &new_bps) {
1303  source_file, new_bps);
1304 
1305  SBStringList empty_name_list;
1306  return LLDB_RECORD_RESULT(
1307  BreakpointsCreateFromFile(source_file, empty_name_list, new_bps));
1308 }
1309 
1311  SBStringList &matching_names,
1312  SBBreakpointList &new_bps) {
1316  source_file, matching_names, new_bps);
1317 
1318  SBError sberr;
1319  TargetSP target_sp(GetSP());
1320  if (!target_sp) {
1321  sberr.SetErrorString(
1322  "BreakpointCreateFromFile called with invalid target.");
1323  return LLDB_RECORD_RESULT(sberr);
1324  }
1325  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1326 
1327  BreakpointIDList bp_ids;
1328 
1329  std::vector<std::string> name_vector;
1330  size_t num_names = matching_names.GetSize();
1331  for (size_t i = 0; i < num_names; i++)
1332  name_vector.push_back(matching_names.GetStringAtIndex(i));
1333 
1334  sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(),
1335  name_vector, bp_ids);
1336  if (sberr.Fail())
1337  return LLDB_RECORD_RESULT(sberr);
1338 
1339  size_t num_bkpts = bp_ids.GetSize();
1340  for (size_t i = 0; i < num_bkpts; i++) {
1341  BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i);
1342  new_bps.AppendByID(bp_id.GetBreakpointID());
1343  }
1344  return LLDB_RECORD_RESULT(sberr);
1345 }
1346 
1349  (lldb::SBFileSpec &), dest_file);
1350 
1351  SBError sberr;
1352  TargetSP target_sp(GetSP());
1353  if (!target_sp) {
1354  sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
1355  return LLDB_RECORD_RESULT(sberr);
1356  }
1357  SBBreakpointList bkpt_list(*this);
1358  return LLDB_RECORD_RESULT(BreakpointsWriteToFile(dest_file, bkpt_list));
1359 }
1360 
1362  SBBreakpointList &bkpt_list,
1363  bool append) {
1366  dest_file, bkpt_list, append);
1367 
1368  SBError sberr;
1369  TargetSP target_sp(GetSP());
1370  if (!target_sp) {
1371  sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
1372  return LLDB_RECORD_RESULT(sberr);
1373  }
1374 
1375  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1376  BreakpointIDList bp_id_list;
1377  bkpt_list.CopyToBreakpointIDList(bp_id_list);
1378  sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(),
1379  bp_id_list, append);
1380  return LLDB_RECORD_RESULT(sberr);
1381 }
1382 
1385 
1386  TargetSP target_sp(GetSP());
1387  if (target_sp) {
1388  // The watchpoint list is thread safe, no need to lock
1389  return target_sp->GetWatchpointList().GetSize();
1390  }
1391  return 0;
1392 }
1393 
1396  (uint32_t), idx);
1397 
1398  SBWatchpoint sb_watchpoint;
1399  TargetSP target_sp(GetSP());
1400  if (target_sp) {
1401  // The watchpoint list is thread safe, no need to lock
1402  sb_watchpoint.SetSP(target_sp->GetWatchpointList().GetByIndex(idx));
1403  }
1404  return LLDB_RECORD_RESULT(sb_watchpoint);
1405 }
1406 
1409  wp_id);
1410 
1411 
1412  bool result = false;
1413  TargetSP target_sp(GetSP());
1414  if (target_sp) {
1415  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1416  std::unique_lock<std::recursive_mutex> lock;
1417  target_sp->GetWatchpointList().GetListMutex(lock);
1418  result = target_sp->RemoveWatchpointByID(wp_id);
1419  }
1420 
1421  return result;
1422 }
1423 
1426  (lldb::watch_id_t), wp_id);
1427 
1428 
1429  SBWatchpoint sb_watchpoint;
1430  lldb::WatchpointSP watchpoint_sp;
1431  TargetSP target_sp(GetSP());
1432  if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) {
1433  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1434  std::unique_lock<std::recursive_mutex> lock;
1435  target_sp->GetWatchpointList().GetListMutex(lock);
1436  watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id);
1437  sb_watchpoint.SetSP(watchpoint_sp);
1438  }
1439 
1440  return LLDB_RECORD_RESULT(sb_watchpoint);
1441 }
1442 
1444  bool read, bool write,
1445  SBError &error) {
1447  (lldb::addr_t, size_t, bool, bool, lldb::SBError &), addr,
1448  size, read, write, error);
1449 
1450  SBWatchpoint sb_watchpoint;
1451  lldb::WatchpointSP watchpoint_sp;
1452  TargetSP target_sp(GetSP());
1453  if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS &&
1454  size > 0) {
1455  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1456  uint32_t watch_type = 0;
1457  if (read)
1458  watch_type |= LLDB_WATCH_TYPE_READ;
1459  if (write)
1460  watch_type |= LLDB_WATCH_TYPE_WRITE;
1461  if (watch_type == 0) {
1462  error.SetErrorString(
1463  "Can't create a watchpoint that is neither read nor write.");
1464  return LLDB_RECORD_RESULT(sb_watchpoint);
1465  }
1466 
1467  // Target::CreateWatchpoint() is thread safe.
1468  Status cw_error;
1469  // This API doesn't take in a type, so we can't figure out what it is.
1470  CompilerType *type = nullptr;
1471  watchpoint_sp =
1472  target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
1473  error.SetError(cw_error);
1474  sb_watchpoint.SetSP(watchpoint_sp);
1475  }
1476 
1477  return LLDB_RECORD_RESULT(sb_watchpoint);
1478 }
1479 
1482 
1483  TargetSP target_sp(GetSP());
1484  if (target_sp) {
1485  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1486  std::unique_lock<std::recursive_mutex> lock;
1487  target_sp->GetWatchpointList().GetListMutex(lock);
1488  target_sp->EnableAllWatchpoints();
1489  return true;
1490  }
1491  return false;
1492 }
1493 
1496 
1497  TargetSP target_sp(GetSP());
1498  if (target_sp) {
1499  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1500  std::unique_lock<std::recursive_mutex> lock;
1501  target_sp->GetWatchpointList().GetListMutex(lock);
1502  target_sp->DisableAllWatchpoints();
1503  return true;
1504  }
1505  return false;
1506 }
1507 
1509  SBType type) {
1511  (const char *, lldb::SBAddress, lldb::SBType), name, addr,
1512  type);
1513 
1514  SBValue sb_value;
1515  lldb::ValueObjectSP new_value_sp;
1516  if (IsValid() && name && *name && addr.IsValid() && type.IsValid()) {
1517  lldb::addr_t load_addr(addr.GetLoadAddress(*this));
1518  ExecutionContext exe_ctx(
1520  CompilerType ast_type(type.GetSP()->GetCompilerType(true));
1521  new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr,
1522  exe_ctx, ast_type);
1523  }
1524  sb_value.SetSP(new_value_sp);
1525  return LLDB_RECORD_RESULT(sb_value);
1526 }
1527 
1529  lldb::SBType type) {
1531  (const char *, lldb::SBData, lldb::SBType), name, data,
1532  type);
1533 
1534  SBValue sb_value;
1535  lldb::ValueObjectSP new_value_sp;
1536  if (IsValid() && name && *name && data.IsValid() && type.IsValid()) {
1537  DataExtractorSP extractor(*data);
1538  ExecutionContext exe_ctx(
1540  CompilerType ast_type(type.GetSP()->GetCompilerType(true));
1541  new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor,
1542  exe_ctx, ast_type);
1543  }
1544  sb_value.SetSP(new_value_sp);
1545  return LLDB_RECORD_RESULT(sb_value);
1546 }
1547 
1549  const char *expr) {
1551  (const char *, const char *), name, expr);
1552 
1553  SBValue sb_value;
1554  lldb::ValueObjectSP new_value_sp;
1555  if (IsValid() && name && *name && expr && *expr) {
1556  ExecutionContext exe_ctx(
1558  new_value_sp =
1559  ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx);
1560  }
1561  sb_value.SetSP(new_value_sp);
1562  return LLDB_RECORD_RESULT(sb_value);
1563 }
1564 
1567 
1568  TargetSP target_sp(GetSP());
1569  if (target_sp) {
1570  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1571  std::unique_lock<std::recursive_mutex> lock;
1572  target_sp->GetWatchpointList().GetListMutex(lock);
1573  target_sp->RemoveAllWatchpoints();
1574  return true;
1575  }
1576  return false;
1577 }
1578 
1579 void SBTarget::AppendImageSearchPath(const char *from, const char *to,
1580  lldb::SBError &error) {
1582  (const char *, const char *, lldb::SBError &), from, to,
1583  error);
1584 
1585  TargetSP target_sp(GetSP());
1586  if (!target_sp)
1587  return error.SetErrorString("invalid target");
1588 
1589  llvm::StringRef srFrom = from, srTo = to;
1590  if (srFrom.empty())
1591  return error.SetErrorString("<from> path can't be empty");
1592  if (srTo.empty())
1593  return error.SetErrorString("<to> path can't be empty");
1594 
1595  target_sp->GetImageSearchPathList().Append(srFrom, srTo, true);
1596 }
1597 
1598 lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
1599  const char *uuid_cstr) {
1601  (const char *, const char *, const char *), path, triple,
1602  uuid_cstr);
1603 
1604  return LLDB_RECORD_RESULT(AddModule(path, triple, uuid_cstr, nullptr));
1605 }
1606 
1607 lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
1608  const char *uuid_cstr, const char *symfile) {
1610  (const char *, const char *, const char *, const char *),
1611  path, triple, uuid_cstr, symfile);
1612 
1613  lldb::SBModule sb_module;
1614  TargetSP target_sp(GetSP());
1615  if (target_sp) {
1616  ModuleSpec module_spec;
1617  if (path)
1618  module_spec.GetFileSpec().SetFile(path, FileSpec::Style::native);
1619 
1620  if (uuid_cstr)
1621  module_spec.GetUUID().SetFromStringRef(uuid_cstr);
1622 
1623  if (triple)
1624  module_spec.GetArchitecture() = Platform::GetAugmentedArchSpec(
1625  target_sp->GetPlatform().get(), triple);
1626  else
1627  module_spec.GetArchitecture() = target_sp->GetArchitecture();
1628 
1629  if (symfile)
1630  module_spec.GetSymbolFileSpec().SetFile(symfile, FileSpec::Style::native);
1631 
1632  sb_module.SetSP(target_sp->GetOrCreateModule(module_spec, true /* notify */));
1633  }
1634  return LLDB_RECORD_RESULT(sb_module);
1635 }
1636 
1639  (const lldb::SBModuleSpec &), module_spec);
1640 
1641  lldb::SBModule sb_module;
1642  TargetSP target_sp(GetSP());
1643  if (target_sp)
1644  sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up,
1645  true /* notify */));
1646  return LLDB_RECORD_RESULT(sb_module);
1647 }
1648 
1650  LLDB_RECORD_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &), module);
1651 
1652  TargetSP target_sp(GetSP());
1653  if (target_sp) {
1654  target_sp->GetImages().AppendIfNeeded(module.GetSP());
1655  return true;
1656  }
1657  return false;
1658 }
1659 
1662 
1663  uint32_t num = 0;
1664  TargetSP target_sp(GetSP());
1665  if (target_sp) {
1666  // The module list is thread safe, no need to lock
1667  num = target_sp->GetImages().GetSize();
1668  }
1669 
1670  return num;
1671 }
1672 
1675 
1676  m_opaque_sp.reset();
1677 }
1678 
1681  (const lldb::SBFileSpec &), sb_file_spec);
1682 
1683  SBModule sb_module;
1684  TargetSP target_sp(GetSP());
1685  if (target_sp && sb_file_spec.IsValid()) {
1686  ModuleSpec module_spec(*sb_file_spec);
1687  // The module list is thread safe, no need to lock
1688  sb_module.SetSP(target_sp->GetImages().FindFirstModule(module_spec));
1689  }
1690  return LLDB_RECORD_RESULT(sb_module);
1691 }
1692 
1695  (const lldb::SBFileSpec &), sb_file_spec);
1696 
1697  SBSymbolContextList sb_sc_list;
1698  const TargetSP target_sp(GetSP());
1699  if (target_sp && sb_file_spec.IsValid())
1700  target_sp->GetImages().FindCompileUnits(*sb_file_spec, *sb_sc_list);
1701  return LLDB_RECORD_RESULT(sb_sc_list);
1702 }
1703 
1706 
1707  TargetSP target_sp(GetSP());
1708  if (target_sp)
1709  return target_sp->GetArchitecture().GetByteOrder();
1710  return eByteOrderInvalid;
1711 }
1712 
1713 const char *SBTarget::GetTriple() {
1715 
1716  TargetSP target_sp(GetSP());
1717  if (target_sp) {
1718  std::string triple(target_sp->GetArchitecture().GetTriple().str());
1719  // Unique the string so we don't run into ownership issues since the const
1720  // strings put the string into the string pool once and the strings never
1721  // comes out
1722  ConstString const_triple(triple.c_str());
1723  return const_triple.GetCString();
1724  }
1725  return nullptr;
1726 }
1727 
1730 
1731  TargetSP target_sp(GetSP());
1732  if (target_sp) {
1733  return target_sp->GetArchitecture().GetDataByteSize();
1734  }
1735  return 0;
1736 }
1737 
1740 
1741  TargetSP target_sp(GetSP());
1742  if (target_sp) {
1743  return target_sp->GetArchitecture().GetCodeByteSize();
1744  }
1745  return 0;
1746 }
1747 
1750 
1751  TargetSP target_sp(GetSP());
1752  if(target_sp){
1753  return target_sp->GetMaximumNumberOfChildrenToDisplay();
1754  }
1755  return 0;
1756 }
1757 
1760 
1761  TargetSP target_sp(GetSP());
1762  if (target_sp)
1763  return target_sp->GetArchitecture().GetAddressByteSize();
1764  return sizeof(void *);
1765 }
1766 
1769  idx);
1770 
1771  SBModule sb_module;
1772  ModuleSP module_sp;
1773  TargetSP target_sp(GetSP());
1774  if (target_sp) {
1775  // The module list is thread safe, no need to lock
1776  module_sp = target_sp->GetImages().GetModuleAtIndex(idx);
1777  sb_module.SetSP(module_sp);
1778  }
1779 
1780  return LLDB_RECORD_RESULT(sb_module);
1781 }
1782 
1785 
1786  TargetSP target_sp(GetSP());
1787  if (target_sp)
1788  return target_sp->GetImages().Remove(module.GetSP());
1789  return false;
1790 }
1791 
1794  GetBroadcaster);
1795 
1796 
1797  TargetSP target_sp(GetSP());
1798  SBBroadcaster broadcaster(target_sp.get(), false);
1799 
1800 
1801  return LLDB_RECORD_RESULT(broadcaster);
1802 }
1803 
1805  lldb::DescriptionLevel description_level) {
1807  (lldb::SBStream &, lldb::DescriptionLevel), description,
1808  description_level);
1809 
1810  Stream &strm = description.ref();
1811 
1812  TargetSP target_sp(GetSP());
1813  if (target_sp) {
1814  target_sp->Dump(&strm, description_level);
1815  } else
1816  strm.PutCString("No value");
1817 
1818  return true;
1819 }
1820 
1822  uint32_t name_type_mask) {
1824  (const char *, uint32_t), name, name_type_mask);
1825 
1826  lldb::SBSymbolContextList sb_sc_list;
1827  if (!name || !name[0])
1828  return LLDB_RECORD_RESULT(sb_sc_list);
1829 
1830  TargetSP target_sp(GetSP());
1831  if (!target_sp)
1832  return LLDB_RECORD_RESULT(sb_sc_list);
1833 
1834  ModuleFunctionSearchOptions function_options;
1835  function_options.include_symbols = true;
1836  function_options.include_inlines = true;
1837 
1838  FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
1839  target_sp->GetImages().FindFunctions(ConstString(name), mask,
1840  function_options, *sb_sc_list);
1841  return LLDB_RECORD_RESULT(sb_sc_list);
1842 }
1843 
1845  uint32_t max_matches,
1846  MatchType matchtype) {
1848  (const char *, uint32_t, lldb::MatchType), name,
1849  max_matches, matchtype);
1850 
1851  lldb::SBSymbolContextList sb_sc_list;
1852  if (name && name[0]) {
1853  llvm::StringRef name_ref(name);
1854  TargetSP target_sp(GetSP());
1855  if (target_sp) {
1856  ModuleFunctionSearchOptions function_options;
1857  function_options.include_symbols = true;
1858  function_options.include_inlines = true;
1859 
1860  std::string regexstr;
1861  switch (matchtype) {
1862  case eMatchTypeRegex:
1863  target_sp->GetImages().FindFunctions(RegularExpression(name_ref),
1864  function_options, *sb_sc_list);
1865  break;
1866  case eMatchTypeStartsWith:
1867  regexstr = llvm::Regex::escape(name) + ".*";
1868  target_sp->GetImages().FindFunctions(RegularExpression(regexstr),
1869  function_options, *sb_sc_list);
1870  break;
1871  default:
1872  target_sp->GetImages().FindFunctions(ConstString(name),
1873  eFunctionNameTypeAny,
1874  function_options, *sb_sc_list);
1875  break;
1876  }
1877  }
1878  }
1879  return LLDB_RECORD_RESULT(sb_sc_list);
1880 }
1881 
1882 lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
1884  typename_cstr);
1885 
1886  TargetSP target_sp(GetSP());
1887  if (typename_cstr && typename_cstr[0] && target_sp) {
1888  ConstString const_typename(typename_cstr);
1889  SymbolContext sc;
1890  const bool exact_match = false;
1891 
1892  const ModuleList &module_list = target_sp->GetImages();
1893  size_t count = module_list.GetSize();
1894  for (size_t idx = 0; idx < count; idx++) {
1895  ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
1896  if (module_sp) {
1897  TypeSP type_sp(
1898  module_sp->FindFirstType(sc, const_typename, exact_match));
1899  if (type_sp)
1900  return LLDB_RECORD_RESULT(SBType(type_sp));
1901  }
1902  }
1903 
1904  // Didn't find the type in the symbols; Try the loaded language runtimes
1905  if (auto process_sp = target_sp->GetProcessSP()) {
1906  for (auto *runtime : process_sp->GetLanguageRuntimes()) {
1907  if (auto vendor = runtime->GetDeclVendor()) {
1908  auto types = vendor->FindTypes(const_typename, /*max_matches*/ 1);
1909  if (!types.empty())
1910  return LLDB_RECORD_RESULT(SBType(types.front()));
1911  }
1912  }
1913  }
1914 
1915  // No matches, search for basic typename matches
1916  for (auto *type_system : target_sp->GetScratchTypeSystems())
1917  if (auto type = type_system->GetBuiltinTypeByName(const_typename))
1918  return LLDB_RECORD_RESULT(SBType(type));
1919  }
1920 
1921  return LLDB_RECORD_RESULT(SBType());
1922 }
1923 
1926  type);
1927 
1928  TargetSP target_sp(GetSP());
1929  if (target_sp) {
1930  for (auto *type_system : target_sp->GetScratchTypeSystems())
1931  if (auto compiler_type = type_system->GetBasicTypeFromAST(type))
1932  return LLDB_RECORD_RESULT(SBType(compiler_type));
1933  }
1934  return LLDB_RECORD_RESULT(SBType());
1935 }
1936 
1937 lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
1939  typename_cstr);
1940 
1941  SBTypeList sb_type_list;
1942  TargetSP target_sp(GetSP());
1943  if (typename_cstr && typename_cstr[0] && target_sp) {
1944  ModuleList &images = target_sp->GetImages();
1945  ConstString const_typename(typename_cstr);
1946  bool exact_match = false;
1947  TypeList type_list;
1948  llvm::DenseSet<SymbolFile *> searched_symbol_files;
1949  images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX,
1950  searched_symbol_files, type_list);
1951 
1952  for (size_t idx = 0; idx < type_list.GetSize(); idx++) {
1953  TypeSP type_sp(type_list.GetTypeAtIndex(idx));
1954  if (type_sp)
1955  sb_type_list.Append(SBType(type_sp));
1956  }
1957 
1958  // Try the loaded language runtimes
1959  if (auto process_sp = target_sp->GetProcessSP()) {
1960  for (auto *runtime : process_sp->GetLanguageRuntimes()) {
1961  if (auto *vendor = runtime->GetDeclVendor()) {
1962  auto types =
1963  vendor->FindTypes(const_typename, /*max_matches*/ UINT32_MAX);
1964  for (auto type : types)
1965  sb_type_list.Append(SBType(type));
1966  }
1967  }
1968  }
1969 
1970  if (sb_type_list.GetSize() == 0) {
1971  // No matches, search for basic typename matches
1972  for (auto *type_system : target_sp->GetScratchTypeSystems())
1973  if (auto compiler_type =
1974  type_system->GetBuiltinTypeByName(const_typename))
1975  sb_type_list.Append(SBType(compiler_type));
1976  }
1977  }
1978  return LLDB_RECORD_RESULT(sb_type_list);
1979 }
1980 
1982  uint32_t max_matches) {
1984  (const char *, uint32_t), name, max_matches);
1985 
1986  SBValueList sb_value_list;
1987 
1988  TargetSP target_sp(GetSP());
1989  if (name && target_sp) {
1990  VariableList variable_list;
1991  target_sp->GetImages().FindGlobalVariables(ConstString(name), max_matches,
1992  variable_list);
1993  if (!variable_list.Empty()) {
1994  ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
1995  if (exe_scope == nullptr)
1996  exe_scope = target_sp.get();
1997  for (const VariableSP &var_sp : variable_list) {
1998  lldb::ValueObjectSP valobj_sp(
1999  ValueObjectVariable::Create(exe_scope, var_sp));
2000  if (valobj_sp)
2001  sb_value_list.Append(SBValue(valobj_sp));
2002  }
2003  }
2004  }
2005 
2006  return LLDB_RECORD_RESULT(sb_value_list);
2007 }
2008 
2010  uint32_t max_matches,
2011  MatchType matchtype) {
2013  (const char *, uint32_t, lldb::MatchType), name,
2014  max_matches, matchtype);
2015 
2016  SBValueList sb_value_list;
2017 
2018  TargetSP target_sp(GetSP());
2019  if (name && target_sp) {
2020  llvm::StringRef name_ref(name);
2021  VariableList variable_list;
2022 
2023  std::string regexstr;
2024  switch (matchtype) {
2025  case eMatchTypeNormal:
2026  target_sp->GetImages().FindGlobalVariables(ConstString(name), max_matches,
2027  variable_list);
2028  break;
2029  case eMatchTypeRegex:
2030  target_sp->GetImages().FindGlobalVariables(RegularExpression(name_ref),
2031  max_matches, variable_list);
2032  break;
2033  case eMatchTypeStartsWith:
2034  regexstr = llvm::Regex::escape(name) + ".*";
2035  target_sp->GetImages().FindGlobalVariables(RegularExpression(regexstr),
2036  max_matches, variable_list);
2037  break;
2038  }
2039  if (!variable_list.Empty()) {
2040  ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
2041  if (exe_scope == nullptr)
2042  exe_scope = target_sp.get();
2043  for (const VariableSP &var_sp : variable_list) {
2044  lldb::ValueObjectSP valobj_sp(
2045  ValueObjectVariable::Create(exe_scope, var_sp));
2046  if (valobj_sp)
2047  sb_value_list.Append(SBValue(valobj_sp));
2048  }
2049  }
2050  }
2051 
2052  return LLDB_RECORD_RESULT(sb_value_list);
2053 }
2054 
2057  (const char *), name);
2058 
2059  SBValueList sb_value_list(FindGlobalVariables(name, 1));
2060  if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
2061  return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0));
2062  return LLDB_RECORD_RESULT(SBValue());
2063 }
2064 
2067 
2068  SBSourceManager source_manager(*this);
2069  return LLDB_RECORD_RESULT(source_manager);
2070 }
2071 
2073  uint32_t count) {
2075  (lldb::SBAddress, uint32_t), base_addr, count);
2076 
2077  return LLDB_RECORD_RESULT(ReadInstructions(base_addr, count, nullptr));
2078 }
2079 
2081  uint32_t count,
2082  const char *flavor_string) {
2084  (lldb::SBAddress, uint32_t, const char *), base_addr,
2085  count, flavor_string);
2086 
2087  SBInstructionList sb_instructions;
2088 
2089  TargetSP target_sp(GetSP());
2090  if (target_sp) {
2091  Address *addr_ptr = base_addr.get();
2092 
2093  if (addr_ptr) {
2094  DataBufferHeap data(
2095  target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0);
2096  bool force_live_memory = true;
2098  lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
2099  const size_t bytes_read =
2100  target_sp->ReadMemory(*addr_ptr, data.GetBytes(), data.GetByteSize(),
2101  error, force_live_memory, &load_addr);
2102  const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
2103  sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
2104  target_sp->GetArchitecture(), nullptr, flavor_string, *addr_ptr,
2105  data.GetBytes(), bytes_read, count, data_from_file));
2106  }
2107  }
2108 
2109  return LLDB_RECORD_RESULT(sb_instructions);
2110 }
2111 
2113  const void *buf,
2114  size_t size) {
2116  (lldb::SBAddress, const void *, size_t), base_addr, buf,
2117  size);
2118 
2119  return LLDB_RECORD_RESULT(
2120  GetInstructionsWithFlavor(base_addr, nullptr, buf, size));
2121 }
2122 
2125  const char *flavor_string, const void *buf,
2126  size_t size) {
2129  (lldb::SBAddress, const char *, const void *, size_t),
2130  base_addr, flavor_string, buf, size);
2131 
2132  SBInstructionList sb_instructions;
2133 
2134  TargetSP target_sp(GetSP());
2135  if (target_sp) {
2136  Address addr;
2137 
2138  if (base_addr.get())
2139  addr = *base_addr.get();
2140 
2141  const bool data_from_file = true;
2142 
2143  sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
2144  target_sp->GetArchitecture(), nullptr, flavor_string, addr, buf, size,
2145  UINT32_MAX, data_from_file));
2146  }
2147 
2148  return LLDB_RECORD_RESULT(sb_instructions);
2149 }
2150 
2152  const void *buf,
2153  size_t size) {
2155  (lldb::addr_t, const void *, size_t), base_addr, buf,
2156  size);
2157 
2159  ResolveLoadAddress(base_addr), nullptr, buf, size));
2160 }
2161 
2164  const char *flavor_string, const void *buf,
2165  size_t size) {
2168  (lldb::addr_t, const char *, const void *, size_t),
2169  base_addr, flavor_string, buf, size);
2170 
2172  ResolveLoadAddress(base_addr), flavor_string, buf, size));
2173 }
2174 
2176  lldb::addr_t section_base_addr) {
2178  (lldb::SBSection, lldb::addr_t), section,
2179  section_base_addr);
2180 
2181  SBError sb_error;
2182  TargetSP target_sp(GetSP());
2183  if (target_sp) {
2184  if (!section.IsValid()) {
2185  sb_error.SetErrorStringWithFormat("invalid section");
2186  } else {
2187  SectionSP section_sp(section.GetSP());
2188  if (section_sp) {
2189  if (section_sp->IsThreadSpecific()) {
2190  sb_error.SetErrorString(
2191  "thread specific sections are not yet supported");
2192  } else {
2193  ProcessSP process_sp(target_sp->GetProcessSP());
2194  if (target_sp->SetSectionLoadAddress(section_sp, section_base_addr)) {
2195  ModuleSP module_sp(section_sp->GetModule());
2196  if (module_sp) {
2197  ModuleList module_list;
2198  module_list.Append(module_sp);
2199  target_sp->ModulesDidLoad(module_list);
2200  }
2201  // Flush info in the process (stack frames, etc)
2202  if (process_sp)
2203  process_sp->Flush();
2204  }
2205  }
2206  }
2207  }
2208  } else {
2209  sb_error.SetErrorString("invalid target");
2210  }
2211  return LLDB_RECORD_RESULT(sb_error);
2212 }
2213 
2216  (lldb::SBSection), section);
2217 
2218  SBError sb_error;
2219 
2220  TargetSP target_sp(GetSP());
2221  if (target_sp) {
2222  if (!section.IsValid()) {
2223  sb_error.SetErrorStringWithFormat("invalid section");
2224  } else {
2225  SectionSP section_sp(section.GetSP());
2226  if (section_sp) {
2227  ProcessSP process_sp(target_sp->GetProcessSP());
2228  if (target_sp->SetSectionUnloaded(section_sp)) {
2229  ModuleSP module_sp(section_sp->GetModule());
2230  if (module_sp) {
2231  ModuleList module_list;
2232  module_list.Append(module_sp);
2233  target_sp->ModulesDidUnload(module_list, false);
2234  }
2235  // Flush info in the process (stack frames, etc)
2236  if (process_sp)
2237  process_sp->Flush();
2238  }
2239  } else {
2240  sb_error.SetErrorStringWithFormat("invalid section");
2241  }
2242  }
2243  } else {
2244  sb_error.SetErrorStringWithFormat("invalid target");
2245  }
2246  return LLDB_RECORD_RESULT(sb_error);
2247 }
2248 
2250  int64_t slide_offset) {
2252  (lldb::SBModule, int64_t), module, slide_offset);
2253 
2254  SBError sb_error;
2255 
2256  TargetSP target_sp(GetSP());
2257  if (target_sp) {
2258  ModuleSP module_sp(module.GetSP());
2259  if (module_sp) {
2260  bool changed = false;
2261  if (module_sp->SetLoadAddress(*target_sp, slide_offset, true, changed)) {
2262  // The load was successful, make sure that at least some sections
2263  // changed before we notify that our module was loaded.
2264  if (changed) {
2265  ModuleList module_list;
2266  module_list.Append(module_sp);
2267  target_sp->ModulesDidLoad(module_list);
2268  // Flush info in the process (stack frames, etc)
2269  ProcessSP process_sp(target_sp->GetProcessSP());
2270  if (process_sp)
2271  process_sp->Flush();
2272  }
2273  }
2274  } else {
2275  sb_error.SetErrorStringWithFormat("invalid module");
2276  }
2277 
2278  } else {
2279  sb_error.SetErrorStringWithFormat("invalid target");
2280  }
2281  return LLDB_RECORD_RESULT(sb_error);
2282 }
2283 
2286  (lldb::SBModule), module);
2287 
2288  SBError sb_error;
2289 
2290  char path[PATH_MAX];
2291  TargetSP target_sp(GetSP());
2292  if (target_sp) {
2293  ModuleSP module_sp(module.GetSP());
2294  if (module_sp) {
2295  ObjectFile *objfile = module_sp->GetObjectFile();
2296  if (objfile) {
2297  SectionList *section_list = objfile->GetSectionList();
2298  if (section_list) {
2299  ProcessSP process_sp(target_sp->GetProcessSP());
2300 
2301  bool changed = false;
2302  const size_t num_sections = section_list->GetSize();
2303  for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
2304  SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
2305  if (section_sp)
2306  changed |= target_sp->SetSectionUnloaded(section_sp);
2307  }
2308  if (changed) {
2309  ModuleList module_list;
2310  module_list.Append(module_sp);
2311  target_sp->ModulesDidUnload(module_list, false);
2312  // Flush info in the process (stack frames, etc)
2313  ProcessSP process_sp(target_sp->GetProcessSP());
2314  if (process_sp)
2315  process_sp->Flush();
2316  }
2317  } else {
2318  module_sp->GetFileSpec().GetPath(path, sizeof(path));
2319  sb_error.SetErrorStringWithFormat("no sections in object file '%s'",
2320  path);
2321  }
2322  } else {
2323  module_sp->GetFileSpec().GetPath(path, sizeof(path));
2324  sb_error.SetErrorStringWithFormat("no object file for module '%s'",
2325  path);
2326  }
2327  } else {
2328  sb_error.SetErrorStringWithFormat("invalid module");
2329  }
2330  } else {
2331  sb_error.SetErrorStringWithFormat("invalid target");
2332  }
2333  return LLDB_RECORD_RESULT(sb_error);
2334 }
2335 
2337  lldb::SymbolType symbol_type) {
2339  (const char *, lldb::SymbolType), name, symbol_type);
2340 
2341  SBSymbolContextList sb_sc_list;
2342  if (name && name[0]) {
2343  TargetSP target_sp(GetSP());
2344  if (target_sp)
2345  target_sp->GetImages().FindSymbolsWithNameAndType(
2346  ConstString(name), symbol_type, *sb_sc_list);
2347  }
2348  return LLDB_RECORD_RESULT(sb_sc_list);
2349 }
2350 
2353  (const char *), expr);
2354 
2355  TargetSP target_sp(GetSP());
2356  if (!target_sp)
2357  return LLDB_RECORD_RESULT(SBValue());
2358 
2359  SBExpressionOptions options;
2360  lldb::DynamicValueType fetch_dynamic_value =
2361  target_sp->GetPreferDynamicValue();
2362  options.SetFetchDynamicValue(fetch_dynamic_value);
2363  options.SetUnwindOnError(true);
2364  return LLDB_RECORD_RESULT(EvaluateExpression(expr, options));
2365 }
2366 
2368  const SBExpressionOptions &options) {
2370  (const char *, const lldb::SBExpressionOptions &), expr,
2371  options);
2372 
2374  SBValue expr_result;
2375  ValueObjectSP expr_value_sp;
2376  TargetSP target_sp(GetSP());
2377  StackFrame *frame = nullptr;
2378  if (target_sp) {
2379  if (expr == nullptr || expr[0] == '\0') {
2380  return LLDB_RECORD_RESULT(expr_result);
2381  }
2382 
2383  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
2384  ExecutionContext exe_ctx(m_opaque_sp.get());
2385 
2386 
2387  frame = exe_ctx.GetFramePtr();
2388  Target *target = exe_ctx.GetTargetPtr();
2389 
2390  if (target) {
2391  target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
2392 
2393  expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
2394  }
2395  }
2396  LLDB_LOGF(expr_log,
2397  "** [SBTarget::EvaluateExpression] Expression result is "
2398  "%s, summary %s **",
2399  expr_result.GetValue(), expr_result.GetSummary());
2400  return LLDB_RECORD_RESULT(expr_result);
2401 }
2402 
2405 
2406  TargetSP target_sp(GetSP());
2407  if (target_sp) {
2408  ABISP abi_sp;
2409  ProcessSP process_sp(target_sp->GetProcessSP());
2410  if (process_sp)
2411  abi_sp = process_sp->GetABI();
2412  else
2413  abi_sp = ABI::FindPlugin(ProcessSP(), target_sp->GetArchitecture());
2414  if (abi_sp)
2415  return abi_sp->GetRedZoneSize();
2416  }
2417  return 0;
2418 }
2419 
2420 bool SBTarget::IsLoaded(const SBModule &module) const {
2422  module);
2423 
2424  TargetSP target_sp(GetSP());
2425  if (!target_sp)
2426  return false;
2427 
2428  ModuleSP module_sp(module.GetSP());
2429  if (!module_sp)
2430  return false;
2431 
2432  return module_sp->IsLoadedInTarget(target_sp.get());
2433 }
2434 
2437 
2438  lldb::SBLaunchInfo launch_info(nullptr);
2439  TargetSP target_sp(GetSP());
2440  if (target_sp)
2441  launch_info.set_ref(m_opaque_sp->GetProcessLaunchInfo());
2442  return LLDB_RECORD_RESULT(launch_info);
2443 }
2444 
2447  (const lldb::SBLaunchInfo &), launch_info);
2448 
2449  TargetSP target_sp(GetSP());
2450  if (target_sp)
2451  m_opaque_sp->SetProcessLaunchInfo(launch_info.ref());
2452 }
2453 
2456  TargetSP target_sp(GetSP());
2457 
2458  if (target_sp) {
2459  return LLDB_RECORD_RESULT(SBEnvironment(target_sp->GetEnvironment()));
2460  }
2461 
2463 }
2464 
2467  TargetSP target_sp(GetSP());
2468 
2469  if (target_sp)
2470  return LLDB_RECORD_RESULT(SBTrace(target_sp->GetTrace()));
2471 
2472  return LLDB_RECORD_RESULT(SBTrace());
2473 }
2474 
2477  error);
2478  TargetSP target_sp(GetSP());
2479  error.Clear();
2480 
2481  if (target_sp) {
2482  if (llvm::Expected<lldb::TraceSP> trace_sp = target_sp->CreateTrace()) {
2483  return LLDB_RECORD_RESULT(SBTrace(*trace_sp));
2484  } else {
2485  error.SetErrorString(llvm::toString(trace_sp.takeError()).c_str());
2486  }
2487  } else {
2488  error.SetErrorString("missing target");
2489  }
2490  return LLDB_RECORD_RESULT(SBTrace());
2491 }
2492 
2493 namespace lldb_private {
2494 namespace repro {
2495 
2496 template <>
2500  LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &));
2502  SBTarget, operator=,(const lldb::SBTarget &));
2503  LLDB_REGISTER_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent,
2504  (const lldb::SBEvent &));
2506  (const lldb::SBEvent &));
2507  LLDB_REGISTER_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent,
2508  (const lldb::SBEvent &));
2510  GetModuleAtIndexFromEvent,
2511  (const uint32_t, const lldb::SBEvent &));
2512  LLDB_REGISTER_STATIC_METHOD(const char *, SBTarget, GetBroadcasterClassName,
2513  ());
2514  LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsValid, ());
2515  LLDB_REGISTER_METHOD_CONST(bool, SBTarget, operator bool, ());
2516  LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, GetProcess, ());
2517  LLDB_REGISTER_METHOD(lldb::SBPlatform, SBTarget, GetPlatform, ());
2520  LLDB_REGISTER_METHOD(void, SBTarget, SetCollectingStats, (bool));
2521  LLDB_REGISTER_METHOD(bool, SBTarget, GetCollectingStats, ());
2522  LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *));
2524  (const char *, lldb::SBError &));
2526  (const char **, const char **, const char *));
2529  (lldb::SBListener &, const char **, const char **,
2530  const char *, const char *, const char *,
2531  const char *, uint32_t, bool, lldb::SBError &));
2536  LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID,
2539  lldb::SBProcess, SBTarget, AttachToProcessWithName,
2540  (lldb::SBListener &, const char *, bool, lldb::SBError &));
2542  lldb::SBProcess, SBTarget, ConnectRemote,
2543  (lldb::SBListener &, const char *, const char *, lldb::SBError &));
2544  LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBTarget, GetExecutable, ());
2546  SBTarget, operator==,(const lldb::SBTarget &));
2548  SBTarget, operator!=,(const lldb::SBTarget &));
2549  LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress,
2550  (lldb::addr_t));
2551  LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress,
2552  (lldb::addr_t));
2553  LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress,
2554  (uint32_t, lldb::addr_t));
2556  ResolveSymbolContextForAddress,
2557  (const lldb::SBAddress &, uint32_t));
2559  BreakpointCreateByLocation, (const char *, uint32_t));
2561  BreakpointCreateByLocation,
2562  (const lldb::SBFileSpec &, uint32_t));
2564  BreakpointCreateByLocation,
2565  (const lldb::SBFileSpec &, uint32_t, lldb::addr_t));
2567  BreakpointCreateByLocation,
2571  BreakpointCreateByLocation,
2572  (const lldb::SBFileSpec &, uint32_t, uint32_t,
2574  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
2575  (const lldb::SBFileSpec &, uint32_t, uint32_t,
2577  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
2578  (const char *, const char *));
2579  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
2580  (const char *, const lldb::SBFileSpecList &,
2581  const lldb::SBFileSpecList &));
2582  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
2583  (const char *, uint32_t, const lldb::SBFileSpecList &,
2584  const lldb::SBFileSpecList &));
2585  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
2586  (const char *, uint32_t, lldb::LanguageType,
2587  const lldb::SBFileSpecList &,
2588  const lldb::SBFileSpecList &));
2589  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
2590  (const char **, uint32_t, uint32_t,
2591  const lldb::SBFileSpecList &,
2592  const lldb::SBFileSpecList &));
2593  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
2594  (const char **, uint32_t, uint32_t, lldb::LanguageType,
2595  const lldb::SBFileSpecList &,
2596  const lldb::SBFileSpecList &));
2597  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
2598  (const char **, uint32_t, uint32_t, lldb::LanguageType,
2600  const lldb::SBFileSpecList &));
2601  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
2602  (const char *, const char *));
2603  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
2604  (const char *, const lldb::SBFileSpecList &,
2605  const lldb::SBFileSpecList &));
2606  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
2607  (const char *, lldb::LanguageType,
2608  const lldb::SBFileSpecList &,
2609  const lldb::SBFileSpecList &));
2611  BreakpointCreateByAddress, (lldb::addr_t));
2613  BreakpointCreateBySBAddress, (lldb::SBAddress &));
2615  lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex,
2616  (const char *, const lldb::SBFileSpec &, const char *));
2618  BreakpointCreateBySourceRegex,
2619  (const char *, const lldb::SBFileSpecList &,
2620  const lldb::SBFileSpecList &));
2622  lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex,
2623  (const char *, const lldb::SBFileSpecList &,
2624  const lldb::SBFileSpecList &, const lldb::SBStringList &));
2626  BreakpointCreateForException,
2627  (lldb::LanguageType, bool, bool));
2629  lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript,
2630  (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &,
2631  const lldb::SBFileSpecList &, bool));
2632  LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumBreakpoints, ());
2634  GetBreakpointAtIndex, (uint32_t));
2635  LLDB_REGISTER_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t));
2636  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID,
2637  (lldb::break_id_t));
2638  LLDB_REGISTER_METHOD(bool, SBTarget, FindBreakpointsByName,
2639  (const char *, lldb::SBBreakpointList &));
2640  LLDB_REGISTER_METHOD(void, SBTarget, GetBreakpointNames,
2641  (lldb::SBStringList &));
2642  LLDB_REGISTER_METHOD(void, SBTarget, DeleteBreakpointName, (const char *));
2643  LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllBreakpoints, ());
2644  LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllBreakpoints, ());
2645  LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllBreakpoints, ());
2646  LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile,
2649  lldb::SBError, SBTarget, BreakpointsCreateFromFile,
2651  LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
2652  (lldb::SBFileSpec &));
2653  LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
2655  LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumWatchpoints, ());
2657  GetWatchpointAtIndex, (uint32_t));
2658  LLDB_REGISTER_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t));
2659  LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID,
2660  (lldb::watch_id_t));
2662  (lldb::addr_t, size_t, bool, bool, lldb::SBError &));
2663  LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllWatchpoints, ());
2664  LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllWatchpoints, ());
2665  LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress,
2666  (const char *, lldb::SBAddress, lldb::SBType));
2667  LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromData,
2668  (const char *, lldb::SBData, lldb::SBType));
2669  LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression,
2670  (const char *, const char *));
2671  LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllWatchpoints, ());
2672  LLDB_REGISTER_METHOD(void, SBTarget, AppendImageSearchPath,
2673  (const char *, const char *, lldb::SBError &));
2675  (const char *, const char *, const char *));
2677  lldb::SBModule, SBTarget, AddModule,
2678  (const char *, const char *, const char *, const char *));
2680  (const lldb::SBModuleSpec &));
2681  LLDB_REGISTER_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &));
2682  LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumModules, ());
2683  LLDB_REGISTER_METHOD(void, SBTarget, Clear, ());
2685  (const lldb::SBFileSpec &));
2687  (const lldb::SBFileSpec &));
2688  LLDB_REGISTER_METHOD(lldb::ByteOrder, SBTarget, GetByteOrder, ());
2689  LLDB_REGISTER_METHOD(const char *, SBTarget, GetTriple, ());
2690  LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetDataByteSize, ());
2691  LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetCodeByteSize, ());
2692  LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetMaximumNumberOfChildrenToDisplay,());
2693  LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetAddressByteSize, ());
2694  LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex,
2695  (uint32_t));
2696  LLDB_REGISTER_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule));
2698  ());
2699  LLDB_REGISTER_METHOD(bool, SBTarget, GetDescription,
2702  (const char *, uint32_t));
2704  FindGlobalFunctions,
2705  (const char *, uint32_t, lldb::MatchType));
2706  LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *));
2708  (lldb::BasicType));
2709  LLDB_REGISTER_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *));
2710  LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
2711  (const char *, uint32_t));
2712  LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
2713  (const char *, uint32_t, lldb::MatchType));
2714  LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable,
2715  (const char *));
2716  LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBTarget, GetSourceManager, ());
2720  (lldb::SBAddress, uint32_t, const char *));
2721  LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress,
2723  LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress,
2724  (lldb::SBSection));
2725  LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress,
2726  (lldb::SBModule, int64_t));
2727  LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress,
2728  (lldb::SBModule));
2730  (const char *, lldb::SymbolType));
2731  LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
2732  (const char *));
2733  LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
2734  (const char *, const lldb::SBExpressionOptions &));
2735  LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ());
2736  LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsLoaded,
2737  (const lldb::SBModule &));
2739  LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo,
2740  (const lldb::SBLaunchInfo &));
2742  size_t, SBTarget, ReadMemory,
2743  (const lldb::SBAddress, void *, size_t, lldb::SBError &));
2745  (lldb::SBAddress, const void *, size_t));
2747  GetInstructionsWithFlavor,
2748  (lldb::SBAddress, const char *, const void *, size_t));
2750  (lldb::addr_t, const void *, size_t));
2752  GetInstructionsWithFlavor,
2753  (lldb::addr_t, const char *, const void *, size_t));
2754  LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBTarget, GetEnvironment, ());
2757 }
2758 
2759 }
2760 }
lldb::SBValueList
Definition: SBValueList.h:18
LLDB_INVALID_WATCH_ID
#define LLDB_INVALID_WATCH_ID
Definition: lldb-defines.h:55
lldb_private::toString
const char * toString(AppleArm64ExceptionClass EC)
Definition: AppleArm64ExceptionClass.h:38
RegularExpression.h
lldb::SBTarget::GetAddressByteSize
uint32_t GetAddressByteSize()
Definition: SBTarget.cpp:1758
lldb::SBStringList
Definition: SBStringList.h:16
lldb_private::ProcessInfo::GetArguments
Args & GetArguments()
Definition: ProcessInfo.h:75
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:108
lldb::SBTarget::BreakpointCreateByName
lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name, const char *module_name=nullptr)
Definition: SBTarget.cpp:812
lldb::SBLaunchInfo
Definition: SBLaunchInfo.h:23
LLDB_RECORD_STATIC_METHOD_NO_ARGS
#define LLDB_RECORD_STATIC_METHOD_NO_ARGS(Result, Class, Method)
Definition: ReproducerInstrumentation.h:174
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb::SBEvent::get
lldb_private::Event * get() const
Definition: SBEvent.cpp:139
lldb_private::DataBufferHeap::GetBytes
uint8_t * GetBytes() override
Definition: DataBufferHeap.cpp:34
lldb_private::DataBufferHeap::GetByteSize
lldb::offset_t GetByteSize() const override
Definition: DataBufferHeap.cpp:45
LLDB_WATCH_TYPE_WRITE
#define LLDB_WATCH_TYPE_WRITE
Definition: lldb-defines.h:58
lldb::SBModuleSpec
Definition: SBModuleSpec.h:17
lldb-public.h
lldb::SBStream::ref
lldb_private::Stream & ref()
Definition: SBStream.cpp:178
lldb::SBStringList::AppendString
void AppendString(const char *str)
Definition: SBStringList.cpp:62
lldb::SBTarget::GetBreakpointNames
void GetBreakpointNames(SBStringList &names)
Definition: SBTarget.cpp:1235
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb::SBTarget::IsValid
bool IsValid() const
Definition: SBTarget.cpp:162
lldb::SBStringList::GetSize
uint32_t GetSize() const
Definition: SBStringList.cpp:102
lldb_private::RegularExpression
Definition: RegularExpression.h:18
lldb::SBTarget::Install
SBError Install()
Install any binaries that need to be installed.
Definition: SBTarget.cpp:300
lldb_private::ProcessInfo::ProcessIDIsValid
bool ProcessIDIsValid() const
Definition: ProcessInfo.h:71
lldb_private::ProcessInfo::SetExecutableFile
void SetExecutableFile(const FileSpec &exe_file, bool add_exe_file_as_first_arg)
Definition: ProcessInfo.cpp:62
lldb::SBTarget::SetLaunchInfo
void SetLaunchInfo(const lldb::SBLaunchInfo &launch_info)
Definition: SBTarget.cpp:2445
lldb::SBTarget::RemoveModule
bool RemoveModule(lldb::SBModule module)
Definition: SBTarget.cpp:1783
SBModule.h
lldb::SBTarget::DeleteWatchpoint
bool DeleteWatchpoint(lldb::watch_id_t watch_id)
Definition: SBTarget.cpp:1407
ModuleSpec.h
LLDB_WATCH_TYPE_READ
#define LLDB_WATCH_TYPE_READ
Definition: lldb-defines.h:57
lldb::SBValue::GetValue
const char * GetValue()
Definition: SBValue.cpp:356
lldb::MatchType
MatchType
String matching algorithm used by SBTarget.
Definition: lldb-enumerations.h:1032
lldb::SBModuleSpec::m_opaque_up
std::unique_ptr< lldb_private::ModuleSpec > m_opaque_up
Definition: SBModuleSpec.h:87
lldb::SBTarget::CreateTrace
lldb::SBTrace CreateTrace(SBError &error)
Create a Trace object for the current target using the using the default supported tracing technology...
Definition: SBTarget.cpp:2475
LLDB_RECORD_RESULT
#define LLDB_RECORD_RESULT(Result)
Definition: ReproducerInstrumentation.h:211
lldb::SBWatchpoint::SetSP
void SetSP(const lldb::WatchpointSP &sp)
Definition: SBWatchpoint.cpp:268
lldb::SBTarget::EvaluateExpression
lldb::SBValue EvaluateExpression(const char *expr)
Definition: SBTarget.cpp:2351
lldb::SBTarget::GetExecutable
lldb::SBFileSpec GetExecutable()
Definition: SBTarget.cpp:579
Host.h
lldb::SBExpressionOptions::GetFetchDynamicValue
lldb::DynamicValueType GetFetchDynamicValue() const
Definition: SBExpressionOptions.cpp:85
LLDB_RECORD_METHOD_CONST_NO_ARGS
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
Definition: ReproducerInstrumentation.h:168
lldb::SBError
Definition: SBError.h:20
lldb::SBTarget::GetInstructions
lldb::SBInstructionList GetInstructions(lldb::SBAddress base_addr, const void *buf, size_t size)
Definition: SBTarget.cpp:2112
SBModuleSpec.h
lldb::eStateAttaching
@ eStateAttaching
Process is currently trying to attach.
Definition: lldb-enumerations.h:78
DeclVendor.h
lldb::SBTarget::GetEnvironment
SBEnvironment GetEnvironment()
Return the environment variables that would be used to launch a new process.
Definition: SBTarget.cpp:2454
lldb_private::ProcessLaunchInfo::SetListener
void SetListener(const lldb::ListenerSP &listener_sp)
Definition: ProcessLaunchInfo.h:130
lldb::SBTarget::ReadInstructions
lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr, uint32_t count)
Definition: SBTarget.cpp:2072
SBStringList.h
lldb_private::SectionList::GetSize
size_t GetSize() const
Definition: Section.h:74
lldb::SBTarget::GetLaunchInfo
lldb::SBLaunchInfo GetLaunchInfo() const
Definition: SBTarget.cpp:2435
lldb::SBTarget::GetModuleAtIndexFromEvent
static lldb::SBModule GetModuleAtIndexFromEvent(const uint32_t idx, const lldb::SBEvent &event)
Definition: SBTarget.cpp:144
lldb::SBProcess::SetSP
void SetSP(const lldb::ProcessSP &process_sp)
Definition: SBProcess.cpp:108
lldb::SBTarget::BreakpointCreateByLocation
lldb::SBBreakpoint BreakpointCreateByLocation(const char *file, uint32_t line)
Definition: SBTarget.cpp:707
lldb_private::eLazyBoolYes
@ eLazyBoolYes
Definition: lldb-private-enumerations.h:115
LLDB_RECORD_METHOD_NO_ARGS
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
Definition: ReproducerInstrumentation.h:165
lldb::SBTarget::GetCodeByteSize
uint32_t GetCodeByteSize()
Architecture code byte width accessor.
Definition: SBTarget.cpp:1738
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:249
lldb_private::Args::AppendArguments
void AppendArguments(const Args &rhs)
Definition: Args.cpp:293
lldb::SBTarget::GetProcess
lldb::SBProcess GetProcess()
Definition: SBTarget.cpp:172
lldb::SBValue
Definition: SBValue.h:21
Module.h
BreakpointLocation.h
lldb::SBListener::IsValid
bool IsValid() const
Definition: SBListener.cpp:53
lldb::SBTarget::GetDebugger
lldb::SBDebugger GetDebugger() const
Definition: SBTarget.cpp:199
lldb::SBBreakpointList::CopyToBreakpointIDList
void CopyToBreakpointIDList(lldb_private::BreakpointIDList &bp_id_list)
Definition: SBBreakpoint.cpp:980
lldb::SBSymbolContextList
Definition: SBSymbolContextList.h:17
lldb::SBTarget::GetBasicType
lldb::SBType GetBasicType(lldb::BasicType type)
Definition: SBTarget.cpp:1924
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
lldb_private::ProcessInfo::SetUserID
void SetUserID(uint32_t uid)
Definition: ProcessInfo.h:57
lldb_private::ProcessAttachInfo::GetListener
lldb::ListenerSP GetListener() const
Definition: Process.h:190
LLDB_RECORD_CONSTRUCTOR_NO_ARGS
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
Definition: ReproducerInstrumentation.h:136
lldb::SBEnvironment
class LLDB_API SBEnvironment
Definition: SBDefines.h:39
lldb::SBTarget::ResolveLoadAddress
lldb::SBAddress ResolveLoadAddress(lldb::addr_t vm_addr)
Resolve a current load address into a section offset address.
Definition: SBTarget.cpp:613
lldb::SBExpressionOptions::SetUnwindOnError
void SetUnwindOnError(bool unwind=true)
Definition: SBExpressionOptions.cpp:64
lldb_private::Module
Definition: Module.h:85
lldb_private::ExecutionContext::GetFramePtr
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
Definition: ExecutionContext.h:408
lldb_private::ProcessInfo::GetProcessID
lldb::pid_t GetProcessID() const
Definition: ProcessInfo.h:67
LLDB_REGISTER_METHOD_CONST
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)
Definition: ReproducerInstrumentation.h:98
lldb_private::SectionList
Definition: Section.h:34
lldb::SBTarget::GetNumBreakpoints
uint32_t GetNumBreakpoints() const
Definition: SBTarget.cpp:1160
lldb::SBEvent
Definition: SBEvent.h:21
StackFrame.h
Disassembler.h
lldb_private::ProcessInfo::SetProcessID
void SetProcessID(lldb::pid_t pid)
Definition: ProcessInfo.h:69
CommandObjectBreakpoint.h
lldb::SBListener::GetSP
lldb::ListenerSP GetSP()
Definition: SBListener.cpp:315
lldb::SBProcess
Definition: SBProcess.h:23
lldb_private::Stream
Definition: Stream.h:28
lldb_private::TypeList::GetTypeAtIndex
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
Definition: TypeList.cpp:66
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
Language.h
lldb::SBTarget::GetTargetFromEvent
static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event)
Definition: SBTarget.cpp:127
SBReproducerPrivate.h
lldb::BasicType
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
Definition: lldb-enumerations.h:741
lldb_private::ModuleFunctionSearchOptions::include_symbols
bool include_symbols
Include the symbol table.
Definition: Module.h:65
lldb::SBExpressionOptions::ref
lldb_private::EvaluateExpressionOptions & ref() const
Definition: SBExpressionOptions.cpp:284
lldb_private::LazyBool
LazyBool
Definition: lldb-private-enumerations.h:115
AddressResolver.h
lldb::SBSymbolContext::ref
lldb_private::SymbolContext & ref()
Definition: SBSymbolContext.cpp:192
lldb::SBStringList
class LLDB_API SBStringList
Definition: SBDefines.h:69
LLDB_REGISTER_CONSTRUCTOR
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
Definition: ReproducerInstrumentation.h:89
lldb_private::ProcessAttachInfo::SetListener
void SetListener(const lldb::ListenerSP &listener_sp)
Definition: Process.h:192
CommandReturnObject.h
Debugger.h
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:451
Section.h
SBSymbolContextList.h
SBListener.h
lldb::SBFileSpec::SetFileSpec
void SetFileSpec(const lldb_private::FileSpec &fspec)
Definition: SBFileSpec.cpp:170
lldb::SBTarget::BreakpointsCreateFromFile
lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file, SBBreakpointList &new_bps)
Read breakpoints from source_file and return the newly created breakpoints in bkpt_list.
Definition: SBTarget.cpp:1299
lldb_private::ProcessInfo::UserIDIsValid
bool UserIDIsValid() const
Definition: ProcessInfo.h:53
ABI.h
lldb::SBInstructionList
Definition: SBInstructionList.h:18
lldb::SBType
class LLDB_API SBType
Definition: SBDefines.h:79
lldb_private::VariableList
Definition: VariableList.h:18
SBSourceManager.h
lldb::SBTarget::operator==
bool operator==(const lldb::SBTarget &rhs) const
Definition: SBTarget.cpp:593
lldb_private::ModuleSpec::GetSymbolFileSpec
FileSpec & GetSymbolFileSpec()
Definition: ModuleSpec.h:82
lldb::SBStructuredData::m_impl_up
StructuredDataImplUP m_impl_up
Definition: SBStructuredData.h:104
Process.h
lldb::SBTarget::CreateValueFromExpression
lldb::SBValue CreateValueFromExpression(const char *name, const char *expr)
Definition: SBTarget.cpp:1548
lldb_private::ModuleFunctionSearchOptions::include_inlines
bool include_inlines
Include inlined functions.
Definition: Module.h:67
lldb::SBTarget::GetNumModules
uint32_t GetNumModules() const
Definition: SBTarget.cpp:1660
lldb::SBPlatform::m_opaque_sp
lldb::PlatformSP m_opaque_sp
Definition: SBPlatform.h:182
SBExpressionOptions.h
lldb::SBValueList::GetValueAtIndex
lldb::SBValue GetValueAtIndex(uint32_t idx) const
Definition: SBValueList.cpp:152
lldb::SBTarget::FindFunctions
lldb::SBSymbolContextList FindFunctions(const char *name, uint32_t name_type_mask=lldb::eFunctionNameTypeAny)
Find functions by name.
Definition: SBTarget.cpp:1821
lldb::SBTarget::AttachToProcessWithID
lldb::SBProcess AttachToProcessWithID(SBListener &listener, lldb::pid_t pid, lldb::SBError &error)
Attach to process with pid.
Definition: SBTarget.cpp:484
lldb_private::Module::GetPlatformFileSpec
const FileSpec & GetPlatformFileSpec() const
Get accessor for the module platform file specification.
Definition: Module.h:491
Target.h
lldb_private::ModuleSpec::GetUUID
UUID & GetUUID()
Definition: ModuleSpec.h:104
lldb::SBTarget::FindFirstType
lldb::SBType FindFirstType(const char *type)
Definition: SBTarget.cpp:1882
lldb::SBValueList::IsValid
bool IsValid() const
Definition: SBValueList.cpp:88
lldb::SBTrace
Definition: SBTrace.h:19
lldb::eMatchTypeStartsWith
@ eMatchTypeStartsWith
Definition: lldb-enumerations.h:1032
lldb_private::Module::GetFileSpec
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition: Module.h:477
lldb::SBTarget
Definition: SBTarget.h:29
BreakpointList.h
LIBLLDB_LOG_EXPRESSIONS
#define LIBLLDB_LOG_EXPRESSIONS
Definition: Logging.h:22
lldb_private::FileSpec
Definition: FileSpec.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb::SBTarget::BreakpointCreateBySourceRegex
lldb::SBBreakpoint BreakpointCreateBySourceRegex(const char *source_regex, const SBFileSpec &source_file, const char *module_name=nullptr)
Definition: SBTarget.cpp:1045
lldb::SBStringList::GetStringAtIndex
const char * GetStringAtIndex(size_t idx)
Definition: SBStringList.cpp:111
lldb_private::ObjectFile::GetSectionList
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
Definition: ObjectFile.cpp:585
lldb_private::ModuleList::GetSize
size_t GetSize() const
Gets the size of the module list.
Definition: ModuleList.cpp:576
lldb::SBTarget::DeleteAllBreakpoints
bool DeleteAllBreakpoints()
Definition: SBTarget.cpp:1287
SBStream.h
lldb::SBTarget::Attach
SBProcess Attach(SBAttachInfo &attach_info, SBError &error)
Definition: SBTarget.cpp:449
ProcessInfo.h
TargetList.h
lldb::SBError::Fail
bool Fail() const
Definition: SBError.cpp:54
lldb::SBLaunchInfo::SetEnvironmentEntries
void SetEnvironmentEntries(const char **envp, bool append)
Update this object with the given environment variables.
Definition: SBLaunchInfo.cpp:187
lldb::SBTarget::FindCompileUnits
lldb::SBSymbolContextList FindCompileUnits(const lldb::SBFileSpec &sb_file_spec)
Find compile units related to *this target and passed source file.
Definition: SBTarget.cpp:1693
AttachToProcess
static Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target)
Definition: SBTarget.cpp:76
lldb::SBError::SetErrorStringWithFormat
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition: SBError.cpp:131
lldb_private::ProcessInstanceInfo::GetEffectiveUserID
uint32_t GetEffectiveUserID() const
Definition: ProcessInfo.h:123
lldb::SBTarget::GetInstructionsWithFlavor
lldb::SBInstructionList GetInstructionsWithFlavor(lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size)
Definition: SBTarget.cpp:2124
LLDB_RECORD_METHOD
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
Definition: ReproducerInstrumentation.h:158
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
lldb::SBListener::m_opaque_sp
lldb::ListenerSP m_opaque_sp
Definition: SBListener.h:102
lldb_private::ModuleList
Definition: ModuleList.h:72
lldb::SBDebugger
Definition: SBDebugger.h:34
lldb_private::ExecutionContextScope
Definition: ExecutionContextScope.h:32
lldb_private::Target::GetAPIMutex
std::recursive_mutex & GetAPIMutex()
Definition: Target.cpp:4510
Args.h
lldb::SBTarget::SBModule
friend class SBModule
Definition: SBTarget.h:872
lldb::SBAddress::GetLoadAddress
addr_t GetLoadAddress(const lldb::SBTarget &target) const
Definition: SBAddress.cpp:112
lldb::SBTarget::ResolveFileAddress
lldb::SBAddress ResolveFileAddress(lldb::addr_t file_addr)
Resolve a current file address into a section offset address.
Definition: SBTarget.cpp:632
SearchFilter.h
lldb::SBTarget::operator!=
bool operator!=(const lldb::SBTarget &rhs) const
Definition: SBTarget.cpp:600
lldb::SBTarget::GetWatchpointAtIndex
lldb::SBWatchpoint GetWatchpointAtIndex(uint32_t idx) const
Definition: SBTarget.cpp:1394
lldb::SBTarget::BreakpointCreateByAddress
lldb::SBBreakpoint BreakpointCreateByAddress(addr_t address)
Definition: SBTarget.cpp:1010
lldb::SBTarget::GetNumWatchpoints
uint32_t GetNumWatchpoints() const
Definition: SBTarget.cpp:1383
lldb::eStateConnected
@ eStateConnected
Process is connected to remote debug services, but not launched or attached to anything yet.
Definition: lldb-enumerations.h:76
SBFileSpec.h
lldb::SBModule::SetSP
void SetSP(const ModuleSP &module_sp)
Definition: SBModule.cpp:208
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition: StructuredData.h:59
lldb::SBStringList::Clear
void Clear()
Definition: SBStringList.cpp:131
lldb::SBTarget::BreakpointsWriteToFile
lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file)
Write breakpoints to dest_file.
Definition: SBTarget.cpp:1347
lldb_private::TypeList::GetSize
uint32_t GetSize() const
Definition: TypeList.cpp:60
lldb::break_id_t
int32_t break_id_t
Definition: lldb-types.h:88
lldb::SBTarget::DisableAllWatchpoints
bool DisableAllWatchpoints()
Definition: SBTarget.cpp:1494
lldb_private::ConstString
Definition: ConstString.h:40
lldb::SBTarget::GetMaximumNumberOfChildrenToDisplay
uint32_t GetMaximumNumberOfChildrenToDisplay() const
Gets the target.max-children-count value It should be used to limit the number of children of large d...
Definition: SBTarget.cpp:1748
lldb::SBTarget::SetCollectingStats
void SetCollectingStats(bool v)
Sets whether we should collect statistics on lldb or not.
Definition: SBTarget.cpp:224
lldb::SBError::SetErrorString
void SetErrorString(const char *err_str)
Definition: SBError.cpp:124
lldb::SBTarget::DisableAllBreakpoints
bool DisableAllBreakpoints()
Definition: SBTarget.cpp:1275
lldb::SBTarget::BreakpointCreateByNames
lldb::SBBreakpoint BreakpointCreateByNames(const char *symbol_name[], uint32_t num_names, uint32_t name_type_mask, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list)
Definition: SBTarget.cpp:897
lldb::SBTarget::SBValue
friend class SBValue
Definition: SBTarget.h:878
lldb_private::BreakpointID::GetBreakpointID
lldb::break_id_t GetBreakpointID() const
Definition: BreakpointID.h:29
lldb::SBTarget::AddModule
bool AddModule(lldb::SBModule &module)
Definition: SBTarget.cpp:1649
lldb::eMatchTypeNormal
@ eMatchTypeNormal
Definition: lldb-enumerations.h:1032
lldb::SBTarget::AttachToProcessWithName
lldb::SBProcess AttachToProcessWithName(SBListener &listener, const char *name, bool wait_for, lldb::SBError &error)
Attach to process with name.
Definition: SBTarget.cpp:515
lldb::SBValueList::Append
void Append(const lldb::SBValue &val_obj)
Definition: SBValueList.cpp:127
lldb::SBTarget::ClearSectionLoadAddress
lldb::SBError ClearSectionLoadAddress(lldb::SBSection section)
Clear the base load address for a module section.
Definition: SBTarget.cpp:2214
lldb::SBFileSpec::ref
const lldb_private::FileSpec & ref() const
Definition: SBFileSpec.cpp:168
lldb::SBFileSpec::IsValid
bool IsValid() const
Definition: SBFileSpec.cpp:79
lldb::SBAddress::IsValid
bool IsValid() const
Definition: SBAddress.cpp:76
lldb::SBTarget::EnableAllWatchpoints
bool EnableAllWatchpoints()
Definition: SBTarget.cpp:1480
lldb_private::GetLogIfAllCategoriesSet
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:58
lldb::SBTarget::GetBroadcasterClassName
static const char * GetBroadcasterClassName()
Definition: SBTarget.cpp:155
lldb_private::SectionList::GetSectionAtIndex
lldb::SectionSP GetSectionAtIndex(size_t idx) const
Definition: Section.cpp:546
lldb::SBEnvironment
Definition: SBEnvironment.h:16
SBDebugger.h
lldb::SBSection
Definition: SBSection.h:17
lldb::SBTarget::FindBreakpointByID
lldb::SBBreakpoint FindBreakpointByID(break_id_t break_id)
Definition: SBTarget.cpp:1198
lldb::DynamicValueType
DynamicValueType
Definition: lldb-enumerations.h:494
lldb::SBTarget::BreakpointCreateByRegex
lldb::SBBreakpoint BreakpointCreateByRegex(const char *symbol_name_regex, const char *module_name=nullptr)
Definition: SBTarget.cpp:954
LLDB_REGISTER_STATIC_METHOD
#define LLDB_REGISTER_STATIC_METHOD(Result, Class, Method, Signature)
Definition: ReproducerInstrumentation.h:103
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb::watch_id_t
int32_t watch_id_t
Definition: lldb-types.h:89
lldb::SBDebugger::reset
void reset(const lldb::DebuggerSP &debugger_sp)
Definition: SBDebugger.cpp:1285
lldb::SBTarget::Clear
void Clear()
Definition: SBTarget.cpp:1673
lldb::SBAttachInfo::ref
lldb_private::ProcessAttachInfo & ref()
Definition: SBAttachInfo.cpp:59
lldb_private::ArchSpec::IsValid
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:342
lldb::SBBreakpoint
class LLDB_API SBBreakpoint
Definition: SBDefines.h:23
TypeSystem.h
lldb::SBTarget::FindModule
lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec)
Definition: SBTarget.cpp:1679
lldb::SymbolType
SymbolType
Symbol types.
Definition: lldb-enumerations.h:612
Address.h
VariableList.h
lldb::SBBreakpointList
Definition: SBBreakpoint.h:159
lldb_private::ProcessAttachInfo
Definition: Process.h:113
ObjectFile.h
lldb::SBType
Definition: SBType.h:104
lldb_private::ModuleFunctionSearchOptions
Options used by Module::FindFunctions.
Definition: Module.h:63
lldb_private::Address::SetRawAddress
void SetRawAddress(lldb::addr_t addr)
Definition: Address.h:435
lldb::SBTarget::GetTrace
lldb::SBTrace GetTrace()
Get a SBTrace object the can manage the processor trace information of this target.
Definition: SBTarget.cpp:2465
lldb::SBTarget::ReadMemory
size_t ReadMemory(const SBAddress addr, void *buf, size_t size, lldb::SBError &error)
Read target memory.
Definition: SBTarget.cpp:687
lldb::SBTypeList::GetSize
uint32_t GetSize()
Definition: SBType.cpp:644
LLDB_INVALID_BREAK_ID
#define LLDB_INVALID_BREAK_ID
Definition: lldb-defines.h:49
lldb::SBFileSpecList::get
const lldb_private::FileSpecList * get() const
Definition: SBFileSpecList.cpp:95
lldb::SBTarget::SetSectionLoadAddress
lldb::SBError SetSectionLoadAddress(lldb::SBSection section, lldb::addr_t section_base_addr)
Set the base load address for a module section.
Definition: SBTarget.cpp:2175
ValueObjectConstResult.h
lldb::SBExpressionOptions::SetFetchDynamicValue
void SetFetchDynamicValue(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
Definition: SBExpressionOptions.cpp:92
lldb::SBTarget::FindWatchpointByID
lldb::SBWatchpoint FindWatchpointByID(lldb::watch_id_t watch_id)
Definition: SBTarget.cpp:1424
lldb::SBTypeList
Definition: SBType.h:241
lldb::SBWatchpoint
Definition: SBWatchpoint.h:16
LLDB_RECORD_CONSTRUCTOR
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
Definition: ReproducerInstrumentation.h:133
lldb::SBTarget::GetDataByteSize
uint32_t GetDataByteSize()
Architecture data byte width accessor.
Definition: SBTarget.cpp:1728
lldb::SBLaunchInfo::SetExecutableFile
void SetExecutableFile(SBFileSpec exe_file, bool add_as_first_arg)
Set the executable file that will be used to launch the process and optionally set it as the first ar...
Definition: SBLaunchInfo.cpp:123
lldb::SBTarget::GetCollectingStats
bool GetCollectingStats()
Returns whether statistics collection are enabled.
Definition: SBTarget.cpp:233
lldb_private::repro::Registry
The registry contains a unique mapping between functions and their ID.
Definition: ReproducerInstrumentation.h:517
lldb_private::Target::Attach
Status Attach(ProcessAttachInfo &attach_info, Stream *stream)
Definition: Target.cpp:3170
lldb::SBTarget::ClearModuleLoadAddress
lldb::SBError ClearModuleLoadAddress(lldb::SBModule module)
Clear the section base load addresses for all sections in a module.
Definition: SBTarget.cpp:2284
lldb_private::Target::GetProcessSP
const lldb::ProcessSP & GetProcessSP() const
Definition: Target.cpp:211
lldb::SBTarget::GetTriple
const char * GetTriple()
Definition: SBTarget.cpp:1713
lldb::SBFileSpecList::GetSize
uint32_t GetSize() const
Definition: SBFileSpecList.cpp:47
lldb::SBTarget::GetBroadcaster
lldb::SBBroadcaster GetBroadcaster() const
Definition: SBTarget.cpp:1792
lldb::SBExpressionOptions
Definition: SBExpressionOptions.h:18
lldb_private::ModuleSpec::GetFileSpec
FileSpec & GetFileSpec()
Definition: ModuleSpec.h:58
lldb_private::ModuleSpec
Definition: ModuleSpec.h:26
lldb::SBTarget::SBProcess
friend class SBProcess
Definition: SBTarget.h:874
lldb_private::Status
Definition: Status.h:44
lldb::SBListener
Definition: SBListener.h:16
lldb::SBSymbolContext
Definition: SBSymbolContext.h:22
lldb::SBTarget::GetNumModulesFromEvent
static uint32_t GetNumModulesFromEvent(const lldb::SBEvent &event)
Definition: SBTarget.cpp:135
lldb::SBTarget::SetModuleLoadAddress
lldb::SBError SetModuleLoadAddress(lldb::SBModule module, int64_t sections_offset)
Slide all file addresses for all module sections so that module appears to loaded at these slide addr...
Definition: SBTarget.cpp:2249
lldb::SBTarget::LaunchSimple
SBProcess LaunchSimple(const char **argv, const char **envp, const char *working_directory)
Launch a new process with sensible defaults.
Definition: SBTarget.cpp:274
lldb::SBTarget::GetPlatform
lldb::SBPlatform GetPlatform()
Return the platform object associated with the target.
Definition: SBTarget.cpp:186
lldb::SBTarget::DeleteAllWatchpoints
bool DeleteAllWatchpoints()
Definition: SBTarget.cpp:1565
lldb_private::repro::RegisterMethods< SBTarget >
void RegisterMethods< SBTarget >(Registry &R)
Definition: SBTarget.cpp:2497
lldb::eByteOrderInvalid
@ eByteOrderInvalid
Definition: lldb-enumerations.h:139
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:437
lldb::SBLaunchInfo::ref
const lldb_private::ProcessLaunchInfo & ref() const
Definition: SBLaunchInfo.cpp:67
BreakpointIDList.h
uint32_t
lldb::SBTarget::operator=
const lldb::SBTarget & operator=(const lldb::SBTarget &rhs)
Definition: SBTarget.cpp:108
lldb::SBTarget::FindSymbols
lldb::SBSymbolContextList FindSymbols(const char *name, lldb::SymbolType type=eSymbolTypeAny)
Definition: SBTarget.cpp:2336
lldb_private::eLazyBoolNo
@ eLazyBoolNo
Definition: lldb-private-enumerations.h:115
LIBLLDB_LOG_BREAKPOINTS
#define LIBLLDB_LOG_BREAKPOINTS
Definition: Logging.h:19
lldb_private::ProcessInfo::GetEnvironment
Environment & GetEnvironment()
Definition: ProcessInfo.h:87
lldb::SBTarget::SBPlatform
friend class SBPlatform
Definition: SBTarget.h:873
lldb::SBTarget::m_opaque_sp
lldb::TargetSP m_opaque_sp
Definition: SBTarget.h:889
lldb_private::Address
Definition: Address.h:59
lldb::SBStructuredData
Definition: SBStructuredData.h:17
lldb::SBBreakpoint
Definition: SBBreakpoint.h:18
lldb_private::Target::EvaluateExpression
lldb::ExpressionResults EvaluateExpression(llvm::StringRef expression, ExecutionContextScope *exe_scope, lldb::ValueObjectSP &result_valobj_sp, const EvaluateExpressionOptions &options=EvaluateExpressionOptions(), std::string *fixed_expression=nullptr, ValueObject *ctx_obj=nullptr)
Definition: Target.cpp:2443
lldb::SBValue::GetSummary
const char * GetSummary()
Definition: SBValue.cpp:423
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
lldb::SBTarget::GetModuleAtIndex
lldb::SBModule GetModuleAtIndex(uint32_t idx)
Definition: SBTarget.cpp:1767
lldb_private::UUID::SetFromStringRef
bool SetFromStringRef(llvm::StringRef str)
Definition: UUID.cpp:96
lldb_private::BreakpointID
Definition: BreakpointID.h:22
lldb::SBTarget::Launch
lldb::SBProcess Launch(SBListener &listener, char const **argv, char const **envp, const char *stdin_path, const char *stdout_path, const char *stderr_path, const char *working_directory, uint32_t launch_flags, bool stop_at_entry, lldb::SBError &error)
Launch a new process.
Definition: SBTarget.cpp:312
lldb::SBTarget::GetByteOrder
lldb::ByteOrder GetByteOrder()
Definition: SBTarget.cpp:1704
lldb::SBTarget::FindBreakpointsByName
bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list)
Definition: SBTarget.cpp:1212
lldb::SBTrace
class LLDB_API SBTrace
Definition: SBDefines.h:78
lldb::SBModule
Definition: SBModule.h:20
lldb::SBData
Definition: SBData.h:20
lldb::SBInstructionList::SetDisassembler
void SetDisassembler(const lldb::DisassemblerSP &opaque_sp)
Definition: SBInstructionList.cpp:117
lldb::SBBreakpointList::AppendByID
void AppendByID(lldb::break_id_t id)
Definition: SBBreakpoint.cpp:953
lldb::SBType::GetSP
lldb::TypeImplSP GetSP()
Definition: SBType.cpp:77
lldb::SBSection::GetSP
lldb::SectionSP GetSP() const
Definition: SBSection.cpp:118
lldb::SBValue::SetSP
void SetSP(const lldb::ValueObjectSP &sp)
Definition: SBValue.cpp:1098
ArchSpec.h
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:31
lldb_private::Environment
Definition: Environment.h:18
lldb::SBData::IsValid
bool IsValid()
Definition: SBData.cpp:60
lldb::SBTarget::CreateValueFromData
lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data, lldb::SBType type)
Definition: SBTarget.cpp:1528
lldb::SBLaunchInfo::set_ref
void set_ref(const lldb_private::ProcessLaunchInfo &info)
Definition: SBLaunchInfo.cpp:71
lldb::SBTarget::ConnectRemote
lldb::SBProcess ConnectRemote(SBListener &listener, const char *url, const char *plugin_name, SBError &error)
Connect to a remote debug server with url.
Definition: SBTarget.cpp:544
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
lldb_private::ModuleSpec::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ModuleSpec.h:94
lldb::SBTarget::WatchAddress
lldb::SBWatchpoint WatchAddress(lldb::addr_t addr, size_t size, bool read, bool write, SBError &error)
Definition: SBTarget.cpp:1443
SBStructuredData.h
lldb::SBTarget::SBTarget
SBTarget()
Definition: SBTarget.cpp:96
lldb::SBTarget::BreakpointCreateForException
lldb::SBBreakpoint BreakpointCreateForException(lldb::LanguageType language, bool catch_bp, bool throw_bp)
Definition: SBTarget.cpp:1112
BreakpointID.h
LLDB_LOG
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:242
lldb::SBModule::GetSP
ModuleSP GetSP() const
Definition: SBModule.cpp:206
lldb::SBFileSpec
Definition: SBFileSpec.h:16
SBTrace.h
StructuredDataImpl.h
SBEvent.h
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:33
lldb::SBTarget::GetStatistics
lldb::SBStructuredData GetStatistics()
Returns a dump of the collected statistics.
Definition: SBTarget.cpp:209
lldb::SBTarget::IsLoaded
bool IsLoaded(const lldb::SBModule &module) const
Definition: SBTarget.cpp:2420
lldb::SBTarget::ResolveSymbolContextForAddress
SBSymbolContext ResolveSymbolContextForAddress(const SBAddress &addr, uint32_t resolve_scope)
Definition: SBTarget.cpp:670
lldb::SBAddress
Definition: SBAddress.h:17
LanguageRuntime.h
lldb::SBTarget::SetSP
void SetSP(const lldb::TargetSP &target_sp)
Definition: SBTarget.cpp:609
SBEnvironment.h
lldb::SBTarget::AppendImageSearchPath
void AppendImageSearchPath(const char *from, const char *to, lldb::SBError &error)
Definition: SBTarget.cpp:1579
lldb::SBTarget::DeleteBreakpointName
void DeleteBreakpointName(const char *name)
Definition: SBTarget.cpp:1252
lldb::SBAddress::ref
lldb_private::Address & ref()
Definition: SBAddress.cpp:180
lldb::SBError::ref
lldb_private::Status & ref()
Definition: SBError.cpp:159
lldb_private::ProcessInfo::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ProcessInfo.h:61
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb::SBTarget::FindFirstGlobalVariable
lldb::SBValue FindFirstGlobalVariable(const char *name)
Find the first global (or static) variable by name.
Definition: SBTarget.cpp:2055
lldb::SBLaunchInfo::SetArguments
void SetArguments(const char **argv, bool append)
Definition: SBLaunchInfo.cpp:157
lldb::SBTarget::BreakpointDelete
bool BreakpointDelete(break_id_t break_id)
Definition: SBTarget.cpp:1184
lldb_private::eLazyBoolCalculate
@ eLazyBoolCalculate
Definition: lldb-private-enumerations.h:115
lldb_private::VariableList::Empty
bool Empty() const
Definition: VariableList.h:68
lldb::SBTarget::EventIsTargetEvent
static bool EventIsTargetEvent(const lldb::SBEvent &event)
Definition: SBTarget.cpp:120
lldb::eMatchTypeRegex
@ eMatchTypeRegex
Definition: lldb-enumerations.h:1032
lldb::SBTarget::CreateValueFromAddress
lldb::SBValue CreateValueFromAddress(const char *name, lldb::SBAddress addr, lldb::SBType type)
Definition: SBTarget.cpp:1508
lldb_private::ProcessInfo::GetExecutableFile
FileSpec & GetExecutableFile()
Definition: ProcessInfo.h:42
lldb_private::TypeList
Definition: TypeList.h:20
lldb_private::ModuleList::GetModuleAtIndex
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
Definition: ModuleList.cpp:351
FileSpec.h
lldb::SBLaunchInfo::SetWorkingDirectory
void SetWorkingDirectory(const char *working_dir)
Definition: SBLaunchInfo.cpp:224
lldb::eStateInvalid
@ eStateInvalid
Definition: lldb-enumerations.h:74
lldb::SBSection::IsValid
bool IsValid() const
Definition: SBSection.cpp:49
lldb::SBTarget::GetSP
lldb::TargetSP GetSP() const
Definition: SBTarget.cpp:607
lldb::SBAddress::get
lldb_private::Address * get()
Definition: SBAddress.cpp:193
lldb::SBTarget::EnableAllBreakpoints
bool EnableAllBreakpoints()
Definition: SBTarget.cpp:1263
lldb::SBTarget::GetBreakpointAtIndex
lldb::SBBreakpoint GetBreakpointAtIndex(uint32_t idx) const
Definition: SBTarget.cpp:1171
lldb_private::BreakpointIDList::GetSize
size_t GetSize() const
Definition: BreakpointIDList.cpp:28
lldb::SBBroadcaster
Definition: SBBroadcaster.h:16
lldb::SBTarget::FindTypes
lldb::SBTypeList FindTypes(const char *type)
Definition: SBTarget.cpp:1937
SBProcess.h
ValueObjectVariable.h
lldb::SBTypeList::Append
void Append(lldb::SBType type)
Definition: SBType.cpp:628
lldb_private::BreakpointIDList::GetBreakpointIDAtIndex
const BreakpointID & GetBreakpointIDAtIndex(size_t index) const
Definition: BreakpointIDList.cpp:31
LLDB_RECORD_STATIC_METHOD
#define LLDB_RECORD_STATIC_METHOD(Result, Class, Method, Signature,...)
Definition: ReproducerInstrumentation.h:171
lldb::SBTarget::FindGlobalVariables
lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches)
Find global and static variables by name.
Definition: SBTarget.cpp:1981
lldb::StateType
StateType
Process and Thread States.
Definition: lldb-enumerations.h:73
lldb_private::Log
Definition: Log.h:49
lldb_private::ModuleList::FindTypes
void FindTypes(Module *search_first, ConstString name, bool name_is_fully_qualified, size_t max_matches, llvm::DenseSet< SymbolFile * > &searched_symbol_files, TypeList &types) const
Find types by name.
Definition: ModuleList.cpp:510
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb::SBType::IsValid
bool IsValid() const
Definition: SBType.cpp:109
lldb_private::FileSpec::SetFile
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition: FileSpec.cpp:172
lldb::SBTarget::BreakpointCreateFromScript
lldb::SBBreakpoint BreakpointCreateFromScript(const char *class_name, SBStructuredData &extra_args, const SBFileSpecList &module_list, const SBFileSpecList &file_list, bool request_hardware=false)
Create a breakpoint using a scripted resolver.
Definition: SBTarget.cpp:1130
lldb::SBTarget::GetSourceManager
SBSourceManager GetSourceManager()
Definition: SBTarget.cpp:2065
lldb::SBStream
Definition: SBStream.h:18
lldb::SBTarget::GetStackRedZoneSize
lldb::addr_t GetStackRedZoneSize()
Definition: SBTarget.cpp:2403
lldb::SBTarget::GetDescription
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition: SBTarget.cpp:1804
LLDB_RECORD_METHOD_CONST
#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature,...)
Definition: ReproducerInstrumentation.h:161
SymbolVendor.h
PATH_MAX
#define PATH_MAX
Definition: windows/PosixApi.h:25
SBTarget.h
lldb::SBValueList::GetSize
uint32_t GetSize() const
Definition: SBValueList.cpp:164
lldb_private::StackFrame
Definition: StackFrame.h:40
lldb::SBTarget::~SBTarget
~SBTarget()
lldb::SBPlatform
Definition: SBPlatform.h:93
lldb_private::DataBufferHeap
Definition: DataBufferHeap.h:30
lldb::SBFileSpecList::Append
void Append(const SBFileSpec &sb_file)
Definition: SBFileSpecList.cpp:53
lldb::SBTarget::ResolvePastLoadAddress
lldb::SBAddress ResolvePastLoadAddress(uint32_t stop_id, lldb::addr_t vm_addr)
Resolve a current load address into a section offset address using the process stop ID to identify a ...
Definition: SBTarget.cpp:649
lldb::SBAttachInfo
Definition: SBAttachInfo.h:18
lldb
Definition: SBAddress.h:15
lldb::SBTarget::BreakpointCreateBySBAddress
lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address)
Definition: SBTarget.cpp:1025
lldb::SBFileSpec
class LLDB_API SBFileSpec
Definition: SBDefines.h:46
ValueObjectList.h
lldb_private::ProcessAttachInfo::SetWaitForLaunch
void SetWaitForLaunch(bool b)
Definition: Process.h:134
lldb_private::ExecutionContextRef
Execution context objects refer to objects in the execution of the program that is being debugged.
Definition: ExecutionContext.h:72
lldb::SBTarget::FindGlobalFunctions
lldb::SBSymbolContextList FindGlobalFunctions(const char *name, uint32_t max_matches, MatchType matchtype)
Find global functions by their name with pattern matching.
Definition: SBTarget.cpp:1844
SymbolFile.h
lldb_private::BreakpointIDList
Definition: BreakpointIDList.h:25
lldb_private::ExecutionContext::GetTargetPtr
Target * GetTargetPtr() const
Returns a pointer to the target object.
Definition: ExecutionContext.cpp:200
lldb_private::ObjectFile
Definition: ObjectFile.h:59
lldb_private::ModuleList::Append
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
lldb::SBTarget::LoadCore
SBProcess LoadCore(const char *core_file)
Definition: SBTarget.cpp:242
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207
lldb::SBFileSpecList
Definition: SBFileSpecList.h:17
SBBreakpoint.h
lldb::ByteOrder
ByteOrder
Byte ordering definitions.
Definition: lldb-enumerations.h:138
LLDB_REGISTER_METHOD
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
Definition: ReproducerInstrumentation.h:93
lldb::SBSourceManager
Definition: SBSourceManager.h:18