LLDB  mainline
SBTarget.cpp
Go to the documentation of this file.
1 //===-- SBTarget.cpp --------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/API/SBTarget.h"
10 #include "SBReproducerPrivate.h"
11 
12 #include "lldb/lldb-public.h"
13 
14 #include "lldb/API/SBBreakpoint.h"
15 #include "lldb/API/SBDebugger.h"
16 #include "lldb/API/SBEvent.h"
18 #include "lldb/API/SBFileSpec.h"
19 #include "lldb/API/SBListener.h"
20 #include "lldb/API/SBModule.h"
21 #include "lldb/API/SBModuleSpec.h"
22 #include "lldb/API/SBProcess.h"
24 #include "lldb/API/SBStream.h"
25 #include "lldb/API/SBStringList.h"
32 #include "lldb/Core/Address.h"
35 #include "lldb/Core/Debugger.h"
36 #include "lldb/Core/Disassembler.h"
37 #include "lldb/Core/Module.h"
38 #include "lldb/Core/ModuleSpec.h"
39 #include "lldb/Core/STLUtils.h"
40 #include "lldb/Core/SearchFilter.h"
41 #include "lldb/Core/Section.h"
46 #include "lldb/Host/Host.h"
48 #include "lldb/Symbol/DeclVendor.h"
49 #include "lldb/Symbol/ObjectFile.h"
50 #include "lldb/Symbol/SymbolFile.h"
53 #include "lldb/Target/ABI.h"
54 #include "lldb/Target/Language.h"
57 #include "lldb/Target/Process.h"
58 #include "lldb/Target/StackFrame.h"
59 #include "lldb/Target/Target.h"
60 #include "lldb/Target/TargetList.h"
61 #include "lldb/Utility/ArchSpec.h"
62 #include "lldb/Utility/Args.h"
63 #include "lldb/Utility/FileSpec.h"
66 
69 #include "llvm/Support/PrettyStackTrace.h"
70 #include "llvm/Support/Regex.h"
71 
72 using namespace lldb;
73 using namespace lldb_private;
74 
75 #define DEFAULT_DISASM_BYTE_SIZE 32
76 
77 namespace {
78 
79 Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) {
80  std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex());
81 
82  auto process_sp = target.GetProcessSP();
83  if (process_sp) {
84  const auto state = process_sp->GetState();
85  if (process_sp->IsAlive() && state == eStateConnected) {
86  // If we are already connected, then we have already specified the
87  // listener, so if a valid listener is supplied, we need to error out to
88  // let the client know.
89  if (attach_info.GetListener())
90  return Status("process is connected and already has a listener, pass "
91  "empty listener");
92  }
93  }
94 
95  return target.Attach(attach_info, nullptr);
96 }
97 
98 } // namespace
99 
100 // SBTarget constructor
101 SBTarget::SBTarget() : m_opaque_sp() {
103 }
104 
105 SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) {
107 }
108 
109 SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) {
110  LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &), target_sp);
111 }
112 
115  SBTarget, operator=,(const lldb::SBTarget &), rhs);
116 
117  if (this != &rhs)
118  m_opaque_sp = rhs.m_opaque_sp;
119  return LLDB_RECORD_RESULT(*this);
120 }
121 
122 // Destructor
124 
127  (const lldb::SBEvent &), event);
128 
129  return Target::TargetEventData::GetEventDataFromEvent(event.get()) != NULL;
130 }
131 
134  (const lldb::SBEvent &), event);
135 
136  return LLDB_RECORD_RESULT(
137  Target::TargetEventData::GetTargetFromEvent(event.get()));
138 }
139 
142  (const lldb::SBEvent &), event);
143 
144  const ModuleList module_list =
145  Target::TargetEventData::GetModuleListFromEvent(event.get());
146  return module_list.GetSize();
147 }
148 
150  const SBEvent &event) {
152  (const uint32_t, const lldb::SBEvent &), idx,
153  event);
154 
155  const ModuleList module_list =
156  Target::TargetEventData::GetModuleListFromEvent(event.get());
157  return LLDB_RECORD_RESULT(SBModule(module_list.GetModuleAtIndex(idx)));
158 }
159 
163 
164  return Target::GetStaticBroadcasterClass().AsCString();
165 }
166 
167 bool SBTarget::IsValid() const {
169  return this->operator bool();
170 }
171 SBTarget::operator bool() const {
172  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, operator bool);
173 
174  return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
175 }
176 
179 
180  SBProcess sb_process;
181  ProcessSP process_sp;
182  TargetSP target_sp(GetSP());
183  if (target_sp) {
184  process_sp = target_sp->GetProcessSP();
185  sb_process.SetSP(process_sp);
186  }
187 
188  return LLDB_RECORD_RESULT(sb_process);
189 }
190 
193 
194  TargetSP target_sp(GetSP());
195  if (!target_sp)
196  return LLDB_RECORD_RESULT(SBPlatform());
197 
198  SBPlatform platform;
199  platform.m_opaque_sp = target_sp->GetPlatform();
200 
201  return LLDB_RECORD_RESULT(platform);
202 }
203 
206 
207  SBDebugger debugger;
208  TargetSP target_sp(GetSP());
209  if (target_sp)
210  debugger.reset(target_sp->GetDebugger().shared_from_this());
211  return LLDB_RECORD_RESULT(debugger);
212 }
213 
216 
217  SBStructuredData data;
218  TargetSP target_sp(GetSP());
219  if (!target_sp)
220  return LLDB_RECORD_RESULT(data);
221 
222  auto stats_up = llvm::make_unique<StructuredData::Dictionary>();
223  int i = 0;
224  for (auto &Entry : target_sp->GetStatistics()) {
225  std::string Desc = lldb_private::GetStatDescription(
226  static_cast<lldb_private::StatisticKind>(i));
227  stats_up->AddIntegerItem(Desc, Entry);
228  i += 1;
229  }
230 
231  data.m_impl_up->SetObjectSP(std::move(stats_up));
232  return LLDB_RECORD_RESULT(data);
233 }
234 
237 
238  TargetSP target_sp(GetSP());
239  if (!target_sp)
240  return;
241  return target_sp->SetCollectingStats(v);
242 }
243 
246 
247  TargetSP target_sp(GetSP());
248  if (!target_sp)
249  return false;
250  return target_sp->GetCollectingStats();
251 }
252 
253 SBProcess SBTarget::LoadCore(const char *core_file) {
255  core_file);
256 
257  lldb::SBError error; // Ignored
258  return LLDB_RECORD_RESULT(LoadCore(core_file, error));
259 }
260 
261 SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) {
263  (const char *, lldb::SBError &), core_file, error);
264 
265  SBProcess sb_process;
266  TargetSP target_sp(GetSP());
267  if (target_sp) {
268  FileSpec filespec(core_file);
269  FileSystem::Instance().Resolve(filespec);
270  ProcessSP process_sp(target_sp->CreateProcess(
271  target_sp->GetDebugger().GetListener(), "", &filespec));
272  if (process_sp) {
273  error.SetError(process_sp->LoadCore());
274  if (error.Success())
275  sb_process.SetSP(process_sp);
276  } else {
277  error.SetErrorString("Failed to create the process");
278  }
279  } else {
280  error.SetErrorString("SBTarget is invalid");
281  }
282  return LLDB_RECORD_RESULT(sb_process);
283 }
284 
285 SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp,
286  const char *working_directory) {
288  (const char **, const char **, const char *), argv, envp,
289  working_directory);
290 
291  char *stdin_path = NULL;
292  char *stdout_path = NULL;
293  char *stderr_path = NULL;
294  uint32_t launch_flags = 0;
295  bool stop_at_entry = false;
296  SBError error;
297  SBListener listener = GetDebugger().GetListener();
298  return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path,
299  stdout_path, stderr_path, working_directory,
300  launch_flags, stop_at_entry, error));
301 }
302 
305 
306  SBError sb_error;
307  TargetSP target_sp(GetSP());
308  if (target_sp) {
309  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
310  sb_error.ref() = target_sp->Install(NULL);
311  }
312  return LLDB_RECORD_RESULT(sb_error);
313 }
314 
315 SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
316  char const **envp, const char *stdin_path,
317  const char *stdout_path, const char *stderr_path,
318  const char *working_directory,
319  uint32_t launch_flags, // See LaunchFlags
320  bool stop_at_entry, lldb::SBError &error) {
322  (lldb::SBListener &, const char **, const char **,
323  const char *, const char *, const char *, const char *,
324  uint32_t, bool, lldb::SBError &),
325  listener, argv, envp, stdin_path, stdout_path, stderr_path,
326  working_directory, launch_flags, stop_at_entry, error);
327 
328  SBProcess sb_process;
329  ProcessSP process_sp;
330  TargetSP target_sp(GetSP());
331 
332  if (target_sp) {
333  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
334 
335  if (stop_at_entry)
336  launch_flags |= eLaunchFlagStopAtEntry;
337 
338  if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
339  launch_flags |= eLaunchFlagDisableASLR;
340 
341  StateType state = eStateInvalid;
342  process_sp = target_sp->GetProcessSP();
343  if (process_sp) {
344  state = process_sp->GetState();
345 
346  if (process_sp->IsAlive() && state != eStateConnected) {
347  if (state == eStateAttaching)
348  error.SetErrorString("process attach is in progress");
349  else
350  error.SetErrorString("a process is already being debugged");
351  return LLDB_RECORD_RESULT(sb_process);
352  }
353  }
354 
355  if (state == eStateConnected) {
356  // If we are already connected, then we have already specified the
357  // listener, so if a valid listener is supplied, we need to error out to
358  // let the client know.
359  if (listener.IsValid()) {
360  error.SetErrorString("process is connected and already has a listener, "
361  "pass empty listener");
362  return LLDB_RECORD_RESULT(sb_process);
363  }
364  }
365 
366  if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
367  launch_flags |= eLaunchFlagDisableSTDIO;
368 
369  ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path),
370  FileSpec(stderr_path),
371  FileSpec(working_directory), launch_flags);
372 
373  Module *exe_module = target_sp->GetExecutableModulePointer();
374  if (exe_module)
375  launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
376  if (argv)
377  launch_info.GetArguments().AppendArguments(argv);
378  if (envp)
379  launch_info.GetEnvironment() = Environment(envp);
380 
381  if (listener.IsValid())
382  launch_info.SetListener(listener.GetSP());
383 
384  error.SetError(target_sp->Launch(launch_info, NULL));
385 
386  sb_process.SetSP(target_sp->GetProcessSP());
387  } else {
388  error.SetErrorString("SBTarget is invalid");
389  }
390 
391  return LLDB_RECORD_RESULT(sb_process);
392 }
393 
394 SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) {
396  (lldb::SBLaunchInfo &, lldb::SBError &), sb_launch_info,
397  error);
398 
399 
400  SBProcess sb_process;
401  TargetSP target_sp(GetSP());
402 
403  if (target_sp) {
404  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
405  StateType state = eStateInvalid;
406  {
407  ProcessSP process_sp = target_sp->GetProcessSP();
408  if (process_sp) {
409  state = process_sp->GetState();
410 
411  if (process_sp->IsAlive() && state != eStateConnected) {
412  if (state == eStateAttaching)
413  error.SetErrorString("process attach is in progress");
414  else
415  error.SetErrorString("a process is already being debugged");
416  return LLDB_RECORD_RESULT(sb_process);
417  }
418  }
419  }
420 
421  lldb_private::ProcessLaunchInfo launch_info = sb_launch_info.ref();
422 
423  if (!launch_info.GetExecutableFile()) {
424  Module *exe_module = target_sp->GetExecutableModulePointer();
425  if (exe_module)
426  launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
427  }
428 
429  const ArchSpec &arch_spec = target_sp->GetArchitecture();
430  if (arch_spec.IsValid())
431  launch_info.GetArchitecture() = arch_spec;
432 
433  error.SetError(target_sp->Launch(launch_info, NULL));
434  sb_launch_info.set_ref(launch_info);
435  sb_process.SetSP(target_sp->GetProcessSP());
436  } else {
437  error.SetErrorString("SBTarget is invalid");
438  }
439 
440  return LLDB_RECORD_RESULT(sb_process);
441 }
442 
445  (lldb::SBAttachInfo &, lldb::SBError &), sb_attach_info,
446  error);
447 
448  SBProcess sb_process;
449  TargetSP target_sp(GetSP());
450 
451  if (target_sp) {
452  ProcessAttachInfo &attach_info = sb_attach_info.ref();
453  if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid()) {
454  PlatformSP platform_sp = target_sp->GetPlatform();
455  // See if we can pre-verify if a process exists or not
456  if (platform_sp && platform_sp->IsConnected()) {
457  lldb::pid_t attach_pid = attach_info.GetProcessID();
458  ProcessInstanceInfo instance_info;
459  if (platform_sp->GetProcessInfo(attach_pid, instance_info)) {
460  attach_info.SetUserID(instance_info.GetEffectiveUserID());
461  } else {
463  "no process found with process ID %" PRIu64, attach_pid);
464  return LLDB_RECORD_RESULT(sb_process);
465  }
466  }
467  }
468  error.SetError(AttachToProcess(attach_info, *target_sp));
469  if (error.Success())
470  sb_process.SetSP(target_sp->GetProcessSP());
471  } else {
472  error.SetErrorString("SBTarget is invalid");
473  }
474 
475  return LLDB_RECORD_RESULT(sb_process);
476 }
477 
479  SBListener &listener,
480  lldb::pid_t pid, // The process ID to attach to
481  SBError &error // An error explaining what went wrong if attach fails
482 ) {
485  listener, pid, error);
486 
487  SBProcess sb_process;
488  TargetSP target_sp(GetSP());
489 
490  if (target_sp) {
491  ProcessAttachInfo attach_info;
492  attach_info.SetProcessID(pid);
493  if (listener.IsValid())
494  attach_info.SetListener(listener.GetSP());
495 
496  ProcessInstanceInfo instance_info;
497  if (target_sp->GetPlatform()->GetProcessInfo(pid, instance_info))
498  attach_info.SetUserID(instance_info.GetEffectiveUserID());
499 
500  error.SetError(AttachToProcess(attach_info, *target_sp));
501  if (error.Success())
502  sb_process.SetSP(target_sp->GetProcessSP());
503  } else
504  error.SetErrorString("SBTarget is invalid");
505 
506  return LLDB_RECORD_RESULT(sb_process);
507 }
508 
510  SBListener &listener,
511  const char *name, // basename of process to attach to
512  bool wait_for, // if true wait for a new instance of "name" to be launched
513  SBError &error // An error explaining what went wrong if attach fails
514 ) {
516  (lldb::SBListener &, const char *, bool, lldb::SBError &),
517  listener, name, wait_for, error);
518 
519  SBProcess sb_process;
520  TargetSP target_sp(GetSP());
521 
522  if (name && target_sp) {
523  ProcessAttachInfo attach_info;
524  attach_info.GetExecutableFile().SetFile(name, FileSpec::Style::native);
525  attach_info.SetWaitForLaunch(wait_for);
526  if (listener.IsValid())
527  attach_info.SetListener(listener.GetSP());
528 
529  error.SetError(AttachToProcess(attach_info, *target_sp));
530  if (error.Success())
531  sb_process.SetSP(target_sp->GetProcessSP());
532  } else
533  error.SetErrorString("SBTarget is invalid");
534 
535  return LLDB_RECORD_RESULT(sb_process);
536 }
537 
539  const char *plugin_name,
540  SBError &error) {
543  (lldb::SBListener &, const char *, const char *, lldb::SBError &),
544  listener, url, plugin_name, error);
545 
546  SBProcess sb_process;
547  ProcessSP process_sp;
548  TargetSP target_sp(GetSP());
549 
550  if (target_sp) {
551  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
552  if (listener.IsValid())
553  process_sp =
554  target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, NULL);
555  else
556  process_sp = target_sp->CreateProcess(
557  target_sp->GetDebugger().GetListener(), plugin_name, NULL);
558 
559  if (process_sp) {
560  sb_process.SetSP(process_sp);
561  error.SetError(process_sp->ConnectRemote(NULL, url));
562  } else {
563  error.SetErrorString("unable to create lldb_private::Process");
564  }
565  } else {
566  error.SetErrorString("SBTarget is invalid");
567  }
568 
569  return LLDB_RECORD_RESULT(sb_process);
570 }
571 
574 
575  SBFileSpec exe_file_spec;
576  TargetSP target_sp(GetSP());
577  if (target_sp) {
578  Module *exe_module = target_sp->GetExecutableModulePointer();
579  if (exe_module)
580  exe_file_spec.SetFileSpec(exe_module->GetFileSpec());
581  }
582 
583  return LLDB_RECORD_RESULT(exe_file_spec);
584 }
585 
586 bool SBTarget::operator==(const SBTarget &rhs) const {
587  LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator==,(const lldb::SBTarget &),
588  rhs);
589 
590  return m_opaque_sp.get() == rhs.m_opaque_sp.get();
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 lldb::TargetSP SBTarget::GetSP() const { return m_opaque_sp; }
601 
602 void SBTarget::SetSP(const lldb::TargetSP &target_sp) {
603  m_opaque_sp = target_sp;
604 }
605 
608  (lldb::addr_t), vm_addr);
609 
610  lldb::SBAddress sb_addr;
611  Address &addr = sb_addr.ref();
612  TargetSP target_sp(GetSP());
613  if (target_sp) {
614  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
615  if (target_sp->ResolveLoadAddress(vm_addr, addr))
616  return LLDB_RECORD_RESULT(sb_addr);
617  }
618 
619  // We have a load address that isn't in a section, just return an address
620  // with the offset filled in (the address) and the section set to NULL
621  addr.SetRawAddress(vm_addr);
622  return LLDB_RECORD_RESULT(sb_addr);
623 }
624 
627  (lldb::addr_t), file_addr);
628 
629  lldb::SBAddress sb_addr;
630  Address &addr = sb_addr.ref();
631  TargetSP target_sp(GetSP());
632  if (target_sp) {
633  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
634  if (target_sp->ResolveFileAddress(file_addr, addr))
635  return LLDB_RECORD_RESULT(sb_addr);
636  }
637 
638  addr.SetRawAddress(file_addr);
639  return LLDB_RECORD_RESULT(sb_addr);
640 }
641 
643  lldb::addr_t vm_addr) {
645  (uint32_t, lldb::addr_t), stop_id, vm_addr);
646 
647  lldb::SBAddress sb_addr;
648  Address &addr = sb_addr.ref();
649  TargetSP target_sp(GetSP());
650  if (target_sp) {
651  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
652  if (target_sp->ResolveLoadAddress(vm_addr, addr))
653  return LLDB_RECORD_RESULT(sb_addr);
654  }
655 
656  // We have a load address that isn't in a section, just return an address
657  // with the offset filled in (the address) and the section set to NULL
658  addr.SetRawAddress(vm_addr);
659  return LLDB_RECORD_RESULT(sb_addr);
660 }
661 
664  uint32_t resolve_scope) {
667  (const lldb::SBAddress &, uint32_t), addr, resolve_scope);
668 
669  SBSymbolContext sc;
670  SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
671  if (addr.IsValid()) {
672  TargetSP target_sp(GetSP());
673  if (target_sp)
674  target_sp->GetImages().ResolveSymbolContextForAddress(addr.ref(), scope,
675  sc.ref());
676  }
677  return LLDB_RECORD_RESULT(sc);
678 }
679 
680 size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size,
681  lldb::SBError &error) {
683  (const lldb::SBAddress, void *, size_t, lldb::SBError &),
684  addr, buf, size, error);
685 
686  SBError sb_error;
687  size_t bytes_read = 0;
688  TargetSP target_sp(GetSP());
689  if (target_sp) {
690  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
691  bytes_read =
692  target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref());
693  } else {
694  sb_error.SetErrorString("invalid target");
695  }
696 
697  return bytes_read;
698 }
699 
701  uint32_t line) {
703  (const char *, uint32_t), file, line);
704 
705  return LLDB_RECORD_RESULT(
706  SBBreakpoint(BreakpointCreateByLocation(SBFileSpec(file, false), line)));
707 }
708 
711  uint32_t line) {
713  (const lldb::SBFileSpec &, uint32_t), sb_file_spec, line);
714 
715  return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0));
716 }
717 
720  uint32_t line, lldb::addr_t offset) {
723  sb_file_spec, line, offset);
724 
725  SBFileSpecList empty_list;
726  return LLDB_RECORD_RESULT(
727  BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list));
728 }
729 
732  uint32_t line, lldb::addr_t offset,
733  SBFileSpecList &sb_module_list) {
737  sb_file_spec, line, offset, sb_module_list);
738 
739  return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0,
740  offset, sb_module_list));
741 }
742 
744  const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
745  lldb::addr_t offset, SBFileSpecList &sb_module_list) {
749  sb_file_spec, line, column, offset, sb_module_list);
750 
751  SBBreakpoint sb_bp;
752  TargetSP target_sp(GetSP());
753  if (target_sp && line != 0) {
754  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
755 
756  const LazyBool check_inlines = eLazyBoolCalculate;
757  const LazyBool skip_prologue = eLazyBoolCalculate;
758  const bool internal = false;
759  const bool hardware = false;
760  const LazyBool move_to_nearest_code = eLazyBoolCalculate;
761  const FileSpecList *module_list = nullptr;
762  if (sb_module_list.GetSize() > 0) {
763  module_list = sb_module_list.get();
764  }
765  sb_bp = target_sp->CreateBreakpoint(
766  module_list, *sb_file_spec, line, column, offset, check_inlines,
767  skip_prologue, internal, hardware, move_to_nearest_code);
768  }
769 
770  return LLDB_RECORD_RESULT(sb_bp);
771 }
772 
774  const char *module_name) {
776  (const char *, const char *), symbol_name, module_name);
777 
778  SBBreakpoint sb_bp;
779  TargetSP target_sp(GetSP());
780  if (target_sp.get()) {
781  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
782 
783  const bool internal = false;
784  const bool hardware = false;
785  const LazyBool skip_prologue = eLazyBoolCalculate;
786  const lldb::addr_t offset = 0;
787  if (module_name && module_name[0]) {
788  FileSpecList module_spec_list;
789  module_spec_list.Append(FileSpec(module_name));
790  sb_bp = target_sp->CreateBreakpoint(
791  &module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto,
792  eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
793  } else {
794  sb_bp = target_sp->CreateBreakpoint(
795  NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown,
796  offset, skip_prologue, internal, hardware);
797  }
798  }
799 
800  return LLDB_RECORD_RESULT(sb_bp);
801 }
802 
804 SBTarget::BreakpointCreateByName(const char *symbol_name,
805  const SBFileSpecList &module_list,
806  const SBFileSpecList &comp_unit_list) {
808  (const char *, const lldb::SBFileSpecList &,
809  const lldb::SBFileSpecList &),
810  symbol_name, module_list, comp_unit_list);
811 
812  lldb::FunctionNameType name_type_mask = eFunctionNameTypeAuto;
813  return LLDB_RECORD_RESULT(
814  BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown,
815  module_list, comp_unit_list));
816 }
817 
819  const char *symbol_name, uint32_t name_type_mask,
820  const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
822  (const char *, uint32_t, const lldb::SBFileSpecList &,
823  const lldb::SBFileSpecList &),
824  symbol_name, name_type_mask, module_list, comp_unit_list);
825 
826  return LLDB_RECORD_RESULT(
827  BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown,
828  module_list, comp_unit_list));
829 }
830 
832  const char *symbol_name, uint32_t name_type_mask,
833  LanguageType symbol_language, const SBFileSpecList &module_list,
834  const SBFileSpecList &comp_unit_list) {
836  (const char *, uint32_t, lldb::LanguageType,
837  const lldb::SBFileSpecList &,
838  const lldb::SBFileSpecList &),
839  symbol_name, name_type_mask, symbol_language, module_list,
840  comp_unit_list);
841 
842  SBBreakpoint sb_bp;
843  TargetSP target_sp(GetSP());
844  if (target_sp && symbol_name && symbol_name[0]) {
845  const bool internal = false;
846  const bool hardware = false;
847  const LazyBool skip_prologue = eLazyBoolCalculate;
848  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
849  FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
850  sb_bp = target_sp->CreateBreakpoint(module_list.get(), comp_unit_list.get(),
851  symbol_name, mask, symbol_language, 0,
852  skip_prologue, internal, hardware);
853  }
854 
855  return LLDB_RECORD_RESULT(sb_bp);
856 }
857 
859  const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
860  const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
863  (const char **, uint32_t, uint32_t, const lldb::SBFileSpecList &,
864  const lldb::SBFileSpecList &),
865  symbol_names, num_names, name_type_mask, module_list, comp_unit_list);
866 
868  symbol_names, num_names, name_type_mask, eLanguageTypeUnknown,
869  module_list, comp_unit_list));
870 }
871 
873  const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
874  LanguageType symbol_language, const SBFileSpecList &module_list,
875  const SBFileSpecList &comp_unit_list) {
877  (const char **, uint32_t, uint32_t, lldb::LanguageType,
878  const lldb::SBFileSpecList &,
879  const lldb::SBFileSpecList &),
880  symbol_names, num_names, name_type_mask, symbol_language,
881  module_list, comp_unit_list);
882 
884  symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 0,
885  module_list, comp_unit_list));
886 }
887 
889  const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
890  LanguageType symbol_language, lldb::addr_t offset,
891  const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
893  (const char **, uint32_t, uint32_t, lldb::LanguageType,
895  const lldb::SBFileSpecList &),
896  symbol_names, num_names, name_type_mask, symbol_language,
897  offset, module_list, comp_unit_list);
898 
899  SBBreakpoint sb_bp;
900  TargetSP target_sp(GetSP());
901  if (target_sp && num_names > 0) {
902  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
903  const bool internal = false;
904  const bool hardware = false;
905  FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
906  const LazyBool skip_prologue = eLazyBoolCalculate;
907  sb_bp = target_sp->CreateBreakpoint(
908  module_list.get(), comp_unit_list.get(), symbol_names, num_names, mask,
909  symbol_language, offset, skip_prologue, internal, hardware);
910  }
911 
912  return LLDB_RECORD_RESULT(sb_bp);
913 }
914 
915 SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
916  const char *module_name) {
918  (const char *, const char *), symbol_name_regex,
919  module_name);
920 
921  SBFileSpecList module_spec_list;
922  SBFileSpecList comp_unit_list;
923  if (module_name && module_name[0]) {
924  module_spec_list.Append(FileSpec(module_name));
925  }
926  return LLDB_RECORD_RESULT(
928  module_spec_list, comp_unit_list));
929 }
930 
932 SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
933  const SBFileSpecList &module_list,
934  const SBFileSpecList &comp_unit_list) {
936  (const char *, const lldb::SBFileSpecList &,
937  const lldb::SBFileSpecList &),
938  symbol_name_regex, module_list, comp_unit_list);
939 
941  symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list));
942 }
943 
945  const char *symbol_name_regex, LanguageType symbol_language,
946  const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
949  (const char *, lldb::LanguageType, const lldb::SBFileSpecList &,
950  const lldb::SBFileSpecList &),
951  symbol_name_regex, symbol_language, module_list, comp_unit_list);
952 
953 
954  SBBreakpoint sb_bp;
955  TargetSP target_sp(GetSP());
956  if (target_sp && symbol_name_regex && symbol_name_regex[0]) {
957  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
958  RegularExpression regexp((llvm::StringRef(symbol_name_regex)));
959  const bool internal = false;
960  const bool hardware = false;
961  const LazyBool skip_prologue = eLazyBoolCalculate;
962 
963  sb_bp = target_sp->CreateFuncRegexBreakpoint(
964  module_list.get(), comp_unit_list.get(), regexp, symbol_language,
965  skip_prologue, internal, hardware);
966  }
967 
968  return LLDB_RECORD_RESULT(sb_bp);
969 }
970 
973  (lldb::addr_t), address);
974 
975  SBBreakpoint sb_bp;
976  TargetSP target_sp(GetSP());
977  if (target_sp) {
978  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
979  const bool hardware = false;
980  sb_bp = target_sp->CreateBreakpoint(address, false, hardware);
981  }
982 
983  return LLDB_RECORD_RESULT(sb_bp);
984 }
985 
988  (lldb::SBAddress &), sb_address);
989 
990  SBBreakpoint sb_bp;
991  TargetSP target_sp(GetSP());
992  if (!sb_address.IsValid()) {
993  return LLDB_RECORD_RESULT(sb_bp);
994  }
995 
996  if (target_sp) {
997  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
998  const bool hardware = false;
999  sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware);
1000  }
1001 
1002  return LLDB_RECORD_RESULT(sb_bp);
1003 }
1004 
1007  const lldb::SBFileSpec &source_file,
1008  const char *module_name) {
1011  (const char *, const lldb::SBFileSpec &, const char *),
1012  source_regex, source_file, module_name);
1013 
1014  SBFileSpecList module_spec_list;
1015 
1016  if (module_name && module_name[0]) {
1017  module_spec_list.Append(FileSpec(module_name));
1018  }
1019 
1020  SBFileSpecList source_file_list;
1021  if (source_file.IsValid()) {
1022  source_file_list.Append(source_file);
1023  }
1024 
1026  source_regex, module_spec_list, source_file_list));
1027 }
1028 
1030  const char *source_regex, const SBFileSpecList &module_list,
1031  const lldb::SBFileSpecList &source_file_list) {
1034  (const char *, const lldb::SBFileSpecList &,
1035  const lldb::SBFileSpecList &),
1036  source_regex, module_list, source_file_list);
1037 
1039  source_regex, module_list, source_file_list, SBStringList()));
1040 }
1041 
1043  const char *source_regex, const SBFileSpecList &module_list,
1044  const lldb::SBFileSpecList &source_file_list,
1045  const SBStringList &func_names) {
1048  (const char *, const lldb::SBFileSpecList &,
1049  const lldb::SBFileSpecList &, const lldb::SBStringList &),
1050  source_regex, module_list, source_file_list, func_names);
1051 
1052  SBBreakpoint sb_bp;
1053  TargetSP target_sp(GetSP());
1054  if (target_sp && source_regex && source_regex[0]) {
1055  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1056  const bool hardware = false;
1057  const LazyBool move_to_nearest_code = eLazyBoolCalculate;
1058  RegularExpression regexp((llvm::StringRef(source_regex)));
1059  std::unordered_set<std::string> func_names_set;
1060  for (size_t i = 0; i < func_names.GetSize(); i++) {
1061  func_names_set.insert(func_names.GetStringAtIndex(i));
1062  }
1063 
1064  sb_bp = target_sp->CreateSourceRegexBreakpoint(
1065  module_list.get(), source_file_list.get(), func_names_set, regexp,
1066  false, hardware, move_to_nearest_code);
1067  }
1068 
1069  return LLDB_RECORD_RESULT(sb_bp);
1070 }
1071 
1074  bool catch_bp, bool throw_bp) {
1076  (lldb::LanguageType, bool, bool), language, catch_bp,
1077  throw_bp);
1078 
1079  SBBreakpoint sb_bp;
1080  TargetSP target_sp(GetSP());
1081  if (target_sp) {
1082  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1083  const bool hardware = false;
1084  sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp,
1085  hardware);
1086  }
1087 
1088  return LLDB_RECORD_RESULT(sb_bp);
1089 }
1090 
1092  const char *class_name, SBStructuredData &extra_args,
1093  const SBFileSpecList &module_list, const SBFileSpecList &file_list,
1094  bool request_hardware) {
1097  (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &,
1098  const lldb::SBFileSpecList &, bool),
1099  class_name, extra_args, module_list, file_list, request_hardware);
1100 
1101  SBBreakpoint sb_bp;
1102  TargetSP target_sp(GetSP());
1103  if (target_sp) {
1104  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1105  Status error;
1106 
1107  StructuredData::ObjectSP obj_sp = extra_args.m_impl_up->GetObjectSP();
1108  sb_bp =
1109  target_sp->CreateScriptedBreakpoint(class_name,
1110  module_list.get(),
1111  file_list.get(),
1112  false, /* internal */
1113  request_hardware,
1114  obj_sp,
1115  &error);
1116  }
1117 
1118  return LLDB_RECORD_RESULT(sb_bp);
1119 }
1120 
1123 
1124  TargetSP target_sp(GetSP());
1125  if (target_sp) {
1126  // The breakpoint list is thread safe, no need to lock
1127  return target_sp->GetBreakpointList().GetSize();
1128  }
1129  return 0;
1130 }
1131 
1134  (uint32_t), idx);
1135 
1136  SBBreakpoint sb_breakpoint;
1137  TargetSP target_sp(GetSP());
1138  if (target_sp) {
1139  // The breakpoint list is thread safe, no need to lock
1140  sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
1141  }
1142  return LLDB_RECORD_RESULT(sb_breakpoint);
1143 }
1144 
1147  bp_id);
1148 
1149  bool result = false;
1150  TargetSP target_sp(GetSP());
1151  if (target_sp) {
1152  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1153  result = target_sp->RemoveBreakpointByID(bp_id);
1154  }
1155 
1156  return result;
1157 }
1158 
1161  (lldb::break_id_t), bp_id);
1162 
1163  SBBreakpoint sb_breakpoint;
1164  TargetSP target_sp(GetSP());
1165  if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) {
1166  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1167  sb_breakpoint = target_sp->GetBreakpointByID(bp_id);
1168  }
1169 
1170  return LLDB_RECORD_RESULT(sb_breakpoint);
1171 }
1172 
1173 bool SBTarget::FindBreakpointsByName(const char *name,
1174  SBBreakpointList &bkpts) {
1176  (const char *, lldb::SBBreakpointList &), name, bkpts);
1177 
1178  TargetSP target_sp(GetSP());
1179  if (target_sp) {
1180  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1181  BreakpointList bkpt_list(false);
1182  bool is_valid =
1183  target_sp->GetBreakpointList().FindBreakpointsByName(name, bkpt_list);
1184  if (!is_valid)
1185  return false;
1186  for (BreakpointSP bkpt_sp : bkpt_list.Breakpoints()) {
1187  bkpts.AppendByID(bkpt_sp->GetID());
1188  }
1189  }
1190  return true;
1191 }
1192 
1195  names);
1196 
1197  names.Clear();
1198 
1199  TargetSP target_sp(GetSP());
1200  if (target_sp) {
1201  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1202 
1203  std::vector<std::string> name_vec;
1204  target_sp->GetBreakpointNames(name_vec);
1205  for (auto name : name_vec)
1206  names.AppendString(name.c_str());
1207  }
1208 }
1209 
1210 void SBTarget::DeleteBreakpointName(const char *name) {
1211  LLDB_RECORD_METHOD(void, SBTarget, DeleteBreakpointName, (const char *),
1212  name);
1213 
1214  TargetSP target_sp(GetSP());
1215  if (target_sp) {
1216  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1217  target_sp->DeleteBreakpointName(ConstString(name));
1218  }
1219 }
1220 
1223 
1224  TargetSP target_sp(GetSP());
1225  if (target_sp) {
1226  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1227  target_sp->EnableAllowedBreakpoints();
1228  return true;
1229  }
1230  return false;
1231 }
1232 
1235 
1236  TargetSP target_sp(GetSP());
1237  if (target_sp) {
1238  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1239  target_sp->DisableAllowedBreakpoints();
1240  return true;
1241  }
1242  return false;
1243 }
1244 
1247 
1248  TargetSP target_sp(GetSP());
1249  if (target_sp) {
1250  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1251  target_sp->RemoveAllowedBreakpoints();
1252  return true;
1253  }
1254  return false;
1255 }
1256 
1258  SBBreakpointList &new_bps) {
1261  source_file, new_bps);
1262 
1263  SBStringList empty_name_list;
1264  return LLDB_RECORD_RESULT(
1265  BreakpointsCreateFromFile(source_file, empty_name_list, new_bps));
1266 }
1267 
1269  SBStringList &matching_names,
1270  SBBreakpointList &new_bps) {
1274  source_file, matching_names, new_bps);
1275 
1276  SBError sberr;
1277  TargetSP target_sp(GetSP());
1278  if (!target_sp) {
1279  sberr.SetErrorString(
1280  "BreakpointCreateFromFile called with invalid target.");
1281  return LLDB_RECORD_RESULT(sberr);
1282  }
1283  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1284 
1285  BreakpointIDList bp_ids;
1286 
1287  std::vector<std::string> name_vector;
1288  size_t num_names = matching_names.GetSize();
1289  for (size_t i = 0; i < num_names; i++)
1290  name_vector.push_back(matching_names.GetStringAtIndex(i));
1291 
1292  sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(),
1293  name_vector, bp_ids);
1294  if (sberr.Fail())
1295  return LLDB_RECORD_RESULT(sberr);
1296 
1297  size_t num_bkpts = bp_ids.GetSize();
1298  for (size_t i = 0; i < num_bkpts; i++) {
1299  BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i);
1300  new_bps.AppendByID(bp_id.GetBreakpointID());
1301  }
1302  return LLDB_RECORD_RESULT(sberr);
1303 }
1304 
1307  (lldb::SBFileSpec &), dest_file);
1308 
1309  SBError sberr;
1310  TargetSP target_sp(GetSP());
1311  if (!target_sp) {
1312  sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
1313  return LLDB_RECORD_RESULT(sberr);
1314  }
1315  SBBreakpointList bkpt_list(*this);
1316  return LLDB_RECORD_RESULT(BreakpointsWriteToFile(dest_file, bkpt_list));
1317 }
1318 
1320  SBBreakpointList &bkpt_list,
1321  bool append) {
1324  dest_file, bkpt_list, append);
1325 
1326  SBError sberr;
1327  TargetSP target_sp(GetSP());
1328  if (!target_sp) {
1329  sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
1330  return LLDB_RECORD_RESULT(sberr);
1331  }
1332 
1333  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1334  BreakpointIDList bp_id_list;
1335  bkpt_list.CopyToBreakpointIDList(bp_id_list);
1336  sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(),
1337  bp_id_list, append);
1338  return LLDB_RECORD_RESULT(sberr);
1339 }
1340 
1343 
1344  TargetSP target_sp(GetSP());
1345  if (target_sp) {
1346  // The watchpoint list is thread safe, no need to lock
1347  return target_sp->GetWatchpointList().GetSize();
1348  }
1349  return 0;
1350 }
1351 
1354  (uint32_t), idx);
1355 
1356  SBWatchpoint sb_watchpoint;
1357  TargetSP target_sp(GetSP());
1358  if (target_sp) {
1359  // The watchpoint list is thread safe, no need to lock
1360  sb_watchpoint.SetSP(target_sp->GetWatchpointList().GetByIndex(idx));
1361  }
1362  return LLDB_RECORD_RESULT(sb_watchpoint);
1363 }
1364 
1367  wp_id);
1368 
1369 
1370  bool result = false;
1371  TargetSP target_sp(GetSP());
1372  if (target_sp) {
1373  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1374  std::unique_lock<std::recursive_mutex> lock;
1375  target_sp->GetWatchpointList().GetListMutex(lock);
1376  result = target_sp->RemoveWatchpointByID(wp_id);
1377  }
1378 
1379  return result;
1380 }
1381 
1384  (lldb::watch_id_t), wp_id);
1385 
1386 
1387  SBWatchpoint sb_watchpoint;
1388  lldb::WatchpointSP watchpoint_sp;
1389  TargetSP target_sp(GetSP());
1390  if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) {
1391  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1392  std::unique_lock<std::recursive_mutex> lock;
1393  target_sp->GetWatchpointList().GetListMutex(lock);
1394  watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id);
1395  sb_watchpoint.SetSP(watchpoint_sp);
1396  }
1397 
1398  return LLDB_RECORD_RESULT(sb_watchpoint);
1399 }
1400 
1402  bool read, bool write,
1403  SBError &error) {
1405  (lldb::addr_t, size_t, bool, bool, lldb::SBError &), addr,
1406  size, read, write, error);
1407 
1408  SBWatchpoint sb_watchpoint;
1409  lldb::WatchpointSP watchpoint_sp;
1410  TargetSP target_sp(GetSP());
1411  if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS &&
1412  size > 0) {
1413  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1414  uint32_t watch_type = 0;
1415  if (read)
1416  watch_type |= LLDB_WATCH_TYPE_READ;
1417  if (write)
1418  watch_type |= LLDB_WATCH_TYPE_WRITE;
1419  if (watch_type == 0) {
1420  error.SetErrorString(
1421  "Can't create a watchpoint that is neither read nor write.");
1422  return LLDB_RECORD_RESULT(sb_watchpoint);
1423  }
1424 
1425  // Target::CreateWatchpoint() is thread safe.
1426  Status cw_error;
1427  // This API doesn't take in a type, so we can't figure out what it is.
1428  CompilerType *type = NULL;
1429  watchpoint_sp =
1430  target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
1431  error.SetError(cw_error);
1432  sb_watchpoint.SetSP(watchpoint_sp);
1433  }
1434 
1435  return LLDB_RECORD_RESULT(sb_watchpoint);
1436 }
1437 
1440 
1441  TargetSP target_sp(GetSP());
1442  if (target_sp) {
1443  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1444  std::unique_lock<std::recursive_mutex> lock;
1445  target_sp->GetWatchpointList().GetListMutex(lock);
1446  target_sp->EnableAllWatchpoints();
1447  return true;
1448  }
1449  return false;
1450 }
1451 
1454 
1455  TargetSP target_sp(GetSP());
1456  if (target_sp) {
1457  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1458  std::unique_lock<std::recursive_mutex> lock;
1459  target_sp->GetWatchpointList().GetListMutex(lock);
1460  target_sp->DisableAllWatchpoints();
1461  return true;
1462  }
1463  return false;
1464 }
1465 
1467  SBType type) {
1469  (const char *, lldb::SBAddress, lldb::SBType), name, addr,
1470  type);
1471 
1472  SBValue sb_value;
1473  lldb::ValueObjectSP new_value_sp;
1474  if (IsValid() && name && *name && addr.IsValid() && type.IsValid()) {
1475  lldb::addr_t load_addr(addr.GetLoadAddress(*this));
1476  ExecutionContext exe_ctx(
1477  ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
1478  CompilerType ast_type(type.GetSP()->GetCompilerType(true));
1479  new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr,
1480  exe_ctx, ast_type);
1481  }
1482  sb_value.SetSP(new_value_sp);
1483  return LLDB_RECORD_RESULT(sb_value);
1484 }
1485 
1487  lldb::SBType type) {
1489  (const char *, lldb::SBData, lldb::SBType), name, data,
1490  type);
1491 
1492  SBValue sb_value;
1493  lldb::ValueObjectSP new_value_sp;
1494  if (IsValid() && name && *name && data.IsValid() && type.IsValid()) {
1495  DataExtractorSP extractor(*data);
1496  ExecutionContext exe_ctx(
1497  ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
1498  CompilerType ast_type(type.GetSP()->GetCompilerType(true));
1499  new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor,
1500  exe_ctx, ast_type);
1501  }
1502  sb_value.SetSP(new_value_sp);
1503  return LLDB_RECORD_RESULT(sb_value);
1504 }
1505 
1507  const char *expr) {
1509  (const char *, const char *), name, expr);
1510 
1511  SBValue sb_value;
1512  lldb::ValueObjectSP new_value_sp;
1513  if (IsValid() && name && *name && expr && *expr) {
1514  ExecutionContext exe_ctx(
1515  ExecutionContextRef(ExecutionContext(m_opaque_sp.get(), false)));
1516  new_value_sp =
1517  ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx);
1518  }
1519  sb_value.SetSP(new_value_sp);
1520  return LLDB_RECORD_RESULT(sb_value);
1521 }
1522 
1525 
1526  TargetSP target_sp(GetSP());
1527  if (target_sp) {
1528  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1529  std::unique_lock<std::recursive_mutex> lock;
1530  target_sp->GetWatchpointList().GetListMutex(lock);
1531  target_sp->RemoveAllWatchpoints();
1532  return true;
1533  }
1534  return false;
1535 }
1536 
1537 void SBTarget::AppendImageSearchPath(const char *from, const char *to,
1538  lldb::SBError &error) {
1540  (const char *, const char *, lldb::SBError &), from, to,
1541  error);
1542 
1543  TargetSP target_sp(GetSP());
1544  if (!target_sp)
1545  return error.SetErrorString("invalid target");
1546 
1547  const ConstString csFrom(from), csTo(to);
1548  if (!csFrom)
1549  return error.SetErrorString("<from> path can't be empty");
1550  if (!csTo)
1551  return error.SetErrorString("<to> path can't be empty");
1552 
1553  target_sp->GetImageSearchPathList().Append(csFrom, csTo, true);
1554 }
1555 
1556 lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
1557  const char *uuid_cstr) {
1559  (const char *, const char *, const char *), path, triple,
1560  uuid_cstr);
1561 
1562  return LLDB_RECORD_RESULT(AddModule(path, triple, uuid_cstr, NULL));
1563 }
1564 
1565 lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
1566  const char *uuid_cstr, const char *symfile) {
1568  (const char *, const char *, const char *, const char *),
1569  path, triple, uuid_cstr, symfile);
1570 
1571  lldb::SBModule sb_module;
1572  TargetSP target_sp(GetSP());
1573  if (target_sp) {
1574  ModuleSpec module_spec;
1575  if (path)
1576  module_spec.GetFileSpec().SetFile(path, FileSpec::Style::native);
1577 
1578  if (uuid_cstr)
1579  module_spec.GetUUID().SetFromStringRef(uuid_cstr);
1580 
1581  if (triple)
1582  module_spec.GetArchitecture() = Platform::GetAugmentedArchSpec(
1583  target_sp->GetPlatform().get(), triple);
1584  else
1585  module_spec.GetArchitecture() = target_sp->GetArchitecture();
1586 
1587  if (symfile)
1588  module_spec.GetSymbolFileSpec().SetFile(symfile, FileSpec::Style::native);
1589 
1590  sb_module.SetSP(target_sp->GetOrCreateModule(module_spec, true /* notify */));
1591  }
1592  return LLDB_RECORD_RESULT(sb_module);
1593 }
1594 
1597  (const lldb::SBModuleSpec &), module_spec);
1598 
1599  lldb::SBModule sb_module;
1600  TargetSP target_sp(GetSP());
1601  if (target_sp)
1602  sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up,
1603  true /* notify */));
1604  return LLDB_RECORD_RESULT(sb_module);
1605 }
1606 
1608  LLDB_RECORD_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &), module);
1609 
1610  TargetSP target_sp(GetSP());
1611  if (target_sp) {
1612  target_sp->GetImages().AppendIfNeeded(module.GetSP());
1613  return true;
1614  }
1615  return false;
1616 }
1617 
1620 
1621  uint32_t num = 0;
1622  TargetSP target_sp(GetSP());
1623  if (target_sp) {
1624  // The module list is thread safe, no need to lock
1625  num = target_sp->GetImages().GetSize();
1626  }
1627 
1628  return num;
1629 }
1630 
1633 
1634  m_opaque_sp.reset();
1635 }
1636 
1639  (const lldb::SBFileSpec &), sb_file_spec);
1640 
1641  SBModule sb_module;
1642  TargetSP target_sp(GetSP());
1643  if (target_sp && sb_file_spec.IsValid()) {
1644  ModuleSpec module_spec(*sb_file_spec);
1645  // The module list is thread safe, no need to lock
1646  sb_module.SetSP(target_sp->GetImages().FindFirstModule(module_spec));
1647  }
1648  return LLDB_RECORD_RESULT(sb_module);
1649 }
1650 
1653  (const lldb::SBFileSpec &), sb_file_spec);
1654 
1655  SBSymbolContextList sb_sc_list;
1656  const TargetSP target_sp(GetSP());
1657  if (target_sp && sb_file_spec.IsValid()) {
1658  const bool append = true;
1659  target_sp->GetImages().FindCompileUnits(*sb_file_spec,
1660  append, *sb_sc_list);
1661  }
1662  return LLDB_RECORD_RESULT(sb_sc_list);
1663 }
1664 
1667 
1668  TargetSP target_sp(GetSP());
1669  if (target_sp)
1670  return target_sp->GetArchitecture().GetByteOrder();
1671  return eByteOrderInvalid;
1672 }
1673 
1674 const char *SBTarget::GetTriple() {
1676 
1677  TargetSP target_sp(GetSP());
1678  if (target_sp) {
1679  std::string triple(target_sp->GetArchitecture().GetTriple().str());
1680  // Unique the string so we don't run into ownership issues since the const
1681  // strings put the string into the string pool once and the strings never
1682  // comes out
1683  ConstString const_triple(triple.c_str());
1684  return const_triple.GetCString();
1685  }
1686  return NULL;
1687 }
1688 
1691 
1692  TargetSP target_sp(GetSP());
1693  if (target_sp) {
1694  return target_sp->GetArchitecture().GetDataByteSize();
1695  }
1696  return 0;
1697 }
1698 
1701 
1702  TargetSP target_sp(GetSP());
1703  if (target_sp) {
1704  return target_sp->GetArchitecture().GetCodeByteSize();
1705  }
1706  return 0;
1707 }
1708 
1711 
1712  TargetSP target_sp(GetSP());
1713  if (target_sp)
1714  return target_sp->GetArchitecture().GetAddressByteSize();
1715  return sizeof(void *);
1716 }
1717 
1720  idx);
1721 
1722  SBModule sb_module;
1723  ModuleSP module_sp;
1724  TargetSP target_sp(GetSP());
1725  if (target_sp) {
1726  // The module list is thread safe, no need to lock
1727  module_sp = target_sp->GetImages().GetModuleAtIndex(idx);
1728  sb_module.SetSP(module_sp);
1729  }
1730 
1731  return LLDB_RECORD_RESULT(sb_module);
1732 }
1733 
1736 
1737  TargetSP target_sp(GetSP());
1738  if (target_sp)
1739  return target_sp->GetImages().Remove(module.GetSP());
1740  return false;
1741 }
1742 
1745  GetBroadcaster);
1746 
1747 
1748  TargetSP target_sp(GetSP());
1749  SBBroadcaster broadcaster(target_sp.get(), false);
1750 
1751 
1752  return LLDB_RECORD_RESULT(broadcaster);
1753 }
1754 
1756  lldb::DescriptionLevel description_level) {
1758  (lldb::SBStream &, lldb::DescriptionLevel), description,
1759  description_level);
1760 
1761  Stream &strm = description.ref();
1762 
1763  TargetSP target_sp(GetSP());
1764  if (target_sp) {
1765  target_sp->Dump(&strm, description_level);
1766  } else
1767  strm.PutCString("No value");
1768 
1769  return true;
1770 }
1771 
1773  uint32_t name_type_mask) {
1775  (const char *, uint32_t), name, name_type_mask);
1776 
1777  lldb::SBSymbolContextList sb_sc_list;
1778  if (!name | !name[0])
1779  return LLDB_RECORD_RESULT(sb_sc_list);
1780 
1781  TargetSP target_sp(GetSP());
1782  if (!target_sp)
1783  return LLDB_RECORD_RESULT(sb_sc_list);
1784 
1785  const bool symbols_ok = true;
1786  const bool inlines_ok = true;
1787  const bool append = true;
1788  FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
1789  target_sp->GetImages().FindFunctions(ConstString(name), mask, symbols_ok,
1790  inlines_ok, append, *sb_sc_list);
1791  return LLDB_RECORD_RESULT(sb_sc_list);
1792 }
1793 
1795  uint32_t max_matches,
1796  MatchType matchtype) {
1798  (const char *, uint32_t, lldb::MatchType), name,
1799  max_matches, matchtype);
1800 
1801  lldb::SBSymbolContextList sb_sc_list;
1802  if (name && name[0]) {
1803  llvm::StringRef name_ref(name);
1804  TargetSP target_sp(GetSP());
1805  if (target_sp) {
1806  std::string regexstr;
1807  switch (matchtype) {
1808  case eMatchTypeRegex:
1809  target_sp->GetImages().FindFunctions(RegularExpression(name_ref), true,
1810  true, true, *sb_sc_list);
1811  break;
1812  case eMatchTypeStartsWith:
1813  regexstr = llvm::Regex::escape(name) + ".*";
1814  target_sp->GetImages().FindFunctions(RegularExpression(regexstr), true,
1815  true, true, *sb_sc_list);
1816  break;
1817  default:
1818  target_sp->GetImages().FindFunctions(ConstString(name),
1819  eFunctionNameTypeAny, true, true,
1820  true, *sb_sc_list);
1821  break;
1822  }
1823  }
1824  }
1825  return LLDB_RECORD_RESULT(sb_sc_list);
1826 }
1827 
1828 lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
1830  typename_cstr);
1831 
1832  TargetSP target_sp(GetSP());
1833  if (typename_cstr && typename_cstr[0] && target_sp) {
1834  ConstString const_typename(typename_cstr);
1835  SymbolContext sc;
1836  const bool exact_match = false;
1837 
1838  const ModuleList &module_list = target_sp->GetImages();
1839  size_t count = module_list.GetSize();
1840  for (size_t idx = 0; idx < count; idx++) {
1841  ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
1842  if (module_sp) {
1843  TypeSP type_sp(
1844  module_sp->FindFirstType(sc, const_typename, exact_match));
1845  if (type_sp)
1846  return LLDB_RECORD_RESULT(SBType(type_sp));
1847  }
1848  }
1849 
1850  // Didn't find the type in the symbols; try the Objective-C runtime if one
1851  // is installed
1852 
1853  ProcessSP process_sp(target_sp->GetProcessSP());
1854 
1855  if (process_sp) {
1856  ObjCLanguageRuntime *objc_language_runtime =
1857  process_sp->GetObjCLanguageRuntime();
1858 
1859  if (objc_language_runtime) {
1860  DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
1861 
1862  if (objc_decl_vendor) {
1863  std::vector<clang::NamedDecl *> decls;
1864 
1865  if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) {
1866  if (CompilerType type = ClangASTContext::GetTypeForDecl(decls[0])) {
1867  return LLDB_RECORD_RESULT(SBType(type));
1868  }
1869  }
1870  }
1871  }
1872  }
1873 
1874  // No matches, search for basic typename matches
1875  ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1876  if (clang_ast)
1877  return LLDB_RECORD_RESULT(SBType(ClangASTContext::GetBasicType(
1878  clang_ast->getASTContext(), const_typename)));
1879  }
1880  return LLDB_RECORD_RESULT(SBType());
1881 }
1882 
1885  type);
1886 
1887  TargetSP target_sp(GetSP());
1888  if (target_sp) {
1889  ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1890  if (clang_ast)
1891  return LLDB_RECORD_RESULT(SBType(
1892  ClangASTContext::GetBasicType(clang_ast->getASTContext(), type)));
1893  }
1894  return LLDB_RECORD_RESULT(SBType());
1895 }
1896 
1897 lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
1899  typename_cstr);
1900 
1901  SBTypeList sb_type_list;
1902  TargetSP target_sp(GetSP());
1903  if (typename_cstr && typename_cstr[0] && target_sp) {
1904  ModuleList &images = target_sp->GetImages();
1905  ConstString const_typename(typename_cstr);
1906  bool exact_match = false;
1907  TypeList type_list;
1908  llvm::DenseSet<SymbolFile *> searched_symbol_files;
1909  uint32_t num_matches =
1910  images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX,
1911  searched_symbol_files, type_list);
1912 
1913  if (num_matches > 0) {
1914  for (size_t idx = 0; idx < num_matches; idx++) {
1915  TypeSP type_sp(type_list.GetTypeAtIndex(idx));
1916  if (type_sp)
1917  sb_type_list.Append(SBType(type_sp));
1918  }
1919  }
1920 
1921  // Try the Objective-C runtime if one is installed
1922 
1923  ProcessSP process_sp(target_sp->GetProcessSP());
1924 
1925  if (process_sp) {
1926  ObjCLanguageRuntime *objc_language_runtime =
1927  process_sp->GetObjCLanguageRuntime();
1928 
1929  if (objc_language_runtime) {
1930  DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
1931 
1932  if (objc_decl_vendor) {
1933  std::vector<clang::NamedDecl *> decls;
1934 
1935  if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) {
1936  for (clang::NamedDecl *decl : decls) {
1937  if (CompilerType type = ClangASTContext::GetTypeForDecl(decl)) {
1938  sb_type_list.Append(SBType(type));
1939  }
1940  }
1941  }
1942  }
1943  }
1944  }
1945 
1946  if (sb_type_list.GetSize() == 0) {
1947  // No matches, search for basic typename matches
1948  ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
1949  if (clang_ast)
1950  sb_type_list.Append(SBType(ClangASTContext::GetBasicType(
1951  clang_ast->getASTContext(), const_typename)));
1952  }
1953  }
1954  return LLDB_RECORD_RESULT(sb_type_list);
1955 }
1956 
1958  uint32_t max_matches) {
1960  (const char *, uint32_t), name, max_matches);
1961 
1962  SBValueList sb_value_list;
1963 
1964  TargetSP target_sp(GetSP());
1965  if (name && target_sp) {
1966  VariableList variable_list;
1967  const uint32_t match_count = target_sp->GetImages().FindGlobalVariables(
1968  ConstString(name), max_matches, variable_list);
1969 
1970  if (match_count > 0) {
1971  ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
1972  if (exe_scope == NULL)
1973  exe_scope = target_sp.get();
1974  for (uint32_t i = 0; i < match_count; ++i) {
1975  lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
1976  exe_scope, variable_list.GetVariableAtIndex(i)));
1977  if (valobj_sp)
1978  sb_value_list.Append(SBValue(valobj_sp));
1979  }
1980  }
1981  }
1982 
1983  return LLDB_RECORD_RESULT(sb_value_list);
1984 }
1985 
1987  uint32_t max_matches,
1988  MatchType matchtype) {
1990  (const char *, uint32_t, lldb::MatchType), name,
1991  max_matches, matchtype);
1992 
1993  SBValueList sb_value_list;
1994 
1995  TargetSP target_sp(GetSP());
1996  if (name && target_sp) {
1997  llvm::StringRef name_ref(name);
1998  VariableList variable_list;
1999 
2000  std::string regexstr;
2001  uint32_t match_count;
2002  switch (matchtype) {
2003  case eMatchTypeNormal:
2004  match_count = target_sp->GetImages().FindGlobalVariables(
2005  ConstString(name), max_matches, variable_list);
2006  break;
2007  case eMatchTypeRegex:
2008  match_count = target_sp->GetImages().FindGlobalVariables(
2009  RegularExpression(name_ref), max_matches, variable_list);
2010  break;
2011  case eMatchTypeStartsWith:
2012  regexstr = llvm::Regex::escape(name) + ".*";
2013  match_count = target_sp->GetImages().FindGlobalVariables(
2014  RegularExpression(regexstr), max_matches, variable_list);
2015  break;
2016  }
2017 
2018  if (match_count > 0) {
2019  ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
2020  if (exe_scope == NULL)
2021  exe_scope = target_sp.get();
2022  for (uint32_t i = 0; i < match_count; ++i) {
2023  lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
2024  exe_scope, variable_list.GetVariableAtIndex(i)));
2025  if (valobj_sp)
2026  sb_value_list.Append(SBValue(valobj_sp));
2027  }
2028  }
2029  }
2030 
2031  return LLDB_RECORD_RESULT(sb_value_list);
2032 }
2033 
2036  (const char *), name);
2037 
2038  SBValueList sb_value_list(FindGlobalVariables(name, 1));
2039  if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
2040  return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0));
2041  return LLDB_RECORD_RESULT(SBValue());
2042 }
2043 
2046 
2047  SBSourceManager source_manager(*this);
2048  return LLDB_RECORD_RESULT(source_manager);
2049 }
2050 
2052  uint32_t count) {
2054  (lldb::SBAddress, uint32_t), base_addr, count);
2055 
2056  return LLDB_RECORD_RESULT(ReadInstructions(base_addr, count, NULL));
2057 }
2058 
2060  uint32_t count,
2061  const char *flavor_string) {
2063  (lldb::SBAddress, uint32_t, const char *), base_addr,
2064  count, flavor_string);
2065 
2066  SBInstructionList sb_instructions;
2067 
2068  TargetSP target_sp(GetSP());
2069  if (target_sp) {
2070  Address *addr_ptr = base_addr.get();
2071 
2072  if (addr_ptr) {
2073  DataBufferHeap data(
2074  target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0);
2075  bool prefer_file_cache = false;
2076  lldb_private::Status error;
2077  lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
2078  const size_t bytes_read =
2079  target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(),
2080  data.GetByteSize(), error, &load_addr);
2081  const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
2082  sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
2083  target_sp->GetArchitecture(), NULL, flavor_string, *addr_ptr,
2084  data.GetBytes(), bytes_read, count, data_from_file));
2085  }
2086  }
2087 
2088  return LLDB_RECORD_RESULT(sb_instructions);
2089 }
2090 
2092  const void *buf,
2093  size_t size) {
2095  (lldb::SBAddress, const void *, size_t), base_addr, buf,
2096  size);
2097 
2098  return GetInstructionsWithFlavor(base_addr, NULL, buf, size);
2099 }
2100 
2103  const char *flavor_string, const void *buf,
2104  size_t size) {
2107  (lldb::SBAddress, const char *, const void *, size_t),
2108  base_addr, flavor_string, buf, size);
2109 
2110  SBInstructionList sb_instructions;
2111 
2112  TargetSP target_sp(GetSP());
2113  if (target_sp) {
2114  Address addr;
2115 
2116  if (base_addr.get())
2117  addr = *base_addr.get();
2118 
2119  const bool data_from_file = true;
2120 
2121  sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
2122  target_sp->GetArchitecture(), NULL, flavor_string, addr, buf, size,
2123  UINT32_MAX, data_from_file));
2124  }
2125 
2126  return sb_instructions;
2127 }
2128 
2130  const void *buf,
2131  size_t size) {
2133  (lldb::addr_t, const void *, size_t), base_addr, buf, size);
2134 
2135  return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), NULL, buf,
2136  size);
2137 }
2138 
2141  const char *flavor_string, const void *buf,
2142  size_t size) {
2145  (lldb::addr_t, const char *, const void *, size_t),
2146  base_addr, flavor_string, buf, size);
2147 
2148  return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string,
2149  buf, size);
2150 }
2151 
2153  lldb::addr_t section_base_addr) {
2155  (lldb::SBSection, lldb::addr_t), section,
2156  section_base_addr);
2157 
2158  SBError sb_error;
2159  TargetSP target_sp(GetSP());
2160  if (target_sp) {
2161  if (!section.IsValid()) {
2162  sb_error.SetErrorStringWithFormat("invalid section");
2163  } else {
2164  SectionSP section_sp(section.GetSP());
2165  if (section_sp) {
2166  if (section_sp->IsThreadSpecific()) {
2167  sb_error.SetErrorString(
2168  "thread specific sections are not yet supported");
2169  } else {
2170  ProcessSP process_sp(target_sp->GetProcessSP());
2171  if (target_sp->SetSectionLoadAddress(section_sp, section_base_addr)) {
2172  ModuleSP module_sp(section_sp->GetModule());
2173  if (module_sp) {
2174  ModuleList module_list;
2175  module_list.Append(module_sp);
2176  target_sp->ModulesDidLoad(module_list);
2177  }
2178  // Flush info in the process (stack frames, etc)
2179  if (process_sp)
2180  process_sp->Flush();
2181  }
2182  }
2183  }
2184  }
2185  } else {
2186  sb_error.SetErrorString("invalid target");
2187  }
2188  return LLDB_RECORD_RESULT(sb_error);
2189 }
2190 
2193  (lldb::SBSection), section);
2194 
2195  SBError sb_error;
2196 
2197  TargetSP target_sp(GetSP());
2198  if (target_sp) {
2199  if (!section.IsValid()) {
2200  sb_error.SetErrorStringWithFormat("invalid section");
2201  } else {
2202  SectionSP section_sp(section.GetSP());
2203  if (section_sp) {
2204  ProcessSP process_sp(target_sp->GetProcessSP());
2205  if (target_sp->SetSectionUnloaded(section_sp)) {
2206  ModuleSP module_sp(section_sp->GetModule());
2207  if (module_sp) {
2208  ModuleList module_list;
2209  module_list.Append(module_sp);
2210  target_sp->ModulesDidUnload(module_list, false);
2211  }
2212  // Flush info in the process (stack frames, etc)
2213  if (process_sp)
2214  process_sp->Flush();
2215  }
2216  } else {
2217  sb_error.SetErrorStringWithFormat("invalid section");
2218  }
2219  }
2220  } else {
2221  sb_error.SetErrorStringWithFormat("invalid target");
2222  }
2223  return LLDB_RECORD_RESULT(sb_error);
2224 }
2225 
2227  int64_t slide_offset) {
2229  (lldb::SBModule, int64_t), module, slide_offset);
2230 
2231  SBError sb_error;
2232 
2233  TargetSP target_sp(GetSP());
2234  if (target_sp) {
2235  ModuleSP module_sp(module.GetSP());
2236  if (module_sp) {
2237  bool changed = false;
2238  if (module_sp->SetLoadAddress(*target_sp, slide_offset, true, changed)) {
2239  // The load was successful, make sure that at least some sections
2240  // changed before we notify that our module was loaded.
2241  if (changed) {
2242  ModuleList module_list;
2243  module_list.Append(module_sp);
2244  target_sp->ModulesDidLoad(module_list);
2245  // Flush info in the process (stack frames, etc)
2246  ProcessSP process_sp(target_sp->GetProcessSP());
2247  if (process_sp)
2248  process_sp->Flush();
2249  }
2250  }
2251  } else {
2252  sb_error.SetErrorStringWithFormat("invalid module");
2253  }
2254 
2255  } else {
2256  sb_error.SetErrorStringWithFormat("invalid target");
2257  }
2258  return LLDB_RECORD_RESULT(sb_error);
2259 }
2260 
2263  (lldb::SBModule), module);
2264 
2265  SBError sb_error;
2266 
2267  char path[PATH_MAX];
2268  TargetSP target_sp(GetSP());
2269  if (target_sp) {
2270  ModuleSP module_sp(module.GetSP());
2271  if (module_sp) {
2272  ObjectFile *objfile = module_sp->GetObjectFile();
2273  if (objfile) {
2274  SectionList *section_list = objfile->GetSectionList();
2275  if (section_list) {
2276  ProcessSP process_sp(target_sp->GetProcessSP());
2277 
2278  bool changed = false;
2279  const size_t num_sections = section_list->GetSize();
2280  for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
2281  SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
2282  if (section_sp)
2283  changed |= target_sp->SetSectionUnloaded(section_sp);
2284  }
2285  if (changed) {
2286  ModuleList module_list;
2287  module_list.Append(module_sp);
2288  target_sp->ModulesDidUnload(module_list, false);
2289  // Flush info in the process (stack frames, etc)
2290  ProcessSP process_sp(target_sp->GetProcessSP());
2291  if (process_sp)
2292  process_sp->Flush();
2293  }
2294  } else {
2295  module_sp->GetFileSpec().GetPath(path, sizeof(path));
2296  sb_error.SetErrorStringWithFormat("no sections in object file '%s'",
2297  path);
2298  }
2299  } else {
2300  module_sp->GetFileSpec().GetPath(path, sizeof(path));
2301  sb_error.SetErrorStringWithFormat("no object file for module '%s'",
2302  path);
2303  }
2304  } else {
2305  sb_error.SetErrorStringWithFormat("invalid module");
2306  }
2307  } else {
2308  sb_error.SetErrorStringWithFormat("invalid target");
2309  }
2310  return LLDB_RECORD_RESULT(sb_error);
2311 }
2312 
2314  lldb::SymbolType symbol_type) {
2316  (const char *, lldb::SymbolType), name, symbol_type);
2317 
2318  SBSymbolContextList sb_sc_list;
2319  if (name && name[0]) {
2320  TargetSP target_sp(GetSP());
2321  if (target_sp) {
2322  bool append = true;
2323  target_sp->GetImages().FindSymbolsWithNameAndType(
2324  ConstString(name), symbol_type, *sb_sc_list, append);
2325  }
2326  }
2327  return LLDB_RECORD_RESULT(sb_sc_list);
2328 }
2329 
2332  (const char *), expr);
2333 
2334  TargetSP target_sp(GetSP());
2335  if (!target_sp)
2336  return LLDB_RECORD_RESULT(SBValue());
2337 
2338  SBExpressionOptions options;
2339  lldb::DynamicValueType fetch_dynamic_value =
2340  target_sp->GetPreferDynamicValue();
2341  options.SetFetchDynamicValue(fetch_dynamic_value);
2342  options.SetUnwindOnError(true);
2343  return LLDB_RECORD_RESULT(EvaluateExpression(expr, options));
2344 }
2345 
2347  const SBExpressionOptions &options) {
2349  (const char *, const lldb::SBExpressionOptions &), expr,
2350  options);
2351 
2353  SBValue expr_result;
2354  ValueObjectSP expr_value_sp;
2355  TargetSP target_sp(GetSP());
2356  StackFrame *frame = NULL;
2357  if (target_sp) {
2358  if (expr == NULL || expr[0] == '\0') {
2359  return LLDB_RECORD_RESULT(expr_result);
2360  }
2361 
2362  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
2363  ExecutionContext exe_ctx(m_opaque_sp.get());
2364 
2365 
2366  frame = exe_ctx.GetFramePtr();
2367  Target *target = exe_ctx.GetTargetPtr();
2368 
2369  if (target) {
2370 #ifdef LLDB_CONFIGURATION_DEBUG
2371  StreamString frame_description;
2372  if (frame)
2373  frame->DumpUsingSettingsFormat(&frame_description);
2374  llvm::PrettyStackTraceFormat stack_trace(
2375  "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = "
2376  "%u) %s",
2377  expr, options.GetFetchDynamicValue(),
2378  frame_description.GetString().str().c_str());
2379 #endif
2380  target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
2381 
2382  expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
2383  }
2384  }
2385  if (expr_log)
2386  expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is "
2387  "%s, summary %s **",
2388  expr_result.GetValue(), expr_result.GetSummary());
2389  return LLDB_RECORD_RESULT(expr_result);
2390 }
2391 
2394 
2395  TargetSP target_sp(GetSP());
2396  if (target_sp) {
2397  ABISP abi_sp;
2398  ProcessSP process_sp(target_sp->GetProcessSP());
2399  if (process_sp)
2400  abi_sp = process_sp->GetABI();
2401  else
2402  abi_sp = ABI::FindPlugin(ProcessSP(), target_sp->GetArchitecture());
2403  if (abi_sp)
2404  return abi_sp->GetRedZoneSize();
2405  }
2406  return 0;
2407 }
2408 
2411 
2412  lldb::SBLaunchInfo launch_info(NULL);
2413  TargetSP target_sp(GetSP());
2414  if (target_sp)
2415  launch_info.set_ref(m_opaque_sp->GetProcessLaunchInfo());
2416  return LLDB_RECORD_RESULT(launch_info);
2417 }
2418 
2421  (const lldb::SBLaunchInfo &), launch_info);
2422 
2423  TargetSP target_sp(GetSP());
2424  if (target_sp)
2425  m_opaque_sp->SetProcessLaunchInfo(launch_info.ref());
2426 }
2427 
2428 namespace lldb_private {
2429 namespace repro {
2430 
2431 template <>
2435  LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &));
2437  SBTarget, operator=,(const lldb::SBTarget &));
2439  (const lldb::SBEvent &));
2441  (const lldb::SBEvent &));
2443  (const lldb::SBEvent &));
2446  (const uint32_t, const lldb::SBEvent &));
2448  ());
2450  LLDB_REGISTER_METHOD_CONST(bool, SBTarget, operator bool, ());
2459  (const char *, lldb::SBError &));
2461  (const char **, const char **, const char *));
2464  (lldb::SBListener &, const char **, const char **,
2465  const char *, const char *, const char *,
2466  const char *, uint32_t, bool, lldb::SBError &));
2475  (lldb::SBListener &, const char *, bool, lldb::SBError &));
2478  (lldb::SBListener &, const char *, const char *, lldb::SBError &));
2481  SBTarget, operator==,(const lldb::SBTarget &));
2483  SBTarget, operator!=,(const lldb::SBTarget &));
2485  (lldb::addr_t));
2487  (lldb::addr_t));
2489  (uint32_t, lldb::addr_t));
2492  (const lldb::SBAddress &, uint32_t));
2494  BreakpointCreateByLocation, (const char *, uint32_t));
2497  (const lldb::SBFileSpec &, uint32_t));
2500  (const lldb::SBFileSpec &, uint32_t, lldb::addr_t));
2507  (const lldb::SBFileSpec &, uint32_t, uint32_t,
2510  (const char *, const char *));
2512  (const char *, const lldb::SBFileSpecList &,
2513  const lldb::SBFileSpecList &));
2515  (const char *, uint32_t, const lldb::SBFileSpecList &,
2516  const lldb::SBFileSpecList &));
2518  (const char *, uint32_t, lldb::LanguageType,
2519  const lldb::SBFileSpecList &,
2520  const lldb::SBFileSpecList &));
2522  (const char **, uint32_t, uint32_t,
2523  const lldb::SBFileSpecList &,
2524  const lldb::SBFileSpecList &));
2526  (const char **, uint32_t, uint32_t, lldb::LanguageType,
2527  const lldb::SBFileSpecList &,
2528  const lldb::SBFileSpecList &));
2530  (const char **, uint32_t, uint32_t, lldb::LanguageType,
2532  const lldb::SBFileSpecList &));
2534  (const char *, const char *));
2536  (const char *, const lldb::SBFileSpecList &,
2537  const lldb::SBFileSpecList &));
2539  (const char *, lldb::LanguageType,
2540  const lldb::SBFileSpecList &,
2541  const lldb::SBFileSpecList &));
2548  (const char *, const lldb::SBFileSpec &, const char *));
2551  (const char *, const lldb::SBFileSpecList &,
2552  const lldb::SBFileSpecList &));
2555  (const char *, const lldb::SBFileSpecList &,
2556  const lldb::SBFileSpecList &, const lldb::SBStringList &));
2559  (lldb::LanguageType, bool, bool));
2562  (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &,
2563  const lldb::SBFileSpecList &, bool));
2569  (lldb::break_id_t));
2571  (const char *, lldb::SBBreakpointList &));
2573  (lldb::SBStringList &));
2574  LLDB_REGISTER_METHOD(void, SBTarget, DeleteBreakpointName, (const char *));
2584  (lldb::SBFileSpec &));
2592  (lldb::watch_id_t));
2594  (lldb::addr_t, size_t, bool, bool, lldb::SBError &));
2598  (const char *, lldb::SBAddress, lldb::SBType));
2600  (const char *, lldb::SBData, lldb::SBType));
2602  (const char *, const char *));
2605  (const char *, const char *, lldb::SBError &));
2607  (const char *, const char *, const char *));
2610  (const char *, const char *, const char *, const char *));
2612  (const lldb::SBModuleSpec &));
2615  LLDB_REGISTER_METHOD(void, SBTarget, Clear, ());
2617  (const lldb::SBFileSpec &));
2619  (const lldb::SBFileSpec &));
2621  LLDB_REGISTER_METHOD(const char *, SBTarget, GetTriple, ());
2626  (uint32_t));
2629  ());
2633  (const char *, uint32_t));
2636  (const char *, uint32_t, lldb::MatchType));
2639  (lldb::BasicType));
2642  (const char *, uint32_t));
2644  (const char *, uint32_t, lldb::MatchType));
2646  (const char *));
2651  (lldb::SBAddress, uint32_t, const char *));
2655  (lldb::SBSection));
2657  (lldb::SBModule, int64_t));
2659  (lldb::SBModule));
2661  (const char *, lldb::SymbolType));
2663  (const char *));
2665  (const char *, const lldb::SBExpressionOptions &));
2669  (const lldb::SBLaunchInfo &));
2670 }
2671 
2672 }
2673 }
void SetListener(const lldb::ListenerSP &listener_sp)
uint32_t GetSize() const
static const char * GetBroadcasterClassName()
Definition: SBTarget.cpp:160
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:61
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:858
Status Attach(ProcessAttachInfo &attach_info, Stream *stream)
Definition: Target.cpp:2997
#define LLDB_WATCH_TYPE_READ
Definition: lldb-defines.h:57
lldb::SBProcess AttachToProcessWithName(SBListener &listener, const char *name, bool wait_for, lldb::SBError &error)
Attach to process with name.
Definition: SBTarget.cpp:509
lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec)
Definition: SBTarget.cpp:1637
lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file)
Write breakpoints to dest_file.
Definition: SBTarget.cpp:1305
The registry contains a unique mapping between functions and their ID.
bool ProcessIDIsValid() const
Definition: ProcessInfo.h:72
void SetCollectingStats(bool v)
Sets whether we should collect statistics on lldb or not.
Definition: SBTarget.cpp:235
bool DisableAllBreakpoints()
Definition: SBTarget.cpp:1233
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
Definition: TypeList.cpp:66
size_t ReadMemory(const SBAddress addr, void *buf, size_t size, lldb::SBError &error)
Read target memory.
Definition: SBTarget.cpp:680
lldb_private::EvaluateExpressionOptions & ref() const
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
lldb::SBError SetSectionLoadAddress(lldb::SBSection section, lldb::addr_t section_base_addr)
Set the base load address for a module section.
Definition: SBTarget.cpp:2152
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
int32_t break_id_t
Definition: lldb-types.h:88
bool AddModule(lldb::SBModule &module)
Definition: SBTarget.cpp:1607
uint32_t GetDataByteSize()
Architecture data byte width accessor.
Definition: SBTarget.cpp:1689
void SetExecutableFile(const FileSpec &exe_file, bool add_exe_file_as_first_arg)
Definition: ProcessInfo.cpp:61
const char * GetTriple()
Definition: SBTarget.cpp:1674
bool GetCollectingStats()
Returns whether statistics collection are enabled.
Definition: SBTarget.cpp:244
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
lldb::SBError ClearModuleLoadAddress(lldb::SBModule module)
Clear the section base load addresses for all sections in a module.
Definition: SBTarget.cpp:2261
lldb::SBPlatform GetPlatform()
Return the platform object associated with the target.
Definition: SBTarget.cpp:191
SBProcess LaunchSimple(const char **argv, const char **envp, const char *working_directory)
Launch a new process with sensible defaults.
Definition: SBTarget.cpp:285
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition: Module.h:531
Process is currently trying to attach.
uint32_t GetSize() const
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
void SetSP(const lldb::ProcessSP &process_sp)
Definition: SBProcess.cpp:108
lldb::SBWatchpoint FindWatchpointByID(lldb::watch_id_t watch_id)
Definition: SBTarget.cpp:1382
clang::ASTContext * getASTContext()
bool Success() const
Definition: SBError.cpp:65
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition: SBError.cpp:131
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:315
static uint32_t GetNumModulesFromEvent(const lldb::SBEvent &event)
Definition: SBTarget.cpp:140
#define LLDB_RECORD_STATIC_METHOD(Result, Class, Method, Signature,...)
lldb::break_id_t GetBreakpointID() const
Definition: BreakpointID.h:30
lldb::SBBroadcaster GetBroadcaster() const
Definition: SBTarget.cpp:1743
#define LLDB_RECORD_DUMMY(Result, Class, Method, Signature,...)
The LLDB_RECORD_DUMMY macro is special because it doesn&#39;t actually record anything.
bool DeleteAllWatchpoints()
Definition: SBTarget.cpp:1523
#define LLDB_RECORD_STATIC_METHOD_NO_ARGS(Result, Class, Method)
bool Fail() const
Definition: SBError.cpp:54
void SetProcessID(lldb::pid_t pid)
Definition: ProcessInfo.h:70
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:538
A file utility class.
Definition: FileSpec.h:55
"lldb/Utility/RegularExpression.h" A C++ wrapper class for regex.
An architecture specification class.
Definition: ArchSpec.h:32
const lldb::SBTarget & operator=(const lldb::SBTarget &rhs)
Definition: SBTarget.cpp:113
lldb::SBBreakpoint BreakpointCreateForException(lldb::LanguageType language, bool catch_bp, bool throw_bp)
Definition: SBTarget.cpp:1073
lldb::SBValue GetValueAtIndex(uint32_t idx) const
lldb::SBModule GetModuleAtIndex(uint32_t idx)
Definition: SBTarget.cpp:1718
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:2226
lldb::PlatformSP m_opaque_sp
Definition: SBPlatform.h:161
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:2375
lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data, lldb::SBType type)
Definition: SBTarget.cpp:1486
A plug-in interface definition class for object file parsers.
Definition: ObjectFile.h:58
void SetError(uint32_t err, lldb::ErrorType type)
Definition: SBError.cpp:97
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
lldb::SBSymbolContextList FindSymbols(const char *name, lldb::SymbolType type=eSymbolTypeAny)
Definition: SBTarget.cpp:2313
int32_t watch_id_t
Definition: lldb-types.h:89
lldb::ByteOrder GetByteOrder()
Definition: SBTarget.cpp:1665
bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list)
Definition: SBTarget.cpp:1173
std::recursive_mutex & GetAPIMutex()
Definition: Target.h:539
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:329
void SetSP(const lldb::ValueObjectSP &sp)
Definition: SBValue.cpp:1117
lldb_private::Event * get() const
Definition: SBEvent.cpp:141
lldb::SBValueList FindGlobalVariables(const char *name, uint32_t max_matches)
Find global and static variables by name.
Definition: SBTarget.cpp:1957
#define LLDB_REGISTER_STATIC_METHOD(Result, Class, Method, Signature)
SBSymbolContext ResolveSymbolContextForAddress(const SBAddress &addr, uint32_t resolve_scope)
Definition: SBTarget.cpp:663
void AppendString(const char *str)
lldb::SBTypeList FindTypes(const char *type)
Definition: SBTarget.cpp:1897
A subclass of DataBuffer that stores a data buffer on the heap.
void set_ref(const lldb_private::ProcessLaunchInfo &info)
bool IsValid() const
Definition: SBListener.cpp:53
void SetErrorString(const char *err_str)
Definition: SBError.cpp:124
void DeleteBreakpointName(const char *name)
Definition: SBTarget.cpp:1210
lldb::SBStructuredData GetStatistics()
Returns a dump of the collected statistics.
Definition: SBTarget.cpp:214
bool EnableAllBreakpoints()
Definition: SBTarget.cpp:1221
void Append(lldb::SBType type)
Definition: SBType.cpp:598
lldb::SBWatchpoint WatchAddress(lldb::addr_t addr, size_t size, bool read, bool write, SBError &error)
Definition: SBTarget.cpp:1401
size_t SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes=16)
Definition: UUID.cpp:92
class LLDB_API SBFileSpec
Definition: SBDefines.h:44
void SetSP(const lldb::TargetSP &target_sp)
Definition: SBTarget.cpp:602
lldb::SBValue FindFirstGlobalVariable(const char *name)
Find the first global (or static) variable by name.
Definition: SBTarget.cpp:2034
bool IsValid() const
Definition: SBFileSpec.cpp:79
lldb::ListenerSP GetSP()
Definition: SBListener.cpp:315
lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address)
Definition: SBTarget.cpp:986
lldb::SBValue CreateValueFromAddress(const char *name, lldb::SBAddress addr, lldb::SBType type)
Definition: SBTarget.cpp:1466
uint32_t GetEffectiveUserID() const
Definition: ProcessInfo.h:125
#define UINT32_MAX
Definition: lldb-defines.h:31
lldb::VariableSP GetVariableAtIndex(size_t idx) const
static bool EventIsTargetEvent(const lldb::SBEvent &event)
Definition: SBTarget.cpp:125
void AppendImageSearchPath(const char *from, const char *to, lldb::SBError &error)
Definition: SBTarget.cpp:1537
lldb::SBListener GetListener()
Definition: SBDebugger.cpp:465
SBSourceManager GetSourceManager()
Definition: SBTarget.cpp:2044
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
uint32_t GetSize()
Definition: SBType.cpp:614
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
bool BreakpointDelete(break_id_t break_id)
Definition: SBTarget.cpp:1145
lldb::TargetSP GetSP() const
Definition: SBTarget.cpp:600
LanguageType
Programming language type.
const lldb::ProcessSP & GetProcessSP() const
Definition: Target.cpp:206
lldb::addr_t GetStackRedZoneSize()
Definition: SBTarget.cpp:2392
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
Definition: ModuleList.cpp:326
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:642
uint32_t GetAddressByteSize()
Definition: SBTarget.cpp:1709
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
lldb::SBBreakpoint GetBreakpointAtIndex(uint32_t idx) const
Definition: SBTarget.cpp:1132
std::string GetStatDescription(lldb_private::StatisticKind K)
lldb_private::Status & ref()
Definition: SBError.cpp:159
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:1091
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:57
lldb_private::Address & ref()
Definition: SBAddress.cpp:188
void SetListener(const lldb::ListenerSP &listener_sp)
Definition: Process.h:178
A collection class for Module objects.
Definition: ModuleList.h:91
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
SBProcess LoadCore(const char *core_file)
Definition: SBTarget.cpp:253
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:109
Process is connected to remote debug services, but not launched or attached to anything yet...
const lldb_private::ProcessLaunchInfo & ref() const
lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name, const char *module_name=nullptr)
Definition: SBTarget.cpp:773
uint32_t GetSize() const
lldb::SBSymbolContextList FindGlobalFunctions(const char *name, uint32_t max_matches, MatchType matchtype)
Find global functions by their name with pattern matching.
Definition: SBTarget.cpp:1794
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition: SBTarget.cpp:1755
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:605
bool IsValid() const
Definition: SBValueList.cpp:88
lldb::TypeImplSP GetSP()
Definition: SBType.cpp:76
lldb_private::ProcessAttachInfo & ref()
llvm::StringRef GetString() const
void Append(const SBFileSpec &sb_file)
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
bool DeleteWatchpoint(lldb::watch_id_t watch_id)
Definition: SBTarget.cpp:1365
void CopyToBreakpointIDList(lldb_private::BreakpointIDList &bp_id_list)
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
lldb::DynamicValueType GetFetchDynamicValue() const
Environment & GetEnvironment()
Definition: ProcessInfo.h:88
lldb::SBValue EvaluateExpression(const char *expr)
Definition: SBTarget.cpp:2330
void SetSP(const lldb::WatchpointSP &sp)
lldb::SectionSP GetSectionAtIndex(size_t idx) const
Definition: Section.cpp:497
void GetBreakpointNames(SBStringList &names)
Definition: SBTarget.cpp:1193
FileSpec & GetExecutableFile()
Definition: ProcessInfo.h:43
lldb_private::SymbolContext & ref()
void SetLaunchInfo(const lldb::SBLaunchInfo &launch_info)
Definition: SBTarget.cpp:2419
ArchSpec & GetArchitecture()
Definition: ProcessInfo.h:62
void SetDisassembler(const lldb::DisassemblerSP &opaque_sp)
Execution context objects refer to objects in the execution of the program that is being debugged...
uint32_t GetCodeByteSize()
Architecture code byte width accessor.
Definition: SBTarget.cpp:1699
lldb::SBBreakpoint BreakpointCreateByLocation(const char *file, uint32_t line)
Definition: SBTarget.cpp:700
void SetRawAddress(lldb::addr_t addr)
Definition: Address.h:425
A section + offset based address class.
Definition: Address.h:80
virtual uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches, std::vector< clang::NamedDecl *> &decls)=0
Look up the set of Decls that the DeclVendor currently knows about matching a given name...
FileSpec & GetFileSpec()
Definition: ModuleSpec.h:75
bool IsValid() const
Definition: SBTarget.cpp:167
General Outline: Allows adding and removing breakpoints and find by ID and index. ...
bool RemoveModule(lldb::SBModule module)
Definition: SBTarget.cpp:1734
StructuredDataImplUP m_impl_up
lldb_private::Stream & ref()
Definition: SBStream.cpp:162
lldb::SBDebugger GetDebugger() const
Definition: SBTarget.cpp:204
lldb::SBType GetBasicType(lldb::BasicType type)
Definition: SBTarget.cpp:1883
lldb::SBLaunchInfo GetLaunchInfo() const
Definition: SBTarget.cpp:2409
lldb::SBFileSpec GetExecutable()
Definition: SBTarget.cpp:572
#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature,...)
SBError Install()
Install any binaries that need to be installed.
Definition: SBTarget.cpp:303
void AppendByID(lldb::break_id_t id)
const char * GetSummary()
Definition: SBValue.cpp:442
lldb::SBInstructionList ReadInstructions(lldb::SBAddress base_addr, uint32_t count)
Definition: SBTarget.cpp:2051
const char * GetStringAtIndex(size_t idx)
ArchSpec & GetArchitecture()
Definition: ModuleSpec.h:111
static lldb::SBModule GetModuleAtIndexFromEvent(const uint32_t idx, const lldb::SBEvent &event)
Definition: SBTarget.cpp:149
uint32_t GetNumBreakpoints() const
Definition: SBTarget.cpp:1121
lldb::SBProcess GetProcess()
Definition: SBTarget.cpp:177
bool IsValid() const
Definition: SBSection.cpp:49
lldb::SBInstructionList GetInstructions(lldb::SBAddress base_addr, const void *buf, size_t size)
Definition: SBTarget.cpp:2091
static lldb::SBTarget GetTargetFromEvent(const lldb::SBEvent &event)
Definition: SBTarget.cpp:132
uint64_t addr_t
Definition: lldb-types.h:83
lldb::SBAddress ResolveLoadAddress(lldb::addr_t vm_addr)
Resolve a current load address into a section offset address.
Definition: SBTarget.cpp:606
size_t GetSize() const
Gets the size of the module list.
Definition: ModuleList.cpp:611
A uniqued constant string class.
Definition: ConstString.h:38
const FileSpec & GetPlatformFileSpec() const
Get accessor for the module platform file specification.
Definition: Module.h:545
Unknown or invalid language value.
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:247
addr_t GetLoadAddress(const lldb::SBTarget &target) const
Definition: SBAddress.cpp:120
FileSpec & GetSymbolFileSpec()
Definition: ModuleSpec.h:99
lldb::SBBreakpoint BreakpointCreateBySourceRegex(const char *source_regex, const SBFileSpec &source_file, const char *module_name=nullptr)
Definition: SBTarget.cpp:1006
class LLDB_API SBType
Definition: SBDefines.h:78
#define LLDB_INVALID_WATCH_ID
Definition: lldb-defines.h:55
Definition: SBAddress.h:15
bool operator==(const lldb::SBTarget &rhs) const
Definition: SBTarget.cpp:586
uint64_t pid_t
Definition: lldb-types.h:85
size_t GetSize() const
Definition: Section.h:83
uint32_t GetNumModules() const
Definition: SBTarget.cpp:1618
lldb::SBInstructionList GetInstructionsWithFlavor(lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size)
Definition: SBTarget.cpp:2102
std::shared_ptr< Object > ObjectSP
lldb::SBValue CreateValueFromExpression(const char *name, const char *expr)
Definition: SBTarget.cpp:1506
lldb::SBProcess AttachToProcessWithID(SBListener &listener, lldb::pid_t pid, lldb::SBError &error)
Attach to process with pid.
Definition: SBTarget.cpp:478
#define LLDB_WATCH_TYPE_WRITE
Definition: lldb-defines.h:58
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:1257
#define PATH_MAX
#define LLDB_INVALID_BREAK_ID
Definition: lldb-defines.h:49
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
void SetFetchDynamicValue(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
lldb_private::Address * get()
Definition: SBAddress.cpp:201
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
Definition: Status.cpp:255
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition: FileSpec.cpp:198
#define LIBLLDB_LOG_EXPRESSIONS
Definition: Logging.h:22
void SetUserID(uint32_t uid)
Definition: ProcessInfo.h:58
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
friend class SBModule
Definition: SBTarget.h:831
class LLDB_API SBBreakpoint
Definition: SBDefines.h:24
bool DisableAllWatchpoints()
Definition: SBTarget.cpp:1452
bool DeleteAllBreakpoints()
Definition: SBTarget.cpp:1245
lldb::SBType FindFirstType(const char *type)
Definition: SBTarget.cpp:1828
bool IsValid() const
Definition: SBType.cpp:108
lldb::SBSymbolContextList FindCompileUnits(const lldb::SBFileSpec &sb_file_spec)
Find compile units related to *this target and passed source file.
Definition: SBTarget.cpp:1651
void AppendArguments(const Args &rhs)
Definition: Args.cpp:296
lldb::SBSymbolContextList FindFunctions(const char *name, uint32_t name_type_mask=lldb::eFunctionNameTypeAny)
Find functions by name.
Definition: SBTarget.cpp:1772
lldb::SBAddress ResolveFileAddress(lldb::addr_t file_addr)
Resolve a current file address into a section offset address.
Definition: SBTarget.cpp:625
SBProcess Attach(SBAttachInfo &attach_info, SBError &error)
Definition: SBTarget.cpp:443
bool operator!=(const lldb::SBTarget &rhs) const
Definition: SBTarget.cpp:593
lldb::SBWatchpoint GetWatchpointAtIndex(uint32_t idx) const
Definition: SBTarget.cpp:1352
bool UserIDIsValid() const
Definition: ProcessInfo.h:54
void Printf(const char *format,...) __attribute__((format(printf
Definition: Log.cpp:113
void RegisterMethods< SBTarget >(Registry &R)
Definition: SBTarget.cpp:2432
uint32_t GetNumWatchpoints() const
Definition: SBTarget.cpp:1341
size_t 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:536
class LLDB_API SBStringList
Definition: SBDefines.h:67
#define LLDB_RECORD_RESULT(Result)
friend class SBValue
Definition: SBTarget.h:836
lldb::pid_t GetProcessID() const
Definition: ProcessInfo.h:68
lldb::SBBreakpoint BreakpointCreateByAddress(addr_t address)
Definition: SBTarget.cpp:971
This base class provides an interface to stack frames.
Definition: StackFrame.h:40
const char * GetValue()
Definition: SBValue.cpp:356
bool EnableAllWatchpoints()
Definition: SBTarget.cpp:1438
lldb::SBBreakpoint FindBreakpointByID(break_id_t break_id)
Definition: SBTarget.cpp:1159
bool IsValid() const
Definition: SBAddress.cpp:79
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)
bool IsValid()
Definition: SBData.cpp:60
lldb::SBError ClearSectionLoadAddress(lldb::SBSection section)
Clear the base load address for a module section.
Definition: SBTarget.cpp:2191
void SetUnwindOnError(bool unwind=true)
An error handling class.
Definition: Status.h:44
lldb::ListenerSP GetListener() const
Definition: Process.h:176
void Append(const lldb::SBValue &val_obj)
lldb::SBBreakpoint BreakpointCreateByRegex(const char *symbol_name_regex, const char *module_name=nullptr)
Definition: SBTarget.cpp:915