diff options
Diffstat (limited to 'lldb/source/Commands/CommandObjectFrame.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectFrame.cpp | 130 |
1 files changed, 23 insertions, 107 deletions
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 33e735ac81d..d184e0038d4 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -26,6 +26,7 @@ #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/Options.h" #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" +#include "lldb/Interpreter/OptionGroupVariable.h" #include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ObjectFile.h" @@ -378,7 +379,7 @@ public: NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused), m_option_group (interpreter), - m_frame_var_options(), + m_option_variable(true), // Include the frame specific options by passing "true" m_varobj_options() { CommandArgumentEntry arg; @@ -394,7 +395,7 @@ public: // Push the data for the first argument into the m_arguments vector. m_arguments.push_back (arg); - m_option_group.Append (&m_frame_var_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); + m_option_group.Append (&m_option_variable, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); m_option_group.Finalize(); } @@ -438,73 +439,8 @@ public: const char *name_cstr = NULL; size_t idx; - if (!m_frame_var_options.globals.empty()) - { - uint32_t fail_count = 0; - if (exe_ctx.target) - { - const size_t num_globals = m_frame_var_options.globals.size(); - for (idx = 0; idx < num_globals; ++idx) - { - VariableList global_var_list; - const uint32_t num_matching_globals - = exe_ctx.target->GetImages().FindGlobalVariables (m_frame_var_options.globals[idx], - true, - UINT32_MAX, - global_var_list); - - if (num_matching_globals == 0) - { - ++fail_count; - result.GetErrorStream().Printf ("error: can't find global variable '%s'\n", - m_frame_var_options.globals[idx].AsCString()); - } - else - { - for (uint32_t global_idx=0; global_idx<num_matching_globals; ++global_idx) - { - var_sp = global_var_list.GetVariableAtIndex(global_idx); - if (var_sp) - { - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, - m_varobj_options.use_dynamic); - if (!valobj_sp) - valobj_sp = exe_ctx.frame->TrackGlobalVariable (var_sp, - m_varobj_options.use_dynamic); - - if (valobj_sp) - { - if (m_frame_var_options.format != eFormatDefault) - valobj_sp->SetFormat (m_frame_var_options.format); - if (m_frame_var_options.show_decl && var_sp->GetDeclaration ().GetFile()) - { - var_sp->GetDeclaration ().DumpStopContext (&s, false); - s.PutCString (": "); - } - - ValueObject::DumpValueObject (result.GetOutputStream(), - valobj_sp.get(), - name_cstr, - m_varobj_options.ptr_depth, - 0, - m_varobj_options.max_depth, - m_varobj_options.show_types, - m_varobj_options.show_location, - m_varobj_options.use_objc, - m_varobj_options.use_dynamic, - false, - m_varobj_options.flat_output); - } - } - } - } - } - } - if (fail_count) - result.SetStatus (eReturnStatusFailed); - } - else if (variable_list) + if (variable_list) { if (command.GetArgumentCount() > 0) { @@ -516,7 +452,7 @@ public: { uint32_t ptr_depth = m_varobj_options.ptr_depth; - if (m_frame_var_options.use_regex) + if (m_option_variable.use_regex) { const uint32_t regex_start_index = regex_var_list.GetSize(); RegularExpression regex (name_cstr); @@ -538,10 +474,10 @@ public: valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic); if (valobj_sp) { - if (m_frame_var_options.format != eFormatDefault) - valobj_sp->SetFormat (m_frame_var_options.format); + if (m_option_variable.format != eFormatDefault) + valobj_sp->SetFormat (m_option_variable.format); - if (m_frame_var_options.show_decl && var_sp->GetDeclaration ().GetFile()) + if (m_option_variable.show_decl && var_sp->GetDeclaration ().GetFile()) { var_sp->GetDeclaration ().DumpStopContext (&s, false); s.PutCString (": "); @@ -589,9 +525,9 @@ public: error); if (valobj_sp) { - if (m_frame_var_options.format != eFormatDefault) - valobj_sp->SetFormat (m_frame_var_options.format); - if (m_frame_var_options.show_decl && var_sp && var_sp->GetDeclaration ().GetFile()) + if (m_option_variable.format != eFormatDefault) + valobj_sp->SetFormat (m_option_variable.format); + if (m_option_variable.show_decl && var_sp && var_sp->GetDeclaration ().GetFile()) { var_sp->GetDeclaration ().DumpStopContext (&s, false); s.PutCString (": "); @@ -635,26 +571,26 @@ public: switch (var_sp->GetScope()) { case eValueTypeVariableGlobal: - dump_variable = m_frame_var_options.show_globals; - if (dump_variable && m_frame_var_options.show_scope) + dump_variable = m_option_variable.show_globals; + if (dump_variable && m_option_variable.show_scope) s.PutCString("GLOBAL: "); break; case eValueTypeVariableStatic: - dump_variable = m_frame_var_options.show_globals; - if (dump_variable && m_frame_var_options.show_scope) + dump_variable = m_option_variable.show_globals; + if (dump_variable && m_option_variable.show_scope) s.PutCString("STATIC: "); break; case eValueTypeVariableArgument: - dump_variable = m_frame_var_options.show_args; - if (dump_variable && m_frame_var_options.show_scope) + dump_variable = m_option_variable.show_args; + if (dump_variable && m_option_variable.show_scope) s.PutCString(" ARG: "); break; case eValueTypeVariableLocal: - dump_variable = m_frame_var_options.show_locals; - if (dump_variable && m_frame_var_options.show_scope) + dump_variable = m_option_variable.show_locals; + if (dump_variable && m_option_variable.show_scope) s.PutCString(" LOCAL: "); break; @@ -672,14 +608,14 @@ public: m_varobj_options.use_dynamic); if (valobj_sp) { - if (m_frame_var_options.format != eFormatDefault) - valobj_sp->SetFormat (m_frame_var_options.format); + if (m_option_variable.format != eFormatDefault) + valobj_sp->SetFormat (m_option_variable.format); // When dumping all variables, don't print any variables // that are not in scope to avoid extra unneeded output if (valobj_sp->IsInScope ()) { - if (m_frame_var_options.show_decl && var_sp->GetDeclaration ().GetFile()) + if (m_option_variable.show_decl && var_sp->GetDeclaration ().GetFile()) { var_sp->GetDeclaration ().DumpStopContext (&s, false); s.PutCString (": "); @@ -710,30 +646,10 @@ public: protected: OptionGroupOptions m_option_group; - OptionGroupFrameVariable m_frame_var_options; + OptionGroupVariable m_option_variable; OptionGroupValueObjectDisplay m_varobj_options; }; -OptionDefinition -CommandObjectFrameVariable::OptionGroupFrameVariable::g_option_table[] = -{ -{ LLDB_OPT_SET_1, false, "no-args", 'a', no_argument, NULL, 0, eArgTypeNone, "Omit function arguments."}, -{ LLDB_OPT_SET_1, false, "show-declaration",'c', no_argument, NULL, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."}, -{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the variable output should use."}, -{ LLDB_OPT_SET_1, false, "show-globals", 'g', no_argument, NULL, 0, eArgTypeNone, "Show the current frame source file global and static variables."}, -{ LLDB_OPT_SET_1, false, "find-global", 'G', required_argument, NULL, 0, eArgTypeVarName, "Find a global variable by name (which might not be in the current stack frame source file)."}, -{ LLDB_OPT_SET_1, false, "no-locals", 'l', no_argument, NULL, 0, eArgTypeNone, "Omit local variables."}, -{ LLDB_OPT_SET_1, false, "regex", 'r', no_argument, NULL, 0, eArgTypeRegularExpression, "The <variable-name> argument for name lookups are regular expressions."}, -{ LLDB_OPT_SET_1, false, "scope", 's', no_argument, NULL, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."}, -{ 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } -}; - -uint32_t -CommandObjectFrameVariable::OptionGroupFrameVariable::GetNumDefinitions () -{ - return sizeof(CommandObjectFrameVariable::OptionGroupFrameVariable::g_option_table)/sizeof(OptionDefinition); -} - #pragma mark CommandObjectMultiwordFrame |