Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 6e3c1a6

Browse files
authored
Merge pull request #6328 from ramarag/arm64debugger
Implementing Arm64 Debugger Requirements
2 parents c358f77 + 00e3695 commit 6e3c1a6

29 files changed

+909
-79
lines changed

functions.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ endfunction(convert_to_absolute_path)
4747
#Preprocess exports definition file
4848
function(preprocess_def_file inputFilename outputFilename)
4949
get_compile_definitions(PREPROCESS_DEFINITIONS)
50-
50+
get_include_directories(ASM_INCLUDE_DIRECTORIES)
5151
add_custom_command(
5252
OUTPUT ${outputFilename}
53-
COMMAND ${CMAKE_CXX_COMPILER} /P /EP /TC ${PREPROCESS_DEFINITIONS} /Fi${outputFilename} ${inputFilename}
53+
COMMAND ${CMAKE_CXX_COMPILER} ${ASM_INCLUDE_DIRECTORIES} /P /EP /TC ${PREPROCESS_DEFINITIONS} /Fi${outputFilename} ${inputFilename}
5454
DEPENDS ${inputFilename}
5555
COMMENT "Preprocessing ${inputFilename}"
5656
)
@@ -185,4 +185,4 @@ function(_install)
185185
if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
186186
install(${ARGV})
187187
endif()
188-
endfunction()
188+
endfunction()

src/debug/daccess/dacdbiimpl.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5238,6 +5238,11 @@ void DacDbiInterfaceImpl::Hijack(
52385238
ctx.R1 = (DWORD)espRecord;
52395239
ctx.R2 = (DWORD)reason;
52405240
ctx.R3 = (DWORD)pData;
5241+
#elif defined(_TARGET_ARM64_)
5242+
ctx.X0 = (DWORD64)espContext;
5243+
ctx.X1 = (DWORD64)espRecord;
5244+
ctx.X2 = (DWORD64)reason;
5245+
ctx.X3 = (DWORD64)pData;
52415246
#else
52425247
PORTABILITY_ASSERT("CordbThread::HijackForUnhandledException is not implemented on this platform.");
52435248
#endif

src/debug/di/CMakeLists.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,30 @@ if(WIN32)
3434
#use static crt
3535
add_definitions(-MT)
3636

37+
if (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)
38+
set(CORDBDI_SOURCES_ASM_FILE ${ARCH_SOURCES_DIR}/floatconversion.asm)
39+
endif()
3740
if (CLR_CMAKE_TARGET_ARCH_AMD64)
3841
set(CORDBDI_SOURCES
3942
${CORDBDI_SOURCES}
40-
${ARCH_SOURCES_DIR}/floatconversion.asm
43+
${CORDBDI_SOURCES_ASM_FILE}
4144
)
45+
elseif (CLR_CMAKE_TARGET_ARCH_ARM64 AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
46+
convert_to_absolute_path(CORDBDI_SOURCES_ASM_FILE ${CORDBDI_SOURCES_ASM_FILE})
47+
get_compile_definitions(ASM_DEFINITIONS)
48+
set(ASM_OPTIONS /c /Zi /W3 /errorReport:prompt)
49+
# asm files require preprocessing using cl.exe on arm64
50+
get_filename_component(name ${CORDBDI_SOURCES_ASM_FILE} NAME_WE)
51+
set(ASM_PREPROCESSED_FILE ${CMAKE_CURRENT_BINARY_DIR}/${name}.asm)
52+
preprocess_def_file(${CORDBDI_SOURCES_ASM_FILE} ${ASM_PREPROCESSED_FILE})
53+
set(CORDBDI_SOURCES_WKS_PREPROCESSED_ASM ${ASM_PREPROCESSED_FILE})
54+
55+
set_property(SOURCE ${CORDBDI_SOURCES_WKS_PREPROCESSED_ASM} PROPERTY COMPILE_DEFINITIONS ${ASM_DEFINITIONS})
56+
set_property(SOURCE ${CORDBDI_SOURCES_WKS_PREPROCESSED_ASM} PROPERTY COMPILE_DEFINITIONS ${ASM_OPTIONS})
57+
set(CORDBDI_SOURCES
58+
${CORDBDI_SOURCES}
59+
${CORDBDI_SOURCES_WKS_PREPROCESSED_ASM}
60+
)
4261
endif()
4362
elseif(CLR_CMAKE_PLATFORM_UNIX)
4463
add_compile_options(-fPIC)
@@ -54,4 +73,5 @@ endif(WIN32)
5473

5574
add_precompiled_header(stdafx.h stdafx.cpp CORDBDI_SOURCES)
5675

76+
5777
add_library_clr(cordbdi STATIC ${CORDBDI_SOURCES})

src/debug/di/DI.props

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@
7676
<CppCompile Include="@(SourcesPublish)" />
7777
<CppCompile Include="@(SourcesShim)" />
7878
<CppCompile Include="@(SourcesRightside)" />
79-
<AssembleAmd64 Condition="'$(BuildArchitecture)' == 'amd64'" Include="..\amd64\floatconversion.asm" />
79+
<AssembleAmd64 Condition="'$(BuildArchitecture)' == 'amd64' and '$(CrossTargetArchitecture)' != 'arm64'" Include="..\amd64\floatconversion.asm" />
80+
</ItemGroup>
81+
<ItemGroup Condition="'$(BuildArchitecture)' == 'arm64'">
82+
<PreprocessAssembleArm Include="..\arm64\floatconversion.asm" />
83+
<AssembleArm64 Include="$(IntermediateOutputDirectory)\floatconversion.i" />
8084
</ItemGroup>
8185
<!--Import the targets-->
8286
</Project>

src/debug/di/arm64/cordbregisterset.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ HRESULT CordbRegisterSet::GetRegisters(ULONG64 mask, ULONG32 regCount,
6565

6666
// @ARM64TODO: floating point support
6767

68-
for (int i = REGISTER_ARM64_X0;
69-
i <= REGISTER_ARM64_PC && iRegister < regCount;
68+
for (int i = REGISTER_ARM64_PC;
69+
i <= REGISTER_ARM64_LR && iRegister < regCount;
7070
i++)
7171
{
7272
if (mask & SETBITULONG64(i))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; Licensed to the .NET Foundation under one or more agreements.
2+
; The .NET Foundation licenses this file to you under the MIT license.
3+
; See the LICENSE file in the project root for more information.
4+
5+
;; ==++==
6+
;;
7+
8+
;;
9+
;; ==--==
10+
#include "ksarm64.h"
11+
12+
;; Arguments
13+
;; input: (in X0) the _NEON128 value to be converted to a double
14+
;; output: the double corresponding to the _NEON128 input value
15+
16+
LEAF_ENTRY FPFillR8
17+
LDR Q0, [X0]
18+
ret lr
19+
LEAF_END
20+
21+
;; Must be at very end of file
22+
END

src/debug/di/module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4114,9 +4114,9 @@ HRESULT CordbNativeCode::GetReturnValueLiveOffset(ULONG32 ILoffset, ULONG32 buff
41144114
int CordbNativeCode::GetCallInstructionLength(BYTE *ip, ULONG32 count)
41154115
{
41164116
#if defined(DBG_TARGET_ARM)
4117-
return E_NOTIMPL;
4117+
return MAX_INSTRUCTION_LENGTH;
41184118
#elif defined(DBG_TARGET_ARM64)
4119-
return E_NOTIMPL;
4119+
return MAX_INSTRUCTION_LENGTH;
41204120
#elif defined(DBG_TARGET_X86)
41214121
if (count < 2)
41224122
return -1;

src/debug/di/rspriv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6097,7 +6097,7 @@ class CordbThread : public CordbBase, public ICorDebugThread,
60976097
// Converts the values in the floating point register area of the context to real number values.
60986098
void Get32bitFPRegisters(CONTEXT * pContext);
60996099

6100-
#elif defined(DBG_TARGET_AMD64)
6100+
#elif defined(DBG_TARGET_AMD64) || defined(DBG_TARGET_ARM64)
61016101
// Converts the values in the floating point register area of the context to real number values.
61026102
void Get64bitFPRegisters(FPRegister64 * rgContextFPRegisters, int start, int nRegisters);
61036103
#endif // DBG_TARGET_X86

src/debug/di/rsthread.cpp

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,8 +1432,20 @@ HRESULT CordbThread::FindFrame(ICorDebugFrame ** ppFrame, FramePointer fp)
14321432
return E_FAIL;
14331433
}
14341434

1435+
14351436
#if !defined(DBG_TARGET_ARM) // @ARMTODO
14361437

1438+
#if defined(CROSS_COMPILE) && defined(_TARGET_ARM64_)
1439+
extern "C" double FPFillR8(void* pFillSlot)
1440+
{
1441+
_ASSERTE(!"nyi for platform");
1442+
return 0;
1443+
}
1444+
#elif defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_)
1445+
extern "C" double FPFillR8(void* pFillSlot);
1446+
#endif
1447+
1448+
14371449
#if defined(_TARGET_X86_)
14381450

14391451
// CordbThread::Get32bitFPRegisters
@@ -1496,8 +1508,7 @@ void CordbThread::Get32bitFPRegisters(CONTEXT * pContext)
14961508
m_floatStackTop = floatStackTop;
14971509
} // CordbThread::Get32bitFPRegisters
14981510

1499-
#elif defined(_TARGET_AMD64_)
1500-
extern "C" double FPFillR8(void* pFillSlot);
1511+
#elif defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_)
15011512

15021513
// CordbThread::Get64bitFPRegisters
15031514
// Converts the values in the floating point register area of the context to real number values. See
@@ -1525,7 +1536,6 @@ void CordbThread::Get64bitFPRegisters(FPRegister64 * rgContextFPRegisters, int s
15251536
}
15261537
} // CordbThread::Get64bitFPRegisters
15271538

1528-
15291539
#endif // _TARGET_X86_
15301540

15311541
// CordbThread::LoadFloatState
@@ -1556,6 +1566,10 @@ void CordbThread::LoadFloatState()
15561566
#elif defined(_TARGET_AMD64_)
15571567
// we have no fixed-value registers, so we begin with the first one and initialize all 16
15581568
Get64bitFPRegisters((FPRegister64*) &(tempContext.Xmm0), 0, 16);
1569+
#elif defined(_TARGET_ARM64_)
1570+
Get64bitFPRegisters((FPRegister64*) &(tempContext.V), 0, 32);
1571+
#else
1572+
_ASSERTE(!"nyi for platform");
15591573
#endif // !_TARGET_X86_
15601574

15611575
m_fFloatStateValid = true;
@@ -6991,6 +7005,8 @@ HRESULT CordbNativeFrame::GetLocalRegisterValue(CorDebugRegister reg,
69917005
if ((reg >= REGISTER_X86_FPSTACK_0) && (reg <= REGISTER_X86_FPSTACK_7))
69927006
#elif defined(DBG_TARGET_AMD64)
69937007
if ((reg >= REGISTER_AMD64_XMM0) && (reg <= REGISTER_AMD64_XMM15))
7008+
#elif defined(DBG_TARGET_ARM64)
7009+
if ((reg >= REGISTER_ARM64_V0) && (reg <= REGISTER_ARM64_V31))
69947010
#endif
69957011
{
69967012
return GetLocalFloatingPointValue(reg, pType, ppValue);
@@ -7239,6 +7255,11 @@ HRESULT CordbNativeFrame::GetLocalFloatingPointValue(DWORD index,
72397255
(index <= REGISTER_AMD64_XMM15)))
72407256
return E_INVALIDARG;
72417257
index -= REGISTER_AMD64_XMM0;
7258+
#elif defined(DBG_TARGET_ARM64)
7259+
if (!((index >= REGISTER_ARM64_V0) &&
7260+
(index <= REGISTER_ARM64_V31)))
7261+
return E_INVALIDARG;
7262+
index -= REGISTER_ARM64_V0;
72427263
#else
72437264
if (!((index >= REGISTER_X86_FPSTACK_0) &&
72447265
(index <= REGISTER_X86_FPSTACK_7)))
@@ -8941,20 +8962,25 @@ HRESULT CordbJITILFrame::GetReturnValueForILOffsetImpl(ULONG32 ILoffset, ICorDeb
89418962

89428963
HRESULT CordbJITILFrame::GetReturnValueForType(CordbType *pType, ICorDebugValue **ppReturnValue)
89438964
{
8944-
#if defined(DBG_TARGET_ARM) || defined(DBG_TARGET_ARM64)
8965+
#if defined(DBG_TARGET_ARM)
89458966
return E_NOTIMPL;
89468967
#else
89478968

8969+
89488970
#if defined(DBG_TARGET_X86)
89498971
const CorDebugRegister floatRegister = REGISTER_X86_FPSTACK_0;
89508972
#elif defined(DBG_TARGET_AMD64)
89518973
const CorDebugRegister floatRegister = REGISTER_AMD64_XMM0;
8974+
#elif defined(DBG_TARGET_ARM64)
8975+
const CorDebugRegister floatRegister = REGISTER_ARM64_V0;
89528976
#endif
89538977

89548978
#if defined(DBG_TARGET_X86)
89558979
const CorDebugRegister ptrRegister = REGISTER_X86_EAX;
89568980
#elif defined(DBG_TARGET_AMD64)
89578981
const CorDebugRegister ptrRegister = REGISTER_AMD64_RAX;
8982+
#elif defined(DBG_TARGET_ARM64)
8983+
const CorDebugRegister ptrRegister = REGISTER_ARM64_X0;
89588984
#endif
89598985

89608986
CorElementType corReturnType = pType->GetElementType();

src/debug/di/shimstackwalk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ void ShimStackWalk::AppendChain(ChainInfo * pChainInfo, StackWalkInfo * pStackWa
10971097
// We need to send an extra enter-managed chain.
10981098
_ASSERTE(pChainInfo->m_fLeafNativeContextIsValid);
10991099
BYTE * sp = reinterpret_cast<BYTE *>(CORDbgGetSP(&(pChainInfo->m_leafNativeContext)));
1100-
#ifndef _TARGET_ARM_
1100+
#if !defined(_TARGET_ARM_) && !defined(_TARGET_ARM64_)
11011101
// Dev11 324806: on ARM we use the caller's SP for a frame's ending delimiter so we cannot
11021102
// subtract 4 bytes from the chain's ending delimiter else the frame might never be in range.
11031103
// TODO: revisit overlapping ranges on ARM, it would be nice to make it consistent with the other architectures.

0 commit comments

Comments
 (0)