[Lldb-commits] [lldb] r259189 - Fix crash in lldb-mi when stack variable name is nullptr. This always happens when execution stops in try scope with unnamed catch clause

Eugene Leviant via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 29 04:17:09 PST 2016


Author: evgeny777
Date: Fri Jan 29 06:17:09 2016
New Revision: 259189

URL: http://llvm.org/viewvc/llvm-project?rev=259189&view=rev
Log:
Fix crash in lldb-mi when stack variable name is nullptr. This always happens when execution stops in try scope with unnamed catch clause

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py
    lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp
    lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp

Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py?rev=259189&r1=259188&r2=259189&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py Fri Jan 29 06:17:09 2016
@@ -199,7 +199,20 @@ class MiStackTestCase(lldbmi_testcase.Mi
         self.expect("\^done,locals=\[{name=\"test_str\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]")
         self.runCmd("-stack-list-locals --simple-values")
         self.expect("\^done,locals=\[{name=\"test_str\",type=\"const char \*\",value=\".*?Rakaposhi.*?\"},{name=\"var_e\",type=\"int\",value=\"24\"},{name=\"ptr\",type=\"int \*\",value=\".*?\"}\]")
+        
+        # Test -stack-list-locals in a function with catch clause, 
+        # having unnamed parameter
+        # Run to BP_catch_unnamed
+        line = line_number('main.cpp', '// BP_catch_unnamed')
+        self.runCmd("-break-insert --file main.cpp:%d" % line)
+        self.expect("\^done,bkpt={number=\"6\"")
+        self.runCmd("-exec-continue")
+        self.expect("\^running")
+        self.expect("\*stopped,reason=\"breakpoint-hit\"")
 
+        # Test -stack-list-locals: use --no-values
+        self.runCmd("-stack-list-locals --no-values")
+        self.expect("\^done,locals=\[name=\"i\",name=\"j\"\]")
     @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
     @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
     def test_lldbmi_stack_list_variables(self):

Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp?rev=259189&r1=259188&r2=259189&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp Fri Jan 29 06:17:09 2016
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include <exception>
+
 struct inner
 {
     int var_d;
@@ -114,6 +116,18 @@ int do_tests_with_args()
     return 0;
 }
 
+void catch_unnamed_test()
+{
+    try
+    {
+        int i = 1, j = 2;
+        throw std::exception(); // BP_catch_unnamed
+    }
+    catch(std::exception&)
+    {
+    }
+}
+
 int
 main(int argc, char const *argv[])
 {
@@ -121,6 +135,7 @@ main(int argc, char const *argv[])
     local_struct_test();
     local_array_test();
     local_pointer_test();
+    catch_unnamed_test();
 
     do_tests_with_args();
     return 0;

Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp?rev=259189&r1=259188&r2=259189&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp Fri Jan 29 06:17:09 2016
@@ -452,7 +452,12 @@ CMICmnLLDBDebugSessionInfo::MIResponseFo
     {
         CMICmnMIValueTuple miValueTuple;
         lldb::SBValue value = vwrSBValueList.GetValueAtIndex(i);
-        const CMICmnMIValueConst miValueConst(value.GetName());
+        // If one stops inside try block with, which catch clause type is unnamed 
+        // (e.g std::exception&) then value name will be nullptr as well as value pointer
+        const char* name = value.GetName();
+        if (name == nullptr)
+            continue;
+        const CMICmnMIValueConst miValueConst(name);
         const CMICmnMIValueResult miValueResultName("name", miValueConst);
         if (vbMarkArgs && vbIsArgs)
         {




More information about the lldb-commits mailing list