This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG754ab803b8dc: [lldb] Use current execution context in SBDebugger (authored by werat, committed by teemperor).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D95761/new/ https://reviews.llvm.org/D95761 Files: lldb/source/API/SBDebugger.cpp lldb/test/API/python_api/debugger/TestDebuggerAPI.py Index: lldb/test/API/python_api/debugger/TestDebuggerAPI.py =================================================================== --- lldb/test/API/python_api/debugger/TestDebuggerAPI.py +++ lldb/test/API/python_api/debugger/TestDebuggerAPI.py @@ -43,3 +43,35 @@ target = lldb.SBTarget() self.assertFalse(target.IsValid()) self.dbg.DeleteTarget(target) + + @add_test_categories(['pyapi']) + def test_debugger_internal_variables(self): + debugger_name = self.dbg.GetInstanceName() + + # Set a variable and check it was written successfully. + error = lldb.SBDebugger.SetInternalVariable( + 'target.prefer-dynamic-value', 'no-dynamic-values', debugger_name) + self.assertTrue(error.Success()) + ret = lldb.SBDebugger.GetInternalVariableValue( + 'target.prefer-dynamic-value', debugger_name) + self.assertEqual(ret.GetSize(), 1) + self.assertEqual(ret.GetStringAtIndex(0), 'no-dynamic-values') + + # Set a variable with a different value. + error = lldb.SBDebugger.SetInternalVariable( + 'target.prefer-dynamic-value', 'no-run-target', debugger_name) + self.assertTrue(error.Success()) + ret = lldb.SBDebugger.GetInternalVariableValue( + 'target.prefer-dynamic-value', debugger_name) + self.assertEqual(ret.GetSize(), 1) + self.assertEqual(ret.GetStringAtIndex(0), 'no-run-target') + + # Try setting invalid value, check for error. + error = lldb.SBDebugger.SetInternalVariable( + 'target.prefer-dynamic-value', 'dummy-value', debugger_name) + self.assertTrue(error.Fail()) + # Check that the value didn't change. + ret = lldb.SBDebugger.GetInternalVariableValue( + 'target.prefer-dynamic-value', debugger_name) + self.assertEqual(ret.GetSize(), 1) + self.assertEqual(ret.GetStringAtIndex(0), 'no-run-target') Index: lldb/source/API/SBDebugger.cpp =================================================================== --- lldb/source/API/SBDebugger.cpp +++ lldb/source/API/SBDebugger.cpp @@ -1278,8 +1278,7 @@ ConstString(debugger_instance_name))); Status error; if (debugger_sp) { - ExecutionContext exe_ctx( - debugger_sp->GetCommandInterpreter().GetExecutionContext()); + ExecutionContext exe_ctx(debugger_sp->GetSelectedExecutionContext()); error = debugger_sp->SetPropertyValue(&exe_ctx, eVarSetOperationAssign, var_name, value); } else { @@ -1303,8 +1302,7 @@ ConstString(debugger_instance_name))); Status error; if (debugger_sp) { - ExecutionContext exe_ctx( - debugger_sp->GetCommandInterpreter().GetExecutionContext()); + ExecutionContext exe_ctx(debugger_sp->GetSelectedExecutionContext()); lldb::OptionValueSP value_sp( debugger_sp->GetPropertyValue(&exe_ctx, var_name, false, error)); if (value_sp) {
Index: lldb/test/API/python_api/debugger/TestDebuggerAPI.py =================================================================== --- lldb/test/API/python_api/debugger/TestDebuggerAPI.py +++ lldb/test/API/python_api/debugger/TestDebuggerAPI.py @@ -43,3 +43,35 @@ target = lldb.SBTarget() self.assertFalse(target.IsValid()) self.dbg.DeleteTarget(target) + + @add_test_categories(['pyapi']) + def test_debugger_internal_variables(self): + debugger_name = self.dbg.GetInstanceName() + + # Set a variable and check it was written successfully. + error = lldb.SBDebugger.SetInternalVariable( + 'target.prefer-dynamic-value', 'no-dynamic-values', debugger_name) + self.assertTrue(error.Success()) + ret = lldb.SBDebugger.GetInternalVariableValue( + 'target.prefer-dynamic-value', debugger_name) + self.assertEqual(ret.GetSize(), 1) + self.assertEqual(ret.GetStringAtIndex(0), 'no-dynamic-values') + + # Set a variable with a different value. + error = lldb.SBDebugger.SetInternalVariable( + 'target.prefer-dynamic-value', 'no-run-target', debugger_name) + self.assertTrue(error.Success()) + ret = lldb.SBDebugger.GetInternalVariableValue( + 'target.prefer-dynamic-value', debugger_name) + self.assertEqual(ret.GetSize(), 1) + self.assertEqual(ret.GetStringAtIndex(0), 'no-run-target') + + # Try setting invalid value, check for error. + error = lldb.SBDebugger.SetInternalVariable( + 'target.prefer-dynamic-value', 'dummy-value', debugger_name) + self.assertTrue(error.Fail()) + # Check that the value didn't change. + ret = lldb.SBDebugger.GetInternalVariableValue( + 'target.prefer-dynamic-value', debugger_name) + self.assertEqual(ret.GetSize(), 1) + self.assertEqual(ret.GetStringAtIndex(0), 'no-run-target') Index: lldb/source/API/SBDebugger.cpp =================================================================== --- lldb/source/API/SBDebugger.cpp +++ lldb/source/API/SBDebugger.cpp @@ -1278,8 +1278,7 @@ ConstString(debugger_instance_name))); Status error; if (debugger_sp) { - ExecutionContext exe_ctx( - debugger_sp->GetCommandInterpreter().GetExecutionContext()); + ExecutionContext exe_ctx(debugger_sp->GetSelectedExecutionContext()); error = debugger_sp->SetPropertyValue(&exe_ctx, eVarSetOperationAssign, var_name, value); } else { @@ -1303,8 +1302,7 @@ ConstString(debugger_instance_name))); Status error; if (debugger_sp) { - ExecutionContext exe_ctx( - debugger_sp->GetCommandInterpreter().GetExecutionContext()); + ExecutionContext exe_ctx(debugger_sp->GetSelectedExecutionContext()); lldb::OptionValueSP value_sp( debugger_sp->GetPropertyValue(&exe_ctx, var_name, false, error)); if (value_sp) {
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits