From 86f3c0cee4796cfb24548e7dec94eff0d76f8447 Mon Sep 17 00:00:00 2001 From: Igor Kulaychuk Date: Mon, 31 Jul 2017 23:14:17 +0300 Subject: [PATCH] Do not step into overloaded operator methods when JMC is enabled --- src/debug/netcoredbg/jmc.cpp | 65 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/src/debug/netcoredbg/jmc.cpp b/src/debug/netcoredbg/jmc.cpp index 8ff04a8..6799111 100644 --- a/src/debug/netcoredbg/jmc.cpp +++ b/src/debug/netcoredbg/jmc.cpp @@ -3,7 +3,9 @@ #include #include #include +#include +#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 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); -- 2.7.4