LLDB  mainline
SBDebugger.cpp
Go to the documentation of this file.
1 //===-- SBDebugger.cpp ----------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/API/SBDebugger.h"
10 #include "SystemInitializerFull.h"
12 #include "lldb/Utility/LLDBLog.h"
13 
14 #include "lldb/API/SBBroadcaster.h"
18 #include "lldb/API/SBError.h"
19 #include "lldb/API/SBEvent.h"
20 #include "lldb/API/SBFile.h"
21 #include "lldb/API/SBFrame.h"
22 #include "lldb/API/SBListener.h"
23 #include "lldb/API/SBProcess.h"
25 #include "lldb/API/SBStream.h"
26 #include "lldb/API/SBStringList.h"
28 #include "lldb/API/SBTarget.h"
29 #include "lldb/API/SBThread.h"
31 #include "lldb/API/SBTypeFilter.h"
32 #include "lldb/API/SBTypeFormat.h"
34 #include "lldb/API/SBTypeSummary.h"
36 
37 #include "lldb/Core/Debugger.h"
40 #include "lldb/Core/Progress.h"
41 #include "lldb/Core/StreamFile.h"
44 #include "lldb/Host/Config.h"
45 #include "lldb/Host/XML.h"
50 #include "lldb/Target/Process.h"
51 #include "lldb/Target/TargetList.h"
52 #include "lldb/Utility/Args.h"
53 #include "lldb/Utility/State.h"
54 #include "lldb/Version/Version.h"
55 
56 #include "llvm/ADT/STLExtras.h"
57 #include "llvm/ADT/StringRef.h"
58 #include "llvm/Support/DynamicLibrary.h"
59 #include "llvm/Support/ManagedStatic.h"
60 #include "llvm/Support/PrettyStackTrace.h"
61 #include "llvm/Support/Signals.h"
62 
63 using namespace lldb;
64 using namespace lldb_private;
65 
66 static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp,
67  const FileSpec &spec,
68  Status &error) {
69  llvm::sys::DynamicLibrary dynlib =
70  llvm::sys::DynamicLibrary::getPermanentLibrary(spec.GetPath().c_str());
71  if (dynlib.isValid()) {
72  typedef bool (*LLDBCommandPluginInit)(lldb::SBDebugger & debugger);
73 
74  lldb::SBDebugger debugger_sb(debugger_sp);
75  // This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger)
76  // function.
77  // TODO: mangle this differently for your system - on OSX, the first
78  // underscore needs to be removed and the second one stays
79  LLDBCommandPluginInit init_func =
80  (LLDBCommandPluginInit)(uintptr_t)dynlib.getAddressOfSymbol(
81  "_ZN4lldb16PluginInitializeENS_10SBDebuggerE");
82  if (init_func) {
83  if (init_func(debugger_sb))
84  return dynlib;
85  else
86  error.SetErrorString("plug-in refused to load "
87  "(lldb::PluginInitialize(lldb::SBDebugger) "
88  "returned false)");
89  } else {
90  error.SetErrorString("plug-in is missing the required initialization: "
91  "lldb::PluginInitialize(lldb::SBDebugger)");
92  }
93  } else {
94  if (FileSystem::Instance().Exists(spec))
95  error.SetErrorString("this file does not represent a loadable dylib");
96  else
97  error.SetErrorString("no such file");
98  }
99  return llvm::sys::DynamicLibrary();
100 }
101 
102 static llvm::ManagedStatic<SystemLifetimeManager> g_debugger_lifetime;
103 
105  lldb::SBDebugger &sb_debugger,
106  unsigned long (*callback)(void *, lldb::SBInputReader *,
107  lldb::InputReaderAction, char const *,
108  unsigned long),
109  void *a, lldb::InputReaderGranularity b, char const *c, char const *d,
110  bool e) {
111  LLDB_INSTRUMENT_VA(this, sb_debugger, callback, a, b, c, d, e);
112 
113  return SBError();
114 }
115 
117 
119  LLDB_INSTRUMENT_VA(this);
120 
121  return false;
122 }
123 
125 
126 SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp)
127  : m_opaque_sp(debugger_sp) {
128  LLDB_INSTRUMENT_VA(this, debugger_sp);
129 }
130 
131 SBDebugger::SBDebugger(const SBDebugger &rhs) : m_opaque_sp(rhs.m_opaque_sp) {
132  LLDB_INSTRUMENT_VA(this, rhs);
133 }
134 
135 SBDebugger::~SBDebugger() = default;
136 
138  LLDB_INSTRUMENT_VA(this, rhs);
139 
140  if (this != &rhs) {
141  m_opaque_sp = rhs.m_opaque_sp;
142  }
143  return *this;
144 }
145 
147  LLDB_INSTRUMENT();
148 
150 }
151 
153  uint64_t &progress_id,
154  uint64_t &completed,
155  uint64_t &total,
156  bool &is_debugger_specific) {
157  LLDB_INSTRUMENT_VA(event);
158  const ProgressEventData *progress_data =
160  if (progress_data == nullptr)
161  return nullptr;
162  progress_id = progress_data->GetID();
163  completed = progress_data->GetCompleted();
164  total = progress_data->GetTotal();
165  is_debugger_specific = progress_data->IsDebuggerSpecific();
166  return progress_data->GetMessage().c_str();
167 }
168 
171  LLDB_INSTRUMENT_VA(event);
172 
173  const DiagnosticEventData *diagnostic_data =
175  if (!diagnostic_data)
176  return {};
177 
178  auto dictionary = std::make_unique<StructuredData::Dictionary>();
179  dictionary->AddStringItem("message", diagnostic_data->GetMessage());
180  dictionary->AddStringItem("type", diagnostic_data->GetPrefix());
181  dictionary->AddBooleanItem("debugger_specific",
182  diagnostic_data->IsDebuggerSpecific());
183 
184  SBStructuredData data;
185  data.m_impl_up->SetObjectSP(std::move(dictionary));
186  return data;
187 }
188 
190  LLDB_INSTRUMENT_VA(this);
191  SBBroadcaster broadcaster(&m_opaque_sp->GetBroadcaster(), false);
192  return broadcaster;
193 }
194 
196  LLDB_INSTRUMENT();
198 }
199 
201  LLDB_INSTRUMENT();
202 
203  SBError error;
204  if (auto e = g_debugger_lifetime->Initialize(
205  std::make_unique<SystemInitializerFull>(), LoadPlugin)) {
206  error.SetError(Status(std::move(e)));
207  }
208  return error;
209 }
210 
212  LLDB_INSTRUMENT();
213 
214  llvm::EnablePrettyStackTrace();
215  static std::string executable =
216  llvm::sys::fs::getMainExecutable(nullptr, nullptr);
217  llvm::sys::PrintStackTraceOnErrorSignal(executable);
218 }
219 
221  LLDB_INSTRUMENT();
222 
223  g_debugger_lifetime->Terminate();
224 }
225 
227  LLDB_INSTRUMENT_VA(this);
228 
229  if (m_opaque_sp)
230  m_opaque_sp->ClearIOHandlers();
231 
232  m_opaque_sp.reset();
233 }
234 
236  LLDB_INSTRUMENT();
237 
238  return SBDebugger::Create(false, nullptr, nullptr);
239 }
240 
241 SBDebugger SBDebugger::Create(bool source_init_files) {
242  LLDB_INSTRUMENT_VA(source_init_files);
243 
244  return SBDebugger::Create(source_init_files, nullptr, nullptr);
245 }
246 
247 SBDebugger SBDebugger::Create(bool source_init_files,
248  lldb::LogOutputCallback callback, void *baton)
249 
250 {
251  LLDB_INSTRUMENT_VA(source_init_files, callback, baton);
252 
253  SBDebugger debugger;
254 
255  // Currently we have issues if this function is called simultaneously on two
256  // different threads. The issues mainly revolve around the fact that the
257  // lldb_private::FormatManager uses global collections and having two threads
258  // parsing the .lldbinit files can cause mayhem. So to get around this for
259  // now we need to use a mutex to prevent bad things from happening.
260  static std::recursive_mutex g_mutex;
261  std::lock_guard<std::recursive_mutex> guard(g_mutex);
262 
263  debugger.reset(Debugger::CreateInstance(callback, baton));
264 
265  SBCommandInterpreter interp = debugger.GetCommandInterpreter();
266  if (source_init_files) {
267  interp.get()->SkipLLDBInitFiles(false);
268  interp.get()->SkipAppInitFiles(false);
269  SBCommandReturnObject result;
270  interp.SourceInitFileInGlobalDirectory(result);
271  interp.SourceInitFileInHomeDirectory(result, false);
272  } else {
273  interp.get()->SkipLLDBInitFiles(true);
274  interp.get()->SkipAppInitFiles(true);
275  }
276  return debugger;
277 }
278 
280  LLDB_INSTRUMENT_VA(debugger);
281 
282  Debugger::Destroy(debugger.m_opaque_sp);
283 
284  if (debugger.m_opaque_sp.get() != nullptr)
285  debugger.m_opaque_sp.reset();
286 }
287 
289  LLDB_INSTRUMENT();
290 
291  // Since this function can be call asynchronously, we allow it to be non-
292  // mandatory. We have seen deadlocks with this function when called so we
293  // need to safeguard against this until we can determine what is causing the
294  // deadlocks.
295 
296  const bool mandatory = false;
297 
299 }
300 
301 bool SBDebugger::IsValid() const {
302  LLDB_INSTRUMENT_VA(this);
303  return this->operator bool();
304 }
305 SBDebugger::operator bool() const {
306  LLDB_INSTRUMENT_VA(this);
307 
308  return m_opaque_sp.get() != nullptr;
309 }
310 
311 void SBDebugger::SetAsync(bool b) {
312  LLDB_INSTRUMENT_VA(this, b);
313 
314  if (m_opaque_sp)
315  m_opaque_sp->SetAsyncExecution(b);
316 }
317 
319  LLDB_INSTRUMENT_VA(this);
320 
321  return (m_opaque_sp ? m_opaque_sp->GetAsyncExecution() : false);
322 }
323 
325  LLDB_INSTRUMENT_VA(this, b);
326 
327  if (m_opaque_sp)
328  m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles(b);
329 }
330 
332  LLDB_INSTRUMENT_VA(this, b);
333 
334  if (m_opaque_sp)
335  m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles(b);
336 }
337 
338 void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) {
339  LLDB_INSTRUMENT_VA(this, fh, transfer_ownership);
340  if (m_opaque_sp)
341  m_opaque_sp->SetInputFile(
342  (FileSP)std::make_shared<NativeFile>(fh, transfer_ownership));
343 }
344 
346  LLDB_INSTRUMENT_VA(this, data);
347  SBError sb_error;
348  if (data == nullptr) {
349  sb_error.SetErrorString("String data is null");
350  return sb_error;
351  }
352 
353  size_t size = strlen(data);
354  if (size == 0) {
355  sb_error.SetErrorString("String data is empty");
356  return sb_error;
357  }
358 
359  if (!m_opaque_sp) {
360  sb_error.SetErrorString("invalid debugger");
361  return sb_error;
362  }
363 
364  sb_error.SetError(m_opaque_sp->SetInputString(data));
365  return sb_error;
366 }
367 
368 // Shouldn't really be settable after initialization as this could cause lots
369 // of problems; don't want users trying to switch modes in the middle of a
370 // debugging session.
372  LLDB_INSTRUMENT_VA(this, file);
373 
374  SBError error;
375  if (!m_opaque_sp) {
376  error.ref().SetErrorString("invalid debugger");
377  return error;
378  }
379  error.SetError(m_opaque_sp->SetInputFile(file.m_opaque_sp));
380  return error;
381 }
382 
384  LLDB_INSTRUMENT_VA(this, file_sp);
385  return SetInputFile(SBFile(file_sp));
386 }
387 
389  LLDB_INSTRUMENT_VA(this, file_sp);
390  return SetOutputFile(SBFile(file_sp));
391 }
392 
393 void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) {
394  LLDB_INSTRUMENT_VA(this, fh, transfer_ownership);
395  SetOutputFile((FileSP)std::make_shared<NativeFile>(fh, transfer_ownership));
396 }
397 
399  LLDB_INSTRUMENT_VA(this, file);
400  SBError error;
401  if (!m_opaque_sp) {
402  error.ref().SetErrorString("invalid debugger");
403  return error;
404  }
405  if (!file) {
406  error.ref().SetErrorString("invalid file");
407  return error;
408  }
409  m_opaque_sp->SetOutputFile(file.m_opaque_sp);
410  return error;
411 }
412 
413 void SBDebugger::SetErrorFileHandle(FILE *fh, bool transfer_ownership) {
414  LLDB_INSTRUMENT_VA(this, fh, transfer_ownership);
415  SetErrorFile((FileSP)std::make_shared<NativeFile>(fh, transfer_ownership));
416 }
417 
419  LLDB_INSTRUMENT_VA(this, file_sp);
420  return SetErrorFile(SBFile(file_sp));
421 }
422 
424  LLDB_INSTRUMENT_VA(this, file);
425  SBError error;
426  if (!m_opaque_sp) {
427  error.ref().SetErrorString("invalid debugger");
428  return error;
429  }
430  if (!file) {
431  error.ref().SetErrorString("invalid file");
432  return error;
433  }
434  m_opaque_sp->SetErrorFile(file.m_opaque_sp);
435  return error;
436 }
437 
439  LLDB_INSTRUMENT_VA(this);
440  if (m_opaque_sp) {
441  File &file_sp = m_opaque_sp->GetInputFile();
442  return file_sp.GetStream();
443  }
444  return nullptr;
445 }
446 
448  LLDB_INSTRUMENT_VA(this);
449  if (m_opaque_sp) {
450  return SBFile(m_opaque_sp->GetInputFileSP());
451  }
452  return SBFile();
453 }
454 
456  LLDB_INSTRUMENT_VA(this);
457  if (m_opaque_sp) {
458  StreamFile &stream_file = m_opaque_sp->GetOutputStream();
459  return stream_file.GetFile().GetStream();
460  }
461  return nullptr;
462 }
463 
465  LLDB_INSTRUMENT_VA(this);
466  if (m_opaque_sp) {
467  SBFile file(m_opaque_sp->GetOutputStream().GetFileSP());
468  return file;
469  }
470  return SBFile();
471 }
472 
474  LLDB_INSTRUMENT_VA(this);
475 
476  if (m_opaque_sp) {
477  StreamFile &stream_file = m_opaque_sp->GetErrorStream();
478  return stream_file.GetFile().GetStream();
479  }
480  return nullptr;
481 }
482 
484  LLDB_INSTRUMENT_VA(this);
485  SBFile file;
486  if (m_opaque_sp) {
487  SBFile file(m_opaque_sp->GetErrorStream().GetFileSP());
488  return file;
489  }
490  return SBFile();
491 }
492 
494  LLDB_INSTRUMENT_VA(this);
495 
496  if (m_opaque_sp)
497  m_opaque_sp->SaveInputTerminalState();
498 }
499 
501  LLDB_INSTRUMENT_VA(this);
502 
503  if (m_opaque_sp)
504  m_opaque_sp->RestoreInputTerminalState();
505 }
507  LLDB_INSTRUMENT_VA(this);
508 
509  SBCommandInterpreter sb_interpreter;
510  if (m_opaque_sp)
511  sb_interpreter.reset(&m_opaque_sp->GetCommandInterpreter());
512 
513  return sb_interpreter;
514 }
515 
516 void SBDebugger::HandleCommand(const char *command) {
517  LLDB_INSTRUMENT_VA(this, command);
518 
519  if (m_opaque_sp) {
520  TargetSP target_sp(m_opaque_sp->GetSelectedTarget());
521  std::unique_lock<std::recursive_mutex> lock;
522  if (target_sp)
523  lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
524 
526  SBCommandReturnObject result;
527 
528  sb_interpreter.HandleCommand(command, result, false);
529 
530  result.PutError(m_opaque_sp->GetErrorStream().GetFileSP());
531  result.PutOutput(m_opaque_sp->GetOutputStream().GetFileSP());
532 
533  if (!m_opaque_sp->GetAsyncExecution()) {
534  SBProcess process(GetCommandInterpreter().GetProcess());
535  ProcessSP process_sp(process.GetSP());
536  if (process_sp) {
537  EventSP event_sp;
538  ListenerSP lldb_listener_sp = m_opaque_sp->GetListener();
539  while (lldb_listener_sp->GetEventForBroadcaster(
540  process_sp.get(), event_sp, std::chrono::seconds(0))) {
541  SBEvent event(event_sp);
542  HandleProcessEvent(process, event, GetOutputFile(), GetErrorFile());
543  }
544  }
545  }
546  }
547 }
548 
550  LLDB_INSTRUMENT_VA(this);
551 
552  SBListener sb_listener;
553  if (m_opaque_sp)
554  sb_listener.reset(m_opaque_sp->GetListener());
555 
556  return sb_listener;
557 }
558 
560  const SBEvent &event, SBFile out,
561  SBFile err) {
562  LLDB_INSTRUMENT_VA(this, process, event, out, err);
563 
564  return HandleProcessEvent(process, event, out.m_opaque_sp, err.m_opaque_sp);
565 }
566 
568  const SBEvent &event, FILE *out,
569  FILE *err) {
570  LLDB_INSTRUMENT_VA(this, process, event, out, err);
571 
572  FileSP outfile = std::make_shared<NativeFile>(out, false);
573  FileSP errfile = std::make_shared<NativeFile>(err, false);
574  return HandleProcessEvent(process, event, outfile, errfile);
575 }
576 
578  const SBEvent &event, FileSP out_sp,
579  FileSP err_sp) {
580 
581  LLDB_INSTRUMENT_VA(this, process, event, out_sp, err_sp);
582 
583  if (!process.IsValid())
584  return;
585 
586  TargetSP target_sp(process.GetTarget().GetSP());
587  if (!target_sp)
588  return;
589 
590  const uint32_t event_type = event.GetType();
591  char stdio_buffer[1024];
592  size_t len;
593 
594  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
595 
596  if (event_type &
598  // Drain stdout when we stop just in case we have any bytes
599  while ((len = process.GetSTDOUT(stdio_buffer, sizeof(stdio_buffer))) > 0)
600  if (out_sp)
601  out_sp->Write(stdio_buffer, len);
602  }
603 
604  if (event_type &
606  // Drain stderr when we stop just in case we have any bytes
607  while ((len = process.GetSTDERR(stdio_buffer, sizeof(stdio_buffer))) > 0)
608  if (err_sp)
609  err_sp->Write(stdio_buffer, len);
610  }
611 
612  if (event_type & Process::eBroadcastBitStateChanged) {
613  StateType event_state = SBProcess::GetStateFromEvent(event);
614 
615  if (event_state == eStateInvalid)
616  return;
617 
618  bool is_stopped = StateIsStoppedState(event_state);
619  if (!is_stopped)
620  process.ReportEventState(event, out_sp);
621  }
622 }
623 
625  LLDB_INSTRUMENT_VA(this);
626 
627  SBSourceManager sb_source_manager(*this);
628  return sb_source_manager;
629 }
630 
631 bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) {
632  LLDB_INSTRUMENT_VA(arch_name, arch_name_len);
633 
634  if (arch_name && arch_name_len) {
635  ArchSpec default_arch = Target::GetDefaultArchitecture();
636 
637  if (default_arch.IsValid()) {
638  const std::string &triple_str = default_arch.GetTriple().str();
639  if (!triple_str.empty())
640  ::snprintf(arch_name, arch_name_len, "%s", triple_str.c_str());
641  else
642  ::snprintf(arch_name, arch_name_len, "%s",
643  default_arch.GetArchitectureName());
644  return true;
645  }
646  }
647  if (arch_name && arch_name_len)
648  arch_name[0] = '\0';
649  return false;
650 }
651 
652 bool SBDebugger::SetDefaultArchitecture(const char *arch_name) {
653  LLDB_INSTRUMENT_VA(arch_name);
654 
655  if (arch_name) {
656  ArchSpec arch(arch_name);
657  if (arch.IsValid()) {
659  return true;
660  }
661  }
662  return false;
663 }
664 
666 SBDebugger::GetScriptingLanguage(const char *script_language_name) {
667  LLDB_INSTRUMENT_VA(this, script_language_name);
668 
669  if (!script_language_name)
670  return eScriptLanguageDefault;
672  llvm::StringRef(script_language_name), eScriptLanguageDefault, nullptr);
673 }
674 
677  LLDB_INSTRUMENT_VA(this, language);
678  SBStructuredData data;
679  if (m_opaque_sp) {
681  m_opaque_sp->GetScriptInterpreter(language);
682  if (interp) {
683  data.m_impl_up->SetObjectSP(interp->GetInterpreterInfo());
684  }
685  }
686  return data;
687 }
688 
690  LLDB_INSTRUMENT();
691 
692  return lldb_private::GetVersion();
693 }
694 
696  LLDB_INSTRUMENT_VA(state);
697 
698  return lldb_private::StateAsCString(state);
699 }
700 
702  llvm::StringRef name, bool value,
703  llvm::StringRef description) {
704  auto entry_up = std::make_unique<StructuredData::Dictionary>();
705  entry_up->AddBooleanItem("value", value);
706  entry_up->AddStringItem("description", description);
707  dict.AddItem(name, std::move(entry_up));
708 }
709 
711  auto array_up = std::make_unique<StructuredData::Array>();
712 #define LLVM_TARGET(target) \
713  array_up->AddItem(std::make_unique<StructuredData::String>(#target));
714 #include "llvm/Config/Targets.def"
715  auto entry_up = std::make_unique<StructuredData::Dictionary>();
716  entry_up->AddItem("value", std::move(array_up));
717  entry_up->AddStringItem("description", "A list of configured LLVM targets.");
718  dict.AddItem("targets", std::move(entry_up));
719 }
720 
722  LLDB_INSTRUMENT();
723 
724  auto config_up = std::make_unique<StructuredData::Dictionary>();
726  *config_up, "xml", XMLDocument::XMLEnabled(),
727  "A boolean value that indicates if XML support is enabled in LLDB");
729  *config_up, "curses", LLDB_ENABLE_CURSES,
730  "A boolean value that indicates if curses support is enabled in LLDB");
732  *config_up, "editline", LLDB_ENABLE_LIBEDIT,
733  "A boolean value that indicates if editline support is enabled in LLDB");
735  *config_up, "lzma", LLDB_ENABLE_LZMA,
736  "A boolean value that indicates if lzma support is enabled in LLDB");
738  *config_up, "python", LLDB_ENABLE_PYTHON,
739  "A boolean value that indicates if python support is enabled in LLDB");
741  *config_up, "lua", LLDB_ENABLE_LUA,
742  "A boolean value that indicates if lua support is enabled in LLDB");
743  AddBoolConfigEntry(*config_up, "fbsdvmcore", LLDB_ENABLE_FBSDVMCORE,
744  "A boolean value that indicates if fbsdvmcore support is "
745  "enabled in LLDB");
746  AddLLVMTargets(*config_up);
747 
748  SBStructuredData data;
749  data.m_impl_up->SetObjectSP(std::move(config_up));
750  return data;
751 }
752 
754  LLDB_INSTRUMENT_VA(state);
755 
756  const bool result = lldb_private::StateIsRunningState(state);
757 
758  return result;
759 }
760 
762  LLDB_INSTRUMENT_VA(state);
763 
764  const bool result = lldb_private::StateIsStoppedState(state, false);
765 
766  return result;
767 }
768 
770  const char *target_triple,
771  const char *platform_name,
772  bool add_dependent_modules,
773  lldb::SBError &sb_error) {
774  LLDB_INSTRUMENT_VA(this, filename, target_triple, platform_name,
775  add_dependent_modules, sb_error);
776 
777  SBTarget sb_target;
778  TargetSP target_sp;
779  if (m_opaque_sp) {
780  sb_error.Clear();
781  OptionGroupPlatform platform_options(false);
782  platform_options.SetPlatformName(platform_name);
783 
784  sb_error.ref() = m_opaque_sp->GetTargetList().CreateTarget(
785  *m_opaque_sp, filename, target_triple,
786  add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo,
787  &platform_options, target_sp);
788 
789  if (sb_error.Success())
790  sb_target.SetSP(target_sp);
791  } else {
792  sb_error.SetErrorString("invalid debugger");
793  }
794 
795  Log *log = GetLog(LLDBLog::API);
796  LLDB_LOGF(log,
797  "SBDebugger(%p)::CreateTarget (filename=\"%s\", triple=%s, "
798  "platform_name=%s, add_dependent_modules=%u, error=%s) => "
799  "SBTarget(%p)",
800  static_cast<void *>(m_opaque_sp.get()), filename, target_triple,
801  platform_name, add_dependent_modules, sb_error.GetCString(),
802  static_cast<void *>(target_sp.get()));
803 
804  return sb_target;
805 }
806 
807 SBTarget
809  const char *target_triple) {
810  LLDB_INSTRUMENT_VA(this, filename, target_triple);
811 
812  SBTarget sb_target;
813  TargetSP target_sp;
814  if (m_opaque_sp) {
815  const bool add_dependent_modules = true;
816  Status error(m_opaque_sp->GetTargetList().CreateTarget(
817  *m_opaque_sp, filename, target_triple,
818  add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr,
819  target_sp));
820  sb_target.SetSP(target_sp);
821  }
822 
823  Log *log = GetLog(LLDBLog::API);
824  LLDB_LOGF(log,
825  "SBDebugger(%p)::CreateTargetWithFileAndTargetTriple "
826  "(filename=\"%s\", triple=%s) => SBTarget(%p)",
827  static_cast<void *>(m_opaque_sp.get()), filename, target_triple,
828  static_cast<void *>(target_sp.get()));
829 
830  return sb_target;
831 }
832 
834  const char *arch_cstr) {
835  LLDB_INSTRUMENT_VA(this, filename, arch_cstr);
836 
837  Log *log = GetLog(LLDBLog::API);
838 
839  SBTarget sb_target;
840  TargetSP target_sp;
841  if (m_opaque_sp) {
842  Status error;
843  if (arch_cstr == nullptr) {
844  // The version of CreateTarget that takes an ArchSpec won't accept an
845  // empty ArchSpec, so when the arch hasn't been specified, we need to
846  // call the target triple version.
847  error = m_opaque_sp->GetTargetList().CreateTarget(
848  *m_opaque_sp, filename, arch_cstr, eLoadDependentsYes, nullptr,
849  target_sp);
850  } else {
851  PlatformSP platform_sp =
852  m_opaque_sp->GetPlatformList().GetSelectedPlatform();
853  ArchSpec arch =
854  Platform::GetAugmentedArchSpec(platform_sp.get(), arch_cstr);
855  if (arch.IsValid())
856  error = m_opaque_sp->GetTargetList().CreateTarget(
857  *m_opaque_sp, filename, arch, eLoadDependentsYes, platform_sp,
858  target_sp);
859  else
860  error.SetErrorStringWithFormat("invalid arch_cstr: %s", arch_cstr);
861  }
862  if (error.Success())
863  sb_target.SetSP(target_sp);
864  }
865 
866  LLDB_LOGF(log,
867  "SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", "
868  "arch=%s) => SBTarget(%p)",
869  static_cast<void *>(m_opaque_sp.get()),
870  filename ? filename : "<unspecified>",
871  arch_cstr ? arch_cstr : "<unspecified>",
872  static_cast<void *>(target_sp.get()));
873 
874  return sb_target;
875 }
876 
877 SBTarget SBDebugger::CreateTarget(const char *filename) {
878  LLDB_INSTRUMENT_VA(this, filename);
879 
880  SBTarget sb_target;
881  TargetSP target_sp;
882  if (m_opaque_sp) {
883  Status error;
884  const bool add_dependent_modules = true;
885  error = m_opaque_sp->GetTargetList().CreateTarget(
886  *m_opaque_sp, filename, "",
887  add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr,
888  target_sp);
889 
890  if (error.Success())
891  sb_target.SetSP(target_sp);
892  }
893  Log *log = GetLog(LLDBLog::API);
894  LLDB_LOGF(log,
895  "SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)",
896  static_cast<void *>(m_opaque_sp.get()), filename,
897  static_cast<void *>(target_sp.get()));
898  return sb_target;
899 }
900 
902  LLDB_INSTRUMENT_VA(this);
903 
904  SBTarget sb_target;
905  if (m_opaque_sp) {
906  sb_target.SetSP(m_opaque_sp->GetDummyTarget().shared_from_this());
907  }
908  Log *log = GetLog(LLDBLog::API);
909  LLDB_LOGF(log, "SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)",
910  static_cast<void *>(m_opaque_sp.get()),
911  static_cast<void *>(sb_target.GetSP().get()));
912  return sb_target;
913 }
914 
916  LLDB_INSTRUMENT_VA(this, target);
917 
918  bool result = false;
919  if (m_opaque_sp) {
920  TargetSP target_sp(target.GetSP());
921  if (target_sp) {
922  // No need to lock, the target list is thread safe
923  result = m_opaque_sp->GetTargetList().DeleteTarget(target_sp);
924  target_sp->Destroy();
925  target.Clear();
926  }
927  }
928 
929  Log *log = GetLog(LLDBLog::API);
930  LLDB_LOGF(log, "SBDebugger(%p)::DeleteTarget (SBTarget(%p)) => %i",
931  static_cast<void *>(m_opaque_sp.get()),
932  static_cast<void *>(target.m_opaque_sp.get()), result);
933 
934  return result;
935 }
936 
938  LLDB_INSTRUMENT_VA(this, idx);
939 
940  SBTarget sb_target;
941  if (m_opaque_sp) {
942  // No need to lock, the target list is thread safe
943  sb_target.SetSP(m_opaque_sp->GetTargetList().GetTargetAtIndex(idx));
944  }
945  return sb_target;
946 }
947 
949  LLDB_INSTRUMENT_VA(this, target);
950 
951  lldb::TargetSP target_sp = target.GetSP();
952  if (!target_sp)
953  return UINT32_MAX;
954 
955  if (!m_opaque_sp)
956  return UINT32_MAX;
957 
958  return m_opaque_sp->GetTargetList().GetIndexOfTarget(target.GetSP());
959 }
960 
962  LLDB_INSTRUMENT_VA(this, pid);
963 
964  SBTarget sb_target;
965  if (m_opaque_sp) {
966  // No need to lock, the target list is thread safe
967  sb_target.SetSP(m_opaque_sp->GetTargetList().FindTargetWithProcessID(pid));
968  }
969  return sb_target;
970 }
971 
973  const char *arch_name) {
974  LLDB_INSTRUMENT_VA(this, filename, arch_name);
975 
976  SBTarget sb_target;
977  if (m_opaque_sp && filename && filename[0]) {
978  // No need to lock, the target list is thread safe
980  m_opaque_sp->GetPlatformList().GetSelectedPlatform().get(), arch_name);
981  TargetSP target_sp(
982  m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture(
983  FileSpec(filename), arch_name ? &arch : nullptr));
984  sb_target.SetSP(target_sp);
985  }
986  return sb_target;
987 }
988 
989 SBTarget SBDebugger::FindTargetWithLLDBProcess(const ProcessSP &process_sp) {
990  SBTarget sb_target;
991  if (m_opaque_sp) {
992  // No need to lock, the target list is thread safe
993  sb_target.SetSP(
994  m_opaque_sp->GetTargetList().FindTargetWithProcess(process_sp.get()));
995  }
996  return sb_target;
997 }
998 
1000  LLDB_INSTRUMENT_VA(this);
1001 
1002  if (m_opaque_sp) {
1003  // No need to lock, the target list is thread safe
1004  return m_opaque_sp->GetTargetList().GetNumTargets();
1005  }
1006  return 0;
1007 }
1008 
1010  LLDB_INSTRUMENT_VA(this);
1011 
1012  Log *log = GetLog(LLDBLog::API);
1013 
1014  SBTarget sb_target;
1015  TargetSP target_sp;
1016  if (m_opaque_sp) {
1017  // No need to lock, the target list is thread safe
1018  target_sp = m_opaque_sp->GetTargetList().GetSelectedTarget();
1019  sb_target.SetSP(target_sp);
1020  }
1021 
1022  if (log) {
1023  SBStream sstr;
1024  sb_target.GetDescription(sstr, eDescriptionLevelBrief);
1025  LLDB_LOGF(log, "SBDebugger(%p)::GetSelectedTarget () => SBTarget(%p): %s",
1026  static_cast<void *>(m_opaque_sp.get()),
1027  static_cast<void *>(target_sp.get()), sstr.GetData());
1028  }
1029 
1030  return sb_target;
1031 }
1032 
1034  LLDB_INSTRUMENT_VA(this, sb_target);
1035 
1036  Log *log = GetLog(LLDBLog::API);
1037 
1038  TargetSP target_sp(sb_target.GetSP());
1039  if (m_opaque_sp) {
1040  m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp);
1041  }
1042  if (log) {
1043  SBStream sstr;
1044  sb_target.GetDescription(sstr, eDescriptionLevelBrief);
1045  LLDB_LOGF(log, "SBDebugger(%p)::SetSelectedTarget () => SBTarget(%p): %s",
1046  static_cast<void *>(m_opaque_sp.get()),
1047  static_cast<void *>(target_sp.get()), sstr.GetData());
1048  }
1049 }
1050 
1052  LLDB_INSTRUMENT_VA(this);
1053 
1054  Log *log = GetLog(LLDBLog::API);
1055 
1056  SBPlatform sb_platform;
1057  DebuggerSP debugger_sp(m_opaque_sp);
1058  if (debugger_sp) {
1059  sb_platform.SetSP(debugger_sp->GetPlatformList().GetSelectedPlatform());
1060  }
1061  LLDB_LOGF(log, "SBDebugger(%p)::GetSelectedPlatform () => SBPlatform(%p): %s",
1062  static_cast<void *>(m_opaque_sp.get()),
1063  static_cast<void *>(sb_platform.GetSP().get()),
1064  sb_platform.GetName());
1065  return sb_platform;
1066 }
1067 
1069  LLDB_INSTRUMENT_VA(this, sb_platform);
1070 
1071  Log *log = GetLog(LLDBLog::API);
1072 
1073  DebuggerSP debugger_sp(m_opaque_sp);
1074  if (debugger_sp) {
1075  debugger_sp->GetPlatformList().SetSelectedPlatform(sb_platform.GetSP());
1076  }
1077 
1078  LLDB_LOGF(log, "SBDebugger(%p)::SetSelectedPlatform (SBPlatform(%p) %s)",
1079  static_cast<void *>(m_opaque_sp.get()),
1080  static_cast<void *>(sb_platform.GetSP().get()),
1081  sb_platform.GetName());
1082 }
1083 
1085  LLDB_INSTRUMENT_VA(this);
1086 
1087  if (m_opaque_sp) {
1088  // No need to lock, the platform list is thread safe
1089  return m_opaque_sp->GetPlatformList().GetSize();
1090  }
1091  return 0;
1092 }
1093 
1095  LLDB_INSTRUMENT_VA(this, idx);
1096 
1097  SBPlatform sb_platform;
1098  if (m_opaque_sp) {
1099  // No need to lock, the platform list is thread safe
1100  sb_platform.SetSP(m_opaque_sp->GetPlatformList().GetAtIndex(idx));
1101  }
1102  return sb_platform;
1103 }
1104 
1106  LLDB_INSTRUMENT_VA(this);
1107 
1108  uint32_t idx = 0;
1109  while (true) {
1111  break;
1112  }
1113  ++idx;
1114  }
1115  // +1 for the host platform, which should always appear first in the list.
1116  return idx + 1;
1117 }
1118 
1120  LLDB_INSTRUMENT_VA(this, idx);
1121 
1122  SBStructuredData data;
1123  auto platform_dict = std::make_unique<StructuredData::Dictionary>();
1124  llvm::StringRef name_str("name"), desc_str("description");
1125 
1126  if (idx == 0) {
1127  PlatformSP host_platform_sp(Platform::GetHostPlatform());
1128  platform_dict->AddStringItem(name_str, host_platform_sp->GetPluginName());
1129  platform_dict->AddStringItem(
1130  desc_str, llvm::StringRef(host_platform_sp->GetDescription()));
1131  } else if (idx > 0) {
1132  llvm::StringRef plugin_name =
1134  if (plugin_name.empty()) {
1135  return data;
1136  }
1137  platform_dict->AddStringItem(name_str, llvm::StringRef(plugin_name));
1138 
1139  llvm::StringRef plugin_desc =
1141  platform_dict->AddStringItem(desc_str, llvm::StringRef(plugin_desc));
1142  }
1143 
1144  data.m_impl_up->SetObjectSP(
1145  StructuredData::ObjectSP(platform_dict.release()));
1146  return data;
1147 }
1148 
1149 void SBDebugger::DispatchInput(void *baton, const void *data, size_t data_len) {
1150  LLDB_INSTRUMENT_VA(this, baton, data, data_len);
1151 
1152  DispatchInput(data, data_len);
1153 }
1154 
1155 void SBDebugger::DispatchInput(const void *data, size_t data_len) {
1156  LLDB_INSTRUMENT_VA(this, data, data_len);
1157 
1158  // Log *log(GetLog (LLDBLog::API));
1159  //
1160  // if (log)
1161  // LLDB_LOGF(log, "SBDebugger(%p)::DispatchInput (data=\"%.*s\",
1162  // size_t=%" PRIu64 ")",
1163  // m_opaque_sp.get(),
1164  // (int) data_len,
1165  // (const char *) data,
1166  // (uint64_t)data_len);
1167  //
1168  // if (m_opaque_sp)
1169  // m_opaque_sp->DispatchInput ((const char *) data, data_len);
1170 }
1171 
1173  LLDB_INSTRUMENT_VA(this);
1174 
1175  if (m_opaque_sp)
1176  m_opaque_sp->DispatchInputInterrupt();
1177 }
1178 
1180  LLDB_INSTRUMENT_VA(this);
1181 
1182  if (m_opaque_sp)
1183  m_opaque_sp->DispatchInputEndOfFile();
1184 }
1185 
1187  LLDB_INSTRUMENT_VA(this, reader);
1188 }
1189 
1190 void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
1191  bool spawn_thread) {
1192  LLDB_INSTRUMENT_VA(this, auto_handle_events, spawn_thread);
1193 
1194  if (m_opaque_sp) {
1196  options.SetAutoHandleEvents(auto_handle_events);
1197  options.SetSpawnThread(spawn_thread);
1198  m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter(options);
1199  }
1200 }
1201 
1202 void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
1203  bool spawn_thread,
1205  int &num_errors, bool &quit_requested,
1206  bool &stopped_for_crash)
1207 
1208 {
1209  LLDB_INSTRUMENT_VA(this, auto_handle_events, spawn_thread, options,
1210  num_errors, quit_requested, stopped_for_crash);
1211 
1212  if (m_opaque_sp) {
1213  options.SetAutoHandleEvents(auto_handle_events);
1214  options.SetSpawnThread(spawn_thread);
1215  CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter();
1217  interp.RunCommandInterpreter(options.ref());
1218  num_errors = result.GetNumErrors();
1219  quit_requested =
1221  stopped_for_crash =
1223  }
1224 }
1225 
1227  const SBCommandInterpreterRunOptions &options) {
1228  LLDB_INSTRUMENT_VA(this, options);
1229 
1230  if (!m_opaque_sp)
1232 
1233  CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter();
1235  interp.RunCommandInterpreter(options.ref());
1236 
1237  return SBCommandInterpreterRunResult(result);
1238 }
1239 
1241  const char *repl_options) {
1242  LLDB_INSTRUMENT_VA(this, language, repl_options);
1243 
1244  SBError error;
1245  if (m_opaque_sp)
1246  error.ref() = m_opaque_sp->RunREPL(language, repl_options);
1247  else
1248  error.SetErrorString("invalid debugger");
1249  return error;
1250 }
1251 
1252 void SBDebugger::reset(const DebuggerSP &debugger_sp) {
1253  m_opaque_sp = debugger_sp;
1254 }
1255 
1256 Debugger *SBDebugger::get() const { return m_opaque_sp.get(); }
1257 
1259  assert(m_opaque_sp.get());
1260  return *m_opaque_sp;
1261 }
1262 
1263 const lldb::DebuggerSP &SBDebugger::get_sp() const { return m_opaque_sp; }
1264 
1266  LLDB_INSTRUMENT_VA(id);
1267 
1268  // No need to lock, the debugger list is thread safe
1269  SBDebugger sb_debugger;
1270  DebuggerSP debugger_sp = Debugger::FindDebuggerWithID(id);
1271  if (debugger_sp)
1272  sb_debugger.reset(debugger_sp);
1273  return sb_debugger;
1274 }
1275 
1277  LLDB_INSTRUMENT_VA(this);
1278 
1279  return (m_opaque_sp ? m_opaque_sp->GetInstanceName().AsCString() : nullptr);
1280 }
1281 
1282 SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value,
1283  const char *debugger_instance_name) {
1284  LLDB_INSTRUMENT_VA(var_name, value, debugger_instance_name);
1285 
1286  SBError sb_error;
1287  DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName(
1288  ConstString(debugger_instance_name)));
1289  Status error;
1290  if (debugger_sp) {
1291  ExecutionContext exe_ctx(
1292  debugger_sp->GetCommandInterpreter().GetExecutionContext());
1293  error = debugger_sp->SetPropertyValue(&exe_ctx, eVarSetOperationAssign,
1294  var_name, value);
1295  } else {
1296  error.SetErrorStringWithFormat("invalid debugger instance name '%s'",
1297  debugger_instance_name);
1298  }
1299  if (error.Fail())
1300  sb_error.SetError(error);
1301  return sb_error;
1302 }
1303 
1306  const char *debugger_instance_name) {
1307  LLDB_INSTRUMENT_VA(var_name, debugger_instance_name);
1308 
1309  DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName(
1310  ConstString(debugger_instance_name)));
1311  Status error;
1312  if (debugger_sp) {
1313  ExecutionContext exe_ctx(
1314  debugger_sp->GetCommandInterpreter().GetExecutionContext());
1315  lldb::OptionValueSP value_sp(
1316  debugger_sp->GetPropertyValue(&exe_ctx, var_name, false, error));
1317  if (value_sp) {
1318  StreamString value_strm;
1319  value_sp->DumpValue(&exe_ctx, value_strm, OptionValue::eDumpOptionValue);
1320  const std::string &value_str = std::string(value_strm.GetString());
1321  if (!value_str.empty()) {
1322  StringList string_list;
1323  string_list.SplitIntoLines(value_str);
1324  return SBStringList(&string_list);
1325  }
1326  }
1327  }
1328  return SBStringList();
1329 }
1330 
1332  LLDB_INSTRUMENT_VA(this);
1333 
1334  return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0);
1335 }
1336 
1338  LLDB_INSTRUMENT_VA(this, term_width);
1339 
1340  if (m_opaque_sp)
1341  m_opaque_sp->SetTerminalWidth(term_width);
1342 }
1343 
1344 const char *SBDebugger::GetPrompt() const {
1345  LLDB_INSTRUMENT_VA(this);
1346 
1347  Log *log = GetLog(LLDBLog::API);
1348 
1349  LLDB_LOGF(log, "SBDebugger(%p)::GetPrompt () => \"%s\"",
1350  static_cast<void *>(m_opaque_sp.get()),
1351  (m_opaque_sp ? m_opaque_sp->GetPrompt().str().c_str() : ""));
1352 
1353  return (m_opaque_sp ? ConstString(m_opaque_sp->GetPrompt()).GetCString()
1354  : nullptr);
1355 }
1356 
1357 void SBDebugger::SetPrompt(const char *prompt) {
1358  LLDB_INSTRUMENT_VA(this, prompt);
1359 
1360  if (m_opaque_sp)
1361  m_opaque_sp->SetPrompt(llvm::StringRef(prompt));
1362 }
1363 
1364 const char *SBDebugger::GetReproducerPath() const {
1365  LLDB_INSTRUMENT_VA(this);
1366 
1367  return (m_opaque_sp
1368  ? ConstString(m_opaque_sp->GetReproducerPath()).GetCString()
1369  : nullptr);
1370 }
1371 
1373  LLDB_INSTRUMENT_VA(this);
1374 
1375  return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone);
1376 }
1377 
1379  LLDB_INSTRUMENT_VA(this, script_lang);
1380 
1381  if (m_opaque_sp) {
1382  m_opaque_sp->SetScriptLanguage(script_lang);
1383  }
1384 }
1385 
1387  LLDB_INSTRUMENT_VA(this);
1388 
1389  return (m_opaque_sp ? m_opaque_sp->GetREPLLanguage() : eLanguageTypeUnknown);
1390 }
1391 
1393  LLDB_INSTRUMENT_VA(this, repl_lang);
1394 
1395  if (m_opaque_sp) {
1396  m_opaque_sp->SetREPLLanguage(repl_lang);
1397  }
1398 }
1399 
1401  LLDB_INSTRUMENT_VA(this, value);
1402 
1403  return (m_opaque_sp ? m_opaque_sp->SetUseExternalEditor(value) : false);
1404 }
1405 
1407  LLDB_INSTRUMENT_VA(this);
1408 
1409  return (m_opaque_sp ? m_opaque_sp->GetUseExternalEditor() : false);
1410 }
1411 
1412 bool SBDebugger::SetUseColor(bool value) {
1413  LLDB_INSTRUMENT_VA(this, value);
1414 
1415  return (m_opaque_sp ? m_opaque_sp->SetUseColor(value) : false);
1416 }
1417 
1419  LLDB_INSTRUMENT_VA(this);
1420 
1421  return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false);
1422 }
1423 
1425  LLDB_INSTRUMENT_VA(this, value);
1426 
1427  return (m_opaque_sp ? m_opaque_sp->SetUseSourceCache(value) : false);
1428 }
1429 
1431  LLDB_INSTRUMENT_VA(this);
1432 
1433  return (m_opaque_sp ? m_opaque_sp->GetUseSourceCache() : false);
1434 }
1435 
1437  LLDB_INSTRUMENT_VA(this, description);
1438 
1439  Stream &strm = description.ref();
1440 
1441  if (m_opaque_sp) {
1442  const char *name = m_opaque_sp->GetInstanceName().AsCString();
1443  user_id_t id = m_opaque_sp->GetID();
1444  strm.Printf("Debugger (instance: \"%s\", id: %" PRIu64 ")", name, id);
1445  } else
1446  strm.PutCString("No value");
1447 
1448  return true;
1449 }
1450 
1452  LLDB_INSTRUMENT_VA(this);
1453 
1454  return (m_opaque_sp ? m_opaque_sp->GetID() : LLDB_INVALID_UID);
1455 }
1456 
1457 SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) {
1458  LLDB_INSTRUMENT_VA(this, platform_name_cstr);
1459 
1460  SBError sb_error;
1461  if (m_opaque_sp) {
1462  if (platform_name_cstr && platform_name_cstr[0]) {
1463  PlatformList &platforms = m_opaque_sp->GetPlatformList();
1464  if (PlatformSP platform_sp = platforms.GetOrCreate(platform_name_cstr))
1465  platforms.SetSelectedPlatform(platform_sp);
1466  else
1467  sb_error.ref().SetErrorString("platform not found");
1468  } else {
1469  sb_error.ref().SetErrorString("invalid platform name");
1470  }
1471  } else {
1472  sb_error.ref().SetErrorString("invalid debugger");
1473  }
1474  return sb_error;
1475 }
1476 
1477 bool SBDebugger::SetCurrentPlatformSDKRoot(const char *sysroot) {
1478  LLDB_INSTRUMENT_VA(this, sysroot);
1479 
1480  if (SBPlatform platform = GetSelectedPlatform()) {
1481  platform.SetSDKRoot(sysroot);
1482  return true;
1483  }
1484  return false;
1485 }
1486 
1488  LLDB_INSTRUMENT_VA(this);
1489 
1490  return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false);
1491 }
1492 
1494  LLDB_INSTRUMENT_VA(this, b);
1495 
1496  if (m_opaque_sp)
1497  m_opaque_sp->SetCloseInputOnEOF(b);
1498 }
1499 
1500 SBTypeCategory SBDebugger::GetCategory(const char *category_name) {
1501  LLDB_INSTRUMENT_VA(this, category_name);
1502 
1503  if (!category_name || *category_name == 0)
1504  return SBTypeCategory();
1505 
1506  TypeCategoryImplSP category_sp;
1507 
1509  category_sp, false)) {
1510  return SBTypeCategory(category_sp);
1511  } else {
1512  return SBTypeCategory();
1513  }
1514 }
1515 
1517  LLDB_INSTRUMENT_VA(this, lang_type);
1518 
1519  TypeCategoryImplSP category_sp;
1520  if (DataVisualization::Categories::GetCategory(lang_type, category_sp)) {
1521  return SBTypeCategory(category_sp);
1522  } else {
1523  return SBTypeCategory();
1524  }
1525 }
1526 
1527 SBTypeCategory SBDebugger::CreateCategory(const char *category_name) {
1528  LLDB_INSTRUMENT_VA(this, category_name);
1529 
1530  if (!category_name || *category_name == 0)
1531  return SBTypeCategory();
1532 
1533  TypeCategoryImplSP category_sp;
1534 
1536  category_sp, true)) {
1537  return SBTypeCategory(category_sp);
1538  } else {
1539  return SBTypeCategory();
1540  }
1541 }
1542 
1543 bool SBDebugger::DeleteCategory(const char *category_name) {
1544  LLDB_INSTRUMENT_VA(this, category_name);
1545 
1546  if (!category_name || *category_name == 0)
1547  return false;
1548 
1549  return DataVisualization::Categories::Delete(ConstString(category_name));
1550 }
1551 
1553  LLDB_INSTRUMENT_VA(this);
1554 
1556 }
1557 
1559  LLDB_INSTRUMENT_VA(this, index);
1560 
1561  return SBTypeCategory(
1563 }
1564 
1566  LLDB_INSTRUMENT_VA(this);
1567 
1568  return GetCategory("default");
1569 }
1570 
1572  LLDB_INSTRUMENT_VA(this, type_name);
1573 
1574  SBTypeCategory default_category_sb = GetDefaultCategory();
1575  if (default_category_sb.GetEnabled())
1576  return default_category_sb.GetFormatForType(type_name);
1577  return SBTypeFormat();
1578 }
1579 
1581  LLDB_INSTRUMENT_VA(this, type_name);
1582 
1583  if (!type_name.IsValid())
1584  return SBTypeSummary();
1586 }
1587 
1589  LLDB_INSTRUMENT_VA(this, type_name);
1590 
1591  if (!type_name.IsValid())
1592  return SBTypeFilter();
1594 }
1595 
1597  LLDB_INSTRUMENT_VA(this, type_name);
1598 
1599  if (!type_name.IsValid())
1600  return SBTypeSynthetic();
1601  return SBTypeSynthetic(
1603 }
1604 
1605 static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) {
1606  if (categories == nullptr)
1607  return {};
1608  size_t len = 0;
1609  while (categories[len] != nullptr)
1610  ++len;
1611  return llvm::makeArrayRef(categories, len);
1612 }
1613 
1614 bool SBDebugger::EnableLog(const char *channel, const char **categories) {
1615  LLDB_INSTRUMENT_VA(this, channel, categories);
1616 
1617  if (m_opaque_sp) {
1618  uint32_t log_options =
1621  llvm::raw_string_ostream error_stream(error);
1622  return m_opaque_sp->EnableLog(channel, GetCategoryArray(categories), "",
1623  log_options, error_stream);
1624  } else
1625  return false;
1626 }
1627 
1629  void *baton) {
1630  LLDB_INSTRUMENT_VA(this, log_callback, baton);
1631 
1632  if (m_opaque_sp) {
1633  return m_opaque_sp->SetLoggingCallback(log_callback, baton);
1634  }
1635 }
lldb::SBCommandInterpreterRunOptions::SetSpawnThread
void SetSpawnThread(bool)
Definition: SBCommandInterpreterRunOptions.cpp:161
lldb::SBStringList
Definition: SBStringList.h:16
Instrumentation.h
SBTypeSynthetic.h
lldb::SBDebugger::StateAsCString
static const char * StateAsCString(lldb::StateType state)
Definition: SBDebugger.cpp:695
lldb::SBDebugger::HandleCommand
void HandleCommand(const char *command)
Definition: SBDebugger.cpp:516
LLDB_LOG_OPTION_PREPEND_THREAD_NAME
#define LLDB_LOG_OPTION_PREPEND_THREAD_NAME
Definition: Log.h:40
SBCommandInterpreterRunOptions.h
lldb::SBDebugger::ref
lldb_private::Debugger & ref() const
Definition: SBDebugger.cpp:1258
lldb::SBDebugger::GetProgressFromEvent
static const char * GetProgressFromEvent(const lldb::SBEvent &event, uint64_t &progress_id, uint64_t &completed, uint64_t &total, bool &is_debugger_specific)
Get progress data from a SBEvent whose type is eBroadcastBitProgress.
Definition: SBDebugger.cpp:152
SystemLifetimeManager.h
lldb::SBDebugger::GetOutputFile
SBFile GetOutputFile()
Definition: SBDebugger.cpp:464
lldb::SBCommandInterpreterRunResult
Definition: SBCommandInterpreterRunOptions.h:85
lldb::SBDebugger::GetOutputFileHandle
FILE * GetOutputFileHandle()
Definition: SBDebugger.cpp:455
lldb::SBDebugger::GetNumCategories
uint32_t GetNumCategories()
Definition: SBDebugger.cpp:1552
lldb::SBDebugger::SetInputFile
SBError SetInputFile(SBFile file)
Definition: SBDebugger.cpp:371
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb::SBEvent::get
lldb_private::Event * get() const
Definition: SBEvent.cpp:133
lldb::SBDebugger::SetInputFileHandle
void SetInputFileHandle(FILE *f, bool transfer_ownership)
Definition: SBDebugger.cpp:338
lldb::SBTypeNameSpecifier
Definition: SBTypeNameSpecifier.h:17
lldb::SBCommandReturnObject::PutOutput
size_t PutOutput(FILE *fh)
Definition: SBCommandReturnObject.cpp:111
lldb::SBDebugger::DispatchInputEndOfFile
void DispatchInputEndOfFile()
Definition: SBDebugger.cpp:1179
lldb::SBCommandInterpreter::SourceInitFileInHomeDirectory
void SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &result)
Definition: SBCommandInterpreter.cpp:442
lldb::SBStream::ref
lldb_private::Stream & ref()
Definition: SBStream.cpp:176
lldb_private::DataVisualization::Categories::GetCount
static uint32_t GetCount()
Definition: DataVisualization.cpp:161
lldb::SBDebugger::RunCommandInterpreter
void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread)
Run the command interpreter.
Definition: SBDebugger.cpp:1190
lldb::ScriptLanguage
ScriptLanguage
Script interpreter types.
Definition: lldb-enumerations.h:216
lldb_private::StructuredData::Dictionary
Definition: StructuredData.h:352
lldb::SBProcess::GetStateFromEvent
static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event)
Definition: SBProcess.cpp:713
lldb::SBDebugger::GetDummyTarget
lldb::SBTarget GetDummyTarget()
Definition: SBDebugger.cpp:901
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb::SBDebugger::GetBroadcasterClass
static const char * GetBroadcasterClass()
Definition: SBDebugger.cpp:146
lldb::SBFile::m_opaque_sp
FileSP m_opaque_sp
Definition: SBFile.h:45
lldb::SBDebugger::StateIsStoppedState
static bool StateIsStoppedState(lldb::StateType state)
Definition: SBDebugger.cpp:761
lldb::SBTypeFilter
Definition: SBTypeFilter.h:17
lldb::SBCommandInterpreter::get
lldb_private::CommandInterpreter * get()
Definition: SBCommandInterpreter.cpp:414
lldb::SBDebugger::GetInputFile
SBFile GetInputFile()
Definition: SBDebugger.cpp:447
lldb::SBDebugger::GetSourceManager
lldb::SBSourceManager GetSourceManager()
Definition: SBDebugger.cpp:624
lldb::SBDebugger::GetIndexOfTarget
uint32_t GetIndexOfTarget(lldb::SBTarget target)
Definition: SBDebugger.cpp:948
SBTypeSummary.h
lldb::SBDebugger::SkipLLDBInitFiles
void SkipLLDBInitFiles(bool b)
Definition: SBDebugger.cpp:324
lldb_private::CommandInterpreter::SkipAppInitFiles
void SkipAppInitFiles(bool skip_app_init_files)
Definition: CommandInterpreter.h:477
lldb::SBDebugger::SetCurrentPlatform
lldb::SBError SetCurrentPlatform(const char *platform_name)
Definition: SBDebugger.cpp:1457
lldb::SBDebugger::GetUseExternalEditor
bool GetUseExternalEditor()
Definition: SBDebugger.cpp:1406
lldb_private::DiagnosticEventData::IsDebuggerSpecific
bool IsDebuggerSpecific() const
Definition: DebuggerEvents.h:63
lldb::SBError::GetCString
const char * GetCString() const
Definition: SBError.cpp:38
lldb::SBDebugger::Clear
void Clear()
Definition: SBDebugger.cpp:226
lldb::SBDebugger::GetTerminalWidth
uint32_t GetTerminalWidth() const
Definition: SBDebugger.cpp:1331
lldb::SBDebugger::GetErrorFileHandle
FILE * GetErrorFileHandle()
Definition: SBDebugger.cpp:473
lldb::SBError
class LLDB_API SBError
Definition: SBDefines.h:52
lldb::SBDebugger::GetUseColor
bool GetUseColor() const
Definition: SBDebugger.cpp:1418
lldb::SBCommandReturnObject
Definition: SBCommandReturnObject.h:24
lldb::LogOutputCallback
void(* LogOutputCallback)(const char *, void *baton)
Definition: lldb-types.h:70
lldb_private::DataVisualization::Categories::GetCategory
static bool GetCategory(ConstString category, lldb::TypeCategoryImplSP &entry, bool allow_create=true)
Definition: DataVisualization.cpp:76
lldb::SBError
Definition: SBError.h:20
lldb_private::Process::eBroadcastBitSTDOUT
@ eBroadcastBitSTDOUT
Definition: Process.h:356
lldb::SBDebugger::Create
static lldb::SBDebugger Create()
Definition: SBDebugger.cpp:235
lldb::SBDebugger::SetOutputFile
SBError SetOutputFile(SBFile file)
Definition: SBDebugger.cpp:398
lldb::SBProcess::IsValid
bool IsValid() const
Definition: SBProcess.cpp:112
lldb_private::CommandInterpreterRunOptions::SetSpawnThread
void SetSpawnThread(bool spawn_thread)
Definition: CommandInterpreter.h:179
lldb::SBTypeSynthetic
class LLDB_API SBTypeSynthetic
Definition: SBDefines.h:101
lldb::SBCommandInterpreter
Definition: SBCommandInterpreter.h:19
SBStringList.h
lldb::SBInputReader
Definition: SBDebugger.h:19
LLDB_INVALID_UID
#define LLDB_INVALID_UID
Definition: lldb-defines.h:80
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:270
lldb_private::CommandInterpreterRunResult
Definition: CommandInterpreter.h:34
lldb::SBDebugger::GetSelectedTarget
lldb::SBTarget GetSelectedTarget()
Definition: SBDebugger.cpp:1009
lldb::SBTypeCategory::GetEnabled
bool GetEnabled()
Definition: SBTypeCategory.cpp:52
lldb::SBDebugger::GetListener
lldb::SBListener GetListener()
Definition: SBDebugger.cpp:549
lldb::SBInputReader::Initialize
SBError Initialize(lldb::SBDebugger &sb_debugger, unsigned long(*callback)(void *, lldb::SBInputReader *, lldb::InputReaderAction, char const *, unsigned long), void *a, lldb::InputReaderGranularity b, char const *c, char const *d, bool e)
Definition: SBDebugger.cpp:104
lldb::SBTypeSummary
class LLDB_API SBTypeSummary
Definition: SBDefines.h:99
lldb_private::StateAsCString
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
Definition: State.cpp:14
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
lldb_private::GetVersion
const char * GetVersion()
Retrieves a string representing the complete LLDB version, which includes the lldb version number,...
Definition: Version.cpp:38
lldb::SBDebugger::GetInstanceName
const char * GetInstanceName()
Definition: SBDebugger.cpp:1276
lldb_private::StateIsRunningState
bool StateIsRunningState(lldb::StateType state)
Check if a state represents a state where the process or thread is running.
Definition: State.cpp:68
OptionArgParser.h
lldb::SBDebugger::MemoryPressureDetected
static void MemoryPressureDetected()
Definition: SBDebugger.cpp:288
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:193
lldb_private::OptionArgParser::ToScriptLanguage
static lldb::ScriptLanguage ToScriptLanguage(llvm::StringRef s, lldb::ScriptLanguage fail_value, bool *success_ptr)
Definition: OptionArgParser.cpp:123
lldb_private::Debugger::CreateInstance
static lldb::DebuggerSP CreateInstance(lldb::LogOutputCallback log_callback=nullptr, void *baton=nullptr)
Definition: Debugger.cpp:652
lldb_private::StringList::SplitIntoLines
size_t SplitIntoLines(const std::string &lines)
Definition: StringList.cpp:152
lldb::SBDebugger::SetErrorFile
SBError SetErrorFile(SBFile file)
Definition: SBDebugger.cpp:423
lldb::SBDebugger::DeleteTarget
bool DeleteTarget(lldb::SBTarget &target)
Definition: SBDebugger.cpp:915
lldb_private::FileSystem::Exists
bool Exists(const FileSpec &file_spec) const
Returns whether the given file exists.
Definition: common/FileSystem.cpp:150
lldb::SBDebugger::GetNumAvailablePlatforms
uint32_t GetNumAvailablePlatforms()
Get the number of available platforms.
Definition: SBDebugger.cpp:1105
lldb::SBEvent
Definition: SBEvent.h:21
LLDB_INSTRUMENT
#define LLDB_INSTRUMENT()
Definition: Instrumentation.h:95
lldb::SBProcess
Definition: SBProcess.h:23
lldb::SBDebugger::GetFilterForType
SBTypeFilter GetFilterForType(SBTypeNameSpecifier)
Definition: SBDebugger.cpp:1588
lldb_private::DiagnosticEventData::GetEventDataFromEvent
static const DiagnosticEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition: DebuggerEvents.cpp:79
lldb::SBProcess::ReportEventState
void ReportEventState(const lldb::SBEvent &event, FILE *out) const
Definition: SBProcess.cpp:305
lldb::SBListener::reset
void reset(lldb::ListenerSP listener_sp)
Definition: SBListener.cpp:292
lldb_private::Stream
Definition: Stream.h:28
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:455
lldb::SBDebugger::PrintStackTraceOnError
static void PrintStackTraceOnError()
Definition: SBDebugger.cpp:211
lldb::SBCommandInterpreterRunOptions::SetAutoHandleEvents
void SetAutoHandleEvents(bool)
Definition: SBCommandInterpreterRunOptions.cpp:148
lldb::SBPlatform::GetName
const char * GetName()
Definition: SBPlatform.cpp:337
lldb::SBProcess::GetSTDOUT
size_t GetSTDOUT(char *dst, size_t dst_len) const
Definition: SBProcess.cpp:260
lldb::SBStringList
class LLDB_API SBStringList
Definition: SBDefines.h:81
lldb::SBDebugger::GetDescription
bool GetDescription(lldb::SBStream &description)
Definition: SBDebugger.cpp:1436
lldb::SBCommandInterpreter::HandleCommand
lldb::ReturnStatus HandleCommand(const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history=false)
Definition: SBCommandInterpreter.cpp:146
lldb_private::DataVisualization::Categories::Delete
static bool Delete(ConstString category)
Definition: DataVisualization.cpp:95
Debugger.h
lldb_private::CommandInterpreterRunOptions
Definition: CommandInterpreter.h:59
lldb::SBTypeSummary
Definition: SBTypeSummary.h:55
SBListener.h
lldb::SBDebugger::SetPrompt
void SetPrompt(const char *prompt)
Definition: SBDebugger.cpp:1357
lldb_private::Process::eBroadcastBitSTDERR
@ eBroadcastBitSTDERR
Definition: Process.h:357
SBSourceManager.h
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::CommandInterpreter::RunCommandInterpreter
CommandInterpreterRunResult RunCommandInterpreter(CommandInterpreterRunOptions &options)
lldb::SBStructuredData::m_impl_up
StructuredDataImplUP m_impl_up
Definition: SBStructuredData.h:104
lldb_private::OptionGroupPlatform
Definition: OptionGroupPlatform.h:21
lldb::SBDebugger::SetAsync
void SetAsync(bool b)
Definition: SBDebugger.cpp:311
lldb::SBDebugger::CreateCategory
SBTypeCategory CreateCategory(const char *category_name)
Definition: SBDebugger.cpp:1527
lldb::SBDebugger::GetDefaultCategory
SBTypeCategory GetDefaultCategory()
Definition: SBDebugger.cpp:1565
Process.h
lldb_private::LLDBLog::API
@ API
lldb::eScriptLanguageNone
@ eScriptLanguageNone
Definition: lldb-enumerations.h:217
lldb::SBDebugger::GetVersionString
static const char * GetVersionString()
Definition: SBDebugger.cpp:689
lldb::SBDebugger::CreateTargetWithFileAndTargetTriple
lldb::SBTarget CreateTargetWithFileAndTargetTriple(const char *filename, const char *target_triple)
Definition: SBDebugger.cpp:808
lldb::SBDebugger::SetSelectedTarget
void SetSelectedTarget(SBTarget &target)
Definition: SBDebugger.cpp:1033
lldb::SBDebugger::SetErrorFileHandle
void SetErrorFileHandle(FILE *f, bool transfer_ownership)
Definition: SBDebugger.cpp:413
lldb::SBDebugger::SetUseColor
bool SetUseColor(bool use_color)
Definition: SBDebugger.cpp:1412
lldb_private::OptionGroupPlatform::SetPlatformName
void SetPlatformName(const char *platform_name)
Definition: OptionGroupPlatform.h:43
lldb::SBTarget
Definition: SBTarget.h:29
lldb_private::DiagnosticEventData::GetPrefix
llvm::StringRef GetPrefix() const
Definition: DebuggerEvents.cpp:49
lldb::SBDebugger::SetScriptLanguage
void SetScriptLanguage(lldb::ScriptLanguage script_lang)
Definition: SBDebugger.cpp:1378
lldb::SBDebugger::GetCategory
SBTypeCategory GetCategory(const char *category_name)
Definition: SBDebugger.cpp:1500
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::Platform::GetHostPlatform
static lldb::PlatformSP GetHostPlatform()
Get the native host platform plug-in.
Definition: Platform.cpp:136
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
SystemInitializerFull.h
lldb::SBError::Success
bool Success() const
Definition: SBError.cpp:64
SBStream.h
lldb_private::Debugger::GetStaticBroadcasterClass
static ConstString GetStaticBroadcasterClass()
Definition: Debugger.cpp:735
TargetList.h
lldb_private::DataVisualization::GetSyntheticForType
static lldb::ScriptedSyntheticChildrenSP GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp)
Definition: DataVisualization.cpp:64
lldb::SBFile
Definition: SBFile.h:16
lldb::SBError::Clear
void Clear()
Definition: SBError.cpp:46
lldb::SBDebugger::IsValid
bool IsValid() const
Definition: SBDebugger.cpp:301
lldb::SBDebugger::GetAvailablePlatformInfoAtIndex
lldb::SBStructuredData GetAvailablePlatformInfoAtIndex(uint32_t idx)
Get the name and description of one of the available platforms.
Definition: SBDebugger.cpp:1119
lldb::InputReaderAction
InputReaderAction
Definition: lldb-enumerations.h:385
lldb_private::StateIsStoppedState
bool StateIsStoppedState(lldb::StateType state, bool must_exist)
Check if a state represents a state where the process or thread is stopped.
Definition: State.cpp:89
AddLLVMTargets
static void AddLLVMTargets(StructuredData::Dictionary &dict)
Definition: SBDebugger.cpp:710
lldb::SBCommandInterpreterRunOptions::ref
lldb_private::CommandInterpreterRunOptions & ref() const
Definition: SBCommandInterpreterRunOptions.cpp:173
lldb::SBDebugger::InitializeWithErrorHandling
static lldb::SBError InitializeWithErrorHandling()
Definition: SBDebugger.cpp:200
lldb::SBDebugger
Definition: SBDebugger.h:34
Version.h
SBThread.h
Args.h
lldb::SBDebugger::GetCloseInputOnEOF
bool GetCloseInputOnEOF() const
Definition: SBDebugger.cpp:1487
lldb::SBDebugger::SetInternalVariable
static lldb::SBError SetInternalVariable(const char *var_name, const char *value, const char *debugger_instance_name)
Definition: SBDebugger.cpp:1282
lldb::SBDebugger::GetInputFileHandle
FILE * GetInputFileHandle()
Definition: SBDebugger.cpp:438
lldb_private::eLoadDependentsNo
@ eLoadDependentsNo
Definition: Target.h:65
lldb::SBDebugger::SetSelectedPlatform
void SetSelectedPlatform(lldb::SBPlatform &platform)
Definition: SBDebugger.cpp:1068
lldb::SBPlatform::GetSP
lldb::PlatformSP GetSP() const
Definition: SBPlatform.cpp:346
lldb::SBCommandReturnObject::PutError
size_t PutError(FILE *fh)
Definition: SBCommandReturnObject.cpp:135
lldb::SBProcess::GetSTDERR
size_t GetSTDERR(char *dst, size_t dst_len) const
Definition: SBProcess.cpp:273
lldb::SBDebugger::GetREPLLanguage
lldb::LanguageType GetREPLLanguage() const
Definition: SBDebugger.cpp:1386
SBFrame.h
Progress.h
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition: StructuredData.h:59
lldb_private::ProgressEventData::GetID
uint64_t GetID() const
Definition: DebuggerEvents.h:34
lldb_private::ProgressEventData
Definition: DebuggerEvents.h:20
lldb::SBDebugger::GetNumPlatforms
uint32_t GetNumPlatforms()
Get the number of currently active platforms.
Definition: SBDebugger.cpp:1084
lldb::SBDebugger::GetSyntheticForType
SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier)
Definition: SBDebugger.cpp:1596
lldb::SBTypeFormat
Definition: SBTypeFormat.h:17
lldb_private::ProgressEventData::GetEventDataFromEvent
static const ProgressEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition: DebuggerEvents.cpp:45
lldb::SBDebugger::GetReproducerPath
const char * GetReproducerPath() const
Definition: SBDebugger.cpp:1364
lldb_private::StringList
Definition: StringList.h:26
SBBroadcaster.h
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::XMLDocument::XMLEnabled
static bool XMLEnabled()
Definition: XML.cpp:81
lldb::SBDebugger::GetScriptLanguage
lldb::ScriptLanguage GetScriptLanguage() const
Definition: SBDebugger.cpp:1372
lldb_private::StreamString
Definition: StreamString.h:23
lldb::SBError::SetErrorString
void SetErrorString(const char *err_str)
Definition: SBError.cpp:121
lldb::SBDebugger::GetPrompt
const char * GetPrompt() const
Definition: SBDebugger.cpp:1344
lldb::SBDebugger::SetTerminalWidth
void SetTerminalWidth(uint32_t term_width)
Definition: SBDebugger.cpp:1337
lldb::SBDebugger::RestoreInputTerminalState
void RestoreInputTerminalState()
Definition: SBDebugger.cpp:500
lldb::SBDebugger::GetErrorFile
SBFile GetErrorFile()
Definition: SBDebugger.cpp:483
lldb::SBFile
class LLDB_API SBFile
Definition: SBDefines.h:57
lldb::SBDebugger::StateIsRunningState
static bool StateIsRunningState(lldb::StateType state)
Definition: SBDebugger.cpp:753
AddBoolConfigEntry
static void AddBoolConfigEntry(StructuredData::Dictionary &dict, llvm::StringRef name, bool value, llvm::StringRef description)
Definition: SBDebugger.cpp:701
OptionGroupPlatform.h
lldb::SBDebugger::RunREPL
SBError RunREPL(lldb::LanguageType language, const char *repl_options)
Definition: SBDebugger.cpp:1240
lldb_private::ModuleList::RemoveOrphanSharedModules
static size_t RemoveOrphanSharedModules(bool mandatory)
Definition: ModuleList.cpp:772
lldb::SBDebugger::PushInputReader
void PushInputReader(lldb::SBInputReader &reader)
Definition: SBDebugger.cpp:1186
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
SBDebugger.h
lldb_private::File
Definition: File.h:35
lldb::SBDebugger::FindTargetWithLLDBProcess
lldb::SBTarget FindTargetWithLLDBProcess(const lldb::ProcessSP &processSP)
Definition: SBDebugger.cpp:989
lldb_private::Debugger
Definition: Debugger.h:72
lldb::SBDebugger::EnableLog
bool EnableLog(const char *channel, const char **categories)
Definition: SBDebugger.cpp:1614
lldb_private::OptionValue::eDumpOptionValue
@ eDumpOptionValue
Definition: OptionValue.h:53
lldb::SBDebugger::GetID
lldb::user_id_t GetID()
Definition: SBDebugger.cpp:1451
lldb::SBDebugger::GetSummaryForType
SBTypeSummary GetSummaryForType(SBTypeNameSpecifier)
Definition: SBDebugger.cpp:1580
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb::SBDebugger::GetUseSourceCache
bool GetUseSourceCache() const
Definition: SBDebugger.cpp:1430
lldb_private::PlatformList
Definition: Platform.h:946
lldb::SBDebugger::reset
void reset(const lldb::DebuggerSP &debugger_sp)
Definition: SBDebugger.cpp:1252
lldb::SBTarget::Clear
void Clear()
Definition: SBTarget.cpp:1538
lldb::SBDebugger::GetPlatformAtIndex
lldb::SBPlatform GetPlatformAtIndex(uint32_t idx)
Get one of the currently active platforms.
Definition: SBDebugger.cpp:1094
lldb_private::ArchSpec::IsValid
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:353
lldb::SBDebugger::GetAsync
bool GetAsync()
Definition: SBDebugger.cpp:318
lldb_private::ProgressEventData::IsDebuggerSpecific
bool IsDebuggerSpecific() const
Definition: DebuggerEvents.h:39
lldb::SBError::SetError
void SetError(uint32_t err, lldb::ErrorType type)
Definition: SBError.cpp:95
lldb_private::CommandInterpreterRunResult::IsResult
bool IsResult(lldb::CommandInterpreterResult result)
Definition: CommandInterpreter.h:42
SBTypeNameSpecifier.h
lldb::SBDebugger::SaveInputTerminalState
void SaveInputTerminalState()
Definition: SBDebugger.cpp:493
lldb::SBDebugger::GetNumTargets
uint32_t GetNumTargets()
Definition: SBDebugger.cpp:999
lldb::SBTypeCategory::GetFormatForType
SBTypeFormat GetFormatForType(SBTypeNameSpecifier)
Definition: SBTypeCategory.cpp:205
lldb::SBDebugger::~SBDebugger
~SBDebugger()
lldb::SBDebugger::Destroy
static void Destroy(lldb::SBDebugger &debugger)
Definition: SBDebugger.cpp:279
lldb::SBDebugger::operator=
lldb::SBDebugger & operator=(const lldb::SBDebugger &rhs)
Definition: SBDebugger.cpp:137
lldb_private::StructuredData::Dictionary::AddItem
void AddItem(llvm::StringRef key, ObjectSP value_sp)
Definition: StructuredData.h:504
lldb::SBDebugger::GetTargetAtIndex
lldb::SBTarget GetTargetAtIndex(uint32_t idx)
Definition: SBDebugger.cpp:937
lldb::SBCommandInterpreter::SourceInitFileInGlobalDirectory
void SourceInitFileInGlobalDirectory(lldb::SBCommandReturnObject &result)
Definition: SBCommandInterpreter.cpp:426
LoadPlugin
static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, Status &error)
Definition: SBDebugger.cpp:66
lldb_private::DiagnosticEventData
Definition: DebuggerEvents.h:51
lldb::SBDebugger::GetDefaultArchitecture
static bool GetDefaultArchitecture(char *arch_name, size_t arch_name_len)
Definition: SBDebugger.cpp:631
lldb_private::StreamFile::GetFile
File & GetFile()
Definition: StreamFile.h:37
lldb_private::eLoadDependentsYes
@ eLoadDependentsYes
Definition: Target.h:64
LLDB_LOG_OPTION_PREPEND_TIMESTAMP
#define LLDB_LOG_OPTION_PREPEND_TIMESTAMP
Definition: Log.h:38
StreamFile.h
lldb::SBDebugger::FindTargetWithProcessID
lldb::SBTarget FindTargetWithProcessID(pid_t pid)
Definition: SBDebugger.cpp:961
lldb_private::DataVisualization::GetSummaryForType
static lldb::TypeSummaryImplSP GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp)
Definition: DataVisualization.cpp:48
SBFile.h
lldb::eScriptLanguageDefault
@ eScriptLanguageDefault
Definition: lldb-enumerations.h:221
lldb_private::Debugger::FindDebuggerWithInstanceName
static lldb::DebuggerSP FindDebuggerWithInstanceName(ConstString instance_name)
Definition: Debugger.cpp:692
lldb::SBDebugger::GetCategoryAtIndex
SBTypeCategory GetCategoryAtIndex(uint32_t)
Definition: SBDebugger.cpp:1558
lldb::SBInputReader::SetIsDone
void SetIsDone(bool)
Definition: SBDebugger.cpp:116
lldb::SBDebugger::SetCloseInputOnEOF
void SetCloseInputOnEOF(bool b)
Definition: SBDebugger.cpp:1493
lldb_private::PlatformList::SetSelectedPlatform
void SetSelectedPlatform(const lldb::PlatformSP &platform_sp)
Definition: Platform.h:988
lldb_private::Status
Definition: Status.h:44
GetCategoryArray
static llvm::ArrayRef< const char * > GetCategoryArray(const char **categories)
Definition: SBDebugger.cpp:1605
lldb::SBListener
Definition: SBListener.h:16
DataVisualization.h
lldb::SBDebugger::GetCommandInterpreter
lldb::SBCommandInterpreter GetCommandInterpreter()
Definition: SBDebugger.cpp:506
lldb_private::Target::GetDefaultArchitecture
static ArchSpec GetDefaultArchitecture()
Definition: Target.cpp:2436
lldb_private::ArchSpec::GetArchitectureName
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:539
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:437
lldb_private::DataVisualization::GetFilterForType
static lldb::TypeFilterImplSP GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp)
Definition: DataVisualization.cpp:59
uint32_t
lldb::SBDebugger::HandleProcessEvent
void HandleProcessEvent(const lldb::SBProcess &process, const lldb::SBEvent &event, FILE *out, FILE *err)
Definition: SBDebugger.cpp:567
DebuggerEvents.h
lldb::SBPlatform::SetSP
void SetSP(const lldb::PlatformSP &platform_sp)
Definition: SBPlatform.cpp:348
lldb::SBDebugger::GetSelectedPlatform
lldb::SBPlatform GetSelectedPlatform()
Definition: SBDebugger.cpp:1051
lldb::SBProcess::GetSP
lldb::ProcessSP GetSP() const
Definition: SBProcess.cpp:102
lldb::SBTypeCategory
class LLDB_API SBTypeCategory
Definition: SBDefines.h:92
lldb::SBDebugger::CreateTarget
lldb::SBTarget CreateTarget(const char *filename, const char *target_triple, const char *platform_name, bool add_dependent_modules, lldb::SBError &error)
Definition: SBDebugger.cpp:769
lldb::SBDebugger::SetInputString
SBError SetInputString(const char *data)
Definition: SBDebugger.cpp:345
lldb_private::Platform::GetAugmentedArchSpec
static ArchSpec GetAugmentedArchSpec(Platform *platform, llvm::StringRef triple)
Augments the triple either with information from platform or the host system (if platform is null).
Definition: Platform.cpp:264
lldb::SBTarget::m_opaque_sp
lldb::TargetSP m_opaque_sp
Definition: SBTarget.h:891
lldb::SBStructuredData
Definition: SBStructuredData.h:17
lldb::SBDebugger::FindTargetWithFileAndArch
lldb::SBTarget FindTargetWithFileAndArch(const char *filename, const char *arch)
Definition: SBDebugger.cpp:972
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
lldb_private::PluginManager::GetPlatformPluginDescriptionAtIndex
static llvm::StringRef GetPlatformPluginDescriptionAtIndex(uint32_t idx)
Definition: PluginManager.cpp:793
lldb::SBDebugger::SetDefaultArchitecture
static bool SetDefaultArchitecture(const char *arch_name)
Definition: SBDebugger.cpp:652
lldb::SBInputReader::IsActive
bool IsActive() const
Definition: SBDebugger.cpp:118
lldb_private::CommandInterpreterRunResult::GetNumErrors
uint32_t GetNumErrors() const
Definition: CommandInterpreter.h:38
lldb_private::Status::SetErrorString
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:241
lldb_private::Debugger::FindDebuggerWithID
static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id)
Definition: Debugger.cpp:1232
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:19
XML.h
lldb::SBTypeFormat
class LLDB_API SBTypeFormat
Definition: SBDefines.h:96
lldb::SBDebugger::GetBroadcaster
lldb::SBBroadcaster GetBroadcaster()
Definition: SBDebugger.cpp:189
lldb_private::ProgressEventData::GetCompleted
uint64_t GetCompleted() const
Definition: DebuggerEvents.h:36
lldb::SBDebugger::SetCurrentPlatformSDKRoot
bool SetCurrentPlatformSDKRoot(const char *sysroot)
Definition: SBDebugger.cpp:1477
lldb::SBDebugger::GetDiagnosticFromEvent
static lldb::SBStructuredData GetDiagnosticFromEvent(const lldb::SBEvent &event)
Definition: SBDebugger.cpp:170
lldb_private::ProgressEventData::GetMessage
const std::string & GetMessage() const
Definition: DebuggerEvents.h:38
lldb::SBDebugger::Terminate
static void Terminate()
Definition: SBDebugger.cpp:220
g_debugger_lifetime
static llvm::ManagedStatic< SystemLifetimeManager > g_debugger_lifetime
Definition: SBDebugger.cpp:102
PluginManager.h
lldb::SBTypeSynthetic
Definition: SBTypeSynthetic.h:17
SBTypeFilter.h
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
SBStructuredData.h
lldb::eCommandInterpreterResultInferiorCrash
@ eCommandInterpreterResultInferiorCrash
Stopped because the corresponding option was set and the inferior crashed.
Definition: lldb-enumerations.h:1128
lldb_private::ScriptInterpreter
Definition: ScriptInterpreter.h:126
StructuredDataImpl.h
SBEvent.h
lldb::SBDebugger::GetScriptInterpreterInfo
SBStructuredData GetScriptInterpreterInfo(ScriptLanguage)
Definition: SBDebugger.cpp:676
lldb_private::ScriptInterpreter::GetInterpreterInfo
virtual StructuredData::DictionarySP GetInterpreterInfo()
Definition: ScriptInterpreter.cpp:49
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb::SBDebugger::GetScriptingLanguage
lldb::ScriptLanguage GetScriptingLanguage(const char *script_language_name)
Definition: SBDebugger.cpp:666
lldb_private::FileSystem::Instance
static FileSystem & Instance()
Definition: common/FileSystem.cpp:46
lldb::SBTarget::SetSP
void SetSP(const lldb::TargetSP &target_sp)
Definition: SBTarget.cpp:578
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb::SBDebugger::SetREPLLanguage
void SetREPLLanguage(lldb::LanguageType repl_lang)
Definition: SBDebugger.cpp:1392
lldb::SBError::ref
lldb_private::Status & ref()
Definition: SBError.cpp:156
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
SBTypeFormat.h
lldb::SBCommandInterpreterRunResult
class LLDB_API SBCommandInterpreterRunResult
Definition: SBDefines.h:43
SBCommandReturnObject.h
lldb::SBDebugger::SetOutputFileHandle
void SetOutputFileHandle(FILE *f, bool transfer_ownership)
Definition: SBDebugger.cpp:393
lldb_private::CommandInterpreter::SkipLLDBInitFiles
void SkipLLDBInitFiles(bool skip_lldbinit_files)
Definition: CommandInterpreter.h:473
lldb::SBDebugger::SetUseExternalEditor
bool SetUseExternalEditor(bool input)
Definition: SBDebugger.cpp:1400
lldb_private::DataVisualization::Categories::GetCategoryAtIndex
static lldb::TypeCategoryImplSP GetCategoryAtIndex(size_t)
Definition: DataVisualization.cpp:166
lldb::eStateInvalid
@ eStateInvalid
Definition: lldb-enumerations.h:74
lldb::SBDebugger::DispatchInput
void DispatchInput(void *baton, const void *data, size_t data_len)
Definition: SBDebugger.cpp:1149
lldb::SBCommandInterpreter::reset
void reset(lldb_private::CommandInterpreter *)
Definition: SBCommandInterpreter.cpp:421
lldb::SBTarget::GetSP
lldb::TargetSP GetSP() const
Definition: SBTarget.cpp:576
LLDB_INSTRUMENT_VA
#define LLDB_INSTRUMENT_VA(...)
Definition: Instrumentation.h:98
CommandInterpreter.h
lldb::SBBroadcaster
Definition: SBBroadcaster.h:16
State.h
lldb_private::Process::eBroadcastBitStateChanged
@ eBroadcastBitStateChanged
Definition: Process.h:354
SBProcess.h
lldb::SBTypeNameSpecifier::IsValid
bool IsValid() const
Definition: SBTypeNameSpecifier.cpp:45
lldb_private::File::GetStream
virtual FILE * GetStream()
Get the underlying libc stream for this file, or NULL.
Definition: File.cpp:126
SBCommandInterpreter.h
lldb_private::StreamFile
Definition: StreamFile.h:22
lldb::SBCommandInterpreterRunOptions
Definition: SBCommandInterpreterRunOptions.h:23
lldb::SBTypeFilter
class LLDB_API SBTypeFilter
Definition: SBDefines.h:95
lldb_private::ProgressEventData::GetTotal
uint64_t GetTotal() const
Definition: DebuggerEvents.h:37
lldb::InputReaderGranularity
InputReaderGranularity
Token size/granularities for Input Readers.
Definition: lldb-enumerations.h:329
lldb::StateType
StateType
Process and Thread States.
Definition: lldb-enumerations.h:73
lldb::SBDebugger::SBDebugger
SBDebugger()
Definition: SBDebugger.cpp:124
lldb_private::Log
Definition: Log.h:48
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb_private::CommandInterpreterRunOptions::SetAutoHandleEvents
void SetAutoHandleEvents(bool auto_handle_events)
Definition: CommandInterpreter.h:173
lldb::SBDebugger::get_sp
const lldb::DebuggerSP & get_sp() const
Definition: SBDebugger.cpp:1263
lldb::SBDebugger::m_opaque_sp
lldb::DebuggerSP m_opaque_sp
Definition: SBDebugger.h:412
lldb::SBStream
Definition: SBStream.h:18
lldb_private::DiagnosticEventData::GetMessage
const std::string & GetMessage() const
Definition: DebuggerEvents.h:62
lldb_private::Target::SetDefaultArchitecture
static void SetDefaultArchitecture(const ArchSpec &arch)
Definition: Target.cpp:2440
lldb::SBTarget::GetDescription
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition: SBTarget.cpp:1675
lldb::SBDebugger::GetInternalVariableValue
static lldb::SBStringList GetInternalVariableValue(const char *var_name, const char *debugger_instance_name)
Definition: SBDebugger.cpp:1305
lldb::SBDebugger::FindDebuggerWithID
static SBDebugger FindDebuggerWithID(int id)
Definition: SBDebugger.cpp:1265
lldb::SBDebugger::SetLoggingCallback
void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton)
Definition: SBDebugger.cpp:1628
lldb_private::PluginManager::GetPlatformPluginNameAtIndex
static llvm::StringRef GetPlatformPluginNameAtIndex(uint32_t idx)
Definition: PluginManager.cpp:788
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:235
lldb_private::FileSpec::GetPath
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:347
SBTarget.h
lldb::SBDebugger::get
lldb_private::Debugger * get() const
Definition: SBDebugger.cpp:1256
lldb::SBDebugger::DispatchInputInterrupt
void DispatchInputInterrupt()
Definition: SBDebugger.cpp:1172
lldb::SBPlatform
Definition: SBPlatform.h:93
lldb_private::PlatformList::GetOrCreate
lldb::PlatformSP GetOrCreate(llvm::StringRef name)
Definition: Platform.cpp:1952
lldb::SBDebugger::GetFormatForType
SBTypeFormat GetFormatForType(SBTypeNameSpecifier)
Definition: SBDebugger.cpp:1571
lldb::SBTypeCategory
Definition: SBTypeCategory.h:17
lldb::SBDebugger::CreateTargetWithFileAndArch
lldb::SBTarget CreateTargetWithFileAndArch(const char *filename, const char *archname)
Definition: SBDebugger.cpp:833
lldb::SBDebugger::DeleteCategory
bool DeleteCategory(const char *category_name)
Definition: SBDebugger.cpp:1543
lldb
Definition: SBAddress.h:15
lldb::SBDebugger::Initialize
static void Initialize()
Definition: SBDebugger.cpp:195
lldb_private::Debugger::Destroy
static void Destroy(lldb::DebuggerSP &debugger_sp)
Definition: Debugger.cpp:663
lldb::SBProcess::GetTarget
lldb::SBTarget GetTarget() const
Definition: SBProcess.cpp:233
lldb::SBDebugger::SetUseSourceCache
bool SetUseSourceCache(bool use_source_cache)
Definition: SBDebugger.cpp:1424
lldb::SBTypeNameSpecifier::GetSP
lldb::TypeNameSpecifierImplSP GetSP()
Definition: SBTypeNameSpecifier.cpp:135
LLDBLog.h
lldb::SBDebugger::GetBuildConfiguration
static SBStructuredData GetBuildConfiguration()
Definition: SBDebugger.cpp:721
lldb::SBDebugger::SkipAppInitFiles
void SkipAppInitFiles(bool b)
Definition: SBDebugger.cpp:331
SBError.h
lldb::eDescriptionLevelBrief
@ eDescriptionLevelBrief
Definition: lldb-enumerations.h:208
lldb::SBStream::GetData
const char * GetData()
Definition: SBStream.cpp:44
SBTypeCategory.h
lldb::eCommandInterpreterResultQuitRequested
@ eCommandInterpreterResultQuitRequested
Stopped because quit was requested.
Definition: lldb-enumerations.h:1133
lldb_private::eVarSetOperationAssign
@ eVarSetOperationAssign
Definition: lldb-private-enumerations.h:90
lldb::SBSourceManager
Definition: SBSourceManager.h:18