diff --git a/docs/design/coreclr/jit/viewing-jit-dumps.md b/docs/design/coreclr/jit/viewing-jit-dumps.md index f24bbb752a9b9c..f5da320507b2c3 100644 --- a/docs/design/coreclr/jit/viewing-jit-dumps.md +++ b/docs/design/coreclr/jit/viewing-jit-dumps.md @@ -172,6 +172,8 @@ Some environment variables such as `DOTNET_JitDisasm` take a list of patterns sp + The simplest method list is a single method name specified using just the method name (no class name), e.g. `Main`. + A list of simple method names can be used, e.g., `Main Test1 Test2`. * The string matched against depends on characters in the pattern: + + If the pattern contains a '!' character, the string matched against is prefixed by the assembly name and an exclamation mark. + - Example: `testassembly!*` - specifies all methods from the assembly named `testassembly`. + If the pattern contains a ':' character, the string matched against is prefixed by the class name and a colon. - Example: `TestClass:Main` - specifies a single method named `Main` in the class named `TestClass`. + If the pattern contains a '(' character, the string matched against is suffixed by the signature. diff --git a/src/coreclr/interpreter/compiler.cpp b/src/coreclr/interpreter/compiler.cpp index 5f6b789b696519..d7fa2a62b10eb4 100644 --- a/src/coreclr/interpreter/compiler.cpp +++ b/src/coreclr/interpreter/compiler.cpp @@ -1199,6 +1199,8 @@ InterpCompiler::InterpCompiler(COMP_HANDLE compHnd, m_classHnd = compHnd->getMethodClass(m_methodHnd); m_methodName = ::PrintMethodName(compHnd, m_classHnd, m_methodHnd, &m_methodInfo->args, + /* includeAssembly */ false, + /* includeClass */ true, /* includeClassInstantiation */ true, /* includeMethodInstantiation */ true, /* includeSignature */ true, @@ -5062,6 +5064,8 @@ void InterpCompiler::PrintMethodName(CORINFO_METHOD_HANDLE method) m_compHnd->getMethodSig(method, &sig, cls); TArray methodName = ::PrintMethodName(m_compHnd, cls, method, &sig, + /* includeAssembly */ false, + /* includeClass */ false, /* includeClassInstantiation */ true, /* includeMethodInstantiation */ true, /* includeSignature */ true, diff --git a/src/coreclr/interpreter/compiler.h b/src/coreclr/interpreter/compiler.h index 47d38f3e1928cb..11d667a1a5fcf1 100644 --- a/src/coreclr/interpreter/compiler.h +++ b/src/coreclr/interpreter/compiler.h @@ -12,6 +12,8 @@ TArray PrintMethodName(COMP_HANDLE comp, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE methHnd, CORINFO_SIG_INFO* sig, + bool includeAssembly, + bool includeClass, bool includeClassInstantiation, bool includeMethodInstantiation, bool includeSignature, diff --git a/src/coreclr/interpreter/interpretershared.h b/src/coreclr/interpreter/interpretershared.h index 851690b33c818f..fe99ccb8ae6bc0 100644 --- a/src/coreclr/interpreter/interpretershared.h +++ b/src/coreclr/interpreter/interpretershared.h @@ -82,6 +82,7 @@ class MethodSet bool m_classNameContainsInstantiation; bool m_methodNameContainsInstantiation; bool m_containsSignature; + bool m_containsAssemblyName; }; const char* m_listFromConfig = nullptr; diff --git a/src/coreclr/interpreter/methodset.cpp b/src/coreclr/interpreter/methodset.cpp index 7858b044ad399d..179e9c6031bc33 100644 --- a/src/coreclr/interpreter/methodset.cpp +++ b/src/coreclr/interpreter/methodset.cpp @@ -40,14 +40,18 @@ void MethodSet::initialize(const char* listFromConfig) name->m_next = m_names; name->m_patternStart = start; name->m_patternEnd = end; - const char* colon = static_cast(memchr(start, ':', end - start)); - const char* startOfMethodName = colon != nullptr ? colon + 1 : start; + const char* exclamation = static_cast(memchr(start, '!', end - start)); + const char* startOfClassName = exclamation != nullptr ? exclamation + 1 : start; + const char* colon = static_cast(memchr(startOfClassName, ':', end - startOfClassName)); + const char* startOfMethodName = colon != nullptr ? colon + 1 : startOfClassName; const char* parens = static_cast(memchr(startOfMethodName, '(', end - startOfMethodName)); const char* endOfMethodName = parens != nullptr ? parens : end; name->m_methodNameContainsInstantiation = memchr(startOfMethodName, '[', endOfMethodName - startOfMethodName) != nullptr; + name->m_containsAssemblyName = (exclamation != nullptr); + if (colon != nullptr) { name->m_containsClassName = true; @@ -156,12 +160,16 @@ bool MethodSet::contains(COMP_HANDLE comp, for (MethodName* name = m_names; name != nullptr; name = name->m_next) { - if ((prevPattern == nullptr) || (name->m_containsClassName != prevPattern->m_containsClassName) || + if ((prevPattern == nullptr) || + (name->m_containsAssemblyName != prevPattern->m_containsAssemblyName) || + (name->m_containsClassName != prevPattern->m_containsClassName) || (name->m_classNameContainsInstantiation != prevPattern->m_classNameContainsInstantiation) || (name->m_methodNameContainsInstantiation != prevPattern->m_methodNameContainsInstantiation) || (name->m_containsSignature != prevPattern->m_containsSignature)) { - printer = PrintMethodName(comp, name->m_containsClassName ? classHnd : NO_CLASS_HANDLE, methodHnd, sigInfo, + printer = PrintMethodName(comp, classHnd, methodHnd, sigInfo, + /* includeAssembly */ name->m_containsAssemblyName, + /* includeClass */ name->m_containsClassName, /* includeClassInstantiation */ name->m_classNameContainsInstantiation, /* includeMethodInstantiation */ name->m_methodNameContainsInstantiation, /* includeSignature */ name->m_containsSignature, diff --git a/src/coreclr/interpreter/naming.cpp b/src/coreclr/interpreter/naming.cpp index 92d4253e593dcb..601a134dceac8f 100644 --- a/src/coreclr/interpreter/naming.cpp +++ b/src/coreclr/interpreter/naming.cpp @@ -7,12 +7,12 @@ void AppendType(COMP_HANDLE comp, TArray* printer, CORINFO_CLASS_HANDLE cl void AppendCorInfoType(TArray* printer, CorInfoType corInfoType); void AppendTypeOrJitAlias(COMP_HANDLE comp, TArray* printer, CORINFO_CLASS_HANDLE clsHnd, bool includeInstantiation); -void AppendString(TArray& array, const char* str) +void AppendString(TArray* array, const char* str) { if (str != nullptr) { size_t strLen = strlen(str); - array.Append(str, static_cast(strLen)); + array->Append(str, static_cast(strLen)); } } @@ -145,6 +145,8 @@ void AppendMethodName(COMP_HANDLE comp, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE methHnd, CORINFO_SIG_INFO* sig, + bool includeAssembly, + bool includeClass, bool includeClassInstantiation, bool includeMethodInstantiation, bool includeSignature, @@ -153,7 +155,14 @@ void AppendMethodName(COMP_HANDLE comp, { TArray result; - if (clsHnd != NO_CLASS_HANDLE) + if (includeAssembly) + { + const char *pAssemblyName = comp->getClassAssemblyName(clsHnd); + AppendString(printer, pAssemblyName); + printer->Add('!'); + } + + if (includeClass) { AppendType(comp, printer, clsHnd, includeClassInstantiation); printer->Add(':'); @@ -268,6 +277,8 @@ TArray PrintMethodName(COMP_HANDLE comp, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE methHnd, CORINFO_SIG_INFO* sig, + bool includeAssembly, + bool includeClass, bool includeClassInstantiation, bool includeMethodInstantiation, bool includeSignature, @@ -276,6 +287,7 @@ TArray PrintMethodName(COMP_HANDLE comp, { TArray printer; AppendMethodName(comp, &printer, clsHnd, methHnd, sig, + includeAssembly, includeClass, includeClassInstantiation, includeMethodInstantiation, includeSignature, includeReturnType, includeThisSpecifier); printer.Add('\0'); // Ensure null-termination diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 7c614f0bb134e9..bdd8945b429724 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -8321,6 +8321,8 @@ class Compiler CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE methodHnd, CORINFO_SIG_INFO* sig, + bool includeAssembly, + bool includeClass, bool includeClassInstantiation, bool includeMethodInstantiation, bool includeSignature, diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp index 3bce6013df008a..a0cd59ed218680 100644 --- a/src/coreclr/jit/eeinterface.cpp +++ b/src/coreclr/jit/eeinterface.cpp @@ -248,9 +248,11 @@ void AppendCorInfoTypeWithModModifiers(StringPrinter* printer, CorInfoTypeWithMo // // Arguments: // printer - the printer -// clsHnd - Handle for the owning class, or NO_CLASS_HANDLE to not print the class. +// clsHnd - Handle for the owning class. // sig - The signature of the method. -// includeClassInstantiation - Whether to print the class instantiation. Only valid when clsHnd is passed. +// includeAssembly - Whether to print the assembly name. +// includeClass - Whether to print the class name. +// includeClassInstantiation - Whether to print the class instantiation. Only valid when includeClass is passed. // includeMethodInstantiation - Whether to print the method instantiation. Requires the signature to be passed. // includeSignature - Whether to print the signature. // includeReturnType - Whether to include the return type at the end. @@ -261,6 +263,8 @@ void Compiler::eePrintMethod(StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE methHnd, CORINFO_SIG_INFO* sig, + bool includeAssembly, + bool includeClass, bool includeClassInstantiation, bool includeMethodInstantiation, bool includeSignature, @@ -275,7 +279,14 @@ void Compiler::eePrintMethod(StringPrinter* printer, return; } - if (clsHnd != NO_CLASS_HANDLE) + if (includeAssembly) + { + const char* pAssemblyName = info.compCompHnd->getClassAssemblyName(clsHnd); + printer->Append(pAssemblyName); + printer->Append('!'); + } + + if (includeClass) { eePrintType(printer, clsHnd, includeClassInstantiation); printer->Append(':'); @@ -432,6 +443,8 @@ const char* Compiler::eeGetMethodFullName( CORINFO_SIG_INFO sig; eeGetMethodSig(hnd, &sig); eePrintMethod(&p, clsHnd, hnd, &sig, + /* includeAssembly */ false, + /* includeClass */ true, /* includeClassInstantiation */ true, /* includeMethodInstantiation */ true, /* includeSignature */ true, includeReturnType, includeThisSpecifier); @@ -448,6 +461,8 @@ const char* Compiler::eeGetMethodFullName( success = eeRunFunctorWithSPMIErrorTrap([&]() { eePrintMethod(&p, clsHnd, hnd, /* sig */ nullptr, + /* includeAssembly */ false, + /* includeClass */ true, /* includeClassInstantiation */ false, /* includeMethodInstantiation */ false, /* includeSignature */ false, @@ -464,8 +479,10 @@ const char* Compiler::eeGetMethodFullName( p.Truncate(0); success = eeRunFunctorWithSPMIErrorTrap([&]() { - eePrintMethod(&p, nullptr, hnd, + eePrintMethod(&p, NO_CLASS_HANDLE, hnd, /* sig */ nullptr, + /* includeAssembly */ false, + /* includeClass */ false, /* includeClassInstantiation */ false, /* includeMethodInstantiation */ false, /* includeSignature */ false, @@ -504,6 +521,8 @@ const char* Compiler::eeGetMethodName(CORINFO_METHOD_HANDLE methHnd, char* buffe bool success = eeRunFunctorWithSPMIErrorTrap([&]() { eePrintMethod(&p, NO_CLASS_HANDLE, methHnd, /* sig */ nullptr, + /* includeAssembly */ false, + /* includeClass */ false, /* includeClassInstantiation */ false, /* includeMethodInstantiation */ false, /* includeSignature */ false, diff --git a/src/coreclr/jit/jitconfig.cpp b/src/coreclr/jit/jitconfig.cpp index e64c861058cd5e..5cbf248d396527 100644 --- a/src/coreclr/jit/jitconfig.cpp +++ b/src/coreclr/jit/jitconfig.cpp @@ -40,14 +40,18 @@ void JitConfigValues::MethodSet::initialize(const char* listFromConfig, ICorJitH name->m_next = m_names; name->m_patternStart = start; name->m_patternEnd = end; - const char* colon = static_cast(memchr(start, ':', end - start)); - const char* startOfMethodName = colon != nullptr ? colon + 1 : start; + const char* exclamation = static_cast(memchr(start, '!', end - start)); + const char* startOfClassName = exclamation != nullptr ? exclamation + 1 : start; + const char* colon = static_cast(memchr(startOfClassName, ':', end - startOfClassName)); + const char* startOfMethodName = colon != nullptr ? colon + 1 : startOfClassName; const char* parens = static_cast(memchr(startOfMethodName, '(', end - startOfMethodName)); const char* endOfMethodName = parens != nullptr ? parens : end; name->m_methodNameContainsInstantiation = memchr(startOfMethodName, '[', endOfMethodName - startOfMethodName) != nullptr; + name->m_containsAssemblyName = (exclamation != nullptr); + if (colon != nullptr) { name->m_containsClassName = true; @@ -164,8 +168,9 @@ bool JitConfigValues::MethodSet::contains(CORINFO_METHOD_HANDLE methodHnd, { printer.Truncate(0); bool success = comp->eeRunFunctorWithSPMIErrorTrap([&]() { - comp->eePrintMethod(&printer, name->m_containsClassName ? classHnd : NO_CLASS_HANDLE, methodHnd, - sigInfo, + comp->eePrintMethod(&printer, classHnd, methodHnd, sigInfo, + /* includeAssembly */ name->m_containsAssemblyName, + /* includeClass */ name->m_containsClassName, /* includeClassInstantiation */ name->m_classNameContainsInstantiation, /* includeMethodInstantiation */ name->m_methodNameContainsInstantiation, /* includeSignature */ name->m_containsSignature, diff --git a/src/coreclr/jit/jitconfig.h b/src/coreclr/jit/jitconfig.h index 0f4e12b87184fd..ed86ff553c7cab 100644 --- a/src/coreclr/jit/jitconfig.h +++ b/src/coreclr/jit/jitconfig.h @@ -22,6 +22,7 @@ class JitConfigValues MethodName* m_next; const char* m_patternStart; const char* m_patternEnd; + bool m_containsAssemblyName; bool m_containsClassName; bool m_classNameContainsInstantiation; bool m_methodNameContainsInstantiation;