Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LoongArch64] coreclr/debug and part of inc directory. #62886

Merged
merged 32 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
47d106f
Merge pull request #1 from dotnet/main
shushanhf Apr 27, 2021
411b59e
Merge branch 'dotnet:main' into master
shushanhf Oct 25, 2021
7eed4eb
Merge branch 'dotnet:main' into master
shushanhf Dec 6, 2021
0d7c9e4
Merge branch 'dotnet:main' into master
shushanhf Dec 10, 2021
2c534c5
Merge branch 'dotnet:main' into master
shushanhf Dec 14, 2021
6e14d76
Merge branch 'dotnet:main' into master
shushanhf Dec 15, 2021
359875d
Merge branch 'dotnet:main' into master
shushanhf Dec 15, 2021
192b095
Merge branch 'dotnet:main' into main
shushanhf Dec 16, 2021
46ebed3
[LoongArch64] add coreclr-inc,gc, ToolBox directory. (#59561)
shushanhf Dec 15, 2021
e6bada0
[LoongArch64] move inc/switches.h to #62889.
Dec 18, 2021
50bc181
[LoongArch64] move some configure files from #62889.
Dec 18, 2021
49104b3
[LoongArch64] revert the modify when moved from #62889.
Dec 18, 2021
d3e0468
[LoongArch64] moved the inc/stdmacros.h to #62885.
Dec 20, 2021
e1d82f9
[LoongArch64] moved inc/corinfo.h to #62885.
Dec 20, 2021
9c211b9
[LoongArch64] modify the related files for compiling error.
shushanhf Dec 21, 2021
7fc185f
[LoongArch64] revert the `src/coreclr/gcinfo/CMakeLists.txt` to origi…
shushanhf Dec 21, 2021
b859a4f
[LoongArch64] delete unused files on windows.
shushanhf Dec 21, 2021
3e89670
[LoongArch64] add define IMAGE_FILE_MACHINE_LOONGARCH64.
shushanhf Dec 21, 2021
f0618ea
[LoongArch64] workround the compiling error for IMAGE_FILE_MACHINE_LO…
shushanhf Dec 21, 2021
054033f
[LoongArch64] workround the compiling error for SPMI_TARGET_ARCHITECT…
Dec 21, 2021
b7cb02b
[LoongArch64] delete the memcpy for LoongArch64 and revert workround …
Dec 22, 2021
72919c1
[LoongArch64] exclude the gc, ToolBox and config files from this PR.
Dec 22, 2021
c806a8f
[LoongArch64] amend code for compiling error on LoongArch64-machine.
shushanhf Jan 14, 2022
f829e9a
[LoongArch64] update the version of the `LICENSE description`.
Jan 19, 2022
81b9deb
Merge branch 'main' into main_loongarch64_3
shushanhf Feb 23, 2022
650ab6a
Merge branch 'main' into main_loongarch64_3
shushanhf Feb 24, 2022
2136701
[LoongArch64] amend the code about debug.
shushanhf Feb 24, 2022
e058faa
[LoongArch64] temp submit for fixing the windows compiling error.
shushanhf Feb 24, 2022
27e1419
Merge branch 'main' into main_loongarch64_3
shushanhf Feb 25, 2022
7c0fe05
Merge branch 'main' into main_loongarch64_3
shushanhf Apr 12, 2022
c2694ff
Merge branch 'main' into main_loongarch64_3
shushanhf Apr 22, 2022
c8fb52a
[LoongArch64] amend some LA's implements for CR.
shushanhf Apr 24, 2022
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/coreclr/binder/assemblybindercommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ BOOL AssemblyBinderCommon::IsValidArchitecture(PEKIND kArchitecture)
#elif defined(TARGET_ARM64)
peARM64;
#else
PORTABILITY_ASSERT("processArchitecture");
peMSIL;
#endif

return (kArchitecture == processArchitecture);
Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/debug/createdump/datatarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ DumpDataTarget::GetMachineType(
*machine = IMAGE_FILE_MACHINE_ARM64;
#elif HOST_X86
*machine = IMAGE_FILE_MACHINE_I386;
#elif HOST_LOONGARCH64
*machine = IMAGE_FILE_MACHINE_LOONGARCH64;
#else
#error Unsupported architecture
#endif
Expand All @@ -79,7 +81,7 @@ HRESULT STDMETHODCALLTYPE
DumpDataTarget::GetPointerSize(
/* [out] */ ULONG32 *size)
{
#if defined(HOST_AMD64) || defined(HOST_ARM64)
#if defined(HOST_AMD64) || defined(HOST_ARM64) || defined(HOST_LOONGARCH64)
*size = 8;
#elif defined(HOST_ARM) || defined(HOST_X86)
*size = 4;
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/debug/createdump/dumpwriterelf.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#define ELF_ARCH EM_AARCH64
#elif defined(__arm__)
#define ELF_ARCH EM_ARM
#elif defined(__loongarch64)
#define ELF_ARCH EM_LOONGARCH
#endif

#define PH_HDR_CANARY 0xFFFF
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/createdump/memoryregion.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#if !defined(PAGE_SIZE) && (defined(__arm__) || defined(__aarch64__))
#if !defined(PAGE_SIZE) && (defined(__arm__) || defined(__aarch64__) || defined(__loongarch64))
#define PAGE_SIZE sysconf(_SC_PAGESIZE)
#endif

Expand Down
20 changes: 20 additions & 0 deletions src/coreclr/debug/createdump/threadinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,29 @@ class CrashInfo;
#define MCREG_Cpsr(mc) ((mc).pstate)
#endif

#if defined(__loongarch64)
// See src/coreclr/pal/src/include/pal/context.h
#define MCREG_Ra(mc) ((mc).gpr[1])
#define MCREG_Fp(mc) ((mc).gpr[22])
#define MCREG_Sp(mc) ((mc).gpr[3])
#define MCREG_Pc(mc) ((mc).pc)
#endif

#define FPREG_ErrorOffset(fpregs) *(DWORD*)&((fpregs).rip)
#define FPREG_ErrorSelector(fpregs) *(((WORD*)&((fpregs).rip)) + 2)
#define FPREG_DataOffset(fpregs) *(DWORD*)&((fpregs).rdp)
#define FPREG_DataSelector(fpregs) *(((WORD*)&((fpregs).rdp)) + 2)
#if defined(__arm__)
#define user_regs_struct user_regs
#define user_fpregs_struct user_fpregs
#elif defined(__loongarch64)
// struct user_regs_struct {} defined `/usr/include/loongarch64-linux-gnu/sys/user.h`

struct user_fpregs_struct
{
unsigned long long fpregs[32];
unsigned long fpscr;
} __attribute__((__packed__));
#endif

#if defined(__aarch64__)
Expand Down Expand Up @@ -130,6 +146,10 @@ class ThreadInfo
inline const uint64_t GetInstructionPointer() const { return MCREG_Pc(m_gpRegisters); }
inline const uint64_t GetStackPointer() const { return MCREG_Sp(m_gpRegisters); }
inline const uint64_t GetFramePointer() const { return MCREG_Fp(m_gpRegisters); }
#elif defined(__loongarch64)
inline const uint64_t GetInstructionPointer() const { return MCREG_Pc(m_gpRegisters); }
inline const uint64_t GetStackPointer() const { return MCREG_Sp(m_gpRegisters); }
inline const uint64_t GetFramePointer() const { return MCREG_Fp(m_gpRegisters); }
#elif defined(__arm__)
inline const uint64_t GetInstructionPointer() const { return m_gpRegisters.ARM_pc; }
inline const uint64_t GetStackPointer() const { return m_gpRegisters.ARM_sp; }
Expand Down
22 changes: 22 additions & 0 deletions src/coreclr/debug/createdump/threadinfounix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ ThreadInfo::Initialize()
TRACE("Thread %04x PC %08lx SP %08lx\n", m_tid, (unsigned long)m_gpRegisters.ARM_pc, (unsigned long)m_gpRegisters.ARM_sp);
#elif defined(__x86_64__)
TRACE("Thread %04x RIP %016llx RSP %016llx\n", m_tid, (unsigned long long)m_gpRegisters.rip, (unsigned long long)m_gpRegisters.rsp);
#elif defined(__loongarch64)
TRACE("Thread %04x PC %016llx SP %016llx\n", m_tid, (unsigned long long)m_gpRegisters.pc, (unsigned long long)m_gpRegisters.gpr[3]);
#else
#error "Unsupported architecture"
#endif
Expand Down Expand Up @@ -221,6 +223,26 @@ ThreadInfo::GetThreadContext(uint32_t flags, CONTEXT* context) const
memcpy(context->D, m_vfpRegisters.fpregs, sizeof(context->D));
#endif
}
#elif defined(__loongarch64)
if ((flags & CONTEXT_CONTROL) == CONTEXT_CONTROL)
{
context->Ra = MCREG_Ra(m_gpRegisters);
context->Sp = MCREG_Sp(m_gpRegisters);
context->Fp = MCREG_Fp(m_gpRegisters);
context->Pc = MCREG_Pc(m_gpRegisters);
}
if ((flags & CONTEXT_INTEGER) == CONTEXT_INTEGER)
{
context->Tp = m_gpRegisters.gpr[2];
memcpy(&context->A0, &m_gpRegisters.gpr[4], sizeof(context->A0)*(21 - 4 + 1));
memcpy(&context->S0, &m_gpRegisters.gpr[23], sizeof(context->S0)*9);
}
if ((flags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT)
{
assert(sizeof(context->F) == sizeof(m_fpRegisters.fpregs));
memcpy(context->F, m_fpRegisters.fpregs, sizeof(context->F));
context->Fcsr = m_fpRegisters.fpscr;
}
#else
#error Platform not supported
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5514,6 +5514,8 @@ ClrDataAccess::Initialize(void)
CorDebugPlatform hostPlatform = CORDB_PLATFORM_POSIX_ARM;
#elif defined(TARGET_ARM64)
CorDebugPlatform hostPlatform = CORDB_PLATFORM_POSIX_ARM64;
#elif defined(TARGET_LOONGARCH64)
CorDebugPlatform hostPlatform = CORDB_PLATFORM_POSIX_LOONGARCH64;
#else
#error Unknown Processor.
#endif
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/debug/daccess/loongarch64/primitives.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#include "stdafx.h"

#include "../../shared/loongarch64/primitives.cpp"
12 changes: 12 additions & 0 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,18 @@ ClrDataAccess::GetRegisterName(int regNum, unsigned int count, _Inout_updates_z_
{
W("eax"), W("ecx"), W("edx"), W("ebx"), W("esp"), W("ebp"), W("esi"), W("edi"),
};
#elif defined(TARGET_LOONGARCH64)
static const WCHAR *regs[] =
{
W("R0"), W("AT"), W("V0"), W("V1"),
W("A0"), W("A1"), W("A2"), W("A3"),
W("A4"), W("A5"), W("A6"), W("A7"),
W("T0"), W("T1"), W("T2"), W("T3"),
W("T8"), W("T9"), W("S0"), W("S1"),
W("S2"), W("S3"), W("S4"), W("S5"),
W("S6"), W("S7"), W("K0"), W("K1"),
W("GP"), W("SP"), W("FP"), W("RA")
};
#endif

// Caller frame registers are encoded as "-(reg+1)".
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/debug/dbgutil/elfreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ Elf64_Ehdr::Elf64_Ehdr()
e_machine = EM_X86_64;
#elif defined(TARGET_ARM64)
e_machine = EM_AARCH64;
#elif defined(TARGET_LOONGARCH64)
e_machine = EM_LOONGARCH;
#endif
e_flags = 0;
e_version = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/di/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if(CLR_CMAKE_HOST_WIN32)
endif()
elseif(CLR_CMAKE_HOST_UNIX)

if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_ARM)
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
set(CORDBDI_SOURCES_ASM_FILE
${ARCH_SOURCES_DIR}/floatconversion.S
)
Expand Down
Loading