#include "lldb/Core/Debugger.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Core/DebuggerEvents.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Progress.h"
#include "lldb/Core/StreamAsynchronousIO.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Expression/REPL.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/StreamFile.h"
#include "lldb/Host/Terminal.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Interpreter/OptionValueLanguage.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/OptionValueSInt64.h"
#include "lldb/Interpreter/OptionValueString.h"
#include "lldb/Interpreter/Property.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StructuredDataPlugin.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/TargetList.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadList.h"
#include "lldb/Utility/AnsiTerminal.h"
#include "lldb/Utility/Event.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Listener.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/State.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-enumerations.h"
#if defined(_WIN32)
#include "lldb/Host/windows/PosixApi.h"
#include "lldb/Host/windows/windows.h"
#endif
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator.h"
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <memory>
#include <mutex>
#include <optional>
#include <set>
#include <string>
#include <system_error>
#if defined(_WIN32)
#include <fcntl.h>
#include <io.h>
#else
#include <unistd.h>
#endif
namespace lldb_private {
class Address;
}
usingnamespacelldb;
usingnamespacelldb_private;
static lldb::user_id_t g_unique_id = …;
static size_t g_debugger_event_thread_stack_bytes = …;
#pragma mark Static Functions
static std::recursive_mutex *g_debugger_list_mutex_ptr = …;
static Debugger::DebuggerList *g_debugger_list_ptr = …;
static llvm::DefaultThreadPool *g_thread_pool = …;
static constexpr OptionEnumValueElement g_show_disassembly_enum_values[] = …;
static constexpr OptionEnumValueElement g_language_enumerators[] = …;
static constexpr OptionEnumValueElement g_dwim_print_verbosities[] = …;
static constexpr OptionEnumValueElement s_stop_show_column_values[] = …;
#define LLDB_PROPERTIES_debugger
#include "CoreProperties.inc"
enum { … };
LoadPluginCallbackType Debugger::g_load_plugin_callback = …;
Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx,
VarSetOperationType op,
llvm::StringRef property_path,
llvm::StringRef value) { … }
bool Debugger::GetAutoConfirm() const { … }
const FormatEntity::Entry *Debugger::GetDisassemblyFormat() const { … }
const FormatEntity::Entry *Debugger::GetFrameFormat() const { … }
const FormatEntity::Entry *Debugger::GetFrameFormatUnique() const { … }
uint64_t Debugger::GetStopDisassemblyMaxSize() const { … }
bool Debugger::GetNotifyVoid() const { … }
llvm::StringRef Debugger::GetPrompt() const { … }
llvm::StringRef Debugger::GetPromptAnsiPrefix() const { … }
llvm::StringRef Debugger::GetPromptAnsiSuffix() const { … }
void Debugger::SetPrompt(llvm::StringRef p) { … }
const FormatEntity::Entry *Debugger::GetThreadFormat() const { … }
const FormatEntity::Entry *Debugger::GetThreadStopFormat() const { … }
lldb::ScriptLanguage Debugger::GetScriptLanguage() const { … }
bool Debugger::SetScriptLanguage(lldb::ScriptLanguage script_lang) { … }
lldb::LanguageType Debugger::GetREPLLanguage() const { … }
bool Debugger::SetREPLLanguage(lldb::LanguageType repl_lang) { … }
uint64_t Debugger::GetTerminalWidth() const { … }
bool Debugger::SetTerminalWidth(uint64_t term_width) { … }
bool Debugger::GetUseExternalEditor() const { … }
bool Debugger::SetUseExternalEditor(bool b) { … }
llvm::StringRef Debugger::GetExternalEditor() const { … }
bool Debugger::SetExternalEditor(llvm::StringRef editor) { … }
bool Debugger::GetUseColor() const { … }
bool Debugger::SetUseColor(bool b) { … }
bool Debugger::GetShowProgress() const { … }
bool Debugger::SetShowProgress(bool show_progress) { … }
llvm::StringRef Debugger::GetShowProgressAnsiPrefix() const { … }
llvm::StringRef Debugger::GetShowProgressAnsiSuffix() const { … }
bool Debugger::GetUseAutosuggestion() const { … }
llvm::StringRef Debugger::GetAutosuggestionAnsiPrefix() const { … }
llvm::StringRef Debugger::GetAutosuggestionAnsiSuffix() const { … }
llvm::StringRef Debugger::GetRegexMatchAnsiPrefix() const { … }
llvm::StringRef Debugger::GetRegexMatchAnsiSuffix() const { … }
bool Debugger::GetShowDontUsePoHint() const { … }
bool Debugger::GetUseSourceCache() const { … }
bool Debugger::SetUseSourceCache(bool b) { … }
bool Debugger::GetHighlightSource() const { … }
StopShowColumn Debugger::GetStopShowColumn() const { … }
llvm::StringRef Debugger::GetStopShowColumnAnsiPrefix() const { … }
llvm::StringRef Debugger::GetStopShowColumnAnsiSuffix() const { … }
llvm::StringRef Debugger::GetStopShowLineMarkerAnsiPrefix() const { … }
llvm::StringRef Debugger::GetStopShowLineMarkerAnsiSuffix() const { … }
uint64_t Debugger::GetStopSourceLineCount(bool before) const { … }
Debugger::StopDisassemblyType Debugger::GetStopDisassemblyDisplay() const { … }
uint64_t Debugger::GetDisassemblyLineCount() const { … }
bool Debugger::GetAutoOneLineSummaries() const { … }
bool Debugger::GetEscapeNonPrintables() const { … }
bool Debugger::GetAutoIndent() const { … }
bool Debugger::SetAutoIndent(bool b) { … }
bool Debugger::GetPrintDecls() const { … }
bool Debugger::SetPrintDecls(bool b) { … }
uint64_t Debugger::GetTabSize() const { … }
bool Debugger::SetTabSize(uint64_t tab_size) { … }
lldb::DWIMPrintVerbosity Debugger::GetDWIMPrintVerbosity() const { … }
bool Debugger::GetShowInlineDiagnostics() const { … }
bool Debugger::SetShowInlineDiagnostics(bool b) { … }
#pragma mark Debugger
void Debugger::Initialize(LoadPluginCallbackType load_plugin_callback) { … }
void Debugger::Terminate() { … }
void Debugger::SettingsInitialize() { … }
void Debugger::SettingsTerminate() { … }
bool Debugger::LoadPlugin(const FileSpec &spec, Status &error) { … }
static FileSystem::EnumerateDirectoryResult
LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
llvm::StringRef path) { … }
void Debugger::InstanceInitialize() { … }
DebuggerSP Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
void *baton) { … }
void Debugger::HandleDestroyCallback() { … }
void Debugger::Destroy(DebuggerSP &debugger_sp) { … }
DebuggerSP
Debugger::FindDebuggerWithInstanceName(llvm::StringRef instance_name) { … }
TargetSP Debugger::FindTargetWithProcessID(lldb::pid_t pid) { … }
TargetSP Debugger::FindTargetWithProcess(Process *process) { … }
llvm::StringRef Debugger::GetStaticBroadcasterClass() { … }
Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
: … { … }
Debugger::~Debugger() { … }
void Debugger::Clear() { … }
bool Debugger::GetAsyncExecution() { … }
void Debugger::SetAsyncExecution(bool async_execution) { … }
repro::DataRecorder *Debugger::GetInputRecorder() { … }
static inline int OpenPipe(int fds[2], std::size_t size) { … }
Status Debugger::SetInputString(const char *data) { … }
void Debugger::SetInputFile(FileSP file_sp) { … }
void Debugger::SetOutputFile(FileSP file_sp) { … }
void Debugger::SetErrorFile(FileSP file_sp) { … }
void Debugger::SaveInputTerminalState() { … }
void Debugger::RestoreInputTerminalState() { … }
ExecutionContext Debugger::GetSelectedExecutionContext() { … }
void Debugger::DispatchInputInterrupt() { … }
void Debugger::DispatchInputEndOfFile() { … }
void Debugger::ClearIOHandlers() { … }
void Debugger::RunIOHandlers() { … }
void Debugger::RunIOHandlerSync(const IOHandlerSP &reader_sp) { … }
bool Debugger::IsTopIOHandler(const lldb::IOHandlerSP &reader_sp) { … }
bool Debugger::CheckTopIOHandlerTypes(IOHandler::Type top_type,
IOHandler::Type second_top_type) { … }
void Debugger::PrintAsync(const char *s, size_t len, bool is_stdout) { … }
llvm::StringRef Debugger::GetTopIOHandlerControlSequence(char ch) { … }
const char *Debugger::GetIOHandlerCommandPrefix() { … }
const char *Debugger::GetIOHandlerHelpPrologue() { … }
bool Debugger::RemoveIOHandler(const IOHandlerSP &reader_sp) { … }
void Debugger::RunIOHandlerAsync(const IOHandlerSP &reader_sp,
bool cancel_top_handler) { … }
void Debugger::AdoptTopIOHandlerFilesIfInvalid(FileSP &in, StreamFileSP &out,
StreamFileSP &err) { … }
void Debugger::PushIOHandler(const IOHandlerSP &reader_sp,
bool cancel_top_handler) { … }
bool Debugger::PopIOHandler(const IOHandlerSP &pop_reader_sp) { … }
StreamSP Debugger::GetAsyncOutputStream() { … }
StreamSP Debugger::GetAsyncErrorStream() { … }
void Debugger::RequestInterrupt() { … }
void Debugger::CancelInterruptRequest() { … }
bool Debugger::InterruptRequested() { … }
Debugger::InterruptionReport::InterruptionReport(
std::string function_name, const llvm::formatv_object_base &payload)
: … { … }
void Debugger::ReportInterruption(const InterruptionReport &report) { … }
Debugger::DebuggerList Debugger::DebuggersRequestingInterruption() { … }
size_t Debugger::GetNumDebuggers() { … }
lldb::DebuggerSP Debugger::GetDebuggerAtIndex(size_t index) { … }
DebuggerSP Debugger::FindDebuggerWithID(lldb::user_id_t id) { … }
bool Debugger::FormatDisassemblerAddress(const FormatEntity::Entry *format,
const SymbolContext *sc,
const SymbolContext *prev_sc,
const ExecutionContext *exe_ctx,
const Address *addr, Stream &s) { … }
void Debugger::AssertCallback(llvm::StringRef message,
llvm::StringRef backtrace,
llvm::StringRef prompt) { … }
void Debugger::SetLoggingCallback(lldb::LogOutputCallback log_callback,
void *baton) { … }
void Debugger::SetDestroyCallback(
lldb_private::DebuggerDestroyCallback destroy_callback, void *baton) { … }
lldb::callback_token_t Debugger::AddDestroyCallback(
lldb_private::DebuggerDestroyCallback destroy_callback, void *baton) { … }
bool Debugger::RemoveDestroyCallback(lldb::callback_token_t token) { … }
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) { … }
void Debugger::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) { … }
static void PrivateReportDiagnostic(Debugger &debugger, Severity severity,
std::string message,
bool debugger_specific) { … }
void Debugger::ReportDiagnosticImpl(Severity severity, std::string message,
std::optional<lldb::user_id_t> debugger_id,
std::once_flag *once) { … }
void Debugger::ReportWarning(std::string message,
std::optional<lldb::user_id_t> debugger_id,
std::once_flag *once) { … }
void Debugger::ReportError(std::string message,
std::optional<lldb::user_id_t> debugger_id,
std::once_flag *once) { … }
void Debugger::ReportInfo(std::string message,
std::optional<lldb::user_id_t> debugger_id,
std::once_flag *once) { … }
void Debugger::ReportSymbolChange(const ModuleSpec &module_spec) { … }
static std::shared_ptr<LogHandler>
CreateLogHandler(LogHandlerKind log_handler_kind, int fd, bool should_close,
size_t buffer_size) { … }
bool Debugger::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,
llvm::raw_ostream &error_stream) { … }
ScriptInterpreter *
Debugger::GetScriptInterpreter(bool can_create,
std::optional<lldb::ScriptLanguage> language) { … }
SourceManager &Debugger::GetSourceManager() { … }
void Debugger::HandleBreakpointEvent(const EventSP &event_sp) { … }
void Debugger::FlushProcessOutput(Process &process, bool flush_stdout,
bool flush_stderr) { … }
void Debugger::HandleProcessEvent(const EventSP &event_sp) { … }
void Debugger::HandleThreadEvent(const EventSP &event_sp) { … }
bool Debugger::IsForwardingEvents() { … }
void Debugger::EnableForwardEvents(const ListenerSP &listener_sp) { … }
void Debugger::CancelForwardEvents(const ListenerSP &listener_sp) { … }
lldb::thread_result_t Debugger::DefaultEventHandler() { … }
bool Debugger::StartEventHandlerThread() { … }
void Debugger::StopEventHandlerThread() { … }
lldb::thread_result_t Debugger::IOHandlerThread() { … }
void Debugger::HandleProgressEvent(const lldb::EventSP &event_sp) { … }
void Debugger::HandleDiagnosticEvent(const lldb::EventSP &event_sp) { … }
bool Debugger::HasIOHandlerThread() const { … }
HostThread Debugger::SetIOHandlerThread(HostThread &new_thread) { … }
bool Debugger::StartIOHandlerThread() { … }
void Debugger::StopIOHandlerThread() { … }
void Debugger::JoinIOHandlerThread() { … }
bool Debugger::IsIOHandlerThreadCurrentThread() const { … }
Target &Debugger::GetSelectedOrDummyTarget(bool prefer_dummy) { … }
Status Debugger::RunREPL(LanguageType language, const char *repl_options) { … }
llvm::ThreadPoolInterface &Debugger::GetThreadPool() { … }