[Lldb-commits] [lldb] [lldb][debugserver][MacOSX] Work around sanitizer misaligned address errors when reading exception data (PR #132193)

via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 20 04:57:24 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 17b4be8f63a9a2c17290c8540d84f17a370b1915 223d85c6b2f5509f704d598bae974a98e5bf6bcb --extensions cpp,h -- lldb/tools/debugserver/source/MacOSX/MachException.cpp lldb/tools/debugserver/source/MacOSX/MachException.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lldb/tools/debugserver/source/MacOSX/MachException.cpp b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
index d05b47cd9b..5a652d9339 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachException.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
@@ -18,21 +18,21 @@
 #include "PThreadMutex.h"
 #include "SysSignal.h"
 #include <cerrno>
+#include <inttypes.h>
 #include <sys/ptrace.h>
 #include <sys/types.h>
-#include <inttypes.h>
 
-static void AppendExceptionData(
-        std::vector<mach_exception_data_type_t> &out,
-        mach_exception_data_t Data, mach_msg_type_number_t Count) {
+static void AppendExceptionData(std::vector<mach_exception_data_type_t> &out,
+                                mach_exception_data_t Data,
+                                mach_msg_type_number_t Count) {
   mach_exception_data_type_t Buf;
   for (mach_msg_type_number_t i = 0; i < Count; ++i) {
     // The input Data we receive need not be aligned correctly.
     // Perform an unaligned copy by pretending we're dealing with
     // a char* buffer. This is required to work around UBSAN/ASAN
     // "misaligned address" errors.
-    auto * src = reinterpret_cast<char*>(&Buf);
-    auto * dst = reinterpret_cast<char*>(Data + i);
+    auto *src = reinterpret_cast<char *>(&Buf);
+    auto *dst = reinterpret_cast<char *>(Data + i);
     memcpy(dst, src, sizeof(mach_exception_data_type_t));
     out.push_back(Buf);
   }
@@ -115,7 +115,8 @@ catch_mach_exception_raise(mach_port_t exc_port, mach_port_t thread_port,
     std::vector<mach_exception_data_type_t> exc_datas;
     AppendExceptionData(exc_datas, exc_data, exc_data_count);
     DNBLogThreaded("::%s ( exc_port = 0x%4.4x, thd_port = 0x%4.4x, tsk_port = "
-                   "0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%" PRIx64 ", "
+                   "0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%" PRIx64
+                   ", "
                    "0x%" PRIx64 " })",
                    __FUNCTION__, exc_port, thread_port, task_port, exc_type,
                    MachException::Name(exc_type), exc_data_count,

``````````

</details>


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


More information about the lldb-commits mailing list