Skip to content

Commit b9608c9

Browse files
committed
deps: update clrmd version
1 parent 47a6b03 commit b9608c9

2 files changed

Lines changed: 17 additions & 30 deletions

File tree

src/BenchmarkDotNet/BenchmarkDotNet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<PackageReference Include="deniszykov.WebSocketListener" Version="4.2.19" />
2828
<PackageReference Include="Gee.External.Capstone" Version="2.3.0" />
2929
<PackageReference Include="Iced" Version="1.21.0" />
30-
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="3.1.512801" />
30+
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="4.0.0-beta.26203.1" />
3131
<PackageReference Include="Perfolizer" Version="[0.6.6]" />
3232
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.30" PrivateAssets="contentfiles;analyzers" />
3333
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />

src/BenchmarkDotNet/Disassemblers/ClrMdDisassembler.cs

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using BenchmarkDotNet.Detectors;
1+
using BenchmarkDotNet.Detectors;
22
using BenchmarkDotNet.Diagnosers;
33
using BenchmarkDotNet.Extensions;
44
using BenchmarkDotNet.Filters;
@@ -41,41 +41,36 @@ private static bool IsValidAddress(ulong address)
4141

4242
private DataTarget Attach(int processId)
4343
{
44+
var dataTargetOptions = new DataTargetOptions
45+
{
46+
SymbolPaths = ["https://msdl.microsoft.com/download/symbols"],
47+
// TODO: Configure DataTargetLimits default values
48+
};
49+
50+
// Ensure symbol cache directory exists https://github.com/microsoft/clrmd/issues/1417
51+
Directory.CreateDirectory(dataTargetOptions.SymbolCachePath);
52+
4453
bool isSelf = processId == System.Diagnostics.Process.GetCurrentProcess().Id;
4554
if (OsDetector.IsWindows())
4655
{
4756
// Windows CoreCLR fails to disassemble generic types when using CreateSnapshotAndAttach, and succeeds with AttachToProcess. https://github.com/microsoft/clrmd/issues/1334
4857
return isSelf && !RuntimeInformation.IsNetCore
49-
? DataTarget.CreateSnapshotAndAttach(processId)
50-
: DataTarget.AttachToProcess(processId, suspend: false);
58+
? DataTarget.CreateSnapshotAndAttach(processId, dataTargetOptions)
59+
: DataTarget.AttachToProcess(processId, suspend: false, dataTargetOptions);
5160
}
5261
if (OsDetector.IsLinux())
5362
{
5463
// Linux crashes when using AttachToProcess in the same process.
64+
// It seems not fixed by https://github.com/microsoft/clrmd/issues/1282
5565
return isSelf
5666
? DataTarget.CreateSnapshotAndAttach(processId)
5767
: DataTarget.AttachToProcess(processId, suspend: false);
5868
}
5969
if (OsDetector.IsMacOS())
6070
{
61-
// ClrMD does not support CreateSnapshotAndAttach on MacOS, and AttachToProcess is unreliable, so we have to create a dump file and load it.
62-
string dumpPath = Path.GetTempFileName();
63-
try
64-
{
65-
try
66-
{
67-
new DiagnosticsClient(processId).WriteDump(DumpType.Full, dumpPath, logDumpGeneration: false);
68-
}
69-
catch (ServerErrorException sxe)
70-
{
71-
throw new ArgumentException($"Unable to create a snapshot of process {processId:x}.", sxe);
72-
}
73-
return DataTarget.LoadDump(dumpPath);
74-
}
75-
finally
76-
{
77-
File.Delete(dumpPath);
78-
}
71+
// On macOS it need to use CreateSnapshotAndAttach API instead of AttachToProcess.
72+
// https://github.com/microsoft/clrmd/issues/1034
73+
return DataTarget.CreateSnapshotAndAttach(processId, dataTargetOptions);
7974
}
8075
throw new NotSupportedException($"{System.Runtime.InteropServices.RuntimeInformation.OSDescription} is not supported");
8176
}
@@ -86,8 +81,6 @@ internal DisassemblyResult AttachAndDisassemble(ClrMdArgs args)
8681

8782
var runtime = dataTarget.ClrVersions.Single().CreateRuntime();
8883

89-
ConfigureSymbols(dataTarget);
90-
9184
var state = new State(runtime, args.TargetFrameworkMoniker);
9285

9386
if (args.Filters.Length > 0)
@@ -120,12 +113,6 @@ internal DisassemblyResult AttachAndDisassemble(ClrMdArgs args)
120113
};
121114
}
122115

123-
private static void ConfigureSymbols(DataTarget dataTarget)
124-
{
125-
// code copied from https://github.com/Microsoft/clrmd/issues/34#issuecomment-161926535
126-
dataTarget.SetSymbolPath("http://msdl.microsoft.com/download/symbols");
127-
}
128-
129116
private static void FilterAndEnqueue(State state, ClrMdArgs args)
130117
{
131118
Regex[] filters = GlobFilter.ToRegex(args.Filters);

0 commit comments

Comments
 (0)