diff --git a/.gitignore b/.gitignore index 26ffb182c7ca..40ed75e7de35 100644 --- a/.gitignore +++ b/.gitignore @@ -333,6 +333,15 @@ tracer/src/Datadog.Trace.ClrProfiler.Native/Makefile tracer/src/Datadog.Trace.ClrProfiler.Native/CMakeCache.txt tracer/src/Datadog.Trace.ClrProfiler.Native/cmake_install.cmake !tracer/src/Datadog.Trace.ClrProfiler.Native/lib/** +tracer/src/Datadog.AutoInstrumentation.NativeLoader/build/ +tracer/src/Datadog.AutoInstrumentation.NativeLoader/deps/ +tracer/src/Datadog.AutoInstrumentation.NativeLoader/CMakeFiles/ +tracer/src/Datadog.AutoInstrumentation.NativeLoader/tmp.* +tracer/src/Datadog.AutoInstrumentation.NativeLoader/Makefile +tracer/src/Datadog.AutoInstrumentation.NativeLoader/CMakeCache.txt +tracer/src/Datadog.AutoInstrumentation.NativeLoader/cmake_install.cmake +tracer/src/Datadog.AutoInstrumentation.NativeLoader/cmake-build-debug/ +!tracer/src/Datadog.AutoInstrumentation.NativeLoader/lib/** profiler/_build/ .ionide/ diff --git a/tracer/README.MD b/tracer/README.MD index 427391d15855..13e0114e06bf 100644 --- a/tracer/README.MD +++ b/tracer/README.MD @@ -102,7 +102,10 @@ You can use Rider and CLion to develop on macOS. Building and testing can be don .\build.sh PackageTracerHome # Build and run integration tests. Requires BuildTracerHome to have previously been run -.\build.sh BuildAndRunIntegrationTests +.\build.sh BuildAndRunLinuxIntegrationTests + +# Build and run integration tests filtering on one framework, one set of tests and a sample app. +.\build.sh BuildAndRunLinuxIntegrationTests --framework "net6.0" --filter "rabbit" --SampleName "Samples.Rabbit" ``` ## Additional Technical Documentation diff --git a/tracer/build/_build/Build.Shared.Steps.cs b/tracer/build/_build/Build.Shared.Steps.cs index f8bebb54ec91..06a00ecb671d 100644 --- a/tracer/build/_build/Build.Shared.Steps.cs +++ b/tracer/build/_build/Build.Shared.Steps.cs @@ -14,7 +14,8 @@ partial class Build .Unlisted() .Description("Compiles the native loader") .DependsOn(CompileNativeLoaderWindows) - .DependsOn(CompileNativeLoaderLinux); + .DependsOn(CompileNativeLoaderLinux) + .DependsOn(CompileNativeLoaderOsx); Target CompileNativeLoaderWindows => _ => _ .Unlisted() @@ -53,10 +54,22 @@ partial class Build Make.Value(workingDirectory: buildDirectory); }); + Target CompileNativeLoaderOsx => _ => _ + .Unlisted() + .After(CompileProfilerManagedSrc) + .OnlyWhenStatic(() => IsOsx) + .Executes(() => + { + var buildDirectory = NativeLoaderProject.Directory; + CMake.Value(arguments: ".", workingDirectory: buildDirectory); + Make.Value(workingDirectory: buildDirectory); + }); + Target PublishNativeLoader => _ => _ .Unlisted() .DependsOn(PublishNativeLoaderWindows) - .DependsOn(PublishNativeLoaderLinux); + .DependsOn(PublishNativeLoaderLinux) + .DependsOn(PublishNativeLoaderOsx); Target PublishNativeLoaderWindows => _ => _ .Unlisted() @@ -113,4 +126,23 @@ partial class Build CopyFileToDirectory(source, dest, FileExistsPolicy.Overwrite); }); + Target PublishNativeLoaderOsx=> _ => _ + .Unlisted() + .OnlyWhenStatic(() => IsOsx) + .After(CompileNativeLoader) + .Executes(() => + { + // Copy native loader assets + var source = NativeLoaderProject.Directory / "bin" / "loader.conf"; + var dest = MonitoringHomeDirectory; + Logger.Info($"Copying '{source}' to '{dest}'"); + CopyFileToDirectory(source, dest, FileExistsPolicy.Overwrite); + + source = NativeLoaderProject.Directory / "bin" / + $"{NativeLoaderProject.Name}.dylib"; + dest = MonitoringHomeDirectory; + Logger.Info($"Copying file '{source}' to 'file {dest}'"); + CopyFileToDirectory(source, dest, FileExistsPolicy.Overwrite); + }); + } diff --git a/tracer/src/Datadog.AutoInstrumentation.NativeLoader/CMakeLists.txt b/tracer/src/Datadog.AutoInstrumentation.NativeLoader/CMakeLists.txt index f8abfd550264..0f83c8d7ed42 100644 --- a/tracer/src/Datadog.AutoInstrumentation.NativeLoader/CMakeLists.txt +++ b/tracer/src/Datadog.AutoInstrumentation.NativeLoader/CMakeLists.txt @@ -167,6 +167,7 @@ add_library("Datadog.AutoInstrumentation.NativeLoader" SHARED dllmain.cpp dynamic_dispatcher.cpp dynamic_instance.cpp + runtimeid_store.cpp ${DOTNET_TRACER_REPO_ROOT_PATH}/shared/src/native-src/miniutf.cpp ${DOTNET_TRACER_REPO_ROOT_PATH}/shared/src/native-lib/coreclr/src/pal/prebuilt/idl/corprof_i.cpp ${DOTNET_TRACER_REPO_ROOT_PATH}/shared/src/native-src/string.cpp diff --git a/tracer/src/Datadog.AutoInstrumentation.NativeLoader/cor_profiler.cpp b/tracer/src/Datadog.AutoInstrumentation.NativeLoader/cor_profiler.cpp index 98c8d4235b49..04afd3d2e626 100644 --- a/tracer/src/Datadog.AutoInstrumentation.NativeLoader/cor_profiler.cpp +++ b/tracer/src/Datadog.AutoInstrumentation.NativeLoader/cor_profiler.cpp @@ -643,14 +643,14 @@ namespace datadog::shared::nativeloader RunInAllProfilers(ExceptionSearchCatcherFound(functionId)); } - HRESULT STDMETHODCALLTYPE CorProfiler::ExceptionOSHandlerEnter(UINT_PTR __unused) + HRESULT STDMETHODCALLTYPE CorProfiler::ExceptionOSHandlerEnter(UINT_PTR unused_variable) { - RunInAllProfilers(ExceptionOSHandlerEnter(__unused)); + RunInAllProfilers(ExceptionOSHandlerEnter(unused_variable)); } - HRESULT STDMETHODCALLTYPE CorProfiler::ExceptionOSHandlerLeave(UINT_PTR __unused) + HRESULT STDMETHODCALLTYPE CorProfiler::ExceptionOSHandlerLeave(UINT_PTR unused_variable) { - RunInAllProfilers(ExceptionOSHandlerLeave(__unused)); + RunInAllProfilers(ExceptionOSHandlerLeave(unused_variable)); } HRESULT STDMETHODCALLTYPE CorProfiler::ExceptionUnwindFunctionEnter(FunctionID functionId) diff --git a/tracer/test/Datadog.Trace.TestHelpers/EnvironmentHelper.cs b/tracer/test/Datadog.Trace.TestHelpers/EnvironmentHelper.cs index b2520a35aaa0..0bf214866a8b 100644 --- a/tracer/test/Datadog.Trace.TestHelpers/EnvironmentHelper.cs +++ b/tracer/test/Datadog.Trace.TestHelpers/EnvironmentHelper.cs @@ -139,7 +139,7 @@ public static string GetNativeLoaderPath() ("win", "X86") => "Datadog.AutoInstrumentation.NativeLoader.x86.dll", ("linux", "X64") => "Datadog.AutoInstrumentation.NativeLoader.so", ("linux", "Arm64") => "Datadog.AutoInstrumentation.NativeLoader.so", - ("osx", _) => throw new PlatformNotSupportedException("The Native Loader is not yet supported on osx"), + ("osx", _) => "Datadog.AutoInstrumentation.NativeLoader.dylib", _ => throw new PlatformNotSupportedException() };