# ## Licensed to the .NET Foundation under one or more agreements. ## The .NET Foundation licenses this file to you under the MIT license. # # #USAGE: #Add Events: modify src/vm/ClrEtwAll.man #Look at the Code in /src/scripts/genLttngProvider.py for using subroutines in this file # # Python 2 compatibility from __future__ import print_function import os import xml.dom.minidom as DOM from utilities import open_for_update, parseInclusionList class RuntimeFlavor: def __init__(self, runtime): if runtime.lower() == "coreclr": self.coreclr = True self.mono = False self.nativeaot = False elif runtime.lower() == "mono": self.coreclr = False self.mono = True self.nativeaot = False elif runtime.lower() == "nativeaot": self.coreclr = False self.mono = False self.nativeaot = True else: self.coreclr = True self.mono = False self.nativeaot = False stdprolog=""" // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************** DO NOT MODIFY. AUTOGENERATED FILE. This file is generated using the logic from /src/scripts/genEventing.py ******************************************************************/ """ lindent = " " coreCLRPalDataTypeMapping={ #constructed types "win:null" :" ", "win:Int64" :"const int64_t", "win:ULong" :"const ULONG", "win:count" :"*", "win:Struct" :"const void", #actual spec "win:GUID" :"const GUID", "win:AnsiString" :"LPCSTR", "win:UnicodeString" :"PCWSTR", "win:Double" :"const double", "win:Int32" :"const signed int", "win:Boolean" :"const BOOL", "win:UInt64" :"const uint64_t", "win:UInt32" :"const unsigned int", "win:UInt16" :"const unsigned short", "win:UInt8" :"const unsigned char", "win:Pointer" :"const void*", "win:Binary" :"const BYTE", } coreCLREventPipeDataTypeMapping={ "BOOL" : "BOOL", "LPCGUID" : "LPCGUID", "UCHAR" : "UCHAR", "ULONG" : "ULONG", "ULONGLONG" : "ULONGLONG", "WCHAR" : "WCHAR", "BYTE" : "BYTE", } monoPalDataTypeMapping={ #constructed types "win:null" :" ", "win:Int64" :"const int64_t", "win:ULong" :"const uint32_t", "win:count" :"*", "win:Struct" :"const void", #actual spec "win:GUID" :"const uint8_t", "win:AnsiString" :"const char*", "win:UnicodeString" :"const ep_char8_t*", "win:Double" :"const double", "win:Int32" :"const int32_t", "win:Boolean" :"const bool", "win:UInt64" :"const uint64_t", "win:UInt32" :"const uint32_t", "win:UInt16" :"const uint16_t", "win:UInt8" :"const uint8_t", "win:Pointer" :"const void*", "win:Binary" :"const uint8_t", } monoEventPipeDataTypeMapping={ "BOOL" : "bool", "LPCGUID" : "const uint8_t*", "UCHAR" : "uint8_t", "ULONG" : "uint32_t", "ULONGLONG" : "uint64_t", "WCHAR" : "wchar_t", "BYTE" : "uint8_t", } aotPalDataTypeMapping={ #constructed types "win:null" :" ", "win:Int64" :"const int64_t", "win:ULong" :"const ULONG", "win:count" :"*", "win:Struct" :"const void", #actual spec "win:GUID" :"const GUID", "win:AnsiString" :"LPCSTR", "win:UnicodeString" :"const WCHAR*", "win:Double" :"const double", "win:Int32" :"const signed int", "win:Boolean" :"const BOOL", "win:UInt64" :"const uint64_t", "win:UInt32" :"const unsigned int", "win:UInt16" :"const unsigned short", "win:UInt8" :"const unsigned char", "win:Pointer" :"const void*", "win:Binary" :"const BYTE", } aotEventPipeDataTypeMapping={ "BOOL" : "BOOL", "LPCGUID" : "const GUID *", "UCHAR" : "UCHAR", "ULONG" : "ULONG", "ULONGLONG" : "ULONGLONG", "WCHAR" : "WCHAR", "BYTE" : "BYTE", } def getEventPipeDataTypeMapping(runtimeFlavor): if runtimeFlavor.coreclr: return coreCLREventPipeDataTypeMapping elif runtimeFlavor.mono: return monoEventPipeDataTypeMapping elif runtimeFlavor.nativeaot: return aotEventPipeDataTypeMapping def getPalDataTypeMapping(runtimeFlavor): if runtimeFlavor.coreclr: return coreCLRPalDataTypeMapping elif runtimeFlavor.mono: return monoPalDataTypeMapping elif runtimeFlavor.nativeaot: return aotPalDataTypeMapping def includeProvider(providerName, runtimeFlavor): if (runtimeFlavor.coreclr or runtimeFlavor.nativeaot) and providerName == "Microsoft-DotNETRuntimeMonoProfiler": return False elif runtimeFlavor.nativeaot and providerName == "Microsoft-Windows-DotNETRuntimeStress": return False else: return True 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 getCoreCLRMonoNativeAotTypeAdaptionDefines(): return """ #ifndef W #define W(str) L##str #endif #ifndef SL #define SL(str) str #endif #ifndef ERROR_SUCCESS #define ERROR_SUCCESS 0L #endif #ifndef ERROR_WRITE_FAULT #define ERROR_WRITE_FAULT 29L #endif """ # A Template represents an ETW template can contain 1 or more AbstractTemplates # The AbstractTemplate contains FunctionSignature # FunctionSignature consist of FunctionParameter representing each parameter in it's signature def getParamSequenceSize(paramSequence, estimate): total = 0 pointers = 0 for param in paramSequence: if param == "win:Int64": total += 8 elif param == "win:ULong": total += 4 elif param == "GUID": total += 16 elif param == "win:Double": total += 8 elif param == "win:Int32": total += 4 elif param == "win:Boolean": total += 4 elif param == "win:UInt64": total += 8 elif param == "win:UInt32": total += 4 elif param == "win:UInt16": total += 2 elif param == "win:UInt8": total += 1 elif param == "win:Pointer": if estimate: total += 8 else: pointers += 1 elif param == "win:Binary": total += 1 elif estimate: if param == "win:AnsiString": total += 32 elif param == "win:UnicodeString": total += 64 elif param == "win:Struct": total += 32 else: raise Exception("Don't know size for " + param) if estimate: return total return total, pointers class Template: def __repr__(self): return "