diff options
| author | Johnny Chen <johnny.chen@apple.com> | 2011-07-14 22:20:12 +0000 | 
|---|---|---|
| committer | Johnny Chen <johnny.chen@apple.com> | 2011-07-14 22:20:12 +0000 | 
| commit | 331eff3995c16e2080222b61063122aa9021e404 (patch) | |
| tree | b44363b9e4a7c981b419fd9558acc4253d30df8d | |
| parent | cbd3bb27d7fcfcfbb0e06f8cf6114976d9548ede (diff) | |
| download | bcm5719-llvm-331eff3995c16e2080222b61063122aa9021e404.tar.gz bcm5719-llvm-331eff3995c16e2080222b61063122aa9021e404.zip  | |
Fixed a crasher where entering 'help disasm' on the command line would crash lldb.
The reasom of the crash is because of a missing entry in the argument table corresponding to eArgTypeUnsignedInteger.
Add such entry and modify the call site of the crash to go through a fail-fast API to retrieve the argument table.
Add a regression test to TestHelp.py.
llvm-svn: 135206
| -rw-r--r-- | lldb/source/Interpreter/CommandObject.cpp | 4 | ||||
| -rw-r--r-- | lldb/test/help/TestHelp.py | 5 | 
2 files changed, 8 insertions, 1 deletions
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index b54b4e15a5e..635d9a58838 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -623,8 +623,9 @@ CommandObject::LookupArgumentName (const char *arg_name)          && arg_name[len-1] == '>')          arg_name_str = arg_name_str.substr (1, len-2); +    const ArgumentTableEntry *table = GetArgumentTable();      for (int i = 0; i < eArgTypeLastArg; ++i) -        if (arg_name_str.compare (g_arguments_data[i].arg_name) == 0) +        if (arg_name_str.compare (table[i].arg_name) == 0)              return_type = g_arguments_data[i].arg_type;      return return_type; @@ -778,6 +779,7 @@ CommandObject::g_arguments_data[] =      { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, { NULL, false }, "Thread ID number." },      { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, { NULL, false }, "Index into the process' list of threads." },      { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, { NULL, false }, "The thread's name." }, +    { eArgTypeUnsignedInteger, "unsigned-integer", CommandCompletions::eNoCompletion, { NULL, false }, "An unsigned integer." },      { eArgTypeUnixSignal, "unix-signal", CommandCompletions::eNoCompletion, { NULL, false }, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." },      { eArgTypeVarName, "variable-name", CommandCompletions::eNoCompletion, { NULL, false }, "The name of a variable in your program." },      { eArgTypeValue, "value", CommandCompletions::eNoCompletion, { NULL, false }, "A value could be anything, depending on where and how it is used." }, diff --git a/lldb/test/help/TestHelp.py b/lldb/test/help/TestHelp.py index 999fa40e2fc..2430a2ea098 100644 --- a/lldb/test/help/TestHelp.py +++ b/lldb/test/help/TestHelp.py @@ -61,6 +61,11 @@ class HelpCommandTestCase(TestBase):          self.expect("version",              patterns = ['LLDB-' + (version_str if version_str else '[0-9]+')]) +    def test_help_should_not_crash_lldb(self): +        """Command 'help disasm' should not crash lldb.""" +        self.runCmd("help disasm", check=False) +        self.runCmd("help unsigned-integer") +      def test_help_should_not_hang_emacsshell(self):          """Command 'settings set term-width 0' should not hang the help command."""          self.runCmd("settings set term-width 0")  | 

