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

Initial work to port EventPipe library to NativeAOT #80382

Merged
merged 34 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cc5971f
CoreCLR shim files renamed to AOT
LakshanF Jan 9, 2023
9cf5f08
change coreclr references to aot
LakshanF Jan 9, 2023
ac16e8e
Native AOT runtime implementation
LakshanF Jan 9, 2023
418f8c3
hooks to EP library from AOT
LakshanF Jan 9, 2023
179585e
Container code
LakshanF Jan 9, 2023
8502406
Maanged to Native hooks
LakshanF Jan 9, 2023
a4ee746
build artifacts
LakshanF Jan 9, 2023
fe8252c
required changes to NativeAOT to support EP
LakshanF Jan 9, 2023
4b9e103
changes to common EP source
LakshanF Jan 9, 2023
548e8d7
sample EventSource test app
LakshanF Jan 9, 2023
1a742b0
Add EventPipe lib to the linker
LakshanF Jan 11, 2023
a03fcb1
Additional conditions to include the EventPipe library
LakshanF Jan 12, 2023
b36a06c
Fixing the Checked and Release and Linux builds
LakshanF Jan 12, 2023
c724e36
Merge branch 'main' into ExperimentEventPipe3
LakshanF Jan 13, 2023
b152648
separating maanged and native EventSource switches
LakshanF Jan 14, 2023
28e5439
Update src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Nativ…
LakshanF Jan 18, 2023
fc77cb9
FB, build break and test fixes
LakshanF Jan 19, 2023
f2002f6
fix non-windows build breaks and using paldebugbreak for TODOs
LakshanF Jan 19, 2023
5b3037e
trying another option to get arounf inttypes.h and PRIu64
LakshanF Jan 19, 2023
602f27b
reverting the changes in ep-json file in common code
LakshanF Jan 20, 2023
d8b5b98
Add an NativeAOT EventSource test
LakshanF Jan 22, 2023
93b0e9d
FB and only enabling FEATURE_PERFTRACING in Windows
LakshanF Jan 24, 2023
31535fe
fix DiagnosticEventSource test
LakshanF Jan 26, 2023
cdf37d4
FB
LakshanF Jan 29, 2023
9b17dd2
Update src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Nativ…
LakshanF Jan 30, 2023
34a44c4
Added GuardCF version and a standalone test
LakshanF Jan 31, 2023
f9b008d
Merge branch 'main' into ExperimentEventPipe3
LakshanF Jan 31, 2023
c55e32f
Moving NativeAOT headers away from EventPipe common code
LakshanF Feb 2, 2023
e4109a2
fix linux build break
LakshanF Feb 2, 2023
4bb2a7a
missed a needed definition in Linux
LakshanF Feb 2, 2023
3419c63
inline eventpipe common source code
LakshanF Feb 6, 2023
97dfa12
Adding Evenpipe lib to a lib test
LakshanF Feb 7, 2023
c10ec13
Small cleanups
MichalStrehovsky Feb 8, 2023
1cd0dc5
Fix linux build
MichalStrehovsky Feb 8, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ The .NET Foundation licenses this file to you under the MIT license.

<IlcRPath Condition="'$(IlcRPath)' == '' and '$(TargetOS)' != 'osx'">$ORIGIN</IlcRPath>
<IlcRPath Condition="'$(IlcRPath)' == '' and '$(TargetOS)' == 'osx'">@executable_path</IlcRPath>

<EventPipeName>libeventpipe-disabled</EventPipeName>
<EventPipeName Condition="'$(EnableNativeEventPipe)' == 'true'">libeventpipe-enabled</EventPipeName>
</PropertyGroup>

<ItemGroup>
<NativeLibrary Condition="'$(IlcMultiModule)' == 'true'" Include="$(SharedLibrary)" />
<NativeLibrary Condition="'$(NativeLib)' == ''" Include="$(IlcSdkPath)libbootstrapper.a" />
<NativeLibrary Condition="'$(NativeLib)' != ''" Include="$(IlcSdkPath)libbootstrapperdll.a" />
<NativeLibrary Include="$(IlcSdkPath)$(FullRuntimeName).a" />
<NativeLibrary Include="$(IlcSdkPath)$(EventPipeName)$(LibFileExt)" />
<NativeLibrary Condition="'$(LinkStandardCPlusPlusLibrary)' != 'true' and '$(StaticICULinking)' != 'true'" Include="$(IlcSdkPath)libstdc++compat.a" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The .NET Foundation licenses this file to you under the MIT license.
<EntryPointSymbol Condition="'$(EntryPointSymbol)' == ''">wmainCRTStartup</EntryPointSymbol>
<LinkerSubsystem Condition="'$(OutputType)' == 'WinExe' and '$(LinkerSubsystem)' == ''">WINDOWS</LinkerSubsystem>
<LinkerSubsystem Condition="'$(OutputType)' == 'Exe' and '$(LinkerSubsystem)' == ''">CONSOLE</LinkerSubsystem>
<EventPipeName>eventpipe-disabled</EventPipeName>
<EventPipeName Condition="'$(EnableNativeEventPipe)' == 'true'">eventpipe-enabled</EventPipeName>
</PropertyGroup>

<!-- Ensure that runtime-specific paths have already been set -->
Expand All @@ -33,6 +35,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<ItemGroup>
<NativeLibrary Include="$(IlcSdkPath)$(BootstrapperName)$(LibrarySuffix)" />
<NativeLibrary Include="$(IlcSdkPath)$(FullRuntimeName)$(LibrarySuffix)" />
<NativeLibrary Include="$(IlcSdkPath)$(EventPipeName)$(LibFileExt)" />
LakshanF marked this conversation as resolved.
Show resolved Hide resolved
<NativeLibrary Condition="'$(IlcMultiModule)' == 'true'" Include="$(SharedLibrary)" />
</ItemGroup>

Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/nativeaot/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
<PropertyGroup>
<DefineConstants Condition="'$(FeatureObjCMarshal)' == 'true'">FEATURE_OBJCMARSHAL;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<FeaturePerfTracing>false</FeaturePerfTracing>
<FeaturePerfTracing Condition="'$(TargetsWindows)' == 'true'">true</FeaturePerfTracing>
</PropertyGroup>
<PropertyGroup>
<DefineConstants Condition="'$(FeaturePerfTracing)' == 'true'">FEATURE_PERFTRACING;$(DefineConstants)</DefineConstants>
</PropertyGroup>


<!-- Platform specific properties -->
<PropertyGroup Condition="'$(Platform)' == 'x64'">
Expand Down
87 changes: 87 additions & 0 deletions src/coreclr/nativeaot/Runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,88 @@
set(EP_GENERATED_HEADER_PATH "${GENERATED_INCLUDE_DIR}")
include (${CLR_SRC_NATIVE_DIR}/eventpipe/configure.cmake)
include_directories(${EP_GENERATED_HEADER_PATH})

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(AOT_EVENTPIPE_SHIM_DIR "${CMAKE_CURRENT_SOURCE_DIR}/eventpipe")

set (SHARED_EVENTPIPE_SOURCE_DIR "${CLR_SRC_NATIVE_DIR}/eventpipe")
include_directories(${SHARED_EVENTPIPE_SOURCE_DIR})

set (AOT_EVENTPIPE_SHIM_SOURCES "")
set (AOT_EVENTPIPE_SHIM_HEADERS "")
set (AOT_EVENTPIPE_MANAGED_TO_NATIVE_SOURCES "")
set (SHARED_DIAGNOSTIC_SERVER_SOURCES "")
set (SHARED_DIAGNOSTIC_SERVER_HEADERS "")
set (AOT_EVENTPIPE_DISABLED_SOURCES "")

set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe")
include (${SHARED_EVENTPIPE_SOURCE_PATH}/CMakeLists.txt)

list(APPEND SHARED_DIAGNOSTIC_SERVER_SOURCES
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-sources.c
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-dump-protocol.c
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-eventpipe-protocol.c
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-ipc-pal-namedpipe.c
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-ipc.c
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-process-protocol.c
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-profiler-protocol.c
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-protocol.c
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-server.c
)

list(APPEND SHARED_DIAGNOSTIC_SERVER_HEADERS
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-dump-protocol.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-eventpipe-protocol.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-getter-setter.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-ipc.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-ipc-pal.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-ipc-pal-types.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-ipc-pal-namedpipe.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-process-protocol.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-profiler-protocol.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-protocol.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-rt.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-rt-config.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-rt-types.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-server.h
${SHARED_EVENTPIPE_SOURCE_DIR}/ds-types.h
)

list(APPEND AOT_EVENTPIPE_SHIM_SOURCES
${AOT_EVENTPIPE_SHIM_DIR}/ep-rt-aot.cpp
)

list(APPEND AOT_EVENTPIPE_SHIM_HEADERS
${AOT_EVENTPIPE_SHIM_DIR}/ds-rt-aot.h
${AOT_EVENTPIPE_SHIM_DIR}/ds-rt-types-aot.h
${AOT_EVENTPIPE_SHIM_DIR}/ep-rt-aot.h
${AOT_EVENTPIPE_SHIM_DIR}/ep-rt-config-aot.h
${AOT_EVENTPIPE_SHIM_DIR}/ep-rt-types-aot.h
)

list(APPEND AOT_EVENTPIPE_MANAGED_TO_NATIVE_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/eventpipeinternal.cpp
${CMAKE_CURRENT_SOURCE_DIR}/eventpipeadapter.h
${CMAKE_CURRENT_SOURCE_DIR}/diagnosticserveradapter.h
${CMAKE_CURRENT_SOURCE_DIR}/EnabledEventPipeInterface.cpp
)

list(APPEND EVENTPIPE_SOURCES
${AOT_EVENTPIPE_SHIM_SOURCES}
${AOT_EVENTPIPE_SHIM_HEADERS}
${AOT_EVENTPIPE_MANAGED_TO_NATIVE_SOURCES}
${SHARED_EVENTPIPE_SOURCES}
${SHARED_EVENTPIPE_HEADERS}
${SHARED_DIAGNOSTIC_SERVER_SOURCES}
${SHARED_DIAGNOSTIC_SERVER_HEADERS}
${SHARED_EVENTPIPE_CONFIG_HEADERS}
)

list(APPEND AOT_EVENTPIPE_DISABLED_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/DisabledEventPipeInterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/disabledeventpipeinternal.cpp
)

set(GC_DIR ../../gc)

set(COMMON_RUNTIME_SOURCES
Expand Down Expand Up @@ -37,6 +122,8 @@ set(COMMON_RUNTIME_SOURCES
UniversalTransitionHelpers.cpp
yieldprocessornormalized.cpp

EventPipeInterface.h

${GC_DIR}/gceventstatus.cpp
${GC_DIR}/gcload.cpp
${GC_DIR}/gcconfig.cpp
Expand Down
8 changes: 6 additions & 2 deletions src/coreclr/nativeaot/Runtime/CommonMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@
#endif
#endif

#ifndef __GCENV_BASE_INCLUDED__
// TODO: gcenv.base.h provides these definitions only if it has been included and windows.h
LakshanF marked this conversation as resolved.
Show resolved Hide resolved
// has not been included (even though though windows.h does not define these services); in
// all other cases the services need to be defined here.

#if !(defined(__GCENV_BASE_INCLUDED__) && !defined(_INC_WINDOWS))

//
// This macro returns val rounded up as necessary to be a multiple of alignment; alignment must be a power of 2
Expand All @@ -75,7 +79,7 @@ inline uintptr_t ALIGN_DOWN(uintptr_t val, uintptr_t alignment);
template <typename T>
inline T* ALIGN_DOWN(T* val, uintptr_t alignment);

#endif // !__GCENV_BASE_INCLUDED__
#endif // !(defined(__GCENV_BASE_INCLUDED__) && !defined(_INC_WINDOWS))

inline bool IS_ALIGNED(uintptr_t val, uintptr_t alignment);
template <typename T>
Expand Down
8 changes: 6 additions & 2 deletions src/coreclr/nativeaot/Runtime/CommonMacros.inl
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#ifndef __GCENV_BASE_INCLUDED__
// TODO: gcenv.base.h provides these definitions only if it has been included and windows.h
// has not been included (even though though windows.h does not define these services); in
// all other cases the services need to be defined here.

#if !(defined(__GCENV_BASE_INCLUDED__) && !defined(_INC_WINDOWS))

//
// This macro returns val rounded up as necessary to be a multiple of alignment; alignment must be a power of 2
Expand Down Expand Up @@ -36,7 +40,7 @@ inline T* ALIGN_DOWN(T* val, uintptr_t alignment)
return reinterpret_cast<T*>(ALIGN_DOWN(reinterpret_cast<uintptr_t>(val), alignment));
}

#endif // !__GCENV_BASE_INCLUDED__
#endif // !(defined(__GCENV_BASE_INCLUDED__) && !defined(_INC_WINDOWS))

inline bool IS_ALIGNED(uintptr_t val, uintptr_t alignment)
{
Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/nativeaot/Runtime/DisabledEventPipeInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

void EventPipeAdapter_Initialize() {}

bool DiagnosticServerAdapter_Initialize() { return false; }
void DiagnosticServerAdapter_PauseForDiagnosticsMonitor() {}

void EventPipeAdapter_FinishInitialize() {}

void EventPipeAdapter_Shutdown() {}
bool DiagnosticServerAdapter_Shutdown() { return false; }
Loading