diff options
Diffstat (limited to 'lldb/source/Commands/CommandObjectExpression.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 85 |
1 files changed, 42 insertions, 43 deletions
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 2bacdbbba02..dde97b231e8 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -37,11 +37,9 @@ using namespace lldb; using namespace lldb_private; -CommandObjectExpression::CommandOptions::CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) +CommandObjectExpression::CommandOptions::CommandOptions () : + OptionGroup() { - // Keep only one place to reset the values to their defaults - OptionParsingStarting(); } @@ -49,12 +47,29 @@ CommandObjectExpression::CommandOptions::~CommandOptions () { } +OptionDefinition +CommandObjectExpression::CommandOptions::g_option_table[] = +{ + { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "dynamic-value", 'd', required_argument, NULL, 0, eArgTypeBoolean, "Upcast the value resulting from the expression to its dynamic type if available."}, + { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error", 'u', required_argument, NULL, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, breakpoint hit or signal."}, + { LLDB_OPT_SET_2 , false, "object-description", 'o', no_argument, NULL, 0, eArgTypeNone, "Print the object description of the value resulting from the expression."}, +}; + + +uint32_t +CommandObjectExpression::CommandOptions::GetNumDefinitions () +{ + return sizeof(g_option_table)/sizeof(OptionDefinition); +} + Error -CommandObjectExpression::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) +CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_arg) { Error error; - char short_option = (char) m_getopt_table[option_idx].val; + const char short_option = (char) g_option_table[option_idx].short_option; switch (short_option) { @@ -65,14 +80,6 @@ CommandObjectExpression::CommandOptions::SetOptionValue (uint32_t option_idx, co //} //break; - case 'g': - debug = true; - break; - - case 'f': - error = Args::StringToFormat(option_arg, format, NULL); - break; - case 'o': print_object = true; break; @@ -111,13 +118,10 @@ CommandObjectExpression::CommandOptions::SetOptionValue (uint32_t option_idx, co } void -CommandObjectExpression::CommandOptions::OptionParsingStarting () +CommandObjectExpression::CommandOptions::OptionParsingStarting (CommandInterpreter &interpreter) { - //language.Clear(); - debug = false; - format = eFormatDefault; - print_object = false; use_dynamic = eLazyBoolCalculate; + print_object = false; unwind_on_error = true; show_types = true; show_summary = true; @@ -134,7 +138,9 @@ CommandObjectExpression::CommandObjectExpression (CommandInterpreter &interprete "expression", "Evaluate a C/ObjC/C++ expression in the current program context, using variables currently in scope.", NULL), - m_options (interpreter), + m_option_group (interpreter), + m_format_options (eFormatDefault), + m_command_options (), m_expr_line_count (0), m_expr_lines () { @@ -157,6 +163,11 @@ CommandObjectExpression::CommandObjectExpression (CommandInterpreter &interprete // Push the data for the first argument into the m_arguments vector. m_arguments.push_back (arg); + + // Add the "--format" and "--count" options to group 1 and 3 + m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT, LLDB_OPT_SET_1); + m_option_group.Append (&m_command_options); + m_option_group.Finalize(); } CommandObjectExpression::~CommandObjectExpression () @@ -166,7 +177,7 @@ CommandObjectExpression::~CommandObjectExpression () Options * CommandObjectExpression::GetOptions () { - return &m_options; + return &m_option_group; } @@ -281,7 +292,7 @@ CommandObjectExpression::EvaluateExpression bool keep_in_memory = true; lldb::DynamicValueType use_dynamic; // If use dynamic is not set, get it from the target: - switch (m_options.use_dynamic) + switch (m_command_options.use_dynamic) { case eLazyBoolCalculate: use_dynamic = target->GetPreferDynamicValue(); @@ -297,12 +308,12 @@ CommandObjectExpression::EvaluateExpression exe_results = target->EvaluateExpression (expr, m_exe_ctx.GetFramePtr(), eExecutionPolicyOnlyWhenNeeded, - m_options.unwind_on_error, + m_command_options.unwind_on_error, keep_in_memory, use_dynamic, result_valobj_sp); - if (exe_results == eExecutionInterrupted && !m_options.unwind_on_error) + if (exe_results == eExecutionInterrupted && !m_command_options.unwind_on_error) { uint32_t start_frame = 0; uint32_t num_frames = 1; @@ -334,8 +345,9 @@ CommandObjectExpression::EvaluateExpression { if (result_valobj_sp->GetError().Success()) { - if (m_options.format != eFormatDefault) - result_valobj_sp->SetFormat (m_options.format); + Format format = m_format_options.GetFormat(); + if (format != eFormatDefault) + result_valobj_sp->SetFormat (format); ValueObject::DumpValueObject (*(output_stream), result_valobj_sp.get(), // Variable object to dump @@ -343,9 +355,9 @@ CommandObjectExpression::EvaluateExpression 0, // Pointer depth to traverse (zero means stop at pointers) 0, // Current depth, this is the top most, so zero... UINT32_MAX, // Max depth to go when dumping concrete types, dump everything... - m_options.show_types, // Show types when dumping? + m_command_options.show_types, // Show types when dumping? false, // Show locations of variables, no since this is a host address which we don't care to see - m_options.print_object, // Print the objective C object? + m_command_options.print_object, // Print the objective C object? use_dynamic, true, // Use synthetic children if available true, // Scope is already checked. Const results are always in scope. @@ -406,7 +418,7 @@ CommandObjectExpression::ExecuteRawCommandString { m_exe_ctx = m_interpreter.GetExecutionContext(); - m_options.NotifyOptionParsingStarting(); + m_option_group.NotifyOptionParsingStarting(); const char * expr = NULL; @@ -471,7 +483,7 @@ CommandObjectExpression::ExecuteRawCommandString if (!ParseOptions (args, result)) return false; - Error error (m_options.NotifyOptionParsingFinished()); + Error error (m_option_group.NotifyOptionParsingFinished()); if (error.Fail()) { result.AppendError (error.AsCString()); @@ -491,16 +503,3 @@ CommandObjectExpression::ExecuteRawCommandString return false; } -OptionDefinition -CommandObjectExpression::CommandOptions::g_option_table[] = -{ -//{ LLDB_OPT_SET_ALL, false, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."}, -//{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."}, -{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the expression output should use."}, -{ LLDB_OPT_SET_2, false, "object-description", 'o', no_argument, NULL, 0, eArgTypeNone, "Print the object description of the value resulting from the expression."}, -{ LLDB_OPT_SET_2, false, "dynamic-value", 'd', required_argument, NULL, 0, eArgTypeBoolean, "Upcast the value resulting from the expression to its dynamic type if available."}, -{ LLDB_OPT_SET_ALL, false, "unwind-on-error", 'u', required_argument, NULL, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, breakpoint hit or signal."}, -{ LLDB_OPT_SET_ALL, false, "debug", 'g', no_argument, NULL, 0, eArgTypeNone, "Enable verbose debug logging of the expression parsing and evaluation."}, -{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } -}; - |