diff options
Diffstat (limited to 'lldb/source/Interpreter')
| -rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 24 | ||||
| -rw-r--r-- | lldb/source/Interpreter/CommandObjectRegexCommand.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Interpreter/OptionValueBoolean.cpp | 48 | ||||
| -rw-r--r-- | lldb/source/Interpreter/OptionValueEnumeration.cpp | 35 |
4 files changed, 109 insertions, 1 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 05384e4a3e5..6ae9793cbd4 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -59,6 +59,19 @@ using namespace lldb; using namespace lldb_private; + +static PropertyDefinition +g_properties[] = +{ + { "expand-regex-aliases", OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, regular expression alias commands will show the expanded command that will be executed. This can be used to debug new regular expression alias commands." }, + { NULL , OptionValue::eTypeInvalid, true, 0 , NULL, NULL, NULL } +}; + +enum +{ + ePropertyExpandRegexAliases = 0 +}; + ConstString & CommandInterpreter::GetStaticBroadcasterClass () { @@ -73,6 +86,7 @@ CommandInterpreter::CommandInterpreter bool synchronous_execution ) : Broadcaster (&debugger, "lldb.command-interpreter"), + Properties(OptionValuePropertiesSP(new OptionValueProperties(ConstString("interpreter")))), m_debugger (debugger), m_synchronous_execution (synchronous_execution), m_skip_lldbinit_files (false), @@ -89,8 +103,18 @@ CommandInterpreter::CommandInterpreter SetEventName (eBroadcastBitResetPrompt, "reset-prompt"); SetEventName (eBroadcastBitQuitCommandReceived, "quit"); CheckInWithManager (); + m_collection_sp->Initialize (g_properties); } +bool +CommandInterpreter::GetExpandRegexAliases () const +{ + const uint32_t idx = ePropertyExpandRegexAliases; + return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0); +} + + + void CommandInterpreter::Initialize () { diff --git a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp index de6faba4d87..27a67e5e02c 100644 --- a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp +++ b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp @@ -76,7 +76,8 @@ CommandObjectRegexCommand::DoExecute } } // Interpret the new command and return this as the result! - result.GetOutputStream().Printf("%s\n", new_command.c_str()); + if (m_interpreter.GetExpandRegexAliases()) + result.GetOutputStream().Printf("%s\n", new_command.c_str()); return m_interpreter.HandleCommand(new_command.c_str(), eLazyBoolCalculate, result); } } diff --git a/lldb/source/Interpreter/OptionValueBoolean.cpp b/lldb/source/Interpreter/OptionValueBoolean.cpp index 4e6fd62bb69..6471943ee5d 100644 --- a/lldb/source/Interpreter/OptionValueBoolean.cpp +++ b/lldb/source/Interpreter/OptionValueBoolean.cpp @@ -14,6 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Stream.h" +#include "lldb/Core/StringList.h" #include "lldb/Interpreter/Args.h" using namespace lldb; @@ -84,4 +85,51 @@ OptionValueBoolean::DeepCopy () const return OptionValueSP(new OptionValueBoolean(*this)); } +size_t +OptionValueBoolean::AutoComplete (CommandInterpreter &interpreter, + const char *s, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) +{ + word_complete = false; + matches.Clear(); + struct StringEntry { + const char *string; + const size_t length; + }; + static const StringEntry g_autocomplete_entries[] = + { + { "true" , 4 }, + { "false", 5 }, + { "on" , 2 }, + { "off" , 3 }, + { "yes" , 3 }, + { "no" , 2 }, + { "1" , 1 }, + { "0" , 1 }, + }; + const size_t k_num_autocomplete_entries = sizeof(g_autocomplete_entries)/sizeof(StringEntry); + + if (s && s[0]) + { + const size_t s_len = strlen(s); + for (size_t i=0; i<k_num_autocomplete_entries; ++i) + { + if (s_len <= g_autocomplete_entries[i].length) + if (::strncasecmp(s, g_autocomplete_entries[i].string, s_len) == 0) + matches.AppendString(g_autocomplete_entries[i].string); + } + } + else + { + // only suggest "true" or "false" by default + for (size_t i=0; i<2; ++i) + matches.AppendString(g_autocomplete_entries[i].string); + } + return matches.GetSize(); +} + + diff --git a/lldb/source/Interpreter/OptionValueEnumeration.cpp b/lldb/source/Interpreter/OptionValueEnumeration.cpp index 61b184fe0a5..03314172931 100644 --- a/lldb/source/Interpreter/OptionValueEnumeration.cpp +++ b/lldb/source/Interpreter/OptionValueEnumeration.cpp @@ -13,6 +13,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/StringList.h" using namespace lldb; using namespace lldb_private; @@ -129,3 +130,37 @@ OptionValueEnumeration::DeepCopy () const return OptionValueSP(new OptionValueEnumeration(*this)); } +size_t +OptionValueEnumeration::AutoComplete (CommandInterpreter &interpreter, + const char *s, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) +{ + word_complete = false; + matches.Clear(); + + const uint32_t num_enumerators = m_enumerations.GetSize(); + if (s && s[0]) + { + const size_t s_len = strlen(s); + for (size_t i=0; i<num_enumerators; ++i) + { + const char *name = m_enumerations.GetCStringAtIndex(i); + if (::strncmp(s, name, s_len) == 0) + matches.AppendString(name); + } + } + else + { + // only suggest "true" or "false" by default + for (size_t i=0; i<num_enumerators; ++i) + matches.AppendString(m_enumerations.GetCStringAtIndex(i)); + } + return matches.GetSize(); +} + + + + |

