diff options
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/Commands/CommandObjectBreakpointCommand.cpp | 75 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 9 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectThread.cpp | 22 | ||||
-rw-r--r-- | lldb/source/Core/UserSettingsController.cpp | 9 | ||||
-rw-r--r-- | lldb/source/Interpreter/Args.cpp | 31 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp | 7 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionGroupWatchpoint.cpp | 25 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h | 2 |
9 files changed, 86 insertions, 98 deletions
diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp index 5130a2f86be..942d7ff891c 100644 --- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp @@ -91,45 +91,42 @@ CommandObjectBreakpointCommandAdd::CommandOptions::SetOptionValue char short_option = (char) m_getopt_table[option_idx].val; switch (short_option) - { - case 'o': - m_use_one_liner = true; - m_one_liner = option_arg; - break; - break; - case 's': - { - bool found_one = false; - m_script_language = (lldb::ScriptLanguage) Args::StringToOptionEnum (option_arg, - g_option_table[option_idx].enum_values, - eScriptLanguageNone, - &found_one); - if (!found_one) - error.SetErrorStringWithFormat("Invalid enumeration value '%s' for option '%c'.\n", - option_arg, - short_option); - - if (m_script_language == eScriptLanguagePython || m_script_language == eScriptLanguageDefault) - { - m_use_commands = false; - m_use_script_language = true; - } - else - { - m_use_commands = true; - m_use_script_language = false; - } - } - break; - case 'e': - bool success_ptr; - m_stop_on_error = Args::StringToBoolean(option_arg, false, &success_ptr); - if (!success_ptr) - error.SetErrorStringWithFormat("Invalid value for stop-on-error: \"%s\".\n", option_arg); - break; - default: - break; - } + { + case 'o': + m_use_one_liner = true; + m_one_liner = option_arg; + break; + + case 's': + m_script_language = (lldb::ScriptLanguage) Args::StringToOptionEnum (option_arg, + g_option_table[option_idx].enum_values, + eScriptLanguageNone, + error); + + if (m_script_language == eScriptLanguagePython || m_script_language == eScriptLanguageDefault) + { + m_use_commands = false; + m_use_script_language = true; + } + else + { + m_use_commands = true; + m_use_script_language = false; + } + break; + + case 'e': + { + bool success = false; + m_stop_on_error = Args::StringToBoolean(option_arg, false, &success); + if (!success) + error.SetErrorStringWithFormat("Invalid value for stop-on-error: \"%s\".\n", option_arg); + } + break; + + default: + break; + } return error; } diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index f948d0f5963..2be8e8d951a 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -1876,17 +1876,10 @@ public: switch (short_option) { case 's': - { - bool found_one = false; m_sort_order = (SortOrder) Args::StringToOptionEnum (option_arg, g_option_table[option_idx].enum_values, eSortOrderNone, - &found_one); - if (!found_one) - error.SetErrorStringWithFormat("Invalid enumeration value '%s' for option '%c'.\n", - option_arg, - short_option); - } + error); break; default: diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 8e4ae8d469e..c7bf27622f8 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -307,11 +307,8 @@ public: case 'm': { - bool found_one = false; OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; - m_run_mode = (lldb::RunMode) Args::StringToOptionEnum(option_arg, enum_values, eOnlyDuringStepping, &found_one); - if (!found_one) - error.SetErrorStringWithFormat("Invalid enumeration value for option '%c'.\n", short_option); + m_run_mode = (lldb::RunMode) Args::StringToOptionEnum(option_arg, enum_values, eOnlyDuringStepping, error); } break; @@ -807,17 +804,16 @@ public: break; case 'm': { - bool found_one = false; OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; - lldb::RunMode run_mode = (lldb::RunMode) Args::StringToOptionEnum(option_arg, enum_values, eOnlyDuringStepping, &found_one); + lldb::RunMode run_mode = (lldb::RunMode) Args::StringToOptionEnum(option_arg, enum_values, eOnlyDuringStepping, error); - if (!found_one) - error.SetErrorStringWithFormat("Invalid enumeration value for option '%c'.\n", short_option); - else if (run_mode == eAllThreads) - m_stop_others = false; - else - m_stop_others = true; - + if (error.Success()) + { + if (run_mode == eAllThreads) + m_stop_others = false; + else + m_stop_others = true; + } } break; default: diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp index 332652aa305..a33b9154c78 100644 --- a/lldb/source/Core/UserSettingsController.cpp +++ b/lldb/source/Core/UserSettingsController.cpp @@ -2381,14 +2381,9 @@ void UserSettingsController::UpdateEnumVariable (OptionEnumValueElement *enum_values, int *enum_var, const char *new_value, - Error &err) + Error &error) { - bool found_one; - - *enum_var = Args::StringToOptionEnum (new_value, enum_values, enum_values[0].value, &found_one); - - if (!found_one) - err.SetErrorString ("Invalid enumeration value; cannot update variable.\n"); + *enum_var = Args::StringToOptionEnum (new_value, enum_values, enum_values[0].value, error); } void diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp index 101a1c26a15..7205cb600c8 100644 --- a/lldb/source/Interpreter/Args.cpp +++ b/lldb/source/Interpreter/Args.cpp @@ -834,21 +834,36 @@ Args::StringToVersion (const char *s, uint32_t &major, uint32_t &minor, uint32_t int32_t -Args::StringToOptionEnum (const char *s, OptionEnumValueElement *enum_values, int32_t fail_value, bool *success_ptr) +Args::StringToOptionEnum (const char *s, OptionEnumValueElement *enum_values, int32_t fail_value, Error &error) { - if (enum_values && s && s[0]) + if (enum_values) { - for (int i = 0; enum_values[i].string_value != NULL ; i++) + if (s && s[0]) { - if (strstr(enum_values[i].string_value, s) == enum_values[i].string_value) + for (int i = 0; enum_values[i].string_value != NULL ; i++) { - if (success_ptr) *success_ptr = true; - return enum_values[i].value; + if (strstr(enum_values[i].string_value, s) == enum_values[i].string_value) + { + error.Clear(); + return enum_values[i].value; + } } } + + StreamString strm; + strm.PutCString ("invalid enumeration value, valid values are: "); + for (int i = 0; enum_values[i].string_value != NULL; i++) + { + strm.Printf ("%s\"%s\"", + i > 0 ? ", " : "", + enum_values[i].string_value); + } + error.SetErrorString(strm.GetData()); + } + else + { + error.SetErrorString ("invalid enumeration argument"); } - if (success_ptr) *success_ptr = false; - return fail_value; } diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp index e4c2b6634fa..bda9b688f36 100644 --- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp +++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp @@ -72,12 +72,9 @@ OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter, { case 'd': { - bool success; int32_t result; - result = Args::StringToOptionEnum (option_arg, TargetInstanceSettings::g_dynamic_value_types, 2, &success); - if (!success) - error.SetErrorStringWithFormat("Invalid dynamic value setting: \"%s\".\n", option_arg); - else + result = Args::StringToOptionEnum (option_arg, TargetInstanceSettings::g_dynamic_value_types, 2, error); + if (error.Success()) use_dynamic = (lldb::DynamicValueType) result; } break; diff --git a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp index 076d010ae7e..c1f2182c1b5 100644 --- a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp +++ b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp @@ -64,21 +64,16 @@ OptionGroupWatchpoint::SetOptionValue (CommandInterpreter &interpreter, char short_option = (char) g_option_table[option_idx].short_option; switch (short_option) { - case 'w': { - OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; - watch_type = (WatchType) Args::StringToOptionEnum(option_arg, enum_values, 0, &watch_variable); - if (!watch_variable) - error.SetErrorStringWithFormat("Invalid option arg for '-w': '%s'.\n", option_arg); + case 'w': + watch_type = (WatchType) Args::StringToOptionEnum(option_arg, g_option_table[option_idx].enum_values, 0, error); + if (error.Success()) + watch_variable = true; break; - } - case 'x': { - bool success = false; - OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; - watch_size = (WatchType) Args::StringToOptionEnum(option_arg, enum_values, 0, &success); - if (!success) - error.SetErrorStringWithFormat("Invalid option arg for '-x': '%s'.\n", option_arg); + + case 'x': + watch_size = (WatchType) Args::StringToOptionEnum(option_arg, g_option_table[option_idx].enum_values, 0, error); break; - } + default: error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option); break; @@ -91,8 +86,8 @@ void OptionGroupWatchpoint::OptionParsingStarting (CommandInterpreter &interpreter) { watch_variable = false; - watch_type = eWatchInvalid; - watch_size = 0; + watch_type = eWatchInvalid; + watch_size = 0; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp index d52b2f0739f..8c269b9f2da 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp @@ -119,8 +119,8 @@ DWARFDebugAranges::Dump (Log *log) const const RangeToDIE::Entry *entry = m_aranges.GetEntryAtIndex(i); log->Printf ("0x%8.8x: [0x%llx - 0x%llx)", entry->data, - entry->range.GetBase(), - entry->range.GetEnd()); + entry->GetRangeBase(), + entry->GetRangeEnd()); } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h index c02ea612e11..90dc4fc43c1 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h @@ -20,7 +20,7 @@ class SymbolFileDWARF; class DWARFDebugAranges { protected: - typedef lldb_private::RangeMap<dw_addr_t, uint32_t, dw_offset_t> RangeToDIE; + typedef lldb_private::RangeDataArray<dw_addr_t, uint32_t, dw_offset_t> RangeToDIE; public: typedef RangeToDIE::Entry Range; |