Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge testing/2.0 into master #400

Merged
merged 46 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
29e16a0
Clean up styles (#340)
nxtn Nov 25, 2019
937d901
Implement SuspendAndAttachToProcess on Linux (#337)
nxtn Nov 25, 2019
a385ae4
Remove legacy runtime support (#342)
leculver Nov 25, 2019
08fbfd0
Reimplement dbgeng interfaces (#343)
leculver Nov 26, 2019
3c29f61
Improve LinuxLiveDataReader (#345)
nxtn Nov 26, 2019
9d31b0e
Refactor codebase for 2.0 (#358)
leculver Dec 3, 2019
a80bf34
Target 4.7.1 instead of 4.7.2. (#361)
leculver Dec 3, 2019
f7ef046
Don't read from /proc/<pid>/mem (#351)
nxtn Dec 3, 2019
469dbfa
Fix permission parser (#357)
nxtn Dec 3, 2019
2e3ae97
Rework instance field GetValue method (#362)
leculver Dec 3, 2019
71ef649
ComponentTypeEventuallyFilledTest (#363)
leculver Dec 3, 2019
b8526e8
Fix struct field size (#364)
leculver Dec 3, 2019
8c41079
Add (skipped) test for String.Empty issue (#366)
leculver Dec 3, 2019
e11b8e4
Fields and segments (#367)
leculver Dec 3, 2019
adf8329
Clean up memory usage (#368)
leculver Dec 4, 2019
3657295
Fix NRE in PEImage.IsManaged (#370)
nxtn Dec 4, 2019
afc30c5
Implement GetFileVersion/GetVersionInfo on Linux (#349)
nxtn Dec 4, 2019
bea024c
Add max length of string reads (#371)
leculver Dec 4, 2019
32c23f1
Ensure ClrRuntime properly cleans up (#372)
leculver Dec 4, 2019
22ebc3e
Implement module and type equality (#373)
leculver Dec 5, 2019
2e329ca
Clean up styles (#356)
nxtn Dec 5, 2019
407dc69
Allow ClrMD to be used from multiple threads (#376)
leculver Dec 5, 2019
672a43a
Clean up ClrmdHeap data reading (#377)
leculver Dec 6, 2019
a04d329
Annotate for nullable reference types (#379)
nxtn Dec 6, 2019
413cb1f
Silence build warning
leculver Dec 6, 2019
726de05
Implement caching options (#383)
leculver Dec 7, 2019
920ad3a
Minor cleanups (#384)
leculver Dec 7, 2019
2597bb2
Report the object reference even when enumerating the stack even if w…
leculver Dec 7, 2019
bd8bcaf
Allow FlushCachedData to be called while enumerating the heap (#385)
leculver Dec 7, 2019
e375c4c
Fix unsynchronized IXClrDataProcess::Flush corruption (#386)
leculver Dec 7, 2019
018206b
Fix stale finalizer queue objects
leculver Dec 7, 2019
147413a
Fix stale dependent handles
leculver Dec 7, 2019
19725d9
Clean up heap initialization
leculver Dec 7, 2019
6e62f52
Stop using ConcurrentBag (#389)
leculver Dec 8, 2019
feb3b12
Various fixes (#390)
leculver Dec 8, 2019
478add5
Rewrite SymbolLocator (#392)
leculver Dec 9, 2019
e4b6109
Put GCRoot back into ClrMD (#395)
leculver Dec 9, 2019
7f6366f
Throw PlatformNotSupportedException in DataTarget (#393)
nxtn Dec 9, 2019
e04eb66
Fix tests
leculver Dec 9, 2019
f891b39
Stop using Nullable<T>.Value (#396)
nxtn Dec 9, 2019
b112f67
Update FixGenerics to work when there's no arity (#397)
leculver Dec 9, 2019
d898517
Add FileVersionInfo to PEImage (#399)
leculver Dec 9, 2019
b69ca3d
Update FXCop build
leculver Dec 9, 2019
c71bf52
Update version to 2.0
leculver Dec 9, 2019
69ed6a7
Merge branch 'testing/2.0' of github.com:Microsoft/clrmd into testing…
leculver Dec 9, 2019
a24fb81
Merge branch 'master' into testing/2.0
leculver Dec 9, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ artifacts/
*.userosscache
*.sln.docstates
*.lock.json
*.xml

# Build results
[Dd]ebug/
Expand Down
44 changes: 44 additions & 0 deletions Microsoft.Diagnostics.Runtime.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Runti
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Runtime.UnitTests", "src\Microsoft.Diagnostics.Runtime.UnitTests\Microsoft.Diagnostics.Runtime.UnitTests.csproj", "{214A7EC8-4D32-4202-8D8B-1761743EE527}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Runtime.Utilities", "src\Microsoft.Diagnostics.Runtime.Utilities\Microsoft.Diagnostics.Runtime.Utilities.csproj", "{46E0ED79-1CAD-4876-919D-A736CE47A4F6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParallelStressTest", "ParallelStressTest\ParallelStressTest.csproj", "{9440A1F6-BF51-48C0-A382-09AE99C0DC30}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -79,6 +83,46 @@ Global
{214A7EC8-4D32-4202-8D8B-1761743EE527}.Release|x64.Build.0 = Release|Any CPU
{214A7EC8-4D32-4202-8D8B-1761743EE527}.Release|x86.ActiveCfg = Release|Any CPU
{214A7EC8-4D32-4202-8D8B-1761743EE527}.Release|x86.Build.0 = Release|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Debug|Win32.ActiveCfg = Debug|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Debug|Win32.Build.0 = Debug|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Debug|x64.ActiveCfg = Debug|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Debug|x64.Build.0 = Debug|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Debug|x86.ActiveCfg = Debug|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Debug|x86.Build.0 = Debug|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Release|Any CPU.Build.0 = Release|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Release|Win32.ActiveCfg = Release|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Release|Win32.Build.0 = Release|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Release|x64.ActiveCfg = Release|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Release|x64.Build.0 = Release|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Release|x86.ActiveCfg = Release|Any CPU
{46E0ED79-1CAD-4876-919D-A736CE47A4F6}.Release|x86.Build.0 = Release|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Debug|Win32.ActiveCfg = Debug|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Debug|Win32.Build.0 = Debug|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Debug|x64.ActiveCfg = Debug|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Debug|x64.Build.0 = Debug|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Debug|x86.ActiveCfg = Debug|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Debug|x86.Build.0 = Debug|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Release|Any CPU.Build.0 = Release|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Release|Win32.ActiveCfg = Release|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Release|Win32.Build.0 = Release|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Release|x64.ActiveCfg = Release|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Release|x64.Build.0 = Release|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Release|x86.ActiveCfg = Release|Any CPU
{9440A1F6-BF51-48C0-A382-09AE99C0DC30}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 6 additions & 0 deletions ParallelStressTest/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
59 changes: 59 additions & 0 deletions ParallelStressTest/ParallelStressTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9440A1F6-BF51-48C0-A382-09AE99C0DC30}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ParallelStressTest</RootNamespace>
<AssemblyName>ParallelStressTest</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\src\Microsoft.Diagnostics.Runtime\Microsoft.Diagnostics.Runtime.csproj">
<Project>{a82126ca-23aa-41f1-8586-a5938d44d0a7}</Project>
<Name>Microsoft.Diagnostics.Runtime</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
165 changes: 165 additions & 0 deletions ParallelStressTest/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
using Microsoft.Diagnostics.Runtime;
using Microsoft.Diagnostics.Runtime.Implementation;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;

namespace ParallelStressTest
{
static class Program
{
const bool BackgroundClear = true;
const int Iterations = int.MaxValue;
const int Threads = 8;
static readonly object _sync = new object();
private static ClrObject[] _expectedObjects;
private static ClrSegment[] _segments;
private static readonly ManualResetEvent _event = new ManualResetEvent(initialState: false);

private static volatile ClrRuntime _runtimeForClearing;

static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("Must specify a crash dump to inspect.");
Environment.Exit(1);
}

using DataTarget dt = DataTarget.LoadCrashDump(args[0]);
using (ClrRuntime runtime = dt.ClrVersions.Single().CreateRuntime())
{
_expectedObjects = runtime.Heap.EnumerateObjects().ToArray();
_segments = runtime.Heap.Segments.ToArray();
}

if (BackgroundClear)
{
Thread t = new Thread(ClearThreadProc);
t.Start();
}

TimeSpan elapsed = default;
for (int i = 0; i < Iterations; i++)
{
Console.Write($"\rIteration: {i + 1:n0} {elapsed}");

dt.DataReader.FlushCachedData();
using ClrRuntime runtime = dt.ClrVersions.Single().CreateRuntime();

lock (_sync)
_runtimeForClearing = runtime;

Thread[] threads = new Thread[Threads];

for (int j = 0; j < Threads; j++)
threads[j] = CreateAndStartThread(runtime);

Stopwatch sw = new Stopwatch();
sw.Start();
_event.Set();

foreach (Thread thread in threads)
thread.Join();

sw.Stop();
elapsed = sw.Elapsed;

lock (_sync)
_runtimeForClearing = null;

_event.Reset();
}
}

private static void ClearThreadProc()
{
while (true)
{
lock (_sync)
{
if (_runtimeForClearing != null)
_runtimeForClearing.FlushCachedData();
}

Thread.Sleep(500);
}
}

private static Thread CreateAndStartThread(ClrRuntime runtime)
{
Thread t = new Thread(() => WorkerThread(runtime));
t.Start();

return t;
}

private static void WorkerThread(ClrRuntime runtime)
{
ClrmdHeap.LogHeapWalkSteps(32);

_event.WaitOne();

if (_segments.Length != runtime.Heap.Segments.Count)
{
Fail(false, $"Segment count mismatch. Expected {_segments.Length} segments, found {runtime.Heap.Segments.Count}.");
}

for (int i = 0; i < _segments.Length; i++)
if (runtime.Heap.Segments[i].FirstObject != _segments[i].FirstObject || runtime.Heap.Segments[i].CommittedEnd != _segments[i].CommittedEnd)
Fail(false, $"Segment[{i}] range [{runtime.Heap.Segments[i].FirstObject:x12}-{runtime.Heap.Segments[i].CommittedEnd:x12}], expected [{_segments[i].FirstObject:x12}-{_segments[i].CommittedEnd:x12}]");

int count = 0;
IEnumerator<ClrObject> enumerator = runtime.Heap.EnumerateObjects().GetEnumerator();
while (enumerator.MoveNext())
{
ClrObject curr = enumerator.Current;
if (curr.Address != _expectedObjects[count].Address)
Fail(true, $"Object {count} was incorrect address: Expected {_expectedObjects[count].Address:x12}, got {curr.Address:x12}");

if (curr.Type != _expectedObjects[count].Type)
Fail(true, $"Object {count} was incorrect type: Expected {_expectedObjects[count].Type.Name}, got {curr.Type?.Name ?? ""}");

count++;
}

if (count != _expectedObjects.Count())
Fail(true, $"Expected {_expectedObjects.Length:n0} objects, found {count:n0}.");
}

private static void Fail(bool printHeapSteps, string reason)
{
lock (_sync)
{
Console.WriteLine();
Console.WriteLine($"Thread {Thread.CurrentThread.ManagedThreadId:x}");
Console.WriteLine(reason);

if (printHeapSteps)
{
int i = ClrmdHeap.Step;
do
{
i = (i + 1) % ClrmdHeap.Steps.Count;
HeapWalkStep step = ClrmdHeap.Steps[i];
Console.WriteLine($"obj:{step.Address:x12} mt:{step.MethodTable:x12} base:{step.BaseSize:x8} comp:{step.ComponentSize:x8} count:{step.Count:x8}");
} while (i != ClrmdHeap.Step);
}
}

Break();
}


private static void Break()
{
if (Debugger.IsAttached)
Debugger.Break();

while (!Debugger.IsAttached)
Thread.Sleep(1000);
}
}
}
36 changes: 36 additions & 0 deletions ParallelStressTest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ParallelStressTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ParallelStressTest")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9440a1f6-bf51-48c0-a382-09ae99c0dc30")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
5 changes: 2 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- This repo version -->
<VersionPrefix>1.1.0</VersionPrefix>
<PreReleaseVersionLabel>
</PreReleaseVersionLabel>
<VersionPrefix>2.0.0</VersionPrefix>
<PreReleaseVersionLabel>beta</PreReleaseVersionLabel>
<AutoGenerateAssemblyVersion>true</AutoGenerateAssemblyVersion>
</PropertyGroup>
</Project>
3 changes: 3 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,6 @@ dotnet_diagnostic.CA1717.severity = none

# CA1060: Move pinvokes to native methods class
dotnet_diagnostic.CA1060.severity = none

# xUnit1004: Test methods should not be skipped
dotnet_diagnostic.xUnit1004.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ public NativeHeap Heap
{
get
{
if (_heap == null)
_heap = new NativeHeap(this);

_heap ??= new NativeHeap(this);
return _heap;
}
}
Expand All @@ -38,15 +36,15 @@ public NativeRuntime(ModuleInfo module, DataTarget dt, DacLibrary lib)
_dataReader = dt.DataReader;
_modules = dt.EnumerateModules().ToArray();

if (SOSNative == null)
if (SOSNative is null)
throw new ClrDiagnosticsException("Unsupported dac version.", ClrDiagnosticsExceptionKind.DacError);
}

public IReadOnlyList<NativeThread> Threads
{
get
{
if (_threads == null)
if (_threads is null)
InitThreads();

return _threads;
Expand Down Expand Up @@ -75,9 +73,9 @@ private void InitThreads()

_threads = threads.ToArray();
}

/*

internal unsafe IList<ClrRoot> EnumerateStackRoots(ClrThread thread)
{
int contextSize;
Expand Down
Loading