Fix lambda variables display
authorIgor Kulaychuk <i.kulaychuk@samsung.com>
Fri, 1 Feb 2019 16:50:13 +0000 (19:50 +0300)
committerIgor Kulaychuk <i.kulaychuk@samsung.com>
Fri, 1 Feb 2019 16:59:06 +0000 (19:59 +0300)
src/debug/netcoredbg/valuewalk.cpp

index 6e4a6244632eea53b572a117f1ec46320c0ec80b..520c0c8c3d7872002c6b049d8d89a7b9ab2a4bff 100644 (file)
@@ -738,6 +738,11 @@ HRESULT Evaluator::WalkMembers(
     return WalkMembers(pValue, pThread, pILFrame, nullptr, cb);
 }
 
+static bool has_prefix(const std::string &s, const std::string &prefix)
+{
+    return prefix.length() <= s.length() && std::equal(prefix.begin(), prefix.end(), s.begin());
+}
+
 HRESULT Evaluator::HandleSpecialLocalVar(
     const std::string &localName,
     ICorDebugValue *pLocalValue,
@@ -749,7 +754,7 @@ HRESULT Evaluator::HandleSpecialLocalVar(
 
     HRESULT Status;
 
-    if (captureName != localName)
+    if (!has_prefix(localName, captureName))
         return S_FALSE;
 
     // Substitute local value with its fields
@@ -763,11 +768,11 @@ HRESULT Evaluator::HandleSpecialLocalVar(
     {
         if (is_static)
             return S_OK;
-        if (captureName == name)
+        if (has_prefix(name, captureName))
             return S_OK;
         if (!locals.insert(name).second)
             return S_OK; // already in the list
-        return cb(pILFrame, pValue, name);
+        return cb(pILFrame, pValue, name.empty() ? "this" : name);
     }));
 
     return S_OK;
@@ -780,7 +785,6 @@ HRESULT Evaluator::HandleSpecialThisParam(
     WalkStackVarsCallback cb)
 {
     static const std::string displayClass = "<>c__DisplayClass";
-    static const std::string hideClass = "<>c";
 
     HRESULT Status;
 
@@ -793,12 +797,9 @@ HRESULT Evaluator::HandleSpecialThisParam(
 
     typeName = typeName.substr(start + 1);
 
-    if (hideClass != typeName)
+    if (!has_prefix(typeName, displayClass))
         return S_FALSE;
 
-    if (displayClass != typeName)
-        return S_OK; // just do not show this value
-
     // Substitute this with its fields
     IfFailRet(WalkMembers(pThisValue, nullptr, pILFrame, [&](
         mdMethodDef,