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
13
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"
28#include "lldb/API/SBTarget.h"
29#include "lldb/API/SBThread.h"
30#include "lldb/API/SBTrace.h"
37
38#include "lldb/Core/Debugger.h"
41#include "lldb/Core/Progress.h"
44#include "lldb/Host/Config.h"
46#include "lldb/Host/XML.h"
51#include "lldb/Target/Process.h"
53#include "lldb/Utility/Args.h"
55#include "lldb/Utility/State.h"
57
58#include "llvm/ADT/STLExtras.h"
59#include "llvm/ADT/StringRef.h"
60#include "llvm/Config/llvm-config.h" // for LLVM_ENABLE_CURL
61#include "llvm/Support/DynamicLibrary.h"
62#include "llvm/Support/ManagedStatic.h"
63#include "llvm/Support/PrettyStackTrace.h"
64#include "llvm/Support/Signals.h"
65
66using namespace lldb;
67using namespace lldb_private;
68
69static llvm::ManagedStatic<SystemLifetimeManager> g_debugger_lifetime;
70
72 lldb::SBDebugger &sb_debugger,
73 unsigned long (*callback)(void *, lldb::SBInputReader *,
74 lldb::InputReaderAction, char const *,
75 unsigned long),
76 void *a, lldb::InputReaderGranularity b, char const *c, char const *d,
77 bool e) {
78 LLDB_INSTRUMENT_VA(this, sb_debugger, callback, a, b, c, d, e);
79
80 return SBError();
81}
82
84
87
88 return false;
89}
90
92
94 : m_opaque_sp(debugger_sp) {
95 LLDB_INSTRUMENT_VA(this, debugger_sp);
96}
97
101
102SBDebugger::~SBDebugger() = default;
103
105 LLDB_INSTRUMENT_VA(this, rhs);
106
107 if (this != &rhs) {
109 }
110 return *this;
111}
112
118
120 uint64_t &progress_id,
121 uint64_t &completed,
122 uint64_t &total,
123 bool &is_debugger_specific) {
124 LLDB_INSTRUMENT_VA(event);
125
126 const ProgressEventData *progress_data =
128 if (progress_data == nullptr)
129 return nullptr;
130 progress_id = progress_data->GetID();
131 completed = progress_data->GetCompleted();
132 total = progress_data->GetTotal();
133 is_debugger_specific = progress_data->IsDebuggerSpecific();
134 ConstString message(progress_data->GetMessage());
135 return message.AsCString();
136}
137
140 LLDB_INSTRUMENT_VA(event);
141
142 StructuredData::DictionarySP dictionary_sp =
144
145 if (!dictionary_sp)
146 return {};
147
149 data.m_impl_up->SetObjectSP(std::move(dictionary_sp));
150 return data;
151}
152
155 LLDB_INSTRUMENT_VA(event);
156
157 StructuredData::DictionarySP dictionary_sp =
159
160 if (!dictionary_sp)
161 return {};
162
164 data.m_impl_up->SetObjectSP(std::move(dictionary_sp));
165 return data;
166}
167
169 LLDB_INSTRUMENT_VA(this);
170 SBBroadcaster broadcaster(&m_opaque_sp->GetBroadcaster(), false);
171 return broadcaster;
172}
173
178
181
183 if (auto e = g_debugger_lifetime->Initialize(
184 std::make_unique<SystemInitializerFull>())) {
185 error.SetError(Status::FromError(std::move(e)));
186 }
187 return error;
188}
189
192
193 llvm::EnablePrettyStackTrace();
194 static std::string executable =
195 llvm::sys::fs::getMainExecutable(nullptr, nullptr);
196 llvm::sys::PrintStackTraceOnErrorSignal(executable);
197}
198
199static void DumpDiagnostics(void *cookie) {
200 Diagnostics::Instance().Dump(llvm::errs());
201}
202
205
206 llvm::sys::AddSignalHandler(&DumpDiagnostics, nullptr);
207}
208
211
212 g_debugger_lifetime->Terminate();
213}
214
216 LLDB_INSTRUMENT_VA(this);
217
218 if (m_opaque_sp)
219 m_opaque_sp->ClearIOHandlers();
220
221 m_opaque_sp.reset();
222}
223
226
227 return SBDebugger::Create(false, nullptr, nullptr);
228}
229
230SBDebugger SBDebugger::Create(bool source_init_files) {
231 LLDB_INSTRUMENT_VA(source_init_files);
232
233 return SBDebugger::Create(source_init_files, nullptr, nullptr);
234}
235
236SBDebugger SBDebugger::Create(bool source_init_files,
237 lldb::LogOutputCallback callback, void *baton)
238
239{
240 LLDB_INSTRUMENT_VA(source_init_files, callback, baton);
241
242 SBDebugger debugger;
243
244 // Currently we have issues if this function is called simultaneously on two
245 // different threads. The issues mainly revolve around the fact that the
246 // lldb_private::FormatManager uses global collections and having two threads
247 // parsing the .lldbinit files can cause mayhem. So to get around this for
248 // now we need to use a mutex to prevent bad things from happening.
249 static std::recursive_mutex g_mutex;
250 std::lock_guard<std::recursive_mutex> guard(g_mutex);
251
252 debugger.reset(Debugger::CreateInstance(callback, baton));
253
255 if (source_init_files) {
256 interp.get()->SkipLLDBInitFiles(false);
257 interp.get()->SkipAppInitFiles(false);
259 interp.SourceInitFileInGlobalDirectory(result);
260 interp.SourceInitFileInHomeDirectory(result, false);
261 } else {
262 interp.get()->SkipLLDBInitFiles(true);
263 interp.get()->SkipAppInitFiles(true);
264 }
265 return debugger;
266}
267
269 LLDB_INSTRUMENT_VA(debugger);
270
272
273 if (debugger.m_opaque_sp.get() != nullptr)
274 debugger.m_opaque_sp.reset();
275}
276
279
280 // Since this function can be call asynchronously, we allow it to be non-
281 // mandatory. We have seen deadlocks with this function when called so we
282 // need to safeguard against this until we can determine what is causing the
283 // deadlocks.
284
285 const bool mandatory = false;
286
288}
289
291 LLDB_INSTRUMENT_VA(this);
292 return this->operator bool();
293}
294SBDebugger::operator bool() const {
295 LLDB_INSTRUMENT_VA(this);
296
297 return m_opaque_sp.get() != nullptr;
298}
299
301 LLDB_INSTRUMENT_VA(this, b);
302
303 if (m_opaque_sp)
304 m_opaque_sp->SetAsyncExecution(b);
305}
306
308 LLDB_INSTRUMENT_VA(this);
309
310 return (m_opaque_sp ? m_opaque_sp->GetAsyncExecution() : false);
311}
312
314 LLDB_INSTRUMENT_VA(this, b);
315
316 if (m_opaque_sp)
317 m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles(b);
318}
319
321 LLDB_INSTRUMENT_VA(this, b);
322
323 if (m_opaque_sp)
324 m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles(b);
325}
326
327void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) {
328 LLDB_INSTRUMENT_VA(this, fh, transfer_ownership);
329 if (m_opaque_sp)
330 m_opaque_sp->SetInputFile(
331 (FileSP)std::make_shared<NativeFile>(fh, transfer_ownership));
332}
333
336 SBError sb_error;
337 if (data == nullptr) {
338 sb_error = Status::FromErrorString("String data is null");
339 return sb_error;
340 }
341
342 size_t size = strlen(data);
343 if (size == 0) {
344 sb_error = Status::FromErrorString("String data is empty");
345 return sb_error;
346 }
347
348 if (!m_opaque_sp) {
349 sb_error = Status::FromErrorString("invalid debugger");
350 return sb_error;
351 }
352
353 sb_error.SetError(m_opaque_sp->SetInputString(data));
354 return sb_error;
355}
356
357// Shouldn't really be settable after initialization as this could cause lots
358// of problems; don't want users trying to switch modes in the middle of a
359// debugging session.
361 LLDB_INSTRUMENT_VA(this, file);
362
364 if (!m_opaque_sp) {
365 error.ref() = Status::FromErrorString("invalid debugger");
366 return error;
367 }
368 if (!file) {
369 error.ref() = Status::FromErrorString("invalid file");
370 return error;
371 }
372 m_opaque_sp->SetInputFile(file.m_opaque_sp);
373 return error;
374}
375
377 LLDB_INSTRUMENT_VA(this, file_sp);
378 return SetInputFile(SBFile(file_sp));
379}
380
382 LLDB_INSTRUMENT_VA(this, file_sp);
383 return SetOutputFile(SBFile(file_sp));
384}
385
386void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) {
387 LLDB_INSTRUMENT_VA(this, fh, transfer_ownership);
388 SetOutputFile((FileSP)std::make_shared<NativeFile>(fh, transfer_ownership));
389}
390
392 LLDB_INSTRUMENT_VA(this, file);
394 if (!m_opaque_sp) {
395 error.ref() = Status::FromErrorString("invalid debugger");
396 return error;
397 }
398 if (!file) {
399 error.ref() = Status::FromErrorString("invalid file");
400 return error;
401 }
402 m_opaque_sp->SetOutputFile(file.m_opaque_sp);
403 return error;
404}
405
406void SBDebugger::SetErrorFileHandle(FILE *fh, bool transfer_ownership) {
407 LLDB_INSTRUMENT_VA(this, fh, transfer_ownership);
408 SetErrorFile((FileSP)std::make_shared<NativeFile>(fh, transfer_ownership));
409}
410
412 LLDB_INSTRUMENT_VA(this, file_sp);
413 return SetErrorFile(SBFile(file_sp));
414}
415
417 LLDB_INSTRUMENT_VA(this, file);
419 if (!m_opaque_sp) {
420 error.ref() = Status::FromErrorString("invalid debugger");
421 return error;
422 }
423 if (!file) {
424 error.ref() = Status::FromErrorString("invalid file");
425 return error;
426 }
427 m_opaque_sp->SetErrorFile(file.m_opaque_sp);
428 return error;
429}
430
432 LLDB_INSTRUMENT_VA(this, setting);
433
435 if (!m_opaque_sp)
436 return data;
437
438 StreamString json_strm;
439 ExecutionContext exe_ctx(
440 m_opaque_sp->GetCommandInterpreter().GetExecutionContext());
441 if (setting && strlen(setting) > 0)
442 m_opaque_sp->DumpPropertyValue(&exe_ctx, json_strm, setting,
443 /*dump_mask*/ 0,
444 /*is_json*/ true);
445 else
446 m_opaque_sp->DumpAllPropertyValues(&exe_ctx, json_strm, /*dump_mask*/ 0,
447 /*is_json*/ true);
448
449 data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_strm.GetString()));
450 return data;
451}
452
454 LLDB_INSTRUMENT_VA(this);
455 if (m_opaque_sp) {
456 File &file_sp = m_opaque_sp->GetInputFile();
457 return file_sp.GetStream();
458 }
459 return nullptr;
460}
461
463 LLDB_INSTRUMENT_VA(this);
464 if (m_opaque_sp) {
465 return SBFile(m_opaque_sp->GetInputFileSP());
466 }
467 return SBFile();
468}
469
471 LLDB_INSTRUMENT_VA(this);
472 if (m_opaque_sp)
473 return m_opaque_sp->GetOutputFileSP()->GetStream();
474 return nullptr;
475}
476
478 LLDB_INSTRUMENT_VA(this);
479 if (m_opaque_sp)
480 return SBFile(m_opaque_sp->GetOutputFileSP());
481 return SBFile();
482}
483
485 LLDB_INSTRUMENT_VA(this);
486
487 if (m_opaque_sp)
488 return m_opaque_sp->GetErrorFileSP()->GetStream();
489 return nullptr;
490}
491
493 LLDB_INSTRUMENT_VA(this);
494 SBFile file;
495 if (m_opaque_sp)
496 return SBFile(m_opaque_sp->GetErrorFileSP());
497 return SBFile();
498}
499
501 LLDB_INSTRUMENT_VA(this);
502
503 if (m_opaque_sp)
504 m_opaque_sp->SaveInputTerminalState();
505}
506
508 LLDB_INSTRUMENT_VA(this);
509
510 if (m_opaque_sp)
511 m_opaque_sp->RestoreInputTerminalState();
512}
514 LLDB_INSTRUMENT_VA(this);
515
516 SBCommandInterpreter sb_interpreter;
517 if (m_opaque_sp)
518 sb_interpreter.reset(&m_opaque_sp->GetCommandInterpreter());
519
520 return sb_interpreter;
521}
522
523void SBDebugger::HandleCommand(const char *command) {
524 LLDB_INSTRUMENT_VA(this, command);
525
526 if (m_opaque_sp) {
527 TargetSP target_sp(m_opaque_sp->GetSelectedTarget());
528 std::unique_lock<std::recursive_mutex> lock;
529 if (target_sp)
530 lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
531
534
535 sb_interpreter.HandleCommand(command, result, false);
536
537 result.PutError(m_opaque_sp->GetErrorFileSP());
538 result.PutOutput(m_opaque_sp->GetOutputFileSP());
539
540 if (!m_opaque_sp->GetAsyncExecution()) {
541 SBProcess process(GetCommandInterpreter().GetProcess());
542 ProcessSP process_sp(process.GetSP());
543 if (process_sp) {
544 EventSP event_sp;
545 ListenerSP lldb_listener_sp = m_opaque_sp->GetListener();
546 while (lldb_listener_sp->GetEventForBroadcaster(
547 process_sp.get(), event_sp, std::chrono::seconds(0))) {
548 SBEvent event(event_sp);
549 HandleProcessEvent(process, event, GetOutputFile(), GetErrorFile());
550 }
551 }
552 }
553 }
554}
555
557 LLDB_INSTRUMENT_VA(this);
558
559 SBListener sb_listener;
560 if (m_opaque_sp)
561 sb_listener.reset(m_opaque_sp->GetListener());
562
563 return sb_listener;
564}
565
566void SBDebugger::HandleProcessEvent(const SBProcess &process,
567 const SBEvent &event, SBFile out,
568 SBFile err) {
569 LLDB_INSTRUMENT_VA(this, process, event, out, err);
570
571 return HandleProcessEvent(process, event, out.m_opaque_sp, err.m_opaque_sp);
572}
573
574void SBDebugger::HandleProcessEvent(const SBProcess &process,
575 const SBEvent &event, FILE *out,
576 FILE *err) {
577 LLDB_INSTRUMENT_VA(this, process, event, out, err);
578
579 FileSP outfile = std::make_shared<NativeFile>(out, false);
580 FileSP errfile = std::make_shared<NativeFile>(err, false);
581 return HandleProcessEvent(process, event, outfile, errfile);
582}
583
584void SBDebugger::HandleProcessEvent(const SBProcess &process,
585 const SBEvent &event, FileSP out_sp,
586 FileSP err_sp) {
587
588 LLDB_INSTRUMENT_VA(this, process, event, out_sp, err_sp);
589
590 if (!process.IsValid())
591 return;
592
593 TargetSP target_sp(process.GetTarget().GetSP());
594 if (!target_sp)
595 return;
596
597 const uint32_t event_type = event.GetType();
598 char stdio_buffer[1024];
599 size_t len;
600
601 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
602
603 if (event_type &
605 // Drain stdout when we stop just in case we have any bytes
606 while ((len = process.GetSTDOUT(stdio_buffer, sizeof(stdio_buffer))) > 0)
607 if (out_sp)
608 out_sp->Write(stdio_buffer, len);
609 }
610
611 if (event_type &
613 // Drain stderr when we stop just in case we have any bytes
614 while ((len = process.GetSTDERR(stdio_buffer, sizeof(stdio_buffer))) > 0)
615 if (err_sp)
616 err_sp->Write(stdio_buffer, len);
617 }
618
619 if (event_type & Process::eBroadcastBitStateChanged) {
620 StateType event_state = SBProcess::GetStateFromEvent(event);
621
622 if (event_state == eStateInvalid)
623 return;
624
625 bool is_stopped = StateIsStoppedState(event_state);
626 if (!is_stopped)
627 process.ReportEventState(event, out_sp);
628 }
629}
630
632 LLDB_INSTRUMENT_VA(this);
633
634 SBSourceManager sb_source_manager(*this);
635 return sb_source_manager;
636}
637
638bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) {
639 LLDB_INSTRUMENT_VA(arch_name, arch_name_len);
640
641 if (arch_name && arch_name_len) {
643
644 if (default_arch.IsValid()) {
645 const std::string &triple_str = default_arch.GetTriple().str();
646 if (!triple_str.empty())
647 ::snprintf(arch_name, arch_name_len, "%s", triple_str.c_str());
648 else
649 ::snprintf(arch_name, arch_name_len, "%s",
650 default_arch.GetArchitectureName());
651 return true;
652 }
653 }
654 if (arch_name && arch_name_len)
655 arch_name[0] = '\0';
656 return false;
657}
658
659bool SBDebugger::SetDefaultArchitecture(const char *arch_name) {
660 LLDB_INSTRUMENT_VA(arch_name);
661
662 if (arch_name) {
663 ArchSpec arch(arch_name);
664 if (arch.IsValid()) {
666 return true;
667 }
668 }
669 return false;
670}
671
673SBDebugger::GetScriptingLanguage(const char *script_language_name) {
674 LLDB_INSTRUMENT_VA(this, script_language_name);
675
676 if (!script_language_name)
679 llvm::StringRef(script_language_name), eScriptLanguageDefault, nullptr);
680}
681
684 LLDB_INSTRUMENT_VA(this, language);
686 if (m_opaque_sp) {
688 m_opaque_sp->GetScriptInterpreter(language);
689 if (interp) {
690 data.m_impl_up->SetObjectSP(interp->GetInterpreterInfo());
691 }
692 }
693 return data;
694}
695
698
700}
701
703 LLDB_INSTRUMENT_VA(state);
704
705 return lldb_private::StateAsCString(state);
706}
707
709 llvm::StringRef name, bool value,
710 llvm::StringRef description) {
711 auto entry_up = std::make_unique<StructuredData::Dictionary>();
712 entry_up->AddBooleanItem("value", value);
713 entry_up->AddStringItem("description", description);
714 dict.AddItem(name, std::move(entry_up));
715}
716
718 auto array_up = std::make_unique<StructuredData::Array>();
719#define LLVM_TARGET(target) \
720 array_up->AddItem(std::make_unique<StructuredData::String>(#target));
721#include "llvm/Config/Targets.def"
722 auto entry_up = std::make_unique<StructuredData::Dictionary>();
723 entry_up->AddItem("value", std::move(array_up));
724 entry_up->AddStringItem("description", "A list of configured LLVM targets.");
725 dict.AddItem("targets", std::move(entry_up));
726}
727
730
731 auto config_up = std::make_unique<StructuredData::Dictionary>();
733 *config_up, "xml", XMLDocument::XMLEnabled(),
734 "A boolean value that indicates if XML support is enabled in LLDB");
736 *config_up, "curl", LLVM_ENABLE_CURL,
737 "A boolean value that indicates if CURL support is enabled in LLDB");
739 *config_up, "curses", LLDB_ENABLE_CURSES,
740 "A boolean value that indicates if curses support is enabled in LLDB");
742 *config_up, "editline", LLDB_ENABLE_LIBEDIT,
743 "A boolean value that indicates if editline support is enabled in LLDB");
744 AddBoolConfigEntry(*config_up, "editline_wchar", LLDB_EDITLINE_USE_WCHAR,
745 "A boolean value that indicates if editline wide "
746 "characters support is enabled in LLDB");
748 *config_up, "lzma", LLDB_ENABLE_LZMA,
749 "A boolean value that indicates if lzma support is enabled in LLDB");
751 *config_up, "python", LLDB_ENABLE_PYTHON,
752 "A boolean value that indicates if python support is enabled in LLDB");
754 *config_up, "lua", LLDB_ENABLE_LUA,
755 "A boolean value that indicates if lua support is enabled in LLDB");
756 AddBoolConfigEntry(*config_up, "fbsdvmcore", LLDB_ENABLE_FBSDVMCORE,
757 "A boolean value that indicates if fbsdvmcore support is "
758 "enabled in LLDB");
759 AddLLVMTargets(*config_up);
760
762 data.m_impl_up->SetObjectSP(std::move(config_up));
763 return data;
764}
765
767 LLDB_INSTRUMENT_VA(state);
768
769 const bool result = lldb_private::StateIsRunningState(state);
770
771 return result;
772}
773
775 LLDB_INSTRUMENT_VA(state);
776
777 const bool result = lldb_private::StateIsStoppedState(state, false);
778
779 return result;
780}
781
783 const char *target_triple,
784 const char *platform_name,
785 bool add_dependent_modules,
786 lldb::SBError &sb_error) {
787 LLDB_INSTRUMENT_VA(this, filename, target_triple, platform_name,
788 add_dependent_modules, sb_error);
789
790 SBTarget sb_target;
791 TargetSP target_sp;
792 if (m_opaque_sp) {
793 sb_error.Clear();
794 OptionGroupPlatform platform_options(false);
795 platform_options.SetPlatformName(platform_name);
796
797 sb_error.ref() = m_opaque_sp->GetTargetList().CreateTarget(
798 *m_opaque_sp, filename, target_triple,
799 add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo,
800 &platform_options, target_sp);
801
802 if (sb_error.Success())
803 sb_target.SetSP(target_sp);
804 } else {
805 sb_error = Status::FromErrorString("invalid debugger");
806 }
807
808 Log *log = GetLog(LLDBLog::API);
809 LLDB_LOGF(log,
810 "SBDebugger(%p)::CreateTarget (filename=\"%s\", triple=%s, "
811 "platform_name=%s, add_dependent_modules=%u, error=%s) => "
812 "SBTarget(%p)",
813 static_cast<void *>(m_opaque_sp.get()), filename, target_triple,
814 platform_name, add_dependent_modules, sb_error.GetCString(),
815 static_cast<void *>(target_sp.get()));
816
817 return sb_target;
818}
819
822 const char *target_triple) {
823 LLDB_INSTRUMENT_VA(this, filename, target_triple);
824
825 SBTarget sb_target;
826 TargetSP target_sp;
827 if (m_opaque_sp) {
828 const bool add_dependent_modules = true;
829 Status error(m_opaque_sp->GetTargetList().CreateTarget(
830 *m_opaque_sp, filename, target_triple,
831 add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr,
832 target_sp));
833 sb_target.SetSP(target_sp);
834 }
835
836 Log *log = GetLog(LLDBLog::API);
837 LLDB_LOGF(log,
838 "SBDebugger(%p)::CreateTargetWithFileAndTargetTriple "
839 "(filename=\"%s\", triple=%s) => SBTarget(%p)",
840 static_cast<void *>(m_opaque_sp.get()), filename, target_triple,
841 static_cast<void *>(target_sp.get()));
842
843 return sb_target;
844}
845
847 const char *arch_cstr) {
848 LLDB_INSTRUMENT_VA(this, filename, arch_cstr);
849
850 Log *log = GetLog(LLDBLog::API);
851
852 SBTarget sb_target;
853 TargetSP target_sp;
854 if (m_opaque_sp) {
856 if (arch_cstr == nullptr) {
857 // The version of CreateTarget that takes an ArchSpec won't accept an
858 // empty ArchSpec, so when the arch hasn't been specified, we need to
859 // call the target triple version.
860 error = m_opaque_sp->GetTargetList().CreateTarget(
861 *m_opaque_sp, filename, arch_cstr, eLoadDependentsYes, nullptr,
862 target_sp);
863 } else {
864 PlatformSP platform_sp =
865 m_opaque_sp->GetPlatformList().GetSelectedPlatform();
866 ArchSpec arch =
867 Platform::GetAugmentedArchSpec(platform_sp.get(), arch_cstr);
868 if (arch.IsValid())
869 error = m_opaque_sp->GetTargetList().CreateTarget(
870 *m_opaque_sp, filename, arch, eLoadDependentsYes, platform_sp,
871 target_sp);
872 else
873 error = Status::FromErrorStringWithFormat("invalid arch_cstr: %s",
874 arch_cstr);
875 }
876 if (error.Success())
877 sb_target.SetSP(target_sp);
878 }
879
880 LLDB_LOGF(log,
881 "SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", "
882 "arch=%s) => SBTarget(%p)",
883 static_cast<void *>(m_opaque_sp.get()),
884 filename ? filename : "<unspecified>",
885 arch_cstr ? arch_cstr : "<unspecified>",
886 static_cast<void *>(target_sp.get()));
887
888 return sb_target;
889}
890
891SBTarget SBDebugger::CreateTarget(const char *filename) {
892 LLDB_INSTRUMENT_VA(this, filename);
893
894 SBTarget sb_target;
895 TargetSP target_sp;
896 if (m_opaque_sp) {
898 const bool add_dependent_modules = true;
899 error = m_opaque_sp->GetTargetList().CreateTarget(
900 *m_opaque_sp, filename, "",
901 add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr,
902 target_sp);
903
904 if (error.Success())
905 sb_target.SetSP(target_sp);
906 }
907 Log *log = GetLog(LLDBLog::API);
908 LLDB_LOGF(log,
909 "SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)",
910 static_cast<void *>(m_opaque_sp.get()), filename,
911 static_cast<void *>(target_sp.get()));
912 return sb_target;
913}
914
916 LLDB_INSTRUMENT_VA(this);
917
918 SBTarget sb_target;
919 if (m_opaque_sp) {
920 sb_target.SetSP(m_opaque_sp->GetDummyTarget().shared_from_this());
921 }
922 Log *log = GetLog(LLDBLog::API);
923 LLDB_LOGF(log, "SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)",
924 static_cast<void *>(m_opaque_sp.get()),
925 static_cast<void *>(sb_target.GetSP().get()));
926 return sb_target;
927}
928
930 LLDB_INSTRUMENT_VA(this);
931 if (m_opaque_sp) {
932 m_opaque_sp->DispatchClientTelemetry(*entry.m_impl_up);
933 } else {
934 Log *log = GetLog(LLDBLog::API);
935 LLDB_LOGF(log,
936 "Could not send telemetry from SBDebugger - debugger was null.");
937 }
938}
939
941 LLDB_INSTRUMENT_VA(this, target);
942
943 bool result = false;
944 if (m_opaque_sp) {
945 TargetSP target_sp(target.GetSP());
946 if (target_sp) {
947 // No need to lock, the target list is thread safe
948 result = m_opaque_sp->GetTargetList().DeleteTarget(target_sp);
949 target_sp->Destroy();
950 target.Clear();
951 }
952 }
953
954 Log *log = GetLog(LLDBLog::API);
955 LLDB_LOGF(log, "SBDebugger(%p)::DeleteTarget (SBTarget(%p)) => %i",
956 static_cast<void *>(m_opaque_sp.get()),
957 static_cast<void *>(target.m_opaque_sp.get()), result);
958
959 return result;
960}
961
963 LLDB_INSTRUMENT_VA(this, idx);
964
965 SBTarget sb_target;
966 if (m_opaque_sp) {
967 // No need to lock, the target list is thread safe
968 sb_target.SetSP(m_opaque_sp->GetTargetList().GetTargetAtIndex(idx));
969 }
970 return sb_target;
971}
972
974 LLDB_INSTRUMENT_VA(this, target);
975
976 lldb::TargetSP target_sp = target.GetSP();
977 if (!target_sp)
978 return UINT32_MAX;
979
980 if (!m_opaque_sp)
981 return UINT32_MAX;
982
983 return m_opaque_sp->GetTargetList().GetIndexOfTarget(target.GetSP());
984}
985
987 LLDB_INSTRUMENT_VA(this, id);
988 SBTarget sb_target;
989 if (m_opaque_sp) {
990 // No need to lock, the target list is thread safe
991 sb_target.SetSP(
992 m_opaque_sp->GetTargetList().FindTargetByGloballyUniqueID(id));
993 }
994 return sb_target;
995}
996
998 LLDB_INSTRUMENT_VA(this, pid);
999
1000 SBTarget sb_target;
1001 if (m_opaque_sp) {
1002 // No need to lock, the target list is thread safe
1003 sb_target.SetSP(m_opaque_sp->GetTargetList().FindTargetWithProcessID(pid));
1004 }
1005 return sb_target;
1006}
1007
1009 const char *arch_name) {
1010 LLDB_INSTRUMENT_VA(this, filename, arch_name);
1011
1012 SBTarget sb_target;
1013 if (m_opaque_sp && filename && filename[0]) {
1014 // No need to lock, the target list is thread safe
1016 m_opaque_sp->GetPlatformList().GetSelectedPlatform().get(), arch_name);
1017 TargetSP target_sp(
1018 m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture(
1019 FileSpec(filename), arch_name ? &arch : nullptr));
1020 sb_target.SetSP(target_sp);
1021 }
1022 return sb_target;
1023}
1024
1026 SBTarget sb_target;
1027 if (m_opaque_sp) {
1028 // No need to lock, the target list is thread safe
1029 sb_target.SetSP(
1030 m_opaque_sp->GetTargetList().FindTargetWithProcess(process_sp.get()));
1031 }
1032 return sb_target;
1033}
1034
1036 LLDB_INSTRUMENT_VA(this);
1037
1038 if (m_opaque_sp) {
1039 // No need to lock, the target list is thread safe
1040 return m_opaque_sp->GetTargetList().GetNumTargets();
1041 }
1042 return 0;
1043}
1044
1046 LLDB_INSTRUMENT_VA(this);
1047
1048 Log *log = GetLog(LLDBLog::API);
1049
1050 SBTarget sb_target;
1051 TargetSP target_sp;
1052 if (m_opaque_sp) {
1053 // No need to lock, the target list is thread safe
1054 target_sp = m_opaque_sp->GetTargetList().GetSelectedTarget();
1055 sb_target.SetSP(target_sp);
1056 }
1057
1058 if (log) {
1059 SBStream sstr;
1060 sb_target.GetDescription(sstr, eDescriptionLevelBrief);
1061 LLDB_LOGF(log, "SBDebugger(%p)::GetSelectedTarget () => SBTarget(%p): %s",
1062 static_cast<void *>(m_opaque_sp.get()),
1063 static_cast<void *>(target_sp.get()), sstr.GetData());
1064 }
1065
1066 return sb_target;
1067}
1068
1070 LLDB_INSTRUMENT_VA(this, sb_target);
1071
1072 Log *log = GetLog(LLDBLog::API);
1073
1074 TargetSP target_sp(sb_target.GetSP());
1075 if (m_opaque_sp) {
1076 m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp);
1077 }
1078 if (log) {
1079 SBStream sstr;
1080 sb_target.GetDescription(sstr, eDescriptionLevelBrief);
1081 LLDB_LOGF(log, "SBDebugger(%p)::SetSelectedTarget () => SBTarget(%p): %s",
1082 static_cast<void *>(m_opaque_sp.get()),
1083 static_cast<void *>(target_sp.get()), sstr.GetData());
1084 }
1085}
1086
1088 LLDB_INSTRUMENT_VA(this);
1089
1090 Log *log = GetLog(LLDBLog::API);
1091
1092 SBPlatform sb_platform;
1093 DebuggerSP debugger_sp(m_opaque_sp);
1094 if (debugger_sp) {
1095 sb_platform.SetSP(debugger_sp->GetPlatformList().GetSelectedPlatform());
1096 }
1097 LLDB_LOGF(log, "SBDebugger(%p)::GetSelectedPlatform () => SBPlatform(%p): %s",
1098 static_cast<void *>(m_opaque_sp.get()),
1099 static_cast<void *>(sb_platform.GetSP().get()),
1100 sb_platform.GetName());
1101 return sb_platform;
1102}
1103
1105 LLDB_INSTRUMENT_VA(this, sb_platform);
1106
1107 Log *log = GetLog(LLDBLog::API);
1108
1109 DebuggerSP debugger_sp(m_opaque_sp);
1110 if (debugger_sp) {
1111 debugger_sp->GetPlatformList().SetSelectedPlatform(sb_platform.GetSP());
1112 }
1113
1114 LLDB_LOGF(log, "SBDebugger(%p)::SetSelectedPlatform (SBPlatform(%p) %s)",
1115 static_cast<void *>(m_opaque_sp.get()),
1116 static_cast<void *>(sb_platform.GetSP().get()),
1117 sb_platform.GetName());
1118}
1119
1121 LLDB_INSTRUMENT_VA(this);
1122
1123 if (m_opaque_sp) {
1124 // No need to lock, the platform list is thread safe
1125 return m_opaque_sp->GetPlatformList().GetSize();
1126 }
1127 return 0;
1128}
1129
1131 LLDB_INSTRUMENT_VA(this, idx);
1132
1133 SBPlatform sb_platform;
1134 if (m_opaque_sp) {
1135 // No need to lock, the platform list is thread safe
1136 sb_platform.SetSP(m_opaque_sp->GetPlatformList().GetAtIndex(idx));
1137 }
1138 return sb_platform;
1139}
1140
1142 LLDB_INSTRUMENT_VA(this);
1143
1144 uint32_t idx = 0;
1145 while (true) {
1147 break;
1148 }
1149 ++idx;
1150 }
1151 // +1 for the host platform, which should always appear first in the list.
1152 return idx + 1;
1153}
1154
1156 LLDB_INSTRUMENT_VA(this, idx);
1157
1159 auto platform_dict = std::make_unique<StructuredData::Dictionary>();
1160 llvm::StringRef name_str("name"), desc_str("description");
1161
1162 if (idx == 0) {
1163 PlatformSP host_platform_sp(Platform::GetHostPlatform());
1164 platform_dict->AddStringItem(name_str, host_platform_sp->GetPluginName());
1165 platform_dict->AddStringItem(
1166 desc_str, llvm::StringRef(host_platform_sp->GetDescription()));
1167 } else if (idx > 0) {
1168 llvm::StringRef plugin_name =
1170 if (plugin_name.empty()) {
1171 return data;
1172 }
1173 platform_dict->AddStringItem(name_str, llvm::StringRef(plugin_name));
1174
1175 llvm::StringRef plugin_desc =
1177 platform_dict->AddStringItem(desc_str, llvm::StringRef(plugin_desc));
1178 }
1179
1180 data.m_impl_up->SetObjectSP(
1181 StructuredData::ObjectSP(platform_dict.release()));
1182 return data;
1183}
1184
1185void SBDebugger::DispatchInput(void *baton, const void *data, size_t data_len) {
1186 LLDB_INSTRUMENT_VA(this, baton, data, data_len);
1187
1189}
1190
1191void SBDebugger::DispatchInput(const void *data, size_t data_len) {
1193
1194 // Log *log(GetLog (LLDBLog::API));
1195 //
1196 // if (log)
1197 // LLDB_LOGF(log, "SBDebugger(%p)::DispatchInput (data=\"%.*s\",
1198 // size_t=%" PRIu64 ")",
1199 // m_opaque_sp.get(),
1200 // (int) data_len,
1201 // (const char *) data,
1202 // (uint64_t)data_len);
1203 //
1204 // if (m_opaque_sp)
1205 // m_opaque_sp->DispatchInput ((const char *) data, data_len);
1206}
1207
1209 LLDB_INSTRUMENT_VA(this);
1210
1211 if (m_opaque_sp)
1212 m_opaque_sp->DispatchInputInterrupt();
1213}
1214
1216 LLDB_INSTRUMENT_VA(this);
1217
1218 if (m_opaque_sp)
1219 m_opaque_sp->DispatchInputEndOfFile();
1220}
1221
1223 LLDB_INSTRUMENT_VA(this, reader);
1224}
1225
1226void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
1227 bool spawn_thread) {
1228 LLDB_INSTRUMENT_VA(this, auto_handle_events, spawn_thread);
1229
1230 if (m_opaque_sp) {
1232 options.SetAutoHandleEvents(auto_handle_events);
1233 options.SetSpawnThread(spawn_thread);
1234 m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter(options);
1235 }
1236}
1237
1238void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
1239 bool spawn_thread,
1241 int &num_errors, bool &quit_requested,
1242 bool &stopped_for_crash)
1243
1244{
1245 LLDB_INSTRUMENT_VA(this, auto_handle_events, spawn_thread, options,
1246 num_errors, quit_requested, stopped_for_crash);
1247
1248 if (m_opaque_sp) {
1249 options.SetAutoHandleEvents(auto_handle_events);
1250 options.SetSpawnThread(spawn_thread);
1251 CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter();
1253 interp.RunCommandInterpreter(options.ref());
1254 num_errors = result.GetNumErrors();
1255 quit_requested =
1257 stopped_for_crash =
1259 }
1260}
1261
1263 const SBCommandInterpreterRunOptions &options) {
1264 LLDB_INSTRUMENT_VA(this, options);
1265
1266 if (!m_opaque_sp)
1268
1269 CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter();
1271 interp.RunCommandInterpreter(options.ref());
1272
1273 return SBCommandInterpreterRunResult(result);
1274}
1275
1277 const char *repl_options) {
1278 LLDB_INSTRUMENT_VA(this, language, repl_options);
1279
1280 SBError error;
1281 if (m_opaque_sp)
1282 error.ref() = m_opaque_sp->RunREPL(language, repl_options);
1283 else
1284 error = Status::FromErrorString("invalid debugger");
1285 return error;
1286}
1287
1288void SBDebugger::reset(const DebuggerSP &debugger_sp) {
1289 m_opaque_sp = debugger_sp;
1290}
1291
1292Debugger *SBDebugger::get() const { return m_opaque_sp.get(); }
1293
1295 assert(m_opaque_sp.get());
1296 return *m_opaque_sp;
1297}
1298
1300
1303
1304 // No need to lock, the debugger list is thread safe
1305 SBDebugger sb_debugger;
1306 DebuggerSP debugger_sp = Debugger::FindDebuggerWithID(id);
1307 if (debugger_sp)
1308 sb_debugger.reset(debugger_sp);
1309 return sb_debugger;
1310}
1311
1313 LLDB_INSTRUMENT_VA(this);
1314
1315 if (!m_opaque_sp)
1316 return nullptr;
1317
1318 return ConstString(m_opaque_sp->GetInstanceName()).AsCString();
1319}
1320
1321SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value,
1322 const char *debugger_instance_name) {
1323 LLDB_INSTRUMENT_VA(var_name, value, debugger_instance_name);
1324
1325 SBError sb_error;
1326 DebuggerSP debugger_sp(
1327 Debugger::FindDebuggerWithInstanceName(debugger_instance_name));
1328 Status error;
1329 if (debugger_sp) {
1330 ExecutionContext exe_ctx(
1331 debugger_sp->GetCommandInterpreter().GetExecutionContext());
1332 error = debugger_sp->SetPropertyValue(&exe_ctx, eVarSetOperationAssign,
1333 var_name, value);
1334 } else {
1336 "invalid debugger instance name '%s'", debugger_instance_name);
1337 }
1338 if (error.Fail())
1339 sb_error.SetError(std::move(error));
1340 return sb_error;
1341}
1342
1345 const char *debugger_instance_name) {
1346 LLDB_INSTRUMENT_VA(var_name, debugger_instance_name);
1347
1348 DebuggerSP debugger_sp(
1349 Debugger::FindDebuggerWithInstanceName(debugger_instance_name));
1350 Status error;
1351 if (debugger_sp) {
1352 ExecutionContext exe_ctx(
1353 debugger_sp->GetCommandInterpreter().GetExecutionContext());
1354 lldb::OptionValueSP value_sp(
1355 debugger_sp->GetPropertyValue(&exe_ctx, var_name, error));
1356 if (value_sp) {
1357 StreamString value_strm;
1358 value_sp->DumpValue(&exe_ctx, value_strm, OptionValue::eDumpOptionValue);
1359 const std::string &value_str = std::string(value_strm.GetString());
1360 if (!value_str.empty()) {
1361 StringList string_list;
1362 string_list.SplitIntoLines(value_str);
1363 return SBStringList(&string_list);
1364 }
1365 }
1366 }
1367 return SBStringList();
1368}
1369
1371 LLDB_INSTRUMENT_VA(this);
1372
1373 return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0);
1374}
1375
1376void SBDebugger::SetTerminalWidth(uint32_t term_width) {
1377 LLDB_INSTRUMENT_VA(this, term_width);
1378
1379 if (m_opaque_sp)
1380 m_opaque_sp->SetTerminalWidth(term_width);
1381}
1382
1384 LLDB_INSTRUMENT_VA(this);
1385
1386 return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0);
1387}
1388
1389void SBDebugger::SetTerminalHeight(uint32_t term_height) {
1390 LLDB_INSTRUMENT_VA(this, term_height);
1391
1392 if (m_opaque_sp)
1393 m_opaque_sp->SetTerminalHeight(term_height);
1394}
1395
1396const char *SBDebugger::GetPrompt() const {
1397 LLDB_INSTRUMENT_VA(this);
1398
1399 Log *log = GetLog(LLDBLog::API);
1400
1401 LLDB_LOG(log, "SBDebugger({0:x})::GetPrompt () => \"{1}\"",
1402 static_cast<void *>(m_opaque_sp.get()),
1403 (m_opaque_sp ? m_opaque_sp->GetPrompt() : ""));
1404
1405 return (m_opaque_sp ? ConstString(m_opaque_sp->GetPrompt()).GetCString()
1406 : nullptr);
1407}
1408
1409void SBDebugger::SetPrompt(const char *prompt) {
1410 LLDB_INSTRUMENT_VA(this, prompt);
1411
1412 if (m_opaque_sp)
1413 m_opaque_sp->SetPrompt(llvm::StringRef(prompt));
1414}
1415
1417 LLDB_INSTRUMENT_VA(this);
1418
1419 return "GetReproducerPath has been deprecated";
1420}
1421
1423 LLDB_INSTRUMENT_VA(this);
1424
1425 return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone);
1426}
1427
1429 LLDB_INSTRUMENT_VA(this, script_lang);
1430
1431 if (m_opaque_sp) {
1432 m_opaque_sp->SetScriptLanguage(script_lang);
1433 }
1434}
1435
1437 LLDB_INSTRUMENT_VA(this);
1438
1439 return (m_opaque_sp ? m_opaque_sp->GetREPLLanguage() : eLanguageTypeUnknown);
1440}
1441
1443 LLDB_INSTRUMENT_VA(this, repl_lang);
1444
1445 if (m_opaque_sp) {
1446 m_opaque_sp->SetREPLLanguage(repl_lang);
1447 }
1448}
1449
1451 LLDB_INSTRUMENT_VA(this, value);
1452
1453 return (m_opaque_sp ? m_opaque_sp->SetUseExternalEditor(value) : false);
1454}
1455
1457 LLDB_INSTRUMENT_VA(this);
1458
1459 return (m_opaque_sp ? m_opaque_sp->GetUseExternalEditor() : false);
1460}
1461
1462bool SBDebugger::SetUseColor(bool value) {
1463 LLDB_INSTRUMENT_VA(this, value);
1464
1465 return (m_opaque_sp ? m_opaque_sp->SetUseColor(value) : false);
1466}
1467
1469 LLDB_INSTRUMENT_VA(this);
1470
1471 return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false);
1472}
1473
1475 LLDB_INSTRUMENT_VA(this, value);
1476
1477 return (m_opaque_sp ? m_opaque_sp->SetShowInlineDiagnostics(value) : false);
1478}
1479
1481 LLDB_INSTRUMENT_VA(this, value);
1482
1483 return (m_opaque_sp ? m_opaque_sp->SetUseSourceCache(value) : false);
1484}
1485
1487 LLDB_INSTRUMENT_VA(this);
1488
1489 return (m_opaque_sp ? m_opaque_sp->GetUseSourceCache() : false);
1490}
1491
1493 LLDB_INSTRUMENT_VA(this, description);
1494
1495 Stream &strm = description.ref();
1496
1497 if (m_opaque_sp) {
1498 const char *name = m_opaque_sp->GetInstanceName().c_str();
1499 user_id_t id = m_opaque_sp->GetID();
1500 strm.Printf("Debugger (instance: \"%s\", id: %" PRIu64 ")", name, id);
1501 } else
1502 strm.PutCString("No value");
1503
1504 return true;
1505}
1506
1508 LLDB_INSTRUMENT_VA(this);
1509
1510 return (m_opaque_sp ? m_opaque_sp->GetID() : LLDB_INVALID_UID);
1511}
1512
1513SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) {
1514 LLDB_INSTRUMENT_VA(this, platform_name_cstr);
1515
1516 SBError sb_error;
1517 if (m_opaque_sp) {
1518 if (platform_name_cstr && platform_name_cstr[0]) {
1519 PlatformList &platforms = m_opaque_sp->GetPlatformList();
1520 if (PlatformSP platform_sp = platforms.GetOrCreate(platform_name_cstr))
1521 platforms.SetSelectedPlatform(platform_sp);
1522 else
1523 sb_error.ref() = Status::FromErrorString("platform not found");
1524 } else {
1525 sb_error.ref() = Status::FromErrorString("invalid platform name");
1526 }
1527 } else {
1528 sb_error.ref() = Status::FromErrorString("invalid debugger");
1529 }
1530 return sb_error;
1531}
1532
1533bool SBDebugger::SetCurrentPlatformSDKRoot(const char *sysroot) {
1534 LLDB_INSTRUMENT_VA(this, sysroot);
1535
1536 if (SBPlatform platform = GetSelectedPlatform()) {
1537 platform.SetSDKRoot(sysroot);
1538 return true;
1539 }
1540 return false;
1541}
1542
1544 LLDB_INSTRUMENT_VA(this);
1545
1546 return false;
1547}
1548
1550 LLDB_INSTRUMENT_VA(this, b);
1551}
1552
1553SBTypeCategory SBDebugger::GetCategory(const char *category_name) {
1554 LLDB_INSTRUMENT_VA(this, category_name);
1555
1556 if (!category_name || *category_name == 0)
1557 return SBTypeCategory();
1558
1559 TypeCategoryImplSP category_sp;
1560
1562 category_sp, false)) {
1563 return SBTypeCategory(category_sp);
1564 } else {
1565 return SBTypeCategory();
1566 }
1567}
1568
1570 LLDB_INSTRUMENT_VA(this, lang_type);
1571
1572 TypeCategoryImplSP category_sp;
1573 if (DataVisualization::Categories::GetCategory(lang_type, category_sp)) {
1574 return SBTypeCategory(category_sp);
1575 } else {
1576 return SBTypeCategory();
1577 }
1578}
1579
1580SBTypeCategory SBDebugger::CreateCategory(const char *category_name) {
1581 LLDB_INSTRUMENT_VA(this, category_name);
1582
1583 if (!category_name || *category_name == 0)
1584 return SBTypeCategory();
1585
1586 TypeCategoryImplSP category_sp;
1587
1589 category_sp, true)) {
1590 return SBTypeCategory(category_sp);
1591 } else {
1592 return SBTypeCategory();
1593 }
1594}
1595
1596bool SBDebugger::DeleteCategory(const char *category_name) {
1597 LLDB_INSTRUMENT_VA(this, category_name);
1598
1599 if (!category_name || *category_name == 0)
1600 return false;
1601
1603}
1604
1610
1617
1619 LLDB_INSTRUMENT_VA(this);
1620
1621 return GetCategory("default");
1622}
1623
1625 LLDB_INSTRUMENT_VA(this, type_name);
1626
1627 SBTypeCategory default_category_sb = GetDefaultCategory();
1628 if (default_category_sb.GetEnabled())
1629 return default_category_sb.GetFormatForType(type_name);
1630 return SBTypeFormat();
1631}
1632
1634 LLDB_INSTRUMENT_VA(this, type_name);
1635
1636 if (!type_name.IsValid())
1637 return SBTypeSummary();
1639}
1640
1642 LLDB_INSTRUMENT_VA(this, type_name);
1643
1644 if (!type_name.IsValid())
1645 return SBTypeFilter();
1647}
1648
1650 LLDB_INSTRUMENT_VA(this, type_name);
1651
1652 if (!type_name.IsValid())
1653 return SBTypeSynthetic();
1654 return SBTypeSynthetic(
1656}
1657
1663
1664static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) {
1665 if (categories == nullptr)
1666 return {};
1667 size_t len = 0;
1668 while (categories[len] != nullptr)
1669 ++len;
1670 return llvm::ArrayRef(categories, len);
1671}
1672
1673bool SBDebugger::EnableLog(const char *channel, const char **categories) {
1674 LLDB_INSTRUMENT_VA(this, channel, categories);
1675
1676 if (m_opaque_sp) {
1677 uint32_t log_options =
1679 std::string error;
1680 llvm::raw_string_ostream error_stream(error);
1681 return m_opaque_sp->EnableLog(channel, GetCategoryArray(categories), "",
1682 log_options, /*buffer_size=*/0,
1683 eLogHandlerStream, error_stream);
1684 } else
1685 return false;
1686}
1687
1689 void *baton) {
1690 LLDB_INSTRUMENT_VA(this, log_callback, baton);
1691
1692 if (m_opaque_sp) {
1693 return m_opaque_sp->SetLoggingCallback(log_callback, baton);
1694 }
1695}
1696
1697void SBDebugger::SetDestroyCallback(
1698 lldb::SBDebuggerDestroyCallback destroy_callback, void *baton) {
1699 LLDB_INSTRUMENT_VA(this, destroy_callback, baton);
1700 if (m_opaque_sp) {
1701 return m_opaque_sp->SetDestroyCallback(
1702 destroy_callback, baton);
1703 }
1704}
1705
1708 void *baton) {
1709 LLDB_INSTRUMENT_VA(this, destroy_callback, baton);
1710
1711 if (m_opaque_sp)
1712 return m_opaque_sp->AddDestroyCallback(destroy_callback, baton);
1713
1715}
1716
1718 LLDB_INSTRUMENT_VA(this, token);
1719
1720 if (m_opaque_sp)
1721 return m_opaque_sp->RemoveDestroyCallback(token);
1722
1723 return false;
1724}
1725
1726SBTrace
1728 const SBFileSpec &trace_description_file) {
1729 LLDB_INSTRUMENT_VA(this, error, trace_description_file);
1730 return SBTrace::LoadTraceFromFile(error, *this, trace_description_file);
1731}
1732
1734 LLDB_INSTRUMENT_VA(this);
1735
1736 if (m_opaque_sp)
1737 m_opaque_sp->RequestInterrupt();
1738}
1740 LLDB_INSTRUMENT_VA(this);
1741
1742 if (m_opaque_sp)
1743 m_opaque_sp->CancelInterruptRequest();
1744}
1745
1747 LLDB_INSTRUMENT_VA(this);
1748
1749 if (m_opaque_sp)
1750 return m_opaque_sp->InterruptRequested();
1751 return false;
1752}
1753
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT()
#define LLDB_INSTRUMENT_VA(...)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:369
#define LLDB_LOGF(log,...)
Definition Log.h:376
#define LLDB_LOG_OPTION_PREPEND_TIMESTAMP
Definition Log.h:38
#define LLDB_LOG_OPTION_PREPEND_THREAD_NAME
Definition Log.h:40
static llvm::ArrayRef< const char * > GetCategoryArray(const char **categories)
static void DumpDiagnostics(void *cookie)
static void AddBoolConfigEntry(StructuredData::Dictionary &dict, llvm::StringRef name, bool value, llvm::StringRef description)
static void AddLLVMTargets(StructuredData::Dictionary &dict)
static llvm::ManagedStatic< SystemLifetimeManager > g_debugger_lifetime
lldb_private::CommandInterpreterRunOptions & ref() const
void reset(lldb_private::CommandInterpreter *)
void SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &result)
lldb_private::CommandInterpreter * get()
void SourceInitFileInGlobalDirectory(lldb::SBCommandReturnObject &result)
lldb::ReturnStatus HandleCommand(const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history=false)
static lldb::SBError SetInternalVariable(const char *var_name, const char *value, const char *debugger_instance_name)
Set an internal variable.
bool DeleteCategory(const char *category_name)
Delete a type category.
lldb::LanguageType GetREPLLanguage() const
Get the current REPL language.
lldb::SBTarget GetTargetAtIndex(uint32_t idx)
Get a target by index.
lldb::SBTarget CreateTarget(const char *filename, const char *target_triple, const char *platform_name, bool add_dependent_modules, lldb::SBError &error)
Create a target with the specified parameters.
SBTypeFilter GetFilterForType(SBTypeNameSpecifier type_name_spec)
Get the filter for a type.
SBError RunREPL(lldb::LanguageType language, const char *repl_options)
Run a REPL (Read-Eval-Print Loop) for the specified language.
bool DeleteTarget(lldb::SBTarget &target)
Delete a target from the debugger.
void SkipAppInitFiles(bool b)
Set whether to skip loading application-specific .lldbinit files.
lldb::SBDebugger & operator=(const lldb::SBDebugger &rhs)
Assignment operator.
static void Terminate()
Terminate LLDB and its subsystems.
lldb::SBPlatform GetPlatformAtIndex(uint32_t idx)
Get one of the currently active platforms.
void SkipLLDBInitFiles(bool b)
Set whether to skip loading .lldbinit files.
void SetAsync(bool b)
Set whether the debugger should run in asynchronous mode.
const void * data
Definition SBDebugger.h:478
bool SetUseExternalEditor(bool input)
Set whether to use an external editor.
bool GetCloseInputOnEOF() const
Get whether to close input on EOF (deprecated).
static bool GetDefaultArchitecture(char *arch_name, size_t arch_name_len)
Get the default architecture.
static void MemoryPressureDetected()
Notify the debugger that system memory pressure has been detected.
void SetPrompt(const char *prompt)
Set the command prompt string.
bool GetDescription(lldb::SBStream &description)
Get a description of this debugger.
void DispatchInput(const void *data, size_t data_len)
Dispatch input to the debugger.
friend class SBStructuredData
Definition SBDebugger.h:681
bool GetUseExternalEditor()
Get whether an external editor is being used.
static void PrintStackTraceOnError()
Configure LLDB to print a stack trace when it crashes.
static lldb::SBDebugger Create()
Create a new debugger instance (deprecated).
void SetInputFileHandle(FILE *f, bool transfer_ownership)
Set the input file handle for the debugger.
void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread)
Run the command interpreter.
static const char * GetVersionString()
Get the LLDB version string.
lldb_private::Debugger & ref() const
lldb::SBStructuredData GetSetting(const char *setting=nullptr)
Get debugger settings as structured data.
const void size_t data_len
Definition SBDebugger.h:478
const char * GetReproducerPath() const
Get the path to the reproducer.
void SetOutputFileHandle(FILE *f, bool transfer_ownership)
Set the output file handle for the debugger.
static lldb::SBError InitializeWithErrorHandling()
Initialize the LLDB debugger subsystem with error handling.
friend class SBProcess
Definition SBDebugger.h:679
void SetTerminalWidth(uint32_t term_width)
Set the terminal width.
SBTypeSummary GetSummaryForType(SBTypeNameSpecifier type_name_spec)
Get the summary for a type.
void HandleCommand(const char *command)
Execute a command in the command interpreter.
lldb::SBCommandInterpreter GetCommandInterpreter()
Get the command interpreter for this debugger.
SBFile GetInputFile()
Get the input file for the debugger.
const char * GetPrompt() const
Get the command prompt string.
friend class SBInputReader
Definition SBDebugger.h:677
bool SetUseColor(bool use_color)
Set whether to use color in output.
bool GetAsync()
Get whether the debugger is running in asynchronous mode.
const lldb::DebuggerSP & get_sp() const
lldb::SBTarget FindTargetByGloballyUniqueID(lldb::user_id_t id)
Find a target with the specified unique ID.
static bool StateIsRunningState(lldb::StateType state)
Check if a state is a running state.
SBError SetErrorFile(SBFile file)
Set the error file for the debugger.
bool SetUseSourceCache(bool use_source_cache)
Set whether to use the source cache.
uint32_t GetNumCategories()
Get the number of type categories.
static lldb::SBStringList GetInternalVariableValue(const char *var_name, const char *debugger_instance_name)
Get the value of an internal variable.
friend class SBTarget
Definition SBDebugger.h:683
void Clear()
Clear this debugger instance.
SBTypeFormat GetFormatForType(SBTypeNameSpecifier type_name_spec)
Get the format for a type.
bool GetUseColor() const
Get whether color is being used in output.
static bool SupportsLanguage(lldb::LanguageType language)
Check if a specific language is supported by LLDB.
lldb::SBListener GetListener()
Get the listener associated with this debugger.
void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton)
Set a callback for log output.
lldb::DebuggerSP m_opaque_sp
Definition SBDebugger.h:697
lldb::ScriptLanguage GetScriptLanguage() const
Get the current scripting language.
LLDB_DEPRECATED_FIXME("Use AddDestroyCallback and RemoveDestroyCallback", "AddDestroyCallback") void SetDestroyCallback(lldb lldb::callback_token_t AddDestroyCallback(lldb::SBDebuggerDestroyCallback destroy_callback, void *baton)
Set a callback for when the debugger is destroyed (deprecated).
void SetScriptLanguage(lldb::ScriptLanguage script_lang)
Set the current scripting language.
uint32_t GetNumAvailablePlatforms()
Get the number of available platforms.
lldb::SBTarget FindTargetWithLLDBProcess(const lldb::ProcessSP &processSP)
friend class SBListener
Definition SBDebugger.h:678
SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier type_name_spec)
Get the synthetic for a type.
void DispatchClientTelemetry(const lldb::SBStructuredData &data)
Dispatch telemetry data from client to server.
SBTypeCategory GetCategoryAtIndex(uint32_t index)
Get a type category by index.
lldb::SBPlatform GetSelectedPlatform()
Get the selected platform.
static const char * GetBroadcasterClass()
Get the broadcaster class name.
lldb::SBTarget CreateTargetWithFileAndArch(const char *filename, const char *archname)
Create a target with the specified file and architecture.
bool IsValid() const
Check if this is a valid SBDebugger object.
static void Initialize()
Initialize LLDB and its subsystems.
static bool StateIsStoppedState(lldb::StateType state)
Check if a state is a stopped state.
lldb::SBError SetCurrentPlatform(const char *platform_name)
Set the current platform by name.
lldb::SBSourceManager GetSourceManager()
Get the source manager for this debugger.
SBTypeCategory GetCategory(const char *category_name)
Get a type category by name.
void ResetStatistics()
Clear collected statistics for targets belonging to this debugger.
void SetREPLLanguage(lldb::LanguageType repl_lang)
Set the current REPL language.
SBStructuredData GetScriptInterpreterInfo(ScriptLanguage language)
Get information about a script interpreter as structured data.
static SBDebugger FindDebuggerWithID(int id)
Find a debugger by ID. Returns an invalid debugger if not found.
bool SetShowInlineDiagnostics(bool b)
Set whether to show inline diagnostics.
uint32_t GetNumPlatforms()
Get the number of currently active platforms.
void DispatchInputEndOfFile()
Signal end-of-file to the current input dispatch.
uint32_t GetTerminalWidth() const
Get the terminal width.
void SetTerminalHeight(uint32_t term_height)
Set the terminal height.
bool InterruptRequested()
Check if an interrupt has been requested.
lldb::SBTarget FindTargetWithFileAndArch(const char *filename, const char *arch)
Find a target with the specified file and architecture.
static lldb::SBStructuredData GetProgressDataFromEvent(const lldb::SBEvent &event)
Get progress data from an event.
static const char * StateAsCString(lldb::StateType state)
Convert a state type to a string.
void PushInputReader(lldb::SBInputReader &reader)
Push an input reader onto the IO handler stack.
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.
lldb::SBTarget GetDummyTarget()
Get the dummy target.
bool EnableLog(const char *channel, const char **categories)
Enable logging for a specific channel and category.
static bool SetDefaultArchitecture(const char *arch_name)
Set the default architecture.
lldb_private::Debugger * get() const
void RestoreInputTerminalState()
Restore the previously saved terminal state.
SBFile GetOutputFile()
Get the output file for the debugger.
lldb::SBBroadcaster GetBroadcaster()
Get the broadcaster that allows subscribing to events from this debugger.
void SetSelectedTarget(SBTarget &target)
Set the selected target.
SBTypeCategory GetDefaultCategory()
Get the default type category.
bool GetUseSourceCache() const
Get whether the source cache is being used.
SBFile GetErrorFile()
Get the error file for the debugger.
uint32_t GetTerminalHeight() const
Get the terminal height.
LLDB_DEPRECATED_FIXME("Use HandleProcessEvent(const SBProcess &, const SBEvent &, SBFile, " "SBFile) or HandleProcessEvent(const SBProcess &, const SBEvent &, " "FileSP, FileSP)", "HandleProcessEvent(const SBProcess &, const SBEvent &, SBFile, SBFile)") void HandleProcessEvent(const lldb voi HandleProcessEvent)(const lldb::SBProcess &process, const lldb::SBEvent &event, SBFile out, SBFile err)
Handle a process event (deprecated).
Definition SBDebugger.h:304
lldb::SBStructuredData GetAvailablePlatformInfoAtIndex(uint32_t idx)
Get information about the available platform at the given index as structured data.
static SBStructuredData GetBuildConfiguration()
Get the build configuration as structured data.
SBTypeCategory CreateCategory(const char *category_name)
Create a new type category.
bool SetCurrentPlatformSDKRoot(const char *sysroot)
Set the SDK root for the current platform.
void SetErrorFileHandle(FILE *f, bool transfer_ownership)
Set the error file handle for the debugger.
SBTrace LoadTraceFromFile(SBError &error, const SBFileSpec &trace_description_file)
Load a trace from a trace description file.
void CancelInterruptRequest()
Cancel a previously requested interrupt.
uint32_t GetNumTargets()
Get the number of targets in the debugger.
FILE * GetInputFileHandle()
Get the input file handle for the debugger.
SBError SetInputFile(SBFile file)
Set the input file for the debugger.
void DispatchInputInterrupt()
Interrupt the current input dispatch.
SBError SetInputString(const char *data)
Set the input from a string.
uint32_t GetIndexOfTarget(lldb::SBTarget target)
Get the index of a target.
SBError SetOutputFile(SBFile file)
Set the output file for the debugger.
lldb::SBTarget GetSelectedTarget()
Get the currently selected target.
void SaveInputTerminalState()
Save the current terminal state.
FILE * GetErrorFileHandle()
Get the error file handle for the debugger.
void SetSelectedPlatform(lldb::SBPlatform &platform)
Set the selected platform.
friend class SBSourceManager
Definition SBDebugger.h:680
void reset(const lldb::DebuggerSP &debugger_sp)
friend class SBPlatform
Definition SBDebugger.h:682
FILE * GetOutputFileHandle()
Get the output file handle for the debugger.
const char * GetInstanceName()
Get the instance name of this debugger.
lldb::SBTarget FindTargetWithProcessID(lldb::pid_t pid)
Find a target with the specified process ID.
static void PrintDiagnosticsOnError()
Configure LLDB to print diagnostic information when it crashes.
void SetCloseInputOnEOF(bool b)
Set whether to close input on EOF (deprecated).
friend class SBCommandInterpreter
Definition SBDebugger.h:676
lldb::user_id_t GetID()
Get the unique ID of this debugger.
lldb::SBTarget CreateTargetWithFileAndTargetTriple(const char *filename, const char *target_triple)
Create a target with the specified file and target triple.
SBDebugger()
Default constructor creates an invalid SBDebugger instance.
bool RemoveDestroyCallback(lldb::callback_token_t token)
Remove a destroy callback.
static lldb::SBStructuredData GetDiagnosticFromEvent(const lldb::SBEvent &event)
Get diagnostic information from an event.
lldb::ScriptLanguage GetScriptingLanguage(const char *script_language_name)
Get the scripting language by name.
static void Destroy(lldb::SBDebugger &debugger)
Destroy a debugger instance.
void RequestInterrupt()
Request an interrupt of the current operation.
bool Success() const
Definition SBError.cpp:81
void SetError(uint32_t err, lldb::ErrorType type)
Definition SBError.cpp:124
lldb_private::Status & ref()
Definition SBError.cpp:191
const char * GetCString() const
Get the error string as a NULL terminated UTF8 c-string.
Definition SBError.cpp:55
void Clear()
Definition SBError.cpp:63
lldb_private::Event * get() const
Definition SBEvent.cpp:134
FileSP m_opaque_sp
Definition SBFile.h:51
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)
bool IsActive() const
void reset(lldb::ListenerSP listener_sp)
const char * GetName()
lldb::PlatformSP GetSP() const
void SetSP(const lldb::PlatformSP &platform_sp)
void ReportEventState(const lldb::SBEvent &event, FILE *out) const
lldb::ProcessSP GetSP() const
static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event)
lldb::SBTarget GetTarget() const
size_t GetSTDOUT(char *dst, size_t dst_len) const
bool IsValid() const
size_t GetSTDERR(char *dst, size_t dst_len) const
lldb_private::Stream & ref()
Definition SBStream.cpp:177
const char * GetData()
Definition SBStream.cpp:44
StructuredDataImplUP m_impl_up
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
void SetSP(const lldb::TargetSP &target_sp)
Definition SBTarget.cpp:581
lldb::TargetSP GetSP() const
Definition SBTarget.cpp:579
lldb::TargetSP m_opaque_sp
Definition SBTarget.h:1024
static SBTrace LoadTraceFromFile(SBError &error, SBDebugger &debugger, const SBFileSpec &trace_description_file)
See SBDebugger::LoadTraceFromFile.
Definition SBTrace.cpp:31
SBTypeFormat GetFormatForType(SBTypeNameSpecifier)
lldb::TypeNameSpecifierImplSP GetSP()
An architecture specification class.
Definition ArchSpec.h:31
bool IsValid() const
Tests if this ArchSpec is valid.
Definition ArchSpec.h:366
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition ArchSpec.h:468
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition ArchSpec.cpp:548
void SetAutoHandleEvents(bool auto_handle_events)
bool IsResult(lldb::CommandInterpreterResult result)
void SkipAppInitFiles(bool skip_app_init_files)
void SkipLLDBInitFiles(bool skip_lldbinit_files)
CommandInterpreterRunResult RunCommandInterpreter(CommandInterpreterRunOptions &options)
A uniqued constant string class.
Definition ConstString.h:40
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
const char * GetCString() const
Get the string value as a C string.
static bool Delete(ConstString category)
static lldb::TypeCategoryImplSP GetCategoryAtIndex(size_t)
static bool GetCategory(ConstString category, lldb::TypeCategoryImplSP &entry, bool allow_create=true)
static lldb::ScriptedSyntheticChildrenSP GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp)
static lldb::TypeFilterImplSP GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp)
static lldb::TypeSummaryImplSP GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp)
static void ResetStatistics(Debugger &debugger, Target *target)
Reset metrics associated with one or all targets in a debugger.
A class to manage flag bits.
Definition Debugger.h:80
static lldb::DebuggerSP FindDebuggerWithInstanceName(llvm::StringRef instance_name)
Definition Debugger.cpp:917
static llvm::StringRef GetStaticBroadcasterClass()
Definition Debugger.cpp:960
static lldb::DebuggerSP CreateInstance(lldb::LogOutputCallback log_callback=nullptr, void *baton=nullptr)
Definition Debugger.cpp:841
static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id)
static void Destroy(lldb::DebuggerSP &debugger_sp)
Definition Debugger.cpp:885
static StructuredData::DictionarySP GetAsStructuredData(const Event *event_ptr)
bool Dump(llvm::raw_ostream &stream)
Gather diagnostics and print a message to the given output stream.
static Diagnostics & Instance()
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A file utility class.
Definition FileSpec.h:57
An abstract base class for files.
Definition File.h:36
virtual FILE * GetStream()
Get the underlying libc stream for this file, or NULL.
Definition File.cpp:129
static size_t RemoveOrphanSharedModules(bool mandatory)
void SetPlatformName(const char *platform_name)
void SetSelectedPlatform(const lldb::PlatformSP &platform_sp)
Definition Platform.h:1111
lldb::PlatformSP GetOrCreate(llvm::StringRef name)
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:227
static lldb::PlatformSP GetHostPlatform()
Get the native host platform plug-in.
Definition Platform.cpp:134
static llvm::StringRef GetPlatformPluginDescriptionAtIndex(uint32_t idx)
static llvm::StringRef GetPlatformPluginNameAtIndex(uint32_t idx)
static const ProgressEventData * GetEventDataFromEvent(const Event *event_ptr)
static StructuredData::DictionarySP GetAsStructuredData(const Event *event_ptr)
virtual StructuredData::DictionarySP GetInterpreterInfo()
An error handling class.
Definition Status.h:118
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
static Status FromErrorString(const char *str)
Definition Status.h:141
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
Definition Status.cpp:137
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
Definition Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition Stream.cpp:65
size_t SplitIntoLines(const std::string &lines)
void AddItem(llvm::StringRef key, ObjectSP value_sp)
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
static ObjectSP ParseJSON(llvm::StringRef json_text)
static ArchSpec GetDefaultArchitecture()
Definition Target.cpp:2800
static void SetDefaultArchitecture(const ArchSpec &arch)
Definition Target.cpp:2804
static bool SupportsLanguageStatic(lldb::LanguageType language)
static bool XMLEnabled()
Definition XML.cpp:83
#define LLDB_INVALID_UID
#define UINT32_MAX
#define LLDB_INVALID_CALLBACK_TOKEN
Definition lldb-types.h:71
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:332
const char * GetVersion()
Retrieves a string representing the complete LLDB version, which includes the lldb version number,...
Definition Version.cpp:38
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
bool StateIsRunningState(lldb::StateType state)
Check if a state represents a state where the process or thread is running.
Definition State.cpp:68
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
Definition State.cpp:14
ScriptLanguage
Script interpreter types.
@ eScriptLanguageDefault
@ eScriptLanguageNone
@ eDescriptionLevelBrief
@ eCommandInterpreterResultInferiorCrash
Stopped because the corresponding option was set and the inferior crashed.
@ eCommandInterpreterResultQuitRequested
Stopped because quit was requested.
class LLDB_API SBTypeCategory
Definition SBDefines.h:121
std::shared_ptr< lldb_private::Platform > PlatformSP
class LLDB_API SBFile
Definition SBDefines.h:74
StateType
Process and Thread States.
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
class LLDB_API SBTypeFilter
Definition SBDefines.h:124
class LLDB_API SBTypeFormat
Definition SBDefines.h:125
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Debugger > DebuggerSP
std::shared_ptr< lldb_private::Event > EventSP
uint64_t pid_t
Definition lldb-types.h:83
std::shared_ptr< lldb_private::Listener > ListenerSP
int32_t callback_token_t
Definition lldb-types.h:81
std::shared_ptr< lldb_private::TypeCategoryImpl > TypeCategoryImplSP
uint64_t user_id_t
Definition lldb-types.h:82
class LLDB_API SBStringList
Definition SBDefines.h:109
void(* SBDebuggerDestroyCallback)(lldb::user_id_t debugger_id, void *baton)
Definition SBDefines.h:145
void(* LogOutputCallback)(const char *, void *baton)
Definition lldb-types.h:73
std::shared_ptr< lldb_private::Target > TargetSP
class LLDB_API SBError
Definition SBDefines.h:69
std::shared_ptr< lldb_private::File > FileSP
std::shared_ptr< lldb_private::OptionValue > OptionValueSP
class LLDB_API SBTypeSynthetic
Definition SBDefines.h:132
class LLDB_API SBCommandInterpreterRunResult
Definition SBDefines.h:59
InputReaderGranularity
Token size/granularities for Input Readers.
class LLDB_API SBTypeSummary
Definition SBDefines.h:130
static lldb::ScriptLanguage ToScriptLanguage(llvm::StringRef s, lldb::ScriptLanguage fail_value, bool *success_ptr)