diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
commit | 5f29bb8a675e8f96452b632e7129113f7dec850e (patch) | |
tree | 3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/Commands | |
parent | 88c643b6fec27eec436c8d138fee6346e92337d6 (diff) | |
download | src-5f29bb8a675e8f96452b632e7129113f7dec850e.tar.gz src-5f29bb8a675e8f96452b632e7129113f7dec850e.zip |
Vendor import of stripped lldb trunk r366426 (just before the release_90
branch point):
https://llvm.org/svn/llvm-project/lldb/trunk@366426
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=351290
Diffstat (limited to 'source/Commands')
60 files changed, 1186 insertions, 1223 deletions
diff --git a/source/Commands/CommandCompletions.cpp b/source/Commands/CommandCompletions.cpp index 705e87651a8c..5d2fb3d67f57 100644 --- a/source/Commands/CommandCompletions.cpp +++ b/source/Commands/CommandCompletions.cpp @@ -1,9 +1,8 @@ //===-- CommandCompletions.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -350,9 +349,7 @@ CommandCompletions::Completer::Completer(CommandInterpreter &interpreter, CommandCompletions::Completer::~Completer() = default; -//---------------------------------------------------------------------- // SourceFileCompleter -//---------------------------------------------------------------------- CommandCompletions::SourceFileCompleter::SourceFileCompleter( CommandInterpreter &interpreter, bool include_support_files, @@ -425,9 +422,7 @@ CommandCompletions::SourceFileCompleter::DoCompletion(SearchFilter *filter) { return m_request.GetNumberOfMatches(); } -//---------------------------------------------------------------------- // SymbolCompleter -//---------------------------------------------------------------------- static bool regex_chars(const char comp) { return (comp == '[' || comp == ']' || comp == '(' || comp == ')' || @@ -493,9 +488,7 @@ size_t CommandCompletions::SymbolCompleter::DoCompletion(SearchFilter *filter) { return m_request.GetNumberOfMatches(); } -//---------------------------------------------------------------------- // ModuleCompleter -//---------------------------------------------------------------------- CommandCompletions::ModuleCompleter::ModuleCompleter( CommandInterpreter &interpreter, CompletionRequest &request) : CommandCompletions::Completer(interpreter, request) { diff --git a/source/Commands/CommandObjectApropos.cpp b/source/Commands/CommandObjectApropos.cpp index 69c2760ded4e..957de475569c 100644 --- a/source/Commands/CommandObjectApropos.cpp +++ b/source/Commands/CommandObjectApropos.cpp @@ -1,10 +1,9 @@ //===-- CommandObjectApropos.cpp ---------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -18,9 +17,7 @@ using namespace lldb; using namespace lldb_private; -//------------------------------------------------------------------------- // CommandObjectApropos -//------------------------------------------------------------------------- CommandObjectApropos::CommandObjectApropos(CommandInterpreter &interpreter) : CommandObjectParsed( @@ -83,7 +80,7 @@ bool CommandObjectApropos::DoExecute(Args &args, CommandReturnObject &result) { std::vector<const Property *> properties; const size_t num_properties = - m_interpreter.GetDebugger().Apropos(search_word, properties); + GetDebugger().Apropos(search_word, properties); if (num_properties) { const bool dump_qualified_name = true; result.AppendMessageWithFormatv( diff --git a/source/Commands/CommandObjectApropos.h b/source/Commands/CommandObjectApropos.h index acd4cedfe9fd..37d86b17d1a2 100644 --- a/source/Commands/CommandObjectApropos.h +++ b/source/Commands/CommandObjectApropos.h @@ -1,10 +1,9 @@ //===-- CommandObjectApropos.h -----------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,9 +14,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectApropos -//------------------------------------------------------------------------- class CommandObjectApropos : public CommandObjectParsed { public: diff --git a/source/Commands/CommandObjectBreakpoint.cpp b/source/Commands/CommandObjectBreakpoint.cpp index 8eb6a5fa5a02..c33f3834cb13 100644 --- a/source/Commands/CommandObjectBreakpoint.cpp +++ b/source/Commands/CommandObjectBreakpoint.cpp @@ -1,14 +1,11 @@ //===-- CommandObjectBreakpoint.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 <vector> - #include "CommandObjectBreakpoint.h" #include "CommandObjectBreakpointCommand.h" #include "lldb/Breakpoint/Breakpoint.h" @@ -31,6 +28,9 @@ #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/StreamString.h" +#include <memory> +#include <vector> + using namespace lldb; using namespace lldb_private; @@ -42,9 +42,7 @@ static void AddBreakpointDescription(Stream *s, Breakpoint *bp, s->EOL(); } -//------------------------------------------------------------------------- // Modifiable Breakpoint Options -//------------------------------------------------------------------------- #pragma mark Modify::CommandOptions static constexpr OptionDefinition g_breakpoint_modify_options[] = { // clang-format off @@ -322,13 +320,11 @@ static constexpr OptionDefinition g_breakpoint_set_options[] = { // clang-format on }; -//------------------------------------------------------------------------- // CommandObjectBreakpointSet -//------------------------------------------------------------------------- class CommandObjectBreakpointSet : public CommandObjectParsed { public: - typedef enum BreakpointSetType { + enum BreakpointSetType { eSetTypeInvalid, eSetTypeFileAndLine, eSetTypeAddress, @@ -337,7 +333,7 @@ public: eSetTypeSourceRegexp, eSetTypeException, eSetTypeScripted, - } BreakpointSetType; + }; CommandObjectBreakpointSet(CommandInterpreter &interpreter) : CommandObjectParsed( @@ -616,7 +612,7 @@ public: m_move_to_nearest_code = eLazyBoolCalculate; m_source_regex_func_names.clear(); m_python_class.clear(); - m_extra_args_sp.reset(new StructuredData::Dictionary()); + m_extra_args_sp = std::make_shared<StructuredData::Dictionary>(); m_current_key.clear(); } @@ -901,7 +897,7 @@ protected: const bool show_locations = false; bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial, show_locations); - if (target == m_interpreter.GetDebugger().GetDummyTarget()) + if (target == GetDebugger().GetDummyTarget()) output_stream.Printf("Breakpoint set in dummy target, will get copied " "into future targets.\n"); else { @@ -962,9 +958,7 @@ private: OptionGroupOptions m_all_options; }; -//------------------------------------------------------------------------- // CommandObjectBreakpointModify -//------------------------------------------------------------------------- #pragma mark Modify class CommandObjectBreakpointModify : public CommandObjectParsed { @@ -1046,9 +1040,7 @@ private: OptionGroupOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectBreakpointEnable -//------------------------------------------------------------------------- #pragma mark Enable class CommandObjectBreakpointEnable : public CommandObjectParsed { @@ -1137,9 +1129,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectBreakpointDisable -//------------------------------------------------------------------------- #pragma mark Disable class CommandObjectBreakpointDisable : public CommandObjectParsed { @@ -1252,21 +1242,14 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectBreakpointList -//------------------------------------------------------------------------- #pragma mark List::CommandOptions static constexpr OptionDefinition g_breakpoint_list_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, false, "internal", 'i', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Show debugger internal breakpoints" }, - { LLDB_OPT_SET_1, false, "brief", 'b', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Give a brief description of the breakpoint (no location info)." }, - // FIXME: We need to add an "internal" command, and then add this sort of thing to it. - // But I need to see it for now, and don't want to wait. - { LLDB_OPT_SET_2, false, "full", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Give a full description of the breakpoint and its locations." }, - { LLDB_OPT_SET_3, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Explain everything we know about the breakpoint (for debugging debugger bugs)." }, - { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "List Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets." }, - // clang-format on + // FIXME: We need to add an "internal" command, and then add this sort of + // thing to it. But I need to see it for now, and don't want to wait. +#define LLDB_OPTIONS_breakpoint_list +#include "CommandOptions.inc" }; #pragma mark List @@ -1418,9 +1401,7 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectBreakpointClear -//------------------------------------------------------------------------- #pragma mark Clear::CommandOptions static constexpr OptionDefinition g_breakpoint_clear_options[] = { @@ -1434,10 +1415,7 @@ static constexpr OptionDefinition g_breakpoint_clear_options[] = { class CommandObjectBreakpointClear : public CommandObjectParsed { public: - typedef enum BreakpointClearType { - eClearTypeInvalid, - eClearTypeFileAndLine - } BreakpointClearType; + enum BreakpointClearType { eClearTypeInvalid, eClearTypeFileAndLine }; CommandObjectBreakpointClear(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "breakpoint clear", @@ -1578,9 +1556,7 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectBreakpointDelete -//------------------------------------------------------------------------- static constexpr OptionDefinition g_breakpoint_delete_options[] = { // clang-format off { LLDB_OPT_SET_1, false, "force", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Delete all breakpoints without querying for confirmation." }, @@ -1734,9 +1710,7 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectBreakpointName -//------------------------------------------------------------------------- static constexpr OptionDefinition g_breakpoint_name_options[] = { // clang-format off @@ -2245,9 +2219,7 @@ private: OptionGroupOptions m_option_group; }; -//------------------------------------------------------------------------- // CommandObjectBreakpointName -//------------------------------------------------------------------------- class CommandObjectBreakpointName : public CommandObjectMultiword { public: CommandObjectBreakpointName(CommandInterpreter &interpreter) @@ -2272,9 +2244,7 @@ public: ~CommandObjectBreakpointName() override = default; }; -//------------------------------------------------------------------------- // CommandObjectBreakpointRead -//------------------------------------------------------------------------- #pragma mark Read::CommandOptions static constexpr OptionDefinition g_breakpoint_read_options[] = { // clang-format off @@ -2403,9 +2373,7 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectBreakpointWrite -//------------------------------------------------------------------------- #pragma mark Write::CommandOptions static constexpr OptionDefinition g_breakpoint_write_options[] = { // clang-format off @@ -2517,9 +2485,7 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectMultiwordBreakpoint -//------------------------------------------------------------------------- #pragma mark MultiwordBreakpoint CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint( diff --git a/source/Commands/CommandObjectBreakpoint.h b/source/Commands/CommandObjectBreakpoint.h index d0026f90e30c..cba1f3f774ee 100644 --- a/source/Commands/CommandObjectBreakpoint.h +++ b/source/Commands/CommandObjectBreakpoint.h @@ -1,9 +1,8 @@ //===-- CommandObjectBreakpoint.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -24,9 +23,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectMultiwordBreakpoint -//------------------------------------------------------------------------- class CommandObjectMultiwordBreakpoint : public CommandObjectMultiword { public: diff --git a/source/Commands/CommandObjectBreakpointCommand.cpp b/source/Commands/CommandObjectBreakpointCommand.cpp index 991b174980e1..3f9d83cd86a8 100644 --- a/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/source/Commands/CommandObjectBreakpointCommand.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectBreakpointCommand.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -27,9 +26,7 @@ using namespace lldb; using namespace lldb_private; -//------------------------------------------------------------------------- // CommandObjectBreakpointCommandAdd -//------------------------------------------------------------------------- // FIXME: "script-type" needs to have its contents determined dynamically, so // somebody can add a new scripting @@ -223,9 +220,9 @@ are no syntax errors may indicate that a function was declared but never called. Options *GetOptions() override { return &m_options; } - void IOHandlerActivated(IOHandler &io_handler) override { + void IOHandlerActivated(IOHandler &io_handler, bool interactive) override { StreamFileSP output_sp(io_handler.GetOutputStreamFile()); - if (output_sp) { + if (output_sp && interactive) { output_sp->PutCString(g_reader_instructions); output_sp->Flush(); } @@ -425,7 +422,7 @@ protected: // to set or collect command callback. Otherwise, call the methods // associated with this object. if (m_options.m_use_script_language) { - ScriptInterpreter *script_interp = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *script_interp = GetDebugger().GetScriptInterpreter(); // Special handling for one-liner specified inline. if (m_options.m_use_one_liner) { script_interp->SetBreakpointCommandCallback( @@ -470,9 +467,7 @@ private: const char *CommandObjectBreakpointCommandAdd::g_reader_instructions = "Enter your debugger command(s). Type 'DONE' to end.\n"; -//------------------------------------------------------------------------- // CommandObjectBreakpointCommandDelete -//------------------------------------------------------------------------- static constexpr OptionDefinition g_breakpoint_delete_options[] = { // clang-format off @@ -607,9 +602,7 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectBreakpointCommandList -//------------------------------------------------------------------------- class CommandObjectBreakpointCommandList : public CommandObjectParsed { public: @@ -637,7 +630,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("There is not a current executable; there are no " @@ -727,9 +720,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectBreakpointCommand -//------------------------------------------------------------------------- CommandObjectBreakpointCommand::CommandObjectBreakpointCommand( CommandInterpreter &interpreter) diff --git a/source/Commands/CommandObjectBreakpointCommand.h b/source/Commands/CommandObjectBreakpointCommand.h index 96d212138282..b18e003368be 100644 --- a/source/Commands/CommandObjectBreakpointCommand.h +++ b/source/Commands/CommandObjectBreakpointCommand.h @@ -1,9 +1,8 @@ //===-- CommandObjectBreakpointCommand.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -20,9 +19,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectMultiwordBreakpoint -//------------------------------------------------------------------------- class CommandObjectBreakpointCommand : public CommandObjectMultiword { public: diff --git a/source/Commands/CommandObjectBugreport.cpp b/source/Commands/CommandObjectBugreport.cpp index dc4b9ef302c0..515cc9a113b1 100644 --- a/source/Commands/CommandObjectBugreport.cpp +++ b/source/Commands/CommandObjectBugreport.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectBugreport.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -20,9 +19,7 @@ using namespace lldb; using namespace lldb_private; -//------------------------------------------------------------------------- // "bugreport unwind" -//------------------------------------------------------------------------- class CommandObjectBugreportUnwind : public CommandObjectParsed { public: @@ -97,6 +94,7 @@ protected: options.SetStopOnError(false); options.SetEchoCommands(true); options.SetPrintResults(true); + options.SetPrintErrors(true); options.SetAddToHistory(false); m_interpreter.HandleCommands(commands, &m_exe_ctx, options, result); @@ -110,9 +108,7 @@ private: #pragma mark CommandObjectMultiwordBugreport -//------------------------------------------------------------------------- // CommandObjectMultiwordBugreport -//------------------------------------------------------------------------- CommandObjectMultiwordBugreport::CommandObjectMultiwordBugreport( CommandInterpreter &interpreter) diff --git a/source/Commands/CommandObjectBugreport.h b/source/Commands/CommandObjectBugreport.h index 1d9aea59925a..24ce6d237d56 100644 --- a/source/Commands/CommandObjectBugreport.h +++ b/source/Commands/CommandObjectBugreport.h @@ -1,9 +1,8 @@ //===-- CommandObjectBugreport.h --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,9 +13,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectMultiwordBugreport -//------------------------------------------------------------------------- class CommandObjectMultiwordBugreport : public CommandObjectMultiword { public: diff --git a/source/Commands/CommandObjectCommands.cpp b/source/Commands/CommandObjectCommands.cpp index 01e1c4269bba..4092e76be6ac 100644 --- a/source/Commands/CommandObjectCommands.cpp +++ b/source/Commands/CommandObjectCommands.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectCommands.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -30,9 +29,7 @@ using namespace lldb; using namespace lldb_private; -//------------------------------------------------------------------------- // CommandObjectCommandsSource -//------------------------------------------------------------------------- static constexpr OptionDefinition g_history_options[] = { // clang-format off @@ -189,9 +186,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectCommandsSource -//------------------------------------------------------------------------- static constexpr OptionDefinition g_source_options[] = { // clang-format off @@ -314,14 +309,20 @@ protected: m_options.m_stop_on_continue.OptionWasSet()) { // Use user set settings CommandInterpreterRunOptions options; - options.SetStopOnContinue(m_options.m_stop_on_continue.GetCurrentValue()); - options.SetStopOnError(m_options.m_stop_on_error.GetCurrentValue()); + + if (m_options.m_stop_on_continue.OptionWasSet()) + options.SetStopOnContinue( + m_options.m_stop_on_continue.GetCurrentValue()); + + if (m_options.m_stop_on_error.OptionWasSet()) + options.SetStopOnError(m_options.m_stop_on_error.GetCurrentValue()); // Individual silent setting is override for global command echo settings. if (m_options.m_silent_run.GetCurrentValue()) { options.SetSilent(true); } else { options.SetPrintResults(true); + options.SetPrintErrors(true); options.SetEchoCommands(m_interpreter.GetEchoCommands()); options.SetEchoCommentCommands(m_interpreter.GetEchoCommentCommands()); } @@ -340,9 +341,7 @@ protected: }; #pragma mark CommandObjectCommandsAlias -//------------------------------------------------------------------------- // CommandObjectCommandsAlias -//------------------------------------------------------------------------- static constexpr OptionDefinition g_alias_options[] = { // clang-format off @@ -766,9 +765,7 @@ protected: }; #pragma mark CommandObjectCommandsUnalias -//------------------------------------------------------------------------- // CommandObjectCommandsUnalias -//------------------------------------------------------------------------- class CommandObjectCommandsUnalias : public CommandObjectParsed { public: @@ -849,9 +846,7 @@ protected: }; #pragma mark CommandObjectCommandsDelete -//------------------------------------------------------------------------- // CommandObjectCommandsDelete -//------------------------------------------------------------------------- class CommandObjectCommandsDelete : public CommandObjectParsed { public: @@ -891,11 +886,11 @@ protected: auto command_name = args[0].ref; if (!m_interpreter.CommandExists(command_name)) { StreamString error_msg_stream; - const bool generate_apropos = true; + const bool generate_upropos = true; const bool generate_type_lookup = false; CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage( &error_msg_stream, command_name, llvm::StringRef(), llvm::StringRef(), - generate_apropos, generate_type_lookup); + generate_upropos, generate_type_lookup); result.AppendError(error_msg_stream.GetString()); result.SetStatus(eReturnStatusFailed); return false; @@ -914,9 +909,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectCommandsAddRegex -//------------------------------------------------------------------------- static constexpr OptionDefinition g_regex_options[] = { // clang-format off @@ -976,10 +969,10 @@ a number follows 'f':" ~CommandObjectCommandsAddRegex() override = default; protected: - void IOHandlerActivated(IOHandler &io_handler) override { + void IOHandlerActivated(IOHandler &io_handler, bool interactive) override { StreamFileSP output_sp(io_handler.GetOutputStreamFile()); - if (output_sp) { - output_sp->PutCString("Enter one of more sed substitution commands in " + if (output_sp && interactive) { + output_sp->PutCString("Enter one or more sed substitution commands in " "the form: 's/<regex>/<subst>/'.\nTerminate the " "substitution list with an empty line.\n"); output_sp->Flush(); @@ -989,7 +982,7 @@ protected: void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override { io_handler.SetIsDone(true); - if (m_regex_cmd_ap) { + if (m_regex_cmd_up) { StringList lines; if (lines.SplitIntoLines(data)) { const size_t num_lines = lines.GetSize(); @@ -998,18 +991,15 @@ protected: llvm::StringRef bytes_strref(lines[i]); Status error = AppendRegexSubstitution(bytes_strref, check_only); if (error.Fail()) { - if (!m_interpreter.GetDebugger() - .GetCommandInterpreter() - .GetBatchCommandMode()) { - StreamSP out_stream = - m_interpreter.GetDebugger().GetAsyncOutputStream(); + if (!GetDebugger().GetCommandInterpreter().GetBatchCommandMode()) { + StreamSP out_stream = GetDebugger().GetAsyncOutputStream(); out_stream->Printf("error: %s\n", error.AsCString()); } } } } - if (m_regex_cmd_ap->HasRegexEntries()) { - CommandObjectSP cmd_sp(m_regex_cmd_ap.release()); + if (m_regex_cmd_up->HasRegexEntries()) { + CommandObjectSP cmd_sp(m_regex_cmd_up.release()); m_interpreter.AddCommand(cmd_sp->GetCommandName(), cmd_sp, true); } } @@ -1026,12 +1016,12 @@ protected: Status error; auto name = command[0].ref; - m_regex_cmd_ap = llvm::make_unique<CommandObjectRegexCommand>( + m_regex_cmd_up = llvm::make_unique<CommandObjectRegexCommand>( m_interpreter, name, m_options.GetHelp(), m_options.GetSyntax(), 10, 0, true); if (argc == 1) { - Debugger &debugger = m_interpreter.GetDebugger(); + Debugger &debugger = GetDebugger(); bool color_prompt = debugger.GetUseColor(); const bool multiple_lines = true; // Get multiple lines IOHandlerSP io_handler_sp(new IOHandlerEditline( @@ -1041,7 +1031,7 @@ protected: llvm::StringRef(), // Continuation prompt multiple_lines, color_prompt, 0, // Don't show line numbers - *this)); + *this, nullptr)); if (io_handler_sp) { debugger.PushIOHandler(io_handler_sp); @@ -1071,7 +1061,7 @@ protected: bool check_only) { Status error; - if (!m_regex_cmd_ap) { + if (!m_regex_cmd_up) { error.SetErrorStringWithFormat( "invalid regular expression command object for: '%.*s'", (int)regex_sed.size(), regex_sed.data()); @@ -1157,22 +1147,22 @@ protected: std::string subst(regex_sed.substr(second_separator_char_pos + 1, third_separator_char_pos - second_separator_char_pos - 1)); - m_regex_cmd_ap->AddRegexCommand(regex.c_str(), subst.c_str()); + m_regex_cmd_up->AddRegexCommand(regex.c_str(), subst.c_str()); } return error; } void AddRegexCommandToInterpreter() { - if (m_regex_cmd_ap) { - if (m_regex_cmd_ap->HasRegexEntries()) { - CommandObjectSP cmd_sp(m_regex_cmd_ap.release()); + if (m_regex_cmd_up) { + if (m_regex_cmd_up->HasRegexEntries()) { + CommandObjectSP cmd_sp(m_regex_cmd_up.release()); m_interpreter.AddCommand(cmd_sp->GetCommandName(), cmd_sp, true); } } } private: - std::unique_ptr<CommandObjectRegexCommand> m_regex_cmd_ap; + std::unique_ptr<CommandObjectRegexCommand> m_regex_cmd_up; class CommandOptions : public Options { public: @@ -1259,7 +1249,7 @@ public: if (m_fetched_help_long) return CommandObjectRaw::GetHelpLong(); - ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter(); if (!scripter) return CommandObjectRaw::GetHelpLong(); @@ -1274,7 +1264,7 @@ public: protected: bool DoExecute(llvm::StringRef raw_command_line, CommandReturnObject &result) override { - ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter(); Status error; @@ -1317,7 +1307,7 @@ public: StreamString stream; stream.Printf("For more information run 'help %s'", name.c_str()); SetHelp(stream.GetString()); - if (ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter()) + if (ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter()) GetFlags().Set(scripter->GetFlagsForCommandObject(cmd_obj_sp)); } @@ -1332,7 +1322,7 @@ public: llvm::StringRef GetHelp() override { if (m_fetched_help_short) return CommandObjectRaw::GetHelp(); - ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter(); if (!scripter) return CommandObjectRaw::GetHelp(); std::string docstring; @@ -1348,7 +1338,7 @@ public: if (m_fetched_help_long) return CommandObjectRaw::GetHelpLong(); - ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter(); if (!scripter) return CommandObjectRaw::GetHelpLong(); @@ -1363,7 +1353,7 @@ public: protected: bool DoExecute(llvm::StringRef raw_command_line, CommandReturnObject &result) override { - ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter(); Status error; @@ -1394,9 +1384,7 @@ private: bool m_fetched_help_long : 1; }; -//------------------------------------------------------------------------- // CommandObjectCommandsScriptImport -//------------------------------------------------------------------------- static constexpr OptionDefinition g_script_import_options[] = { // clang-format off @@ -1477,8 +1465,7 @@ protected: }; bool DoExecute(Args &command, CommandReturnObject &result) override { - if (m_interpreter.GetDebugger().GetScriptLanguage() != - lldb::eScriptLanguagePython) { + if (GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython) { result.AppendError("only scripting language supported for module " "importing is currently Python"); result.SetStatus(eReturnStatusFailed); @@ -1504,7 +1491,7 @@ protected: // won't stomp on each other (wrt to execution contents, options, and // more) m_exe_ctx.Clear(); - if (m_interpreter.GetScriptInterpreter()->LoadScriptingModule( + if (GetDebugger().GetScriptInterpreter()->LoadScriptingModule( entry.c_str(), m_options.m_allow_reload, init_session, error)) { result.SetStatus(eReturnStatusSuccessFinishNoResult); } else { @@ -1520,9 +1507,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectCommandsScriptAdd -//------------------------------------------------------------------------- static constexpr OptionEnumValueElement g_script_synchro_type[] = { {eScriptedCommandSynchronicitySynchronous, "synchronous", "Run synchronous"}, @@ -1635,9 +1620,9 @@ protected: ScriptedCommandSynchronicity m_synchronicity; }; - void IOHandlerActivated(IOHandler &io_handler) override { + void IOHandlerActivated(IOHandler &io_handler, bool interactive) override { StreamFileSP output_sp(io_handler.GetOutputStreamFile()); - if (output_sp) { + if (output_sp && interactive) { output_sp->PutCString(g_python_command_instructions); output_sp->Flush(); } @@ -1647,7 +1632,7 @@ protected: std::string &data) override { StreamFileSP error_sp = io_handler.GetErrorStreamFile(); - ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter(); if (interpreter) { StringList lines; @@ -1693,8 +1678,7 @@ protected: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - if (m_interpreter.GetDebugger().GetScriptLanguage() != - lldb::eScriptLanguagePython) { + if (GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython) { result.AppendError("only scripting language supported for scripted " "commands is currently Python"); result.SetStatus(eReturnStatusFailed); @@ -1732,8 +1716,7 @@ protected: } } } else { - ScriptInterpreter *interpreter = - GetCommandInterpreter().GetScriptInterpreter(); + ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter(); if (!interpreter) { result.AppendError("cannot find ScriptInterpreter"); result.SetStatus(eReturnStatusFailed); @@ -1767,9 +1750,7 @@ protected: ScriptedCommandSynchronicity m_synchronicity; }; -//------------------------------------------------------------------------- // CommandObjectCommandsScriptList -//------------------------------------------------------------------------- class CommandObjectCommandsScriptList : public CommandObjectParsed { public: @@ -1788,9 +1769,7 @@ public: } }; -//------------------------------------------------------------------------- // CommandObjectCommandsScriptClear -//------------------------------------------------------------------------- class CommandObjectCommandsScriptClear : public CommandObjectParsed { public: @@ -1810,9 +1789,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectCommandsScriptDelete -//------------------------------------------------------------------------- class CommandObjectCommandsScriptDelete : public CommandObjectParsed { public: @@ -1862,9 +1839,7 @@ protected: #pragma mark CommandObjectMultiwordCommandsScript -//------------------------------------------------------------------------- // CommandObjectMultiwordCommandsScript -//------------------------------------------------------------------------- class CommandObjectMultiwordCommandsScript : public CommandObjectMultiword { public: @@ -1894,9 +1869,7 @@ public: #pragma mark CommandObjectMultiwordCommands -//------------------------------------------------------------------------- // CommandObjectMultiwordCommands -//------------------------------------------------------------------------- CommandObjectMultiwordCommands::CommandObjectMultiwordCommands( CommandInterpreter &interpreter) diff --git a/source/Commands/CommandObjectCommands.h b/source/Commands/CommandObjectCommands.h index 57ae8f27efec..468ee53344f1 100644 --- a/source/Commands/CommandObjectCommands.h +++ b/source/Commands/CommandObjectCommands.h @@ -1,10 +1,9 @@ //===-- CommandObjectCommands.h -----------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -17,9 +16,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectMultiwordCommands -//------------------------------------------------------------------------- class CommandObjectMultiwordCommands : public CommandObjectMultiword { public: diff --git a/source/Commands/CommandObjectDisassemble.cpp b/source/Commands/CommandObjectDisassemble.cpp index f8ee46121851..5972555b2499 100644 --- a/source/Commands/CommandObjectDisassemble.cpp +++ b/source/Commands/CommandObjectDisassemble.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectDisassemble.cpp ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -230,9 +229,7 @@ CommandObjectDisassemble::CommandOptions::GetDefinitions() { return llvm::makeArrayRef(g_disassemble_options); } -//------------------------------------------------------------------------- // CommandObjectDisassemble -//------------------------------------------------------------------------- CommandObjectDisassemble::CommandObjectDisassemble( CommandInterpreter &interpreter) @@ -248,7 +245,7 @@ CommandObjectDisassemble::~CommandObjectDisassemble() = default; bool CommandObjectDisassemble::DoExecute(Args &command, CommandReturnObject &result) { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("invalid target, create a debug target using the " "'target create' command"); @@ -323,8 +320,8 @@ bool CommandObjectDisassemble::DoExecute(Args &command, ConstString name(m_options.func_name.c_str()); if (Disassembler::Disassemble( - m_interpreter.GetDebugger(), m_options.arch, plugin_name, - flavor_string, m_exe_ctx, name, + GetDebugger(), m_options.arch, plugin_name, flavor_string, + m_exe_ctx, name, nullptr, // Module * m_options.num_instructions, m_options.show_mixed, m_options.show_mixed ? m_options.num_lines_context : 0, options, @@ -487,8 +484,8 @@ bool CommandObjectDisassemble::DoExecute(Args &command, bool print_sc_header = ranges.size() > 1; for (AddressRange cur_range : ranges) { if (Disassembler::Disassemble( - m_interpreter.GetDebugger(), m_options.arch, plugin_name, - flavor_string, m_exe_ctx, cur_range.GetBaseAddress(), + GetDebugger(), m_options.arch, plugin_name, flavor_string, + m_exe_ctx, cur_range.GetBaseAddress(), m_options.num_instructions, m_options.show_mixed, m_options.show_mixed ? m_options.num_lines_context : 0, options, result.GetOutputStream())) { @@ -535,8 +532,8 @@ bool CommandObjectDisassemble::DoExecute(Args &command, cur_range.SetByteSize(DEFAULT_DISASM_BYTE_SIZE); if (Disassembler::Disassemble( - m_interpreter.GetDebugger(), m_options.arch, plugin_name, - flavor_string, m_exe_ctx, cur_range, m_options.num_instructions, + GetDebugger(), m_options.arch, plugin_name, flavor_string, + m_exe_ctx, cur_range, m_options.num_instructions, m_options.show_mixed, m_options.show_mixed ? m_options.num_lines_context : 0, options, result.GetOutputStream())) { diff --git a/source/Commands/CommandObjectDisassemble.h b/source/Commands/CommandObjectDisassemble.h index 04c4cc247ee9..70193e914c7f 100644 --- a/source/Commands/CommandObjectDisassemble.h +++ b/source/Commands/CommandObjectDisassemble.h @@ -1,9 +1,8 @@ //===-- CommandObjectDisassemble.h ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,9 +15,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectDisassemble -//------------------------------------------------------------------------- class CommandObjectDisassemble : public CommandObjectParsed { public: diff --git a/source/Commands/CommandObjectExpression.cpp b/source/Commands/CommandObjectExpression.cpp index e87d68a53da4..29e4ab695522 100644 --- a/source/Commands/CommandObjectExpression.cpp +++ b/source/Commands/CommandObjectExpression.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectExpression.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -11,7 +10,6 @@ #include "llvm/ADT/StringRef.h" #include "CommandObjectExpression.h" -#include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectVariable.h" @@ -235,7 +233,7 @@ Single and multi-line expressions: with no newlines. To evaluate a multi-line expression, \ hit a return after an empty expression, and lldb will enter the multi-line expression editor. \ Hit return on an empty line to end the multi-line expression." - + R"( Timeouts: @@ -364,7 +362,7 @@ int CommandObjectExpression::HandleCompletion(CompletionRequest &request) { Status error; lldb::UserExpressionSP expr(target->GetUserExpressionForLanguage( code, llvm::StringRef(), language, UserExpression::eResultTypeAny, - options, error)); + options, nullptr, error)); if (error.Fail()) return 0; @@ -483,8 +481,7 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr, } else { if (result_valobj_sp->GetError().GetError() == UserExpression::kNoResult) { - if (format != eFormatVoid && - m_interpreter.GetDebugger().GetNotifyVoid()) { + if (format != eFormatVoid && GetDebugger().GetNotifyVoid()) { error_stream->PutCString("(void)\n"); } @@ -561,7 +558,7 @@ void CommandObjectExpression::GetMultilineExpression() { llvm::StringRef(), // Continuation prompt multiple_lines, color_prompt, 1, // Show line numbers starting at 1 - *this)); + *this, nullptr)); StreamFileSP output_sp(io_handler_sp->GetOutputStreamFile()); if (output_sp) { @@ -572,6 +569,29 @@ void CommandObjectExpression::GetMultilineExpression() { debugger.PushIOHandler(io_handler_sp); } +static EvaluateExpressionOptions +GetExprOptions(ExecutionContext &ctx, + CommandObjectExpression::CommandOptions command_options) { + command_options.OptionParsingStarting(&ctx); + + // Default certain settings for REPL regardless of the global settings. + command_options.unwind_on_error = false; + command_options.ignore_breakpoints = false; + command_options.debug = false; + + EvaluateExpressionOptions expr_options; + expr_options.SetUnwindOnError(command_options.unwind_on_error); + expr_options.SetIgnoreBreakpoints(command_options.ignore_breakpoints); + expr_options.SetTryAllThreads(command_options.try_all_threads); + + if (command_options.timeout > 0) + expr_options.SetTimeout(std::chrono::microseconds(command_options.timeout)); + else + expr_options.SetTimeout(llvm::None); + + return expr_options; +} + bool CommandObjectExpression::DoExecute(llvm::StringRef command, CommandReturnObject &result) { m_fixed_expression.clear(); @@ -627,7 +647,8 @@ bool CommandObjectExpression::DoExecute(llvm::StringRef command, if (repl_sp) { if (initialize) { - repl_sp->SetCommandOptions(m_command_options); + repl_sp->SetEvaluateOptions( + GetExprOptions(exe_ctx, m_command_options)); repl_sp->SetFormatOptions(m_format_options); repl_sp->SetValueObjectDisplayOptions(m_varobj_options); } diff --git a/source/Commands/CommandObjectExpression.h b/source/Commands/CommandObjectExpression.h index 2eeca0da0578..89c8e1dbeceb 100644 --- a/source/Commands/CommandObjectExpression.h +++ b/source/Commands/CommandObjectExpression.h @@ -1,9 +1,8 @@ //===-- CommandObjectExpression.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -58,9 +57,7 @@ public: int HandleCompletion(CompletionRequest &request) override; protected: - //------------------------------------------------------------------ // IOHandler::Delegate functions - //------------------------------------------------------------------ void IOHandlerInputComplete(IOHandler &io_handler, std::string &line) override; @@ -71,7 +68,7 @@ protected: bool EvaluateExpression(llvm::StringRef expr, Stream *output_stream, Stream *error_stream, - CommandReturnObject *result = NULL); + CommandReturnObject *result = nullptr); void GetMultilineExpression(); diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp index f8318a38e28d..ab6a07952f19 100644 --- a/source/Commands/CommandObjectFrame.cpp +++ b/source/Commands/CommandObjectFrame.cpp @@ -1,14 +1,10 @@ //===-- CommandObjectFrame.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 <string> - #include "CommandObjectFrame.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" @@ -46,18 +42,17 @@ #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" +#include <memory> +#include <string> + using namespace lldb; using namespace lldb_private; #pragma mark CommandObjectFrameDiagnose -//------------------------------------------------------------------------- // CommandObjectFrameInfo -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- // CommandObjectFrameDiagnose -//------------------------------------------------------------------------- static constexpr OptionDefinition g_frame_diag_options[] = { // clang-format off @@ -217,9 +212,7 @@ protected: #pragma mark CommandObjectFrameInfo -//------------------------------------------------------------------------- // CommandObjectFrameInfo -//------------------------------------------------------------------------- class CommandObjectFrameInfo : public CommandObjectParsed { public: @@ -243,9 +236,7 @@ protected: #pragma mark CommandObjectFrameSelect -//------------------------------------------------------------------------- // CommandObjectFrameSelect -//------------------------------------------------------------------------- static OptionDefinition g_frame_select_options[] = { // clang-format off @@ -413,9 +404,7 @@ protected: }; #pragma mark CommandObjectFrameVariable -//---------------------------------------------------------------------- // List images with associated information -//---------------------------------------------------------------------- class CommandObjectFrameVariable : public CommandObjectParsed { public: CommandObjectFrameVariable(CommandInterpreter &interpreter) @@ -527,9 +516,9 @@ protected: ConstString(m_option_variable.summary.GetCurrentValue()), summary_format_sp); else if (!m_option_variable.summary_string.IsCurrentValueEmpty()) - summary_format_sp.reset(new StringSummaryFormat( + summary_format_sp = std::make_shared<StringSummaryFormat>( TypeSummaryImpl::Flags(), - m_option_variable.summary_string.GetCurrentValue())); + m_option_variable.summary_string.GetCurrentValue()); DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions( eLanguageRuntimeDescriptionDisplayVerbosityFull, eFormatDefault, @@ -901,7 +890,7 @@ bool CommandObjectFrameRecognizerAdd::DoExecute(Args &command, return false; } - ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter(); if (interpreter && !interpreter->CheckObjectExists(m_options.m_class_name.c_str())) { @@ -1119,9 +1108,7 @@ class CommandObjectFrameRecognizer : public CommandObjectMultiword { #pragma mark CommandObjectMultiwordFrame -//------------------------------------------------------------------------- // CommandObjectMultiwordFrame -//------------------------------------------------------------------------- CommandObjectMultiwordFrame::CommandObjectMultiwordFrame( CommandInterpreter &interpreter) diff --git a/source/Commands/CommandObjectFrame.h b/source/Commands/CommandObjectFrame.h index 3199399163df..46a59f71733b 100644 --- a/source/Commands/CommandObjectFrame.h +++ b/source/Commands/CommandObjectFrame.h @@ -1,9 +1,8 @@ //===-- CommandObjectFrame.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,9 +14,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectMultiwordFrame -//------------------------------------------------------------------------- class CommandObjectMultiwordFrame : public CommandObjectMultiword { public: diff --git a/source/Commands/CommandObjectGUI.cpp b/source/Commands/CommandObjectGUI.cpp index ed834dcbe4fb..21ed510d1264 100644 --- a/source/Commands/CommandObjectGUI.cpp +++ b/source/Commands/CommandObjectGUI.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,9 +15,7 @@ using namespace lldb; using namespace lldb_private; -//------------------------------------------------------------------------- // CommandObjectGUI -//------------------------------------------------------------------------- CommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "gui", @@ -29,7 +26,7 @@ CommandObjectGUI::~CommandObjectGUI() {} bool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) { #ifndef LLDB_DISABLE_CURSES if (args.GetArgumentCount() == 0) { - Debugger &debugger = m_interpreter.GetDebugger(); + Debugger &debugger = GetDebugger(); lldb::StreamFileSP input_sp = debugger.GetInputFile(); if (input_sp && input_sp->GetFile().GetIsRealTerminal() && diff --git a/source/Commands/CommandObjectGUI.h b/source/Commands/CommandObjectGUI.h index b20c3a7191ab..a19aad18ec35 100644 --- a/source/Commands/CommandObjectGUI.h +++ b/source/Commands/CommandObjectGUI.h @@ -1,9 +1,8 @@ //===-- CommandObjectGUI.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,9 +13,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectGUI -//------------------------------------------------------------------------- class CommandObjectGUI : public CommandObjectParsed { public: diff --git a/source/Commands/CommandObjectHelp.cpp b/source/Commands/CommandObjectHelp.cpp index 1f1d63d72903..ab557919d0a0 100644 --- a/source/Commands/CommandObjectHelp.cpp +++ b/source/Commands/CommandObjectHelp.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectHelp.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,13 +15,12 @@ using namespace lldb; using namespace lldb_private; -//------------------------------------------------------------------------- // CommandObjectHelp -//------------------------------------------------------------------------- void CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage( - Stream *s, llvm::StringRef command, llvm::StringRef prefix, llvm::StringRef subcommand, - bool include_apropos, bool include_type_lookup) { + Stream *s, llvm::StringRef command, llvm::StringRef prefix, + llvm::StringRef subcommand, bool include_upropos, + bool include_type_lookup) { if (!s || command.empty()) return; @@ -33,7 +31,7 @@ void CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage( s->Printf("'%s' is not a known command.\n", command_str.c_str()); s->Printf("Try '%shelp' to see a current list of commands.\n", prefix.str().c_str()); - if (include_apropos) { + if (include_upropos) { s->Printf("Try '%sapropos %s' for a list of related commands.\n", prefix_str.c_str(), lookup_str.c_str()); } @@ -68,11 +66,8 @@ CommandObjectHelp::CommandObjectHelp(CommandInterpreter &interpreter) CommandObjectHelp::~CommandObjectHelp() = default; static constexpr OptionDefinition g_help_options[] = { - // clang-format off - {LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Hide aliases in the command list."}, - {LLDB_OPT_SET_ALL, false, "hide-user-commands", 'u', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Hide user-defined commands from the list."}, - {LLDB_OPT_SET_ALL, false, "show-hidden-commands", 'h', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Include commands prefixed with an underscore."}, - // clang-format on +#define LLDB_OPTIONS_help +#include "CommandOptions.inc" }; llvm::ArrayRef<OptionDefinition> diff --git a/source/Commands/CommandObjectHelp.h b/source/Commands/CommandObjectHelp.h index 5d5b672a5fbd..a641b19a46d0 100644 --- a/source/Commands/CommandObjectHelp.h +++ b/source/Commands/CommandObjectHelp.h @@ -1,9 +1,8 @@ //===-- CommandObjectHelp.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,9 +15,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectHelp -//------------------------------------------------------------------------- class CommandObjectHelp : public CommandObjectParsed { public: @@ -30,7 +27,7 @@ public: static void GenerateAdditionalHelpAvenuesMessage( Stream *s, llvm::StringRef command, llvm::StringRef prefix, - llvm::StringRef subcommand, bool include_apropos = true, + llvm::StringRef subcommand, bool include_upropos = true, bool include_type_lookup = true); class CommandOptions : public Options { diff --git a/source/Commands/CommandObjectLanguage.cpp b/source/Commands/CommandObjectLanguage.cpp index f0028d65da37..47c9e2a52023 100644 --- a/source/Commands/CommandObjectLanguage.cpp +++ b/source/Commands/CommandObjectLanguage.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectLanguage.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectLanguage.h b/source/Commands/CommandObjectLanguage.h index ef8e11863e7e..b86457c99af3 100644 --- a/source/Commands/CommandObjectLanguage.h +++ b/source/Commands/CommandObjectLanguage.h @@ -1,9 +1,8 @@ //===-- CommandObjectLanguage.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectLog.cpp b/source/Commands/CommandObjectLog.cpp index b019336bdc92..2ad61de1a3e9 100644 --- a/source/Commands/CommandObjectLog.cpp +++ b/source/Commands/CommandObjectLog.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectLog.cpp ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -49,9 +48,7 @@ static constexpr OptionDefinition g_log_options[] = { class CommandObjectLogEnable : public CommandObjectParsed { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ CommandObjectLogEnable(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "log enable", "Enable logging for a single log channel.", @@ -171,9 +168,9 @@ protected: std::string error; llvm::raw_string_ostream error_stream(error); - bool success = m_interpreter.GetDebugger().EnableLog( - channel, args.GetArgumentArrayRef(), log_file, m_options.log_options, - error_stream); + bool success = + GetDebugger().EnableLog(channel, args.GetArgumentArrayRef(), log_file, + m_options.log_options, error_stream); result.GetErrorStream() << error_stream.str(); if (success) @@ -188,9 +185,7 @@ protected: class CommandObjectLogDisable : public CommandObjectParsed { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ CommandObjectLogDisable(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "log disable", "Disable one or more log channel categories.", @@ -248,9 +243,7 @@ protected: class CommandObjectLogList : public CommandObjectParsed { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ CommandObjectLogList(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "log list", "List the log categories for one or more log " @@ -295,9 +288,7 @@ protected: class CommandObjectLogTimer : public CommandObjectParsed { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ CommandObjectLogTimer(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "log timers", "Enable, disable, dump, and reset LLDB internal " diff --git a/source/Commands/CommandObjectLog.h b/source/Commands/CommandObjectLog.h index f02a7be514ac..b2da900e21ed 100644 --- a/source/Commands/CommandObjectLog.h +++ b/source/Commands/CommandObjectLog.h @@ -1,9 +1,8 @@ //===-- CommandObjectLog.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -17,23 +16,17 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectLog -//------------------------------------------------------------------------- class CommandObjectLog : public CommandObjectMultiword { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ CommandObjectLog(CommandInterpreter &interpreter); ~CommandObjectLog() override; private: - //------------------------------------------------------------------ // For CommandObjectLog only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(CommandObjectLog); }; diff --git a/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp index b1edb1afa5d2..1afcac71318d 100644 --- a/source/Commands/CommandObjectMemory.cpp +++ b/source/Commands/CommandObjectMemory.cpp @@ -1,24 +1,19 @@ //===-- CommandObjectMemory.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 <inttypes.h> - -#include "clang/AST/Decl.h" - #include "CommandObjectMemory.h" -#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/DumpDataExtractor.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" #include "lldb/Core/ValueObjectMemory.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" +#include "lldb/Expression/ExpressionVariable.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -26,15 +21,17 @@ #include "lldb/Interpreter/OptionGroupFormat.h" #include "lldb/Interpreter/OptionGroupOutputFile.h" #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" +#include "lldb/Interpreter/OptionValueLanguage.h" #include "lldb/Interpreter/OptionValueString.h" #include "lldb/Interpreter/Options.h" -#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/TypeList.h" +#include "lldb/Target/Language.h" #include "lldb/Target/MemoryHistory.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/DataBufferHeap.h" @@ -43,6 +40,9 @@ #include "lldb/lldb-private.h" +#include <cinttypes> +#include <memory> + using namespace lldb; using namespace lldb_private; @@ -51,7 +51,9 @@ static constexpr OptionDefinition g_read_memory_options[] = { {LLDB_OPT_SET_1, false, "num-per-line", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNumberPerLine, "The number of items per line to display." }, {LLDB_OPT_SET_2, false, "binary", 'b', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that " "uses the format, size, count and number per line settings." }, - {LLDB_OPT_SET_3, true , "type", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNone, "The name of a type to view memory as." }, + {LLDB_OPT_SET_3 | + LLDB_OPT_SET_4, true , "type", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "The name of a type to view memory as." }, + {LLDB_OPT_SET_4, false, "language", 'x', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "The language of the type to view memory as."}, {LLDB_OPT_SET_3, false, "offset", 'E', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCount, "How many elements of the specified type to skip before starting to display data." }, {LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | @@ -63,7 +65,7 @@ class OptionGroupReadMemory : public OptionGroup { public: OptionGroupReadMemory() : m_num_per_line(1, 1), m_output_as_binary(false), m_view_as_type(), - m_offset(0, 0) {} + m_offset(0, 0), m_language_for_type(eLanguageTypeUnknown) {} ~OptionGroupReadMemory() override = default; @@ -97,6 +99,10 @@ public: m_force = true; break; + case 'x': + error = m_language_for_type.SetValueFromString(option_value); + break; + case 'E': error = m_offset.SetValueFromString(option_value); break; @@ -115,6 +121,7 @@ public: m_view_as_type.Clear(); m_force = false; m_offset.Clear(); + m_language_for_type.Clear(); } Status FinalizeSettings(Target *target, OptionGroupFormat &format_options) { @@ -277,7 +284,8 @@ public: bool AnyOptionWasSet() const { return m_num_per_line.OptionWasSet() || m_output_as_binary || - m_view_as_type.OptionWasSet() || m_offset.OptionWasSet(); + m_view_as_type.OptionWasSet() || m_offset.OptionWasSet() || + m_language_for_type.OptionWasSet(); } OptionValueUInt64 m_num_per_line; @@ -285,11 +293,10 @@ public: OptionValueString m_view_as_type; bool m_force; OptionValueUInt64 m_offset; + OptionValueLanguage m_language_for_type; }; -//---------------------------------------------------------------------- // Read memory from the inferior process -//---------------------------------------------------------------------- class CommandObjectMemoryRead : public CommandObjectParsed { public: CommandObjectMemoryRead(CommandInterpreter &interpreter) @@ -374,7 +381,7 @@ protected: return false; } - CompilerType clang_ast_type; + CompilerType compiler_type; Status error; const char *view_as_type_cstr = @@ -474,26 +481,43 @@ protected: exact_match, 1, searched_symbol_files, type_list); - if (type_list.GetSize() == 0 && lookup_type_name.GetCString() && - *lookup_type_name.GetCString() == '$') { - if (ClangPersistentVariables *persistent_vars = - llvm::dyn_cast_or_null<ClangPersistentVariables>( - target->GetPersistentExpressionStateForLanguage( - lldb::eLanguageTypeC))) { - clang::TypeDecl *tdecl = llvm::dyn_cast_or_null<clang::TypeDecl>( - persistent_vars->GetPersistentDecl( - ConstString(lookup_type_name))); - - if (tdecl) { - clang_ast_type.SetCompilerType( - ClangASTContext::GetASTContext(&tdecl->getASTContext()), - reinterpret_cast<lldb::opaque_compiler_type_t>( - const_cast<clang::Type *>(tdecl->getTypeForDecl()))); + if (type_list.GetSize() == 0 && lookup_type_name.GetCString()) { + LanguageType language_for_type = + m_memory_options.m_language_for_type.GetCurrentValue(); + std::set<LanguageType> languages_to_check; + if (language_for_type != eLanguageTypeUnknown) { + languages_to_check.insert(language_for_type); + } else { + languages_to_check = Language::GetSupportedLanguages(); + } + + std::set<CompilerType> user_defined_types; + for (auto lang : languages_to_check) { + if (auto *persistent_vars = + target->GetPersistentExpressionStateForLanguage(lang)) { + if (llvm::Optional<CompilerType> type = + persistent_vars->GetCompilerTypeFromPersistentDecl( + lookup_type_name)) { + user_defined_types.emplace(*type); + } } } + + if (user_defined_types.size() > 1) { + result.AppendErrorWithFormat( + "Mutiple types found matching raw type '%s', please disambiguate " + "by specifying the language with -x", + lookup_type_name.GetCString()); + result.SetStatus(eReturnStatusFailed); + return false; + } + + if (user_defined_types.size() == 1) { + compiler_type = *user_defined_types.begin(); + } } - if (!clang_ast_type.IsValid()) { + if (!compiler_type.IsValid()) { if (type_list.GetSize() == 0) { result.AppendErrorWithFormat("unable to find any types that match " "the raw type '%s' for full type '%s'\n", @@ -503,14 +527,14 @@ protected: return false; } else { TypeSP type_sp(type_list.GetTypeAtIndex(0)); - clang_ast_type = type_sp->GetFullCompilerType(); + compiler_type = type_sp->GetFullCompilerType(); } } while (pointer_count > 0) { - CompilerType pointer_type = clang_ast_type.GetPointerType(); + CompilerType pointer_type = compiler_type.GetPointerType(); if (pointer_type.IsValid()) - clang_ast_type = pointer_type; + compiler_type = pointer_type; else { result.AppendError("unable make a pointer type\n"); result.SetStatus(eReturnStatusFailed); @@ -519,7 +543,7 @@ protected: --pointer_count; } - llvm::Optional<uint64_t> size = clang_ast_type.GetByteSize(nullptr); + llvm::Optional<uint64_t> size = compiler_type.GetByteSize(nullptr); if (!size) { result.AppendErrorWithFormat( "unable to get the byte size of the type '%s'\n", @@ -549,7 +573,7 @@ protected: // options have been set addr = m_next_addr; total_byte_size = m_prev_byte_size; - clang_ast_type = m_prev_clang_ast_type; + compiler_type = m_prev_compiler_type; if (!m_format_options.AnyOptionWasSet() && !m_memory_options.AnyOptionWasSet() && !m_outfile_options.AnyOptionWasSet() && @@ -636,13 +660,13 @@ protected: DataBufferSP data_sp; size_t bytes_read = 0; - if (clang_ast_type.GetOpaqueQualType()) { + if (compiler_type.GetOpaqueQualType()) { // Make sure we don't display our type as ASCII bytes like the default // memory read if (!m_format_options.GetFormatValue().OptionWasSet()) m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault); - llvm::Optional<uint64_t> size = clang_ast_type.GetByteSize(nullptr); + llvm::Optional<uint64_t> size = compiler_type.GetByteSize(nullptr); if (!size) { result.AppendError("can't get size of type"); return false; @@ -653,7 +677,7 @@ protected: addr = addr + (*size * m_memory_options.m_offset.GetCurrentValue()); } else if (m_format_options.GetFormatValue().GetCurrentValue() != eFormatCString) { - data_sp.reset(new DataBufferHeap(total_byte_size, '\0')); + data_sp = std::make_shared<DataBufferHeap>(total_byte_size, '\0'); if (data_sp->GetBytes() == nullptr) { result.AppendErrorWithFormat( "can't allocate 0x%" PRIx32 @@ -693,8 +717,9 @@ protected: item_byte_size = target->GetMaximumSizeOfStringSummary(); if (!m_format_options.GetCountValue().OptionWasSet()) item_count = 1; - data_sp.reset(new DataBufferHeap((item_byte_size + 1) * item_count, - '\0')); // account for NULLs as necessary + data_sp = std::make_shared<DataBufferHeap>( + (item_byte_size + 1) * item_count, + '\0'); // account for NULLs as necessary if (data_sp->GetBytes() == nullptr) { result.AppendErrorWithFormat( "can't allocate 0x%" PRIx64 @@ -741,7 +766,8 @@ protected: if (break_on_no_NULL) break; } - data_sp.reset(new DataBufferHeap(data_sp->GetBytes(), bytes_read + 1)); + data_sp = + std::make_shared<DataBufferHeap>(data_sp->GetBytes(), bytes_read + 1); } m_next_addr = addr + bytes_read; @@ -750,7 +776,7 @@ protected: m_prev_memory_options = m_memory_options; m_prev_outfile_options = m_outfile_options; m_prev_varobj_options = m_varobj_options; - m_prev_clang_ast_type = clang_ast_type; + m_prev_compiler_type = compiler_type; StreamFile outfile_stream; Stream *output_stream = nullptr; @@ -800,14 +826,14 @@ protected: } ExecutionContextScope *exe_scope = m_exe_ctx.GetBestExecutionContextScope(); - if (clang_ast_type.GetOpaqueQualType()) { + if (compiler_type.GetOpaqueQualType()) { for (uint32_t i = 0; i < item_count; ++i) { addr_t item_addr = addr + (i * item_byte_size); Address address(item_addr); StreamString name_strm; name_strm.Printf("0x%" PRIx64, item_addr); ValueObjectSP valobj_sp(ValueObjectMemory::Create( - exe_scope, name_strm.GetString(), address, clang_ast_type)); + exe_scope, name_strm.GetString(), address, compiler_type)); if (valobj_sp) { Format format = m_format_options.GetFormat(); if (format != eFormatDefault) @@ -877,7 +903,7 @@ protected: OptionGroupReadMemory m_prev_memory_options; OptionGroupOutputFile m_prev_outfile_options; OptionGroupValueObjectDisplay m_prev_varobj_options; - CompilerType m_prev_clang_ast_type; + CompilerType m_prev_compiler_type; }; static constexpr OptionDefinition g_memory_find_option_table[] = { @@ -889,9 +915,7 @@ static constexpr OptionDefinition g_memory_find_option_table[] = { // clang-format on }; -//---------------------------------------------------------------------- // Find the specified data in memory -//---------------------------------------------------------------------- class CommandObjectMemoryFind : public CommandObjectParsed { public: class OptionGroupFindMemory : public OptionGroup { @@ -1186,9 +1210,7 @@ static constexpr OptionDefinition g_memory_write_option_table[] = { // clang-format on }; -//---------------------------------------------------------------------- // Write memory to the inferior process -//---------------------------------------------------------------------- class CommandObjectMemoryWrite : public CommandObjectParsed { public: class OptionGroupWriteMemory : public OptionGroup { @@ -1595,9 +1617,7 @@ protected: OptionGroupWriteMemory m_memory_options; }; -//---------------------------------------------------------------------- // Get malloc/free history of a memory address. -//---------------------------------------------------------------------- class CommandObjectMemoryHistory : public CommandObjectParsed { public: CommandObjectMemoryHistory(CommandInterpreter &interpreter) @@ -1677,9 +1697,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectMemoryRegion -//------------------------------------------------------------------------- #pragma mark CommandObjectMemoryRegion class CommandObjectMemoryRegion : public CommandObjectParsed { @@ -1770,9 +1788,7 @@ protected: lldb::addr_t m_prev_end_addr; }; -//------------------------------------------------------------------------- // CommandObjectMemory -//------------------------------------------------------------------------- CommandObjectMemory::CommandObjectMemory(CommandInterpreter &interpreter) : CommandObjectMultiword( diff --git a/source/Commands/CommandObjectMemory.h b/source/Commands/CommandObjectMemory.h index 0fa5251e82ff..f94cdf3287aa 100644 --- a/source/Commands/CommandObjectMemory.h +++ b/source/Commands/CommandObjectMemory.h @@ -1,9 +1,8 @@ //===-- CommandObjectMemory.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectMultiword.cpp b/source/Commands/CommandObjectMultiword.cpp index 64c4f6686e6b..4011cceb8a26 100644 --- a/source/Commands/CommandObjectMultiword.cpp +++ b/source/Commands/CommandObjectMultiword.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectMultiword.cpp ------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,9 +15,7 @@ using namespace lldb; using namespace lldb_private; -//------------------------------------------------------------------------- // CommandObjectMultiword -//------------------------------------------------------------------------- CommandObjectMultiword::CommandObjectMultiword(CommandInterpreter &interpreter, const char *name, diff --git a/source/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp index fc442f5f4d5d..53549cdeee32 100644 --- a/source/Commands/CommandObjectPlatform.cpp +++ b/source/Commands/CommandObjectPlatform.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectPlatform.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -154,9 +153,7 @@ private: DISALLOW_COPY_AND_ASSIGN(OptionPermissions); }; -//---------------------------------------------------------------------- // "platform select <platform-name>" -//---------------------------------------------------------------------- class CommandObjectPlatformSelect : public CommandObjectParsed { public: CommandObjectPlatformSelect(CommandInterpreter &interpreter) @@ -194,8 +191,7 @@ protected: PlatformSP platform_sp(m_platform_options.CreatePlatformWithOptions( m_interpreter, ArchSpec(), select, error, platform_arch)); if (platform_sp) { - m_interpreter.GetDebugger().GetPlatformList().SetSelectedPlatform( - platform_sp); + GetDebugger().GetPlatformList().SetSelectedPlatform(platform_sp); platform_sp->GetStatus(result.GetOutputStream()); result.SetStatus(eReturnStatusSuccessFinishResult); @@ -219,9 +215,7 @@ protected: OptionGroupPlatform m_platform_options; }; -//---------------------------------------------------------------------- // "platform list" -//---------------------------------------------------------------------- class CommandObjectPlatformList : public CommandObjectParsed { public: CommandObjectPlatformList(CommandInterpreter &interpreter) @@ -241,7 +235,7 @@ protected: host_platform_sp->GetDescription()); uint32_t idx; - for (idx = 0; 1; ++idx) { + for (idx = 0; true; ++idx) { const char *plugin_name = PluginManager::GetPlatformPluginNameAtIndex(idx); if (plugin_name == nullptr) @@ -262,9 +256,7 @@ protected: } }; -//---------------------------------------------------------------------- // "platform status" -//---------------------------------------------------------------------- class CommandObjectPlatformStatus : public CommandObjectParsed { public: CommandObjectPlatformStatus(CommandInterpreter &interpreter) @@ -278,14 +270,13 @@ protected: bool DoExecute(Args &args, CommandReturnObject &result) override { Stream &ostrm = result.GetOutputStream(); - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); PlatformSP platform_sp; if (target) { platform_sp = target->GetPlatform(); } if (!platform_sp) { - platform_sp = - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform(); + platform_sp = GetDebugger().GetPlatformList().GetSelectedPlatform(); } if (platform_sp) { platform_sp->GetStatus(ostrm); @@ -298,9 +289,7 @@ protected: } }; -//---------------------------------------------------------------------- // "platform connect <connect-url>" -//---------------------------------------------------------------------- class CommandObjectPlatformConnect : public CommandObjectParsed { public: CommandObjectPlatformConnect(CommandInterpreter &interpreter) @@ -316,15 +305,14 @@ protected: Stream &ostrm = result.GetOutputStream(); PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { Status error(platform_sp->ConnectRemote(args)); if (error.Success()) { platform_sp->GetStatus(ostrm); result.SetStatus(eReturnStatusSuccessFinishResult); - platform_sp->ConnectToWaitingProcesses(m_interpreter.GetDebugger(), - error); + platform_sp->ConnectToWaitingProcesses(GetDebugger(), error); if (error.Fail()) { result.AppendError(error.AsCString()); result.SetStatus(eReturnStatusFailed); @@ -342,7 +330,7 @@ protected: Options *GetOptions() override { PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); OptionGroupOptions *m_platform_options = nullptr; if (platform_sp) { m_platform_options = platform_sp->GetConnectionOptions(m_interpreter); @@ -353,9 +341,7 @@ protected: } }; -//---------------------------------------------------------------------- // "platform disconnect" -//---------------------------------------------------------------------- class CommandObjectPlatformDisconnect : public CommandObjectParsed { public: CommandObjectPlatformDisconnect(CommandInterpreter &interpreter) @@ -368,7 +354,7 @@ public: protected: bool DoExecute(Args &args, CommandReturnObject &result) override { PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { if (args.GetArgumentCount() == 0) { Status error; @@ -415,9 +401,7 @@ protected: } }; -//---------------------------------------------------------------------- // "platform settings" -//---------------------------------------------------------------------- class CommandObjectPlatformSettings : public CommandObjectParsed { public: CommandObjectPlatformSettings(CommandInterpreter &interpreter) @@ -437,7 +421,7 @@ public: protected: bool DoExecute(Args &args, CommandReturnObject &result) override { PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { if (m_option_working_dir.GetOptionValue().OptionWasSet()) platform_sp->SetWorkingDirectory( @@ -460,9 +444,7 @@ protected: OptionGroupFile m_option_working_dir; }; -//---------------------------------------------------------------------- // "platform mkdir" -//---------------------------------------------------------------------- class CommandObjectPlatformMkDir : public CommandObjectParsed { public: CommandObjectPlatformMkDir(CommandInterpreter &interpreter) @@ -475,7 +457,7 @@ public: bool DoExecute(Args &args, CommandReturnObject &result) override { PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { std::string cmd_line; args.GetCommandString(cmd_line); @@ -512,9 +494,7 @@ public: OptionGroupOptions m_options; }; -//---------------------------------------------------------------------- // "platform fopen" -//---------------------------------------------------------------------- class CommandObjectPlatformFOpen : public CommandObjectParsed { public: CommandObjectPlatformFOpen(CommandInterpreter &interpreter) @@ -526,7 +506,7 @@ public: bool DoExecute(Args &args, CommandReturnObject &result) override { PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { Status error; std::string cmd_line; @@ -569,9 +549,7 @@ public: OptionGroupOptions m_options; }; -//---------------------------------------------------------------------- // "platform fclose" -//---------------------------------------------------------------------- class CommandObjectPlatformFClose : public CommandObjectParsed { public: CommandObjectPlatformFClose(CommandInterpreter &interpreter) @@ -582,7 +560,7 @@ public: bool DoExecute(Args &args, CommandReturnObject &result) override { PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { std::string cmd_line; args.GetCommandString(cmd_line); @@ -605,9 +583,7 @@ public: } }; -//---------------------------------------------------------------------- // "platform fread" -//---------------------------------------------------------------------- static constexpr OptionDefinition g_platform_fread_options[] = { // clang-format off @@ -628,7 +604,7 @@ public: bool DoExecute(Args &args, CommandReturnObject &result) override { PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { std::string cmd_line; args.GetCommandString(cmd_line); @@ -700,9 +676,7 @@ protected: CommandOptions m_options; }; -//---------------------------------------------------------------------- // "platform fwrite" -//---------------------------------------------------------------------- static constexpr OptionDefinition g_platform_fwrite_options[] = { // clang-format off @@ -723,7 +697,7 @@ public: bool DoExecute(Args &args, CommandReturnObject &result) override { PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { std::string cmd_line; args.GetCommandString(cmd_line); @@ -794,9 +768,7 @@ protected: class CommandObjectPlatformFile : public CommandObjectMultiword { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ CommandObjectPlatformFile(CommandInterpreter &interpreter) : CommandObjectMultiword( interpreter, "platform file", @@ -815,15 +787,11 @@ public: ~CommandObjectPlatformFile() override = default; private: - //------------------------------------------------------------------ // For CommandObjectPlatform only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(CommandObjectPlatformFile); }; -//---------------------------------------------------------------------- // "platform get-file remote-file-path host-file-path" -//---------------------------------------------------------------------- class CommandObjectPlatformGetFile : public CommandObjectParsed { public: CommandObjectPlatformGetFile(CommandInterpreter &interpreter) @@ -874,7 +842,7 @@ public: } PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { const char *remote_file_path = args.GetArgumentAtIndex(0); const char *local_file_path = args.GetArgumentAtIndex(1); @@ -898,9 +866,7 @@ public: } }; -//---------------------------------------------------------------------- // "platform get-size remote-file-path" -//---------------------------------------------------------------------- class CommandObjectPlatformGetSize : public CommandObjectParsed { public: CommandObjectPlatformGetSize(CommandInterpreter &interpreter) @@ -941,7 +907,7 @@ public: } PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { std::string remote_file_path(args.GetArgumentAtIndex(0)); user_id_t size = platform_sp->GetFileSize(FileSpec(remote_file_path)); @@ -964,9 +930,7 @@ public: } }; -//---------------------------------------------------------------------- // "platform put-file" -//---------------------------------------------------------------------- class CommandObjectPlatformPutFile : public CommandObjectParsed { public: CommandObjectPlatformPutFile(CommandInterpreter &interpreter) @@ -986,7 +950,7 @@ public: FileSpec dst_fs(dst ? dst : src_fs.GetFilename().GetCString()); PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { Status error(platform_sp->PutFile(src_fs, dst_fs)); if (error.Success()) { @@ -1003,9 +967,7 @@ public: } }; -//---------------------------------------------------------------------- // "platform process launch" -//---------------------------------------------------------------------- class CommandObjectPlatformProcessLaunch : public CommandObjectParsed { public: CommandObjectPlatformProcessLaunch(CommandInterpreter &interpreter) @@ -1021,14 +983,13 @@ public: protected: bool DoExecute(Args &args, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); PlatformSP platform_sp; if (target) { platform_sp = target->GetPlatform(); } if (!platform_sp) { - platform_sp = - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform(); + platform_sp = GetDebugger().GetPlatformList().GetSelectedPlatform(); } if (platform_sp) { @@ -1059,7 +1020,7 @@ protected: } if (m_options.launch_info.GetExecutableFile()) { - Debugger &debugger = m_interpreter.GetDebugger(); + Debugger &debugger = GetDebugger(); if (argc == 0) target->GetRunArguments(m_options.launch_info.GetArguments()); @@ -1093,9 +1054,7 @@ protected: ProcessLaunchCommandOptions m_options; }; -//---------------------------------------------------------------------- // "platform process list" -//---------------------------------------------------------------------- static OptionDefinition g_platform_process_list_options[] = { // clang-format off @@ -1131,14 +1090,13 @@ public: protected: bool DoExecute(Args &args, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); PlatformSP platform_sp; if (target) { platform_sp = target->GetPlatform(); } if (!platform_sp) { - platform_sp = - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform(); + platform_sp = GetDebugger().GetPlatformList().GetSelectedPlatform(); } if (platform_sp) { @@ -1152,10 +1110,9 @@ protected: if (pid != LLDB_INVALID_PROCESS_ID) { ProcessInstanceInfo proc_info; if (platform_sp->GetProcessInfo(pid, proc_info)) { - ProcessInstanceInfo::DumpTableHeader(ostrm, platform_sp.get(), - m_options.show_args, + ProcessInstanceInfo::DumpTableHeader(ostrm, m_options.show_args, m_options.verbose); - proc_info.DumpAsTableRow(ostrm, platform_sp.get(), + proc_info.DumpAsTableRow(ostrm, platform_sp->GetUserIDResolver(), m_options.show_args, m_options.verbose); result.SetStatus(eReturnStatusSuccessFinishResult); } else { @@ -1213,13 +1170,12 @@ protected: result.AppendMessageWithFormat(" whose name %s \"%s\"", match_desc, match_name); result.AppendMessageWithFormat("\n"); - ProcessInstanceInfo::DumpTableHeader(ostrm, platform_sp.get(), - m_options.show_args, + ProcessInstanceInfo::DumpTableHeader(ostrm, m_options.show_args, m_options.verbose); for (uint32_t i = 0; i < matches; ++i) { proc_infos.GetProcessInfoAtIndex(i).DumpAsTableRow( - ostrm, platform_sp.get(), m_options.show_args, - m_options.verbose); + ostrm, platform_sp->GetUserIDResolver(), + m_options.show_args, m_options.verbose); } } } @@ -1396,9 +1352,7 @@ protected: CommandOptions m_options; }; -//---------------------------------------------------------------------- // "platform process info" -//---------------------------------------------------------------------- class CommandObjectPlatformProcessInfo : public CommandObjectParsed { public: CommandObjectPlatformProcessInfo(CommandInterpreter &interpreter) @@ -1425,14 +1379,13 @@ public: protected: bool DoExecute(Args &args, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); PlatformSP platform_sp; if (target) { platform_sp = target->GetPlatform(); } if (!platform_sp) { - platform_sp = - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform(); + platform_sp = GetDebugger().GetPlatformList().GetSelectedPlatform(); } if (platform_sp) { @@ -1454,7 +1407,7 @@ protected: if (platform_sp->GetProcessInfo(pid, proc_info)) { ostrm.Printf("Process information for process %" PRIu64 ":\n", pid); - proc_info.Dump(ostrm, platform_sp.get()); + proc_info.Dump(ostrm, platform_sp->GetUserIDResolver()); } else { ostrm.Printf("error: no process information is available for " "process %" PRIu64 "\n", @@ -1608,11 +1561,11 @@ public: bool DoExecute(Args &command, CommandReturnObject &result) override { PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) { Status err; ProcessSP remote_process_sp = platform_sp->Attach( - m_options.attach_info, m_interpreter.GetDebugger(), nullptr, err); + m_options.attach_info, GetDebugger(), nullptr, err); if (err.Fail()) { result.AppendError(err.AsCString()); result.SetStatus(eReturnStatusFailed); @@ -1636,9 +1589,7 @@ protected: class CommandObjectPlatformProcess : public CommandObjectMultiword { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ CommandObjectPlatformProcess(CommandInterpreter &interpreter) : CommandObjectMultiword(interpreter, "platform process", "Commands to query, launch and attach to " @@ -1659,15 +1610,11 @@ public: ~CommandObjectPlatformProcess() override = default; private: - //------------------------------------------------------------------ // For CommandObjectPlatform only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(CommandObjectPlatformProcess); }; -//---------------------------------------------------------------------- // "platform shell" -//---------------------------------------------------------------------- static constexpr OptionDefinition g_platform_shell_options[] = { // clang-format off { LLDB_OPT_SET_ALL, false, "timeout", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeValue, "Seconds to wait for the remote host to finish running the command." }, @@ -1746,7 +1693,7 @@ public: return false; PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); Status error; if (platform_sp) { FileSpec working_dir{}; @@ -1791,9 +1738,7 @@ public: CommandOptions m_options; }; -//---------------------------------------------------------------------- // "platform install" - install a target to a remote end -//---------------------------------------------------------------------- class CommandObjectPlatformInstall : public CommandObjectParsed { public: CommandObjectPlatformInstall(CommandInterpreter &interpreter) @@ -1820,7 +1765,7 @@ public: return false; } PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); if (!platform_sp) { result.AppendError("no platform currently selected"); result.SetStatus(eReturnStatusFailed); diff --git a/source/Commands/CommandObjectPlatform.h b/source/Commands/CommandObjectPlatform.h index e15df5a0441f..c94d2ea2cc4d 100644 --- a/source/Commands/CommandObjectPlatform.h +++ b/source/Commands/CommandObjectPlatform.h @@ -1,9 +1,8 @@ //===-- CommandObjectPlatform.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,9 +14,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectPlatform -//------------------------------------------------------------------------- class CommandObjectPlatform : public CommandObjectMultiword { public: diff --git a/source/Commands/CommandObjectPlugin.cpp b/source/Commands/CommandObjectPlugin.cpp index 2e805bab9d6f..89e01ba52027 100644 --- a/source/Commands/CommandObjectPlugin.cpp +++ b/source/Commands/CommandObjectPlugin.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectPlugin.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -62,7 +61,7 @@ protected: FileSpec dylib_fspec(command[0].ref); FileSystem::Instance().Resolve(dylib_fspec); - if (m_interpreter.GetDebugger().LoadPlugin(dylib_fspec, error)) + if (GetDebugger().LoadPlugin(dylib_fspec, error)) result.SetStatus(eReturnStatusSuccessFinishResult); else { result.AppendError(error.AsCString()); diff --git a/source/Commands/CommandObjectPlugin.h b/source/Commands/CommandObjectPlugin.h index cd39eb19b49d..0aabb1399407 100644 --- a/source/Commands/CommandObjectPlugin.h +++ b/source/Commands/CommandObjectPlugin.h @@ -1,9 +1,8 @@ //===-- CommandObjectPlugin.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp index 5b0e6d784a02..b20a2d533332 100644 --- a/source/Commands/CommandObjectProcess.cpp +++ b/source/Commands/CommandObjectProcess.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectProcess.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -101,9 +100,7 @@ protected: std::string m_new_process_action; }; -//------------------------------------------------------------------------- // CommandObjectProcessLaunch -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessLaunch class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach { public: @@ -150,7 +147,7 @@ public: protected: bool DoExecute(Args &launch_args, CommandReturnObject &result) override { - Debugger &debugger = m_interpreter.GetDebugger(); + Debugger &debugger = GetDebugger(); Target *target = debugger.GetSelectedTarget().get(); // If our listener is nullptr, users aren't allows to launch ModuleSP exe_module_sp = target->GetExecutableModule(); @@ -196,7 +193,10 @@ protected: if (target->GetDisableSTDIO()) m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO); - m_options.launch_info.GetEnvironment() = target->GetEnvironment(); + // Merge the launch info environment with the target environment. + Environment target_env = target->GetEnvironment(); + m_options.launch_info.GetEnvironment().insert(target_env.begin(), + target_env.end()); if (!target_settings_argv0.empty()) { m_options.launch_info.GetArguments().AppendArgument( @@ -255,51 +255,6 @@ protected: ProcessLaunchCommandOptions m_options; }; -//#define SET1 LLDB_OPT_SET_1 -//#define SET2 LLDB_OPT_SET_2 -//#define SET3 LLDB_OPT_SET_3 -// -// OptionDefinition -// CommandObjectProcessLaunch::CommandOptions::g_option_table[] = -//{ -// // clang-format off -// {SET1 | SET2 | SET3, false, "stop-at-entry", 's', OptionParser::eNoArgument, -// nullptr, 0, eArgTypeNone, "Stop at the entry point of the program -// when launching a process."}, -// {SET1, false, "stdin", 'i', -// OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, -// "Redirect stdin for the process to <path>."}, -// {SET1, false, "stdout", 'o', -// OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, -// "Redirect stdout for the process to <path>."}, -// {SET1, false, "stderr", 'e', -// OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, -// "Redirect stderr for the process to <path>."}, -// {SET1 | SET2 | SET3, false, "plugin", 'p', -// OptionParser::eRequiredArgument, nullptr, 0, eArgTypePlugin, "Name of -// the process plugin you want to use."}, -// { SET2, false, "tty", 't', -// OptionParser::eOptionalArgument, nullptr, 0, eArgTypeDirectoryName, "Start -// the process in a terminal. If <path> is specified, look for a terminal whose -// name contains <path>, else start the process in a new terminal."}, -// { SET3, false, "no-stdio", 'n', OptionParser::eNoArgument, -// nullptr, 0, eArgTypeNone, "Do not set up for terminal I/O to go to -// running process."}, -// {SET1 | SET2 | SET3, false, "working-dir", 'w', -// OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Set the -// current working directory to <path> when running the inferior."}, -// {0, false, nullptr, 0, 0, nullptr, 0, eArgTypeNone, nullptr} -// // clang-format on -//}; -// -//#undef SET1 -//#undef SET2 -//#undef SET3 - -//------------------------------------------------------------------------- -// CommandObjectProcessAttach -//------------------------------------------------------------------------- - static constexpr OptionDefinition g_process_attach_options[] = { // clang-format off { LLDB_OPT_SET_ALL, false, "continue", 'c', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Immediately continue the process once attached." }, @@ -435,9 +390,9 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); // N.B. The attach should be synchronous. It doesn't help much to get the // prompt back between initiating the attach and the target actually // stopping. So even if the interpreter is set to be asynchronous, we wait @@ -454,8 +409,8 @@ protected: TargetSP new_target_sp; Status error; - error = m_interpreter.GetDebugger().GetTargetList().CreateTarget( - m_interpreter.GetDebugger(), "", "", eLoadDependentsNo, + error = GetDebugger().GetTargetList().CreateTarget( + GetDebugger(), "", "", eLoadDependentsNo, nullptr, // No platform options new_target_sp); target = new_target_sp.get(); @@ -463,7 +418,7 @@ protected: result.AppendError(error.AsCString("Error creating target")); return false; } - m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target); + GetDebugger().GetTargetList().SetSelectedTarget(target); } // Record the old executable module, we want to issue a warning if the @@ -548,9 +503,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectProcessContinue -//------------------------------------------------------------------------- static constexpr OptionDefinition g_process_continue_options[] = { // clang-format off @@ -712,9 +665,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectProcessDetach -//------------------------------------------------------------------------- static constexpr OptionDefinition g_process_detach_options[] = { // clang-format off { LLDB_OPT_SET_1, false, "keep-stopped", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." }, @@ -810,9 +761,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectProcessConnect -//------------------------------------------------------------------------- static constexpr OptionDefinition g_process_connect_options[] = { // clang-format off @@ -900,7 +849,7 @@ protected: plugin_name = m_options.plugin_name.c_str(); Status error; - Debugger &debugger = m_interpreter.GetDebugger(); + Debugger &debugger = GetDebugger(); PlatformSP platform_sp = m_interpreter.GetPlatform(true); ProcessSP process_sp = platform_sp->ConnectProcess( command.GetArgumentAtIndex(0), plugin_name, debugger, @@ -916,9 +865,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectProcessPlugin -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessPlugin class CommandObjectProcessPlugin : public CommandObjectProxy { @@ -939,9 +886,7 @@ public: } }; -//------------------------------------------------------------------------- // CommandObjectProcessLoad -//------------------------------------------------------------------------- static constexpr OptionDefinition g_process_load_options[] = { // clang-format off @@ -1055,9 +1000,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectProcessUnload -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessUnload class CommandObjectProcessUnload : public CommandObjectParsed { @@ -1103,9 +1046,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectProcessSignal -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessSignal class CommandObjectProcessSignal : public CommandObjectParsed { @@ -1170,9 +1111,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectProcessInterrupt -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessInterrupt class CommandObjectProcessInterrupt : public CommandObjectParsed { @@ -1214,9 +1153,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectProcessKill -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessKill class CommandObjectProcessKill : public CommandObjectParsed { @@ -1257,9 +1194,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectProcessSaveCore -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessSaveCore class CommandObjectProcessSaveCore : public CommandObjectParsed { @@ -1303,9 +1238,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectProcessStatus -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessStatus class CommandObjectProcessStatus : public CommandObjectParsed { @@ -1337,9 +1270,7 @@ public: } }; -//------------------------------------------------------------------------- // CommandObjectProcessHandle -//------------------------------------------------------------------------- static constexpr OptionDefinition g_process_handle_options[] = { // clang-format off @@ -1489,7 +1420,7 @@ public: protected: bool DoExecute(Args &signal_args, CommandReturnObject &result) override { - TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget(); + TargetSP target_sp = GetDebugger().GetSelectedTarget(); if (!target_sp) { result.AppendError("No current target;" @@ -1596,9 +1527,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectMultiwordProcess -//------------------------------------------------------------------------- CommandObjectMultiwordProcess::CommandObjectMultiwordProcess( CommandInterpreter &interpreter) diff --git a/source/Commands/CommandObjectProcess.h b/source/Commands/CommandObjectProcess.h index 7325dce49683..3b1ff26dbb05 100644 --- a/source/Commands/CommandObjectProcess.h +++ b/source/Commands/CommandObjectProcess.h @@ -1,9 +1,8 @@ //===-- CommandObjectProcess.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,9 +13,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectMultiwordProcess -//------------------------------------------------------------------------- class CommandObjectMultiwordProcess : public CommandObjectMultiword { public: diff --git a/source/Commands/CommandObjectQuit.cpp b/source/Commands/CommandObjectQuit.cpp index 2c5b20bf5846..70ee336f8a1b 100644 --- a/source/Commands/CommandObjectQuit.cpp +++ b/source/Commands/CommandObjectQuit.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectQuit.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -17,9 +16,7 @@ using namespace lldb; using namespace lldb_private; -//------------------------------------------------------------------------- // CommandObjectQuit -//------------------------------------------------------------------------- CommandObjectQuit::CommandObjectQuit(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "quit", "Quit the LLDB debugger.", diff --git a/source/Commands/CommandObjectQuit.h b/source/Commands/CommandObjectQuit.h index 0f9da62278d9..458ef2456fca 100644 --- a/source/Commands/CommandObjectQuit.h +++ b/source/Commands/CommandObjectQuit.h @@ -1,9 +1,8 @@ //===-- CommandObjectQuit.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,9 +13,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectQuit -//------------------------------------------------------------------------- class CommandObjectQuit : public CommandObjectParsed { public: diff --git a/source/Commands/CommandObjectRegister.cpp b/source/Commands/CommandObjectRegister.cpp index ae8b5d0027c7..34482a8b1e4f 100644 --- a/source/Commands/CommandObjectRegister.cpp +++ b/source/Commands/CommandObjectRegister.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectRegister.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -32,9 +31,7 @@ using namespace lldb; using namespace lldb_private; -//---------------------------------------------------------------------- // "register read" -//---------------------------------------------------------------------- static constexpr OptionDefinition g_register_read_options[] = { // clang-format off @@ -299,9 +296,7 @@ protected: CommandOptions m_command_options; }; -//---------------------------------------------------------------------- // "register write" -//---------------------------------------------------------------------- class CommandObjectRegisterWrite : public CommandObjectParsed { public: CommandObjectRegisterWrite(CommandInterpreter &interpreter) @@ -394,9 +389,7 @@ protected: } }; -//---------------------------------------------------------------------- // CommandObjectRegister constructor -//---------------------------------------------------------------------- CommandObjectRegister::CommandObjectRegister(CommandInterpreter &interpreter) : CommandObjectMultiword(interpreter, "register", "Commands to access registers for the current " diff --git a/source/Commands/CommandObjectRegister.h b/source/Commands/CommandObjectRegister.h index 96fc47af0a21..6fc47cf386a3 100644 --- a/source/Commands/CommandObjectRegister.h +++ b/source/Commands/CommandObjectRegister.h @@ -1,9 +1,8 @@ //===-- CommandObjectRegister.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,23 +13,17 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectRegister -//------------------------------------------------------------------------- class CommandObjectRegister : public CommandObjectMultiword { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ CommandObjectRegister(CommandInterpreter &interpreter); ~CommandObjectRegister() override; private: - //------------------------------------------------------------------ // For CommandObjectRegister only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(CommandObjectRegister); }; diff --git a/source/Commands/CommandObjectReproducer.cpp b/source/Commands/CommandObjectReproducer.cpp index f393f17d9aec..4b0e9e36d202 100644 --- a/source/Commands/CommandObjectReproducer.cpp +++ b/source/Commands/CommandObjectReproducer.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectReproducer.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -22,8 +21,12 @@ using namespace lldb_private; class CommandObjectReproducerGenerate : public CommandObjectParsed { public: CommandObjectReproducerGenerate(CommandInterpreter &interpreter) - : CommandObjectParsed(interpreter, "reproducer generate", - "Generate reproducer on disk.", nullptr) {} + : CommandObjectParsed( + interpreter, "reproducer generate", + "Generate reproducer on disk. When the debugger is in capture " + "mode, this command will output the reproducer to a directory on " + "disk. In replay mode this command in a no-op.", + nullptr) {} ~CommandObjectReproducerGenerate() override = default; @@ -38,13 +41,21 @@ protected: auto &r = repro::Reproducer::Instance(); if (auto generator = r.GetGenerator()) { generator->Keep(); + } else if (r.GetLoader()) { + // Make this operation a NOP in replay mode. + result.SetStatus(eReturnStatusSuccessFinishNoResult); + return result.Succeeded(); } else { result.AppendErrorWithFormat("Unable to get the reproducer generator"); + result.SetStatus(eReturnStatusFailed); return false; } result.GetOutputStream() << "Reproducer written to '" << r.GetReproducerPath() << "'\n"; + result.GetOutputStream() + << "Please have a look at the directory to assess if you're willing to " + "share the contained information.\n"; result.SetStatus(eReturnStatusSuccessFinishResult); return result.Succeeded(); @@ -54,8 +65,14 @@ protected: class CommandObjectReproducerStatus : public CommandObjectParsed { public: CommandObjectReproducerStatus(CommandInterpreter &interpreter) - : CommandObjectParsed(interpreter, "reproducer status", - "Show the current reproducer status.", nullptr) {} + : CommandObjectParsed( + interpreter, "reproducer status", + "Show the current reproducer status. In capture mode the debugger " + "is collecting all the information it needs to create a " + "reproducer. In replay mode the reproducer is replaying a " + "reproducer. When the reproducers are off, no data is collected " + "and no reproducer can be generated.", + nullptr) {} ~CommandObjectReproducerStatus() override = default; @@ -68,12 +85,11 @@ protected: } auto &r = repro::Reproducer::Instance(); - if (auto generator = r.GetGenerator()) { + if (r.GetGenerator()) { result.GetOutputStream() << "Reproducer is in capture mode.\n"; - } else if (auto generator = r.GetLoader()) { + } else if (r.GetLoader()) { result.GetOutputStream() << "Reproducer is in replay mode.\n"; } else { - result.GetOutputStream() << "Reproducer is off.\n"; } @@ -84,9 +100,10 @@ protected: CommandObjectReproducer::CommandObjectReproducer( CommandInterpreter &interpreter) - : CommandObjectMultiword(interpreter, "reproducer", - "Commands controlling LLDB reproducers.", - "log <subcommand> [<command-options>]") { + : CommandObjectMultiword( + interpreter, "reproducer", + "Commands to inspect and manipulate the reproducer functionality.", + "log <subcommand> [<command-options>]") { LoadSubCommand( "generate", CommandObjectSP(new CommandObjectReproducerGenerate(interpreter))); diff --git a/source/Commands/CommandObjectReproducer.h b/source/Commands/CommandObjectReproducer.h index 6691e8a8e626..ad377241f814 100644 --- a/source/Commands/CommandObjectReproducer.h +++ b/source/Commands/CommandObjectReproducer.h @@ -1,9 +1,8 @@ //===-- CommandObjectReproducer.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,9 +14,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectReproducer -//------------------------------------------------------------------------- class CommandObjectReproducer : public CommandObjectMultiword { public: diff --git a/source/Commands/CommandObjectSettings.cpp b/source/Commands/CommandObjectSettings.cpp index 967a009189e4..55a0002c5997 100644 --- a/source/Commands/CommandObjectSettings.cpp +++ b/source/Commands/CommandObjectSettings.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectSettings.cpp -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -20,15 +19,11 @@ using namespace lldb; using namespace lldb_private; -//------------------------------------------------------------------------- // CommandObjectSettingsSet -//------------------------------------------------------------------------- static constexpr OptionDefinition g_settings_set_options[] = { - // clang-format off - { LLDB_OPT_SET_2, false, "global", 'g', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Apply the new value to the global default value." }, - { LLDB_OPT_SET_2, false, "force", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Force an empty value to be accepted as the default." } - // clang-format on +#define LLDB_OPTIONS_settings_set +#include "CommandOptions.inc" }; class CommandObjectSettingsSet : public CommandObjectRaw { @@ -164,9 +159,8 @@ insert-before or insert-after."); const char *setting_var_name = request.GetParsedLine().GetArgumentAtIndex(setting_var_idx); Status error; - lldb::OptionValueSP value_sp( - m_interpreter.GetDebugger().GetPropertyValue( - &m_exe_ctx, setting_var_name, false, error)); + lldb::OptionValueSP value_sp(GetDebugger().GetPropertyValue( + &m_exe_ctx, setting_var_name, false, error)); if (value_sp) { value_sp->AutoComplete(m_interpreter, request); } @@ -205,7 +199,7 @@ protected: // A missing value corresponds to clearing the setting when "force" is // specified. if (argc == 1 && m_options.m_force) { - Status error(m_interpreter.GetDebugger().SetPropertyValue( + Status error(GetDebugger().SetPropertyValue( &m_exe_ctx, eVarSetOperationClear, var_name, llvm::StringRef())); if (error.Fail()) { result.AppendError(error.AsCString()); @@ -223,8 +217,8 @@ protected: Status error; if (m_options.m_global) { - error = m_interpreter.GetDebugger().SetPropertyValue( - nullptr, eVarSetOperationAssign, var_name, var_value_cstr); + error = GetDebugger().SetPropertyValue(nullptr, eVarSetOperationAssign, + var_name, var_value_cstr); } if (error.Success()) { @@ -235,8 +229,8 @@ protected: // if we did not clear the command's exe_ctx first ExecutionContext exe_ctx(m_exe_ctx); m_exe_ctx.Clear(); - error = m_interpreter.GetDebugger().SetPropertyValue( - &exe_ctx, eVarSetOperationAssign, var_name, var_value_cstr); + error = GetDebugger().SetPropertyValue(&exe_ctx, eVarSetOperationAssign, + var_name, var_value_cstr); } if (error.Fail()) { @@ -254,9 +248,7 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectSettingsShow -- Show current values -//------------------------------------------------------------------------- class CommandObjectSettingsShow : public CommandObjectParsed { public: @@ -297,7 +289,7 @@ protected: if (!args.empty()) { for (const auto &arg : args) { - Status error(m_interpreter.GetDebugger().DumpPropertyValue( + Status error(GetDebugger().DumpPropertyValue( &m_exe_ctx, result.GetOutputStream(), arg.ref, OptionValue::eDumpGroupValue)); if (error.Success()) { @@ -308,23 +300,19 @@ protected: } } } else { - m_interpreter.GetDebugger().DumpAllPropertyValues( - &m_exe_ctx, result.GetOutputStream(), OptionValue::eDumpGroupValue); + GetDebugger().DumpAllPropertyValues(&m_exe_ctx, result.GetOutputStream(), + OptionValue::eDumpGroupValue); } return result.Succeeded(); } }; -//------------------------------------------------------------------------- // CommandObjectSettingsWrite -- Write settings to file -//------------------------------------------------------------------------- static constexpr OptionDefinition g_settings_write_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, true, "file", 'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eDiskFileCompletion, eArgTypeFilename, "The file into which to write the settings." }, - { LLDB_OPT_SET_ALL, false, "append",'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Append to saved settings file if it exists."}, - // clang-format on +#define LLDB_OPTIONS_settings_write +#include "CommandOptions.inc" }; class CommandObjectSettingsWrite : public CommandObjectParsed { @@ -422,13 +410,13 @@ protected: ExecutionContext clean_ctx; if (args.empty()) { - m_interpreter.GetDebugger().DumpAllPropertyValues( - &clean_ctx, out_file, OptionValue::eDumpGroupExport); + GetDebugger().DumpAllPropertyValues(&clean_ctx, out_file, + OptionValue::eDumpGroupExport); return result.Succeeded(); } for (const auto &arg : args) { - Status error(m_interpreter.GetDebugger().DumpPropertyValue( + Status error(GetDebugger().DumpPropertyValue( &clean_ctx, out_file, arg.ref, OptionValue::eDumpGroupExport)); if (!error.Success()) { result.AppendError(error.AsCString()); @@ -443,14 +431,11 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectSettingsRead -- Read settings from file -//------------------------------------------------------------------------- static constexpr OptionDefinition g_settings_read_options[] = { - // clang-format off - {LLDB_OPT_SET_ALL, true, "file",'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eDiskFileCompletion, eArgTypeFilename, "The file from which to read the breakpoints." }, - // clang-format on +#define LLDB_OPTIONS_settings_read +#include "CommandOptions.inc" }; class CommandObjectSettingsRead : public CommandObjectParsed { @@ -511,6 +496,7 @@ protected: options.SetAddToHistory(false); options.SetEchoCommands(false); options.SetPrintResults(true); + options.SetPrintErrors(true); options.SetStopOnError(false); m_interpreter.HandleCommandsFromFile(file, &clean_ctx, options, result); return result.Succeeded(); @@ -520,9 +506,7 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectSettingsList -- List settable variables -//------------------------------------------------------------------------- class CommandObjectSettingsList : public CommandObjectParsed { public: @@ -576,7 +560,7 @@ protected: const char *property_path = args.GetArgumentAtIndex(i); const Property *property = - m_interpreter.GetDebugger().GetValueProperties()->GetPropertyAtPath( + GetDebugger().GetValueProperties()->GetPropertyAtPath( &m_exe_ctx, will_modify, property_path); if (property) { @@ -589,17 +573,15 @@ protected: } } } else { - m_interpreter.GetDebugger().DumpAllDescriptions(m_interpreter, - result.GetOutputStream()); + GetDebugger().DumpAllDescriptions(m_interpreter, + result.GetOutputStream()); } return result.Succeeded(); } }; -//------------------------------------------------------------------------- // CommandObjectSettingsRemove -//------------------------------------------------------------------------- class CommandObjectSettingsRemove : public CommandObjectRaw { public: @@ -685,7 +667,7 @@ protected: const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false); - Status error(m_interpreter.GetDebugger().SetPropertyValue( + Status error(GetDebugger().SetPropertyValue( &m_exe_ctx, eVarSetOperationRemove, var_name, var_value_cstr)); if (error.Fail()) { result.AppendError(error.AsCString()); @@ -697,9 +679,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectSettingsReplace -//------------------------------------------------------------------------- class CommandObjectSettingsReplace : public CommandObjectRaw { public: @@ -787,7 +767,7 @@ protected: const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false); - Status error(m_interpreter.GetDebugger().SetPropertyValue( + Status error(GetDebugger().SetPropertyValue( &m_exe_ctx, eVarSetOperationReplace, var_name, var_value_cstr)); if (error.Fail()) { result.AppendError(error.AsCString()); @@ -801,9 +781,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectSettingsInsertBefore -//------------------------------------------------------------------------- class CommandObjectSettingsInsertBefore : public CommandObjectRaw { public: @@ -895,7 +873,7 @@ protected: const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false); - Status error(m_interpreter.GetDebugger().SetPropertyValue( + Status error(GetDebugger().SetPropertyValue( &m_exe_ctx, eVarSetOperationInsertBefore, var_name, var_value_cstr)); if (error.Fail()) { result.AppendError(error.AsCString()); @@ -907,9 +885,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectSettingInsertAfter -//------------------------------------------------------------------------- class CommandObjectSettingsInsertAfter : public CommandObjectRaw { public: @@ -1000,7 +976,7 @@ protected: const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false); - Status error(m_interpreter.GetDebugger().SetPropertyValue( + Status error(GetDebugger().SetPropertyValue( &m_exe_ctx, eVarSetOperationInsertAfter, var_name, var_value_cstr)); if (error.Fail()) { result.AppendError(error.AsCString()); @@ -1012,9 +988,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectSettingsAppend -//------------------------------------------------------------------------- class CommandObjectSettingsAppend : public CommandObjectRaw { public: @@ -1096,7 +1070,7 @@ protected: const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false); - Status error(m_interpreter.GetDebugger().SetPropertyValue( + Status error(GetDebugger().SetPropertyValue( &m_exe_ctx, eVarSetOperationAppend, var_name, var_value_cstr)); if (error.Fail()) { result.AppendError(error.AsCString()); @@ -1108,9 +1082,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectSettingsClear -//------------------------------------------------------------------------- class CommandObjectSettingsClear : public CommandObjectParsed { public: @@ -1166,7 +1138,7 @@ protected: return false; } - Status error(m_interpreter.GetDebugger().SetPropertyValue( + Status error(GetDebugger().SetPropertyValue( &m_exe_ctx, eVarSetOperationClear, var_name, llvm::StringRef())); if (error.Fail()) { result.AppendError(error.AsCString()); @@ -1178,9 +1150,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectMultiwordSettings -//------------------------------------------------------------------------- CommandObjectMultiwordSettings::CommandObjectMultiwordSettings( CommandInterpreter &interpreter) diff --git a/source/Commands/CommandObjectSettings.h b/source/Commands/CommandObjectSettings.h index df1338600456..730425953ea7 100644 --- a/source/Commands/CommandObjectSettings.h +++ b/source/Commands/CommandObjectSettings.h @@ -1,9 +1,8 @@ //===-- CommandObjectSettings.h ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,9 +15,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectMultiwordSettings -//------------------------------------------------------------------------- class CommandObjectMultiwordSettings : public CommandObjectMultiword { public: diff --git a/source/Commands/CommandObjectSource.cpp b/source/Commands/CommandObjectSource.cpp index 2fce34f9846e..1b515d0f1099 100644 --- a/source/Commands/CommandObjectSource.cpp +++ b/source/Commands/CommandObjectSource.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectSource.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -33,9 +32,7 @@ using namespace lldb; using namespace lldb_private; #pragma mark CommandObjectSourceInfo -//---------------------------------------------------------------------- // CommandObjectSourceInfo - debug line entries dumping command -//---------------------------------------------------------------------- static constexpr OptionDefinition g_source_info_options[] = { // clang-format off @@ -195,7 +192,7 @@ protected: continue; // Print a new header if the module changed. - const ConstString &module_file_name = + ConstString module_file_name = module->GetFileSpec().GetFilename(); assert(module_file_name); if (module_file_name != last_module_file_name) { @@ -241,8 +238,8 @@ protected: // Dump all matching lines at or above start_line for the file in the // CU. - const ConstString &file_spec_name = file_spec.GetFilename(); - const ConstString &module_file_name = + ConstString file_spec_name = file_spec.GetFilename(); + ConstString module_file_name = module->GetFileSpec().GetFilename(); bool cu_header_printed = false; uint32_t line = start_line; @@ -575,7 +572,7 @@ protected: Target *target = m_exe_ctx.GetTargetPtr(); if (target == nullptr) { - target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("invalid target, create a debug target using the " "'target create' command."); @@ -645,9 +642,7 @@ protected: }; #pragma mark CommandObjectSourceList -//------------------------------------------------------------------------- // CommandObjectSourceList -//------------------------------------------------------------------------- static constexpr OptionDefinition g_source_list_options[] = { // clang-format off @@ -781,7 +776,7 @@ protected: ConstString function; LineEntry line_entry; - SourceInfo(const ConstString &name, const LineEntry &line_entry) + SourceInfo(ConstString name, const LineEntry &line_entry) : function(name), line_entry(line_entry) {} SourceInfo() : function(), line_entry() {} @@ -902,7 +897,7 @@ protected: // these somewhere, there should probably be a module-filter-list that can be // passed to the various ModuleList::Find* calls, which would either be a // vector of string names or a ModuleSpecList. - size_t FindMatchingFunctions(Target *target, const ConstString &name, + size_t FindMatchingFunctions(Target *target, ConstString name, SymbolContextList &sc_list) { // Displaying the source for a symbol: bool include_inlines = true; @@ -935,7 +930,7 @@ protected: return num_matches; } - size_t FindMatchingFunctionSymbols(Target *target, const ConstString &name, + size_t FindMatchingFunctionSymbols(Target *target, ConstString name, SymbolContextList &sc_list) { size_t num_matches = 0; const size_t num_modules = m_options.modules.size(); @@ -1137,8 +1132,7 @@ protected: m_options.num_lines >= 10 ? 5 : m_options.num_lines / 2; const uint32_t column = - (m_interpreter.GetDebugger().GetStopShowColumn() != - eStopShowColumnNone) + (GetDebugger().GetStopShowColumn() != eStopShowColumnNone) ? sc.line_entry.column : 0; target->GetSourceManager().DisplaySourceLinesWithLineNumbers( @@ -1293,9 +1287,7 @@ protected: }; #pragma mark CommandObjectMultiwordSource -//------------------------------------------------------------------------- // CommandObjectMultiwordSource -//------------------------------------------------------------------------- CommandObjectMultiwordSource::CommandObjectMultiwordSource( CommandInterpreter &interpreter) diff --git a/source/Commands/CommandObjectSource.h b/source/Commands/CommandObjectSource.h index b2553832210d..d72122d55dc7 100644 --- a/source/Commands/CommandObjectSource.h +++ b/source/Commands/CommandObjectSource.h @@ -1,10 +1,9 @@ //===-- CommandObjectSource.h.h -----------------------------------*- C++ //-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -17,9 +16,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectMultiwordSource -//------------------------------------------------------------------------- class CommandObjectMultiwordSource : public CommandObjectMultiword { public: diff --git a/source/Commands/CommandObjectStats.cpp b/source/Commands/CommandObjectStats.cpp index 9225a94b70d3..a73c2a8e0409 100644 --- a/source/Commands/CommandObjectStats.cpp +++ b/source/Commands/CommandObjectStats.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectStats.cpp ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectStats.h b/source/Commands/CommandObjectStats.h index 3c5c2c04db1f..27e9a6ff865a 100644 --- a/source/Commands/CommandObjectStats.h +++ b/source/Commands/CommandObjectStats.h @@ -1,9 +1,8 @@ //===-- CommandObjectStats.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp index ee55b22c5ea2..e913a28501f2 100644 --- a/source/Commands/CommandObjectTarget.cpp +++ b/source/Commands/CommandObjectTarget.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectTarget.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -18,7 +17,6 @@ #include "lldb/DataFormatters/ValueObjectPrinter.h" #include "lldb/Host/OptionParser.h" #include "lldb/Host/StringConvert.h" -#include "lldb/Host/Symbols.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/OptionArgParser.h" @@ -36,6 +34,7 @@ #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Symbol/LineTable.h" +#include "lldb/Symbol/LocateSymbolFile.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/SymbolVendor.h" @@ -202,9 +201,7 @@ private: #pragma mark CommandObjectTargetCreate -//------------------------------------------------------------------------- // "target create" -//------------------------------------------------------------------------- class CommandObjectTargetCreate : public CommandObjectParsed { public: @@ -317,7 +314,7 @@ protected: bool must_set_platform_path = false; - Debugger &debugger = m_interpreter.GetDebugger(); + Debugger &debugger = GetDebugger(); TargetSP target_sp; llvm::StringRef arch_cstr = m_arch_option.GetArchitectureName(); @@ -396,7 +393,8 @@ protected: debugger.GetTargetList().SetSelectedTarget(target_sp.get()); if (must_set_platform_path) { ModuleSpec main_module_spec(file_spec); - ModuleSP module_sp = target_sp->GetSharedModule(main_module_spec); + ModuleSP module_sp = target_sp->GetOrCreateModule(main_module_spec, + true /* notify */); if (module_sp) module_sp->SetPlatformFileSpec(remote_file); } @@ -412,11 +410,10 @@ protected: } FileSpec core_file_dir; core_file_dir.GetDirectory() = core_file.GetDirectory(); - target_sp->GetExecutableSearchPaths().Append(core_file_dir); + target_sp->AppendExecutableSearchPaths(core_file_dir); ProcessSP process_sp(target_sp->CreateProcess( - m_interpreter.GetDebugger().GetListener(), llvm::StringRef(), - &core_file)); + GetDebugger().GetListener(), llvm::StringRef(), &core_file)); if (process_sp) { // Seems weird that we Launch a core file, but that is what we @@ -476,9 +473,7 @@ private: #pragma mark CommandObjectTargetList -//---------------------------------------------------------------------- // "target list" -//---------------------------------------------------------------------- class CommandObjectTargetList : public CommandObjectParsed { public: @@ -496,7 +491,7 @@ protected: Stream &strm = result.GetOutputStream(); bool show_stopped_process_status = false; - if (DumpTargetList(m_interpreter.GetDebugger().GetTargetList(), + if (DumpTargetList(GetDebugger().GetTargetList(), show_stopped_process_status, strm) == 0) { strm.PutCString("No targets.\n"); } @@ -511,9 +506,7 @@ protected: #pragma mark CommandObjectTargetSelect -//---------------------------------------------------------------------- // "target select" -//---------------------------------------------------------------------- class CommandObjectTargetSelect : public CommandObjectParsed { public: @@ -533,7 +526,7 @@ protected: uint32_t target_idx = StringConvert::ToUInt32(target_idx_arg, UINT32_MAX, 0, &success); if (success) { - TargetList &target_list = m_interpreter.GetDebugger().GetTargetList(); + TargetList &target_list = GetDebugger().GetTargetList(); const uint32_t num_targets = target_list.GetNumTargets(); if (target_idx < num_targets) { TargetSP target_sp(target_list.GetTargetAtIndex(target_idx)); @@ -576,9 +569,7 @@ protected: #pragma mark CommandObjectTargetSelect -//---------------------------------------------------------------------- // "target delete" -//---------------------------------------------------------------------- class CommandObjectTargetDelete : public CommandObjectParsed { public: @@ -611,7 +602,7 @@ protected: bool DoExecute(Args &args, CommandReturnObject &result) override { const size_t argc = args.GetArgumentCount(); std::vector<TargetSP> delete_target_list; - TargetList &target_list = m_interpreter.GetDebugger().GetTargetList(); + TargetList &target_list = GetDebugger().GetTargetList(); TargetSP target_sp; if (m_all_option.GetOptionValue()) { @@ -689,9 +680,7 @@ protected: #pragma mark CommandObjectTargetVariable -//---------------------------------------------------------------------- // "target variable" -//---------------------------------------------------------------------- class CommandObjectTargetVariable : public CommandObjectParsed { static const uint32_t SHORT_OPTION_FILE = 0x66696c65; // 'file' @@ -1064,7 +1053,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target) { const size_t argc = command.GetArgumentCount(); if (argc & 1) { @@ -1118,7 +1107,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target) { bool notify = true; target->GetImageSearchPathList().Clear(notify); @@ -1179,7 +1168,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target) { size_t argc = command.GetArgumentCount(); // check for at least 3 arguments and an odd number of parameters @@ -1247,7 +1236,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target) { if (command.GetArgumentCount() != 0) { result.AppendError("list takes no arguments\n"); @@ -1293,7 +1282,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target) { if (command.GetArgumentCount() != 1) { result.AppendError("query requires one argument\n"); @@ -1317,9 +1306,7 @@ protected: } }; -//---------------------------------------------------------------------- // Static Helper functions -//---------------------------------------------------------------------- static void DumpModuleArchitecture(Stream &strm, Module *module, bool full_triple, uint32_t width) { if (module) { @@ -1348,7 +1335,7 @@ static void DumpModuleUUID(Stream &strm, Module *module) { static uint32_t DumpCompileUnitLineTable(CommandInterpreter &interpreter, Stream &strm, Module *module, const FileSpec &file_spec, - bool load_addresses) { + lldb::DescriptionLevel desc_level) { uint32_t num_matches = 0; if (module) { SymbolContextList sc_list; @@ -1367,7 +1354,7 @@ static uint32_t DumpCompileUnitLineTable(CommandInterpreter &interpreter, if (line_table) line_table->GetDescription( &strm, interpreter.GetExecutionContext().GetTargetPtr(), - lldb::eDescriptionLevelBrief); + desc_level); else strm << "No line table"; } @@ -1829,10 +1816,8 @@ static size_t FindModulesByName(Target *target, const char *module_name, #pragma mark CommandObjectTargetModulesModuleAutoComplete -//---------------------------------------------------------------------- // A base command object class that can auto complete with module file // paths -//---------------------------------------------------------------------- class CommandObjectTargetModulesModuleAutoComplete : public CommandObjectParsed { @@ -1871,10 +1856,8 @@ public: #pragma mark CommandObjectTargetModulesSourceFileAutoComplete -//---------------------------------------------------------------------- // A base command object class that can auto complete with module source // file paths -//---------------------------------------------------------------------- class CommandObjectTargetModulesSourceFileAutoComplete : public CommandObjectParsed { @@ -1925,7 +1908,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("invalid target, create a debug target using the " "'target create' command"); @@ -1984,9 +1967,8 @@ static constexpr OptionEnumValueElement g_sort_option_enumeration[] = { {eSortOrderByName, "name", "Sort output by symbol name."} }; static constexpr OptionDefinition g_target_modules_dump_symtab_options[] = { - // clang-format off - { LLDB_OPT_SET_1, false, "sort", 's', OptionParser::eRequiredArgument, nullptr, OptionEnumValues(g_sort_option_enumeration), 0, eArgTypeSortOrder, "Supply a sort order when dumping the symbol table." } - // clang-format on +#define LLDB_OPTIONS_target_modules_dump_symtab +#include "CommandOptions.inc" }; class CommandObjectTargetModulesDumpSymtab @@ -2041,7 +2023,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("invalid target, create a debug target using the " "'target create' command"); @@ -2126,9 +2108,7 @@ protected: #pragma mark CommandObjectTargetModulesDumpSections -//---------------------------------------------------------------------- // Image section dumping command -//---------------------------------------------------------------------- class CommandObjectTargetModulesDumpSections : public CommandObjectTargetModulesModuleAutoComplete { @@ -2144,7 +2124,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("invalid target, create a debug target using the " "'target create' command"); @@ -2221,9 +2201,7 @@ protected: #pragma mark CommandObjectTargetModulesDumpSections -//---------------------------------------------------------------------- // Clang AST dumping command -//---------------------------------------------------------------------- class CommandObjectTargetModulesDumpClangAST : public CommandObjectTargetModulesModuleAutoComplete { @@ -2239,7 +2217,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("invalid target, create a debug target using the " "'target create' command"); @@ -2300,9 +2278,7 @@ protected: #pragma mark CommandObjectTargetModulesDumpSymfile -//---------------------------------------------------------------------- // Image debug symbol dumping command -//---------------------------------------------------------------------- class CommandObjectTargetModulesDumpSymfile : public CommandObjectTargetModulesModuleAutoComplete { @@ -2318,7 +2294,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("invalid target, create a debug target using the " "'target create' command"); @@ -2391,9 +2367,7 @@ protected: #pragma mark CommandObjectTargetModulesDumpLineTable -//---------------------------------------------------------------------- // Image debug line table dumping command -//---------------------------------------------------------------------- class CommandObjectTargetModulesDumpLineTable : public CommandObjectTargetModulesSourceFileAutoComplete { @@ -2406,6 +2380,8 @@ public: ~CommandObjectTargetModulesDumpLineTable() override = default; + Options *GetOptions() override { return &m_options; } + protected: bool DoExecute(Args &command, CommandReturnObject &result) override { Target *target = m_exe_ctx.GetTargetPtr(); @@ -2438,8 +2414,9 @@ protected: if (DumpCompileUnitLineTable( m_interpreter, result.GetOutputStream(), target_modules.GetModulePointerAtIndexUnlocked(i), - file_spec, m_exe_ctx.GetProcessPtr() && - m_exe_ctx.GetProcessRef().IsAlive())) + file_spec, + m_options.m_verbose ? eDescriptionLevelFull + : eDescriptionLevelBrief)) num_dumped++; } if (num_dumped == 0) @@ -2459,19 +2436,52 @@ protected: } return result.Succeeded(); } + + class CommandOptions : public Options { + public: + CommandOptions() : Options() { OptionParsingStarting(nullptr); } + + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + assert(option_idx == 0 && "We only have one option."); + m_verbose = true; + + return Status(); + } + + void OptionParsingStarting(ExecutionContext *execution_context) override { + m_verbose = false; + } + + llvm::ArrayRef<OptionDefinition> GetDefinitions() override { + static constexpr OptionDefinition g_options[] = { + {LLDB_OPT_SET_ALL, + false, + "verbose", + 'v', + OptionParser::eNoArgument, + nullptr, + {}, + 0, + eArgTypeNone, + "Enable verbose dump."}, + }; + return llvm::makeArrayRef(g_options); + } + + bool m_verbose; + }; + + CommandOptions m_options; }; #pragma mark CommandObjectTargetModulesDump -//---------------------------------------------------------------------- // Dump multi-word command for target modules -//---------------------------------------------------------------------- class CommandObjectTargetModulesDump : public CommandObjectMultiword { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ CommandObjectTargetModulesDump(CommandInterpreter &interpreter) : CommandObjectMultiword( interpreter, "target modules dump", @@ -2539,7 +2549,7 @@ protected: OptionGroupFile m_symbol_file; bool DoExecute(Args &args, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("invalid target, create a debug target using the " "'target create' command"); @@ -2559,7 +2569,8 @@ protected: module_spec.GetSymbolFileSpec() = m_symbol_file.GetOptionValue().GetCurrentValue(); if (Symbols::DownloadObjectAndSymbolFile(module_spec)) { - ModuleSP module_sp(target->GetSharedModule(module_spec)); + ModuleSP module_sp(target->GetOrCreateModule(module_spec, + true /* notify */)); if (module_sp) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; @@ -2621,7 +2632,8 @@ protected: if (!module_spec.GetArchitecture().IsValid()) module_spec.GetArchitecture() = target->GetArchitecture(); Status error; - ModuleSP module_sp(target->GetSharedModule(module_spec, &error)); + ModuleSP module_sp(target->GetOrCreateModule(module_spec, + true /* notify */, &error)); if (!module_sp) { const char *error_cstr = error.AsCString(); if (error_cstr) @@ -2700,7 +2712,7 @@ public: protected: bool DoExecute(Args &args, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); const bool load = m_load_option.GetOptionValue().GetCurrentValue(); const bool set_pc = m_pc_option.GetOptionValue().GetCurrentValue(); if (target == nullptr) { @@ -2955,9 +2967,7 @@ protected: OptionGroupUInt64 m_slide_option; }; -//---------------------------------------------------------------------- // List images with associated information -//---------------------------------------------------------------------- static constexpr OptionDefinition g_target_modules_list_options[] = { // clang-format off @@ -3037,7 +3047,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); const bool use_global_module_list = m_options.m_use_global_module_list; // Define a local module list here to ensure it lives longer than any // "locker" object which might lock its contents below (through the @@ -3321,9 +3331,7 @@ protected: #pragma mark CommandObjectTargetModulesShowUnwind -//---------------------------------------------------------------------- // Lookup unwind information in images -//---------------------------------------------------------------------- static constexpr OptionDefinition g_target_modules_show_unwind_options[] = { // clang-format off @@ -3494,8 +3502,7 @@ protected: start_addr = abi->FixCodeAddress(start_addr); FuncUnwindersSP func_unwinders_sp( - sc.module_sp->GetObjectFile() - ->GetUnwindTable() + sc.module_sp->GetUnwindTable() .GetUncachedFuncUnwindersContainingAddress(start_addr, sc)); if (!func_unwinders_sp) continue; @@ -3506,14 +3513,14 @@ protected: funcname.AsCString(), start_addr); UnwindPlanSP non_callsite_unwind_plan = - func_unwinders_sp->GetUnwindPlanAtNonCallSite(*target, *thread, -1); + func_unwinders_sp->GetUnwindPlanAtNonCallSite(*target, *thread); if (non_callsite_unwind_plan) { result.GetOutputStream().Printf( "Asynchronous (not restricted to call-sites) UnwindPlan is '%s'\n", non_callsite_unwind_plan->GetSourceName().AsCString()); } UnwindPlanSP callsite_unwind_plan = - func_unwinders_sp->GetUnwindPlanAtCallSite(*target, -1); + func_unwinders_sp->GetUnwindPlanAtCallSite(*target, *thread); if (callsite_unwind_plan) { result.GetOutputStream().Printf( "Synchronous (restricted to call-sites) UnwindPlan is '%s'\n", @@ -3530,7 +3537,7 @@ protected: result.GetOutputStream().Printf("\n"); UnwindPlanSP assembly_sp = - func_unwinders_sp->GetAssemblyUnwindPlan(*target, *thread, 0); + func_unwinders_sp->GetAssemblyUnwindPlan(*target, *thread); if (assembly_sp) { result.GetOutputStream().Printf( "Assembly language inspection UnwindPlan:\n"); @@ -3540,7 +3547,7 @@ protected: } UnwindPlanSP ehframe_sp = - func_unwinders_sp->GetEHFrameUnwindPlan(*target, 0); + func_unwinders_sp->GetEHFrameUnwindPlan(*target); if (ehframe_sp) { result.GetOutputStream().Printf("eh_frame UnwindPlan:\n"); ehframe_sp->Dump(result.GetOutputStream(), thread.get(), @@ -3549,7 +3556,7 @@ protected: } UnwindPlanSP ehframe_augmented_sp = - func_unwinders_sp->GetEHFrameAugmentedUnwindPlan(*target, *thread, 0); + func_unwinders_sp->GetEHFrameAugmentedUnwindPlan(*target, *thread); if (ehframe_augmented_sp) { result.GetOutputStream().Printf("eh_frame augmented UnwindPlan:\n"); ehframe_augmented_sp->Dump(result.GetOutputStream(), thread.get(), @@ -3558,7 +3565,7 @@ protected: } if (UnwindPlanSP plan_sp = - func_unwinders_sp->GetDebugFrameUnwindPlan(*target, 0)) { + func_unwinders_sp->GetDebugFrameUnwindPlan(*target)) { result.GetOutputStream().Printf("debug_frame UnwindPlan:\n"); plan_sp->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS); @@ -3567,7 +3574,7 @@ protected: if (UnwindPlanSP plan_sp = func_unwinders_sp->GetDebugFrameAugmentedUnwindPlan(*target, - *thread, 0)) { + *thread)) { result.GetOutputStream().Printf("debug_frame augmented UnwindPlan:\n"); plan_sp->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS); @@ -3575,7 +3582,7 @@ protected: } UnwindPlanSP arm_unwind_sp = - func_unwinders_sp->GetArmUnwindUnwindPlan(*target, 0); + func_unwinders_sp->GetArmUnwindUnwindPlan(*target); if (arm_unwind_sp) { result.GetOutputStream().Printf("ARM.exidx unwind UnwindPlan:\n"); arm_unwind_sp->Dump(result.GetOutputStream(), thread.get(), @@ -3583,8 +3590,16 @@ protected: result.GetOutputStream().Printf("\n"); } + if (UnwindPlanSP symfile_plan_sp = + func_unwinders_sp->GetSymbolFileUnwindPlan(*thread)) { + result.GetOutputStream().Printf("Symbol file UnwindPlan:\n"); + symfile_plan_sp->Dump(result.GetOutputStream(), thread.get(), + LLDB_INVALID_ADDRESS); + result.GetOutputStream().Printf("\n"); + } + UnwindPlanSP compact_unwind_sp = - func_unwinders_sp->GetCompactUnwindUnwindPlan(*target, 0); + func_unwinders_sp->GetCompactUnwindUnwindPlan(*target); if (compact_unwind_sp) { result.GetOutputStream().Printf("Compact unwind UnwindPlan:\n"); compact_unwind_sp->Dump(result.GetOutputStream(), thread.get(), @@ -3627,9 +3642,7 @@ protected: CommandOptions m_options; }; -//---------------------------------------------------------------------- // Lookup information in images -//---------------------------------------------------------------------- static constexpr OptionDefinition g_target_modules_lookup_options[] = { // clang-format off @@ -3726,7 +3739,7 @@ public: break; case 'v': - m_verbose = 1; + m_verbose = true; break; case 'A': @@ -3922,7 +3935,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("invalid target, create a debug target using the " "'target create' command"); @@ -4015,9 +4028,7 @@ protected: #pragma mark CommandObjectMultiwordImageSearchPaths -//------------------------------------------------------------------------- // CommandObjectMultiwordImageSearchPaths -//------------------------------------------------------------------------- class CommandObjectTargetModulesImageSearchPaths : public CommandObjectMultiword { @@ -4050,15 +4061,11 @@ public: #pragma mark CommandObjectTargetModules -//------------------------------------------------------------------------- // CommandObjectTargetModules -//------------------------------------------------------------------------- class CommandObjectTargetModules : public CommandObjectMultiword { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ CommandObjectTargetModules(CommandInterpreter &interpreter) : CommandObjectMultiword(interpreter, "target modules", "Commands for accessing information for one or " @@ -4087,9 +4094,7 @@ public: ~CommandObjectTargetModules() override = default; private: - //------------------------------------------------------------------ // For CommandObjectTargetModules only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(CommandObjectTargetModules); }; @@ -4482,15 +4487,11 @@ protected: #pragma mark CommandObjectTargetSymbols -//------------------------------------------------------------------------- // CommandObjectTargetSymbols -//------------------------------------------------------------------------- class CommandObjectTargetSymbols : public CommandObjectMultiword { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ CommandObjectTargetSymbols(CommandInterpreter &interpreter) : CommandObjectMultiword( interpreter, "target symbols", @@ -4503,21 +4504,17 @@ public: ~CommandObjectTargetSymbols() override = default; private: - //------------------------------------------------------------------ // For CommandObjectTargetModules only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(CommandObjectTargetSymbols); }; #pragma mark CommandObjectTargetStopHookAdd -//------------------------------------------------------------------------- // CommandObjectTargetStopHookAdd -//------------------------------------------------------------------------- static constexpr OptionDefinition g_target_stop_hook_add_options[] = { // clang-format off - { LLDB_OPT_SET_ALL, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOneLiner, "Specify a one-line breakpoint command inline. Be sure to surround it with quotes." }, + { LLDB_OPT_SET_ALL, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOneLiner, "Add a command for the stop hook. Can be specified more than once, and commands will be run in the order they appear." }, { LLDB_OPT_SET_ALL, false, "shlib", 's', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Set the module within which the stop-hook is to be run." }, { LLDB_OPT_SET_ALL, false, "thread-index", 'x', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadIndex, "The stop hook is run only for the thread whose index matches this argument." }, { LLDB_OPT_SET_ALL, false, "thread-id", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadID, "The stop hook is run only for the thread whose TID matches this argument." }, @@ -4528,6 +4525,7 @@ static constexpr OptionDefinition g_target_stop_hook_add_options[] = { { LLDB_OPT_SET_1, false, "end-line", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLineNum, "Set the end of the line range for which the stop-hook is to be run." }, { LLDB_OPT_SET_2, false, "classname", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeClassName, "Specify the class within which the stop-hook is to be run." }, { LLDB_OPT_SET_3, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Set the function name within which the stop hook will be run." }, + { LLDB_OPT_SET_ALL, false, "auto-continue",'G', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "The breakpoint will auto-continue after running its commands." }, // clang-format on }; @@ -4568,6 +4566,17 @@ public: m_sym_ctx_specified = true; break; + case 'G': { + bool value, success; + value = OptionArgParser::ToBoolean(option_arg, false, &success); + if (success) { + m_auto_continue = value; + } else + error.SetErrorStringWithFormat( + "invalid boolean value '%s' passed for -G option", + option_arg.str().c_str()); + } + break; case 'l': if (option_arg.getAsInteger(0, m_line_start)) { error.SetErrorStringWithFormat("invalid start line number: \"%s\"", @@ -4623,7 +4632,7 @@ public: case 'o': m_use_one_liner = true; - m_one_liner = option_arg; + m_one_liner.push_back(option_arg); break; default: @@ -4652,6 +4661,7 @@ public: m_use_one_liner = false; m_one_liner.clear(); + m_auto_continue = false; } std::string m_class_name; @@ -4670,7 +4680,8 @@ public: bool m_thread_specified; // Instance variables to hold the values for one_liner options. bool m_use_one_liner; - std::string m_one_liner; + std::vector<std::string> m_one_liner; + bool m_auto_continue; }; CommandObjectTargetStopHookAdd(CommandInterpreter &interpreter) @@ -4686,9 +4697,9 @@ public: Options *GetOptions() override { return &m_options; } protected: - void IOHandlerActivated(IOHandler &io_handler) override { + void IOHandlerActivated(IOHandler &io_handler, bool interactive) override { StreamFileSP output_sp(io_handler.GetOutputStreamFile()); - if (output_sp) { + if (output_sp && interactive) { output_sp->PutCString( "Enter your stop hook command(s). Type 'DONE' to end.\n"); output_sp->Flush(); @@ -4706,7 +4717,7 @@ protected: m_stop_hook_sp->GetID()); error_sp->Flush(); } - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target) target->RemoveStopHookByID(m_stop_hook_sp->GetID()); } else { @@ -4731,49 +4742,49 @@ protected: Target::StopHookSP new_hook_sp = target->CreateStopHook(); // First step, make the specifier. - std::unique_ptr<SymbolContextSpecifier> specifier_ap; + std::unique_ptr<SymbolContextSpecifier> specifier_up; if (m_options.m_sym_ctx_specified) { - specifier_ap.reset(new SymbolContextSpecifier( - m_interpreter.GetDebugger().GetSelectedTarget())); + specifier_up.reset( + new SymbolContextSpecifier(GetDebugger().GetSelectedTarget())); if (!m_options.m_module_name.empty()) { - specifier_ap->AddSpecification( + specifier_up->AddSpecification( m_options.m_module_name.c_str(), SymbolContextSpecifier::eModuleSpecified); } if (!m_options.m_class_name.empty()) { - specifier_ap->AddSpecification( + specifier_up->AddSpecification( m_options.m_class_name.c_str(), SymbolContextSpecifier::eClassOrNamespaceSpecified); } if (!m_options.m_file_name.empty()) { - specifier_ap->AddSpecification( + specifier_up->AddSpecification( m_options.m_file_name.c_str(), SymbolContextSpecifier::eFileSpecified); } if (m_options.m_line_start != 0) { - specifier_ap->AddLineSpecification( + specifier_up->AddLineSpecification( m_options.m_line_start, SymbolContextSpecifier::eLineStartSpecified); } if (m_options.m_line_end != UINT_MAX) { - specifier_ap->AddLineSpecification( + specifier_up->AddLineSpecification( m_options.m_line_end, SymbolContextSpecifier::eLineEndSpecified); } if (!m_options.m_function_name.empty()) { - specifier_ap->AddSpecification( + specifier_up->AddSpecification( m_options.m_function_name.c_str(), SymbolContextSpecifier::eFunctionSpecified); } } - if (specifier_ap) - new_hook_sp->SetSpecifier(specifier_ap.release()); + if (specifier_up) + new_hook_sp->SetSpecifier(specifier_up.release()); // Next see if any of the thread options have been entered: @@ -4795,10 +4806,13 @@ protected: new_hook_sp->SetThreadSpecifier(thread_spec); } + + new_hook_sp->SetAutoContinue(m_options.m_auto_continue); if (m_options.m_use_one_liner) { - // Use one-liner. - new_hook_sp->GetCommandPointer()->AppendString( - m_options.m_one_liner.c_str()); + // Use one-liners. + for (auto cmd : m_options.m_one_liner) + new_hook_sp->GetCommandPointer()->AppendString( + cmd.c_str()); result.AppendMessageWithFormat("Stop hook #%" PRIu64 " added.\n", new_hook_sp->GetID()); } else { @@ -4826,9 +4840,7 @@ private: #pragma mark CommandObjectTargetStopHookDelete -//------------------------------------------------------------------------- // CommandObjectTargetStopHookDelete -//------------------------------------------------------------------------- class CommandObjectTargetStopHookDelete : public CommandObjectParsed { public: @@ -4884,9 +4896,7 @@ protected: #pragma mark CommandObjectTargetStopHookEnableDisable -//------------------------------------------------------------------------- // CommandObjectTargetStopHookEnableDisable -//------------------------------------------------------------------------- class CommandObjectTargetStopHookEnableDisable : public CommandObjectParsed { public: @@ -4941,9 +4951,7 @@ private: #pragma mark CommandObjectTargetStopHookList -//------------------------------------------------------------------------- // CommandObjectTargetStopHookList -//------------------------------------------------------------------------- class CommandObjectTargetStopHookList : public CommandObjectParsed { public: @@ -4982,9 +4990,7 @@ protected: #pragma mark CommandObjectMultiwordTargetStopHooks -//------------------------------------------------------------------------- // CommandObjectMultiwordTargetStopHooks -//------------------------------------------------------------------------- class CommandObjectMultiwordTargetStopHooks : public CommandObjectMultiword { public: @@ -5015,9 +5021,7 @@ public: #pragma mark CommandObjectMultiwordTarget -//------------------------------------------------------------------------- // CommandObjectMultiwordTarget -//------------------------------------------------------------------------- CommandObjectMultiwordTarget::CommandObjectMultiwordTarget( CommandInterpreter &interpreter) diff --git a/source/Commands/CommandObjectTarget.h b/source/Commands/CommandObjectTarget.h index 643ce547dcb6..86d554c8a310 100644 --- a/source/Commands/CommandObjectTarget.h +++ b/source/Commands/CommandObjectTarget.h @@ -1,9 +1,8 @@ //===-- CommandObjectTarget.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -15,9 +14,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectMultiwordTarget -//------------------------------------------------------------------------- class CommandObjectMultiwordTarget : public CommandObjectMultiword { public: diff --git a/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp index e792887d4ff3..ed7cf0a1a48d 100644 --- a/source/Commands/CommandObjectThread.cpp +++ b/source/Commands/CommandObjectThread.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectThread.cpp ---------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -38,9 +37,7 @@ using namespace lldb; using namespace lldb_private; -//------------------------------------------------------------------------- // CommandObjectIterateOverThreads -//------------------------------------------------------------------------- class CommandObjectIterateOverThreads : public CommandObjectParsed { @@ -239,16 +236,11 @@ protected: bool m_add_return = true; }; -//------------------------------------------------------------------------- // CommandObjectThreadBacktrace -//------------------------------------------------------------------------- static constexpr OptionDefinition g_thread_backtrace_options[] = { - // clang-format off - { LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCount, "How many frames to display (-1 for all)" }, - { LLDB_OPT_SET_1, false, "start", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFrameIndex, "Frame in which to start the backtrace" }, - { LLDB_OPT_SET_1, false, "extended", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Show the extended backtrace, if available" } - // clang-format on +#define LLDB_OPTIONS_thread_backtrace +#include "CommandOptions.inc" }; class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads { @@ -322,7 +314,10 @@ public: "indexes can be specified as arguments.\n" "Use the thread-index \"all\" to see all threads.\n" "Use the thread-index \"unique\" to see threads grouped by unique " - "call stacks.", + "call stacks.\n" + "Use 'settings set frame-format' to customize the printing of " + "frames in the backtrace and 'settings set thread-format' to " + "customize the thread header.", nullptr, eCommandRequiresProcess | eCommandRequiresThread | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | @@ -409,16 +404,8 @@ static constexpr OptionEnumValues TriRunningModes() { } static constexpr OptionDefinition g_thread_step_scope_options[] = { - // clang-format off - { LLDB_OPT_SET_1, false, "step-in-avoids-no-debug", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "A boolean value that sets whether stepping into functions will step over functions with no debug information." }, - { LLDB_OPT_SET_1, false, "step-out-avoids-no-debug", 'A', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "A boolean value, if true stepping out of functions will continue to step out till it hits a function with debug information." }, - { LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, {}, 1, eArgTypeCount, "How many times to perform the stepping operation - currently only supported for step-inst and next-inst." }, - { LLDB_OPT_SET_1, false, "end-linenumber", 'e', OptionParser::eRequiredArgument, nullptr, {}, 1, eArgTypeLineNum, "The line at which to stop stepping - defaults to the next line and only supported for step-in and step-over. You can also pass the string 'block' to step to the end of the current block. This is particularly useful in conjunction with --step-target to step through a complex calling sequence." }, - { LLDB_OPT_SET_1, false, "run-mode", 'm', OptionParser::eRequiredArgument, nullptr, TriRunningModes(), 0, eArgTypeRunMode, "Determine how to run other threads while stepping the current thread." }, - { LLDB_OPT_SET_1, false, "step-over-regexp", 'r', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeRegularExpression, "A regular expression that defines function names to not to stop at when stepping in." }, - { LLDB_OPT_SET_1, false, "step-in-target", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFunctionName, "The name of the directly called function step in should stop at when stepping into." }, - { LLDB_OPT_SET_2, false, "python-class", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonClass, "The name of the class that will manage this step - only supported for Scripted Step." } - // clang-format on +#define LLDB_OPTIONS_thread_step_scope +#include "CommandOptions.inc" }; class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed { @@ -484,7 +471,7 @@ public: case 'e': if (option_arg == "block") { - m_end_line_is_block_end = 1; + m_end_line_is_block_end = true; break; } if (option_arg.getAsInteger(0, m_end_line)) @@ -617,7 +604,7 @@ protected: result.AppendErrorWithFormat("empty class name for scripted step."); result.SetStatus(eReturnStatusFailed); return false; - } else if (!m_interpreter.GetScriptInterpreter()->CheckObjectExists( + } else if (!GetDebugger().GetScriptInterpreter()->CheckObjectExists( m_options.m_class_name.c_str())) { result.AppendErrorWithFormat( "class for scripted step: \"%s\" does not exist.", @@ -808,9 +795,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectThreadContinue -//------------------------------------------------------------------------- class CommandObjectThreadContinue : public CommandObjectParsed { public: @@ -843,7 +828,7 @@ public: bool DoExecute(Args &command, CommandReturnObject &result) override { bool synchronous_execution = m_interpreter.GetSynchronous(); - if (!m_interpreter.GetDebugger().GetSelectedTarget()) { + if (!GetDebugger().GetSelectedTarget()) { result.AppendError("invalid target, create a debug target using the " "'target create' command"); result.SetStatus(eReturnStatusFailed); @@ -988,9 +973,7 @@ public: } }; -//------------------------------------------------------------------------- // CommandObjectThreadUntil -//------------------------------------------------------------------------- static constexpr OptionEnumValueElement g_duo_running_mode[] = { {eOnlyThisThread, "this-thread", "Run only this thread"}, @@ -1001,12 +984,8 @@ static constexpr OptionEnumValues DuoRunningModes() { } static constexpr OptionDefinition g_thread_until_options[] = { - // clang-format off - { LLDB_OPT_SET_1, false, "frame", 'f', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFrameIndex, "Frame index for until operation - defaults to 0" }, - { LLDB_OPT_SET_1, false, "thread", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadIndex, "Thread index for the thread for until operation" }, - { LLDB_OPT_SET_1, false, "run-mode",'m', OptionParser::eRequiredArgument, nullptr, DuoRunningModes(), 0, eArgTypeRunMode, "Determine how to run other threads while stepping this one" }, - { LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Run until we reach the specified address, or leave the function - can be specified multiple times." } - // clang-format on +#define LLDB_OPTIONS_thread_until +#include "CommandOptions.inc" }; class CommandObjectThreadUntil : public CommandObjectParsed { @@ -1125,7 +1104,7 @@ protected: bool DoExecute(Args &command, CommandReturnObject &result) override { bool synchronous_execution = m_interpreter.GetSynchronous(); - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("invalid target, create a debug target using the " "'target create' command"); @@ -1329,9 +1308,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectThreadSelect -//------------------------------------------------------------------------- class CommandObjectThreadSelect : public CommandObjectParsed { public: @@ -1392,16 +1369,16 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectThreadList -//------------------------------------------------------------------------- class CommandObjectThreadList : public CommandObjectParsed { public: CommandObjectThreadList(CommandInterpreter &interpreter) : CommandObjectParsed( interpreter, "thread list", - "Show a summary of each thread in the current target process.", + "Show a summary of each thread in the current target process. " + "Use 'settings set thread-format' to customize the individual " + "thread listings.", "thread list", eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {} @@ -1424,15 +1401,11 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectThreadInfo -//------------------------------------------------------------------------- static constexpr OptionDefinition g_thread_info_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, false, "json", 'j', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the thread info in JSON format." }, - { LLDB_OPT_SET_ALL, false, "stop-info", 's', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the extended stop info in JSON format." } - // clang-format on +#define LLDB_OPTIONS_thread_info +#include "CommandOptions.inc" }; class CommandObjectThreadInfo : public CommandObjectIterateOverThreads { @@ -1519,9 +1492,7 @@ public: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectThreadException -//------------------------------------------------------------------------- class CommandObjectThreadException : public CommandObjectIterateOverThreads { public: @@ -1564,14 +1535,11 @@ class CommandObjectThreadException : public CommandObjectIterateOverThreads { } }; -//------------------------------------------------------------------------- // CommandObjectThreadReturn -//------------------------------------------------------------------------- static constexpr OptionDefinition g_thread_return_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, false, "from-expression", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Return from the innermost expression evaluation." } - // clang-format on +#define LLDB_OPTIONS_thread_return +#include "CommandOptions.inc" }; class CommandObjectThreadReturn : public CommandObjectRaw { @@ -1742,18 +1710,11 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectThreadJump -//------------------------------------------------------------------------- static constexpr OptionDefinition g_thread_jump_options[] = { - // clang-format off - { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "Specifies the source file to jump to." }, - { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLineNum, "Specifies the line number to jump to." }, - { LLDB_OPT_SET_2, true, "by", 'b', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOffset, "Jumps by a relative line offset from the current line." }, - { LLDB_OPT_SET_3, true, "address", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Jumps to a specific address." }, - { LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "force", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allows the PC to leave the current function." } - // clang-format on +#define LLDB_OPTIONS_thread_jump +#include "CommandOptions.inc" }; class CommandObjectThreadJump : public CommandObjectParsed { @@ -1890,19 +1851,13 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // Next are the subcommands of CommandObjectMultiwordThreadPlan -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- // CommandObjectThreadPlanList -//------------------------------------------------------------------------- static constexpr OptionDefinition g_thread_plan_list_options[] = { - // clang-format off - { LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display more information about the thread plans" }, - { LLDB_OPT_SET_1, false, "internal", 'i', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display internal as well as user thread plans" } - // clang-format on +#define LLDB_OPTIONS_thread_plan_list +#include "CommandOptions.inc" }; class CommandObjectThreadPlanList : public CommandObjectIterateOverThreads { @@ -2062,9 +2017,7 @@ public: } }; -//------------------------------------------------------------------------- // CommandObjectMultiwordThreadPlan -//------------------------------------------------------------------------- class CommandObjectMultiwordThreadPlan : public CommandObjectMultiword { public: @@ -2083,9 +2036,7 @@ public: ~CommandObjectMultiwordThreadPlan() override = default; }; -//------------------------------------------------------------------------- // CommandObjectMultiwordThread -//------------------------------------------------------------------------- CommandObjectMultiwordThread::CommandObjectMultiwordThread( CommandInterpreter &interpreter) diff --git a/source/Commands/CommandObjectThread.h b/source/Commands/CommandObjectThread.h index 5da31cec58e1..77729ceecd63 100644 --- a/source/Commands/CommandObjectThread.h +++ b/source/Commands/CommandObjectThread.h @@ -1,9 +1,8 @@ //===-- CommandObjectThread.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectType.cpp b/source/Commands/CommandObjectType.cpp index 815e563197b0..98a43f50b1b1 100644 --- a/source/Commands/CommandObjectType.cpp +++ b/source/Commands/CommandObjectType.cpp @@ -1,18 +1,13 @@ //===-- CommandObjectType.cpp -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 "CommandObjectType.h" -#include <algorithm> -#include <cctype> -#include <functional> - #include "lldb/Core/Debugger.h" #include "lldb/Core/IOHandler.h" #include "lldb/DataFormatters/DataVisualization.h" @@ -40,6 +35,11 @@ #include "llvm/ADT/STLExtras.h" +#include <algorithm> +#include <cctype> +#include <functional> +#include <memory> + using namespace lldb; using namespace lldb_private; @@ -52,7 +52,7 @@ public: std::string m_category; ScriptAddOptions(const TypeSummaryImpl::Flags &flags, bool regx, - const ConstString &name, std::string catg) + ConstString name, std::string catg) : m_flags(flags), m_regex(regx), m_name(name), m_category(catg) {} typedef std::shared_ptr<ScriptAddOptions> SharedPointer; @@ -96,23 +96,8 @@ static bool WarnOnPotentialUnquotedUnsignedType(Args &command, } static constexpr OptionDefinition g_type_summary_add_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Add this to the given category instead of the default one." }, - { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, cascade through typedef chains." }, - { LLDB_OPT_SET_ALL, false, "no-value", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't show the value, just show the summary, for this type." }, - { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects." }, - { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for references-to-type objects." }, - { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type names are actually regular expressions." }, - { LLDB_OPT_SET_1, true, "inline-children", 'c', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "If true, inline all child values into summary string." }, - { LLDB_OPT_SET_1, false, "omit-names", 'O', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "If true, omit value names in the summary display." }, - { LLDB_OPT_SET_2, true, "summary-string", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeSummaryString, "Summary string used to display text and object contents." }, - { LLDB_OPT_SET_3, false, "python-script", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonScript, "Give a one-liner Python script as part of the command." }, - { LLDB_OPT_SET_3, false, "python-function", 'F', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonFunction, "Give the name of a Python function to use for this type." }, - { LLDB_OPT_SET_3, false, "input-python", 'P', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Input Python code to use for this type manually." }, - { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "expand", 'e', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Expand aggregate data types to show children on separate lines." }, - { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "hide-empty", 'h', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Do not expand aggregate data types with no children." }, - { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "A name for this summary string." } - // clang-format on +#define LLDB_OPTIONS_type_summary_add +#include "CommandOptions.inc" }; class CommandObjectTypeSummaryAdd : public CommandObjectParsed, @@ -160,7 +145,7 @@ public: ~CommandObjectTypeSummaryAdd() override = default; - void IOHandlerActivated(IOHandler &io_handler) override { + void IOHandlerActivated(IOHandler &io_handler, bool interactive) override { static const char *g_summary_addreader_instructions = "Enter your Python command(s). Type 'DONE' to end.\n" "def function (valobj,internal_dict):\n" @@ -169,7 +154,7 @@ public: " internal_dict: an LLDB support object not to be used\"\"\"\n"; StreamFileSP output_sp(io_handler.GetOutputStreamFile()); - if (output_sp) { + if (output_sp && interactive) { output_sp->PutCString(g_summary_addreader_instructions); output_sp->Flush(); } @@ -180,7 +165,7 @@ public: StreamFileSP error_sp = io_handler.GetErrorStreamFile(); #ifndef LLDB_DISABLE_PYTHON - ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter(); if (interpreter) { StringList lines; lines.SplitIntoLines(data); @@ -192,7 +177,7 @@ public: options_ptr); // this will ensure that we get rid of the pointer // when going out of scope - ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter(); if (interpreter) { std::string funct_name_str; if (interpreter->GenerateTypeScriptFunction(lines, @@ -206,9 +191,9 @@ public: // for every type in the list TypeSummaryImplSP script_format; - script_format.reset(new ScriptSummaryFormat( + script_format = std::make_shared<ScriptSummaryFormat>( options->m_flags, funct_name_str.c_str(), - lines.CopyList(" ").c_str())); + lines.CopyList(" ").c_str()); Status error; @@ -298,15 +283,8 @@ static const char *g_synth_addreader_instructions = "class synthProvider:\n"; static constexpr OptionDefinition g_type_synth_add_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, cascade through typedef chains." }, - { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects." }, - { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for references-to-type objects." }, - { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Add this to the given category instead of the default one." }, - { LLDB_OPT_SET_2, false, "python-class", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonClass, "Use this Python class to produce synthetic children." }, - { LLDB_OPT_SET_3, false, "input-python", 'P', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type Python code to generate a class that provides synthetic children." }, - { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type names are actually regular expressions." } - // clang-format on +#define LLDB_OPTIONS_type_synth_add +#include "CommandOptions.inc" }; class CommandObjectTypeSynthAdd : public CommandObjectParsed, @@ -412,9 +390,9 @@ protected: } } - void IOHandlerActivated(IOHandler &io_handler) override { + void IOHandlerActivated(IOHandler &io_handler, bool interactive) override { StreamFileSP output_sp(io_handler.GetOutputStreamFile()); - if (output_sp) { + if (output_sp && interactive) { output_sp->PutCString(g_synth_addreader_instructions); output_sp->Flush(); } @@ -425,7 +403,7 @@ protected: StreamFileSP error_sp = io_handler.GetErrorStreamFile(); #ifndef LLDB_DISABLE_PYTHON - ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter(); if (interpreter) { StringList lines; lines.SplitIntoLines(data); @@ -437,7 +415,7 @@ protected: options_ptr); // this will ensure that we get rid of the pointer // when going out of scope - ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter(); if (interpreter) { std::string class_name_str; if (interpreter->GenerateTypeSynthClass(lines, class_name_str)) { @@ -450,12 +428,12 @@ protected: // class SyntheticChildrenSP synth_provider; - synth_provider.reset(new ScriptedSyntheticChildren( + synth_provider = std::make_shared<ScriptedSyntheticChildren>( SyntheticChildren::Flags() .SetCascades(options->m_cascade) .SetSkipPointers(options->m_skip_pointers) .SetSkipReferences(options->m_skip_references), - class_name_str.c_str())); + class_name_str.c_str()); lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory( @@ -523,19 +501,11 @@ public: Status *error); }; -//------------------------------------------------------------------------- // CommandObjectTypeFormatAdd -//------------------------------------------------------------------------- static constexpr OptionDefinition g_type_format_add_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Add this to the given category instead of the default one." }, - { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, cascade through typedef chains." }, - { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects." }, - { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for references-to-type objects." }, - { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type names are actually regular expressions." }, - { LLDB_OPT_SET_2, false, "type", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Format variables as if they were of this type." } - // clang-format on +#define LLDB_OPTIONS_type_format_add +#include "CommandOptions.inc" }; class CommandObjectTypeFormatAdd : public CommandObjectParsed { @@ -700,18 +670,18 @@ protected: TypeFormatImplSP entry; if (m_command_options.m_custom_type_name.empty()) - entry.reset(new TypeFormatImpl_Format( + entry = std::make_shared<TypeFormatImpl_Format>( format, TypeFormatImpl::Flags() .SetCascades(m_command_options.m_cascade) .SetSkipPointers(m_command_options.m_skip_pointers) - .SetSkipReferences(m_command_options.m_skip_references))); + .SetSkipReferences(m_command_options.m_skip_references)); else - entry.reset(new TypeFormatImpl_EnumType( + entry = std::make_shared<TypeFormatImpl_EnumType>( ConstString(m_command_options.m_custom_type_name.c_str()), TypeFormatImpl::Flags() .SetCascades(m_command_options.m_cascade) .SetSkipPointers(m_command_options.m_skip_pointers) - .SetSkipReferences(m_command_options.m_skip_references))); + .SetSkipReferences(m_command_options.m_skip_references)); // now I have a valid format, let's add it to every type @@ -751,11 +721,8 @@ protected: }; static constexpr OptionDefinition g_type_formatter_delete_options[] = { - // clang-format off - { LLDB_OPT_SET_1, false, "all", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Delete from every category." }, - { LLDB_OPT_SET_2, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Delete from given category." }, - { LLDB_OPT_SET_3, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Delete from given language's category." } - // clang-format on +#define LLDB_OPTIONS_type_formatter_delete +#include "CommandOptions.inc" }; class CommandObjectTypeFormatterDelete : public CommandObjectParsed { @@ -893,9 +860,8 @@ protected: }; static constexpr OptionDefinition g_type_formatter_clear_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, false, "all", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Clear every category." } - // clang-format on +#define LLDB_OPTIONS_type_formatter_clear +#include "CommandOptions.inc" }; class CommandObjectTypeFormatterClear : public CommandObjectParsed { @@ -980,9 +946,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectTypeFormatDelete -//------------------------------------------------------------------------- class CommandObjectTypeFormatDelete : public CommandObjectTypeFormatterDelete { public: @@ -996,9 +960,7 @@ public: ~CommandObjectTypeFormatDelete() override = default; }; -//------------------------------------------------------------------------- // CommandObjectTypeFormatClear -//------------------------------------------------------------------------- class CommandObjectTypeFormatClear : public CommandObjectTypeFormatterClear { public: @@ -1011,10 +973,8 @@ public: static constexpr OptionDefinition g_type_formatter_list_options[] = { - // clang-format off - {LLDB_OPT_SET_1, false, "category-regex", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Only show categories matching this filter."}, - {LLDB_OPT_SET_2, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Only show the category for a specific language."} - // clang-format on +#define LLDB_OPTIONS_type_formatter_list +#include "CommandOptions.inc" }; template <typename FormatterType> @@ -1222,9 +1182,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectTypeFormatList -//------------------------------------------------------------------------- class CommandObjectTypeFormatList : public CommandObjectTypeFormatterList<TypeFormatImpl> { @@ -1236,9 +1194,7 @@ public: #ifndef LLDB_DISABLE_PYTHON -//------------------------------------------------------------------------- // CommandObjectTypeSummaryAdd -//------------------------------------------------------------------------- #endif // LLDB_DISABLE_PYTHON @@ -1353,10 +1309,10 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary( std::string code = (" " + m_options.m_python_function + "(valobj,internal_dict)"); - script_format.reset( - new ScriptSummaryFormat(m_options.m_flags, funct_name, code.c_str())); + script_format = std::make_shared<ScriptSummaryFormat>( + m_options.m_flags, funct_name, code.c_str()); - ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter(); if (interpreter && !interpreter->CheckObjectExists(funct_name)) result.AppendWarningWithFormat( @@ -1366,7 +1322,7 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary( } else if (!m_options.m_python_script .empty()) // we have a quick 1-line script, just use it { - ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter(); if (!interpreter) { result.AppendError("script interpreter missing - unable to generate " "function wrapper.\n"); @@ -1390,8 +1346,8 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary( std::string code = " " + m_options.m_python_script; - script_format.reset(new ScriptSummaryFormat( - m_options.m_flags, funct_name_str.c_str(), code.c_str())); + script_format = std::make_shared<ScriptSummaryFormat>( + m_options.m_flags, funct_name_str.c_str(), code.c_str()); } else { // Use an IOHandler to grab Python code from the user ScriptAddOptions *options = @@ -1713,9 +1669,7 @@ bool CommandObjectTypeSummaryAdd::AddSummary(ConstString type_name, } } -//------------------------------------------------------------------------- // CommandObjectTypeSummaryDelete -//------------------------------------------------------------------------- class CommandObjectTypeSummaryDelete : public CommandObjectTypeFormatterDelete { public: @@ -1749,9 +1703,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectTypeSummaryList -//------------------------------------------------------------------------- class CommandObjectTypeSummaryList : public CommandObjectTypeFormatterList<TypeSummaryImpl> { @@ -1778,15 +1730,11 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectTypeCategoryDefine -//------------------------------------------------------------------------- static constexpr OptionDefinition g_type_category_define_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, false, "enabled", 'e', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "If specified, this category will be created enabled." }, - { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Specify the language that this category is supported for." } - // clang-format on +#define LLDB_OPTIONS_type_category_define +#include "CommandOptions.inc" }; class CommandObjectTypeCategoryDefine : public CommandObjectParsed { @@ -1885,14 +1833,11 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectTypeCategoryEnable -//------------------------------------------------------------------------- static constexpr OptionDefinition g_type_category_enable_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Enable the category for this language." }, - // clang-format on +#define LLDB_OPTIONS_type_category_enable +#include "CommandOptions.inc" }; class CommandObjectTypeCategoryEnable : public CommandObjectParsed { @@ -2002,9 +1947,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectTypeCategoryDelete -//------------------------------------------------------------------------- class CommandObjectTypeCategoryDelete : public CommandObjectParsed { public: @@ -2062,14 +2005,11 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectTypeCategoryDisable -//------------------------------------------------------------------------- OptionDefinition constexpr g_type_category_disable_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Enable the category for this language." } - // clang-format on +#define LLDB_OPTIONS_type_category_disable +#include "CommandOptions.inc" }; class CommandObjectTypeCategoryDisable : public CommandObjectParsed { @@ -2174,9 +2114,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectTypeCategoryList -//------------------------------------------------------------------------- class CommandObjectTypeCategoryList : public CommandObjectParsed { public: @@ -2245,9 +2183,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectTypeFilterList -//------------------------------------------------------------------------- class CommandObjectTypeFilterList : public CommandObjectTypeFormatterList<TypeFilterImpl> { @@ -2259,9 +2195,7 @@ public: #ifndef LLDB_DISABLE_PYTHON -//------------------------------------------------------------------------- // CommandObjectTypeSynthList -//------------------------------------------------------------------------- class CommandObjectTypeSynthList : public CommandObjectTypeFormatterList<SyntheticChildren> { @@ -2274,9 +2208,7 @@ public: #endif // LLDB_DISABLE_PYTHON -//------------------------------------------------------------------------- // CommandObjectTypeFilterDelete -//------------------------------------------------------------------------- class CommandObjectTypeFilterDelete : public CommandObjectTypeFormatterDelete { public: @@ -2291,9 +2223,7 @@ public: #ifndef LLDB_DISABLE_PYTHON -//------------------------------------------------------------------------- // CommandObjectTypeSynthDelete -//------------------------------------------------------------------------- class CommandObjectTypeSynthDelete : public CommandObjectTypeFormatterDelete { public: @@ -2309,9 +2239,7 @@ public: #endif // LLDB_DISABLE_PYTHON -//------------------------------------------------------------------------- // CommandObjectTypeFilterClear -//------------------------------------------------------------------------- class CommandObjectTypeFilterClear : public CommandObjectTypeFormatterClear { public: @@ -2323,9 +2251,7 @@ public: }; #ifndef LLDB_DISABLE_PYTHON -//------------------------------------------------------------------------- // CommandObjectTypeSynthClear -//------------------------------------------------------------------------- class CommandObjectTypeSynthClear : public CommandObjectTypeFormatterClear { public: @@ -2393,7 +2319,7 @@ bool CommandObjectTypeSynthAdd::Execute_PythonClass( entry.reset(impl); - ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter(); if (interpreter && !interpreter->CheckObjectExists(impl->GetPythonClassName())) @@ -2491,14 +2417,8 @@ bool CommandObjectTypeSynthAdd::AddSynth(ConstString type_name, #endif // LLDB_DISABLE_PYTHON static constexpr OptionDefinition g_type_filter_add_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, cascade through typedef chains." }, - { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects." }, - { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for references-to-type objects." }, - { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Add this to the given category instead of the default one." }, - { LLDB_OPT_SET_ALL, false, "child", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeExpressionPath, "Include this expression path in the synthetic view." }, - { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type names are actually regular expressions." } - // clang-format on +#define LLDB_OPTIONS_type_filter_add +#include "CommandOptions.inc" }; class CommandObjectTypeFilterAdd : public CommandObjectParsed { @@ -2742,14 +2662,10 @@ protected: } }; -//---------------------------------------------------------------------- // "type lookup" -//---------------------------------------------------------------------- static constexpr OptionDefinition g_type_lookup_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, false, "show-help", 'h', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display available help for types" }, - { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Which language's types should the search scope be" } - // clang-format on +#define LLDB_OPTIONS_type_lookup +#include "CommandOptions.inc" }; class CommandObjectTypeLookup : public CommandObjectRaw { @@ -2844,17 +2760,11 @@ public: return m_cmd_help_long; StreamString stream; - // FIXME: hardcoding languages is not good - lldb::LanguageType languages[] = {eLanguageTypeObjC, - eLanguageTypeC_plus_plus}; - - for (const auto lang_type : languages) { - if (auto language = Language::FindPlugin(lang_type)) { - if (const char *help = language->GetLanguageSpecificTypeLookupHelp()) { - stream.Printf("%s\n", help); - } - } - } + Language::ForEach([&](Language *lang) { + if (const char *help = lang->GetLanguageSpecificTypeLookupHelp()) + stream.Printf("%s\n", help); + return true; + }); m_cmd_help_long = stream.GetString(); return m_cmd_help_long; @@ -2879,10 +2789,6 @@ public: exe_ctx)) return false; - // TargetSP - // target_sp(GetCommandInterpreter().GetDebugger().GetSelectedTarget()); - // const bool fill_all_in = true; - // ExecutionContext exe_ctx(target_sp.get(), fill_all_in); ExecutionContextScope *best_scope = exe_ctx.GetBestExecutionContextScope(); bool any_found = false; @@ -2894,9 +2800,10 @@ public: if ((is_global_search = (m_command_options.m_language == eLanguageTypeUnknown))) { - // FIXME: hardcoding languages is not good - languages.push_back(Language::FindPlugin(eLanguageTypeObjC)); - languages.push_back(Language::FindPlugin(eLanguageTypeC_plus_plus)); + Language::ForEach([&](Language *lang) { + languages.push_back(lang); + return true; + }); } else { languages.push_back(Language::FindPlugin(m_command_options.m_language)); } @@ -2994,7 +2901,7 @@ public: protected: bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override { - TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget(); + TargetSP target_sp = GetDebugger().GetSelectedTarget(); Thread *thread = GetDefaultThread(); if (!thread) { result.AppendError("no default thread"); @@ -3168,9 +3075,7 @@ public: ~CommandObjectTypeSummary() override = default; }; -//------------------------------------------------------------------------- // CommandObjectType -//------------------------------------------------------------------------- CommandObjectType::CommandObjectType(CommandInterpreter &interpreter) : CommandObjectMultiword(interpreter, "type", diff --git a/source/Commands/CommandObjectType.h b/source/Commands/CommandObjectType.h index a9223f842b30..ebb19039e503 100644 --- a/source/Commands/CommandObjectType.h +++ b/source/Commands/CommandObjectType.h @@ -1,9 +1,8 @@ //===-- CommandObjectType.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// diff --git a/source/Commands/CommandObjectVersion.cpp b/source/Commands/CommandObjectVersion.cpp index 6155f49e9762..904baf5b7d44 100644 --- a/source/Commands/CommandObjectVersion.cpp +++ b/source/Commands/CommandObjectVersion.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectVersion.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -16,9 +15,7 @@ using namespace lldb; using namespace lldb_private; -//------------------------------------------------------------------------- // CommandObjectVersion -//------------------------------------------------------------------------- CommandObjectVersion::CommandObjectVersion(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "version", diff --git a/source/Commands/CommandObjectVersion.h b/source/Commands/CommandObjectVersion.h index d1afafc69bf8..30f44aeb1658 100644 --- a/source/Commands/CommandObjectVersion.h +++ b/source/Commands/CommandObjectVersion.h @@ -1,9 +1,8 @@ //===-- CommandObjectVersion.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -14,9 +13,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectVersion -//------------------------------------------------------------------------- class CommandObjectVersion : public CommandObjectParsed { public: diff --git a/source/Commands/CommandObjectWatchpoint.cpp b/source/Commands/CommandObjectWatchpoint.cpp index d2600a462203..98e758b7ef6a 100644 --- a/source/Commands/CommandObjectWatchpoint.cpp +++ b/source/Commands/CommandObjectWatchpoint.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectWatchpoint.cpp -----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -143,21 +142,14 @@ bool CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs( return !in_range; } -//------------------------------------------------------------------------- // CommandObjectWatchpointList -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- // CommandObjectWatchpointList::Options -//------------------------------------------------------------------------- #pragma mark List::CommandOptions static constexpr OptionDefinition g_watchpoint_list_options[] = { - // clang-format off - { LLDB_OPT_SET_1, false, "brief", 'b', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Give a brief description of the watchpoint (no location info)." }, - { LLDB_OPT_SET_2, false, "full", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Give a full description of the watchpoint and its locations." }, - { LLDB_OPT_SET_3, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Explain everything we know about the watchpoint (for debugging debugger bugs)." } - // clang-format on +#define LLDB_OPTIONS_watchpoint_list +#include "CommandOptions.inc" }; #pragma mark List @@ -230,7 +222,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("Invalid target. No current target or watchpoints."); result.SetStatus(eReturnStatusSuccessFinishNoResult); @@ -296,9 +288,7 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectWatchpointEnable -//------------------------------------------------------------------------- #pragma mark Enable class CommandObjectWatchpointEnable : public CommandObjectParsed { @@ -320,7 +310,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (!CheckTargetForWatchpointOperations(target, result)) return false; @@ -367,9 +357,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectWatchpointDisable -//------------------------------------------------------------------------- #pragma mark Disable class CommandObjectWatchpointDisable : public CommandObjectParsed { @@ -392,7 +380,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (!CheckTargetForWatchpointOperations(target, result)) return false; @@ -442,9 +430,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectWatchpointDelete -//------------------------------------------------------------------------- #pragma mark Delete class CommandObjectWatchpointDelete : public CommandObjectParsed { @@ -466,7 +452,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (!CheckTargetForWatchpointOperations(target, result)) return false; @@ -518,15 +504,12 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectWatchpointIgnore -//------------------------------------------------------------------------- #pragma mark Ignore::CommandOptions static constexpr OptionDefinition g_watchpoint_ignore_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, true, "ignore-count", 'i', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCount, "Set the number of times this watchpoint is skipped before stopping." } - // clang-format on +#define LLDB_OPTIONS_watchpoint_ignore +#include "CommandOptions.inc" }; class CommandObjectWatchpointIgnore : public CommandObjectParsed { @@ -590,7 +573,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (!CheckTargetForWatchpointOperations(target, result)) return false; @@ -639,16 +622,13 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectWatchpointModify -//------------------------------------------------------------------------- #pragma mark Modify::CommandOptions static constexpr OptionDefinition g_watchpoint_modify_options[] = { - // clang-format off - { LLDB_OPT_SET_ALL, false, "condition", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeExpression, "The watchpoint stops only if this condition expression evaluates to true." } - // clang-format on +#define LLDB_OPTIONS_watchpoint_modify +#include "CommandOptions.inc" }; #pragma mark Modify @@ -719,7 +699,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (!CheckTargetForWatchpointOperations(target, result)) return false; @@ -770,9 +750,7 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectWatchpointSetVariable -//------------------------------------------------------------------------- #pragma mark SetVariable class CommandObjectWatchpointSetVariable : public CommandObjectParsed { @@ -839,7 +817,7 @@ protected: } bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); StackFrame *frame = m_exe_ctx.GetFramePtr(); // If no argument is present, issue an error message. There's no way to @@ -960,9 +938,7 @@ private: OptionGroupWatchpoint m_option_watchpoint; }; -//------------------------------------------------------------------------- // CommandObjectWatchpointSetExpression -//------------------------------------------------------------------------- #pragma mark Set class CommandObjectWatchpointSetExpression : public CommandObjectRaw { @@ -1026,7 +1002,7 @@ protected: m_option_group.NotifyOptionParsingStarting( &exe_ctx); // This is a raw command, so notify the option group - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); StackFrame *frame = m_exe_ctx.GetFramePtr(); OptionsWithRaw args(raw_command); @@ -1128,9 +1104,7 @@ private: OptionGroupWatchpoint m_option_watchpoint; }; -//------------------------------------------------------------------------- // CommandObjectWatchpointSet -//------------------------------------------------------------------------- #pragma mark Set class CommandObjectWatchpointSet : public CommandObjectMultiword { @@ -1151,9 +1125,7 @@ public: ~CommandObjectWatchpointSet() override = default; }; -//------------------------------------------------------------------------- // CommandObjectMultiwordWatchpoint -//------------------------------------------------------------------------- #pragma mark MultiwordWatchpoint CommandObjectMultiwordWatchpoint::CommandObjectMultiwordWatchpoint( diff --git a/source/Commands/CommandObjectWatchpoint.h b/source/Commands/CommandObjectWatchpoint.h index bc0a2c0c6a7d..f21796e6bc8d 100644 --- a/source/Commands/CommandObjectWatchpoint.h +++ b/source/Commands/CommandObjectWatchpoint.h @@ -1,9 +1,8 @@ //===-- CommandObjectWatchpoint.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -17,9 +16,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectMultiwordWatchpoint -//------------------------------------------------------------------------- class CommandObjectMultiwordWatchpoint : public CommandObjectMultiword { public: diff --git a/source/Commands/CommandObjectWatchpointCommand.cpp b/source/Commands/CommandObjectWatchpointCommand.cpp index 3a9ebfbd15d0..2be0b5b154e0 100644 --- a/source/Commands/CommandObjectWatchpointCommand.cpp +++ b/source/Commands/CommandObjectWatchpointCommand.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectWatchpointCommand.cpp ----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -25,9 +24,7 @@ using namespace lldb; using namespace lldb_private; -//------------------------------------------------------------------------- // CommandObjectWatchpointCommandAdd -//------------------------------------------------------------------------- // FIXME: "script-type" needs to have its contents determined dynamically, so // somebody can add a new scripting @@ -46,12 +43,8 @@ static constexpr OptionEnumValues ScriptOptionEnum() { } static constexpr OptionDefinition g_watchpoint_command_add_options[] = { - // clang-format off - { LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOneLiner, "Specify a one-line watchpoint command inline. Be sure to surround it with quotes." }, - { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Specify whether watchpoint command execution should terminate on error." }, - { LLDB_OPT_SET_ALL, false, "script-type", 's', OptionParser::eRequiredArgument, nullptr, ScriptOptionEnum(), 0, eArgTypeNone, "Specify the language for the commands - if none is specified, the lldb command interpreter will be used." }, - { LLDB_OPT_SET_2, false, "python-function", 'F', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonFunction, "Give the name of a Python function to run as command for this watchpoint. Be sure to give a module name if appropriate." } - // clang-format on +#define LLDB_OPTIONS_watchpoint_command_add +#include "CommandOptions.inc" }; class CommandObjectWatchpointCommandAdd : public CommandObjectParsed, @@ -208,9 +201,9 @@ are no syntax errors may indicate that a function was declared but never called. Options *GetOptions() override { return &m_options; } - void IOHandlerActivated(IOHandler &io_handler) override { + void IOHandlerActivated(IOHandler &io_handler, bool interactive) override { StreamFileSP output_sp(io_handler.GetOutputStreamFile()); - if (output_sp) { + if (output_sp && interactive) { output_sp->PutCString( "Enter your debugger command(s). Type 'DONE' to end.\n"); output_sp->Flush(); @@ -226,12 +219,12 @@ are no syntax errors may indicate that a function was declared but never called. WatchpointOptions *wp_options = (WatchpointOptions *)io_handler.GetUserData(); if (wp_options) { - std::unique_ptr<WatchpointOptions::CommandData> data_ap( + std::unique_ptr<WatchpointOptions::CommandData> data_up( new WatchpointOptions::CommandData()); - if (data_ap) { - data_ap->user_source.SplitIntoLines(line); + if (data_up) { + data_up->user_source.SplitIntoLines(line); auto baton_sp = std::make_shared<WatchpointOptions::CommandBaton>( - std::move(data_ap)); + std::move(data_up)); wp_options->SetCallback(WatchpointOptionsCallbackFunction, baton_sp); } } @@ -250,19 +243,19 @@ are no syntax errors may indicate that a function was declared but never called. /// Set a one-liner as the callback for the watchpoint. void SetWatchpointCommandCallback(WatchpointOptions *wp_options, const char *oneliner) { - std::unique_ptr<WatchpointOptions::CommandData> data_ap( + std::unique_ptr<WatchpointOptions::CommandData> data_up( new WatchpointOptions::CommandData()); // It's necessary to set both user_source and script_source to the // oneliner. The former is used to generate callback description (as in // watchpoint command list) while the latter is used for Python to // interpret during the actual callback. - data_ap->user_source.AppendString(oneliner); - data_ap->script_source.assign(oneliner); - data_ap->stop_on_error = m_options.m_stop_on_error; + data_up->user_source.AppendString(oneliner); + data_up->script_source.assign(oneliner); + data_up->stop_on_error = m_options.m_stop_on_error; auto baton_sp = - std::make_shared<WatchpointOptions::CommandBaton>(std::move(data_ap)); + std::make_shared<WatchpointOptions::CommandBaton>(std::move(data_up)); wp_options->SetCallback(WatchpointOptionsCallbackFunction, baton_sp); } @@ -298,6 +291,7 @@ are no syntax errors may indicate that a function was declared but never called. options.SetStopOnError(data->stop_on_error); options.SetEchoCommands(false); options.SetPrintResults(true); + options.SetPrintErrors(true); options.SetAddToHistory(false); debugger.GetCommandInterpreter().HandleCommands(commands, &exe_ctx, @@ -390,7 +384,7 @@ are no syntax errors may indicate that a function was declared but never called. protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("There is not a current executable; there are no " @@ -445,7 +439,7 @@ protected: if (m_options.m_use_script_language) { // Special handling for one-liner specified inline. if (m_options.m_use_one_liner) { - m_interpreter.GetScriptInterpreter()->SetWatchpointCommandCallback( + GetDebugger().GetScriptInterpreter()->SetWatchpointCommandCallback( wp_options, m_options.m_one_liner.c_str()); } // Special handling for using a Python function by name instead of @@ -455,10 +449,11 @@ protected: else if (!m_options.m_function_name.empty()) { std::string oneliner(m_options.m_function_name); oneliner += "(frame, wp, internal_dict)"; - m_interpreter.GetScriptInterpreter()->SetWatchpointCommandCallback( + GetDebugger().GetScriptInterpreter()->SetWatchpointCommandCallback( wp_options, oneliner.c_str()); } else { - m_interpreter.GetScriptInterpreter() + GetDebugger() + .GetScriptInterpreter() ->CollectDataForWatchpointCommandCallback(wp_options, result); } } else { @@ -479,9 +474,7 @@ private: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectWatchpointCommandDelete -//------------------------------------------------------------------------- class CommandObjectWatchpointCommandDelete : public CommandObjectParsed { public: @@ -508,7 +501,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("There is not a current executable; there are no " @@ -559,9 +552,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectWatchpointCommandList -//------------------------------------------------------------------------- class CommandObjectWatchpointCommandList : public CommandObjectParsed { public: @@ -589,7 +580,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); if (target == nullptr) { result.AppendError("There is not a current executable; there are no " @@ -659,9 +650,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectWatchpointCommand -//------------------------------------------------------------------------- CommandObjectWatchpointCommand::CommandObjectWatchpointCommand( CommandInterpreter &interpreter) diff --git a/source/Commands/CommandObjectWatchpointCommand.h b/source/Commands/CommandObjectWatchpointCommand.h index e079220d0efe..f2f15ef50b0f 100644 --- a/source/Commands/CommandObjectWatchpointCommand.h +++ b/source/Commands/CommandObjectWatchpointCommand.h @@ -1,9 +1,8 @@ //===-- CommandObjectWatchpointCommand.h ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// @@ -18,9 +17,7 @@ namespace lldb_private { -//------------------------------------------------------------------------- // CommandObjectMultiwordWatchpoint -//------------------------------------------------------------------------- class CommandObjectWatchpointCommand : public CommandObjectMultiword { public: diff --git a/source/Commands/Options.td b/source/Commands/Options.td new file mode 100644 index 000000000000..9cfbcd2d4ebf --- /dev/null +++ b/source/Commands/Options.td @@ -0,0 +1,308 @@ +include "OptionsBase.td" + +let Command = "target modules dump symtab" in { + def tm_sort : Option<"sort", "s">, Group<1>, + Desc<"Supply a sort order when dumping the symbol table.">, + EnumArg<"SortOrder", "OptionEnumValues(g_sort_option_enumeration)">; +} + +let Command = "help" in { + def help_hide_aliases : Option<"hide-aliases", "a">, + Desc<"Hide aliases in the command list.">; + def help_hide_user : Option<"hide-user-commands", "u">, + Desc<"Hide user-defined commands from the list.">; + def help_show_hidden : Option<"show-hidden-commands", "h">, + Desc<"Include commands prefixed with an underscore.">; +} + +let Command = "settings set" in { + def setset_global : Option<"global", "g">, Arg<"Filename">, + Completion<"DiskFile">, + Desc<"Apply the new value to the global default value.">; + def setset_force : Option<"force", "f">, + Desc<"Force an empty value to be accepted as the default.">; +} + +let Command = "settings write" in { + def setwrite_file : Option<"file", "f">, Required, Arg<"Filename">, + Completion<"DiskFile">, + Desc<"The file into which to write the settings.">; + def setwrite_append : Option<"append", "a">, + Desc<"Append to saved settings file if it exists.">; +} + +let Command = "settings read" in { + def setread_file : Option<"file", "f">, Required, Arg<"Filename">, + Completion<"DiskFile">, + Desc<"The file from which to read the settings.">; +} + +let Command = "breakpoint list" in { + def blist_internal : Option<"internal", "i">, + Desc<"Show debugger internal breakpoints">; + def blist_brief : Option<"brief", "b">, Group<1>, + Desc<"Give a brief description of the breakpoint (no location info).">; + def blist_full : Option<"full", "f">, Group<2>, + Desc<"Give a full description of the breakpoint and its locations.">; + def blist_verbose : Option<"verbose", "v">, Group<3>, + Desc<"Explain everything we know about the breakpoint (for debugging " + "debugger bugs).">; + def blist_dummy_bp : Option<"dummy-breakpoints", "D">, + Desc<"List Dummy breakpoints - i.e. breakpoints set before a file is " + "provided, which prime new targets.">; +} + +let Command = "thread backtrace" in { + def thread_backtrace_count : Option<"count", "c">, Group<1>, Arg<"Count">, + Desc<"How many frames to display (-1 for all)">; + def thread_backtrace_start : Option<"start", "s">, Group<1>, + Arg<"FrameIndex">, Desc<"Frame in which to start the backtrace">; + def thread_backtrace_extended : Option<"extended", "e">, Group<1>, + Arg<"Boolean">, Desc<"Show the extended backtrace, if available">; +} + +let Command = "thread step scope" in { + def thread_step_scope_step_in_avoids_no_debug : + Option<"step-in-avoids-no-debug", "a">, Group<1>, Arg<"Boolean">, + Desc<"A boolean value that sets whether stepping into functions will step " + "over functions with no debug information.">; + def thread_step_scope_step_out_avoids_no_debug : + Option<"step-out-avoids-no-debug", "A">, Group<1>, Arg<"Boolean">, + Desc<"A boolean value, if true stepping out of functions will continue to" + " step out till it hits a function with debug information.">; + def thread_step_scope_count : Option<"count", "c">, Group<1>, Arg<"Count">, + Desc<"How many times to perform the stepping operation - currently only " + "supported for step-inst and next-inst.">; + def thread_step_scope_end_linenumber : Option<"end-linenumber", "e">, + Group<1>, Arg<"LineNum">, Desc<"The line at which to stop stepping - " + "defaults to the next line and only supported for step-in and step-over." + " You can also pass the string 'block' to step to the end of the current" + " block. This is particularly use in conjunction with --step-target to" + " step through a complex calling sequence.">; + def thread_step_scope_run_mode : Option<"run-mode", "m">, Group<1>, + EnumArg<"RunMode", "TriRunningModes()">, Desc<"Determine how to run other " + "threads while stepping the current thread.">; + def thread_step_scope_step_over_regexp : Option<"step-over-regexp", "r">, + Group<1>, Arg<"RegularExpression">, Desc<"A regular expression that defines" + "function names to not to stop at when stepping in.">; + def thread_step_scope_step_in_target : Option<"step-in-target", "t">, + Group<1>, Arg<"FunctionName">, Desc<"The name of the directly called " + "function step in should stop at when stepping into.">; + def thread_step_scope_python_class : Option<"python-class", "C">, Group<2>, + Arg<"PythonClass">, Desc<"The name of the class that will manage this step " + "- only supported for Scripted Step.">; +} + +let Command = "thread until" in { + def thread_until_frame : Option<"frame", "f">, Group<1>, Arg<"FrameIndex">, + Desc<"Frame index for until operation - defaults to 0">; + def thread_until_thread : Option<"thread", "t">, Group<1>, Arg<"ThreadIndex">, + Desc<"Thread index for the thread for until operation">; + def thread_until_run_mode : Option<"run-mode", "m">, Group<1>, + EnumArg<"RunMode", "DuoRunningModes()">, Desc<"Determine how to run other" + "threads while stepping this one">; + def thread_until_address : Option<"address", "a">, Group<1>, + Arg<"AddressOrExpression">, Desc<"Run until we reach the specified address," + "or leave the function - can be specified multiple times.">; +} + +let Command = "thread info" in { + def thread_info_json : Option<"json", "j">, Desc<"Display the thread info in" + " JSON format.">; + def thread_info_stop_info : Option<"stop-info", "s">, Desc<"Display the " + "extended stop info in JSON format.">; +} + +let Command = "thread return" in { + def thread_return_from_expression : Option<"from-expression", "x">, + Desc<"Return from the innermost expression evaluation.">; +} + +let Command = "thread jump" in { + def thread_jump_file : Option<"file", "f">, Group<1>, Arg<"Filename">, + Completion<"SourceFile">, Desc<"Specifies the source file to jump to.">; + def thread_jump_line : Option<"line", "l">, Group<1>, Arg<"LineNum">, + Required, Desc<"Specifies the line number to jump to.">; + def thread_jump_by : Option<"by", "b">, Group<2>, Arg<"Offset">, Required, + Desc<"Jumps by a relative line offset from the current line.">; + def thread_jump_address : Option<"address", "a">, Group<3>, + Arg<"AddressOrExpression">, Required, Desc<"Jumps to a specific address.">; + def thread_jump_force : Option<"force", "r">, Groups<[1,2,3]>, + Desc<"Allows the PC to leave the current function.">; +} + +let Command = "thread plan list" in { + def thread_plan_list_verbose : Option<"verbose", "v">, Group<1>, + Desc<"Display more information about the thread plans">; + def thread_plan_list_internal : Option<"internal", "i">, Group<1>, + Desc<"Display internal as well as user thread plans">; +} + +let Command = "type summary add" in { + def type_summary_add_category : Option<"category", "w">, Arg<"Name">, + Desc<"Add this to the given category instead of the default one.">; + def type_summary_add_cascade : Option<"cascade", "C">, Arg<"Boolean">, + Desc<"If true, cascade through typedef chains.">; + def type_summary_add_no_value : Option<"no-value", "v">, + Desc<"Don't show the value, just show the summary, for this type.">; + def type_summary_add_skip_pointers : Option<"skip-pointers", "p">, + Desc<"Don't use this format for pointers-to-type objects.">; + def type_summary_add_skip_references : Option<"skip-references", "r">, + Desc<"Don't use this format for references-to-type objects.">; + def type_summary_add_regex : Option<"regex", "x">, + Desc<"Type names are actually regular expressions.">; + def type_summary_add_inline_children : Option<"inline-children", "c">, + Group<1>, Required, + Desc<"If true, inline all child values into summary string.">; + def type_summary_add_omit_names : Option<"omit-names", "O">, Group<1>, + Desc<"If true, omit value names in the summary display.">; + def type_summary_add_summary_string : Option<"summary-string", "s">, Group<2>, + Arg<"SummaryString">, Required, + Desc<"Summary string used to display text and object contents.">; + def type_summary_add_python_script : Option<"python-script", "o">, Group<3>, + Arg<"PythonScript">, + Desc<"Give a one-liner Python script as part of the command.">; + def type_summary_add_python_function : Option<"python-function", "F">, + Group<3>, Arg<"PythonFunction">, + Desc<"Give the name of a Python function to use for this type.">; + def type_summary_add_input_python : Option<"input-python", "P">, Group<3>, + Desc<"Input Python code to use for this type manually.">; + def type_summary_add_expand : Option<"expand", "e">, Groups<[2,3]>, + Desc<"Expand aggregate data types to show children on separate lines.">; + def type_summary_add_hide_empty : Option<"hide-empty", "h">, Groups<[2,3]>, + Desc<"Do not expand aggregate data types with no children.">; + def type_summary_add_name : Option<"name", "n">, Groups<[2,3]>, Arg<"Name">, + Desc<"A name for this summary string.">; +} + +let Command = "type synth add" in { + def type_synth_add_cascade : Option<"cascade", "C">, Arg<"Boolean">, + Desc<"If true, cascade through typedef chains.">; + def type_synth_add_skip_pointers : Option<"skip-pointers", "p">, + Desc<"Don't use this format for pointers-to-type objects.">; + def type_synth_add_skip_references : Option<"skip-references", "r">, + Desc<"Don't use this format for references-to-type objects.">; + def type_synth_add_category : Option<"category", "w">, Arg<"Name">, + Desc<"Add this to the given category instead of the default one.">; + def type_synth_add_python_class : Option<"python-class", "l">, Group<2>, + Arg<"PythonClass">, + Desc<"Use this Python class to produce synthetic children.">; + def type_synth_add_input_python : Option<"input-python", "P">, Group<3>, + Desc<"Type Python code to generate a class that provides synthetic " + "children.">; + def type_synth_add_regex : Option<"regex", "x">, + Desc<"Type names are actually regular expressions.">; +} + +let Command = "type format add" in { + def type_format_add_category : Option<"category", "w">, Arg<"Name">, + Desc<"Add this to the given category instead of the default one.">; + def type_format_add_cascade : Option<"cascade", "C">, Arg<"Boolean">, + Desc<"If true, cascade through typedef chains.">; + def type_format_add_skip_pointers : Option<"skip-pointers", "p">, + Desc<"Don't use this format for pointers-to-type objects.">; + def type_format_add_skip_references : Option<"skip-references", "r">, + Desc<"Don't use this format for references-to-type objects.">; + def type_format_add_regex : Option<"regex", "x">, + Desc<"Type names are actually regular expressions.">; + def type_format_add_type : Option<"type", "t">, Group<2>, Arg<"Name">, + Desc<"Format variables as if they were of this type.">; +} + +let Command = "type formatter delete" in { + def type_formatter_delete_all : Option<"all", "a">, Group<1>, + Desc<"Delete from every category.">; + def type_formatter_delete_category : Option<"category", "w">, Group<2>, + Arg<"Name">, Desc<"Delete from given category.">; + def type_formatter_delete_language : Option<"language", "l">, Group<3>, + Arg<"Language">, Desc<"Delete from given language's category.">; +} + +let Command = "type formatter clear" in { + def type_formatter_clear_all : Option<"all", "a">, + Desc<"Clear every category.">; +} + +let Command = "type formatter list" in { + def type_formatter_list_category_regex : Option<"category-regex", "w">, + Group<1>, Arg<"Name">, Desc<"Only show categories matching this filter.">; + def type_formatter_list_language : Option<"language", "l">, Group<2>, + Arg<"Language">, Desc<"Only show the category for a specific language.">; +} + +let Command = "type category define" in { + def type_category_define_enabled : Option<"enabled", "e">, + Desc<"If specified, this category will be created enabled.">; + def type_category_define_language : Option<"language", "l">, Arg<"Language">, + Desc<"Specify the language that this category is supported for.">; +} + +let Command = "type category enable" in { + def type_category_enable_language : Option<"language", "l">, Arg<"Language">, + Desc<"Enable the category for this language.">; +} + +let Command = "type category disable" in { + def type_category_disable_language : Option<"language", "l">, Arg<"Language">, + Desc<"Enable the category for this language.">; +} + +let Command = "type filter add" in { + def type_filter_add_cascade : Option<"cascade", "C">, Arg<"Boolean">, + Desc<"If true, cascade through typedef chains.">; + def type_filter_add_skip_pointers : Option<"skip-pointers", "p">, + Desc<"Don't use this format for pointers-to-type objects.">; + def type_filter_add_skip_references : Option<"skip-references", "r">, + Desc<"Don't use this format for references-to-type objects.">; + def type_filter_add_category : Option<"category", "w">, Arg<"Name">, + Desc<"Add this to the given category instead of the default one.">; + def type_filter_add_child : Option<"child", "c">, Arg<"ExpressionPath">, + Desc<"Include this expression path in the synthetic view.">; + def type_filter_add_regex : Option<"regex", "x">, + Desc<"Type names are actually regular expressions.">; +} + +let Command = "type lookup" in { + def type_lookup_show_help : Option<"show-help", "h">, + Desc<"Display available help for types">; + def type_lookup_language : Option<"language", "l">, Arg<"Language">, + Desc<"Which language's types should the search scope be">; +} + +let Command = "watchpoint list" in { + def watchpoint_list_brief : Option<"brief", "b">, Group<1>, Desc<"Give a " + "brief description of the watchpoint (no location info).">; + def watchpoint_list_full : Option<"full", "f">, Group<2>, Desc<"Give a full " + "description of the watchpoint and its locations.">; + def watchpoint_list_verbose : Option<"verbose", "v">, Group<3>, Desc<"Explain" + "everything we know about the watchpoint (for debugging debugger bugs).">; +} + +let Command = "watchpoint ignore" in { + def watchpoint_ignore_ignore_count : Option<"ignore-count", "i">, + Arg<"Count">, Required, Desc<"Set the number of times this watchpoint is" + " skipped before stopping.">; +} + +let Command = "watchpoint modify" in { + def watchpoint_modify_condition : Option<"condition", "c">, Arg<"Expression">, + Desc<"The watchpoint stops only if this condition expression evaluates " + "to true.">; +} + +let Command = "watchpoint command add" in { + def watchpoint_command_add_one_liner : Option<"one-liner", "o">, Group<1>, + Arg<"OneLiner">, Desc<"Specify a one-line watchpoint command inline. Be " + "sure to surround it with quotes.">; + def watchpoint_command_add_stop_on_error : Option<"stop-on-error", "e">, + Arg<"Boolean">, Desc<"Specify whether watchpoint command execution should " + "terminate on error.">; + def watchpoint_command_add_script_type : Option<"script-type", "s">, + EnumArg<"None", "ScriptOptionEnum()">, Desc<"Specify the language for the" + " commands - if none is specified, the lldb command interpreter will be " + "used.">; + def watchpoint_command_add_python_function : Option<"python-function", "F">, + Group<2>, Arg<"PythonFunction">, Desc<"Give the name of a Python function " + "to run as command for this watchpoint. Be sure to give a module name if " + "appropriate.">; +} diff --git a/source/Commands/OptionsBase.td b/source/Commands/OptionsBase.td new file mode 100644 index 000000000000..a81563ed28c2 --- /dev/null +++ b/source/Commands/OptionsBase.td @@ -0,0 +1,160 @@ + +// The fields below describe how the fields of `OptionDefinition` struct are +// initialized by different definitions in the Options.td and this file. +//////////////////////////////////////////////////////////////////////////////// +// Field: usage_mask +// Default value: LLDB_OPT_SET_ALL (Option allowed in all groups) +// Set by: +// - `Group`: Sets a single group to this option. +// Example: def foo : Option<"foo", "f">, Group<1>; +// - `Groups`: Sets a given list of group numbers. +// Example: def foo : Option<"foo", "f">, Groups<[1,4,6]>; +// - `GroupRange`: Sets an interval of groups. Start and end are inclusive. +// Example: def foo : Option<"foo", "f">, GroupRange<1, 4>; +// Sets group 1, 2, 3, 4 for the option. +//////////////////////////////////////////////////////////////////////////////// +// Field: required +// Default value: false (Not required) +// Set by: +// - `Required`: Marks the option as required. +// Example: def foo : Option<"foo", "f">, Required; +//////////////////////////////////////////////////////////////////////////////// +// Field: long_option +// Default value: not available (has to be defined in Option) +// Set by: +// - `Option` constructor: Already set by constructor. +// Example: def foo : Option<"long-option", "l"> +// ^ +// long option value +//////////////////////////////////////////////////////////////////////////////// +// Field: short_option +// Default value: not available (has to be defined in Option) +// Set by: +// - `Option` constructor: Already set by constructor. +// Example: def foo : Option<"long-option", "l"> +// ^ +// short option +//////////////////////////////////////////////////////////////////////////////// +// Field: option_has_arg +// Default value: OptionParser::eNoArgument (No argument allowed) +// Set by: +// - `OptionalArg`: Sets the argument type and marks it as optional. +// - `Arg`: Sets the argument type and marks it as required. +// - `EnumArg`: Sets the argument type to an enum and marks it as required. +// See argument_type field for more info. +//////////////////////////////////////////////////////////////////////////////// +// Field: validator +// Default value: 0 (No validator for option) +// Set by: Nothing. This is currently only set after initialization in LLDB. +//////////////////////////////////////////////////////////////////////////////// +// Field: enum_values +// Default value: {} (No enum associated with this option) +// Set by: +// - `EnumArg`: Sets the argument type and assigns it a enum holding the valid +// values. The enum needs to be a variable in the including code. +// Marks the option as required (see option_has_arg). +// Example: def foo : Option<"foo", "f">, +// EnumArg<"SortOrder", +// "OptionEnumValues(g_sort_option_enumeration)">; +//////////////////////////////////////////////////////////////////////////////// +// Field: completion_type +// Default value: CommandCompletions::eNoCompletion (no tab completion) +// Set by: +// - `Completion`: Gives the option a single completion kind. +// Example: def foo : Option<"foo", "f">, +// Completion<"DiskFile">; +// Sets the completion to eDiskFileCompletion +// +// - `Completions`: Sets a given kinds of completions. +// Example: def foo : Option<"foo", "f">, +// Completions<["DiskFile", "DiskDirectory"]>; +// Sets the completion to +// `eDiskFileCompletion | eDiskDirectoryCompletion`. +//////////////////////////////////////////////////////////////////////////////// +// Field: argument_type +// Default value: eArgTypeNone +// Set by: +// - `OptionalArg`: Sets the argument type and marks it as optional. +// Example: def foo : Option<"foo", "f">, OptionalArg<"Pid">; +// Sets the argument type to eArgTypePid and marks option as +// optional (see option_has_arg). +// - `Arg`: Sets the argument type and marks it as required. +// Example: def foo : Option<"foo", "f">, Arg<"Pid">; +// Sets the argument type to eArgTypePid and marks option as +// required (see option_has_arg). +// - `EnumArg`: Sets the argument type and assigns it a enum holding the valid +// values. The enum needs to be a variable in the including code. +// Marks the option as required (see option_has_arg). +// Example: def foo : Option<"foo", "f">, +// EnumArg<"SortOrder", +// "OptionEnumValues(g_sort_option_enumeration)">; +//////////////////////////////////////////////////////////////////////////////// +// Field: usage_text +// Default value: "" +// Set by: +// - `Desc`: Sets the description for the given option. +// Example: def foo : Option<"foo", "f">, Desc<"does nothing.">; +// Sets the description to "does nothing.". + +// Base class for all options. +class Option<string fullname, string shortname> { + string FullName = fullname; + string ShortName = shortname; + // The full associated command/subcommand such as "settings set". + string Command; +} + +// Moves the option into a list of option groups. +class Groups<list<int> groups> { + list<int> Groups = groups; +} + +// Moves the option in all option groups in a range. +// Start and end values are inclusive. +class GroupRange<int start, int end> { + int GroupStart = start; + int GroupEnd = end; +} +// Moves the option in a single option group. +class Group<int group> { + int GroupStart = group; + int GroupEnd = group; +} + +// Sets the description for the option that should be +// displayed to the user. +class Desc<string description> { + string Description = description; +} + +// Marks the option as required when calling the +// associated command. +class Required { + bit Required = 1; +} + +// Gives the option an optional argument. +class OptionalArg<string type> { + string ArgType = type; + bit OptionalArg = 1; +} + +// Gives the option an required argument. +class Arg<string type> { + string ArgType = type; +} + +// Gives the option an required argument. +class EnumArg<string type, string enum> { + string ArgType = type; + string ArgEnum = enum; +} + +// Sets the available completions for the given option. +class Completions<list<string> completions> { + list<string> Completions = completions; +} +// Sets a single completion for the given option. +class Completion<string completion> { + list<string> Completions = [completion]; +} |