Skip to content

Commit 78d1edb

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

File tree

2 files changed

+18
-34
lines changed

2 files changed

+18
-34
lines changed

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: 17 additions & 33 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,33 @@ 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 cache directory exists
51+
// Ensure symbol cache directory exists https://github.com/microsoft/clrmd/issues/1417
52+
Directory.CreateDirectory(dataTargetOptions.SymbolCachePath);
53+
4454
bool isSelf = processId == System.Diagnostics.Process.GetCurrentProcess().Id;
4555
if (OsDetector.IsWindows())
4656
{
4757
// Windows CoreCLR fails to disassemble generic types when using CreateSnapshotAndAttach, and succeeds with AttachToProcess. https://github.com/microsoft/clrmd/issues/1334
4858
return isSelf && !RuntimeInformation.IsNetCore
49-
? DataTarget.CreateSnapshotAndAttach(processId)
50-
: DataTarget.AttachToProcess(processId, suspend: false);
59+
? DataTarget.CreateSnapshotAndAttach(processId, dataTargetOptions)
60+
: DataTarget.AttachToProcess(processId, suspend: false, dataTargetOptions);
5161
}
5262
if (OsDetector.IsLinux())
5363
{
54-
// Linux crashes when using AttachToProcess in the same process.
55-
return isSelf
56-
? DataTarget.CreateSnapshotAndAttach(processId)
57-
: DataTarget.AttachToProcess(processId, suspend: false);
64+
return DataTarget.AttachToProcess(processId, suspend: false, dataTargetOptions);
5865
}
5966
if (OsDetector.IsMacOS())
6067
{
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-
}
68+
// On macOS it need to use CreateSnapshotAndAttach API instead of AttachToProcess.
69+
// https://github.com/microsoft/clrmd/issues/1034
70+
return DataTarget.CreateSnapshotAndAttach(processId, dataTargetOptions);
7971
}
8072
throw new NotSupportedException($"{System.Runtime.InteropServices.RuntimeInformation.OSDescription} is not supported");
8173
}
@@ -86,8 +78,6 @@ internal DisassemblyResult AttachAndDisassemble(ClrMdArgs args)
8678

8779
var runtime = dataTarget.ClrVersions.Single().CreateRuntime();
8880

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

9383
if (args.Filters.Length > 0)
@@ -120,12 +110,6 @@ internal DisassemblyResult AttachAndDisassemble(ClrMdArgs args)
120110
};
121111
}
122112

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-
129113
private static void FilterAndEnqueue(State state, ClrMdArgs args)
130114
{
131115
Regex[] filters = GlobFilter.ToRegex(args.Filters);

0 commit comments

Comments
 (0)