[Lldb-commits] [lldb] [lldb] [debugserver] address preprocessor warning, extra arg (PR #90808)

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Thu May 2 11:07:43 PDT 2024


================
@@ -169,25 +173,28 @@ kern_return_t DNBArchMachARM64::GetGPRState(bool force) {
                          (thread_state_t)&m_state.context.gpr, &count);
   if (DNBLogEnabledForAny(LOG_THREAD)) {
     uint64_t *x = &m_state.context.gpr.__x[0];
+
+#if defined(DEBUGSERVER_IS_ARM64E)
     DNBLogThreaded("thread_get_state signed regs "
                    "\n   fp=%16.16llx"
                    "\n   lr=%16.16llx"
                    "\n   sp=%16.16llx"
                    "\n   pc=%16.16llx",
-#if __has_feature(ptrauth_calls) && defined(__LP64__)
                    reinterpret_cast<uint64_t>(m_state.context.gpr.__opaque_fp),
                    reinterpret_cast<uint64_t>(m_state.context.gpr.__opaque_lr),
                    reinterpret_cast<uint64_t>(m_state.context.gpr.__opaque_sp),
-                   reinterpret_cast<uint64_t>(m_state.context.gpr.__opaque_pc)
+                   reinterpret_cast<uint64_t>(m_state.context.gpr.__opaque_pc));
 #else
-                   m_state.context.gpr.__fp,
-                   m_state.context.gpr.__lr, 
-                   m_state.context.gpr.__sp,
-                   m_state.context.gpr.__pc
+    DNBLogThreaded("thread_get_state signed regs "
+                   "\n   fp=%16.16llx"
+                   "\n   lr=%16.16llx"
+                   "\n   sp=%16.16llx"
+                   "\n   pc=%16.16llx",
+                   m_state.context.gpr.__fp, m_state.context.gpr.__lr,
+                   m_state.context.gpr.__sp, m_state.context.gpr.__pc);
----------------
bulbazord wrote:

Suggestion: The format string is the same between these two, why not pull out the common factor? 
```
const char *format = "thread_get_state signed regs\n   fp=%16.16llx\n   lr=%16.16llx\n   sp=%16.16llx\n   pc=%16.16llx";
#if defined(...)
    DNBLogThreaded(format, ...);
#else
    DNBLogThreaded(format, ...);
#endif
```

You could also pull out the arguments.

https://github.com/llvm/llvm-project/pull/90808


More information about the lldb-commits mailing list