Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build without FEATURE_EVENT_TRACE #32746

Merged
merged 1 commit into from
Feb 25, 2020
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: 2 additions & 0 deletions src/coreclr/clrdefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ add_definitions(-DFEATURE_DEFAULT_INTERFACES)
if(FEATURE_EVENT_TRACE)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:FEATURE_EVENT_TRACE>)
add_definitions(-DFEATURE_PERFTRACING)
else(FEATURE_EVENT_TRACE)
add_custom_target(eventing_headers) # add a dummy target to avoid checking for FEATURE_EVENT_TRACE in multiple places
endif(FEATURE_EVENT_TRACE)
if(FEATURE_GDBJIT)
add_definitions(-DFEATURE_GDBJIT)
Expand Down
14 changes: 12 additions & 2 deletions src/coreclr/src/gc/env/etmdummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#define FireEtwGCMarkHandles(HeapNum, ClrInstanceID) 0
#define FireEtwGCMarkOlderGenerationRoots(HeapNum, ClrInstanceID) 0
#define FireEtwFinalizeObject(TypeID, ObjectID, ClrInstanceID) 0
#define FireEtwSetGCHandle(HandleID, ObjectID, Kind, Generation, ClrInstanceID) 0
#define FireEtwSetGCHandle(HandleID, ObjectID, Kind, Generation, DomainAddr, ClrInstanceID) 0
#define FireEtwDestroyGCHandle(HandleID, ClrInstanceID) 0
#define FireEtwGCSampledObjectAllocationLow(Address, TypeID, ObjectCountForTypeSample, TotalSizeForTypeSample, ClrInstanceID) 0
#define FireEtwPinObjectAtGCTime(HandleID, ObjectID, ObjectSize, TypeName, ClrInstanceID) 0
Expand Down Expand Up @@ -376,7 +376,7 @@
#define FireEtwFailFast(FailFastUserMessage, FailedEIP, OSExitCode, ClrExitCode, ClrInstanceID) 0
#define FireEtwPrvFinalizeObject(TypeID, ObjectID, ClrInstanceID, TypeName) 0
#define FireEtwCCWRefCountChange(HandleID, ObjectID, COMInterfacePointer, NewRefCount, AppDomainID, ClassName, NameSpace, Operation, ClrInstanceID) 0
#define FireEtwPrvSetGCHandle(HandleID, ObjectID, Kind, Generation, ClrInstanceID) 0
#define FireEtwPrvSetGCHandle(HandleID, ObjectID, Kind, Generation, DomainAddr, ClrInstanceId) 0
#define FireEtwPrvDestroyGCHandle(HandleID, ClrInstanceID) 0
#define FireEtwFusionMessageEvent(ClrInstanceID, Prepend, Message) 0
#define FireEtwFusionErrorCodeEvent(ClrInstanceID, Category, ErrorCode) 0
Expand All @@ -398,3 +398,13 @@
#define FireEtwBeginCreateManagedReference(ClrInstanceID) 0
#define FireEtwEndCreateManagedReference(ClrInstanceID) 0
#define FireEtwObjectVariantMarshallingToManaged(TypeName, Int1, ClrInstanceID) 0
#define FireEtwGCDynamicEvent(EventName, PayloadSize, Payload, ClrInstanceId) 0
#define FireEtwBGC1stSweepEnd(GenNumber, ClrInstanceId) 0
#define FireEtwResolutionAttempted(ClrInstanceId, asmName, stage, assemblyLoadContextName, result, resultAsmName, resultAsmPath, errMsg) 0
#define FireEtwResolutionAttempted(ClrInstanceId, asmName, event, alcName, result, resultAsmName, resultAsmPath, errMsg) 0
#define FireEtwKnownPathProbed(ClrInstanceId, path, source, hr) 0
#define FireEtwContentionStop_V1(managedContention, ClrInstanceId, elapsedTimeInNanosecond) 0
#define FireEtwAssemblyLoadContextResolvingHandlerInvoked(ClrInstanceId, assemblyName, handlerName, alcName, resultAssemblyName, resultAssemblyPath) 0
#define FireEtwAppDomainAssemblyResolveHandlerInvoked(ClrInstanceId, assemblyName, handlerName, resultAssemblyName, resultAssemblyPath) 0
#define FireEtwAssemblyLoadFromResolveHandlerInvoked(ClrInstanceId, assemblyName, isTrackedAssembly, requestingAssemblyPath, requestedAssemblyPath) 0
#define FireEtwEventSource(eventID, eventName, eventSourceName, payload) 0
20 changes: 16 additions & 4 deletions src/coreclr/src/inc/eventtracebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ struct ProfilingScanContext;

#else // FEATURE_EVENT_TRACE

#include "etmdummy.h"
#include "../gc/env/etmdummy.h"
#endif // FEATURE_EVENT_TRACE

#ifndef FEATURE_REDHAWK
Expand All @@ -245,7 +245,9 @@ extern UINT32 g_nClrInstanceId;
#define TRACE_LEVEL_VERBOSE 5 // Detailed traces from intermediate steps

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

class XplatEventLoggerConfiguration
Expand Down Expand Up @@ -388,9 +390,10 @@ class XplatEventLoggerController
{
ActivateAllKeywordsOfAllProviders();
}
#ifdef FEATURE_EVENT_TRACE
else
{
auto provider = GetProvider(providerName);
LTTNG_TRACE_CONTEXT *provider = GetProvider(providerName);
if (provider == nullptr)
{
return;
Expand All @@ -399,20 +402,23 @@ class XplatEventLoggerController
provider->Level = level;
provider->IsEnabled = true;
}
#endif
}

static void ActivateAllKeywordsOfAllProviders()
{
#ifdef FEATURE_EVENT_TRACE
for (LTTNG_TRACE_CONTEXT * const provider : ALL_LTTNG_PROVIDERS_CONTEXT)
{
provider->EnabledKeywordsBitmask = (ULONGLONG)(-1);
provider->Level = TRACE_LEVEL_VERBOSE;
provider->IsEnabled = true;
}
#endif
}

private:

#ifdef FEATURE_EVENT_TRACE
static LTTNG_TRACE_CONTEXT * const GetProvider(LPCWSTR providerName)
{
auto length = wcslen(providerName);
Expand All @@ -425,6 +431,7 @@ class XplatEventLoggerController
}
return nullptr;
}
#endif
};

class XplatEventLogger
Expand All @@ -437,6 +444,7 @@ class XplatEventLogger
return configEventLogging.val(CLRConfig::EXTERNAL_EnableEventLog);
}

#ifdef FEATURE_EVENT_TRACE
inline static bool IsProviderEnabled(DOTNET_TRACE_CONTEXT providerCtx)
{
return providerCtx.LttngProvider->IsEnabled;
Expand All @@ -458,7 +466,7 @@ class XplatEventLogger
}
return false;
}

#endif

/*
This method is where COMPlus_LTTngConfig environment variable is parsed and is registered with the runtime provider
Expand Down Expand Up @@ -1204,6 +1212,10 @@ namespace ETW
#else
static bool IsEnabled() { return false; }
static void SendSettings() {}
static void SendPause() {}
static void SendResume(UINT32 newMethodCount) {}
static void SendBackgroundJitStart(UINT32 pendingMethodCount) {}
static void SendBackgroundJitStop(UINT32 pendingMethodCount, UINT32 jittedMethodCount) {}
#endif

DISABLE_CONSTRUCT_COPY(Runtime);
Expand Down
11 changes: 5 additions & 6 deletions src/coreclr/src/scripts/genEventing.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,12 +635,11 @@ def generatePlatformIndependentFiles(sClrEtwAllMan, incDir, etmDummyFile, extern
clrproviders = os.path.join(incDir, "clrproviders.h")
with open_for_update(clrproviders) as Clrproviders:
Clrproviders.write("""
typedef struct _EVENT_DESCRIPTOR
{
int const Level;
ULONGLONG const Keyword;
} EVENT_DESCRIPTOR;
""")
typedef struct _EVENT_DESCRIPTOR
am11 marked this conversation as resolved.
Show resolved Hide resolved
{
int const Level;
ULONGLONG const Keyword;
} EVENT_DESCRIPTOR;""")

if not is_windows:
Clrproviders.write(eventpipe_trace_context_typedef) # define EVENTPIPE_TRACE_CONTEXT
Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/src/vm/proftoeeinterfaceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7062,14 +7062,14 @@ HRESULT ProfToEEInterfaceImpl::EventPipeCreateProvider(const WCHAR *szName, EVEN
EX_CATCH_HRESULT(hr);

return hr;
#elif // FEATURE_PERFTRACING
#else // FEATURE_PERFTRACING
return E_NOTIMPL;
#endif // FEATURE_PERFTRACING
}

HRESULT ProfToEEInterfaceImpl::EventPipeDefineEvent(
EVENTPIPE_PROVIDER provHandle,
const WCHAR *szName,
const WCHAR *szName,
UINT32 eventID,
UINT64 keywords,
UINT32 eventVersion,
Expand Down Expand Up @@ -7112,7 +7112,7 @@ HRESULT ProfToEEInterfaceImpl::EventPipeDefineEvent(
&& sizeof(EventPipeParameterDesc) == sizeof(COR_PRF_EVENTPIPE_PARAM_DESC),
"Layouts of EventPipeParameterDesc type and COR_PRF_EVENTPIPE_PARAM_DESC type do not match!");
EventPipeParameterDesc *params = reinterpret_cast<EventPipeParameterDesc *>(pParamDescs);

size_t metadataLength;
NewArrayHolder<BYTE> pMetadata = EventPipeMetadataGenerator::GenerateEventMetadata(
eventID,
Expand All @@ -7139,7 +7139,7 @@ HRESULT ProfToEEInterfaceImpl::EventPipeDefineEvent(
EX_CATCH_HRESULT(hr);

return hr;
#elif // FEATURE_PERFTRACING
#else // FEATURE_PERFTRACING
return E_NOTIMPL;
#endif // FEATURE_PERFTRACING
}
Expand Down Expand Up @@ -7174,14 +7174,14 @@ HRESULT ProfToEEInterfaceImpl::EventPipeWriteEvent(

static_assert(offsetof(EventData, Ptr) == offsetof(COR_PRF_EVENT_DATA, ptr)
&& offsetof(EventData, Size) == offsetof(COR_PRF_EVENT_DATA, size)
&& sizeof(EventData) == sizeof(COR_PRF_EVENT_DATA),
&& sizeof(EventData) == sizeof(COR_PRF_EVENT_DATA),
"Layouts of EventData type and COR_PRF_EVENT_DATA type do not match!");

EventData *pEventData = reinterpret_cast<EventData *>(data);
EventPipe::WriteEvent(*pEvent, pEventData, cData, pActivityId, pRelatedActivityId);

return S_OK;
#elif // FEATURE_PERFTRACING
#else // FEATURE_PERFTRACING
return E_NOTIMPL;
#endif // FEATURE_PERFTRACING
}
Expand Down