[Lldb-commits] [lldb] e194d89 - [lldb/MachO] "Fix" intentional out-of-bounds error (NFC)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Dec 18 12:54:11 PST 2019
Author: Jonas Devlieghere
Date: 2019-12-18T12:54:04-08:00
New Revision: e194d890126007bc8e5acb655f007ef76002edb7
URL: https://github.com/llvm/llvm-project/commit/e194d890126007bc8e5acb655f007ef76002edb7
DIFF: https://github.com/llvm/llvm-project/commit/e194d890126007bc8e5acb655f007ef76002edb7.diff
LOG: [lldb/MachO] "Fix" intentional out-of-bounds error (NFC)
Remove the hack that populates the cpsr register in the gpr struct by
writing past the end of the array. This was tripping up ASan.
Patch by: Reva Cuthbertson
Added:
Modified:
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 57c43de0c945..ef6ad1696c47 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -479,12 +479,13 @@ class RegisterContextDarwin_arm_Mach : public RegisterContextDarwin_arm {
switch (flavor) {
case GPRAltRegSet:
case GPRRegSet:
- for (uint32_t i = 0; i < count; ++i) {
+ // On ARM, the CPSR register is also included in the count but it is
+ // not included in gpr.r so loop until (count-1).
+ for (uint32_t i = 0; i < (count - 1); ++i) {
gpr.r[i] = data.GetU32(&offset);
}
-
- // Note that gpr.cpsr is also copied by the above loop; this loop
- // technically extends one element past the end of the gpr.r[] array.
+ // Save cpsr explicitly.
+ gpr.cpsr = data.GetU32(&offset);
SetError(GPRRegSet, Read, 0);
offset = next_thread_state;
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
index 94eebabfe2e0..173e66904151 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
@@ -1140,10 +1140,11 @@ bool RegisterContextDarwin_arm::ReadRegister(const RegisterInfo *reg_info,
case gpr_sp:
case gpr_lr:
case gpr_pc:
- case gpr_cpsr:
value.SetUInt32(gpr.r[reg - gpr_r0]);
break;
-
+ case gpr_cpsr:
+ value.SetUInt32(gpr.cpsr);
+ break;
case fpu_s0:
case fpu_s1:
case fpu_s2:
More information about the lldb-commits
mailing list