diff options
| author | Carlo Kok <ck@remobjects.com> | 2016-06-06 09:40:27 +0000 |
|---|---|---|
| committer | Carlo Kok <ck@remobjects.com> | 2016-06-06 09:40:27 +0000 |
| commit | 490d18b3c5d92f63cf03b351fc4eb38ea2a69cb4 (patch) | |
| tree | 8e7eba721d658b2a1a55422a114ba9bebc0b67aa /lldb/source/Plugins/Process/Windows/Common | |
| parent | 26a56adaea535bbe7894e428a67026c76be7c6e0 (diff) | |
| download | bcm5719-llvm-490d18b3c5d92f63cf03b351fc4eb38ea2a69cb4.tar.gz bcm5719-llvm-490d18b3c5d92f63cf03b351fc4eb38ea2a69cb4.zip | |
(Minor tweak) Make RegisterContextWindows_x86/x64::GetRegisterInfoAtIndex
return NULL for an invalid register.
The unwind logic asks for the "return address register" which doesn't exist
on x86/x86_64, returns -1 and calls this with -1 as a parameter, ends up
out of scope of the array bounds for g_register_infos and later SIGSEGVs
on accessing. This now matches the other GetRegisterInfoAtIndex for
other platforms.
llvm-svn: 271876
Diffstat (limited to 'lldb/source/Plugins/Process/Windows/Common')
| -rw-r--r-- | lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp b/lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp index 103cff4a2a5..3a9c31a0b77 100644 --- a/lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp @@ -136,6 +136,8 @@ RegisterInfo g_register_infos[] = { nullptr}, }; +static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos); + // Array of lldb register numbers used to define the set of all General Purpose Registers uint32_t g_gpr_reg_indices[] = {eRegisterIndexRax, eRegisterIndexRbx, eRegisterIndexRcx, eRegisterIndexRdx, eRegisterIndexRdi, eRegisterIndexRsi, eRegisterIndexR8, eRegisterIndexR9, @@ -169,7 +171,9 @@ RegisterContextWindows_x64::GetRegisterCount() const RegisterInfo * RegisterContextWindows_x64::GetRegisterInfoAtIndex(size_t reg) { - return &g_register_infos[reg]; + if (reg < k_num_register_infos) + return &g_register_infos[reg]; + return NULL; } size_t diff --git a/lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp b/lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp index a95561d20b9..11733eee7cb 100644 --- a/lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp @@ -64,6 +64,7 @@ RegisterInfo g_register_infos[] = { DEFINE_GPR(eip, "pc"), { ehframe_eip_i386, dwarf_eip_i386, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, lldb_eip_i386 }, nullptr, nullptr}, { DEFINE_GPR_BIN(eflags, "flags"), { ehframe_eflags_i386, dwarf_eflags_i386, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, lldb_eflags_i386}, nullptr, nullptr}, }; +static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos); // Array of lldb register numbers used to define the set of all General Purpose Registers uint32_t g_gpr_reg_indices[] = @@ -106,7 +107,9 @@ RegisterContextWindows_x86::GetRegisterCount() const RegisterInfo * RegisterContextWindows_x86::GetRegisterInfoAtIndex(size_t reg) { - return &g_register_infos[reg]; + if (reg < k_num_register_infos) + return &g_register_infos[reg]; + return NULL; } size_t |

