Author: Igor Kudrin
Date: 2025-08-07T13:01:52-07:00
New Revision: 11e1d465860903fd9ead27c0c1e60de4439011db

URL: 
https://github.com/llvm/llvm-project/commit/11e1d465860903fd9ead27c0c1e60de4439011db
DIFF: 
https://github.com/llvm/llvm-project/commit/11e1d465860903fd9ead27c0c1e60de4439011db.diff

LOG: [lldb] Fix UBSan complaints for #151460

Added: 
    

Modified: 
    lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
    lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h 
b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
index 021ec49b3d2be..bca5bff24bff0 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -46,9 +46,9 @@ class RegisterInfoPOSIX_arm64
 
   // based on RegisterContextDarwin_arm64.h
   // Pack this so there are no extra bytes, but align its start address to at
-  // least 4 bytes to prevent alignment errors on Arm 32-bit.
+  // least 8 bytes to prevent alignment errors.
   LLVM_PACKED_START
-  struct alignas(4) GPR {
+  struct alignas(8) GPR {
     uint64_t x[29]; // x0-x28
     uint64_t fp;    // x29
     uint64_t lr;    // x30

diff  --git a/lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp 
b/lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp
index 08296da564976..c6bfe0fa68759 100644
--- a/lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp
+++ b/lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp
@@ -62,7 +62,7 @@ struct Arch64EmulatorTester : public EmulateInstructionARM64 {
       reg_value.SetUInt64(tester->gpr.pc);
       return true;
     case gpr_cpsr_arm64:
-      reg_value.SetUInt64(tester->gpr.cpsr);
+      reg_value.SetUInt32(tester->gpr.cpsr);
       return true;
     default:
       return false;
@@ -97,7 +97,7 @@ struct Arch64EmulatorTester : public EmulateInstructionARM64 {
       tester->gpr.pc = reg_value.GetAsUInt64();
       return true;
     case gpr_cpsr_arm64:
-      tester->gpr.cpsr = reg_value.GetAsUInt64();
+      tester->gpr.cpsr = reg_value.GetAsUInt32();
       return true;
     default:
       return false;
@@ -112,7 +112,7 @@ struct Arch64EmulatorTester : public 
EmulateInstructionARM64 {
     assert(addr - tester->memory_offset + length <= sizeof(tester->memory));
     if (addr >= tester->memory_offset &&
         addr - tester->memory_offset + length <= sizeof(tester->memory)) {
-      memcpy(dst, tester->memory + addr - tester->memory_offset, length);
+      memcpy(dst, tester->memory + (addr - tester->memory_offset), length);
       return length;
     }
     return 0;


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to