Do not step into overloaded operator methods when JMC is enabled
authorIgor Kulaychuk <i.kulaychuk@samsung.com>
Mon, 31 Jul 2017 20:14:17 +0000 (23:14 +0300)
committerIgor Kulaychuk <i.kulaychuk@samsung.com>
Mon, 13 Nov 2017 19:22:40 +0000 (22:22 +0300)
src/debug/netcoredbg/jmc.cpp

index 8ff04a8..6799111 100644 (file)
@@ -3,7 +3,9 @@
 #include <string>
 #include <vector>
 #include <list>
+#include <unordered_set>
 
+#include "cputil.h"
 #include "typeprinter.h"
 #include "platform.h"
 #include "symbolreader.h"
@@ -12,6 +14,58 @@ static const char *g_nonUserCode = "System.Diagnostics.DebuggerNonUserCodeAttrib
 static const char *g_stepThrough = "System.Diagnostics.DebuggerStepThroughAttribute..ctor";
 // TODO: DebuggerStepThroughAttribute also affects breakpoints when JMC is enabled
 
+// From ECMA-335
+static const std::unordered_set<std::string> g_operatorMethodNames
+{
+// Unary operators
+    "op_Decrement",                    // --
+    "op_Increment",                    // ++
+    "op_UnaryNegation",                // - (unary)
+    "op_UnaryPlus",                    // + (unary)
+    "op_LogicalNot",                   // !
+    "op_True",                         // Not defined
+    "op_False",                        // Not defined
+    "op_AddressOf",                    // & (unary)
+    "op_OnesComplement",               // ~
+    "op_PointerDereference",           // * (unary)
+// Binary operators
+    "op_Addition",                     // + (binary)
+    "op_Subtraction",                  // - (binary)
+    "op_Multiply",                     // * (binary)
+    "op_Division",                     // /
+    "op_Modulus",                      // %
+    "op_ExclusiveOr",                  // ^
+    "op_BitwiseAnd",                   // & (binary)
+    "op_BitwiseOr",                    // |
+    "op_LogicalAnd",                   // &&
+    "op_LogicalOr",                    // ||
+    "op_Assign",                       // Not defined (= is not the same)
+    "op_LeftShift",                    // <<
+    "op_RightShift",                   // >>
+    "op_SignedRightShift",             // Not defined
+    "op_UnsignedRightShift",           // Not defined
+    "op_Equality",                     // ==
+    "op_GreaterThan",                  // >
+    "op_LessThan",                     // <
+    "op_Inequality",                   // !=
+    "op_GreaterThanOrEqual",           // >=
+    "op_LessThanOrEqual",              // <=
+    "op_UnsignedRightShiftAssignment", // Not defined
+    "op_MemberSelection",              // ->
+    "op_RightShiftAssignment",         // >>=
+    "op_MultiplicationAssignment",     // *=
+    "op_PointerToMemberSelection",     // ->*
+    "op_SubtractionAssignment",        // -=
+    "op_ExclusiveOrAssignment",        // ^=
+    "op_LeftShiftAssignment",          // <<=
+    "op_ModulusAssignment",            // %=
+    "op_AdditionAssignment",           // +=
+    "op_BitwiseAndAssignment",         // &=
+    "op_BitwiseOrAssignment",          // |=
+    "op_Comma",                        // ,
+    "op_DivisionAssignment"            // /=
+};
+
 bool ShouldLoadSymbolsForModule(const std::string &moduleName)
 {
     std::string name = GetFileName(moduleName);
@@ -85,12 +139,13 @@ static HRESULT GetNonJMCMethodsForTypeDef(
                                      szFunctionName, _countof(szFunctionName), &nameLen,
                                      nullptr, nullptr, nullptr, nullptr, nullptr);
 
-        if (HasAttribute(pMD, methodDef, g_nonUserCode))
-            excludeMethods.push_back(methodDef);
-        else if (HasAttribute(pMD, methodDef, g_stepThrough))
-            excludeMethods.push_back(methodDef);
-        else if (!HasSourceLocation(sr, methodDef))
+        if ((g_operatorMethodNames.find(to_utf8(szFunctionName)) != g_operatorMethodNames.end())
+            || HasAttribute(pMD, methodDef, g_nonUserCode)
+            || HasAttribute(pMD, methodDef, g_stepThrough)
+            || !HasSourceLocation(sr, methodDef))
+        {
             excludeMethods.push_back(methodDef);
+        }
     }
     pMD->CloseEnum(fEnum);