Avoid crashing when funceval does not work
authorIgor Kulaychuk <i.kulaychuk@samsung.com>
Mon, 26 Mar 2018 10:35:02 +0000 (13:35 +0300)
committerIgor Kulaychuk <i.kulaychuk@samsung.com>
Mon, 9 Apr 2018 16:12:11 +0000 (19:12 +0300)
src/debug/netcoredbg/expr.cpp
src/debug/netcoredbg/variables.cpp

index 18930e9c1c90d0d4f8bf774f8e0f572c4fe2c243..52c0422b3d0682776e2ef21212901f2328b78547 100644 (file)
@@ -185,6 +185,9 @@ HRESULT Evaluator::RunClassConstructor(ICorDebugThread *pThread, ICorDebugValue
         IfFailRet(FindFunction(pModule, typeName, getTypeHandleMethodName, &m_pGetTypeHandle));
     }
 
+    if (!m_pRunClassConstructor || !m_pGetTypeHandle)
+        return E_FAIL;
+
     ToRelease<ICorDebugValue> pNewValue;
 
     ToRelease<ICorDebugValue> pUnboxedValue;
index 4f1eff81bc5878c59dd3a29013a81dd565d500c6..df0590159106667b2fd236c60fef9882184b23aa 100644 (file)
@@ -23,6 +23,9 @@ HRESULT Variables::GetNumChild(
     ULONG numstatic = 0;
     ULONG numinstance = 0;
 
+    if (pValue == nullptr)
+        return 0;
+
     IfFailRet(m_evaluator.WalkMembers(pValue, nullptr, nullptr, [&numstatic, &numinstance](
         mdMethodDef,
         ICorDebugModule *,
@@ -360,8 +363,15 @@ HRESULT Variables::GetChildren(
         if (var.name.find('(') == std::string::npos) // expression evaluator does not support typecasts
             var.evaluateName = ref.evaluateName + (isIndex ? "" : ".") + var.name;
         bool escape = true;
-        PrintValue(it.value, var.value, escape);
-        TypePrinter::GetTypeOfValue(it.value, var.type);
+        if (it.value == nullptr)
+        {
+            var.value = "<error>";
+        }
+        else
+        {
+            PrintValue(it.value, var.value, escape);
+            TypePrinter::GetTypeOfValue(it.value, var.type);
+        }
         AddVariableReference(var, ref.frameId, it.value, ValueIsVariable);
         variables.push_back(var);
     }