diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj index 5ac4d2d78b58e..e77a87c666571 100644 --- a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -302,11 +302,6 @@ - - - - - @@ -317,15 +312,15 @@ - - src\System\Diagnostics\Eventing\Generated\NativeRuntimeEventSource.CoreCLR.cs + + src\System\Diagnostics\Eventing\NativeRuntimeEventSource.Generated.cs - + <_PythonWarningParameter>-Wall <_PythonWarningParameter Condition="'$(MSBuildTreatWarningsAsErrors)' == 'true'">$(_PythonWarningParameter) -Werror diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj index 8cb3c82645e69..fc97632716fd2 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj @@ -571,8 +571,35 @@ + - - + + + + + src\System\Diagnostics\Eventing\NativeRuntimeEventSource.Generated.cs + + + + + + + + <_PythonWarningParameter>-Wall + <_PythonWarningParameter Condition="'$(MSBuildTreatWarningsAsErrors)' == 'true'">$(_PythonWarningParameter) -Werror + <_EventingSourceFileDirectory>%(EventingSourceFile.RootDir)%(EventingSourceFile.Directory) + <_EventingSourceFileDirectory Condition="HasTrailingSlash('$(_EventingSourceFileDirectory)')">$(_EventingSourceFileDirectory.TrimEnd('\')) + + + + + + + + diff --git a/src/coreclr/scripts/genRuntimeEventSources.py b/src/coreclr/scripts/genRuntimeEventSources.py index 5fcfbc0476f11..ed13eeec7238e 100644 --- a/src/coreclr/scripts/genRuntimeEventSources.py +++ b/src/coreclr/scripts/genRuntimeEventSources.py @@ -5,8 +5,7 @@ import os import xml.dom.minidom as DOM -from utilities import open_for_update -from genEventing import RuntimeFlavor +from utilities import open_for_update, parseInclusionList import argparse import sys @@ -24,12 +23,8 @@ ######################################################################## # START CONFIGURATION ######################################################################## -coreCLRManifestsToGenerate = { - "Microsoft-Windows-DotNETRuntime" : "NativeRuntimeEventSource.CoreCLR.cs" -} - -monoManifestsToGenerate = { - "Microsoft-Windows-DotNETRuntime" : "NativeRuntimeEventSource.Mono.cs" +manifestsToGenerate = { + "Microsoft-Windows-DotNETRuntime" : "NativeRuntimeEventSource.Generated.cs" } providerNameToClassNameMap = { @@ -77,11 +72,22 @@ def writeOutput(outputFile, str): def getCSharpTypeFromManifestType(manifestType): return manifestTypeToCSharpTypeMap[manifestType] -def getManifestsToGenerate(runtimeFlavor): - if runtimeFlavor.coreclr: - return coreCLRManifestsToGenerate - elif runtimeFlavor.mono: - return monoManifestsToGenerate +def getManifestsToGenerate(): + return manifestsToGenerate + +def includeEvent(inclusionList, providerName, eventName): + if len(inclusionList) == 0: + return True + if providerName in inclusionList and eventName in inclusionList[providerName]: + return True + elif providerName in inclusionList and "*" in inclusionList[providerName]: + return True + elif "*" in inclusionList and eventName in inclusionList["*"]: + return True + elif "*" in inclusionList and "*" in inclusionList["*"]: + return True + else: + return False def generateEvent(eventNode, providerNode, outputFile, stringTable): @@ -174,7 +180,9 @@ def generateEvent(eventNode, providerNode, outputFile, stringTable): writeOutput(outputFile, "}\n\n") -def generateEvents(providerNode, outputFile, stringTable): +def generateEvents(providerNode, outputFile, stringTable, inclusion_list): + + providerName = providerNode.getAttribute("name") # Get the events element. for node in providerNode.getElementsByTagName("events"): @@ -188,6 +196,10 @@ def generateEvents(providerNode, outputFile, stringTable): # key = eventID, value = version eventList = dict() for eventNode in eventNodes: + eventName = eventNode.getAttribute('symbol') + if not includeEvent(inclusion_list, providerName, eventName): + continue + eventID = eventNode.getAttribute("value") eventVersion = eventNode.getAttribute("version") eventList[eventID] = eventVersion @@ -195,6 +207,10 @@ def generateEvents(providerNode, outputFile, stringTable): # Iterate over each event node and process it. # Only emit events for the latest version of the event, otherwise EventSource initialization will fail. for eventNode in eventNodes: + eventName = eventNode.getAttribute('symbol') + if not includeEvent(inclusion_list, providerName, eventName): + continue + eventID = eventNode.getAttribute("value") eventVersion = eventNode.getAttribute("version") if eventID in eventList and eventList[eventID] == eventVersion: @@ -305,7 +321,29 @@ def generateEnumTypeMap(providerNode): return typeMap -def generateKeywordsClass(providerNode, outputFile): +def generateKeywordsClass(providerNode, outputFile, inclusion_list): + + providerName = providerNode.getAttribute("name") + + # Get the events element. + for node in providerNode.getElementsByTagName("events"): + eventsNode = node + break + + # Get the list of event nodes. + eventNodes = eventsNode.getElementsByTagName("event") + + # Build the list of used keywords + keywordSet = set() + for eventNode in eventNodes: + eventName = eventNode.getAttribute('symbol') + if not includeEvent(inclusion_list, providerName, eventName): + continue + + # Not all events have keywords specified, and some have multiple keywords specified. + keywords = eventNode.getAttribute("keywords") + if keywords: + keywordSet = keywordSet.union(keywords.split()) # Find the keywords element. for node in providerNode.getElementsByTagName("keywords"): @@ -317,7 +355,11 @@ def generateKeywordsClass(providerNode, outputFile): increaseTabLevel() for keywordNode in keywordsNode.getElementsByTagName("keyword"): - writeOutput(outputFile, "public const EventKeywords " + keywordNode.getAttribute("name") + " = (EventKeywords)" + keywordNode.getAttribute("mask") + ";\n") + keywordName = keywordNode.getAttribute("name") + if keywordName not in keywordSet: + continue; + + writeOutput(outputFile, "public const EventKeywords " + keywordName + " = (EventKeywords)" + keywordNode.getAttribute("mask") + ";\n") decreaseTabLevel() writeOutput(outputFile, "}\n\n") @@ -338,7 +380,7 @@ def loadStringTable(manifest): return stringTable -def generateEventSources(manifestFullPath, intermediatesDirFullPath, runtimeFlavor): +def generateEventSources(manifestFullPath, intermediatesDirFullPath, inclusion_list): # Open the manifest for reading. manifest = DOM.parse(manifestFullPath) @@ -347,7 +389,7 @@ def generateEventSources(manifestFullPath, intermediatesDirFullPath, runtimeFlav stringTable = loadStringTable(manifest) # Iterate over each provider that we want to generate an EventSource for. - for providerName, outputFileName in getManifestsToGenerate(runtimeFlavor).items(): + for providerName, outputFileName in getManifestsToGenerate().items(): for node in manifest.getElementsByTagName("provider"): if node.getAttribute("name") == providerName: providerNode = node @@ -379,7 +421,7 @@ def generateEventSources(manifestFullPath, intermediatesDirFullPath, runtimeFlav increaseTabLevel() # Write the keywords class. - generateKeywordsClass(providerNode, outputFile) + generateKeywordsClass(providerNode, outputFile, inclusion_list) #### Disable enums until they are needed #### # Generate the enum type map. @@ -394,7 +436,7 @@ def generateEventSources(manifestFullPath, intermediatesDirFullPath, runtimeFlav #### Disable enums until they are needed #### # Generate events. - generateEvents(providerNode, outputFile, stringTable) + generateEvents(providerNode, outputFile, stringTable, inclusion_list) # Write the class footer. decreaseTabLevel() @@ -413,8 +455,8 @@ def main(argv): help='full path to manifest containing the description of events') required.add_argument('--intermediate', type=str, required=True, help='full path to eventprovider intermediate directory') - required.add_argument('--runtimeflavor', type=str,default="CoreCLR", - help='runtime flavor') + required.add_argument('--inc', type=str,default="", + help='full path to inclusion list') args, unknown = parser.parse_known_args(argv) if unknown: print('Unknown argument(s): ', ', '.join(unknown)) @@ -422,7 +464,7 @@ def main(argv): manifestFullPath = args.man intermediatesDirFullPath = args.intermediate - runtimeFlavor = RuntimeFlavor(args.runtimeflavor) + inclusion_filename = args.inc # Ensure the intermediates directory exists. try: @@ -431,8 +473,10 @@ def main(argv): if not os.path.isdir(intermediatesDirFullPath): raise + inclusion_list = parseInclusionList(inclusion_filename) + # Generate event sources. - generateEventSources(manifestFullPath, intermediatesDirFullPath, runtimeFlavor) + generateEventSources(manifestFullPath, intermediatesDirFullPath, inclusion_list) return 0 if __name__ == '__main__': diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.Internal.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.Internal.cs index 7e9368dd3e929..660d65b367e86 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.Internal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.Internal.cs @@ -10,17 +10,6 @@ namespace System.Diagnostics.Tracing // It contains the runtime specific interop to native event sinks. internal sealed partial class NativeRuntimeEventSource : EventSource { -#if NATIVEAOT - // We don't have these keywords defined from the genRuntimeEventSources.py, so we need to manually define them here. - public static partial class Keywords - { - public const EventKeywords ContentionKeyword = (EventKeywords)0x4000; - public const EventKeywords ThreadingKeyword = (EventKeywords)0x10000; - public const EventKeywords ThreadTransferKeyword = (EventKeywords)0x80000000; - public const EventKeywords WaitHandleKeyword = (EventKeywords)0x40000000000; - } -#endif - [NonEvent] [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "NativeRuntimeEventSource_LogContentionLockCreated")] private static partial void LogContentionLockCreated(nint LockID, nint AssociatedObjectID, ushort ClrInstanceID); diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index 20fa27df32e89..d7983bef48786 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -315,8 +315,8 @@ - - src\System\Diagnostics\Eventing\Generated\NativeRuntimeEventSource.Mono.cs + + src\System\Diagnostics\Eventing\NativeRuntimeEventSource.Generated.cs @@ -327,7 +327,7 @@ DependsOnTargets="FindPython" BeforeTargets="BeforeCompile"> - + <_PythonWarningParameter>-Wall <_PythonWarningParameter Condition="'$(MSBuildTreatWarningsAsErrors)' == 'true'">$(_PythonWarningParameter) -Werror @@ -335,7 +335,7 @@ <_EventingSourceFileDirectory Condition="HasTrailingSlash('$(_EventingSourceFileDirectory)')">$(_EventingSourceFileDirectory.TrimEnd('\')) - + diff --git a/src/tests/issues.targets b/src/tests/issues.targets index 078ca36547d11..0440ee51964ac 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -686,9 +686,6 @@ - - https://github.com/dotnet/runtime/issues/105556 - https://github.com/dotnet/runtime/issues/102544