26#include "lldb/Host/Config.h"
70#include "llvm/ADT/STLExtras.h"
71#include "llvm/ADT/StringRef.h"
72#include "llvm/ADT/iterator.h"
73#include "llvm/Config/llvm-config.h"
74#include "llvm/Support/DynamicLibrary.h"
75#include "llvm/Support/FileSystem.h"
76#include "llvm/Support/FormatAdapters.h"
77#include "llvm/Support/Process.h"
78#include "llvm/Support/ThreadPool.h"
79#include "llvm/Support/Threading.h"
80#include "llvm/Support/raw_ostream.h"
92#include <system_error>
113 static std::mutex g_mutex;
124 "Never show disassembly when displaying a stop context.",
129 "Show disassembly when there is no debug information.",
134 "Show disassembly when there is no source information, or the source "
136 "is missing when displaying a stop context.",
141 "Always show disassembly when displaying a stop context.",
149 "Disable scripting languages.",
154 "Select python as the default scripting language.",
159 "Select the lldb default as the default scripting language.",
165 "Use no verbosity when running dwim-print."},
167 "Use partial verbosity when running dwim-print - display a message when "
168 "`expression` evaluation is used."},
170 "Use full verbosity when running dwim-print."},
177 "Highlight the stop column with ANSI terminal codes when color/ANSI "
178 "mode is enabled; otherwise, fall back to using a text-only caret (^) "
179 "as if \"caret-only\" mode was selected.",
184 "Highlight the stop column with ANSI terminal codes when running LLDB "
185 "with color/ANSI enabled.",
190 "Highlight the stop column with a caret character (^) underneath the "
191 "stop column. This method introduces a new line in source listings "
192 "that display thread stop locations.",
197 "Do not highlight the stop column.",
205 "Do not show any autosuggestion.",
210 "Show a suggestion sourced from previously entered commands.",
215 "Show the prefix that tab completion would insert for the current "
220#define LLDB_PROPERTIES_debugger
221#include "CoreProperties.inc"
224#define LLDB_PROPERTIES_debugger
225#include "CorePropertiesEnum.inc"
229#define LLDB_PROPERTIES_testing
230#include "CoreProperties.inc"
233#define LLDB_PROPERTIES_testing
234#include "CorePropertiesEnum.inc"
242 const llvm::SmallVector<llvm::StringRef> kVendorSafePaths = {
243#include "SafeAutoloadPaths.inc"
246 for (
auto path : kVendorSafePaths) {
247 assert(!path.empty());
266 const uint32_t idx = ePropertyInjectVarLocListError;
268 idx, g_testing_properties[idx].default_uint_value != 0);
273 return g_testing_properties;
277 const uint32_t idx = ePropertySafeAutoloadPaths;
280 assert(option_value);
285 const uint32_t idx = ePropertySafeAutoloadPaths;
288 assert(option_value);
293 const uint32_t idx = ePropertySafeAutoloadPaths;
302 llvm::StringRef property_path,
303 llvm::StringRef value) {
304 bool is_load_script =
305 (property_path ==
"target.load-script-from-symbol-file");
307 bool invalidate_data_vis = (property_path ==
"escape-non-printables");
308 invalidate_data_vis |=
309 (property_path ==
"target.max-zero-padding-in-float-format");
310 if (invalidate_data_vis) {
316 if (is_load_script && exe_ctx && exe_ctx->
GetTargetSP()) {
318 load_script_old_value =
319 target_sp->TargetProperties::GetLoadScriptFromSymbolFile();
322 if (
error.Success()) {
324 if (property_path == g_debugger_properties[ePropertyPrompt].name) {
325 llvm::StringRef new_prompt =
GetPrompt();
331 auto bytes = std::make_unique<EventDataBytes>(new_prompt);
332 auto prompt_change_event_sp = std::make_shared<Event>(
335 }
else if (property_path == g_debugger_properties[ePropertyUseColor].name) {
339 }
else if (property_path ==
340 g_debugger_properties[ePropertyPromptAnsiPrefix].name ||
342 g_debugger_properties[ePropertyPromptAnsiSuffix].name) {
346 }
else if (property_path ==
347 g_debugger_properties[ePropertyShowStatusline].name) {
358 }
else if (property_path ==
359 g_debugger_properties[ePropertyStatuslineFormat].name ||
361 g_debugger_properties[ePropertySeparator].name) {
364 }
else if (property_path ==
365 g_debugger_properties[ePropertyUseSourceCache].name) {
371 }
else if (is_load_script && target_sp &&
373 if (target_sp->TargetProperties::GetLoadScriptFromSymbolFile() ==
375 std::list<Status> errors;
376 if (!target_sp->LoadScriptingResources(errors)) {
378 for (
auto &
error : errors)
379 s->Printf(
"%s\n",
error.AsCString());
388 constexpr uint32_t idx = ePropertyAutoConfirm;
390 idx, g_debugger_properties[idx].default_uint_value != 0);
394 constexpr uint32_t idx = ePropertyDisassemblyFormat;
399 constexpr uint32_t idx = ePropertyFrameFormat;
404 constexpr uint32_t idx = ePropertyFrameFormatUnique;
409 constexpr uint32_t idx = ePropertyStopDisassemblyMaxSize;
411 idx, g_debugger_properties[idx].default_uint_value);
415 constexpr uint32_t idx = ePropertyNotiftVoid;
417 idx, g_debugger_properties[idx].default_uint_value != 0);
421 constexpr uint32_t idx = ePropertyPrompt;
423 idx, g_debugger_properties[idx].default_cstr_value);
427 const uint32_t idx = ePropertyPromptAnsiPrefix;
429 idx, g_debugger_properties[idx].default_cstr_value);
433 const uint32_t idx = ePropertyPromptAnsiSuffix;
435 idx, g_debugger_properties[idx].default_cstr_value);
439 constexpr uint32_t idx = ePropertyPrompt;
441 llvm::StringRef new_prompt =
GetPrompt();
450 constexpr uint32_t idx = ePropertyThreadFormat;
455 constexpr uint32_t idx = ePropertyThreadStopFormat;
460 const uint32_t idx = ePropertyScriptLanguage;
463 g_debugger_properties[idx].default_uint_value));
467 const uint32_t idx = ePropertyScriptLanguage;
472 const uint32_t idx = ePropertyREPLLanguage;
477 const uint32_t idx = ePropertyREPLLanguage;
482 const uint32_t idx = ePropertyTerminalWidth;
484 idx, g_debugger_properties[idx].default_uint_value);
492 const uint32_t idx = ePropertyTerminalHeight;
494 idx, g_debugger_properties[idx].default_uint_value);
502 uint64_t term_height) {
505 const bool width_success =
507 const bool height_success =
511 handler_sp->TerminalSizeChanged();
519 return width_success && height_success;
523 const uint32_t idx = ePropertyUseExternalEditor;
525 idx, g_debugger_properties[idx].default_uint_value != 0);
529 const uint32_t idx = ePropertyUseExternalEditor;
534 const uint32_t idx = ePropertyExternalEditor;
536 idx, g_debugger_properties[idx].default_cstr_value);
540 const uint32_t idx = ePropertyExternalEditor;
545 const uint32_t idx = ePropertyUseColor;
547 idx, g_debugger_properties[idx].default_uint_value != 0);
551 const uint32_t idx = ePropertyUseColor;
560 const uint32_t idx = ePropertyShowProgress;
562 idx, g_debugger_properties[idx].default_uint_value != 0);
566 const uint32_t idx = ePropertyShowProgress;
571 const uint32_t idx = ePropertyShowProgressAnsiPrefix;
573 idx, g_debugger_properties[idx].default_cstr_value);
577 const uint32_t idx = ePropertyShowProgressAnsiSuffix;
579 idx, g_debugger_properties[idx].default_cstr_value);
583 const uint32_t idx = ePropertyLabelAnsiPrefix;
585 idx, g_debugger_properties[idx].default_cstr_value);
589 const uint32_t idx = ePropertyLabelAnsiSuffix;
591 idx, g_debugger_properties[idx].default_cstr_value);
595 const uint32_t idx = ePropertyTitleAnsiPrefix;
597 idx, g_debugger_properties[idx].default_cstr_value);
601 const uint32_t idx = ePropertyTitleAnsiSuffix;
603 idx, g_debugger_properties[idx].default_cstr_value);
607 const uint32_t idx = ePropertyDividerAnsiPrefix;
609 idx, g_debugger_properties[idx].default_cstr_value);
613 const uint32_t idx = ePropertyDividerAnsiSuffix;
615 idx, g_debugger_properties[idx].default_cstr_value);
619 const uint32_t idx = ePropertyShowStatusline;
621 idx, g_debugger_properties[idx].default_uint_value != 0);
625 constexpr uint32_t idx = ePropertyStatuslineFormat;
630 constexpr uint32_t idx = ePropertyStatuslineFormat;
637 constexpr uint32_t idx = ePropertySeparator;
639 idx, g_debugger_properties[idx].default_cstr_value);
643 const uint32_t idx = ePropertyShowDisabledAnsiPrefix;
645 idx, g_debugger_properties[idx].default_cstr_value);
649 const uint32_t idx = ePropertyShowDisabledAnsiSuffix;
651 idx, g_debugger_properties[idx].default_cstr_value);
655 constexpr uint32_t idx = ePropertySeparator;
662 const uint32_t idx = ePropertyShowAutosuggestion;
665 g_debugger_properties[idx].default_uint_value));
669 const uint32_t idx = ePropertyShowAutosuggestionAnsiPrefix;
671 idx, g_debugger_properties[idx].default_cstr_value);
675 const uint32_t idx = ePropertyShowAutosuggestionAnsiSuffix;
677 idx, g_debugger_properties[idx].default_cstr_value);
681 const uint32_t idx = ePropertyShowRegexMatchAnsiPrefix;
683 idx, g_debugger_properties[idx].default_cstr_value);
687 const uint32_t idx = ePropertyShowRegexMatchAnsiSuffix;
689 idx, g_debugger_properties[idx].default_cstr_value);
693 const uint32_t idx = ePropertyShowDontUsePoHint;
695 idx, g_debugger_properties[idx].default_uint_value != 0);
699 const uint32_t idx = ePropertyUseSourceCache;
701 idx, g_debugger_properties[idx].default_uint_value != 0);
705 const uint32_t idx = ePropertyUseSourceCache;
714 const uint32_t idx = ePropertyMarkHiddenFrames;
716 idx, g_debugger_properties[idx].default_uint_value != 0);
720 const uint32_t idx = ePropertyHighlightSource;
722 idx, g_debugger_properties[idx].default_uint_value != 0);
726 const uint32_t idx = ePropertyStopShowColumn;
729 g_debugger_properties[idx].default_uint_value));
733 const uint32_t idx = ePropertyStopShowColumnAnsiPrefix;
735 idx, g_debugger_properties[idx].default_cstr_value);
739 const uint32_t idx = ePropertyStopShowColumnAnsiSuffix;
741 idx, g_debugger_properties[idx].default_cstr_value);
745 const uint32_t idx = ePropertyStopShowLineMarkerAnsiPrefix;
747 idx, g_debugger_properties[idx].default_cstr_value);
751 const uint32_t idx = ePropertyStopShowLineMarkerAnsiSuffix;
753 idx, g_debugger_properties[idx].default_cstr_value);
758 before ? ePropertyStopLineCountBefore : ePropertyStopLineCountAfter;
760 idx, g_debugger_properties[idx].default_uint_value);
764 const uint32_t idx = ePropertyStopDisassemblyDisplay;
767 g_debugger_properties[idx].default_uint_value));
771 const uint32_t idx = ePropertyStopDisassemblyCount;
773 idx, g_debugger_properties[idx].default_uint_value);
777 const uint32_t idx = ePropertyAutoOneLineSummaries;
779 idx, g_debugger_properties[idx].default_uint_value != 0);
783 const uint32_t idx = ePropertyEscapeNonPrintables;
785 idx, g_debugger_properties[idx].default_uint_value != 0);
789 const uint32_t idx = ePropertyAutoIndent;
791 idx, g_debugger_properties[idx].default_uint_value != 0);
795 const uint32_t idx = ePropertyAutoIndent;
800 const uint32_t idx = ePropertyPrintDecls;
802 idx, g_debugger_properties[idx].default_uint_value != 0);
806 const uint32_t idx = ePropertyPrintDecls;
811 const uint32_t idx = ePropertyTabSize;
813 idx, g_debugger_properties[idx].default_uint_value);
817 const uint32_t idx = ePropertyTabSize;
822 const uint32_t idx = ePropertyDWIMPrintVerbosity;
825 g_debugger_properties[idx].default_uint_value != 0));
829 const uint32_t idx = ePropertyShowInlineDiagnostics;
831 idx, g_debugger_properties[idx].default_uint_value);
835 const uint32_t idx = ePropertyShowInlineDiagnostics;
850 "Debugger::Initialize called more than once!");
853 g_thread_pool =
new llvm::DefaultThreadPool(llvm::optimal_concurrency());
859 "Debugger::Terminate called without a matching Debugger::Initialize!");
865 debugger->HandleDestroyCallback();
892 llvm::sys::DynamicLibrary dynlib =
894 if (dynlib.isValid()) {
909 llvm::StringRef path) {
912 static constexpr llvm::StringLiteral g_dylibext(
".dylib");
913 static constexpr llvm::StringLiteral g_solibext(
".so");
920 namespace fs = llvm::sys::fs;
925 if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
926 ft == fs::file_type::type_unknown) {
936 debugger->
LoadPlugin(plugin_file_spec, plugin_load_error);
939 }
else if (ft == fs::file_type::directory_file ||
940 ft == fs::file_type::symlink_file ||
941 ft == fs::file_type::type_unknown) {
953 const bool find_directories =
true;
954 const bool find_files =
true;
955 const bool find_other =
true;
957 if (
FileSpec dir_spec = HostInfo::GetSystemPluginDir()) {
959 dir_spec.GetPath(dir_path,
sizeof(dir_path))) {
961 find_files, find_other,
966 if (
FileSpec dir_spec = HostInfo::GetUserPluginDir()) {
968 dir_spec.GetPath(dir_path,
sizeof(dir_path))) {
970 find_files, find_other,
986 helper.SetDebugger(debugger_sp.get());
992 debugger_sp->InstanceInitialize();
1026 debugger_sp->HandleDestroyCallback();
1033 (*debugger_sp->GetAsyncOutputStream())
1036 (*debugger_sp->GetAsyncErrorStream()) << result.
GetErrorString() <<
'\n';
1039 debugger_sp->Clear();
1045 if ((*pos).get() == debugger_sp.get()) {
1060 if (llvm::StringRef(debugger_sp->GetInstanceName()) == instance_name)
1068 static constexpr llvm::StringLiteral class_name(
"lldb.debugger");
1098 "target",
"Settings specify to debugging targets.",
true,
1101 "platform",
"Platform settings.",
true,
1104 "symbols",
"Symbol lookup and cache settings.",
true,
1110 "diagnostics",
"Diagnostics settings.",
true,
1115 "Settings specify to the debugger's command interpreter.",
true,
1120 "testing",
"Testing-only settings.",
true,
1126 std::make_shared<CallbackLogHandler>(log_callback, baton);
1130 assert(default_platform_sp);
1137 arch = HostInfo::GetArchitecture();
1138 assert(arch.
IsValid() &&
"No valid default or host archspec");
1139 const bool is_dummy_target =
true;
1141 new Target(*
this, arch, default_platform_sp, is_dummy_target));
1147 ePropertyTerminalWidth);
1152 ePropertyTerminalHeight);
1156 const char *term = getenv(
"TERM");
1157 auto disable_color = [&]() {
1162 if (term && !strcmp(term,
"dumb"))
1168#if defined(_WIN32) && defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING)
1171 llvm::sys::Process::UseANSIEscapeCodes(
true);
1200 if (
ProcessSP process_sp = target_sp->GetProcessSP())
1201 process_sp->Finalize(
false );
1202 target_sp->Destroy();
1225static inline int OpenPipe(
int fds[2], std::size_t size) {
1227 return _pipe(fds, size, O_BINARY);
1237 int fds[2] = {-1, -1};
1239 if (data ==
nullptr) {
1244 size_t size = strlen(data);
1252 "can't create pipe file descriptors for LLDB commands");
1256 int r = write(fds[
WRITE], data, size);
1260 llvm::sys::Process::SafelyCloseFileDescriptor(fds[
WRITE]);
1264 FILE *commands_file = fdopen(fds[
READ],
"rb");
1265 if (commands_file ==
nullptr) {
1267 "fdopen(%i, \"rb\") failed (errno = %i) "
1268 "when trying to open LLDB commands pipe",
1270 llvm::sys::Process::SafelyCloseFileDescriptor(fds[
READ]);
1280 assert(file_sp && file_sp->IsValid());
1288 assert(file_sp && file_sp->IsValid());
1294 assert(file_sp && file_sp->IsValid());
1321 std::optional<ExecutionContextRef> exe_ctx_ref) {
1346 if (adopt_dummy_target)
1357 reader_sp->Interrupt();
1364 reader_sp->GotEOF();
1386 std::lock_guard<std::recursive_mutex> guard(
1392 if (top_reader_sp && top_reader_sp->GetIsDone())
1409 while (top_reader_sp) {
1410 top_reader_sp->Run();
1413 if (top_reader_sp.get() == reader_sp.get()) {
1422 if (top_reader_sp && top_reader_sp->GetIsDone()) {
1425 if (top_reader_sp.get() == reader_sp.get())
1449 locked_stream.
Write(s, len);
1470 bool cancel_top_handler) {
1485 if (!in || !in->IsValid()) {
1487 in = top_reader_sp->GetInputFileSP();
1496 if (!out || !out->GetUnlockedFile().IsValid()) {
1498 out = top_reader_sp->GetOutputStreamFileSP();
1507 if (!err || !err->GetUnlockedFile().IsValid()) {
1509 err = top_reader_sp->GetErrorStreamFileSP();
1520 bool cancel_top_handler) {
1530 if (reader_sp == top_reader_sp)
1535 reader_sp->Activate();
1539 if (top_reader_sp) {
1540 top_reader_sp->Deactivate();
1541 if (cancel_top_handler)
1542 top_reader_sp->Cancel();
1559 if (pop_reader_sp != reader_sp)
1562 reader_sp->Deactivate();
1563 reader_sp->Cancel();
1568 reader_sp->Activate();
1577 reader_sp->Refresh();
1581 return std::make_unique<StreamAsynchronousIO>(*
this,
1586 return std::make_unique<StreamAsynchronousIO>(*
this,
1614 std::string function_name,
const llvm::formatv_object_base &payload)
1619 desc << payload <<
"\n";
1633 if (debugger_sp->InterruptRequested())
1634 result.push_back(debugger_sp);
1653 if (index < g_debugger_list_ptr->size())
1673 if (debugger_sp->GetID() ==
id)
1687 if (format ==
nullptr) {
1691 format = &format_entry;
1693 if (format ==
nullptr) {
1695 format = &format_entry;
1698 bool function_changed =
false;
1699 bool initial_function =
false;
1705 function_changed =
true;
1709 function_changed =
true;
1719 initial_function =
true;
1727 llvm::StringRef backtrace,
1728 llvm::StringRef prompt) {
1742 std::make_shared<CallbackLogHandler>(log_callback, baton);
1745std::vector<std::string>
1747 std::vector<std::string> copied;
1749 llvm::StringRef log_path = entry.first();
1750 llvm::StringRef file_name = llvm::sys::path::filename(log_path);
1753 if (!llvm::sys::fs::copy_file(log_path, destination.
GetPath()))
1754 copied.push_back(file_name.str());
1779 if (it->token == token) {
1788 std::string title, std::string details,
1789 uint64_t completed, uint64_t total,
1790 bool is_debugger_specific,
1791 uint32_t progress_broadcast_bit) {
1797 progress_broadcast_bit,
1799 completed, total, is_debugger_specific)));
1804 std::string details, uint64_t completed,
1806 std::optional<lldb::user_id_t> debugger_id,
1807 uint32_t progress_broadcast_bit) {
1815 std::move(details), completed, total,
1817 progress_broadcast_bit);
1828 progress_broadcast_bit);
1833 std::string message,
bool debugger_specific,
1834 bool internal_error) {
1835 uint32_t event_type = 0;
1838 assert(
false &&
"eSeverityInfo should not be broadcast");
1860 EventSP event_sp = std::make_shared<Event>(
1867 std::optional<lldb::user_id_t> debugger_id,
1868 std::once_flag *once,
bool internal_error) {
1869 auto ReportDiagnosticLambda = [&]() {
1889 true, internal_error);
1903 std::call_once(*once, ReportDiagnosticLambda);
1905 ReportDiagnosticLambda();
1909 std::optional<lldb::user_id_t> debugger_id,
1910 std::once_flag *once) {
1915 std::optional<lldb::user_id_t> debugger_id,
1916 std::once_flag *once) {
1921 std::optional<lldb::user_id_t> debugger_id,
1922 std::once_flag *once) {
1938 std::optional<lldb::user_id_t> debugger_id,
1939 std::once_flag *once) {
1949 EventSP event_sp = std::make_shared<Event>(
1952 debugger_sp->GetBroadcaster().BroadcastEvent(event_sp);
1956static std::shared_ptr<LogHandler>
1958 size_t buffer_size) {
1959 switch (log_handler_kind) {
1961 return std::make_shared<StreamLogHandler>(fd, should_close, buffer_size);
1963 return std::make_shared<RotatingLogHandler>(buffer_size);
1965 return std::make_shared<SystemLogHandler>();
1973 llvm::ArrayRef<const char *> categories,
1974 llvm::StringRef log_file, uint32_t log_options,
1978 std::shared_ptr<LogHandler> log_handler_sp;
1984 }
else if (log_file.empty()) {
1987 false, buffer_size);
1991 log_handler_sp = pos->second.lock();
1992 if (!log_handler_sp) {
2000 FileSpec(log_file), flags, lldb::eFilePermissionsFileDefault,
false);
2002 return llvm::createStringErrorV(
"Unable to open log file '{}': {}",
2004 llvm::fmt_consume(file.takeError()));
2012 assert(log_handler_sp);
2014 if (log_options == 0)
2023 std::optional<lldb::ScriptLanguage> language) {
2046 using namespace lldb;
2047 const uint32_t event_type =
2064 if (event_type & eBreakpointEventTypeLocationsAdded) {
2065 uint32_t num_new_locations =
2068 if (num_new_locations > 0) {
2072 output_up->Printf(
"%d location%s added to breakpoint %d\n",
2073 num_new_locations, num_new_locations == 1 ?
"" :
"s",
2074 breakpoint->GetID());
2092 bool flush_stderr) {
2093 const auto &flush = [&](
Stream &stream,
2098 while ((len = (process.*get)(buffer,
sizeof(buffer),
error)) > 0)
2099 stream.
Write(buffer, len);
2112 const uint32_t event_type = event_sp->GetType();
2123 bool pop_process_io_handler =
false;
2126 bool state_is_stopped =
false;
2127 const bool got_state_changed =
2131 const bool got_structured_data =
2134 if (got_state_changed) {
2141 if (got_state_changed && !state_is_stopped) {
2146 pop_process_io_handler);
2151 got_stderr || got_state_changed);
2154 if (got_structured_data) {
2158 auto structured_data_sp =
2162 plugin_sp->GetDescription(structured_data_sp, content_stream);
2163 if (
error.Success()) {
2164 if (!content_stream.
GetString().empty()) {
2167 content_stream.
Flush();
2170 output_stream_up->PutCString(content_stream.
GetString());
2173 error_stream_up->Format(
"Failed to print structured "
2174 "data with plugin {0}: {1}",
2175 plugin_sp->GetPluginName(),
error);
2181 if (got_state_changed && state_is_stopped) {
2184 pop_process_io_handler);
2187 output_stream_up->Flush();
2188 error_stream_up->Flush();
2190 if (pop_process_io_handler)
2191 process_sp->PopProcessIOHandler();
2199 const uint32_t event_type = event_sp->GetType();
2200 const bool stop_format =
true;
2230 static std::once_flag g_once_flag;
2231 static bool g_supports_osc_progress =
false;
2233 std::call_once(g_once_flag, []() {
2236 if (
const char *term_program = std::getenv(
"TERM_PROGRAM")) {
2237 llvm::StringRef term_program_str(term_program);
2238 if (term_program_str.starts_with(
"ghostty") ||
2239 term_program_str.starts_with(
"wezterm")) {
2240 g_supports_osc_progress =
true;
2246 std::array<const char *, 3> known_env_vars = {
2248 "GHOSTTY_RESOURCES_DIR",
2251 for (
const char *env_var : known_env_vars) {
2252 if (std::getenv(env_var)) {
2253 g_supports_osc_progress =
true;
2259 return g_supports_osc_progress;
2265 File &file = stream_sp->GetUnlockedFile();
2290 llvm::StringRef broadcaster_class_process(
2297 broadcaster_class_process,
2308 process_event_spec);
2311 listener_sp->StartListeningForEvents(
2317 listener_sp->StartListeningForEvents(
2339 if (listener_sp->GetEvent(event_sp, std::nullopt)) {
2340 std::optional<ExecutionContextRef> exe_ctx_ref = std::nullopt;
2342 Broadcaster *broadcaster = event_sp->GetBroadcaster();
2344 uint32_t event_type = event_sp->GetType();
2346 if (broadcaster_class == broadcaster_class_process) {
2352 const bool adopt_selected =
2360 }
else if (broadcaster_class == broadcaster_class_target) {
2365 }
else if (broadcaster_class == broadcaster_class_thread) {
2374 }
else if (event_type &
2376 const char *data =
static_cast<const char *
>(
2378 if (data && data[0]) {
2380 error_up->PutCString(data);
2384 eBroadcastBitAsynchronousOutputData) {
2385 const char *data =
static_cast<const char *
>(
2387 if (data && data[0]) {
2389 output_up->PutCString(data);
2426 llvm::StringRef full_name(
"lldb.debugger.event-handler");
2431 llvm::StringRef thread_name =
2432 full_name.size() < llvm::get_max_thread_name_length()
2434 :
"dbg.evt-handler";
2437 llvm::Expected<HostThread> event_handler_thread =
2442 if (event_handler_thread) {
2446 "failed to launch host thread: {0}");
2455 listener_sp->GetEvent(event_sp, std::nullopt);
2480 ProgressReport progress_report{data->GetID(), data->GetCompleted(),
2481 data->GetTotal(), data->GetMessage()};
2489 return report.id == progress_report.
id;
2492 const bool complete = data->GetCompleted() == data->GetTotal();
2496 *it = progress_report;
2528std::optional<Debugger::ProgressReport>
2532 return std::nullopt;
2559 if (io_handler_thread) {
2563 "failed to launch host thread: {0}");
2591 if (!prefer_dummy) {
2609 language = *single_lang;
2610 }
else if (repl_languages.
Empty()) {
2612 "LLDB isn't configured with REPL support for any languages.");
2616 "Multiple possible REPL languages. Please specify a language.");
2632 "couldn't find a REPL for %s",
2637 repl_sp->SetCompilerOptions(repl_options);
2645 "Debugger::GetThreadPool called before Debugger::Initialize");
2650 llvm::StringRef name,
bool value,
2651 llvm::StringRef description) {
2652 auto entry_up = std::make_unique<StructuredData::Dictionary>();
2653 entry_up->AddBooleanItem(
"value", value);
2654 entry_up->AddStringItem(
"description", description);
2655 dict.
AddItem(name, std::move(entry_up));
2659 auto array_up = std::make_unique<StructuredData::Array>();
2660#define LLVM_TARGET(target) \
2661 array_up->AddItem(std::make_unique<StructuredData::String>(#target));
2662#include "llvm/Config/Targets.def"
2663 auto entry_up = std::make_unique<StructuredData::Dictionary>();
2664 entry_up->AddItem(
"value", std::move(array_up));
2665 entry_up->AddStringItem(
"description",
"A list of configured LLVM targets.");
2666 dict.
AddItem(
"targets", std::move(entry_up));
2670 auto config_up = std::make_unique<StructuredData::Dictionary>();
2673 "A boolean value that indicates if XML support is enabled in LLDB");
2675 *config_up,
"curl", LLVM_ENABLE_CURL,
2676 "A boolean value that indicates if CURL support is enabled in LLDB");
2678 *config_up,
"curses", LLDB_ENABLE_CURSES,
2679 "A boolean value that indicates if curses support is enabled in LLDB");
2681 *config_up,
"editline", LLDB_ENABLE_LIBEDIT,
2682 "A boolean value that indicates if editline support is enabled in LLDB");
2684 "A boolean value that indicates if editline wide "
2685 "characters support is enabled in LLDB");
2687 *config_up,
"zlib", LLVM_ENABLE_ZLIB,
2688 "A boolean value that indicates if zlib support is enabled in LLDB");
2690 *config_up,
"lzma", LLVM_ENABLE_LZMA,
2691 "A boolean value that indicates if lzma support is enabled in LLDB");
2693 *config_up,
"python", LLDB_ENABLE_PYTHON,
2694 "A boolean value that indicates if python support is enabled in LLDB");
2696 *config_up,
"lua", LLDB_ENABLE_LUA,
2697 "A boolean value that indicates if lua support is enabled in LLDB");
#define OSC_PROGRESS_REMOVE
#define OSC_PROGRESS_INDETERMINATE
#define OSC_PROGRESS_SHOW
static llvm::raw_ostream & error(Stream &strm)
static bool RequiresFollowChildWorkaround(const Process &process)
static llvm::DefaultThreadPool * g_thread_pool
static constexpr OptionEnumValueElement g_show_disassembly_enum_values[]
static bool TerminalSupportsOSCProgress()
Conservative heuristic to detect whether OSC 9;4 progress is supported by the current terminal.
static lldb::user_id_t g_unique_id
static constexpr OptionEnumValueElement g_language_enumerators[]
static constexpr OptionEnumValueElement g_dwim_print_verbosities[]
static constexpr OptionEnumValueElement s_stop_show_column_values[]
static void PrivateReportProgress(Debugger &debugger, uint64_t progress_id, std::string title, std::string details, uint64_t completed, uint64_t total, bool is_debugger_specific, uint32_t progress_broadcast_bit)
static void PrivateReportDiagnostic(Debugger &debugger, Severity severity, std::string message, bool debugger_specific, bool internal_error)
static Debugger::DebuggerList * g_debugger_list_ptr
static int OpenPipe(int fds[2], std::size_t size)
static size_t g_debugger_event_thread_stack_bytes
static constexpr OptionEnumValueElement g_show_autosuggestion_enum_values[]
static std::mutex & GetDebuggerListMutex()
static FileSystem::EnumerateDirectoryResult LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path)
static std::shared_ptr< LogHandler > CreateLogHandler(LogHandlerKind log_handler_kind, int fd, bool should_close, size_t buffer_size)
static void AddBoolConfigEntry(StructuredData::Dictionary &dict, llvm::StringRef name, bool value, llvm::StringRef description)
static void AddLLVMTargets(StructuredData::Dictionary &dict)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOG_OPTION_APPEND
#define LLDB_LOG_ERROR(log, error,...)
#define LLDB_LOG_OPTION_PREPEND_TIMESTAMP
#define LLDB_LOG_OPTION_PREPEND_THREAD_NAME
A section + offset based address class.
An architecture specification class.
bool IsValid() const
Tests if this ArchSpec is valid.
static lldb::BreakpointEventType GetBreakpointEventTypeFromEvent(const lldb::EventSP &event_sp)
static lldb::BreakpointSP GetBreakpointFromEvent(const lldb::EventSP &event_sp)
static const BreakpointEventData * GetEventDataFromEvent(const Event *event_sp)
static size_t GetNumBreakpointLocationsFromEvent(const lldb::EventSP &event_sp)
An event broadcasting class.
bool EventTypeHasListeners(uint32_t event_type)
virtual llvm::StringRef GetBroadcasterClass() const
This needs to be filled in if you are going to register the broadcaster with the broadcaster manager ...
void BroadcastEvent(lldb::EventSP &event_sp)
Broadcast an event which has no associated data.
void UpdatePrompt(llvm::StringRef prompt)
void UpdateUseColor(bool use_color)
@ eBroadcastBitAsynchronousOutputData
@ eBroadcastBitQuitCommandReceived
@ eBroadcastBitAsynchronousErrorData
@ eBroadcastBitResetPrompt
bool WasInterrupted() const
bool SaveTranscript(CommandReturnObject &result, std::optional< std::string > output_file=std::nullopt)
Save the current debugger session transcript to a file on disk.
bool GetSaveSessionOnQuit() const
std::string GetErrorString(bool with_diagnostics=true) const
Return the errors as a string.
llvm::StringRef GetOutputString() const
static void ForceUpdate()
std::string m_function_name
const std::chrono::time_point< std::chrono::system_clock > m_interrupt_time
const uint64_t m_thread_id
InterruptionReport(std::string function_name, std::string description)
std::string m_description
A class to manage flag bits.
static void AssertCallback(llvm::StringRef message, llvm::StringRef backtrace, llvm::StringRef prompt)
llvm::StringRef GetAutosuggestionAnsiPrefix() const
bool SetUseExternalEditor(bool use_external_editor_p)
PlatformList m_platform_list
HostThread m_event_handler_thread
FormatEntity::Entry GetDisassemblyFormat() const
uint64_t GetDisassemblyLineCount() const
llvm::StringRef GetDisabledAnsiSuffix() const
uint64_t GetTerminalHeight() const
lldb::LockableStreamFileSP m_output_stream_sp
bool SetExternalEditor(llvm::StringRef editor)
void RequestInterrupt()
Interruption in LLDB:
void ReportInterruption(const InterruptionReport &report)
const std::string m_instance_name
lldb::ThreadSP HandleThreadEvent(const lldb::EventSP &event_sp)
void HandleProgressEvent(const lldb::EventSP &event_sp)
SourceManager & GetSourceManager()
bool SetTerminalDimensions(uint64_t term_width, uint64_t term_height)
Set the terminal width and height together, so observers are notified once with both dimensions curre...
bool SetShowProgress(bool show_progress)
bool StartEventHandlerThread()
Manually start the global event handler thread.
bool SetUseSourceCache(bool use_source_cache)
static const FileSpecList & GetDefaultSafeAutoLoadPaths()
void StopEventHandlerThread()
Manually stop the debugger's default event handler.
static void ReportInternalError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report an error that may be a bug in LLDB.
static void ReportInfo(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report info events.
void SetAsyncExecution(bool async)
ExecutionContext GetSelectedExecutionContext(bool adopt_dummy_target)
Get the execution context representing the selected entities in the selected target.
HostThread SetIOHandlerThread(HostThread &new_thread)
void CancelForwardEvents(const lldb::ListenerSP &listener_sp)
bool GetPrintDecls() const
lldb::FileSP GetInputFileSP()
void StopIOHandlerThread()
bool GetHighlightSource() const
llvm::StringMap< std::weak_ptr< LogHandler > > m_stream_handlers
bool IsEscapeCodeCapableTTY()
llvm::StringRef GetLabelAnsiSuffix() const
CommandInterpreter & GetCommandInterpreter()
FormatEntity::Entry GetStatuslineFormat() const
void SaveInputTerminalState()
llvm::StringRef GetDividerAnsiPrefix() const
LoadedPluginsList m_loaded_plugins
bool GetShowInlineDiagnostics() const
void InstanceInitialize()
bool SetTabSize(uint64_t tab_size)
void HandleDiagnosticEvent(const lldb::EventSP &event_sp)
bool StartIOHandlerThread()
static lldb::DebuggerSP GetDebuggerAtIndex(size_t index)
llvm::StringRef GetAutosuggestionAnsiSuffix() const
lldb::ListenerSP m_listener_sp
void PushIOHandler(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
std::mutex m_destroy_callback_mutex
lldb::callback_token_t AddDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton)
Add a callback for when the debugger is destroyed.
lldb::thread_result_t IOHandlerThread()
FormatEntity::Entry GetFrameFormatUnique() const
std::optional< ProgressReport > GetCurrentProgressReport() const
llvm::StringRef GetDisabledAnsiPrefix() const
bool GetUseExternalEditor() const
TerminalState m_terminal_state
lldb::StreamUP GetAsyncErrorStream()
bool InterruptRequested()
bool GetEscapeNonPrintables() const
bool ShouldSuggestBugReport(llvm::StringRef failure)
Returns true the first time this debugger sees failure while diagnostics.suggest-bugreport is on.
lldb::TargetSP m_dummy_target_sp
llvm::SmallVector< DestroyCallbackInfo, 2 > m_destroy_callbacks
std::unique_ptr< CommandInterpreter > m_command_interpreter_up
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
static bool FormatDisassemblerAddress(const FormatEntity::Entry *format, const SymbolContext *sc, const SymbolContext *prev_sc, const ExecutionContext *exe_ctx, const Address *addr, Stream &s)
static void SettingsInitialize()
LockableStreamFile::Mutex m_output_mutex
static llvm::ThreadPoolInterface & GetThreadPool()
Shared thread pool. Use only with ThreadPoolTaskGroup.
llvm::StringRef GetShowProgressAnsiSuffix() const
bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp)
bool HasIOHandlerThread() const
void DispatchInputEndOfFile()
llvm::SmallVector< ProgressReport, 4 > m_progress_reports
Bookkeeping for command line progress events.
bool IsIOHandlerThreadCurrentThread() const
ExecutionContextRef GetSelectedExecutionContextRef(bool adopt_dummy_target)
Like GetSelectedExecutionContext but returns an ExecutionContextRef.
void DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry)
std::mutex m_progress_reports_mutex
lldb::ProcessSP HandleProcessEvent(const lldb::EventSP &event_sp)
lldb::ListenerSP m_forward_listener_sp
std::array< lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown > m_script_interpreters
std::atomic< bool > m_flush_statusline
Raised by FlushStatusLine to request a flush at the next redraw.
LockingAdaptedIterable< std::mutex, DebuggerList > DebuggerIterable
std::shared_ptr< CallbackLogHandler > m_callback_handler_sp
void SetDestroyCallback(lldb_private::DebuggerDestroyCallback destroy_callback, void *baton)
DEPRECATED: We used to only support one Destroy callback.
lldb::FileSP GetOutputFileSP()
Broadcaster m_broadcaster
Public Debugger event broadcaster.
void DispatchInputInterrupt()
static void Initialize(LoadPluginCallbackType load_plugin_callback)
static lldb::DebuggerSP FindDebuggerWithInstanceName(llvm::StringRef instance_name)
uint64_t GetTerminalWidth() const
std::mutex m_interrupt_mutex
std::recursive_mutex m_io_handler_synchronous_mutex
bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp)
Remove the given IO handler if it's currently active.
bool GetAutoOneLineSummaries() const
const char * GetIOHandlerCommandPrefix()
std::optional< Statusline > m_statusline
llvm::StringRef GetDividerAnsiSuffix() const
ThreadSafeDenseSet< llvm::stable_hash > m_suggested_bugreports
Hashes of the failures this debugger already suggested 'bugreport' for.
llvm::StringRef GetTitleAnsiPrefix() const
lldb::BroadcasterManagerSP m_broadcaster_manager_sp
void FlushStatusLine()
Discard the statusline's cached frame at its next redraw.
Status RunREPL(lldb::LanguageType language, const char *repl_options)
bool PopIOHandler(const lldb::IOHandlerSP &reader_sp)
static StructuredData::DictionarySP GetBuildConfiguration()
Get the build configuration as structured data.
bool RemoveDestroyCallback(lldb::callback_token_t token)
Remove the specified callback. Return true if successful.
static LoadPluginCallbackType g_load_plugin_callback
bool GetShowStatusline() const
std::recursive_mutex m_script_interpreter_mutex
void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Run the given IO handler and return immediately.
void SetInputFile(lldb::FileSP file)
lldb::LockableStreamFileSP GetOutputStreamSP()
Except for Debugger and IOHandler, GetOutputStreamSP and GetErrorStreamSP should not be used directly...
void SuggestBugReport(llvm::StringRef failure, Stream &strm)
Writes the 'bugreport' note to strm if ShouldSuggestBugReport.
void SetPrompt(llvm::StringRef p)
llvm::StringRef GetSeparator() const
bool StatuslineSupported()
Whether the statusline can be drawn: show-statusline is enabled and the output is an escape-code-capa...
uint64_t GetStopDisassemblyMaxSize() const
bool SetTerminalHeight(uint64_t term_height)
Broadcaster m_sync_broadcaster
Private debugger synchronization.
static DebuggerIterable Debuggers()
Get locking iterator for debuggers.
llvm::StringRef GetTitleAnsiSuffix() const
void RestoreInputTerminalState()
bool GetUseSourceCache() const
HostThread m_io_handler_thread
llvm::StringRef GetRegexMatchAnsiSuffix() const
static llvm::StringRef GetStaticBroadcasterClass()
lldb::FileSP m_input_file_sp
bool SetREPLLanguage(lldb::LanguageType repl_lang)
@ eBroadcastBitEventThreadIsListening
bool GetAutoIndent() const
AutosuggestionMode GetAutosuggestionMode() const
llvm::StringRef GetStopShowColumnAnsiSuffix() const
Status SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef property_path, llvm::StringRef value) override
llvm::StringRef GetPromptAnsiSuffix() const
FormatEntity::Entry GetThreadStopFormat() const
void SetErrorFile(lldb::FileSP file)
bool GetAutoConfirm() const
lldb::ScriptLanguage GetScriptLanguage() const
lldb::callback_token_t m_destroy_callback_next_token
std::unique_ptr< SourceManager > m_source_manager_up
static lldb::DebuggerSP CreateInstance(lldb::LogOutputCallback log_callback=nullptr, void *baton=nullptr)
lldb::StopShowColumn GetStopShowColumn() const
static void ReportSymbolChange(const ModuleSpec &module_spec)
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
bool SetPrintDecls(bool b)
bool SetScriptLanguage(lldb::ScriptLanguage script_lang)
lldb::LockableStreamFileSP m_error_stream_sp
bool SetShowInlineDiagnostics(bool)
bool LoadPlugin(const FileSpec &spec, Status &error)
void SetOutputFile(lldb::FileSP file)
uint64_t GetStopSourceLineCount(bool before) const
bool SetStatuslineFormat(const FormatEntity::Entry &format)
void EnableForwardEvents(const lldb::ListenerSP &listener_sp)
static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id)
void HandleBreakpointEvent(const lldb::EventSP &event_sp)
void JoinIOHandlerThread()
bool CheckTopIOHandlerTypes(IOHandler::Type top_type, IOHandler::Type second_top_type)
Target & GetDummyTarget()
TargetGroupList m_target_group_list
lldb::ListenerSP GetListener()
static void Destroy(lldb::DebuggerSP &debugger_sp)
SourceManager::SourceFileCache m_source_file_cache
llvm::StringRef GetPromptAnsiPrefix() const
lldb::StreamUP GetAsyncOutputStream()
void RedrawStatusline(std::optional< ExecutionContextRef > exe_ctx_ref)
Redraw the statusline if enabled.
void RunIOHandlerSync(const lldb::IOHandlerSP &reader_sp)
Run the given IO handler and block until it's complete.
Broadcaster & GetBroadcaster()
Get the public broadcaster for this debugger.
llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const
bool GetShowDontUsePoHint() const
uint64_t GetTabSize() const
bool GetShowProgress() const
llvm::StringRef GetRegexMatchAnsiPrefix() const
void HandleDestroyCallback()
std::mutex m_output_flush_mutex
llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const
static void ReportDiagnosticImpl(lldb::Severity severity, std::string message, std::optional< lldb::user_id_t > debugger_id, std::once_flag *once, bool internal_error=false)
bool SetSeparator(llvm::StringRef s)
bool SetUseColor(bool use_color)
std::mutex m_statusline_mutex
Mutex protecting the m_statusline member.
const char * GetIOHandlerHelpPrologue()
Status SetInputString(const char *data)
llvm::StringRef GetLabelAnsiPrefix() const
Target & GetSelectedOrDummyTarget(bool prefer_dummy=false)
std::vector< std::string > CopyLogFilesToDirectory(const FileSpec &dir)
Copy this debugger's file-backed log files into the given directory, for inclusion in a diagnostics b...
IOHandlerStack m_io_handler_stack
llvm::once_flag m_clear_once
static void SettingsTerminate()
static void ReportProgress(uint64_t progress_id, std::string title, std::string details, uint64_t completed, uint64_t total, std::optional< lldb::user_id_t > debugger_id, uint32_t progress_category_bit=lldb::eBroadcastBitProgress)
Report progress events.
lldb::LanguageType GetREPLLanguage() const
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton)
bool SetTerminalWidth(uint64_t term_width)
Debugger(lldb::LogOutputCallback m_log_callback, void *baton)
llvm::StringRef GetExternalEditor() const
static size_t GetNumDebuggers()
FormatEntity::Entry GetThreadFormat() const
uint32_t m_interrupt_requested
Tracks interrupt requests.
lldb::DWIMPrintVerbosity GetDWIMPrintVerbosity() const
bool GetMarkHiddenFrames() const
lldb::thread_result_t DefaultEventHandler()
void PrintAsync(const char *s, size_t len, bool is_stdout)
lldb::LockableStreamFileSP GetErrorStreamSP()
llvm::Error EnableLog(llvm::StringRef channel, llvm::ArrayRef< const char * > categories, llvm::StringRef log_file, uint32_t log_options, size_t buffer_size, LogHandlerKind log_handler_kind)
bool IsForwardingEvents()
llvm::StringRef GetPrompt() const
bool GetNotifyVoid() const
llvm::StringRef GetShowProgressAnsiPrefix() const
void AdoptTopIOHandlerFilesIfInvalid(lldb::FileSP &in, lldb::LockableStreamFileSP &out, lldb::LockableStreamFileSP &err)
FormatEntity::Entry GetFrameFormat() const
lldb::StopDisassemblyType GetStopDisassemblyDisplay() const
llvm::StringRef GetTopIOHandlerControlSequence(char ch)
void FlushProcessOutput(Process &process, bool flush_stdout, bool flush_stderr)
Force flushing the process's pending stdout and stderr to the debugger's asynchronous stdout and stde...
void CancelInterruptRequest()
Decrement the "interrupt requested" counter.
std::vector< lldb::DebuggerSP > DebuggerList
bool SetAutoIndent(bool b)
friend class CommandInterpreter
llvm::StringRef GetStopShowColumnAnsiPrefix() const
static DebuggerList DebuggersRequestingInterruption()
void Dump(Stream *s) const override
static const DiagnosticEventData * GetEventDataFromEvent(const Event *event_ptr)
bool GetSuggestBugReport() const
static DiagnosticsProperties & GetGlobalProperties()
void Record(llvm::StringRef message)
Record a diagnostic message into the always-on, in-memory log.
static Diagnostics & Instance()
static const void * GetBytesFromEvent(const Event *event_ptr)
static lldb::ProcessSP GetProcessFromEvent(const Event *event_ptr)
static lldb::StructuredDataPluginSP GetPluginFromEvent(const Event *event_ptr)
static StructuredData::ObjectSP GetObjectFromEvent(const Event *event_ptr)
Execution context objects refer to objects in the execution of the program that is being debugged.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
bool HasTargetScope() const
Returns true the ExecutionContext object contains a valid target.
Target & GetTargetRef() const
Returns a reference to the target object.
void EmplaceBack(Args &&...args)
Inserts a new FileSpec into the FileSpecList constructed in-place with the given arguments.
FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
llvm::StringRef GetFileNameExtension() const
Extract the extension of the file.
void EnumerateDirectory(llvm::Twine path, bool find_directories, bool find_files, bool find_other, EnumerateDirectoryCallbackType callback, void *callback_baton)
@ eEnumerateDirectoryResultEnter
Recurse into the current entry if it is a directory or symlink, or next if not.
@ eEnumerateDirectoryResultNext
Enumerate next entry in the current directory.
@ eEnumerateDirectoryResultQuit
Stop directory enumerations at any level.
int Open(const char *path, int flags, int mode=0600)
Wraps open in a platform-independent way.
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
An abstract base class for files.
bool GetIsRealTerminal()
Return true if this file from a real terminal.
static int kInvalidDescriptor
virtual int GetDescriptor() const
Get underlying OS file descriptor for this file, or kInvalidDescriptor.
bool GetIsTerminalWithColors()
Return true if this file is a terminal which supports colors.
Status Close() override
Flush any buffers and release any resources owned by the file.
bool GetIsInteractive()
Return true if this file is interactive.
const Mangled & GetMangled() const
static void SystemLog(lldb::Severity severity, llvm::StringRef message)
Emit the given message to the operating system log.
static lldb::thread_t GetCurrentThread()
Get the thread token (the one returned by ThreadCreate when the thread was created) for the calling t...
static llvm::StringRef GetSettingName()
static LanguageSet GetLanguagesSupportingREPLs()
static std::string GetVersionWithLanguageInfo()
Returns lldb_private::GetVersion(), followed by the GetVersionInfo() of each registered language plug...
static const char * GetNameForLanguageType(lldb::LanguageType language)
Returns the internal LLDB name for the specified language.
static LanguageProperties & GetGlobalLanguageProperties()
static lldb::ListenerSP MakeListener(llvm::StringRef name)
static llvm::Error EnableLogChannel(const std::shared_ptr< LogHandler > &log_handler_sp, uint32_t log_options, llvm::StringRef channel, llvm::ArrayRef< const char * > categories)
static ModuleListProperties & GetGlobalModuleListProperties()
void AppendCurrentValue(const FileSpec &value)
void SetCurrentValue(const FileSpecList &value)
void SetMinimumValue(uint64_t v)
static lldb::ScriptInterpreterSP GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang, Debugger &debugger)
static void DebuggerInitialize(Debugger &debugger)
FollowForkMode GetFollowForkMode() const
static bool GetRestartedFromEvent(const Event *event_ptr)
static lldb::ProcessSP GetProcessFromEvent(const Event *event_ptr)
static lldb::StateType GetStateFromEvent(const Event *event_ptr)
A plug-in interface definition class for debugging a process.
static bool HandleProcessStateChangedEvent(const lldb::EventSP &event_sp, Stream *stream, SelectMostRelevant select_most_relevant, bool &pop_process_io_handler)
Centralize the code that handles and prints descriptions for process state changes.
static llvm::StringRef GetStaticBroadcasterClass()
@ eBroadcastBitStructuredData
@ eBroadcastBitStateChanged
virtual size_t GetSTDERR(char *buf, size_t buf_size, Status &error)
Get any available STDERR.
virtual size_t GetSTDOUT(char *buf, size_t buf_size, Status &error)
Get any available STDOUT.
static const ProgressEventData * GetEventDataFromEvent(const Event *event_ptr)
lldb::OptionValuePropertiesSP m_collection_sp
virtual Status SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef property_path, llvm::StringRef value)
T GetPropertyAtIndexAs(uint32_t idx, T default_value, const ExecutionContext *exe_ctx=nullptr) const
bool SetPropertyAtIndex(uint32_t idx, T t, const ExecutionContext *exe_ctx=nullptr) const
lldb::OptionValuePropertiesSP GetValueProperties() const
static lldb::REPLSP Create(Status &Status, lldb::LanguageType language, Debugger *debugger, Target *target, const char *repl_options)
Get a REPL with an existing target (or, failing that, a debugger to use), and (optional) extra argume...
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
bool Success() const
Test for success condition.
void Flush() override
Flush the stream.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
virtual void Flush()=0
Flush the stream.
void AddItem(llvm::StringRef key, ObjectSP value_sp)
std::shared_ptr< Dictionary > DictionarySP
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
Symbol * symbol
The Symbol for a given query.
bool Compare(ConstString name, lldb::SymbolType type) const
ConstString GetName() const
lldb::SymbolType GetType() const
Debugger & GetDebugger() const
static void SettingsTerminate()
static llvm::StringRef GetStaticBroadcasterClass()
static TargetProperties & GetGlobalProperties()
static ArchSpec GetDefaultArchitecture()
@ eBroadcastBitBreakpointChanged
static void SettingsInitialize()
static llvm::Expected< HostThread > LaunchThread(llvm::StringRef name, std::function< lldb::thread_result_t()> thread_function, size_t min_stack_byte_size=0)
static lldb::ThreadSP GetThreadFromEvent(const Event *event_ptr)
@ eBroadcastBitThreadSelected
@ eBroadcastBitStackChanged
static llvm::StringRef GetStaticBroadcasterClass()
virtual void DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry, Debugger *debugger)
static TelemetryManager * GetInstance()
@ SelectMostRelevantFrame
#define LLDB_INVALID_HOST_THREAD
std::string FormatAnsiTerminalCodes(llvm::StringRef format, bool do_color=true)
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.
@ eLoadScriptFromSymFileTrue
@ eLoadScriptFromSymFileFalse
@ eLoadScriptFromSymFileWarn
const char * GetVersion()
Retrieves a string representing the LLDB version, which includes the lldb version number,...
void(* DebuggerDestroyCallback)(lldb::user_id_t debugger_id, void *baton)
bool StateIsStoppedState(lldb::StateType state, bool must_exist)
Check if a state represents a state where the process or thread is stopped.
NativeFilePosix NativeFile
llvm::StringRef GetBugReportNote()
Appended to an error that may be a bug in LLDB. Starts with a newline.
llvm::sys::DynamicLibrary(* LoadPluginCallbackType)(const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, Status &error)
VarSetOperationType
Settable state variable types.
AutosuggestionMode
Controls how the show-autosuggestion setting drives inline suggestions in the interactive command lin...
@ eAutosuggestionTabMode
Show the prefix that tab completion would insert for the current line.
@ eAutosuggestionOn
Show a suggestion sourced from previously entered commands.
@ eAutosuggestionOff
Do not show any autosuggestion.
ScriptLanguage
Script interpreter types.
Severity
Used for expressing severity in logs and diagnostics.
@ eBroadcastBitExternalProgress
std::shared_ptr< lldb_private::IOHandler > IOHandlerSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::Platform > PlatformSP
DWIMPrintVerbosity
Enum to control the verbosity level of dwim-print execution.
@ eDWIMPrintVerbosityFull
Always print a message indicating how dwim-print is evaluating its expression.
@ eDWIMPrintVerbosityNone
Run dwim-print with no verbosity.
@ eDWIMPrintVerbosityExpression
Print a message when dwim-print uses expression evaluation.
StateType
Process and Thread States.
@ eStateStopped
Process or thread is stopped and can be examined.
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
std::shared_ptr< lldb_private::StructuredDataPlugin > StructuredDataPluginSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Debugger > DebuggerSP
StopDisassemblyType
Used to determine when to show disassembly.
@ eStopDisassemblyTypeNever
@ eStopDisassemblyTypeNoSource
@ eStopDisassemblyTypeAlways
@ eStopDisassemblyTypeNoDebugInfo
@ eStopShowColumnAnsiOrCaret
std::shared_ptr< lldb_private::Event > EventSP
std::shared_ptr< lldb_private::Listener > ListenerSP
std::shared_ptr< lldb_private::LockableStreamFile > LockableStreamFileSP
void(* LogOutputCallback)(const char *, void *baton)
std::shared_ptr< lldb_private::Target > TargetSP
std::unique_ptr< lldb_private::Stream > StreamUP
std::shared_ptr< lldb_private::File > FileSP
std::shared_ptr< lldb_private::REPL > REPLSP
lldb_private::DebuggerDestroyCallback callback
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
std::optional< lldb::LanguageType > GetSingularLanguage()
If the set contains a single language only, return it.
void AppendSafeAutoLoadPaths(FileSpec path)
Appends a path to the testing.safe-auto-load-paths setting.
static TestingProperties & GetGlobalTestingProperties()
FileSpecList GetSafeAutoLoadPaths() const
Callers should use Debugger::GetSafeAutoLoadPaths since it accounts for default paths configured via ...
void SetSafeAutoLoadPaths(FileSpecList paths)
Overwrites the testing.safe-auto-load-paths settings.
bool GetInjectVarLocListError() const
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
lldb::user_id_t GetID() const
Get accessor for the user ID.
Helper RAII class for collecting telemetry.