26
26
#include < cinttypes>
27
27
#include < sys/sysctl.h>
28
28
29
+ #undef DEBUGSERVER_IS_ARM64E
29
30
#if __has_feature(ptrauth_calls)
30
31
#include < ptrauth.h>
32
+ #if defined(__LP64__)
33
+ #define DEBUGSERVER_IS_ARM64E 1
34
+ #endif
31
35
#endif
32
36
33
37
// Break only in privileged or user mode
@@ -115,7 +119,7 @@ static uint64_t clear_pac_bits(uint64_t value) {
115
119
uint64_t DNBArchMachARM64::GetPC (uint64_t failValue) {
116
120
// Get program counter
117
121
if (GetGPRState (false ) == KERN_SUCCESS)
118
- #if __has_feature(ptrauth_calls) && defined(__LP64__ )
122
+ #if defined(DEBUGSERVER_IS_ARM64E )
119
123
return clear_pac_bits (
120
124
reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_pc ));
121
125
#else
@@ -147,7 +151,7 @@ kern_return_t DNBArchMachARM64::SetPC(uint64_t value) {
147
151
uint64_t DNBArchMachARM64::GetSP (uint64_t failValue) {
148
152
// Get stack pointer
149
153
if (GetGPRState (false ) == KERN_SUCCESS)
150
- #if __has_feature(ptrauth_calls) && defined(__LP64__ )
154
+ #if defined(DEBUGSERVER_IS_ARM64E )
151
155
return clear_pac_bits (
152
156
reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_sp ));
153
157
#else
@@ -169,25 +173,24 @@ kern_return_t DNBArchMachARM64::GetGPRState(bool force) {
169
173
(thread_state_t )&m_state.context.gpr, &count);
170
174
if (DNBLogEnabledForAny(LOG_THREAD)) {
171
175
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,
178
184
reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_fp ),
179
185
reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_lr ),
180
186
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 ));
182
188
#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 );
187
191
#endif
188
- );
189
192
190
- #if __has_feature(ptrauth_calls) && defined(__LP64__ )
193
+ #if defined(DEBUGSERVER_IS_ARM64E )
191
194
uint64_t log_fp = clear_pac_bits (
192
195
reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_fp ));
193
196
uint64_t log_lr = clear_pac_bits (
@@ -661,7 +664,7 @@ kern_return_t DNBArchMachARM64::EnableHardwareSingleStep(bool enable) {
661
664
return err.Status ();
662
665
}
663
666
664
- #if __has_feature(ptrauth_calls) && defined(__LP64__ )
667
+ #if defined(DEBUGSERVER_IS_ARM64E )
665
668
uint64_t pc = clear_pac_bits (
666
669
reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_pc ));
667
670
#else
@@ -2187,7 +2190,7 @@ bool DNBArchMachARM64::GetRegisterValue(uint32_t set, uint32_t reg,
2187
2190
case e_regSetGPR:
2188
2191
if (reg <= gpr_pc) {
2189
2192
switch (reg) {
2190
- #if __has_feature(ptrauth_calls) && defined(__LP64__ )
2193
+ #if defined(DEBUGSERVER_IS_ARM64E )
2191
2194
case gpr_pc:
2192
2195
value->value .uint64 = clear_pac_bits (
2193
2196
reinterpret_cast <uint64_t >(m_state.context .gpr .__opaque_pc ));
0 commit comments