[Lldb-commits] [lldb] r284439 - Fix a crash in expressions with fixits in the dummy target.

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 17 16:59:42 PDT 2016


Author: jingham
Date: Mon Oct 17 18:59:41 2016
New Revision: 284439

URL: http://llvm.org/viewvc/llvm-project?rev=284439&view=rev
Log:
Fix a crash in expressions with fixits in the dummy target.

In the expression command, if the target is NULL, you have to use the dummy
target.

<rdar://problem/28811687>

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py
    lldb/trunk/source/Commands/CommandObjectExpression.cpp

Modified: lldb/trunk/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py?rev=284439&r1=284438&r2=284439&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py Mon Oct 17 18:59:41 2016
@@ -23,11 +23,18 @@ class ExprCommandWithFixits(TestBase):
         self.main_source_spec = lldb.SBFileSpec(self.main_source)
 
     @skipUnlessDarwin
-    def test(self):
-        """Test calling a function that throws and ObjC exception."""
+    def test_with_target(self):
+        """Test calling expressions with errors that can be fixed by the FixIts."""
         self.build()
         self.try_expressions()
 
+    def test_with_dummy_target(self):
+        """Test calling expressions in the dummy target with errors that can be fixed by the FixIts."""
+        ret_val = lldb.SBCommandReturnObject()
+        result = self.dbg.GetCommandInterpreter().HandleCommand("expression ((1 << 16) - 1))", ret_val)
+        self.assertEqual(result, lldb.eReturnStatusSuccessFinishResult, "The expression was successful.")
+        self.assertTrue("Fix-it applied" in ret_val.GetError(), "Found the applied FixIt.")
+
     def try_expressions(self):
         """Test calling expressions with errors that can be fixed by the FixIts."""
         exe_name = "a.out"

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=284439&r1=284438&r2=284439&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Mon Oct 17 18:59:41 2016
@@ -614,6 +614,9 @@ bool CommandObjectExpression::DoExecute(
   if (EvaluateExpression(expr, &(result.GetOutputStream()),
                          &(result.GetErrorStream()), &result)) {
     Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
+    if (!target)
+        target = GetDummyTarget();
+
     if (!m_fixed_expression.empty() && target->GetEnableNotifyAboutFixIts()) {
       CommandHistory &history = m_interpreter.GetCommandHistory();
       // FIXME: Can we figure out what the user actually typed (e.g. some alias




More information about the lldb-commits mailing list