[Lldb-commits] [lldb] 95e2949 - [LLDB] Fix possible nullptr exception

via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 16 08:41:10 PDT 2022


Author: Emmmer
Date: 2022-08-16T23:41:00+08:00
New Revision: 95e2949a5352aea0182ba5295bf9ba46080c261e

URL: https://github.com/llvm/llvm-project/commit/95e2949a5352aea0182ba5295bf9ba46080c261e
DIFF: https://github.com/llvm/llvm-project/commit/95e2949a5352aea0182ba5295bf9ba46080c261e.diff

LOG: [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

Added: 
    

Modified: 
    lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp b/lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp
index ee5295bf65651..f9520cf4cfb75 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;


        


More information about the lldb-commits mailing list