2626#include < cinttypes>
2727#include < sys/sysctl.h>
2828
29+ #undef DEBUGSERVER_IS_ARM64E
2930#if __has_feature(ptrauth_calls)
3031#include < ptrauth.h>
32+ #if defined(__LP64__)
33+ #define DEBUGSERVER_IS_ARM64E 1
34+ #endif
3135#endif
3236
3337// Break only in privileged or user mode
@@ -115,7 +119,7 @@ static uint64_t clear_pac_bits(uint64_t value) {
115119uint64_t DNBArchMachARM64::GetPC (uint64_t failValue) {
116120 // Get program counter
117121 if (GetGPRState (false ) == KERN_SUCCESS)
118- #if __has_feature(ptrauth_calls) && defined(__LP64__ )
122+ #if defined(DEBUGSERVER_IS_ARM64E )
119123 return clear_pac_bits (
120124 reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_pc ));
121125#else
@@ -147,7 +151,7 @@ kern_return_t DNBArchMachARM64::SetPC(uint64_t value) {
147151uint64_t DNBArchMachARM64::GetSP (uint64_t failValue) {
148152 // Get stack pointer
149153 if (GetGPRState (false ) == KERN_SUCCESS)
150- #if __has_feature(ptrauth_calls) && defined(__LP64__ )
154+ #if defined(DEBUGSERVER_IS_ARM64E )
151155 return clear_pac_bits (
152156 reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_sp ));
153157#else
@@ -169,25 +173,24 @@ kern_return_t DNBArchMachARM64::GetGPRState(bool force) {
169173 (thread_state_t )&m_state.context.gpr, &count);
170174 if (DNBLogEnabledForAny(LOG_THREAD)) {
171175 uint64_t *x = &m_state.context .gpr .__x [0 ];
172- DNBLogThreaded (" thread_get_state signed regs "
173- " \n fp=%16.16llx"
174- " \n lr=%16.16llx"
175- " \n sp=%16.16llx"
176- " \n pc=%16.16llx" ,
177- #if __has_feature(ptrauth_calls) && defined(__LP64__)
176+
177+ const char *log_str = " thread_get_state signed regs "
178+ " \n fp=%16.16llx"
179+ " \n lr=%16.16llx"
180+ " \n sp=%16.16llx"
181+ " \n pc=%16.16llx" ;
182+ #if defined(DEBUGSERVER_IS_ARM64E)
183+ DNBLogThreaded (log_str,
178184 reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_fp ),
179185 reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_lr ),
180186 reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_sp ),
181- reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_pc )
187+ reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_pc ));
182188#else
183- m_state.context .gpr .__fp ,
184- m_state.context .gpr .__lr ,
185- m_state.context .gpr .__sp ,
186- m_state.context .gpr .__pc
189+ DNBLogThreaded (log_str, m_state.context .gpr .__fp , m_state.context .gpr .__lr ,
190+ m_state.context .gpr .__sp , m_state.context .gpr .__pc );
187191#endif
188- );
189192
190- #if __has_feature(ptrauth_calls) && defined(__LP64__ )
193+ #if defined(DEBUGSERVER_IS_ARM64E )
191194 uint64_t log_fp = clear_pac_bits (
192195 reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_fp ));
193196 uint64_t log_lr = clear_pac_bits (
@@ -661,7 +664,7 @@ kern_return_t DNBArchMachARM64::EnableHardwareSingleStep(bool enable) {
661664 return err.Status ();
662665 }
663666
664- #if __has_feature(ptrauth_calls) && defined(__LP64__ )
667+ #if defined(DEBUGSERVER_IS_ARM64E )
665668 uint64_t pc = clear_pac_bits (
666669 reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_pc ));
667670#else
@@ -2187,7 +2190,7 @@ bool DNBArchMachARM64::GetRegisterValue(uint32_t set, uint32_t reg,
21872190 case e_regSetGPR:
21882191 if (reg <= gpr_pc) {
21892192 switch (reg) {
2190- #if __has_feature(ptrauth_calls) && defined(__LP64__ )
2193+ #if defined(DEBUGSERVER_IS_ARM64E )
21912194 case gpr_pc:
21922195 value->value .uint64 = clear_pac_bits (
21932196 reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_pc ));
0 commit comments