diff options
author | Ben Adams <thundercat@illyriad.co.uk> | 2019-06-26 14:55:14 +0200 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2019-06-26 05:55:13 -0700 |
commit | 3063e668d045d5bc2fbdbbc99e68fac0d771190e (patch) | |
tree | d723ca46f2b0121a3ef127bb27b5ce940f3aa85b /src | |
parent | d9d31e6b03758abdd1621cf9da6fdd35b778a6fa (diff) | |
download | coreclr-3063e668d045d5bc2fbdbbc99e68fac0d771190e.tar.gz coreclr-3063e668d045d5bc2fbdbbc99e68fac0d771190e.tar.bz2 coreclr-3063e668d045d5bc2fbdbbc99e68fac0d771190e.zip |
Don't show AggressiveInlining items in exception stacks (#25408)
Diffstat (limited to 'src')
5 files changed, 26 insertions, 8 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/StackTrace.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/StackTrace.cs index 8365c48200..3855a5c6de 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/StackTrace.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/StackTrace.cs @@ -339,7 +339,32 @@ namespace System.Diagnostics private static bool ShowInStackTrace(MethodBase mb) { Debug.Assert(mb != null); - return !(mb.IsDefined(typeof(StackTraceHiddenAttribute)) || (mb.DeclaringType?.IsDefined(typeof(StackTraceHiddenAttribute)) ?? false)); + + if (mb.MethodImplementationFlags.HasFlag(MethodImplAttributes.AggressiveInlining)) + { + // Aggressive Inlines won't normally show in the StackTrace; however for Tier0 Jit and + // cross-assembly AoT/R2R these inlines will be blocked until Tier1 Jit re-Jits + // them when they will inline. We don't show them in the StackTrace to bring consitency + // between this first-pass asm and fully optimized asm. + return false; + } + + if (mb.IsDefined(typeof(StackTraceHiddenAttribute), inherit: false)) + { + // Don't show where StackTraceHidden is applied to the method. + return false; + } + + Type? declaringType = mb.DeclaringType; + // Methods don't always have containing types, for example dynamic RefEmit generated methods. + if (declaringType != null && + declaringType.IsDefined(typeof(StackTraceHiddenAttribute), inherit: false)) + { + // Don't show where StackTraceHidden is applied to the containing Type of the method. + return false; + } + + return true; } private static bool TryResolveStateMachineMethod(ref MethodBase method, out Type declaringType) diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs index 9a153ae767..f3b63c56e6 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs @@ -51,7 +51,6 @@ namespace System.Runtime.CompilerServices /// <summary>Gets the result of the ValueTask.</summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] - [StackTraceHidden] public void GetResult() => _value.ThrowIfCompletedUnsuccessfully(); /// <summary>Schedules the continuation action for the <see cref="ConfiguredValueTaskAwaitable"/>.</summary> @@ -157,7 +156,6 @@ namespace System.Runtime.CompilerServices /// <summary>Gets the result of the ValueTask.</summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] - [StackTraceHidden] public TResult GetResult() => _value.Result; /// <summary>Schedules the continuation action for the <see cref="ConfiguredValueTaskAwaitable{TResult}"/>.</summary> diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs index d7bc41b278..db63f7f5fd 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs @@ -43,7 +43,6 @@ namespace System.Runtime.CompilerServices } /// <summary>Gets the result of the ValueTask.</summary> - [StackTraceHidden] [MethodImpl(MethodImplOptions.AggressiveInlining)] public void GetResult() => _value.ThrowIfCompletedUnsuccessfully(); @@ -126,7 +125,6 @@ namespace System.Runtime.CompilerServices } /// <summary>Gets the result of the ValueTask.</summary> - [StackTraceHidden] [MethodImpl(MethodImplOptions.AggressiveInlining)] public TResult GetResult() => _value.Result; diff --git a/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs b/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs index 75c6fd9a32..cfb8040296 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs @@ -350,7 +350,6 @@ namespace System.Threading.Tasks /// <summary>Throws the exception that caused the <see cref="ValueTask"/> to fail. If it completed successfully, nothing is thrown.</summary> [MethodImpl(MethodImplOptions.AggressiveInlining)] - [StackTraceHidden] internal void ThrowIfCompletedUnsuccessfully() { object? obj = _obj; diff --git a/src/System.Private.CoreLib/src/System/Utf8String.Manipulation.cs b/src/System.Private.CoreLib/src/System/Utf8String.Manipulation.cs index 6fcdf17a26..bd71883fd7 100644 --- a/src/System.Private.CoreLib/src/System/Utf8String.Manipulation.cs +++ b/src/System.Private.CoreLib/src/System/Utf8String.Manipulation.cs @@ -82,8 +82,6 @@ namespace System [ComponentModel.EditorBrowsable(ComponentModel.EditorBrowsableState.Never)] public Utf8String Slice(int startIndex, int length) => Substring(startIndex, length); - - [StackTraceHidden] [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ValidateStartIndexAndLength(int startIndex, int length) { |