Skip to content

Commit

Permalink
Merge pull request #3534 from mikem8361/release/stable
Browse files Browse the repository at this point in the history
Merge main into release/stable
  • Loading branch information
mikem8361 authored Dec 2, 2022
2 parents ca25fd4 + 07e9ae8 commit bd63c2f
Show file tree
Hide file tree
Showing 86 changed files with 2,426 additions and 743 deletions.
10 changes: 10 additions & 0 deletions .config/tsaoptions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"instanceUrl": "https://devdiv.visualstudio.com/",
"template": "TFSDEVDIV",
"projectName": "DEVDIV",
"areaPath": "DevDiv\\NET Runtime\\Diagnostics\\SDL",
"iterationPath": "DevDiv",
"notificationAliases": [ "[email protected]" ],
"repositoryName": "diagnostics",
"codebaseName": "diagnostics"
}
152 changes: 152 additions & 0 deletions diagnostics-codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
parameters:
- name: runtimeFeed
displayName: Feed for runtime installation
type: string
default: default
values:
- default
- name: runtimeFeedToken
displayName: Base 64 SAS Token for runtime installation
type: string
default: default
values:
- default

trigger:
none

schedules:
- cron: 0 3 * * SUN
displayName: Weekly Sunday CodeQL run
branches:
include:
- main
always: true

variables:
# CG is handled in the primary CI pipeline
- name: skipComponentGovernanceDetection
value: true

stages:
- stage: build
displayName: Build and Test Diagnostics
jobs:
- template: /eng/build.yml
parameters:
name: Windows
osGroup: Windows_NT
isCodeQLRun: true
strategy:
matrix:
Build_Release:
_BuildConfig: Release
_BuildArch: x64
Build_Release_x86:
_BuildConfig: Release
_BuildArch: x86
Build_Release_arm:
_BuildConfig: Release
_BuildArch: arm
Build_Release_arm64:
_BuildConfig: Release
_BuildArch: arm64

- template: /eng/build.yml
parameters:
name: CentOS_7
osGroup: Linux
dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-7-3e800f1-20190501005343
isCodeQLRun: true
strategy:
matrix:
Build_Release:
_BuildConfig: Release
_BuildArch: x64

- template: /eng/build.yml
parameters:
name: Alpine3_13
osGroup: Linux
dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.13-WithNode-20210910135845-c401c85
isCodeQLRun: true
strategy:
matrix:
Build_Release:
_BuildConfig: Release
_BuildArch: x64

- template: /eng/build.yml
parameters:
name: MacOS
osGroup: MacOS
isCodeQLRun: true
strategy:
matrix:
Build_Release:
_BuildConfig: Release
_BuildArch: x64

- template: /eng/build.yml
parameters:
name: MacOS_arm64
osGroup: MacOS_cross
crossbuild: true
isCodeQLRun: true
strategy:
matrix:
Build_Release:
_BuildConfig: Release
_BuildArch: arm64

- template: /eng/build.yml
parameters:
name: Linux_arm
osGroup: Linux
dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-20210719121212-8a8d3be
crossrootfsDir: '/crossrootfs/arm'
isCodeQLRun: true
strategy:
matrix:
Build_Release:
_BuildConfig: Release
_BuildArch: arm

- template: /eng/build.yml
parameters:
name: Linux_arm64
osGroup: Linux
dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm64-20210719121212-8a8d3be
crossrootfsDir: '/crossrootfs/arm64'
isCodeQLRun: true
strategy:
matrix:
Build_Release:
_BuildConfig: Release
_BuildArch: arm64

- template: /eng/build.yml
parameters:
name: Linux_musl_arm
osGroup: Linux
dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm-alpine-20210923140502-78f7860
crossrootfsDir: '/crossrootfs/arm'
isCodeQLRun: true
strategy:
matrix:
Build_Release:
_BuildConfig: Release
_BuildArch: arm

- template: /eng/build.yml
parameters:
name: Linux_musl_arm64
osGroup: Linux
dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm64-alpine-20210923140502-78f7860
crossrootfsDir: '/crossrootfs/arm64'
isCodeQLRun: true
strategy:
matrix:
Build_Release:
_BuildConfig: Release
_BuildArch: arm64
94 changes: 45 additions & 49 deletions documentation/tutorial/src/triggerdump/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,71 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics.Tracing;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

using Microsoft.Diagnostics.Tools.RuntimeClient;
using Microsoft.Diagnostics.NETCore.Client;
using Microsoft.Diagnostics.Tracing;

namespace Microsoft.Diagnostics.Tools.Counters
{
internal class Program
{
private static ulong _sessionId;
private static int threshold;
private static int pid;

private static int pid;

private static void Main(string[] args)
{
if(args.Length<2)
if (args.Length < 2)
{
Console.WriteLine("triggerdump <pid> <mem threshold in MB>");
}
else
{
pid = Convert.ToInt32(args[0]);
threshold = Convert.ToInt32(args[1]);
pid = Convert.ToInt32(args[0]);
threshold = Convert.ToInt32(args[1]);
DiagnosticsClient diagnosticsClient = new(pid);
EventPipeSession session = null;

Task monitorTask = new Task(() =>
Task monitorTask = new Task(() =>
{
var provider = new List<EventPipeProvider>
{
var prov = new List<Provider>();
prov.Add(new Provider("System.Runtime", filterData:"EventCounterIntervalSec=1"));

var configuration = new SessionConfiguration(
circularBufferSizeMB: 1000,
outputPath: "",
providers: prov);

var binaryReader = EventPipeClient.CollectTracing(Int32.Parse(args[0]), configuration, out _sessionId);
EventPipeEventSource source = new EventPipeEventSource(binaryReader);
source.Dynamic.All += Dynamic_All;
source.Process();
});

Task commandTask = new Task(() =>
new EventPipeProvider("System.Runtime", EventLevel.Verbose,
arguments: new Dictionary<string, string> { ["EventCounterIntervalSec"] = "1" })
};

session = diagnosticsClient.StartEventPipeSession(provider, false);
EventPipeEventSource source = new(session.EventStream);
source.Dynamic.All += Dynamic_All;
source.Process();
});

Task commandTask = new Task(() =>
{
while (true)
{
while(true)
while (!Console.KeyAvailable) { }
ConsoleKey cmd = Console.ReadKey(true).Key;
if (cmd == ConsoleKey.Q)
{
while (!Console.KeyAvailable) { }
ConsoleKey cmd = Console.ReadKey(true).Key;
if (cmd == ConsoleKey.Q)
{
break;
}
break;
}
});
}
});

monitorTask.Start();
commandTask.Start();
commandTask.Wait();
monitorTask.Start();
commandTask.Start();
commandTask.Wait();

try
{
EventPipeClient.StopTracing(Int32.Parse(args[0]), _sessionId);
}
catch (System.IO.EndOfStreamException) {}
try
{
session?.Stop();
}
catch (System.IO.EndOfStreamException) { }
}
}

Expand All @@ -83,13 +79,13 @@ private static void Dynamic_All(TraceEvent obj)
IDictionary<string, object> payloadFields = (IDictionary<string, object>)(payloadVal["Payload"]);

ICounterPayload payload = payloadFields.Count == 6 ? (ICounterPayload)new IncrementingCounterPayload(payloadFields) : (ICounterPayload)new CounterPayload(payloadFields);
string displayName = payload.GetDisplay();
string displayName = payload.GetDisplay();
if (string.IsNullOrEmpty(displayName))
{
displayName = payload.GetName();
}

if(string.Compare(displayName, "GC Heap Size") == 0 && Convert.ToInt32(payload.GetValue())>threshold)
if (string.Compare(displayName, "GC Heap Size") == 0 && Convert.ToInt32(payload.GetValue()) > threshold)
{
Console.WriteLine("Memory threshold has been breached....");
System.Diagnostics.Process process = System.Diagnostics.Process.GetProcessById(pid);
Expand All @@ -107,11 +103,11 @@ private static void Dynamic_All(TraceEvent obj)
if (!File.Exists(createDumpPath))
{
Console.WriteLine("Unable to locate 'createdump' tool in '{runtimeDirectory}'");
Environment.Exit(1);
}
Environment.Exit(1);
}

var createdump = new System.Diagnostics.Process()
{
{
StartInfo = new System.Diagnostics.ProcessStartInfo()
{
FileName = createDumpPath,
Expand Down
15 changes: 4 additions & 11 deletions documentation/tutorial/src/triggerdump/triggerdump.csproj
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ToolCommandName>triggerdump</ToolCommandName>
<RootNamespace>Diagnosticv.TriggerDump</RootNamespace>
<Description>Trigger dump</Description>
<PackageTags>Diagnostic</PackageTags>
<PackageReleaseNotes>$(Description)</PackageReleaseNotes>
<TargetName>triggerdump</TargetName>
<OutputType>Exe</OutputType>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)..\..\..\..\src\Tools\dotnet-trace\Extensions.cs" Link="Extensions.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\..\..\src\Microsoft.Diagnostics.Tools.RuntimeClient\Microsoft.Diagnostics.Tools.RuntimeClient.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.41" />
<PackageReference Include="Microsoft.Diagnostics.NETCore.Client" Version="0.2.351802" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.0.5" />
</ItemGroup>
</Project>
7 changes: 6 additions & 1 deletion eng/AuxMsbuildFiles/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<Project>
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
<ItemGroup>
<KnownFrameworkReference Remove="Microsoft.WindowsDesktop.App" />
<KnownFrameworkReference Remove="Microsoft.WindowsDesktop.App.WPF" />
<KnownFrameworkReference Remove="Microsoft.WindowsDesktop.App.WindowsForms" />
</ItemGroup>
<Import Project="SdkPackOverrides.targets"/>
</Project>
</Project>
Loading

0 comments on commit bd63c2f

Please sign in to comment.