Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BETA/TraceNetwork.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Param(
@{
# The configuration files define the data tabs in the WPA viewer.
# https://learn.microsoft.com/en-us/windows-hardware/test/wpt/view-profiles
ViewerConfig = "..\WPAP\BasicInfo.wpaProfile", "..\WPAP\EdgeRegions.wpaProfile", ".\WPAP\Network.wpaProfile"
ViewerConfig = "..\WPAP\BasicInfo.wpaProfile", ".\WPAP\Network.wpaProfile"

# The trace file name is: <InstanceName>.etl
TraceName = $TraceParams.InstanceName
Expand Down
9 changes: 9 additions & 0 deletions src/NetBlame/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@

# IDE0024: Use block body for operators
csharp_style_expression_bodied_operators = false:silent

# Flag methods that can be static as warnings
# dotnet_diagnostic.CA1822.severity = warning

# Require 'this.' for methods and show a warning if it is missing
# dotnet_style_qualification_for_method = true:warning
# dotnet_style_qualification_for_field = true:warning
# dotnet_style_qualification_for_property = true:warning

41 changes: 30 additions & 11 deletions src/NetBlame/Auxiliary/CallStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Office Idle Manager
namespace NetBlameCustomDataSource.Stack
{
static class PID { public const IDVal Unknown = -1; } // Process ID
static class TID { public const IDVal Unknown = -1; } // Thrread ID
static class TID { public const IDVal Unknown = -1; } // Thread ID
static class PROC { public const IDVal Unknown = -1; } // Processor ID

public class MyStackSnapshot : IStackSnapshot
Expand Down Expand Up @@ -344,7 +344,11 @@ protected static bool IsEmpty(MyStackSnapshot stack)
return Array.TrueForAll(stack.rgStack, s => s?.Frames == null);
}

public bool IsNull(IStackSnapshot stack) => IsEmpty((MyStackSnapshot)stack);
public bool IsNull(IStackSnapshot stack)
{
MyStackSnapshot myStack = stack as MyStackSnapshot;
return (myStack != null) ? IsEmpty(myStack) : GetFrameCount(stack) == 0;
}

protected static int CountAll(MyStackSnapshot stack) => stack?.rgStack?.Length ?? 0;

Expand Down Expand Up @@ -394,11 +398,18 @@ public string _GetValue(IStackSnapshot stack, in MyStackSnapshot.Attributes attr
// Invoked for Last Stack
public int GetCount(IStackSnapshot stack)
{
MyStackSnapshot myStack = (MyStackSnapshot)stack;
MyStackSnapshot myStack = stack as MyStackSnapshot;

AssertCritical(myStack?.StackLast == null || Equals(stack, myStack.StackLast));
if (myStack != null)
{
AssertCritical(myStack.StackLast == null || Equals(stack, myStack.StackLast));

if (IsEmpty(myStack)) return 0;
if (IsEmpty(myStack)) return 0;
}
else
{
if (GetFrameCount(stack) == 0) return 0;
}

int count = _GetCount(stack);
#if StackTitle
Expand All @@ -410,17 +421,27 @@ public int GetCount(IStackSnapshot stack)
return count;
}

static readonly MyStackSnapshot.Attributes s_attrib = default;

// Invoked for Last Stack
public string GetValue(IStackSnapshot stack, int index)
{
MyStackSnapshot myStack = (MyStackSnapshot)stack;
MyStackSnapshot myStack = stack as MyStackSnapshot;

AssertCritical(myStack?.StackLast == null || Equals(stack, myStack.StackLast));
if (myStack != null)
{
AssertCritical(myStack.StackLast == null || Equals(stack, myStack.StackLast));

if (IsEmpty(myStack)) return PastEndValue;
if (IsEmpty(myStack)) return PastEndValue;

return _GetValue(stack, in ((MyStackSnapshot)stack).rgAttrib[^1], index);
return _GetValue(stack, in myStack.rgAttrib[^1], index);
}
else
{
if (GetFrameCount(stack) == 0) return PastEndValue;

return _GetValue(stack, in s_attrib, index);
}
}


Expand Down Expand Up @@ -666,8 +687,6 @@ public FullStackSnapshotAccessProvider(SymLoadProgress _symLoadProgress) : base(

public new string GetValue(IStackSnapshot stack, int index)
{
AssertImportant(stack != null);

MyStackSnapshot myStack = (MyStackSnapshot)stack;

if (IsEmpty(myStack)) return PastEndValue;
Expand Down
12 changes: 9 additions & 3 deletions src/NetBlame/Auxiliary/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ public static class Extensions

public static string ToGraphable(this IPAddress ipAddr) => ipAddr?.ToString() ?? String.Empty;

public static string ToGraphable(this IPEndPoint ipEndPoint) => !ipEndPoint.Empty() ? ipEndPoint.ToString() : String.Empty;
public static string AddrGraphable(this IPEndPoint ipEndPoint) => !ipEndPoint.Empty() ? ipEndPoint.Address.ToString() : String.Empty;
public static string ToGraphable(this IPEndPoint ipEndPoint) => !ipEndPoint.Empty() ? ((ipEndPoint.Port != 0) ? ipEndPoint.ToString() : ipEndPoint.AddrGraphable()) : String.Empty;
public static string AddrGraphable(this IPEndPoint ipEndPoint) => !(ipEndPoint?.Address).Empty() ? ipEndPoint.Address.ToString() : String.Empty;
public static uint PortGraphable(this IPEndPoint ipEndPoint) => (uint?)ipEndPoint?.Port ?? 0;

public static string ToStringOrBlank(this ushort val) => (val > 0) ? val.ToString() : string.Empty;
public static string ToStringOrBlank(this ushort? val) => (val > 0) ? val.ToString() : string.Empty;
public static string ToHexOrBlank(this uint val) => (val > 0) ? val.ToString("X") : string.Empty;

public static bool Empty(this SocketAddress socket) => (socket == null || socket[0]/*family*/ == 0);

// SocketAddress.Equals may give false negatives when the socket contains random padding bytes!
Expand Down Expand Up @@ -111,6 +115,8 @@ public static bool IsAddrZero(this SocketAddress socket)

public static SocketAddress GetRemoteAddress(this IGenericEvent evt) => (evt.GetUInt32("RemoteAddressLength") != 0) ? evt.GetSocketAddress("RemoteAddress") : null;

public static bool Contains(this ReadOnlySpan<char> span, string substr) => span.IndexOf(substr) >= 0;

// Simple hash of all addresses in the stack. Returns 0 if none.
public static int Hash(this IStackSnapshot ss)
{
Expand All @@ -122,6 +128,6 @@ public static int Hash(this IStackSnapshot ss)

return hash;
}
}
} // Extensions

} // NetBlameCustomDataSource.Events
Loading