diff --git a/diagnostics.sln b/diagnostics.sln index ed4beeecb2..91ac02996f 100644 --- a/diagnostics.sln +++ b/diagnostics.sln @@ -155,7 +155,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "inc", "inc", "{41BDFD6D-D16 src\shared\inc\readytoruninstructionset.h = src\shared\inc\readytoruninstructionset.h src\shared\inc\regdisp.h = src\shared\inc\regdisp.h src\shared\inc\registrywrapper.h = src\shared\inc\registrywrapper.h - src\shared\inc\releaseholder.h = src\shared\inc\releaseholder.h src\shared\inc\resource.h = src\shared\inc\resource.h src\shared\inc\runtimeinfo.h = src\shared\inc\runtimeinfo.h src\shared\inc\safemath.h = src\shared\inc\safemath.h @@ -333,6 +332,26 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "minipal", "minipal", "{D9A9 src\shared\native\minipal\utils.h = src\shared\native\minipal\utils.h EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "inc", "inc", "{9E51C821-4095-4250-BD8A-2A29396DB1B4}" + ProjectSection(SolutionItems) = preProject + src\inc\corcompile.h = src\inc\corcompile.h + src\inc\ntimageex.h = src\inc\ntimageex.h + src\inc\releaseholder.h = src\inc\releaseholder.h + src\inc\stacktrace.h = src\inc\stacktrace.h + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "rt", "rt", "{D2D76252-D225-4B79-9DDB-A36867A4720E}" + ProjectSection(SolutionItems) = preProject + src\inc\rt\intsafe.h = src\inc\rt\intsafe.h + src\inc\rt\oaidl.h = src\inc\rt\oaidl.h + src\inc\rt\psapi.h = src\inc\rt\psapi.h + src\inc\rt\tchar.h = src\inc\rt\tchar.h + src\inc\rt\tlhelp32.h = src\inc\rt\tlhelp32.h + src\inc\rt\winapifamily.h = src\inc\rt\winapifamily.h + src\inc\rt\winternl.h = src\inc\rt\winternl.h + src\inc\rt\winver.h = src\inc\rt\winver.h + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Checked|Any CPU = Checked|Any CPU @@ -2365,6 +2384,8 @@ Global {06FB18BC-F4DD-4DB9-A566-551254CD1064} = {795B7A50-1B1F-406E-94E0-F9B35104EF22} {641F00F0-2693-451B-A96A-13E4E115BF0F} = {7852EDE4-93DF-4DB1-8A86-C521703811AF} {D9A91544-CDF8-4C68-BAD2-47F4968A8652} = {641F00F0-2693-451B-A96A-13E4E115BF0F} + {9E51C821-4095-4250-BD8A-2A29396DB1B4} = {19FAB78C-3351-4911-8F0C-8C6056401740} + {D2D76252-D225-4B79-9DDB-A36867A4720E} = {9E51C821-4095-4250-BD8A-2A29396DB1B4} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {46465737-C938-44FC-BE1A-4CE139EBB5E0} diff --git a/eng/Versions.props b/eng/Versions.props index c1ed9f0a17..bfec6d92c3 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -56,7 +56,7 @@ 10.0.0-beta.24463.4 1.2.0-beta.406 7.0.0-beta.22316.2 - 10.0.18362 + 10.0.26100.1 13.0.1 10.0.0-alpha.1.24467.1 diff --git a/src/SOS/CMakeLists.txt b/src/SOS/CMakeLists.txt index ddee23f624..e1de7aff33 100644 --- a/src/SOS/CMakeLists.txt +++ b/src/SOS/CMakeLists.txt @@ -14,9 +14,9 @@ if(CLR_CMAKE_HOST_WIN32) add_compile_options(/Zl) # omit default library name in .OBJ add_subdirectory(runcommand) - if(NOT CLR_CMAKE_TARGET_ARCH_ARM64 AND NOT CLR_CMAKE_TARGET_ARCH_ARM) + if(NOT CLR_CMAKE_TARGET_ARCH_ARM) add_subdirectory(SOS.UnitTests/Debuggees/DesktopClrHost) - endif(NOT CLR_CMAKE_TARGET_ARCH_ARM64 AND NOT CLR_CMAKE_TARGET_ARCH_ARM) + endif(NOT CLR_CMAKE_TARGET_ARCH_ARM) endif(CLR_CMAKE_HOST_WIN32) add_compile_definitions(STRESS_LOG_ANALYZER) diff --git a/src/SOS/SOS.Extensions/DebuggerServices.cs b/src/SOS/SOS.Extensions/DebuggerServices.cs index f1f4caf563..82cb8872dd 100644 --- a/src/SOS/SOS.Extensions/DebuggerServices.cs +++ b/src/SOS/SOS.Extensions/DebuggerServices.cs @@ -82,9 +82,9 @@ public HResult GetDebuggeeType(out DEBUG_CLASS debugClass, out DEBUG_CLASS_QUALI return VTable.GetDebuggeeType(Self, out debugClass, out qualifier); } - public HResult GetExecutingProcessorType(out IMAGE_FILE_MACHINE type) + public HResult GetProcessorType(out IMAGE_FILE_MACHINE type) { - return VTable.GetExecutingProcessorType(Self, out type); + return VTable.GetProcessorType(Self, out type); } public HResult AddCommand(string command, string help, IEnumerable aliases) @@ -519,7 +519,7 @@ private readonly unsafe struct IDebuggerServicesVTable { public readonly delegate* unmanaged[Stdcall] GetOperatingSystem; public readonly delegate* unmanaged[Stdcall] GetDebuggeeType; - public readonly delegate* unmanaged[Stdcall] GetExecutingProcessorType; + public readonly delegate* unmanaged[Stdcall] GetProcessorType; public readonly delegate* unmanaged[Stdcall] AddCommand; public readonly delegate* unmanaged[Stdcall] OutputString; public readonly delegate* unmanaged[Stdcall] ReadVirtual; diff --git a/src/SOS/SOS.Extensions/TargetFromFromDebuggerServices.cs b/src/SOS/SOS.Extensions/TargetFromFromDebuggerServices.cs index aa8b378258..13fc5cd324 100644 --- a/src/SOS/SOS.Extensions/TargetFromFromDebuggerServices.cs +++ b/src/SOS/SOS.Extensions/TargetFromFromDebuggerServices.cs @@ -44,9 +44,10 @@ internal TargetFromDebuggerServices(DebuggerServices debuggerServices, IHost hos IsDump = true; } - hr = debuggerServices.GetExecutingProcessorType(out IMAGE_FILE_MACHINE type); + hr = debuggerServices.GetProcessorType(out IMAGE_FILE_MACHINE type); if (hr == HResult.S_OK) { + Debug.Assert(type is not IMAGE_FILE_MACHINE.ARM64X and not IMAGE_FILE_MACHINE.ARM64EC); Architecture = type switch { IMAGE_FILE_MACHINE.I386 => Architecture.X86, @@ -62,7 +63,7 @@ internal TargetFromDebuggerServices(DebuggerServices debuggerServices, IHost hos } else { - throw new PlatformNotSupportedException($"GetExecutingProcessorType() FAILED {hr:X8}"); + throw new PlatformNotSupportedException($"GetProcessorType() FAILED {hr:X8}"); } hr = debuggerServices.GetCurrentProcessId(out uint processId); diff --git a/src/SOS/SOS.Hosting/DbgEng/DebugControl.cs b/src/SOS/SOS.Hosting/DbgEng/DebugControl.cs index 50e0966688..097e8c1ac7 100644 --- a/src/SOS/SOS.Hosting/DbgEng/DebugControl.cs +++ b/src/SOS/SOS.Hosting/DbgEng/DebugControl.cs @@ -56,7 +56,7 @@ private static void AddDebugControl(VTableBuilder builder, SOSHost soshost) builder.AddMethod(new GetReturnOffsetDelegate((self, offset) => DebugClient.NotImplemented)); builder.AddMethod(new OutputStackTraceDelegate((self, outputControl, frames, frameSize, flags) => DebugClient.NotImplemented)); builder.AddMethod(new GetDebuggeeTypeDelegate(soshost.GetDebuggeeType)); - builder.AddMethod(new GetActualProcessorTypeDelegate((self, type) => DebugClient.NotImplemented)); + builder.AddMethod(new GetActualProcessorTypeDelegate(soshost.GetExecutingProcessorType)); builder.AddMethod(new GetExecutingProcessorTypeDelegate(soshost.GetExecutingProcessorType)); builder.AddMethod(new GetNumberPossibleExecutingProcessorTypesDelegate((self, number) => DebugClient.NotImplemented)); builder.AddMethod(new GetPossibleExecutingProcessorTypesDelegate((self, start, count, types) => DebugClient.NotImplemented)); diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ImageFileMachine.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ImageFileMachine.cs index da1a4881e2..a8524a388f 100644 --- a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ImageFileMachine.cs +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ImageFileMachine.cs @@ -35,6 +35,8 @@ public enum IMAGE_FILE_MACHINE : uint AMD64 = 0x8664, // AMD64 (K8) M32R = 0x9041, // M32R little-endian ARM64 = 0xAA64, // ARM64 Little-endian + ARM64EC = 0xA641, + ARM64X = 0xA64E, CEE = 0xC0EE, LOONGARCH64 = 0x6264, RISCV64 = 0x5064 diff --git a/src/SOS/SOS.Hosting/SOSHost.cs b/src/SOS/SOS.Hosting/SOSHost.cs index e78234871a..5a8cfb48b4 100644 --- a/src/SOS/SOS.Hosting/SOSHost.cs +++ b/src/SOS/SOS.Hosting/SOSHost.cs @@ -165,30 +165,16 @@ internal unsafe int GetExecutingProcessorType( IntPtr self, IMAGE_FILE_MACHINE* type) { - switch (Target.Architecture) - { - case Architecture.X64: - *type = IMAGE_FILE_MACHINE.AMD64; - break; - case Architecture.X86: - *type = IMAGE_FILE_MACHINE.I386; - break; - case Architecture.Arm: - *type = IMAGE_FILE_MACHINE.ARMNT; - break; - case Architecture.Arm64: - *type = IMAGE_FILE_MACHINE.ARM64; - break; - case (Architecture)6 /* Architecture.LoongArch64 */: - *type = IMAGE_FILE_MACHINE.LOONGARCH64; - break; - case (Architecture)9 /* Architecture.RiscV64 */: - *type = IMAGE_FILE_MACHINE.RISCV64; - break; - default: - *type = IMAGE_FILE_MACHINE.UNKNOWN; - break; - } + *type = Target.Architecture switch + { + Architecture.X64 => IMAGE_FILE_MACHINE.AMD64, + Architecture.X86 => IMAGE_FILE_MACHINE.I386, + Architecture.Arm => IMAGE_FILE_MACHINE.ARMNT, + Architecture.Arm64 => IMAGE_FILE_MACHINE.ARM64, + (Architecture)6 /* Architecture.LoongArch64 */=> IMAGE_FILE_MACHINE.LOONGARCH64, + (Architecture)9 /* Architecture.RiscV64 */=> IMAGE_FILE_MACHINE.RISCV64, + _ => IMAGE_FILE_MACHINE.UNKNOWN, + }; return HResult.S_OK; } diff --git a/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt b/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt index bf79961cf4..2d701b681b 100644 --- a/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt +++ b/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt @@ -124,7 +124,7 @@ - diff --git a/src/SOS/Strike/CMakeLists.txt b/src/SOS/Strike/CMakeLists.txt index 63124f3dc3..f0c7ab5410 100644 --- a/src/SOS/Strike/CMakeLists.txt +++ b/src/SOS/Strike/CMakeLists.txt @@ -30,9 +30,6 @@ if(CLR_CMAKE_HOST_ARCH_AMD64) message(STATUS "CLR_CMAKE_HOST_ARCH_AMD64") add_definitions(-DSOS_TARGET_AMD64=1) add_definitions(-D_TARGET_WIN64_=1) - add_definitions(-DDBG_TARGET_64BIT=1) - add_definitions(-DDBG_TARGET_AMD64=1) - add_definitions(-DDBG_TARGET_WIN64=1) if (CLR_CMAKE_HOST_WIN32) add_definitions(-DSOS_TARGET_ARM64=1) endif(CLR_CMAKE_HOST_WIN32) @@ -43,43 +40,26 @@ elseif(CLR_CMAKE_HOST_ARCH_I386) add_definitions(-DSOS_TARGET_X86=1) add_definitions(-D_TARGET_X86_=1) add_definitions(-DTARGET_X86) - add_definitions(-DDBG_TARGET_X86=1) - add_definitions(-DDBG_TARGET_32BIT=1) if (CLR_CMAKE_HOST_WIN32) add_definitions(-DSOS_TARGET_ARM=1) endif(CLR_CMAKE_HOST_WIN32) elseif(CLR_CMAKE_HOST_ARCH_ARM) message(STATUS "CLR_CMAKE_HOST_ARCH_ARM") add_definitions(-DSOS_TARGET_ARM=1) - add_definitions(-D_TARGET_WIN32_=1) add_definitions(-D_TARGET_ARM_=1) - add_definitions(-DDBG_TARGET_ARM=1) - add_definitions(-DDBG_TARGET_32BIT=1) elseif(CLR_CMAKE_HOST_ARCH_ARM64) message(STATUS "CLR_CMAKE_HOST_ARCH_ARM64") add_definitions(-DSOS_TARGET_ARM64=1) add_definitions(-D_TARGET_WIN64_=1) - add_definitions(-DDBG_TARGET_64BIT=1) - add_definitions(-DDBG_TARGET_ARM64=1) - add_definitions(-DDBG_TARGET_WIN64=1) elseif(CLR_CMAKE_HOST_ARCH_MIPS64) add_definitions(-DSOS_TARGET_MIPS64=1) add_definitions(-D_TARGET_WIN64_=1) - add_definitions(-DDBG_TARGET_64BIT=1) - add_definitions(-DDBG_TARGET_MIPS64=1) - add_definitions(-DDBG_TARGET_WIN64=1) elseif(CLR_CMAKE_HOST_ARCH_RISCV64) add_definitions(-DSOS_TARGET_RISCV64=1) add_definitions(-D_TARGET_WIN64_=1) - add_definitions(-DDBG_TARGET_64BIT=1) - add_definitions(-DDBG_TARGET_RISCV64=1) - add_definitions(-DDBG_TARGET_WIN64=1) elseif(CLR_CMAKE_HOST_ARCH_LOONGARCH64) add_definitions(-DSOS_TARGET_LOONGARCH64=1) add_definitions(-D_TARGET_WIN64_=1) - add_definitions(-DDBG_TARGET_64BIT=1) - add_definitions(-DDBG_TARGET_LOONGARCH64=1) - add_definitions(-DDBG_TARGET_WIN64=1) endif() add_definitions(-DSTRIKE) diff --git a/src/SOS/Strike/clrma/managedanalysis.cpp b/src/SOS/Strike/clrma/managedanalysis.cpp index 04df2f2760..6adb3fa73a 100644 --- a/src/SOS/Strike/clrma/managedanalysis.cpp +++ b/src/SOS/Strike/clrma/managedanalysis.cpp @@ -70,8 +70,10 @@ ClrmaManagedAnalysis::QueryDebugClient(IUnknown* pUnknown) } switch (m_processorType) { - case IMAGE_FILE_MACHINE_ARM64: case IMAGE_FILE_MACHINE_AMD64: + case IMAGE_FILE_MACHINE_ARM64: + case IMAGE_FILE_MACHINE_ARM64X: + case IMAGE_FILE_MACHINE_ARM64EC: case IMAGE_FILE_MACHINE_LOONGARCH64: case IMAGE_FILE_MACHINE_RISCV64: m_pointerSize = 8; diff --git a/src/SOS/Strike/clrma/managedanalysis.h b/src/SOS/Strike/clrma/managedanalysis.h index a78852e9ef..02a80a3304 100644 --- a/src/SOS/Strike/clrma/managedanalysis.h +++ b/src/SOS/Strike/clrma/managedanalysis.h @@ -9,6 +9,7 @@ #include // IDL #include #include +#include #include #include #include @@ -21,14 +22,6 @@ #include #include -#ifndef IMAGE_FILE_MACHINE_RISCV64 -#define IMAGE_FILE_MACHINE_RISCV64 0x5064 // RISCV64 -#endif - -#ifndef IMAGE_FILE_MACHINE_LOONGARCH64 -#define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264 // LOONGARCH64 -#endif - enum ClrmaGlobalFlags { LoggingEnabled = 0x01, // CLRMA logging enabled diff --git a/src/SOS/Strike/dbgengservices.cpp b/src/SOS/Strike/dbgengservices.cpp index 6dad478366..8d6bbaa64e 100644 --- a/src/SOS/Strike/dbgengservices.cpp +++ b/src/SOS/Strike/dbgengservices.cpp @@ -189,10 +189,24 @@ DbgEngServices::GetDebuggeeType( } HRESULT -DbgEngServices::GetExecutingProcessorType( +DbgEngServices::GetProcessorType( PULONG type) { - return m_control->GetExecutingProcessorType(type); + ULONG executingType; + HRESULT hr = m_control->GetExecutingProcessorType(&executingType); + if (FAILED(hr)) + { + return hr; + } + _ASSERTE(executingType != IMAGE_FILE_MACHINE_ARM64X); + *type = executingType; +#if defined(SOS_TARGET_AMD64) || defined(SOS_TARGET_ARM64) + if (executingType == IMAGE_FILE_MACHINE_ARM64EC) + { + *type = IMAGE_FILE_MACHINE_AMD64; + } +#endif // defined(SOS_TARGET_AMD64) || defined(SOS_TARGET_ARM64) + return S_OK; } HRESULT diff --git a/src/SOS/Strike/dbgengservices.h b/src/SOS/Strike/dbgengservices.h index 73eff8044d..c7cbb4092e 100644 --- a/src/SOS/Strike/dbgengservices.h +++ b/src/SOS/Strike/dbgengservices.h @@ -72,7 +72,7 @@ class DbgEngServices : public IDebuggerServices, public IRemoteMemoryService, pu PULONG debugClass, PULONG qualifier); - HRESULT STDMETHODCALLTYPE GetExecutingProcessorType( + HRESULT STDMETHODCALLTYPE GetProcessorType( PULONG type); HRESULT STDMETHODCALLTYPE AddCommand( diff --git a/src/SOS/Strike/disasmX86.cpp b/src/SOS/Strike/disasmX86.cpp index 11750ab77c..21db6e526a 100644 --- a/src/SOS/Strike/disasmX86.cpp +++ b/src/SOS/Strike/disasmX86.cpp @@ -620,7 +620,14 @@ void // #ifdef _WIN64 - ExtOut("%08x`%08x ", (ULONG)(InstrAddr >> 32), (ULONG)InstrAddr); + if (GetHost()->GetHostType() == IHost::HostType::DbgEng) + { + ExtOut("%08x`%08x ", (ULONG)(InstrAddr >> 32), (ULONG)InstrAddr); + } + else + { + ExtOut("%016llx ", InstrAddr); + } #else ExtOut("%08x ", (ULONG)InstrAddr); #endif diff --git a/src/SOS/Strike/exts.cpp b/src/SOS/Strike/exts.cpp index 81f304fd47..1bb392ba47 100644 --- a/src/SOS/Strike/exts.cpp +++ b/src/SOS/Strike/exts.cpp @@ -152,6 +152,15 @@ GetTargetMachine(ULONG processorType) targetMachine = ARM64Machine::GetInstance(); } #endif // SOS_TARGET_ARM64 + _ASSERTE(processorType != IMAGE_FILE_MACHINE_ARM64X); +#if defined(SOS_TARGET_AMD64) || defined(SOS_TARGET_ARM64) + if (processorType == IMAGE_FILE_MACHINE_ARM64EC) + { +#ifdef SOS_TARGET_AMD64 + targetMachine = AMD64Machine::GetInstance(); +#endif // SOS_TARGET_AMD64 + } +#endif // defined(SOS_TARGET_AMD64) || defined(SOS_TARGET_ARM64) #ifdef SOS_TARGET_RISCV64 if (processorType == IMAGE_FILE_MACHINE_RISCV64) { @@ -167,6 +176,46 @@ GetTargetMachine(ULONG processorType) return targetMachine; } +const char* +GetProcessorName(ULONG type) +{ + const char* architecture = "unknown"; + switch (type) + { + case IMAGE_FILE_MACHINE_AMD64: + architecture = "x64"; + break; + case IMAGE_FILE_MACHINE_I386: + architecture = "x86"; + break; + case IMAGE_FILE_MACHINE_ARM: + architecture = "arm"; + break; + case IMAGE_FILE_MACHINE_THUMB: + architecture = "thumb"; + break; + case IMAGE_FILE_MACHINE_ARMNT: + architecture = "armnt"; + break; + case IMAGE_FILE_MACHINE_ARM64: + architecture = "arm64"; + break; + case IMAGE_FILE_MACHINE_ARM64EC: + architecture = "arm64ec"; + break; + case IMAGE_FILE_MACHINE_ARM64X: + architecture = "arm64x"; + break; + case IMAGE_FILE_MACHINE_RISCV64: + architecture = "riscv64"; + break; + case IMAGE_FILE_MACHINE_LOONGARCH64: + architecture = "loongarch64"; + break; + } + return architecture; +} + HRESULT ArchQuery(void) { @@ -176,32 +225,19 @@ ArchQuery(void) g_targetMachine = GetTargetMachine(processorType); if (g_targetMachine == NULL) { - const char* architecture = ""; - switch (processorType) + const char* architecture = GetProcessorName(processorType); + const char* message = ""; +#if defined(SOS_TARGET_AMD64) || defined(SOS_TARGET_ARM64) + if (processorType == IMAGE_FILE_MACHINE_ARM64EC) + { + message = "Arm64ec targets require a x64 compatible SOS and debugger."; + } + else +#endif { - case IMAGE_FILE_MACHINE_AMD64: - architecture = "x64"; - break; - case IMAGE_FILE_MACHINE_I386: - architecture = "x86"; - break; - case IMAGE_FILE_MACHINE_ARM: - case IMAGE_FILE_MACHINE_THUMB: - case IMAGE_FILE_MACHINE_ARMNT: - architecture = "arm32"; - break; - case IMAGE_FILE_MACHINE_ARM64: - architecture = "arm64"; - break; - case IMAGE_FILE_MACHINE_RISCV64: - architecture = "riscv64"; - break; - case IMAGE_FILE_MACHINE_LOONGARCH64: - architecture = "loongarch64"; - break; + message = "A 32 bit target may require a 32 bit debugger or vice versa. In general, try to use the same bitness for the debugger and target process."; } - ExtErr("SOS does not support the current target architecture '%s' (0x%04x). A 32 bit target may require a 32 bit debugger or vice versa. In general, try to use the same bitness for the debugger and target process.\n", - architecture, processorType); + ExtErr("SOS does not support the current target architecture '%s' (0x%04x). %s\n", architecture, processorType, message); return E_FAIL; } return S_OK; diff --git a/src/SOS/Strike/exts.h b/src/SOS/Strike/exts.h index 31a15fd92c..5ee3a0c70d 100644 --- a/src/SOS/Strike/exts.h +++ b/src/SOS/Strike/exts.h @@ -55,14 +55,6 @@ // printing CDA values. #define CDA_TO_UL64(cda) ((ULONG64)(TO_TADDR(cda))) -#ifndef IMAGE_FILE_MACHINE_RISCV64 -#define IMAGE_FILE_MACHINE_RISCV64 0x5064 // RISCV64 -#endif // !IMAGE_FILE_MACHINE_RISCV64 - -#ifndef IMAGE_FILE_MACHINE_LOONGARCH64 -#define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264 // LOONGARCH64 -#endif // !IMAGE_FILE_MACHINE_LOONGARCH64 - typedef struct _TADDR_RANGE { TADDR start; @@ -159,6 +151,9 @@ ExtQuery(PDEBUG_CLIENT client); HRESULT ExtInit(PDEBUG_CLIENT client); +const char* +GetProcessorName(ULONG type); + HRESULT ArchQuery(void); diff --git a/src/SOS/Strike/platformspecific.h b/src/SOS/Strike/platformspecific.h index 6a66df890d..88ac1a7368 100644 --- a/src/SOS/Strike/platformspecific.h +++ b/src/SOS/Strike/platformspecific.h @@ -14,6 +14,7 @@ // The main debugger code already has target platform definitions for CONTEXT. #include +#include #ifndef FEATURE_PAL @@ -42,14 +43,6 @@ struct DT_UNICODE_STRING #define DT_GDI_HANDLE_BUFFER_SIZE32 34 #define DT_GDI_HANDLE_BUFFER_SIZE64 60 -#ifndef IMAGE_FILE_MACHINE_ARMNT -#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 // ARM Thumb-2 Little-Endian -#endif - -#ifndef IMAGE_FILE_MACHINE_ARM64 -#define IMAGE_FILE_MACHINE_ARM64 0xAA64 // ARM64 Little-Endian -#endif - #ifdef _TARGET_WIN64_ typedef ULONG DT_GDI_HANDLE_BUFFER[DT_GDI_HANDLE_BUFFER_SIZE64]; #else diff --git a/src/SOS/Strike/sos.def b/src/SOS/Strike/sos.def index 50b7ae3299..73f7ed5dac 100644 --- a/src/SOS/Strike/sos.def +++ b/src/SOS/Strike/sos.def @@ -141,6 +141,7 @@ EXPORTS pe=PrintException printexception=PrintException Printexception=PrintException + processor SaveModule savemodule=SaveModule SetHostRuntime diff --git a/src/SOS/Strike/strike.cpp b/src/SOS/Strike/strike.cpp index 59861b4411..bf8ac0e4bd 100644 --- a/src/SOS/Strike/strike.cpp +++ b/src/SOS/Strike/strike.cpp @@ -13618,6 +13618,27 @@ DECLARE_API(SetHostRuntime) return S_OK; } +DECLARE_API(processor) +{ + INIT_API_EXT(); + ULONG executingType; + if (SUCCEEDED(g_ExtControl->GetExecutingProcessorType(&executingType))) + { + ExtOut("Executing processor type: %04x '%s'\n", executingType, GetProcessorName(executingType)); + } + ULONG actualType; + if (SUCCEEDED(g_ExtControl->GetActualProcessorType(&actualType))) + { + ExtOut("Actual processor type: %04x '%s'\n", actualType, GetProcessorName(actualType)); + } + ULONG effectiveType; + if (SUCCEEDED(g_ExtControl->GetEffectiveProcessorType(&effectiveType))) + { + ExtOut("Effective processor type: %04x '%s'\n", effectiveType, GetProcessorName(effectiveType)); + } + return S_OK; +} + #endif // FEATURE_PAL // diff --git a/src/SOS/Strike/xplat/dbgeng.h b/src/SOS/Strike/xplat/dbgeng.h index 64a64fc916..146ecf1bdb 100644 --- a/src/SOS/Strike/xplat/dbgeng.h +++ b/src/SOS/Strike/xplat/dbgeng.h @@ -111,7 +111,14 @@ class DebugClient GetExecutingProcessorType( PULONG type) { - return m_lldbservices->GetExecutingProcessorType(type); + return m_lldbservices->GetProcessorType(type); + } + + HRESULT + GetActualProcessorType( + PULONG type) + { + return m_lldbservices->GetProcessorType(type); } HRESULT diff --git a/src/SOS/inc/debuggerservices.h b/src/SOS/inc/debuggerservices.h index e333177bc3..204a164525 100644 --- a/src/SOS/inc/debuggerservices.h +++ b/src/SOS/inc/debuggerservices.h @@ -37,7 +37,7 @@ IDebuggerServices : public IUnknown PULONG debugClass, PULONG qualifier) = 0; - virtual HRESULT STDMETHODCALLTYPE GetExecutingProcessorType( + virtual HRESULT STDMETHODCALLTYPE GetProcessorType( PULONG type) = 0; virtual HRESULT STDMETHODCALLTYPE AddCommand( diff --git a/src/SOS/inc/lldbservices.h b/src/SOS/inc/lldbservices.h index b31f251223..bef3f2ace6 100644 --- a/src/SOS/inc/lldbservices.h +++ b/src/SOS/inc/lldbservices.h @@ -321,7 +321,7 @@ ILLDBServices : public IUnknown // Returns the type of processor used in the // current processor context. - virtual HRESULT STDMETHODCALLTYPE GetExecutingProcessorType( + virtual HRESULT STDMETHODCALLTYPE GetProcessorType( PULONG type) = 0; // Executes the given command string. diff --git a/src/SOS/lldbplugin/CMakeLists.txt b/src/SOS/lldbplugin/CMakeLists.txt index a1656bfb71..76dc0ecc7b 100644 --- a/src/SOS/lldbplugin/CMakeLists.txt +++ b/src/SOS/lldbplugin/CMakeLists.txt @@ -20,50 +20,6 @@ if(SKIP_LLDBPLUGIN) set(REQUIRE_LLDBPLUGIN false) endif() -if(CLR_CMAKE_HOST_ARCH_AMD64) - add_definitions(-D_TARGET_AMD64_=1) - add_definitions(-DDBG_TARGET_64BIT=1) - add_definitions(-DDBG_TARGET_AMD64=1) - add_definitions(-DDBG_TARGET_WIN64=1) - add_definitions(-DBIT64) -elseif(CLR_CMAKE_HOST_ARCH_I386) - add_definitions(-D_TARGET_X86_=1) - add_definitions(-DDBG_TARGET_32BIT=1) - add_definitions(-DDBG_TARGET_X86=1) -elseif(CLR_CMAKE_HOST_ARCH_ARM) - add_definitions(-D_TARGET_ARM_=1) - add_definitions(-DDBG_TARGET_32BIT=1) - add_definitions(-DDBG_TARGET_ARM=1) -elseif(CLR_CMAKE_HOST_ARCH_ARM64) - add_definitions(-D_TARGET_ARM64_=1) - add_definitions(-DDBG_TARGET_64BIT=1) - add_definitions(-DDBG_TARGET_ARM64=1) - add_definitions(-DDBG_TARGET_WIN64=1) - add_definitions(-DBIT64) - SET(REQUIRE_LLDBPLUGIN false) -elseif(CLR_CMAKE_HOST_ARCH_MIPS64) - add_definitions(-D_TARGET_MIPS64_=1) - add_definitions(-DDBG_TARGET_64BIT=1) - add_definitions(-DDBG_TARGET_MIPS64=1) - add_definitions(-DDBG_TARGET_WIN64=1) - add_definitions(-DBIT64) - SET(REQUIRE_LLDBPLUGIN false) -elseif(CLR_CMAKE_HOST_ARCH_RISCV64) - add_definitions(-D_TARGET_RISCV64_=1) - add_definitions(-DDBG_TARGET_64BIT=1) - add_definitions(-DDBG_TARGET_RISCV64=1) - add_definitions(-DDBG_TARGET_WIN64=1) - add_definitions(-DBIT64) - SET(REQUIRE_LLDBPLUGIN false) -elseif(CLR_CMAKE_HOST_ARCH_LOONGARCH64) - add_definitions(-D_TARGET_LOONGARCH64_=1) - add_definitions(-DDBG_TARGET_64BIT=1) - add_definitions(-DDBG_TARGET_LOONGARCH64=1) - add_definitions(-DDBG_TARGET_WIN64=1) - add_definitions(-DBIT64) - SET(REQUIRE_LLDBPLUGIN false) -endif() - if(NOT $ENV{LLVM_HOME} STREQUAL "") set(LLDB_INCLUDE_DIR "$ENV{LLVM_HOME}/include") set(LLDB_LIB_DIR "$ENV{LLVM_HOME}/lib") diff --git a/src/SOS/lldbplugin/services.cpp b/src/SOS/lldbplugin/services.cpp index 182a74be46..9f8285b40e 100644 --- a/src/SOS/lldbplugin/services.cpp +++ b/src/SOS/lldbplugin/services.cpp @@ -223,17 +223,17 @@ LLDBServices::VirtualUnwind( DT_CONTEXT *dtcontext = (DT_CONTEXT*)context; lldb::SBFrame frameFound; -#ifdef DBG_TARGET_AMD64 +#ifdef TARGET_AMD64 DWORD64 spToFind = dtcontext->Rsp; -#elif DBG_TARGET_X86 +#elif TARGET_X86 DWORD spToFind = dtcontext->Esp; -#elif DBG_TARGET_ARM +#elif TARGET_ARM DWORD spToFind = dtcontext->Sp; -#elif DBG_TARGET_ARM64 +#elif TARGET_ARM64 DWORD64 spToFind = dtcontext->Sp; -#elif DBG_TARGET_RISCV64 +#elif TARGET_RISCV64 DWORD64 spToFind = dtcontext->Sp; -#elif DBG_TARGET_LOONGARCH64 +#elif TARGET_LOONGARCH64 DWORD64 spToFind = dtcontext->Sp; #else #error "spToFind undefined for this platform" @@ -447,20 +447,20 @@ LLDBServices::GetPageSize( } HRESULT -LLDBServices::GetExecutingProcessorType( +LLDBServices::GetProcessorType( PULONG type) { -#ifdef DBG_TARGET_AMD64 +#ifdef TARGET_AMD64 *type = IMAGE_FILE_MACHINE_AMD64; -#elif DBG_TARGET_ARM +#elif TARGET_ARM *type = IMAGE_FILE_MACHINE_ARMNT; -#elif DBG_TARGET_ARM64 +#elif TARGET_ARM64 *type = IMAGE_FILE_MACHINE_ARM64; -#elif DBG_TARGET_X86 +#elif TARGET_X86 *type = IMAGE_FILE_MACHINE_I386; -#elif DBG_TARGET_RISCV64 +#elif TARGET_RISCV64 *type = IMAGE_FILE_MACHINE_RISCV64; -#elif DBG_TARGET_LOONGARCH64 +#elif TARGET_LOONGARCH64 *type = IMAGE_FILE_MACHINE_LOONGARCH64; #else #error "Unsupported target" @@ -1629,7 +1629,7 @@ LLDBServices::GetContextFromFrame( /* const */ lldb::SBFrame& frame, DT_CONTEXT *dtcontext) { -#ifdef DBG_TARGET_AMD64 +#ifdef TARGET_AMD64 dtcontext->Rip = frame.GetPC(); dtcontext->Rsp = frame.GetSP(); dtcontext->Rbp = frame.GetFP(); @@ -1656,7 +1656,7 @@ LLDBServices::GetContextFromFrame( dtcontext->SegEs = GetRegister(frame, "es"); dtcontext->SegFs = GetRegister(frame, "fs"); dtcontext->SegGs = GetRegister(frame, "gs"); -#elif DBG_TARGET_ARM +#elif TARGET_ARM dtcontext->Pc = frame.GetPC(); dtcontext->Sp = frame.GetSP(); dtcontext->Lr = GetRegister(frame, "lr"); @@ -1675,7 +1675,7 @@ LLDBServices::GetContextFromFrame( dtcontext->R10 = GetRegister(frame, "r10"); dtcontext->R11 = GetRegister(frame, "r11"); dtcontext->R12 = GetRegister(frame, "r12"); -#elif DBG_TARGET_ARM64 +#elif TARGET_ARM64 dtcontext->Pc = frame.GetPC(); dtcontext->Sp = frame.GetSP(); dtcontext->Lr = GetRegister(frame, "x30"); @@ -1711,7 +1711,7 @@ LLDBServices::GetContextFromFrame( dtcontext->X26 = GetRegister(frame, "x26"); dtcontext->X27 = GetRegister(frame, "x27"); dtcontext->X28 = GetRegister(frame, "x28"); -#elif DBG_TARGET_X86 +#elif TARGET_X86 dtcontext->Eip = frame.GetPC(); dtcontext->Esp = frame.GetSP(); dtcontext->Ebp = frame.GetFP(); @@ -1730,7 +1730,7 @@ LLDBServices::GetContextFromFrame( dtcontext->SegEs = GetRegister(frame, "es"); dtcontext->SegFs = GetRegister(frame, "fs"); dtcontext->SegGs = GetRegister(frame, "gs"); -#elif DBG_TARGET_LOONGARCH64 +#elif TARGET_LOONGARCH64 dtcontext->Pc = frame.GetPC(); dtcontext->Sp = frame.GetSP(); dtcontext->Ra = GetRegister(frame, "ra"); diff --git a/src/SOS/lldbplugin/services.h b/src/SOS/lldbplugin/services.h index a69bb236a2..734f56bf2f 100644 --- a/src/SOS/lldbplugin/services.h +++ b/src/SOS/lldbplugin/services.h @@ -136,7 +136,7 @@ class LLDBServices : public ILLDBServices, public ILLDBServices2, public IDebugg HRESULT STDMETHODCALLTYPE GetPageSize( PULONG size); - HRESULT STDMETHODCALLTYPE GetExecutingProcessorType( + HRESULT STDMETHODCALLTYPE GetProcessorType( PULONG type); HRESULT STDMETHODCALLTYPE Execute( diff --git a/src/dbgshim/debugshim.cpp b/src/dbgshim/debugshim.cpp index 06cbe5f8af..6525aa97e4 100644 --- a/src/dbgshim/debugshim.cpp +++ b/src/dbgshim/debugshim.cpp @@ -11,16 +11,9 @@ #include "dbgutil.h" #include #include //has the CLR_ID_V4_DESKTOP guid in it +#include #include "palclr.h" -#ifndef IMAGE_FILE_MACHINE_ARMNT -#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 // ARM Thumb-2 Little-Endian -#endif - -#ifndef IMAGE_FILE_MACHINE_ARM64 -#define IMAGE_FILE_MACHINE_ARM64 0xAA64 // ARM64 Little-Endian -#endif - //***************************************************************************** // CLRDebuggingImpl implementation (ICLRDebugging) //***************************************************************************** @@ -766,9 +759,9 @@ HRESULT CLRDebuggingImpl::FormatLongDacModuleName(_Inout_updates_z_(cchBuffer) W #endif const WCHAR* pDacBaseName = NULL; - if(m_skuId == CLR_ID_V4_DESKTOP) + if (m_skuId == CLR_ID_V4_DESKTOP) pDacBaseName = CLR_DAC_MODULE_NAME_W; - else if(m_skuId == CLR_ID_CORECLR || m_skuId == CLR_ID_PHONE_CLR || m_skuId == CLR_ID_ONECORE_CLR) + else if (m_skuId == CLR_ID_CORECLR || m_skuId == CLR_ID_PHONE_CLR || m_skuId == CLR_ID_ONECORE_CLR) pDacBaseName = CORECLR_DAC_MODULE_NAME_W; else { @@ -776,23 +769,33 @@ HRESULT CLRDebuggingImpl::FormatLongDacModuleName(_Inout_updates_z_(cchBuffer) W return E_UNEXPECTED; } + _ASSERTE(targetImageFileMachine != IMAGE_FILE_MACHINE_ARM64X && targetImageFileMachine != IMAGE_FILE_MACHINE_ARM64EC); + const WCHAR* pTargetArch = NULL; - if(targetImageFileMachine == IMAGE_FILE_MACHINE_I386) + if (targetImageFileMachine == IMAGE_FILE_MACHINE_I386) { pTargetArch = W("x86"); } - else if(targetImageFileMachine == IMAGE_FILE_MACHINE_AMD64) + else if (targetImageFileMachine == IMAGE_FILE_MACHINE_AMD64) { pTargetArch = W("amd64"); } - else if(targetImageFileMachine == IMAGE_FILE_MACHINE_ARMNT) + else if (targetImageFileMachine == IMAGE_FILE_MACHINE_ARMNT) { pTargetArch = W("arm"); } - else if(targetImageFileMachine == IMAGE_FILE_MACHINE_ARM64) + else if (targetImageFileMachine == IMAGE_FILE_MACHINE_ARM64) { pTargetArch = W("arm64"); } + else if (targetImageFileMachine == IMAGE_FILE_MACHINE_RISCV64) + { + pTargetArch = W("riscv64"); + } + else if (targetImageFileMachine == IMAGE_FILE_MACHINE_LOONGARCH64) + { + pTargetArch = W("loongarch64"); + } else { _ASSERTE(!"Unknown target image file machine type"); @@ -800,9 +803,9 @@ HRESULT CLRDebuggingImpl::FormatLongDacModuleName(_Inout_updates_z_(cchBuffer) W } const WCHAR* pBuildFlavor = W(""); - if(pVersion->dwFileFlags & VS_FF_DEBUG) + if (pVersion->dwFileFlags & VS_FF_DEBUG) { - if(pVersion->dwFileFlags & VS_FF_SPECIALBUILD) + if (pVersion->dwFileFlags & VS_FF_SPECIALBUILD) pBuildFlavor = W(".dbg"); else pBuildFlavor = W(".chk"); @@ -823,7 +826,7 @@ HRESULT CLRDebuggingImpl::FormatLongDacModuleName(_Inout_updates_z_(cchBuffer) W // validate the output buffer is larger than our estimate above _ASSERTE(cchBuffer >= minCchBuffer); - if(!(cchBuffer >= minCchBuffer)) return E_INVALIDARG; + if (!(cchBuffer >= minCchBuffer)) return E_INVALIDARG; swprintf_s(pBuffer, cchBuffer, W("%s_%s_%s_%u.%u.%u.%02u%s.dll"), pDacBaseName, diff --git a/src/inc/ntimageex.h b/src/inc/ntimageex.h new file mode 100644 index 0000000000..b249b74a4c --- /dev/null +++ b/src/inc/ntimageex.h @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#pragma once + +#ifndef IMAGE_FILE_MACHINE_ARMNT +#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 // ARM Thumb-2 Little-Endian +#endif + +#ifndef IMAGE_FILE_MACHINE_ARM64 +#define IMAGE_FILE_MACHINE_ARM64 0xAA64 // ARM64 Little-Endian +#endif + +#ifndef IMAGE_FILE_MACHINE_ARM64EC +#define IMAGE_FILE_MACHINE_ARM64EC 0xA641 +#endif + +#ifndef IMAGE_FILE_MACHINE_ARM64X +#define IMAGE_FILE_MACHINE_ARM64X 0xA64E +#endif + +#ifndef IMAGE_FILE_MACHINE_RISCV64 +#define IMAGE_FILE_MACHINE_RISCV64 0x5064 // RISCV64 +#endif + +#ifndef IMAGE_FILE_MACHINE_LOONGARCH64 +#define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264 // LOONGARCH64 +#endif + diff --git a/src/shared/pal/src/init/pal.cpp b/src/shared/pal/src/init/pal.cpp index 871c220db0..f6ea18445d 100644 --- a/src/shared/pal/src/init/pal.cpp +++ b/src/shared/pal/src/init/pal.cpp @@ -87,6 +87,11 @@ int CacheLineSize; using namespace CorUnix; +#if defined(HOST_ARM64) +// Flag to check if atomics feature is available on +// the machine +bool g_arm64_atomics_present = false; +#endif Volatile init_count = 0; Volatile shutdown_intent = 0;