Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/coreclr/clr.featuredefines.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
<!-- single thread -->
<FeaturePortableTimer Condition="'$(WasmEnableThreads)' != 'true'">false</FeaturePortableTimer>
<FeaturePortableThreadPool Condition="'$(WasmEnableThreads)' != 'true'">false</FeaturePortableThreadPool>
<!-- until we implement ST event pipe for CoreCLR -->
<FeaturePerfTracing>false</FeaturePerfTracing>
<ProfilingSupportedBuild>false</ProfilingSupportedBuild>
</PropertyGroup>

Expand Down
9 changes: 7 additions & 2 deletions src/coreclr/clrdefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,14 @@ add_definitions(-DFEATURE_DEFAULT_INTERFACES)
if(FEATURE_EVENT_TRACE)
add_compile_definitions(FEATURE_EVENT_TRACE)
add_definitions(-DFEATURE_PERFTRACING)
else(FEATURE_EVENT_TRACE)
elseif(FEATURE_PERFTRACING)
add_definitions(-DFEATURE_PERFTRACING)
if(CLR_CROSS_COMPONENTS_BUILD)
add_custom_target(eventing_headers)
endif()
else()
add_custom_target(eventing_headers) # add a dummy target to avoid checking for FEATURE_EVENT_TRACE in multiple places
endif(FEATURE_EVENT_TRACE)
endif()
if(FEATURE_GDBJIT)
add_definitions(-DFEATURE_GDBJIT)
endif()
Expand Down
19 changes: 15 additions & 4 deletions src/coreclr/clrfeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,34 @@ if(CLR_CMAKE_TARGET_TIZEN_LINUX)
set(FEATURE_GDBJIT_LANGID_CS 1)
endif()

# FEATURE_EVENT_TRACE: Enables the full eventing infrastructure (generated FireEtw* functions,
# EventPipe write calls, ETW on Windows). Set on all platforms except cross-component WASM builds.
if(NOT DEFINED FEATURE_EVENT_TRACE)
if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT (CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_TARGET_ARCH_WASM))
if (NOT (CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_TARGET_ARCH_WASM))
# To actually disable FEATURE_EVENT_TRACE, also change clr.featuredefines.props
set(FEATURE_EVENT_TRACE 1)
endif()
endif(NOT DEFINED FEATURE_EVENT_TRACE)

# FEATURE_EVENTSOURCE_XPLAT: Enables the LTTng-based XplatEventLogger path (LTTNG_TRACE_CONTEXT,
# XplatEventLogger, XplatEventLoggerController, and the generated FireEtXplat* functions).
# Currently Linux-only (excluding Android). Used as the sole guard for all LTTng-related code;
# platforms without this flag (Windows, macOS, Browser, WASI) use EventPipe-only eventing.
if(NOT DEFINED FEATURE_EVENTSOURCE_XPLAT)
if (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT (CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_TARGET_ARCH_WASM))
# To actually disable FEATURE_EVENTSOURCE_XPLAT, also change clr.featuredefines.props
set(FEATURE_EVENTSOURCE_XPLAT 1)
endif()
endif(NOT DEFINED FEATURE_EVENTSOURCE_XPLAT)

if(NOT DEFINED FEATURE_PERFTRACING AND FEATURE_EVENT_TRACE)
set(FEATURE_PERFTRACING 1)
endif(NOT DEFINED FEATURE_PERFTRACING AND FEATURE_EVENT_TRACE)
# FEATURE_PERFTRACING: Enables the EventPipe diagnostics subsystem (event sessions, IPC protocol,
# diagnostic server). Set whenever FEATURE_EVENT_TRACE is set, or when threadless perftracing is
# explicitly requested via FEATURE_PERFTRACING_DISABLE_THREADS.
if(NOT DEFINED FEATURE_PERFTRACING)
if(FEATURE_EVENT_TRACE OR FEATURE_PERFTRACING_DISABLE_THREADS)
set(FEATURE_PERFTRACING 1)
endif()
Comment thread
pavelsavara marked this conversation as resolved.
endif(NOT DEFINED FEATURE_PERFTRACING)

if(NOT DEFINED FEATURE_DBGIPC)
if(CLR_CMAKE_TARGET_UNIX)
Expand Down
28 changes: 15 additions & 13 deletions src/coreclr/inc/eventtracebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,20 @@ enum EtwGCSettingFlags
#define ETWFireEvent(EventName) FireEtw##EventName(GetClrInstanceId())

#define ETW_TRACING_INITIALIZED(RegHandle) (TRUE)
#if defined(FEATURE_EVENTSOURCE_XPLAT)
#define ETW_EVENT_ENABLED(Context, EventDescriptor) (EventPipeHelper::IsEnabled(Context, EventDescriptor.Level, EventDescriptor.Keyword) || \
(XplatEventLogger::IsKeywordEnabled(Context, EventDescriptor.Level, EventDescriptor.Keyword)))
#define ETW_CATEGORY_ENABLED(Context, Level, Keyword) (EventPipeHelper::IsEnabled(Context, Level, Keyword) || \
(XplatEventLogger::IsKeywordEnabled(Context, Level, Keyword)))
#define ETW_TRACING_ENABLED(Context, EventDescriptor) (EventEnabled##EventDescriptor())
#define ETW_TRACING_CATEGORY_ENABLED(Context, Level, Keyword) (EventPipeHelper::IsEnabled(Context, Level, Keyword) || \
(XplatEventLogger::IsKeywordEnabled(Context, Level, Keyword)))
#else // FEATURE_EVENTSOURCE_XPLAT
#define ETW_EVENT_ENABLED(Context, EventDescriptor) (EventPipeHelper::IsEnabled(Context, EventDescriptor.Level, EventDescriptor.Keyword))
#define ETW_CATEGORY_ENABLED(Context, Level, Keyword) (EventPipeHelper::IsEnabled(Context, Level, Keyword))
#define ETW_TRACING_ENABLED(Context, EventDescriptor) (EventEnabled##EventDescriptor())
#define ETW_TRACING_CATEGORY_ENABLED(Context, Level, Keyword) (EventPipeHelper::IsEnabled(Context, Level, Keyword))
#endif // FEATURE_EVENTSOURCE_XPLAT
#define ETW_PROVIDER_ENABLED(ProviderSymbol) (TRUE)
#else //defined(FEATURE_PERFTRACING)
#define ETW_INLINE
Expand Down Expand Up @@ -248,16 +255,11 @@ struct ProfilingScanContext;
extern UINT32 g_nClrInstanceId;

#define GetClrInstanceId() (static_cast<UINT16>(g_nClrInstanceId))
#if defined(HOST_UNIX) && (defined(FEATURE_EVENT_TRACE) || defined(FEATURE_EVENTSOURCE_XPLAT))
#if defined(HOST_UNIX) && defined(FEATURE_EVENT_TRACE)
#define KEYWORDZERO 0x0

#define DEF_LTTNG_KEYWORD_ENABLED 1
#ifdef FEATURE_EVENT_TRACE
#include "clrproviders.h"
#endif // FEATURE_EVENT_TRACE
#include "clrconfig.h"

#endif // defined(HOST_UNIX) && (defined(FEATURE_EVENT_TRACE) || defined(FEATURE_EVENTSOURCE_XPLAT))
#endif // defined(HOST_UNIX) && defined(FEATURE_EVENT_TRACE)

#if defined(FEATURE_PERFTRACING) || defined(FEATURE_EVENTSOURCE_XPLAT)

Expand Down Expand Up @@ -416,7 +418,7 @@ class XplatEventLoggerConfiguration
};
#endif // defined(FEATURE_PERFTRACING) || defined(FEATURE_EVENTSOURCE_XPLAT)

#if defined(HOST_UNIX) && (defined(FEATURE_EVENT_TRACE) || defined(FEATURE_EVENTSOURCE_XPLAT))
#if defined(FEATURE_EVENTSOURCE_XPLAT)

class XplatEventLoggerController
{
Expand All @@ -436,7 +438,7 @@ class XplatEventLoggerController
{
ActivateAllKeywordsOfAllProviders();
}
#ifdef FEATURE_EVENT_TRACE
#if defined(FEATURE_EVENT_TRACE) && defined(HOST_UNIX)
else
{
LTTNG_TRACE_CONTEXT *provider = GetProvider(providerName);
Expand All @@ -453,7 +455,7 @@ class XplatEventLoggerController

static void ActivateAllKeywordsOfAllProviders()
{
#ifdef FEATURE_EVENT_TRACE
#if defined(FEATURE_EVENT_TRACE) && defined(HOST_UNIX)
for (LTTNG_TRACE_CONTEXT * const provider : ALL_LTTNG_PROVIDERS_CONTEXT)
{
provider->EnabledKeywordsBitmask = (ULONGLONG)(-1);
Expand All @@ -464,7 +466,7 @@ class XplatEventLoggerController
}

private:
#ifdef FEATURE_EVENT_TRACE
#if defined(FEATURE_EVENT_TRACE) && defined(HOST_UNIX)
static LTTNG_TRACE_CONTEXT * const GetProvider(LPCWSTR providerName)
{
auto length = u16_strlen(providerName);
Expand All @@ -490,7 +492,7 @@ class XplatEventLogger
return configEventLogging.val(CLRConfig::EXTERNAL_EnableEventLog);
}

#ifdef FEATURE_EVENT_TRACE
#if defined(FEATURE_EVENT_TRACE) && defined(HOST_UNIX)
inline static bool IsProviderEnabled(DOTNET_TRACE_CONTEXT providerCtx)
{
return providerCtx.LttngProvider->IsEnabled;
Expand Down Expand Up @@ -557,7 +559,7 @@ class XplatEventLogger
};


#endif // defined(HOST_UNIX) && (defined(FEATURE_EVENT_TRACE) || defined(FEATURE_EVENTSOURCE_XPLAT))
#endif // defined(FEATURE_EVENTSOURCE_XPLAT)

#if defined(FEATURE_EVENT_TRACE)

Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ add_library_clr(clrinterpreter_objects OBJECT ${INTERPRETER_SOURCES})

target_include_directories(clrinterpreter_objects PRIVATE ../jitshared)

if (FEATURE_PERFTRACING_DISABLE_THREADS)
target_compile_definitions(clrinterpreter_objects PRIVATE PERFTRACING_DISABLE_THREADS)
endif()

if (NOT CMAKE_GENERATOR MATCHES "Visual Studio")
set_target_properties(clrinterpreter_objects PROPERTIES EXCLUDE_FROM_ALL $<NOT:${FEATURE_INTERPRETER}>)
endif()
Expand Down
10 changes: 9 additions & 1 deletion src/coreclr/scripts/genEventPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,20 @@ def generateClrEventPipeWriteEventsImpl(
"void Init" +
providerPrettyName +
"(void)\n{\n")
if runtimeFlavor.coreclr:
callbackExpr = ("\n#ifdef FEATURE_EVENT_TRACE\n" +
" " + eventPipeCallbackCastExpr + "(" + callbackName + ")\n" +
"#else\n" +
" nullptr\n" +
"#endif\n ")
else:
callbackExpr = eventPipeCallbackCastExpr + "(" + callbackName + ")"
WriteEventImpl.append(
" EventPipeProvider" +
providerPrettyName +
" = " + createProviderFunc + "(" +
providerPrettyName +
"Name, " + eventPipeCallbackCastExpr + "(" + callbackName + "));\n")
"Name, " + callbackExpr + ");\n")
for eventNode in eventNodes:
eventName = eventNode.getAttribute('symbol')
templateName = eventNode.getAttribute('template')
Expand Down
21 changes: 18 additions & 3 deletions src/coreclr/scripts/genEventing.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,15 @@ def generateClrallEvents(eventNodes, allTemplates, target_cpp, runtimeFlavor, is

if runtimeFlavor.coreclr or write_xplatheader or runtimeFlavor.nativeaot:
if not is_host_windows:
# native AOT does not support non-windows eventing other than via event pipe
# native AOT and browser/wasi do not support non-windows eventing other than via event pipe
if not runtimeFlavor.nativeaot:
clrallEvents.append(" || (XplatEventLogger" +
clrallEvents.append("\n#if defined(FEATURE_EVENTSOURCE_XPLAT)\n")
clrallEvents.append(" || (XplatEventLogger" +
("::" if target_cpp else "_") +
"IsEventLoggingEnabled() && EventXplatEnabled" +
eventName + "());}\n\n")
eventName + "())\n")
clrallEvents.append("#endif // FEATURE_EVENTSOURCE_XPLAT\n")
clrallEvents.append(";}\n\n")
else:
clrallEvents.append(";}\n\n")
else:
Expand Down Expand Up @@ -534,8 +537,12 @@ def generateClrallEvents(eventNodes, allTemplates, target_cpp, runtimeFlavor, is
fnbody.append("ActivityId,RelatedActivityId);\n")

if runtimeFlavor.coreclr or write_xplatheader:
if not is_host_windows:
fnbody.append("#if defined(FEATURE_EVENTSOURCE_XPLAT)\n")
fnbody.append(lindent)
fnbody.append("status &= FireEtXplat" + eventName + "(" + ''.join(line) + ");\n")
if not is_host_windows:
fnbody.append("#endif // FEATURE_EVENTSOURCE_XPLAT\n")

if runtimeFlavor.nativeaot:
if providerName == "Microsoft-Windows-DotNETRuntime" or providerName == "Microsoft-Windows-DotNETRuntimePrivate" or providerName == "Microsoft-Windows-DotNETRuntimeRundown":
Expand Down Expand Up @@ -868,7 +875,9 @@ def generatePlatformIndependentFiles(sClrEtwAllMan, incDir, etmDummyFile, extern
typedef struct _DOTNET_TRACE_CONTEXT
{
EVENTPIPE_TRACE_CONTEXT EventPipeProvider;
#if defined(FEATURE_EVENTSOURCE_XPLAT)
PLTTNG_TRACE_CONTEXT LttngProvider;
#endif
} DOTNET_TRACE_CONTEXT, *PDOTNET_TRACE_CONTEXT;
#endif // DOTNET_TRACE_CONTEXT_DEF
"""
Expand All @@ -894,7 +903,9 @@ def generatePlatformIndependentFiles(sClrEtwAllMan, incDir, etmDummyFile, extern
""")
if not is_host_windows and not runtimeFlavor.nativeaot:
Clrproviders.write(eventpipe_trace_context_typedef) # define EVENTPIPE_TRACE_CONTEXT
Clrproviders.write("#if defined(FEATURE_EVENTSOURCE_XPLAT)\n")
Clrproviders.write(lttng_trace_context_typedef) # define LTTNG_TRACE_CONTEXT
Clrproviders.write("#endif // FEATURE_EVENTSOURCE_XPLAT\n")
Clrproviders.write(dotnet_trace_context_typedef_unix + "\n")

allProviders = []
Expand All @@ -910,7 +921,9 @@ def generatePlatformIndependentFiles(sClrEtwAllMan, incDir, etmDummyFile, extern
eventpipeProviderCtxName = providerSymbol + "_EVENTPIPE_Context"
Clrproviders.write('__attribute__((weak)) EVENTPIPE_TRACE_CONTEXT ' + eventpipeProviderCtxName + ' = { W("' + providerName + '"), 0, false, 0 };\n')
lttngProviderCtxName = providerSymbol + "_LTTNG_Context"
Clrproviders.write('#if defined(FEATURE_EVENTSOURCE_XPLAT)\n')
Clrproviders.write('__attribute__((weak)) LTTNG_TRACE_CONTEXT ' + lttngProviderCtxName + ' = { W("' + providerName + '"), 0, false, 0 };\n')
Clrproviders.write('#endif // FEATURE_EVENTSOURCE_XPLAT\n')

Clrproviders.write("// Keywords\n");
for keywordNode in providerNode.getElementsByTagName('keyword'):
Expand All @@ -934,10 +947,12 @@ def generatePlatformIndependentFiles(sClrEtwAllMan, incDir, etmDummyFile, extern

# define and initialize runtime providers' DOTNET_TRACE_CONTEXT depending on the platform
if not is_host_windows and not runtimeFlavor.nativeaot:
Clrproviders.write('#if defined(FEATURE_EVENTSOURCE_XPLAT)\n')
Clrproviders.write('#define NB_PROVIDERS ' + str(nbProviders) + '\n')
Clrproviders.write(('constexpr ' if target_cpp else 'static const ') + 'LTTNG_TRACE_CONTEXT * ALL_LTTNG_PROVIDERS_CONTEXT[NB_PROVIDERS] = { ')
Clrproviders.write(', '.join(allProviders))
Clrproviders.write(' };\n')
Clrproviders.write('#endif // FEATURE_EVENTSOURCE_XPLAT\n')


clreventpipewriteevents = os.path.join(incDir, "clreventpipewriteevents.h")
Expand Down
9 changes: 6 additions & 3 deletions src/coreclr/vm/eventing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ add_custom_command(
set_source_files_properties(${EventingHeaders} PROPERTIES GENERATED TRUE)

add_custom_target(eventing_headers DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/eventing_headers.timestamp)
add_dependencies(eventing_headers eventprovider)

add_subdirectory(eventpipe)

if(CLR_CMAKE_HOST_WIN32)
add_subdirectory(EtwProvider)
endif()

if (TARGET eventprovider)
add_dependencies(eventing_headers eventprovider)
endif()

add_subdirectory(eventpipe)
5 changes: 5 additions & 0 deletions src/coreclr/vm/eventing/eventpipe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ add_library_clr(eventpipe_gen_objs OBJECT ${GEN_EVENTPIPE_SOURCES})
target_precompile_headers(eventpipe_gen_objs PRIVATE [["common.h"]])
set_target_properties(eventpipe_gen_objs PROPERTIES LINKER_LANGUAGE CXX)
add_dependencies(eventpipe_gen_objs eventing_headers)
target_compile_definitions(eventpipe_gen_objs PRIVATE FEATURE_PERFTRACING)

add_library_clr(eventpipe_objs OBJECT ${CORECLR_EVENTPIPE_SHIM_SOURCES} ${CORECLR_EVENTPIPE_SHIM_HEADERS})
set_target_properties(eventpipe_objs PROPERTIES
Expand All @@ -53,6 +54,10 @@ set_target_properties(eventpipe_objs PROPERTIES
)
add_dependencies(eventpipe_objs eventing_headers)
target_link_libraries(eventpipe_objs PRIVATE dn-diagnosticserver dn-eventpipe)
target_compile_definitions(eventpipe_objs PRIVATE FEATURE_PERFTRACING)
if (FEATURE_PERFTRACING_DISABLE_THREADS)
target_compile_definitions(eventpipe_objs PRIVATE PERFTRACING_DISABLE_THREADS)
endif()

# The CoreCLR EventPipe runtime is C++, but the EventPipe and DiagnosticServer sources are C.
# Forcibly override them to build as C++.
Expand Down
Loading
Loading