Skip to content

Commit 167799b

Browse files
committed
Address CR feedback
1 parent 9d2541d commit 167799b

File tree

4 files changed

+24
-37
lines changed

4 files changed

+24
-37
lines changed

src/coreclr/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,17 @@ static void NotifyOfCrossThreadDependencySlow()
5959
private static partial bool LaunchInternal();
6060

6161
// Returns whether or not a managed debugger is attached to the process.
62-
public static bool IsAttached => IsManagedDebuggerAttached();
62+
public static bool IsAttached => IsManagedDebuggerAttached() != 0;
6363

6464
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "DebugDebugger_IsManagedDebuggerAttached")]
65-
[return: MarshalAs(UnmanagedType.Bool)]
66-
private static partial bool IsManagedDebuggerAttached();
65+
[SuppressGCTransition]
66+
private static partial int IsManagedDebuggerAttached();
67+
68+
internal static bool IsAnyDebuggerAttached() => IsAnyDebuggerAttachedInternal() != 0;
6769

6870
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "DebugDebugger_IsAnyDebuggerAttached")]
69-
[return: MarshalAs(UnmanagedType.Bool)]
70-
internal static partial bool IsAnyDebuggerAttached();
71+
[SuppressGCTransition]
72+
private static partial int IsAnyDebuggerAttachedInternal();
7173

7274
// Constants representing the importance level of messages to be logged.
7375
//
@@ -88,11 +90,11 @@ static void NotifyOfCrossThreadDependencySlow()
8890
private static partial void LogInternal(int level, string? category, string? message);
8991

9092
// Checks to see if an attached debugger has logging enabled
91-
public static bool IsLogging() => IsLoggingHelper();
93+
public static bool IsLogging() => IsLoggingInternal() != 0;
9294

9395
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "DebugDebugger_IsLoggingHelper")]
94-
[return: MarshalAs(UnmanagedType.Bool)]
95-
private static partial bool IsLoggingHelper();
96+
[SuppressGCTransition]
97+
private static partial int IsLoggingInternal();
9698

9799
// Posts a custom notification for the attached debugger. If there is no
98100
// debugger attached, has no effect. The debugger may or may not

src/coreclr/nativeaot/Runtime/MiscHelpers.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ EXTERN_C int32_t QCALLTYPE RhpGetCurrentThreadStackTrace(void* pOutputBuffer, ui
397397

398398
EXTERN_C UInt32_BOOL QCALLTYPE DebugDebugger_IsAnyDebuggerAttached()
399399
{
400+
// Explicitly not checking for a managed debugger; only checking for a native debugger.
400401
return minipal_is_native_debugger_present();
401402
}
402403

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ public static bool IsLogging()
7777
return false;
7878
}
7979

80+
internal static bool IsAnyDebuggerAttached() => IsAnyDebuggerAttachedInternal() != 0;
81+
8082
[LibraryImport(RuntimeImports.RuntimeLibrary, EntryPoint = "DebugDebugger_IsAnyDebuggerAttached")]
81-
private static partial int DebugDebugger_IsAnyDebuggerAttached();
82-
internal static bool IsAnyDebuggerAttached() => DebugDebugger_IsAnyDebuggerAttached() != 0;
83+
[SuppressGCTransition]
84+
private static partial int IsAnyDebuggerAttachedInternal();
8385
}
8486
}

src/coreclr/vm/debugdebugger.cpp

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -855,56 +855,38 @@ extern "C" void QCALLTYPE DebugDebugger_CustomNotification(QCall::ObjectHandleOn
855855

856856
extern "C" BOOL QCALLTYPE DebugDebugger_IsLoggingHelper()
857857
{
858-
QCALL_CONTRACT;
859-
860-
BOOL result = FALSE;
861-
862-
BEGIN_QCALL;
858+
QCALL_CONTRACT_NO_GC_TRANSITION;
863859

864860
#ifdef DEBUGGING_SUPPORTED
865861
if (CORDebuggerAttached())
866862
{
867-
result = g_pDebugInterface->IsLoggingEnabled();
863+
return g_pDebugInterface->IsLoggingEnabled();
868864
}
869865
#endif // DEBUGGING_SUPPORTED
870866

871-
END_QCALL;
872-
873-
return result;
867+
return FALSE;
874868
}
875869

876870
extern "C" BOOL QCALLTYPE DebugDebugger_IsAnyDebuggerAttached()
877871
{
878-
QCALL_CONTRACT;
879-
880-
BOOL result = FALSE;
881-
882-
BEGIN_QCALL;
872+
QCALL_CONTRACT_NO_GC_TRANSITION;
883873

884874
#ifdef DEBUGGING_SUPPORTED
885-
result = CORDebuggerAttached() || minipal_is_native_debugger_present();
875+
return CORDebuggerAttached() || minipal_is_native_debugger_present();
886876
#endif // DEBUGGING_SUPPORTED
887877

888-
END_QCALL;
889-
890-
return result;
878+
return FALSE;
891879
}
892880

893881
extern "C" BOOL QCALLTYPE DebugDebugger_IsManagedDebuggerAttached()
894882
{
895-
QCALL_CONTRACT;
896-
897-
BOOL result = FALSE;
898-
899-
BEGIN_QCALL;
883+
QCALL_CONTRACT_NO_GC_TRANSITION;
900884

901885
#ifdef DEBUGGING_SUPPORTED
902-
result = CORDebuggerAttached();
886+
return CORDebuggerAttached();
903887
#endif
904888

905-
END_QCALL;
906-
907-
return result;
889+
return FALSE;
908890
}
909891
#endif // !DACCESS_COMPILE
910892

0 commit comments

Comments
 (0)