Skip to content

Commit

Permalink
Fix hook and dylib
Browse files Browse the repository at this point in the history
  • Loading branch information
xoofx committed Dec 13, 2024
1 parent 03e8a6b commit 5fcf716
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Ultra.Core/Ultra.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</PackageReference>
</ItemGroup>

<!--<ItemGroup>
<ItemGroup>
<Content Include="..\Ultra.Sampler\libUltraSampler.dylib">
<Link>libUltraSampler.dylib</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand All @@ -53,5 +53,5 @@
<Link>libUltraSamplerHook.dylib</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>-->
</ItemGroup>
</Project>
11 changes: 8 additions & 3 deletions src/Ultra.Core/UltraProfilerEventPipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Ultra.Core;
/// </summary>
internal sealed class UltraProfilerEventPipe : UltraProfiler
{
private static string PathToNativeUltraSampler => Path.Combine(AppContext.BaseDirectory, "libUltraSamplerHook.dyld");
private static string PathToNativeUltraSampler => Path.Combine(AppContext.BaseDirectory, "libUltraSamplerHook.dylib");

/// <summary>
/// Initializes a new instance of the <see cref="UltraProfiler"/> class.
Expand Down Expand Up @@ -97,11 +97,13 @@ private static void SetupUltraSampler(ProcessStartInfo startInfo)

private class UltraSamplerProfilerState
{
private readonly CancellationToken _token;
private readonly DiagnosticPortSession _samplerSession;
private readonly DiagnosticPortSession _clrSession;

public UltraSamplerProfilerState(string baseName, int pid, CancellationToken token)
{
_token = token;
_samplerSession = new(pid, true, baseName, token);
_clrSession = new(pid, false, baseName, token);
}
Expand Down Expand Up @@ -129,8 +131,11 @@ public long TotalFileLength()
public async Task StartProfiling()
{
await _samplerSession.WaitForConnectAndStartSession();

await _samplerSession.StartProfiling(_token);
await _clrSession.StartProfiling(_token);
}

public async ValueTask StopAndDisposeAsync()
{
await _samplerSession.StopAndDisposeAsync().ConfigureAwait(false);
Expand Down
Binary file added src/Ultra.Sampler/libUltraSampler.dylib
Binary file not shown.
Binary file added src/Ultra.Sampler/libUltraSamplerHook.dylib
Binary file not shown.

0 comments on commit 5fcf716

Please sign in to comment.