diff --git a/src/coreclr/vm/datadescriptor/datadescriptor.inc b/src/coreclr/vm/datadescriptor/datadescriptor.inc index 85d6df4ecaa043..bd2969438a8433 100644 --- a/src/coreclr/vm/datadescriptor/datadescriptor.inc +++ b/src/coreclr/vm/datadescriptor/datadescriptor.inc @@ -989,10 +989,21 @@ CDAC_TYPES_END() CDAC_GLOBALS_BEGIN() -#if defined(TARGET_UNIX) -CDAC_GLOBAL_STRING(OperatingSystem, unix) +#if defined(TARGET_BROWSER) +#ifdef Browser +#error Handle 'Browser' define +#endif // Browser +CDAC_GLOBAL_STRING(OperatingSystem, Browser) +#elif defined(TARGET_UNIX) +#ifdef Unix +#error Handle 'Unix' define +#endif // Unix +CDAC_GLOBAL_STRING(OperatingSystem, Unix) #elif defined(TARGET_WINDOWS) -CDAC_GLOBAL_STRING(OperatingSystem, windows) +#ifdef Windows +#error Handle 'Windows' define +#endif // Windows +CDAC_GLOBAL_STRING(OperatingSystem, Windows) #else #error TARGET_{OS} define is not recognized by the cDAC. Update this switch and the enum values in IRuntimeInfo.cs #endif diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeInfo.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeInfo.cs index 31e80c9ddc5430..99d4f1fb6dd3b9 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeInfo.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeInfo.cs @@ -26,6 +26,7 @@ public enum RuntimeInfoOperatingSystem : uint Unknown = 0, Windows, Unix, + Browser, } public interface IRuntimeInfo : IContract diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/AMD64/AMD64Unwinder.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/AMD64/AMD64Unwinder.cs index 404504cd79335a..53b3a5bf106e9b 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/AMD64/AMD64Unwinder.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/AMD64/AMD64Unwinder.cs @@ -31,7 +31,7 @@ internal class AMD64Unwinder(Target target) private readonly Target _target = target; private readonly IExecutionManager _eman = target.Contracts.ExecutionManager; - private readonly bool _unix = target.Contracts.RuntimeInfo.GetTargetOperatingSystem() == RuntimeInfoOperatingSystem.Unix; + private readonly bool _unixAMD64ABI = target.Contracts.RuntimeInfo.GetTargetOperatingSystem() != RuntimeInfoOperatingSystem.Windows; public bool Unwind(ref AMD64Context context) { @@ -97,7 +97,7 @@ public bool Unwind(ref AMD64Context context) { frameOffset = unwindInfo.FrameOffset; - if (_unix) + if (_unixAMD64ABI) { // If UnwindInfo->FrameOffset == 15 (the maximum value), then there might be a UWOP_SET_FPREG_LARGE. // However, it is still legal for a UWOP_SET_FPREG to set UnwindInfo->FrameOffset == 15 (since this @@ -133,7 +133,7 @@ public bool Unwind(ref AMD64Context context) unwindOp = GetUnwindCode(unwindInfo, index); if (unwindOp.UnwindOp == UnwindCode.OpCodes.UWOP_SET_FPREG) break; - if (_unix) + if (_unixAMD64ABI) { if (unwindOp.UnwindOp == UnwindCode.OpCodes.UWOP_SET_FPREG_LARGE) { @@ -835,7 +835,7 @@ private bool UnwindPrologue( UnwindCode unwindOp = GetUnwindCode(unwindInfo, index); - if (_unix) + if (_unixAMD64ABI) { if (unwindOp.UnwindOp > UnwindCode.OpCodes.UWOP_SET_FPREG_LARGE) { @@ -845,7 +845,8 @@ private bool UnwindPrologue( } else { - if (unwindOp.UnwindOp == UnwindCode.OpCodes.UWOP_SET_FPREG_LARGE) + Debug.Assert(_target.Contracts.RuntimeInfo.GetTargetOperatingSystem() == RuntimeInfoOperatingSystem.Windows); + if (unwindOp.UnwindOp > UnwindCode.OpCodes.UWOP_PUSH_MACHFRAME) { Debug.Fail("Expected unwind code"); return false; @@ -929,7 +930,7 @@ private bool UnwindPrologue( // case UnwindCode.OpCodes.UWOP_SET_FPREG_LARGE: { - UnwinderAssert(_unix); + UnwinderAssert(_unixAMD64ABI); UnwinderAssert(unwindInfo.FrameOffset == 15); uint frameOffset = GetUnwindCode(unwindInfo, index + 1).FrameOffset; frameOffset += (uint)(GetUnwindCode(unwindInfo, index + 2).FrameOffset << 16); diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/X86/X86Unwinder.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/X86/X86Unwinder.cs index 0b90ec428403fd..547f4c104c390e 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/X86/X86Unwinder.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/X86/X86Unwinder.cs @@ -34,7 +34,7 @@ public class X86Unwinder(Target target) private readonly Target _target = target; private readonly uint _pointerSize = (uint)target.PointerSize; private readonly bool _updateAllRegs = true; - private readonly bool _unixX86ABI = target.Contracts.RuntimeInfo.GetTargetOperatingSystem() == RuntimeInfoOperatingSystem.Unix; + private readonly bool _unixX86ABI = target.Contracts.RuntimeInfo.GetTargetOperatingSystem() != RuntimeInfoOperatingSystem.Windows; private static readonly RegMask[] registerOrder = [ diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs index dd385161312b2d..4ac39286bb3dad 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs @@ -589,9 +589,10 @@ int ISOSDacInterface.GetClrWatsonBuckets(ClrDataAddress thread, void* pGenericMo byte[] buckets = Array.Empty(); try { - if (_target.Contracts.RuntimeInfo.GetTargetOperatingSystem() == RuntimeInfoOperatingSystem.Unix) + if (_target.Contracts.RuntimeInfo.GetTargetOperatingSystem() != RuntimeInfoOperatingSystem.Windows) throw Marshal.GetExceptionForHR(HResults.E_FAIL)!; - else if (thread == 0 || pGenericModeBlock == null) + + if (thread == 0 || pGenericModeBlock == null) throw new ArgumentException(); buckets = threadContract.GetWatsonBuckets(thread.ToTargetPointer(_target));