From 95e2949a5352aea0182ba5295bf9ba46080c261e Mon Sep 17 00:00:00 2001 From: Emmmer Date: Tue, 16 Aug 2022 15:35:38 +0800 Subject: [LLDB] Fix possible nullptr exception Some architectures do not have a flag register (like riscv). In this case, we should set it to `baton.m_register_values.end()` to avoid nullptr exception. Reviewed By: DavidSpickett Differential Revision: https://reviews.llvm.org/D131945 --- .../Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp') diff --git a/lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp b/lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp index ee5295bf6565..f9520cf4cfb7 100644 --- a/lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp +++ b/lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp @@ -128,8 +128,10 @@ Status NativeProcessSoftwareSingleStep::SetupSoftwareSingleStepping( auto pc_it = baton.m_register_values.find(reg_info_pc->kinds[eRegisterKindDWARF]); - auto flags_it = - baton.m_register_values.find(reg_info_flags->kinds[eRegisterKindDWARF]); + auto flags_it = reg_info_flags == nullptr + ? baton.m_register_values.end() + : baton.m_register_values.find( + reg_info_flags->kinds[eRegisterKindDWARF]); lldb::addr_t next_pc; lldb::addr_t next_flags; -- cgit v1.2.3