diff options
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp')
-rw-r--r-- | contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp | 169 |
1 files changed, 72 insertions, 97 deletions
diff --git a/contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp b/contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp index 9477b50..cd436df 100644 --- a/contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp +++ b/contrib/llvm/tools/lldb/source/Commands/CommandObjectFrame.cpp @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// -#include "CommandObjectFrame.h" - // C Includes // C++ Includes #include <string> + // Other libraries and framework includes // Project includes +#include "CommandObjectFrame.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" @@ -58,22 +58,15 @@ using namespace lldb_private; class CommandObjectFrameInfo : public CommandObjectParsed { public: - - CommandObjectFrameInfo (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "frame info", - "List information about the currently selected frame in the current thread.", - "frame info", - eCommandRequiresFrame | - eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused ) + CommandObjectFrameInfo(CommandInterpreter &interpreter) + : CommandObjectParsed(interpreter, "frame info", + "List information about the current stack frame in the current thread.", "frame info", + eCommandRequiresFrame | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused) { } - ~CommandObjectFrameInfo () override - { - } + ~CommandObjectFrameInfo() override = default; protected: bool @@ -94,20 +87,16 @@ protected: class CommandObjectFrameSelect : public CommandObjectParsed { public: - - class CommandOptions : public Options + class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { OptionParsingStarting (); } - ~CommandOptions () override - { - } + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -148,17 +137,14 @@ public: static OptionDefinition g_option_table[]; int32_t relative_frame_offset; }; - - CommandObjectFrameSelect (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "frame select", - "Select a frame by index from within the current thread and make it the current frame.", - NULL, - eCommandRequiresThread | - eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused ), - m_options (interpreter) + + CommandObjectFrameSelect(CommandInterpreter &interpreter) + : CommandObjectParsed( + interpreter, "frame select", + "Select the current stack frame by index from within the current thread (see 'thread backtrace'.)", + nullptr, eCommandRequiresThread | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused), + m_options(interpreter) { CommandArgumentEntry arg; CommandArgumentData index_arg; @@ -174,9 +160,7 @@ public: m_arguments.push_back (arg); } - ~CommandObjectFrameSelect () override - { - } + ~CommandObjectFrameSelect() override = default; Options * GetOptions () override @@ -184,7 +168,6 @@ public: return &m_options; } - protected: bool DoExecute (Args& command, CommandReturnObject &result) override @@ -209,7 +192,7 @@ protected: if (frame_idx == 0) { //If you are already at the bottom of the stack, then just warn and don't reset the frame. - result.AppendError("Already at the bottom of the stack"); + result.AppendError("Already at the bottom of the stack."); result.SetStatus(eReturnStatusFailed); return false; } @@ -229,7 +212,7 @@ protected: if (frame_idx == num_frames - 1) { //If we are already at the top of the stack, just warn and don't reset the frame. - result.AppendError("Already at the top of the stack"); + result.AppendError("Already at the top of the stack."); result.SetStatus(eReturnStatusFailed); return false; } @@ -247,7 +230,7 @@ protected: frame_idx = StringConvert::ToUInt32 (frame_idx_cstr, UINT32_MAX, 0, &success); if (!success) { - result.AppendErrorWithFormat ("invalid frame index argument '%s'", frame_idx_cstr); + result.AppendErrorWithFormat("invalid frame index argument '%s'.", frame_idx_cstr); result.SetStatus (eReturnStatusFailed); return false; } @@ -283,16 +266,16 @@ protected: return result.Succeeded(); } -protected: +protected: CommandOptions m_options; }; OptionDefinition CommandObjectFrameSelect::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "relative", 'r', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOffset, "A relative frame index offset from the current frame index."}, -{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } + { LLDB_OPT_SET_1, false, "relative", 'r', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOffset, "A relative frame index offset from the current frame index."}, + { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; #pragma mark CommandObjectFrameVariable @@ -302,26 +285,19 @@ CommandObjectFrameSelect::CommandOptions::g_option_table[] = class CommandObjectFrameVariable : public CommandObjectParsed { public: - - CommandObjectFrameVariable (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "frame variable", - "Show frame variables. All argument and local variables " - "that are in scope will be shown when no arguments are given. " - "If any arguments are specified, they can be names of " - "argument, local, file static and file global variables. " - "Children of aggregate variables can be specified such as " - "'var->child.x'.", - NULL, - eCommandRequiresFrame | - eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused | - eCommandRequiresProcess), - m_option_group (interpreter), - m_option_variable(true), // Include the frame specific options by passing "true" - m_option_format (eFormatDefault), - m_varobj_options() + CommandObjectFrameVariable(CommandInterpreter &interpreter) + : CommandObjectParsed( + interpreter, "frame variable", "Show variables for the current stack frame. Defaults to all " + "arguments and local variables in scope. Names of argument, " + "local, file static and file global variables can be specified. " + "Children of aggregate variables can be specified such as " + "'var->child.x'.", + nullptr, eCommandRequiresFrame | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | + eCommandProcessMustBePaused | eCommandRequiresProcess), + m_option_group(interpreter), + m_option_variable(true), // Include the frame specific options by passing "true" + m_option_format(eFormatDefault), + m_varobj_options() { CommandArgumentEntry arg; CommandArgumentData var_name_arg; @@ -342,9 +318,7 @@ public: m_option_group.Finalize(); } - ~CommandObjectFrameVariable () override - { - } + ~CommandObjectFrameVariable() override = default; Options * GetOptions () override @@ -352,7 +326,6 @@ public: return &m_option_group; } - int HandleArgumentCompletion (Args &input, int &cursor_index, @@ -367,14 +340,14 @@ public: std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, - CommandCompletions::eVariablePathCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::eVariablePathCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + nullptr, + word_complete, + matches); return matches.GetSize(); } @@ -387,17 +360,15 @@ protected: Stream &s = result.GetOutputStream(); - bool get_file_globals = true; - // Be careful about the stack frame, if any summary formatter runs code, it might clear the StackFrameList // for the thread. So hold onto a shared pointer to the frame so it stays alive. - VariableList *variable_list = frame->GetVariableList (get_file_globals); + VariableList *variable_list = frame->GetVariableList (m_option_variable.show_globals); VariableSP var_sp; ValueObjectSP valobj_sp; - const char *name_cstr = NULL; + const char *name_cstr = nullptr; size_t idx; TypeSummaryImplSP summary_format_sp; @@ -423,7 +394,7 @@ protected: // If we have any args to the variable command, we will make // variable objects from them... - for (idx = 0; (name_cstr = command.GetArgumentAtIndex(idx)) != NULL; ++idx) + for (idx = 0; (name_cstr = command.GetArgumentAtIndex(idx)) != nullptr; ++idx) { if (m_option_variable.use_regex) { @@ -502,16 +473,18 @@ protected: options.SetVariableFormatDisplayLanguage(valobj_sp->GetPreferredDisplayLanguage()); Stream &output_stream = result.GetOutputStream(); - options.SetRootValueObjectName(valobj_sp->GetParent() ? name_cstr : NULL); + options.SetRootValueObjectName(valobj_sp->GetParent() ? name_cstr : nullptr); valobj_sp->Dump(output_stream,options); } else { - const char *error_cstr = error.AsCString(NULL); + const char *error_cstr = error.AsCString(nullptr); if (error_cstr) result.GetErrorStream().Printf("error: %s\n", error_cstr); else - result.GetErrorStream().Printf ("error: unable to find any variable expression path that matches '%s'\n", name_cstr); + result.GetErrorStream().Printf( + "error: unable to find any variable expression path that matches '%s'.\n", + name_cstr); } } } @@ -529,13 +502,16 @@ protected: switch (var_sp->GetScope()) { case eValueTypeVariableGlobal: - dump_variable = m_option_variable.show_globals; + // Always dump globals since we only fetched them if + // m_option_variable.show_scope was true if (dump_variable && m_option_variable.show_scope) scope_string = "GLOBAL: "; break; case eValueTypeVariableStatic: - dump_variable = m_option_variable.show_globals; + // Always dump globals since we only fetched them if + // m_option_variable.show_scope was true, or this is + // a static variable from a block in the current scope if (dump_variable && m_option_variable.show_scope) scope_string = "STATIC: "; break; @@ -552,6 +528,10 @@ protected: scope_string = " LOCAL: "; break; + case eValueTypeVariableThreadLocal: + if (dump_variable && m_option_variable.show_scope) + scope_string = "THREAD: "; + break; default: break; } @@ -572,8 +552,8 @@ protected: // that are not in scope to avoid extra unneeded output if (valobj_sp->IsInScope ()) { - if (false == valobj_sp->GetTargetSP()->GetDisplayRuntimeSupportValues() && - true == valobj_sp->IsRuntimeSupportValue()) + if (!valobj_sp->GetTargetSP()->GetDisplayRuntimeSupportValues() && + valobj_sp->IsRuntimeSupportValue()) continue; if (!scope_string.empty()) @@ -607,33 +587,28 @@ protected: return result.Succeeded(); } -protected: +protected: OptionGroupOptions m_option_group; OptionGroupVariable m_option_variable; OptionGroupFormat m_option_format; OptionGroupValueObjectDisplay m_varobj_options; }; - #pragma mark CommandObjectMultiwordFrame //------------------------------------------------------------------------- // CommandObjectMultiwordFrame //------------------------------------------------------------------------- -CommandObjectMultiwordFrame::CommandObjectMultiwordFrame (CommandInterpreter &interpreter) : - CommandObjectMultiword (interpreter, - "frame", - "A set of commands for operating on the current thread's frames.", - "frame <subcommand> [<subcommand-options>]") +CommandObjectMultiwordFrame::CommandObjectMultiwordFrame(CommandInterpreter &interpreter) + : CommandObjectMultiword(interpreter, "frame", + "Commands for selecting and examing the current thread's stack frames.", + "frame <subcommand> [<subcommand-options>]") { LoadSubCommand ("info", CommandObjectSP (new CommandObjectFrameInfo (interpreter))); LoadSubCommand ("select", CommandObjectSP (new CommandObjectFrameSelect (interpreter))); LoadSubCommand ("variable", CommandObjectSP (new CommandObjectFrameVariable (interpreter))); } -CommandObjectMultiwordFrame::~CommandObjectMultiwordFrame () -{ -} - +CommandObjectMultiwordFrame::~CommandObjectMultiwordFrame() = default; |