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((FileSP)std::make_shared<NativeFile>(
331 fh, File::eOpenOptionReadOnly, 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>(
389 fh, File::eOpenOptionWriteOnly, transfer_ownership));
390}
391
393 LLDB_INSTRUMENT_VA(this, file);
395 if (!m_opaque_sp) {
396 error.ref() = Status::FromErrorString("invalid debugger");
397 return error;
398 }
399 if (!file) {
400 error.ref() = Status::FromErrorString("invalid file");
401 return error;
402 }
403 m_opaque_sp->SetOutputFile(file.m_opaque_sp);
404 return error;
405}
406
407void SBDebugger::SetErrorFileHandle(FILE *fh, bool transfer_ownership) {
408 LLDB_INSTRUMENT_VA(this, fh, transfer_ownership);
409 SetErrorFile((FileSP)std::make_shared<NativeFile>(
410 fh, File::eOpenOptionWriteOnly, transfer_ownership));
411}
412
414 LLDB_INSTRUMENT_VA(this, file_sp);
415 return SetErrorFile(SBFile(file_sp));
416}
417
419 LLDB_INSTRUMENT_VA(this, file);
421 if (!m_opaque_sp) {
422 error.ref() = Status::FromErrorString("invalid debugger");
423 return error;
424 }
425 if (!file) {
426 error.ref() = Status::FromErrorString("invalid file");
427 return error;
428 }
429 m_opaque_sp->SetErrorFile(file.m_opaque_sp);
430 return error;
431}
432
434 LLDB_INSTRUMENT_VA(this, setting);
435
437 if (!m_opaque_sp)
438 return data;
439
440 StreamString json_strm;
441 ExecutionContext exe_ctx(
442 m_opaque_sp->GetCommandInterpreter().GetExecutionContext());
443 if (setting && strlen(setting) > 0)
444 m_opaque_sp->DumpPropertyValue(&exe_ctx, json_strm, setting,
445 /*dump_mask*/ 0,
446 /*is_json*/ true);
447 else
448 m_opaque_sp->DumpAllPropertyValues(&exe_ctx, json_strm, /*dump_mask*/ 0,
449 /*is_json*/ true);
450
451 data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_strm.GetString()));
452 return data;
453}
454
456 LLDB_INSTRUMENT_VA(this);
457 if (m_opaque_sp) {
458 File &file_sp = m_opaque_sp->GetInputFile();
459 return file_sp.GetStream();
460 }
461 return nullptr;
462}
463
465 LLDB_INSTRUMENT_VA(this);
466 if (m_opaque_sp) {
467 return SBFile(m_opaque_sp->GetInputFileSP());
468 }
469 return SBFile();
470}
471
473 LLDB_INSTRUMENT_VA(this);
474 if (m_opaque_sp)
475 return m_opaque_sp->GetOutputFileSP()->GetStream();
476 return nullptr;
477}
478
480 LLDB_INSTRUMENT_VA(this);
481 if (m_opaque_sp)
482 return SBFile(m_opaque_sp->GetOutputFileSP());
483 return SBFile();
484}
485
487 LLDB_INSTRUMENT_VA(this);
488
489 if (m_opaque_sp)
490 return m_opaque_sp->GetErrorFileSP()->GetStream();
491 return nullptr;
492}
493
495 LLDB_INSTRUMENT_VA(this);
496 SBFile file;
497 if (m_opaque_sp)
498 return SBFile(m_opaque_sp->GetErrorFileSP());
499 return SBFile();
500}
501
503 LLDB_INSTRUMENT_VA(this);
504
505 if (m_opaque_sp)
506 m_opaque_sp->SaveInputTerminalState();
507}
508
510 LLDB_INSTRUMENT_VA(this);
511
512 if (m_opaque_sp)
513 m_opaque_sp->RestoreInputTerminalState();
514}
516 LLDB_INSTRUMENT_VA(this);
517
518 SBCommandInterpreter sb_interpreter;
519 if (m_opaque_sp)
520 sb_interpreter.reset(&m_opaque_sp->GetCommandInterpreter());
521
522 return sb_interpreter;
523}
524
525void SBDebugger::HandleCommand(const char *command) {
526 LLDB_INSTRUMENT_VA(this, command);
527
528 if (m_opaque_sp) {
529 TargetSP target_sp(m_opaque_sp->GetSelectedTarget());
530 std::unique_lock<std::recursive_mutex> lock;
531 if (target_sp)
532 lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
533
536
537 sb_interpreter.HandleCommand(command, result, false);
538
539 result.PutError(m_opaque_sp->GetErrorFileSP());
540 result.PutOutput(m_opaque_sp->GetOutputFileSP());
541
542 if (!m_opaque_sp->GetAsyncExecution()) {
543 SBProcess process(GetCommandInterpreter().GetProcess());
544 ProcessSP process_sp(process.GetSP());
545 if (process_sp) {
546 EventSP event_sp;
547 ListenerSP lldb_listener_sp = m_opaque_sp->GetListener();
548 while (lldb_listener_sp->GetEventForBroadcaster(
549 process_sp.get(), event_sp, std::chrono::seconds(0))) {
550 SBEvent event(event_sp);
551 HandleProcessEvent(process, event, GetOutputFile(), GetErrorFile());
552 }
553 }
554 }
555 }
556}
557
559 LLDB_INSTRUMENT_VA(this);
560
561 SBListener sb_listener;
562 if (m_opaque_sp)
563 sb_listener.reset(m_opaque_sp->GetListener());
564
565 return sb_listener;
566}
567
568void SBDebugger::HandleProcessEvent(const SBProcess &process,
569 const SBEvent &event, SBFile out,
570 SBFile err) {
571 LLDB_INSTRUMENT_VA(this, process, event, out, err);
572
573 return HandleProcessEvent(process, event, out.m_opaque_sp, err.m_opaque_sp);
574}
575
576void SBDebugger::HandleProcessEvent(const SBProcess &process,
577 const SBEvent &event, FILE *out,
578 FILE *err) {
579 LLDB_INSTRUMENT_VA(this, process, event, out, err);
580
581 FileSP outfile =
582 std::make_shared<NativeFile>(out, File::eOpenOptionWriteOnly, false);
583 FileSP errfile =
584 std::make_shared<NativeFile>(err, File::eOpenOptionWriteOnly, false);
585 return HandleProcessEvent(process, event, outfile, errfile);
586}
587
588void SBDebugger::HandleProcessEvent(const SBProcess &process,
589 const SBEvent &event, FileSP out_sp,
590 FileSP err_sp) {
591
592 LLDB_INSTRUMENT_VA(this, process, event, out_sp, err_sp);
593
594 if (!process.IsValid())
595 return;
596
597 TargetSP target_sp(process.GetTarget().GetSP());
598 if (!target_sp)
599 return;
600
601 const uint32_t event_type = event.GetType();
602 char stdio_buffer[1024];
603 size_t len;
604
605 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
606
607 if (event_type &
609 // Drain stdout when we stop just in case we have any bytes
610 while ((len = process.GetSTDOUT(stdio_buffer, sizeof(stdio_buffer))) > 0)
611 if (out_sp)
612 out_sp->Write(stdio_buffer, len);
613 }
614
615 if (event_type &
617 // Drain stderr when we stop just in case we have any bytes
618 while ((len = process.GetSTDERR(stdio_buffer, sizeof(stdio_buffer))) > 0)
619 if (err_sp)
620 err_sp->Write(stdio_buffer, len);
621 }
622
623 if (event_type & Process::eBroadcastBitStateChanged) {
624 StateType event_state = SBProcess::GetStateFromEvent(event);
625
626 if (event_state == eStateInvalid)
627 return;
628
629 bool is_stopped = StateIsStoppedState(event_state);
630 if (!is_stopped)
631 process.ReportEventState(event, out_sp);
632 }
633}
634
636 LLDB_INSTRUMENT_VA(this);
637
638 SBSourceManager sb_source_manager(*this);
639 return sb_source_manager;
640}
641
642bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) {
643 LLDB_INSTRUMENT_VA(arch_name, arch_name_len);
644
645 if (arch_name && arch_name_len) {
647
648 if (default_arch.IsValid()) {
649 const std::string &triple_str = default_arch.GetTriple().str();
650 if (!triple_str.empty())
651 ::snprintf(arch_name, arch_name_len, "%s", triple_str.c_str());
652 else
653 ::snprintf(arch_name, arch_name_len, "%s",
654 default_arch.GetArchitectureName());
655 return true;
656 }
657 }
658 if (arch_name && arch_name_len)
659 arch_name[0] = '\0';
660 return false;
661}
662
663bool SBDebugger::SetDefaultArchitecture(const char *arch_name) {
664 LLDB_INSTRUMENT_VA(arch_name);
665
666 if (arch_name) {
667 ArchSpec arch(arch_name);
668 if (arch.IsValid()) {
670 return true;
671 }
672 }
673 return false;
674}
675
677SBDebugger::GetScriptingLanguage(const char *script_language_name) {
678 LLDB_INSTRUMENT_VA(this, script_language_name);
679
680 if (!script_language_name)
683 llvm::StringRef(script_language_name), eScriptLanguageDefault, nullptr);
684}
685
688 LLDB_INSTRUMENT_VA(this, language);
690 if (m_opaque_sp) {
692 m_opaque_sp->GetScriptInterpreter(language);
693 if (interp) {
694 data.m_impl_up->SetObjectSP(interp->GetInterpreterInfo());
695 }
696 }
697 return data;
698}
699
702
704}
705
707 LLDB_INSTRUMENT_VA(state);
708
709 return lldb_private::StateAsCString(state);
710}
711
713 llvm::StringRef name, bool value,
714 llvm::StringRef description) {
715 auto entry_up = std::make_unique<StructuredData::Dictionary>();
716 entry_up->AddBooleanItem("value", value);
717 entry_up->AddStringItem("description", description);
718 dict.AddItem(name, std::move(entry_up));
719}
720
722 auto array_up = std::make_unique<StructuredData::Array>();
723#define LLVM_TARGET(target) \
724 array_up->AddItem(std::make_unique<StructuredData::String>(#target));
725#include "llvm/Config/Targets.def"
726 auto entry_up = std::make_unique<StructuredData::Dictionary>();
727 entry_up->AddItem("value", std::move(array_up));
728 entry_up->AddStringItem("description", "A list of configured LLVM targets.");
729 dict.AddItem("targets", std::move(entry_up));
730}
731
734
735 auto config_up = std::make_unique<StructuredData::Dictionary>();
737 *config_up, "xml", XMLDocument::XMLEnabled(),
738 "A boolean value that indicates if XML support is enabled in LLDB");
740 *config_up, "curl", LLVM_ENABLE_CURL,
741 "A boolean value that indicates if CURL support is enabled in LLDB");
743 *config_up, "curses", LLDB_ENABLE_CURSES,
744 "A boolean value that indicates if curses support is enabled in LLDB");
746 *config_up, "editline", LLDB_ENABLE_LIBEDIT,
747 "A boolean value that indicates if editline support is enabled in LLDB");
748 AddBoolConfigEntry(*config_up, "editline_wchar", LLDB_EDITLINE_USE_WCHAR,
749 "A boolean value that indicates if editline wide "
750 "characters support is enabled in LLDB");
752 *config_up, "lzma", LLDB_ENABLE_LZMA,
753 "A boolean value that indicates if lzma support is enabled in LLDB");
755 *config_up, "python", LLDB_ENABLE_PYTHON,
756 "A boolean value that indicates if python support is enabled in LLDB");
758 *config_up, "lua", LLDB_ENABLE_LUA,
759 "A boolean value that indicates if lua support is enabled in LLDB");
760 AddBoolConfigEntry(*config_up, "fbsdvmcore", LLDB_ENABLE_FBSDVMCORE,
761 "A boolean value that indicates if fbsdvmcore support is "
762 "enabled in LLDB");
763 AddLLVMTargets(*config_up);
764
766 data.m_impl_up->SetObjectSP(std::move(config_up));
767 return data;
768}
769
771 LLDB_INSTRUMENT_VA(state);
772
773 const bool result = lldb_private::StateIsRunningState(state);
774
775 return result;
776}
777
779 LLDB_INSTRUMENT_VA(state);
780
781 const bool result = lldb_private::StateIsStoppedState(state, false);
782
783 return result;
784}
785
787 const char *target_triple,
788 const char *platform_name,
789 bool add_dependent_modules,
790 lldb::SBError &sb_error) {
791 LLDB_INSTRUMENT_VA(this, filename, target_triple, platform_name,
792 add_dependent_modules, sb_error);
793
794 SBTarget sb_target;
795 TargetSP target_sp;
796 if (m_opaque_sp) {
797 sb_error.Clear();
798 OptionGroupPlatform platform_options(false);
799 platform_options.SetPlatformName(platform_name);
800
801 sb_error.ref() = m_opaque_sp->GetTargetList().CreateTarget(
802 *m_opaque_sp, filename, target_triple,
803 add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo,
804 &platform_options, target_sp);
805
806 if (sb_error.Success())
807 sb_target.SetSP(target_sp);
808 } else {
809 sb_error = Status::FromErrorString("invalid debugger");
810 }
811
812 Log *log = GetLog(LLDBLog::API);
813 LLDB_LOGF(log,
814 "SBDebugger(%p)::CreateTarget (filename=\"%s\", triple=%s, "
815 "platform_name=%s, add_dependent_modules=%u, error=%s) => "
816 "SBTarget(%p)",
817 static_cast<void *>(m_opaque_sp.get()), filename, target_triple,
818 platform_name, add_dependent_modules, sb_error.GetCString(),
819 static_cast<void *>(target_sp.get()));
820
821 return sb_target;
822}
823
826 const char *target_triple) {
827 LLDB_INSTRUMENT_VA(this, filename, target_triple);
828
829 SBTarget sb_target;
830 TargetSP target_sp;
831 if (m_opaque_sp) {
832 const bool add_dependent_modules = true;
833 Status error(m_opaque_sp->GetTargetList().CreateTarget(
834 *m_opaque_sp, filename, target_triple,
835 add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr,
836 target_sp));
837 sb_target.SetSP(target_sp);
838 }
839
840 Log *log = GetLog(LLDBLog::API);
841 LLDB_LOGF(log,
842 "SBDebugger(%p)::CreateTargetWithFileAndTargetTriple "
843 "(filename=\"%s\", triple=%s) => SBTarget(%p)",
844 static_cast<void *>(m_opaque_sp.get()), filename, target_triple,
845 static_cast<void *>(target_sp.get()));
846
847 return sb_target;
848}
849
851 const char *arch_cstr) {
852 LLDB_INSTRUMENT_VA(this, filename, arch_cstr);
853
854 Log *log = GetLog(LLDBLog::API);
855
856 SBTarget sb_target;
857 TargetSP target_sp;
858 if (m_opaque_sp) {
860 if (arch_cstr == nullptr) {
861 // The version of CreateTarget that takes an ArchSpec won't accept an
862 // empty ArchSpec, so when the arch hasn't been specified, we need to
863 // call the target triple version.
864 error = m_opaque_sp->GetTargetList().CreateTarget(
865 *m_opaque_sp, filename, arch_cstr, eLoadDependentsYes, nullptr,
866 target_sp);
867 } else {
868 PlatformSP platform_sp =
869 m_opaque_sp->GetPlatformList().GetSelectedPlatform();
870 ArchSpec arch =
871 Platform::GetAugmentedArchSpec(platform_sp.get(), arch_cstr);
872 if (arch.IsValid())
873 error = m_opaque_sp->GetTargetList().CreateTarget(
874 *m_opaque_sp, filename, arch, eLoadDependentsYes, platform_sp,
875 target_sp);
876 else
877 error = Status::FromErrorStringWithFormat("invalid arch_cstr: %s",
878 arch_cstr);
879 }
880 if (error.Success())
881 sb_target.SetSP(target_sp);
882 }
883
884 LLDB_LOGF(log,
885 "SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", "
886 "arch=%s) => SBTarget(%p)",
887 static_cast<void *>(m_opaque_sp.get()),
888 filename ? filename : "<unspecified>",
889 arch_cstr ? arch_cstr : "<unspecified>",
890 static_cast<void *>(target_sp.get()));
891
892 return sb_target;
893}
894
895SBTarget SBDebugger::CreateTarget(const char *filename) {
896 LLDB_INSTRUMENT_VA(this, filename);
897
898 SBTarget sb_target;
899 TargetSP target_sp;
900 if (m_opaque_sp) {
902 const bool add_dependent_modules = true;
903 error = m_opaque_sp->GetTargetList().CreateTarget(
904 *m_opaque_sp, filename, "",
905 add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr,
906 target_sp);
907
908 if (error.Success())
909 sb_target.SetSP(target_sp);
910 }
911 Log *log = GetLog(LLDBLog::API);
912 LLDB_LOGF(log,
913 "SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)",
914 static_cast<void *>(m_opaque_sp.get()), filename,
915 static_cast<void *>(target_sp.get()));
916 return sb_target;
917}
918
920 LLDB_INSTRUMENT_VA(this);
921
922 SBTarget sb_target;
923 if (m_opaque_sp) {
924 sb_target.SetSP(m_opaque_sp->GetDummyTarget().shared_from_this());
925 }
926 Log *log = GetLog(LLDBLog::API);
927 LLDB_LOGF(log, "SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)",
928 static_cast<void *>(m_opaque_sp.get()),
929 static_cast<void *>(sb_target.GetSP().get()));
930 return sb_target;
931}
932
934 LLDB_INSTRUMENT_VA(this);
935 if (m_opaque_sp) {
936 m_opaque_sp->DispatchClientTelemetry(*entry.m_impl_up);
937 } else {
938 Log *log = GetLog(LLDBLog::API);
939 LLDB_LOGF(log,
940 "Could not send telemetry from SBDebugger - debugger was null.");
941 }
942}
943
945 LLDB_INSTRUMENT_VA(this, target);
946
947 bool result = false;
948 if (m_opaque_sp) {
949 TargetSP target_sp(target.GetSP());
950 if (target_sp) {
951 // No need to lock, the target list is thread safe
952 result = m_opaque_sp->GetTargetList().DeleteTarget(target_sp);
953 target_sp->Destroy();
954 target.Clear();
955 }
956 }
957
958 Log *log = GetLog(LLDBLog::API);
959 LLDB_LOGF(log, "SBDebugger(%p)::DeleteTarget (SBTarget(%p)) => %i",
960 static_cast<void *>(m_opaque_sp.get()),
961 static_cast<void *>(target.m_opaque_sp.get()), result);
962
963 return result;
964}
965
967 LLDB_INSTRUMENT_VA(this, idx);
968
969 SBTarget sb_target;
970 if (m_opaque_sp) {
971 // No need to lock, the target list is thread safe
972 sb_target.SetSP(m_opaque_sp->GetTargetList().GetTargetAtIndex(idx));
973 }
974 return sb_target;
975}
976
978 LLDB_INSTRUMENT_VA(this, target);
979
980 lldb::TargetSP target_sp = target.GetSP();
981 if (!target_sp)
982 return UINT32_MAX;
983
984 if (!m_opaque_sp)
985 return UINT32_MAX;
986
987 return m_opaque_sp->GetTargetList().GetIndexOfTarget(target.GetSP());
988}
989
991 LLDB_INSTRUMENT_VA(this, id);
992 SBTarget sb_target;
993 if (m_opaque_sp) {
994 // No need to lock, the target list is thread safe
995 sb_target.SetSP(
996 m_opaque_sp->GetTargetList().FindTargetByGloballyUniqueID(id));
997 }
998 return sb_target;
999}
1000
1002 LLDB_INSTRUMENT_VA(this, pid);
1003
1004 SBTarget sb_target;
1005 if (m_opaque_sp) {
1006 // No need to lock, the target list is thread safe
1007 sb_target.SetSP(m_opaque_sp->GetTargetList().FindTargetWithProcessID(pid));
1008 }
1009 return sb_target;
1010}
1011
1013 const char *arch_name) {
1014 LLDB_INSTRUMENT_VA(this, filename, arch_name);
1015
1016 SBTarget sb_target;
1017 if (m_opaque_sp && filename && filename[0]) {
1018 // No need to lock, the target list is thread safe
1020 m_opaque_sp->GetPlatformList().GetSelectedPlatform().get(), arch_name);
1021 TargetSP target_sp(
1022 m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture(
1023 FileSpec(filename), arch_name ? &arch : nullptr));
1024 sb_target.SetSP(target_sp);
1025 }
1026 return sb_target;
1027}
1028
1030 SBTarget sb_target;
1031 if (m_opaque_sp) {
1032 // No need to lock, the target list is thread safe
1033 sb_target.SetSP(
1034 m_opaque_sp->GetTargetList().FindTargetWithProcess(process_sp.get()));
1035 }
1036 return sb_target;
1037}
1038
1040 LLDB_INSTRUMENT_VA(this);
1041
1042 if (m_opaque_sp) {
1043 // No need to lock, the target list is thread safe
1044 return m_opaque_sp->GetTargetList().GetNumTargets();
1045 }
1046 return 0;
1047}
1048
1050 LLDB_INSTRUMENT_VA(this);
1051
1052 Log *log = GetLog(LLDBLog::API);
1053
1054 SBTarget sb_target;
1055 TargetSP target_sp;
1056 if (m_opaque_sp) {
1057 // No need to lock, the target list is thread safe
1058 target_sp = m_opaque_sp->GetTargetList().GetSelectedTarget();
1059 sb_target.SetSP(target_sp);
1060 }
1061
1062 if (log) {
1063 SBStream sstr;
1064 sb_target.GetDescription(sstr, eDescriptionLevelBrief);
1065 LLDB_LOGF(log, "SBDebugger(%p)::GetSelectedTarget () => SBTarget(%p): %s",
1066 static_cast<void *>(m_opaque_sp.get()),
1067 static_cast<void *>(target_sp.get()), sstr.GetData());
1068 }
1069
1070 return sb_target;
1071}
1072
1074 LLDB_INSTRUMENT_VA(this, sb_target);
1075
1076 Log *log = GetLog(LLDBLog::API);
1077
1078 TargetSP target_sp(sb_target.GetSP());
1079 if (m_opaque_sp) {
1080 m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp);
1081 }
1082 if (log) {
1083 SBStream sstr;
1084 sb_target.GetDescription(sstr, eDescriptionLevelBrief);
1085 LLDB_LOGF(log, "SBDebugger(%p)::SetSelectedTarget () => SBTarget(%p): %s",
1086 static_cast<void *>(m_opaque_sp.get()),
1087 static_cast<void *>(target_sp.get()), sstr.GetData());
1088 }
1089}
1090
1092 LLDB_INSTRUMENT_VA(this);
1093
1094 Log *log = GetLog(LLDBLog::API);
1095
1096 SBPlatform sb_platform;
1097 DebuggerSP debugger_sp(m_opaque_sp);
1098 if (debugger_sp) {
1099 sb_platform.SetSP(debugger_sp->GetPlatformList().GetSelectedPlatform());
1100 }
1101 LLDB_LOGF(log, "SBDebugger(%p)::GetSelectedPlatform () => SBPlatform(%p): %s",
1102 static_cast<void *>(m_opaque_sp.get()),
1103 static_cast<void *>(sb_platform.GetSP().get()),
1104 sb_platform.GetName());
1105 return sb_platform;
1106}
1107
1109 LLDB_INSTRUMENT_VA(this, sb_platform);
1110
1111 Log *log = GetLog(LLDBLog::API);
1112
1113 DebuggerSP debugger_sp(m_opaque_sp);
1114 if (debugger_sp) {
1115 debugger_sp->GetPlatformList().SetSelectedPlatform(sb_platform.GetSP());
1116 }
1117
1118 LLDB_LOGF(log, "SBDebugger(%p)::SetSelectedPlatform (SBPlatform(%p) %s)",
1119 static_cast<void *>(m_opaque_sp.get()),
1120 static_cast<void *>(sb_platform.GetSP().get()),
1121 sb_platform.GetName());
1122}
1123
1125 LLDB_INSTRUMENT_VA(this);
1126
1127 if (m_opaque_sp) {
1128 // No need to lock, the platform list is thread safe
1129 return m_opaque_sp->GetPlatformList().GetSize();
1130 }
1131 return 0;
1132}
1133
1135 LLDB_INSTRUMENT_VA(this, idx);
1136
1137 SBPlatform sb_platform;
1138 if (m_opaque_sp) {
1139 // No need to lock, the platform list is thread safe
1140 sb_platform.SetSP(m_opaque_sp->GetPlatformList().GetAtIndex(idx));
1141 }
1142 return sb_platform;
1143}
1144
1146 LLDB_INSTRUMENT_VA(this);
1147
1148 uint32_t idx = 0;
1149 while (true) {
1151 break;
1152 }
1153 ++idx;
1154 }
1155 // +1 for the host platform, which should always appear first in the list.
1156 return idx + 1;
1157}
1158
1160 LLDB_INSTRUMENT_VA(this, idx);
1161
1163 auto platform_dict = std::make_unique<StructuredData::Dictionary>();
1164 llvm::StringRef name_str("name"), desc_str("description");
1165
1166 if (idx == 0) {
1167 PlatformSP host_platform_sp(Platform::GetHostPlatform());
1168 platform_dict->AddStringItem(name_str, host_platform_sp->GetPluginName());
1169 platform_dict->AddStringItem(
1170 desc_str, llvm::StringRef(host_platform_sp->GetDescription()));
1171 } else if (idx > 0) {
1172 llvm::StringRef plugin_name =
1174 if (plugin_name.empty()) {
1175 return data;
1176 }
1177 platform_dict->AddStringItem(name_str, llvm::StringRef(plugin_name));
1178
1179 llvm::StringRef plugin_desc =
1181 platform_dict->AddStringItem(desc_str, llvm::StringRef(plugin_desc));
1182 }
1183
1184 data.m_impl_up->SetObjectSP(
1185 StructuredData::ObjectSP(platform_dict.release()));
1186 return data;
1187}
1188
1189void SBDebugger::DispatchInput(void *baton, const void *data, size_t data_len) {
1190 LLDB_INSTRUMENT_VA(this, baton, data, data_len);
1191
1193}
1194
1195void SBDebugger::DispatchInput(const void *data, size_t data_len) {
1197
1198 // Log *log(GetLog (LLDBLog::API));
1199 //
1200 // if (log)
1201 // LLDB_LOGF(log, "SBDebugger(%p)::DispatchInput (data=\"%.*s\",
1202 // size_t=%" PRIu64 ")",
1203 // m_opaque_sp.get(),
1204 // (int) data_len,
1205 // (const char *) data,
1206 // (uint64_t)data_len);
1207 //
1208 // if (m_opaque_sp)
1209 // m_opaque_sp->DispatchInput ((const char *) data, data_len);
1210}
1211
1213 LLDB_INSTRUMENT_VA(this);
1214
1215 if (m_opaque_sp)
1216 m_opaque_sp->DispatchInputInterrupt();
1217}
1218
1220 LLDB_INSTRUMENT_VA(this);
1221
1222 if (m_opaque_sp)
1223 m_opaque_sp->DispatchInputEndOfFile();
1224}
1225
1227 LLDB_INSTRUMENT_VA(this, reader);
1228}
1229
1230void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
1231 bool spawn_thread) {
1232 LLDB_INSTRUMENT_VA(this, auto_handle_events, spawn_thread);
1233
1234 if (m_opaque_sp) {
1236 options.SetAutoHandleEvents(auto_handle_events);
1237 options.SetSpawnThread(spawn_thread);
1238 m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter(options);
1239 }
1240}
1241
1242void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
1243 bool spawn_thread,
1245 int &num_errors, bool &quit_requested,
1246 bool &stopped_for_crash)
1247
1248{
1249 LLDB_INSTRUMENT_VA(this, auto_handle_events, spawn_thread, options,
1250 num_errors, quit_requested, stopped_for_crash);
1251
1252 if (m_opaque_sp) {
1253 options.SetAutoHandleEvents(auto_handle_events);
1254 options.SetSpawnThread(spawn_thread);
1255 CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter();
1257 interp.RunCommandInterpreter(options.ref());
1258 num_errors = result.GetNumErrors();
1259 quit_requested =
1261 stopped_for_crash =
1263 }
1264}
1265
1267 const SBCommandInterpreterRunOptions &options) {
1268 LLDB_INSTRUMENT_VA(this, options);
1269
1270 if (!m_opaque_sp)
1272
1273 CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter();
1275 interp.RunCommandInterpreter(options.ref());
1276
1277 return SBCommandInterpreterRunResult(result);
1278}
1279
1281 const char *repl_options) {
1282 LLDB_INSTRUMENT_VA(this, language, repl_options);
1283
1284 SBError error;
1285 if (m_opaque_sp)
1286 error.ref() = m_opaque_sp->RunREPL(language, repl_options);
1287 else
1288 error = Status::FromErrorString("invalid debugger");
1289 return error;
1290}
1291
1292void SBDebugger::reset(const DebuggerSP &debugger_sp) {
1293 m_opaque_sp = debugger_sp;
1294}
1295
1296Debugger *SBDebugger::get() const { return m_opaque_sp.get(); }
1297
1299 assert(m_opaque_sp.get());
1300 return *m_opaque_sp;
1301}
1302
1304
1307
1308 // No need to lock, the debugger list is thread safe
1309 SBDebugger sb_debugger;
1310 DebuggerSP debugger_sp = Debugger::FindDebuggerWithID(id);
1311 if (debugger_sp)
1312 sb_debugger.reset(debugger_sp);
1313 return sb_debugger;
1314}
1315
1317 LLDB_INSTRUMENT_VA(this);
1318
1319 if (!m_opaque_sp)
1320 return nullptr;
1321
1322 return ConstString(m_opaque_sp->GetInstanceName()).AsCString();
1323}
1324
1325SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value,
1326 const char *debugger_instance_name) {
1327 LLDB_INSTRUMENT_VA(var_name, value, debugger_instance_name);
1328
1329 SBError sb_error;
1330 DebuggerSP debugger_sp(
1331 Debugger::FindDebuggerWithInstanceName(debugger_instance_name));
1332 Status error;
1333 if (debugger_sp) {
1334 ExecutionContext exe_ctx(
1335 debugger_sp->GetCommandInterpreter().GetExecutionContext());
1336 error = debugger_sp->SetPropertyValue(&exe_ctx, eVarSetOperationAssign,
1337 var_name, value);
1338 } else {
1340 "invalid debugger instance name '%s'", debugger_instance_name);
1341 }
1342 if (error.Fail())
1343 sb_error.SetError(std::move(error));
1344 return sb_error;
1345}
1346
1349 const char *debugger_instance_name) {
1350 LLDB_INSTRUMENT_VA(var_name, debugger_instance_name);
1351
1352 DebuggerSP debugger_sp(
1353 Debugger::FindDebuggerWithInstanceName(debugger_instance_name));
1354 Status error;
1355 if (debugger_sp) {
1356 ExecutionContext exe_ctx(
1357 debugger_sp->GetCommandInterpreter().GetExecutionContext());
1358 lldb::OptionValueSP value_sp(
1359 debugger_sp->GetPropertyValue(&exe_ctx, var_name, error));
1360 if (value_sp) {
1361 StreamString value_strm;
1362 value_sp->DumpValue(&exe_ctx, value_strm, OptionValue::eDumpOptionValue);
1363 const std::string &value_str = std::string(value_strm.GetString());
1364 if (!value_str.empty()) {
1365 StringList string_list;
1366 string_list.SplitIntoLines(value_str);
1367 return SBStringList(&string_list);
1368 }
1369 }
1370 }
1371 return SBStringList();
1372}
1373
1375 LLDB_INSTRUMENT_VA(this);
1376
1377 return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0);
1378}
1379
1380void SBDebugger::SetTerminalWidth(uint32_t term_width) {
1381 LLDB_INSTRUMENT_VA(this, term_width);
1382
1383 if (m_opaque_sp)
1384 m_opaque_sp->SetTerminalWidth(term_width);
1385}
1386
1388 LLDB_INSTRUMENT_VA(this);
1389
1390 return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0);
1391}
1392
1393void SBDebugger::SetTerminalHeight(uint32_t term_height) {
1394 LLDB_INSTRUMENT_VA(this, term_height);
1395
1396 if (m_opaque_sp)
1397 m_opaque_sp->SetTerminalHeight(term_height);
1398}
1399
1400const char *SBDebugger::GetPrompt() const {
1401 LLDB_INSTRUMENT_VA(this);
1402
1403 Log *log = GetLog(LLDBLog::API);
1404
1405 LLDB_LOG(log, "SBDebugger({0:x})::GetPrompt () => \"{1}\"",
1406 static_cast<void *>(m_opaque_sp.get()),
1407 (m_opaque_sp ? m_opaque_sp->GetPrompt() : ""));
1408
1409 return (m_opaque_sp ? ConstString(m_opaque_sp->GetPrompt()).GetCString()
1410 : nullptr);
1411}
1412
1413void SBDebugger::SetPrompt(const char *prompt) {
1414 LLDB_INSTRUMENT_VA(this, prompt);
1415
1416 if (m_opaque_sp)
1417 m_opaque_sp->SetPrompt(llvm::StringRef(prompt));
1418}
1419
1421 LLDB_INSTRUMENT_VA(this);
1422
1423 return "GetReproducerPath has been deprecated";
1424}
1425
1427 LLDB_INSTRUMENT_VA(this);
1428
1429 return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone);
1430}
1431
1433 LLDB_INSTRUMENT_VA(this, script_lang);
1434
1435 if (m_opaque_sp) {
1436 m_opaque_sp->SetScriptLanguage(script_lang);
1437 }
1438}
1439
1441 LLDB_INSTRUMENT_VA(this);
1442
1443 return (m_opaque_sp ? m_opaque_sp->GetREPLLanguage() : eLanguageTypeUnknown);
1444}
1445
1447 LLDB_INSTRUMENT_VA(this, repl_lang);
1448
1449 if (m_opaque_sp) {
1450 m_opaque_sp->SetREPLLanguage(repl_lang);
1451 }
1452}
1453
1455 LLDB_INSTRUMENT_VA(this, value);
1456
1457 return (m_opaque_sp ? m_opaque_sp->SetUseExternalEditor(value) : false);
1458}
1459
1461 LLDB_INSTRUMENT_VA(this);
1462
1463 return (m_opaque_sp ? m_opaque_sp->GetUseExternalEditor() : false);
1464}
1465
1466bool SBDebugger::SetUseColor(bool value) {
1467 LLDB_INSTRUMENT_VA(this, value);
1468
1469 return (m_opaque_sp ? m_opaque_sp->SetUseColor(value) : false);
1470}
1471
1473 LLDB_INSTRUMENT_VA(this);
1474
1475 return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false);
1476}
1477
1479 LLDB_INSTRUMENT_VA(this, value);
1480
1481 return (m_opaque_sp ? m_opaque_sp->SetShowInlineDiagnostics(value) : false);
1482}
1483
1485 LLDB_INSTRUMENT_VA(this, value);
1486
1487 return (m_opaque_sp ? m_opaque_sp->SetUseSourceCache(value) : false);
1488}
1489
1491 LLDB_INSTRUMENT_VA(this);
1492
1493 return (m_opaque_sp ? m_opaque_sp->GetUseSourceCache() : false);
1494}
1495
1497 LLDB_INSTRUMENT_VA(this, description);
1498
1499 Stream &strm = description.ref();
1500
1501 if (m_opaque_sp) {
1502 const char *name = m_opaque_sp->GetInstanceName().c_str();
1503 user_id_t id = m_opaque_sp->GetID();
1504 strm.Printf("Debugger (instance: \"%s\", id: %" PRIu64 ")", name, id);
1505 } else
1506 strm.PutCString("No value");
1507
1508 return true;
1509}
1510
1512 LLDB_INSTRUMENT_VA(this);
1513
1514 return (m_opaque_sp ? m_opaque_sp->GetID() : LLDB_INVALID_UID);
1515}
1516
1517SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) {
1518 LLDB_INSTRUMENT_VA(this, platform_name_cstr);
1519
1520 SBError sb_error;
1521 if (m_opaque_sp) {
1522 if (platform_name_cstr && platform_name_cstr[0]) {
1523 PlatformList &platforms = m_opaque_sp->GetPlatformList();
1524 if (PlatformSP platform_sp = platforms.GetOrCreate(platform_name_cstr))
1525 platforms.SetSelectedPlatform(platform_sp);
1526 else
1527 sb_error.ref() = Status::FromErrorString("platform not found");
1528 } else {
1529 sb_error.ref() = Status::FromErrorString("invalid platform name");
1530 }
1531 } else {
1532 sb_error.ref() = Status::FromErrorString("invalid debugger");
1533 }
1534 return sb_error;
1535}
1536
1537bool SBDebugger::SetCurrentPlatformSDKRoot(const char *sysroot) {
1538 LLDB_INSTRUMENT_VA(this, sysroot);
1539
1540 if (SBPlatform platform = GetSelectedPlatform()) {
1541 platform.SetSDKRoot(sysroot);
1542 return true;
1543 }
1544 return false;
1545}
1546
1548 LLDB_INSTRUMENT_VA(this);
1549
1550 return false;
1551}
1552
1554 LLDB_INSTRUMENT_VA(this, b);
1555}
1556
1557SBTypeCategory SBDebugger::GetCategory(const char *category_name) {
1558 LLDB_INSTRUMENT_VA(this, category_name);
1559
1560 if (!category_name || *category_name == 0)
1561 return SBTypeCategory();
1562
1563 TypeCategoryImplSP category_sp;
1564
1566 category_sp, false)) {
1567 return SBTypeCategory(category_sp);
1568 } else {
1569 return SBTypeCategory();
1570 }
1571}
1572
1574 LLDB_INSTRUMENT_VA(this, lang_type);
1575
1576 TypeCategoryImplSP category_sp;
1577 if (DataVisualization::Categories::GetCategory(lang_type, category_sp)) {
1578 return SBTypeCategory(category_sp);
1579 } else {
1580 return SBTypeCategory();
1581 }
1582}
1583
1584SBTypeCategory SBDebugger::CreateCategory(const char *category_name) {
1585 LLDB_INSTRUMENT_VA(this, category_name);
1586
1587 if (!category_name || *category_name == 0)
1588 return SBTypeCategory();
1589
1590 TypeCategoryImplSP category_sp;
1591
1593 category_sp, true)) {
1594 return SBTypeCategory(category_sp);
1595 } else {
1596 return SBTypeCategory();
1597 }
1598}
1599
1600bool SBDebugger::DeleteCategory(const char *category_name) {
1601 LLDB_INSTRUMENT_VA(this, category_name);
1602
1603 if (!category_name || *category_name == 0)
1604 return false;
1605
1607}
1608
1614
1621
1623 LLDB_INSTRUMENT_VA(this);
1624
1625 return GetCategory("default");
1626}
1627
1629 LLDB_INSTRUMENT_VA(this, type_name);
1630
1631 SBTypeCategory default_category_sb = GetDefaultCategory();
1632 if (default_category_sb.GetEnabled())
1633 return default_category_sb.GetFormatForType(type_name);
1634 return SBTypeFormat();
1635}
1636
1638 LLDB_INSTRUMENT_VA(this, type_name);
1639
1640 if (!type_name.IsValid())
1641 return SBTypeSummary();
1643}
1644
1646 LLDB_INSTRUMENT_VA(this, type_name);
1647
1648 if (!type_name.IsValid())
1649 return SBTypeFilter();
1651}
1652
1654 LLDB_INSTRUMENT_VA(this, type_name);
1655
1656 if (!type_name.IsValid())
1657 return SBTypeSynthetic();
1658 return SBTypeSynthetic(
1660}
1661
1667
1668static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) {
1669 if (categories == nullptr)
1670 return {};
1671 size_t len = 0;
1672 while (categories[len] != nullptr)
1673 ++len;
1674 return llvm::ArrayRef(categories, len);
1675}
1676
1677bool SBDebugger::EnableLog(const char *channel, const char **categories) {
1678 LLDB_INSTRUMENT_VA(this, channel, categories);
1679
1680 if (m_opaque_sp) {
1681 uint32_t log_options =
1683 std::string error;
1684 llvm::raw_string_ostream error_stream(error);
1685 return m_opaque_sp->EnableLog(channel, GetCategoryArray(categories), "",
1686 log_options, /*buffer_size=*/0,
1687 eLogHandlerStream, error_stream);
1688 } else
1689 return false;
1690}
1691
1693 void *baton) {
1694 LLDB_INSTRUMENT_VA(this, log_callback, baton);
1695
1696 if (m_opaque_sp) {
1697 return m_opaque_sp->SetLoggingCallback(log_callback, baton);
1698 }
1699}
1700
1701void SBDebugger::SetDestroyCallback(
1702 lldb::SBDebuggerDestroyCallback destroy_callback, void *baton) {
1703 LLDB_INSTRUMENT_VA(this, destroy_callback, baton);
1704 if (m_opaque_sp) {
1705 return m_opaque_sp->SetDestroyCallback(
1706 destroy_callback, baton);
1707 }
1708}
1709
1712 void *baton) {
1713 LLDB_INSTRUMENT_VA(this, destroy_callback, baton);
1714
1715 if (m_opaque_sp)
1716 return m_opaque_sp->AddDestroyCallback(destroy_callback, baton);
1717
1719}
1720
1722 LLDB_INSTRUMENT_VA(this, token);
1723
1724 if (m_opaque_sp)
1725 return m_opaque_sp->RemoveDestroyCallback(token);
1726
1727 return false;
1728}
1729
1730SBTrace
1732 const SBFileSpec &trace_description_file) {
1733 LLDB_INSTRUMENT_VA(this, error, trace_description_file);
1734 return SBTrace::LoadTraceFromFile(error, *this, trace_description_file);
1735}
1736
1738 LLDB_INSTRUMENT_VA(this);
1739
1740 if (m_opaque_sp)
1741 m_opaque_sp->RequestInterrupt();
1742}
1744 LLDB_INSTRUMENT_VA(this);
1745
1746 if (m_opaque_sp)
1747 m_opaque_sp->CancelInterruptRequest();
1748}
1749
1751 LLDB_INSTRUMENT_VA(this);
1752
1753 if (m_opaque_sp)
1754 return m_opaque_sp->InterruptRequested();
1755 return false;
1756}
1757
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:54
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:178
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:587
lldb::TargetSP GetSP() const
Definition SBTarget.cpp:585
lldb::TargetSP m_opaque_sp
Definition SBTarget.h:1042
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:128
@ eOpenOptionReadOnly
Definition File.h:51
@ eOpenOptionWriteOnly
Definition File.h:52
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:226
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:2805
static void SetDefaultArchitecture(const ArchSpec &arch)
Definition Target.cpp:2809
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:122
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:125
class LLDB_API SBTypeFormat
Definition SBDefines.h:126
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:110
void(* SBDebuggerDestroyCallback)(lldb::user_id_t debugger_id, void *baton)
Definition SBDefines.h:146
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:133
class LLDB_API SBCommandInterpreterRunResult
Definition SBDefines.h:59
InputReaderGranularity
Token size/granularities for Input Readers.
class LLDB_API SBTypeSummary
Definition SBDefines.h:131
static lldb::ScriptLanguage ToScriptLanguage(llvm::StringRef s, lldb::ScriptLanguage fail_value, bool *success_ptr)