llvm/lldb/source/Interpreter/CommandInterpreter.cpp

//===-- CommandInterpreter.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include <chrono>
#include <cstdlib>
#include <limits>
#include <memory>
#include <optional>
#include <string>
#include <vector>

#include "Commands/CommandObjectApropos.h"
#include "Commands/CommandObjectBreakpoint.h"
#include "Commands/CommandObjectCommands.h"
#include "Commands/CommandObjectDWIMPrint.h"
#include "Commands/CommandObjectDiagnostics.h"
#include "Commands/CommandObjectDisassemble.h"
#include "Commands/CommandObjectExpression.h"
#include "Commands/CommandObjectFrame.h"
#include "Commands/CommandObjectGUI.h"
#include "Commands/CommandObjectHelp.h"
#include "Commands/CommandObjectLanguage.h"
#include "Commands/CommandObjectLog.h"
#include "Commands/CommandObjectMemory.h"
#include "Commands/CommandObjectPlatform.h"
#include "Commands/CommandObjectPlugin.h"
#include "Commands/CommandObjectProcess.h"
#include "Commands/CommandObjectQuit.h"
#include "Commands/CommandObjectRegexCommand.h"
#include "Commands/CommandObjectRegister.h"
#include "Commands/CommandObjectScripting.h"
#include "Commands/CommandObjectSession.h"
#include "Commands/CommandObjectSettings.h"
#include "Commands/CommandObjectSource.h"
#include "Commands/CommandObjectStats.h"
#include "Commands/CommandObjectTarget.h"
#include "Commands/CommandObjectThread.h"
#include "Commands/CommandObjectTrace.h"
#include "Commands/CommandObjectType.h"
#include "Commands/CommandObjectVersion.h"
#include "Commands/CommandObjectWatchpoint.h"

#include "lldb/Core/Debugger.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/StreamFile.h"
#include "lldb/Utility/ErrorMessages.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/State.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StructuredData.h"
#include "lldb/Utility/Timer.h"

#include "lldb/Host/Config.h"
#if LLDB_ENABLE_LIBEDIT
#include "lldb/Host/Editline.h"
#endif
#include "lldb/Host/File.h"
#include "lldb/Host/FileCache.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"

#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/Property.h"
#include "lldb/Utility/Args.h"

#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/TargetList.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/UnixSignals.h"

#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/ScopedPrinter.h"

#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif

usingnamespacelldb;
usingnamespacelldb_private;

static const char *k_white_space =;

static constexpr const char *InitFileWarning =;

const char *CommandInterpreter::g_no_argument =;
const char *CommandInterpreter::g_need_argument =;
const char *CommandInterpreter::g_argument =;


#define LLDB_PROPERTIES_interpreter
#include "InterpreterProperties.inc"

enum {};

llvm::StringRef CommandInterpreter::GetStaticBroadcasterClass() {}

CommandInterpreter::CommandInterpreter(Debugger &debugger,
                                       bool synchronous_execution)
    :{}

bool CommandInterpreter::GetExpandRegexAliases() const {}

bool CommandInterpreter::GetPromptOnQuit() const {}

void CommandInterpreter::SetPromptOnQuit(bool enable) {}

bool CommandInterpreter::GetSaveTranscript() const {}

void CommandInterpreter::SetSaveTranscript(bool enable) {}

bool CommandInterpreter::GetSaveSessionOnQuit() const {}

void CommandInterpreter::SetSaveSessionOnQuit(bool enable) {}

bool CommandInterpreter::GetOpenTranscriptInEditor() const {}

void CommandInterpreter::SetOpenTranscriptInEditor(bool enable) {}

FileSpec CommandInterpreter::GetSaveSessionDirectory() const {}

void CommandInterpreter::SetSaveSessionDirectory(llvm::StringRef path) {}

bool CommandInterpreter::GetEchoCommands() const {}

void CommandInterpreter::SetEchoCommands(bool enable) {}

bool CommandInterpreter::GetEchoCommentCommands() const {}

void CommandInterpreter::SetEchoCommentCommands(bool enable) {}

void CommandInterpreter::AllowExitCodeOnQuit(bool allow) {}

bool CommandInterpreter::SetQuitExitCode(int exit_code) {}

int CommandInterpreter::GetQuitExitCode(bool &exited) const {}

void CommandInterpreter::ResolveCommand(const char *command_line,
                                        CommandReturnObject &result) {}

bool CommandInterpreter::GetStopCmdSourceOnError() const {}

bool CommandInterpreter::GetSpaceReplPrompts() const {}

bool CommandInterpreter::GetRepeatPreviousCommand() const {}

bool CommandInterpreter::GetRequireCommandOverwrite() const {}

void CommandInterpreter::Initialize() {}

void CommandInterpreter::Clear() {}

const char *CommandInterpreter::ProcessEmbeddedScriptCommands(const char *arg) {}

#define REGISTER_COMMAND_OBJECT(NAME, CLASS)

void CommandInterpreter::LoadCommandDictionary() {}

int CommandInterpreter::GetCommandNamesMatchingPartialString(
    const char *cmd_str, bool include_aliases, StringList &matches,
    StringList &descriptions) {}

CommandObjectMultiword *CommandInterpreter::VerifyUserMultiwordCmdPath(
    Args &path, bool leaf_is_command, Status &result) {}

CommandObjectSP
CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, bool include_aliases,
                                 bool exact, StringList *matches,
                                 StringList *descriptions) const {}

bool CommandInterpreter::AddCommand(llvm::StringRef name,
                                    const lldb::CommandObjectSP &cmd_sp,
                                    bool can_replace) {}

Status CommandInterpreter::AddUserCommand(llvm::StringRef name,
                                          const lldb::CommandObjectSP &cmd_sp,
                                          bool can_replace) {}

CommandObjectSP
CommandInterpreter::GetCommandSPExact(llvm::StringRef cmd_str,
                                      bool include_aliases) const {}

CommandObject *
CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str,
                                     StringList *matches,
                                     StringList *descriptions) const {}

CommandObject *CommandInterpreter::GetUserCommandObject(
    llvm::StringRef cmd, StringList *matches, StringList *descriptions) const {}

CommandObject *CommandInterpreter::GetAliasCommandObject(
    llvm::StringRef cmd, StringList *matches, StringList *descriptions) const {}

bool CommandInterpreter::CommandExists(llvm::StringRef cmd) const {}

bool CommandInterpreter::GetAliasFullName(llvm::StringRef cmd,
                                          std::string &full_name) const {}

bool CommandInterpreter::AliasExists(llvm::StringRef cmd) const {}

bool CommandInterpreter::UserCommandExists(llvm::StringRef cmd) const {}

bool CommandInterpreter::UserMultiwordCommandExists(llvm::StringRef cmd) const {}

CommandAlias *
CommandInterpreter::AddAlias(llvm::StringRef alias_name,
                             lldb::CommandObjectSP &command_obj_sp,
                             llvm::StringRef args_string) {}

bool CommandInterpreter::RemoveAlias(llvm::StringRef alias_name) {}

bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd, bool force) {}

bool CommandInterpreter::RemoveUser(llvm::StringRef user_name) {}

bool CommandInterpreter::RemoveUserMultiword(llvm::StringRef multi_name) {}

void CommandInterpreter::GetHelp(CommandReturnObject &result,
                                 uint32_t cmd_types) {}

CommandObject *CommandInterpreter::GetCommandObjectForCommand(
    llvm::StringRef &command_string) {}

static const char *k_valid_command_chars =;
static void StripLeadingSpaces(std::string &s) {}

static size_t FindArgumentTerminator(const std::string &s) {}

static bool ExtractCommand(std::string &command_string, std::string &command,
                           std::string &suffix, char &quote_char) {}

CommandObject *CommandInterpreter::BuildAliasResult(
    llvm::StringRef alias_name, std::string &raw_input_string,
    std::string &alias_result, CommandReturnObject &result) {}

Status CommandInterpreter::PreprocessCommand(std::string &command) {}

Status
CommandInterpreter::PreprocessToken(std::string &expr_str) {}

bool CommandInterpreter::HandleCommand(const char *command_line,
                                       LazyBool lazy_add_to_history,
                                       const ExecutionContext &override_context,
                                       CommandReturnObject &result) {}

bool CommandInterpreter::HandleCommand(const char *command_line,
                                       LazyBool lazy_add_to_history,
                                       CommandReturnObject &result,
                                       bool force_repeat_command) {}

void CommandInterpreter::HandleCompletionMatches(CompletionRequest &request) {}

void CommandInterpreter::HandleCompletion(CompletionRequest &request) {}

std::optional<std::string>
CommandInterpreter::GetAutoSuggestionForCommand(llvm::StringRef line) {}

void CommandInterpreter::UpdatePrompt(llvm::StringRef new_prompt) {}

bool CommandInterpreter::Confirm(llvm::StringRef message, bool default_answer) {}

const CommandAlias *
CommandInterpreter::GetAlias(llvm::StringRef alias_name) const {}

bool CommandInterpreter::HasCommands() const {}

bool CommandInterpreter::HasAliases() const {}

bool CommandInterpreter::HasUserCommands() const {}

bool CommandInterpreter::HasUserMultiwordCommands() const {}

bool CommandInterpreter::HasAliasOptions() const {}

void CommandInterpreter::BuildAliasCommandArgs(CommandObject *alias_cmd_obj,
                                               const char *alias_name,
                                               Args &cmd_args,
                                               std::string &raw_input_string,
                                               CommandReturnObject &result) {}

int CommandInterpreter::GetOptionArgumentPosition(const char *in_string) {}

static void GetHomeInitFile(llvm::SmallVectorImpl<char> &init_file,
                            llvm::StringRef suffix = {}

static void GetHomeREPLInitFile(llvm::SmallVectorImpl<char> &init_file,
                                LanguageType language) {}

static void GetCwdInitFile(llvm::SmallVectorImpl<char> &init_file) {}

void CommandInterpreter::SourceInitFile(FileSpec file,
                                        CommandReturnObject &result) {}

void CommandInterpreter::SourceInitFileCwd(CommandReturnObject &result) {}

/// We will first see if there is an application specific ".lldbinit" file
/// whose name is "~/.lldbinit" followed by a "-" and the name of the program.
/// If this file doesn't exist, we fall back to the REPL init file or the
/// default home init file in "~/.lldbinit".
void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result,
                                            bool is_repl) {}

void CommandInterpreter::SourceInitFileGlobal(CommandReturnObject &result) {}

const char *CommandInterpreter::GetCommandPrefix() {}

PlatformSP CommandInterpreter::GetPlatform(bool prefer_target_platform) {}

bool CommandInterpreter::DidProcessStopAbnormally() const {}

void
CommandInterpreter::HandleCommands(const StringList &commands,
                                   const ExecutionContext &override_context,
                                   const CommandInterpreterRunOptions &options,
                                   CommandReturnObject &result) {}

void CommandInterpreter::HandleCommands(const StringList &commands,
                                        const CommandInterpreterRunOptions &options,
                                        CommandReturnObject &result) {}

// Make flags that we can pass into the IOHandler so our delegates can do the
// right thing
enum {};

void CommandInterpreter::HandleCommandsFromFile(
    FileSpec &cmd_file, const ExecutionContext &context,
    const CommandInterpreterRunOptions &options, CommandReturnObject &result) {}

void CommandInterpreter::HandleCommandsFromFile(FileSpec &cmd_file,
    const CommandInterpreterRunOptions &options, CommandReturnObject &result) {}

bool CommandInterpreter::GetSynchronous() {}

void CommandInterpreter::SetSynchronous(bool value) {}

void CommandInterpreter::OutputFormattedHelpText(Stream &strm,
                                                 llvm::StringRef prefix,
                                                 llvm::StringRef help_text) {}

void CommandInterpreter::OutputFormattedHelpText(Stream &strm,
                                                 llvm::StringRef word_text,
                                                 llvm::StringRef separator,
                                                 llvm::StringRef help_text,
                                                 size_t max_word_len) {}

void CommandInterpreter::OutputHelpText(Stream &strm, llvm::StringRef word_text,
                                        llvm::StringRef separator,
                                        llvm::StringRef help_text,
                                        uint32_t max_word_len) {}

void CommandInterpreter::FindCommandsForApropos(
    llvm::StringRef search_word, StringList &commands_found,
    StringList &commands_help, const CommandObject::CommandMap &command_map) {}

void CommandInterpreter::FindCommandsForApropos(llvm::StringRef search_word,
                                                StringList &commands_found,
                                                StringList &commands_help,
                                                bool search_builtin_commands,
                                                bool search_user_commands,
                                                bool search_alias_commands,
                                                bool search_user_mw_commands) {}

ExecutionContext CommandInterpreter::GetExecutionContext() const {}

void CommandInterpreter::OverrideExecutionContext(
    const ExecutionContext &override_context) {}

void CommandInterpreter::RestoreExecutionContext() {}

void CommandInterpreter::GetProcessOutput() {}

void CommandInterpreter::StartHandlingCommand() {}

void CommandInterpreter::FinishHandlingCommand() {}

bool CommandInterpreter::InterruptCommand() {}

bool CommandInterpreter::WasInterrupted() const {}

void CommandInterpreter::PrintCommandOutput(IOHandler &io_handler,
                                            llvm::StringRef str,
                                            bool is_stdout) {}

bool CommandInterpreter::EchoCommandNonInteractive(
    llvm::StringRef line, const Flags &io_handler_flags) const {}

void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
                                                std::string &line) {}

bool CommandInterpreter::IOHandlerInterrupt(IOHandler &io_handler) {}

bool CommandInterpreter::SaveTranscript(
    CommandReturnObject &result, std::optional<std::string> output_file) {}

bool CommandInterpreter::IsInteractive() {}

FileSpec CommandInterpreter::GetCurrentSourceDir() {}

void CommandInterpreter::GetLLDBCommandsFromIOHandler(
    const char *prompt, IOHandlerDelegate &delegate, void *baton) {}

void CommandInterpreter::GetPythonCommandsFromIOHandler(
    const char *prompt, IOHandlerDelegate &delegate, void *baton) {}

bool CommandInterpreter::IsActive() {}

lldb::IOHandlerSP
CommandInterpreter::GetIOHandler(bool force_create,
                                 CommandInterpreterRunOptions *options) {}

CommandInterpreterRunResult CommandInterpreter::RunCommandInterpreter(
    CommandInterpreterRunOptions &options) {}

CommandObject *
CommandInterpreter::ResolveCommandImpl(std::string &command_line,
                                       CommandReturnObject &result) {}

llvm::json::Value CommandInterpreter::GetStatistics() {}

const StructuredData::Array &CommandInterpreter::GetTranscript() const {}