Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 7524d72

Browse files
author
Victor "Nate" Graf
authored
Enable EventPipe across Unix and Windows (#14772)
* [squashed] most work complete to enable EventPipe on Windows * Eventpipe now builds on Windows * Ensure evevntpipe is intialized on Windows * Resolve the location of python from build.cmd * Ensure eventing files are generated when needed * moving linkage declaration to cmake * create new event from constructor * enable FEATURE_EVENT_TRACE and FEATURE_PERF_TRACE everywhere * [WIP] checkpoint in fixing contarct errors * add another possible python location * Fix double delete bug in EventPipeConfiguration destructor * Fix typo in function name * Revert changes to .gitgnore * bump to netstandard1.6 in preperation for new version of TraceEvent * Revert changes to groovy files * revert changes to perf-prep scripts * add common.h and use nothrow * Fix issue which was causing double delete of configprovider * Add new test utilizing TraceEvent * Remove accidentally added local directory reference * Add comment to explain the addition of misc/tracepointprovider.cpp * Add back sys.exit(0) and refactor * Change conditional to be more direct * Better handle NULL config * Initialize m_deleteDefered * Eliminate obsolete field * Fix spelling error * Fix nits * Make smaple progiler timing functions easier to read * Move projects back to netstandard1.4 * Incomplete improvements to EventPipeTrace test * Add event integrity checks to test * Clean up some left over code * Add EventSource based test * Remove unused PAL tests on Windows * Fix Linux build breaks * Minor changes to CMake files * Remove //HACK for hack that was previously removed * Fix formatting and negate a #ifdef * Add conditional to ensure PERFTRACING is not enabled without EVENT_TRACE * Take lock on EventPipeProvider and EventPipeConfiguration destruction * Load winmm.dll at runtime * Change function name and compile conditions * Move typedef into #ifndef * Use the correct config in setup * Change lifecycle managment of EventPipeConfiguration's configuration provider * Enable EventPipe tests pri0 and disable broken tests * Replace python3 only error with python2 compatable one * Make common.csproj build pri0 * Change TraceEvent version to 2.0.2 to match published verison * Address cross build failure * Remove use of undefined variable * Add crossgen fix to .cmd * Use more specific types to avoid marshalling errors * Use Assert-style statements and remove one check * Fix cross arch build * Fix flipped branch * Bring build.cmd changes to build.sh * Fix cmake writing * Revert "Bring build.cmd changes to build.sh" This reverts commit 893c649. * remove stdlib.h * Fix out of order null check
1 parent 9891c8b commit 7524d72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2003
-1048
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ endif (WIN32)
2323
set(CLR_DIR ${CMAKE_CURRENT_SOURCE_DIR})
2424
set(VM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/vm)
2525
set(GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/inc)
26+
set(GENERATED_EVENTING_DIR ${CMAKE_CURRENT_BINARY_DIR}/eventing)
2627
set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/version.cpp")
2728

2829
set(CORECLR_SET_RPATH ON)

build.cmd

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ set __ThisScriptDir="%~dp0"
2828
if defined VisualStudioVersion (
2929
if not defined __VSVersion echo %__MsgPrefix%Detected Visual Studio %VisualStudioVersion% developer command ^prompt environment
3030
goto :Run
31-
)
31+
)
3232

3333
echo %__MsgPrefix%Searching ^for Visual Studio 2017 or 2015 installation
3434
set _VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
@@ -294,6 +294,16 @@ if %__EnforcePgo%==1 (
294294
)
295295
)
296296

297+
REM Determine if this is a cross-arch build
298+
299+
if /i "%__BuildArch%"=="arm64" (
300+
set __DoCrossArchBuild=1
301+
)
302+
303+
if /i "%__BuildArch%"=="arm" (
304+
set __DoCrossArchBuild=1
305+
)
306+
297307
:: Set the remaining variables based upon the determined build configuration
298308
set "__BinDir=%__RootBinDir%\Product\%__BuildOS%.%__BuildArch%.%__BuildType%"
299309
set "__IntermediatesDir=%__RootBinDir%\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
@@ -380,6 +390,38 @@ for /f "tokens=*" %%s in ('%DotNetCli% msbuild "%OptDataProjectFilePath%" /t:Dum
380390
set __IbcOptDataVersion=%%s
381391
)
382392

393+
REM =========================================================================================
394+
REM ===
395+
REM === Generate source files for eventing
396+
REM ===
397+
REM =========================================================================================
398+
399+
REM Find python and set it to the variable PYTHON
400+
echo import sys; print sys.executable | (python2.7 || python2 || py -2 || python) > %TEMP%\pythonlocation.txt 2> NUL
401+
set /p PYTHON=<%TEMP%\pythonlocation.txt
402+
if NOT DEFINED PYTHON (
403+
echo %__MsgPrefix%Error: Could not find a python 2.7 installation
404+
exit /b 1
405+
)
406+
407+
if /i "%__DoCrossArchBuild%"=="1" (
408+
set __IntermediatesIncDir=%__CrossCompIntermediatesDir%\src\inc
409+
set __IntermediatesEventingDir=%__CrossCompIntermediatesDir%\eventing
410+
) else (
411+
set __IntermediatesIncDir=%__IntermediatesDir%\src\inc
412+
set __IntermediatesEventingDir=%__IntermediatesDir%\eventing
413+
)
414+
415+
echo Laying out dynamically generated files consumed by the build system
416+
echo Laying out dynamically generated Event test files and etmdummy stub functions
417+
%PYTHON% -B -Wall %__SourceDir%\scripts\genEventing.py --inc %__IntermediatesIncDir% --dummy %__IntermediatesIncDir%\etmdummy.h --man %__SourceDir%\vm\ClrEtwAll.man --nonextern || exit /b 1
418+
419+
echo Laying out dynamically generated EventPipe Implementation
420+
%PYTHON% -B -Wall %__SourceDir%\scripts\genEventPipe.py --man %__SourceDir%\vm\ClrEtwAll.man --intermediate %__IntermediatesEventingDir%\eventpipe --nonextern || exit /b 1
421+
422+
echo Laying out ETW event logging interface
423+
%PYTHON% -B -Wall %__SourceDir%\scripts\genEtwProvider.py --man %__SourceDir%\vm\ClrEtwAll.man --intermediate %__IntermediatesIncDir% --exc %__SourceDir%\vm\ClrEtwAllMeta.lst || exit /b 1
424+
383425
REM =========================================================================================
384426
REM ===
385427
REM === Build the CLR VM
@@ -476,14 +518,6 @@ REM === Build Cross-Architecture Native Components (if applicable)
476518
REM ===
477519
REM =========================================================================================
478520

479-
if /i "%__BuildArch%"=="arm64" (
480-
set __DoCrossArchBuild=1
481-
)
482-
483-
if /i "%__BuildArch%"=="arm" (
484-
set __DoCrossArchBuild=1
485-
)
486-
487521
if /i "%__DoCrossArchBuild%"=="1" (
488522
REM Scope environment changes start {
489523
setlocal

build.sh

Lines changed: 16 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -194,28 +194,9 @@ generate_event_logging_sources()
194194
fi
195195

196196
# Event Logging Infrastructure
197-
__GeneratedIntermediate="$__IntermediatesDir/Generated"
198-
__GeneratedIntermediateEventProvider="$__GeneratedIntermediate/eventprovider_new"
199-
__GeneratedIntermediateEventPipe="$__GeneratedIntermediate/eventpipe_new"
200-
201-
if [[ -d "$__GeneratedIntermediateEventProvider" ]]; then
202-
rm -rf "$__GeneratedIntermediateEventProvider"
203-
fi
204-
205-
if [[ -d "$__GeneratedIntermediateEventPipe" ]]; then
206-
rm -rf "$__GeneratedIntermediateEventPipe"
207-
fi
208-
209-
if [[ ! -d "$__GeneratedIntermediate/eventprovider" ]]; then
210-
mkdir -p "$__GeneratedIntermediate/eventprovider"
211-
fi
212-
213-
if [[ ! -d "$__GeneratedIntermediate/eventpipe" ]]; then
214-
mkdir -p "$__GeneratedIntermediate/eventpipe"
215-
fi
216-
217-
mkdir -p "$__GeneratedIntermediateEventProvider"
218-
mkdir -p "$__GeneratedIntermediateEventPipe"
197+
__GeneratedIntermediate="$__IntermediatesDir/eventing"
198+
__GeneratedIntermediateEventProvider="$__GeneratedIntermediate/eventprovider"
199+
__GeneratedIntermediateEventPipe="$__GeneratedIntermediate/eventpipe"
219200

220201
__PythonWarningFlags="-Wall"
221202
if [[ $__IgnoreWarnings == 0 ]]; then
@@ -225,54 +206,38 @@ generate_event_logging_sources()
225206

226207
if [[ $__SkipCoreCLR == 0 || $__ConfigureOnly == 1 ]]; then
227208
echo "Laying out dynamically generated files consumed by the build system "
228-
echo "Laying out dynamically generated Event Logging Test files"
229-
$PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genXplatEventing.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst" --testdir "$__GeneratedIntermediateEventProvider/tests"
209+
echo "Laying out dynamically generated Event test files, etmdummy stub functions, and external linkages"
210+
$PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventing.py" --inc $__IntermediatesDir/src/inc --dummy $__IntermediatesDir/src/inc/etmdummy.h --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --testdir "$__GeneratedIntermediateEventProvider/tests"
230211

231212
if [[ $? != 0 ]]; then
232213
exit
233214
fi
234215

235-
case $__BuildOS in
236-
Linux|FreeBSD)
237-
echo "Laying out dynamically generated EventPipe Implementation"
238-
$PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventPipe.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventPipe" --exc "$__ProjectRoot/src/vm/ClrEtwAllMeta.lst"
239-
if [[ $? != 0 ]]; then
240-
exit
241-
fi
242-
;;
243-
*)
244-
;;
245-
esac
216+
echo "Laying out dynamically generated EventPipe Implementation"
217+
$PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genEventPipe.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventPipe"
246218

247219
#determine the logging system
248220
case $__BuildOS in
249221
Linux|FreeBSD)
250222
echo "Laying out dynamically generated Event Logging Implementation of Lttng"
251-
$PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genXplatLttng.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventProvider"
223+
$PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genLttngProvider.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventProvider"
252224
if [[ $? != 0 ]]; then
253225
exit
254226
fi
255227
;;
256228
*)
229+
echo "Laying out dummy event logging provider"
230+
$PYTHON -B $__PythonWarningFlags "$__ProjectRoot/src/scripts/genDummyProvider.py" --man "$__ProjectRoot/src/vm/ClrEtwAll.man" --intermediate "$__GeneratedIntermediateEventProvider"
231+
if [[ $? != 0 ]]; then
232+
exit
233+
fi
257234
;;
258235
esac
259-
fi
260-
261-
echo "Cleaning the temp folder of dynamically generated Event Logging files"
262-
$PYTHON -B $__PythonWarningFlags -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventprovider\",\"$__GeneratedIntermediateEventProvider\")"
263-
if [[ $? != 0 ]]; then
264-
exit
265-
fi
266236

267-
rm -rf "$__GeneratedIntermediateEventProvider"
268-
269-
echo "Cleaning the temp folder of dynamically generated EventPipe files"
270-
$PYTHON -B $__PythonWarningFlags -c "import sys;sys.path.insert(0,\"$__ProjectRoot/src/scripts\"); from Utilities import *;UpdateDirectory(\"$__GeneratedIntermediate/eventpipe\",\"$__GeneratedIntermediateEventPipe\")"
271-
if [[ $? != 0 ]]; then
272-
exit
237+
if [[ $__CrossBuild == 1 ]]; then
238+
cp -r $__GeneratedIntermediate $__CrossCompIntermediatesDir
239+
fi
273240
fi
274-
275-
rm -rf "$__GeneratedIntermediateEventPipe"
276241
}
277242

278243
build_native()

clr.coreclr.props

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<FeatureEventTrace>true</FeatureEventTrace>
44
<FeatureICastable>true</FeatureICastable>
55
<FeatureManagedEtwChannels>true</FeatureManagedEtwChannels>
6+
<FeatureManagedEtw>true</FeatureManagedEtw>
7+
<FeaturePerfTracing>true</FeaturePerfTracing>
68

79
<ProfilingSupportedBuild>true</ProfilingSupportedBuild>
810
</PropertyGroup>
@@ -21,7 +23,6 @@
2123
<PropertyGroup Condition="'$(TargetsWindows)' == 'true'">
2224
<FeatureArrayStubAsIL Condition="'$(TargetArch)' != 'i386'">true</FeatureArrayStubAsIL>
2325
<FeatureMulticastStubAsIL Condition="'$(TargetArch)' != 'i386'">true</FeatureMulticastStubAsIL>
24-
<FeatureManagedEtw>true</FeatureManagedEtw>
2526
<FeatureStubsAsIL Condition="'$(TargetArch)' == 'arm64'">true</FeatureStubsAsIL>
2627
<FeatureUseLcid>true</FeatureUseLcid>
2728
<FeatureCominterop>true</FeatureCominterop>
@@ -32,9 +33,4 @@
3233
<FeatureAppX>true</FeatureAppX>
3334
<FeatureWin32Registry>true</FeatureWin32Registry>
3435
</PropertyGroup>
35-
36-
<PropertyGroup Condition="'$(TargetsLinux)' == 'true'">
37-
<FeatureManagedEtw>true</FeatureManagedEtw>
38-
<FeaturePerfTracing>true</FeaturePerfTracing>
39-
</PropertyGroup>
40-
</Project>
36+
</Project>

clr.defines.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<DefineConstants Condition="'$(FeatureManagedEtwChannels)' == 'true'">$(DefineConstants);FEATURE_MANAGED_ETW_CHANNELS</DefineConstants>
2121
<DefineConstants Condition="'$(FeaturePal)' == 'true'">$(DefineConstants);FEATURE_PAL</DefineConstants>
2222
<DefineConstants Condition="'$(FeaturePerfTracing)' == 'true'">$(DefineConstants);FEATURE_PERFTRACING</DefineConstants>
23+
<DefineConstants Condition="'$(FeatureEventTrace)' == 'true'">$(DefineConstants);FEATURE_EVENT_TRACE</DefineConstants>
2324
<DefineConstants Condition="'$(FeatureXplatEventSource)' == 'true'">$(DefineConstants);FEATURE_EVENTSOURCE_XPLAT</DefineConstants>
2425
<DefineConstants Condition="'$(FeatureUseLcid)' == 'true'">$(DefineConstants);FEATURE_USE_LCID</DefineConstants>
2526
<DefineConstants Condition="'$(FeatureWin32Registry)' == 'true'">$(DefineConstants);FEATURE_WIN32_REGISTRY</DefineConstants>

clrdefinitions.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ if(FEATURE_DBGIPC)
125125
endif(FEATURE_DBGIPC)
126126
if(FEATURE_EVENT_TRACE)
127127
add_definitions(-DFEATURE_EVENT_TRACE=1)
128+
add_definitions(-DFEATURE_PERFTRACING=1)
128129
endif(FEATURE_EVENT_TRACE)
129130
if(FEATURE_GDBJIT)
130131
add_definitions(-DFEATURE_GDBJIT)
@@ -138,9 +139,6 @@ endif(FEATURE_GDBJIT_LANGID_CS)
138139
if(FEATURE_GDBJIT_SYMTAB)
139140
add_definitions(-DFEATURE_GDBJIT_SYMTAB)
140141
endif(FEATURE_GDBJIT_SYMTAB)
141-
if(CLR_CMAKE_PLATFORM_LINUX)
142-
add_definitions(-DFEATURE_PERFTRACING)
143-
endif(CLR_CMAKE_PLATFORM_LINUX)
144142
if(CLR_CMAKE_PLATFORM_UNIX)
145143
add_definitions(-DFEATURE_EVENTSOURCE_XPLAT=1)
146144
endif(CLR_CMAKE_PLATFORM_UNIX)

clrfeatures.cmake

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,13 @@ if(CLR_CMAKE_TARGET_TIZEN_LINUX)
33
endif()
44

55
if(NOT DEFINED FEATURE_EVENT_TRACE)
6-
if (WIN32)
7-
set(FEATURE_EVENT_TRACE 1)
8-
endif()
9-
10-
if(CLR_CMAKE_PLATFORM_LINUX)
11-
if(CLR_CMAKE_TARGET_TIZEN_LINUX)
12-
set(FEATURE_EVENT_TRACE 1)
13-
elseif(CLR_CMAKE_TARGET_ARCH_AMD64)
14-
set(FEATURE_EVENT_TRACE 1)
15-
elseif(CLR_CMAKE_TARGET_ARCH_ARM)
16-
set(FEATURE_EVENT_TRACE 1)
17-
elseif(CLR_CMAKE_TARGET_ARCH_ARM64)
18-
set(FEATURE_EVENT_TRACE 1)
19-
endif()
20-
endif(CLR_CMAKE_PLATFORM_LINUX)
6+
set(FEATURE_EVENT_TRACE 1)
217
endif(NOT DEFINED FEATURE_EVENT_TRACE)
228

9+
if(NOT DEFINED FEATURE_PERFTRACING AND FEATURE_EVENT_TRACE)
10+
set(FEATURE_PERFTRACING 1)
11+
endif(NOT DEFINED FEATURE_PERFTRACING AND FEATURE_EVENT_TRACE)
12+
2313
if(NOT DEFINED FEATURE_DBGIPC)
2414
if(CLR_CMAKE_PLATFORM_UNIX AND (NOT CLR_CMAKE_PLATFORM_ANDROID))
2515
set(FEATURE_DBGIPC 1)

dependencies.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<XunitPackageVersion>2.2.0-beta2-build3300</XunitPackageVersion>
3939
<XunitConsoleNetcorePackageVersion>1.0.2-prerelease-00177</XunitConsoleNetcorePackageVersion>
4040
<XunitPerformanceApiPackageVersion>1.0.0-beta-build0012</XunitPerformanceApiPackageVersion>
41-
<MicrosoftDiagnosticsTracingTraceEventPackageVersion>1.0.3-alpha-experimental</MicrosoftDiagnosticsTracingTraceEventPackageVersion>
41+
<MicrosoftDiagnosticsTracingTraceEventPackageVersion>2.0.2</MicrosoftDiagnosticsTracingTraceEventPackageVersion>
4242
<VCRuntimeVersion>1.2.0</VCRuntimeVersion>
4343
</PropertyGroup>
4444

0 commit comments

Comments
 (0)