[Lldb-commits] [lldb] 25ebed5 - [lldb][windows] refactor null handling in DynamicLoaderWindowsDYLD (#200821)

via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 1 07:53:01 PDT 2026


Author: Charles Zablit
Date: 2026-06-01T15:52:56+01:00
New Revision: 25ebed5fc05af9263300e381c684b3202fec3b2f

URL: https://github.com/llvm/llvm-project/commit/25ebed5fc05af9263300e381c684b3202fec3b2f
DIFF: https://github.com/llvm/llvm-project/commit/25ebed5fc05af9263300e381c684b3202fec3b2f.diff

LOG: [lldb][windows] refactor null handling in DynamicLoaderWindowsDYLD (#200821)

This patch thightens the null guards.

---------

Co-authored-by: Nerixyz <nero.9 at hotmail.de>

Added: 
    

Modified: 
    lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
index 79fb4d46eff41..b0ea55c96f48f 100644
--- a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
@@ -139,7 +139,7 @@ void DynamicLoaderWindowsDYLD::DidAttach() {
 
   ModuleSP executable = GetTargetExecutable();
 
-  if (!executable.get())
+  if (!executable)
     return;
 
   // Try to fetch the load address of the file from the process, since there
@@ -168,7 +168,7 @@ void DynamicLoaderWindowsDYLD::DidLaunch() {
   LLDB_LOGF(log, "DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
 
   ModuleSP executable = GetTargetExecutable();
-  if (!executable.get())
+  if (!executable)
     return;
 
   lldb::addr_t load_addr = GetLoadAddress(executable);
@@ -194,7 +194,11 @@ DynamicLoaderWindowsDYLD::GetStepThroughTrampolinePlan(Thread &thread,
     return ThreadPlanSP();
   }
 
-  uint64_t pc = thread.GetRegisterContext()->GetPC();
+  RegisterContextSP reg_ctx_sp = thread.GetRegisterContext();
+  if (!reg_ctx_sp)
+    return ThreadPlanSP();
+
+  uint64_t pc = reg_ctx_sp->GetPC();
   // Max size of an instruction in x86 is 15 bytes.
   AddressRange range(pc, 2 * 15);
 
@@ -204,10 +208,7 @@ DynamicLoaderWindowsDYLD::GetStepThroughTrampolinePlan(Thread &thread,
     return ThreadPlanSP();
   }
 
-  InstructionList *insn_list = &disassembler_sp->GetInstructionList();
-  if (insn_list == nullptr) {
-    return ThreadPlanSP();
-  }
+  InstructionList &insn_list = disassembler_sp->GetInstructionList();
 
   // First instruction in a x86 Windows trampoline is going to be an indirect
   // jump through the IAT and the next one will be a nop (usually there for
@@ -215,15 +216,19 @@ DynamicLoaderWindowsDYLD::GetStepThroughTrampolinePlan(Thread &thread,
   //     0x70ff4cfc <+956>: jmpl   *0x7100c2a8
   //     0x70ff4d02 <+962>: nop
 
-  auto first_insn = insn_list->GetInstructionAtIndex(0);
-  auto second_insn = insn_list->GetInstructionAtIndex(1);
+  auto first_insn = insn_list.GetInstructionAtIndex(0);
+  auto second_insn = insn_list.GetInstructionAtIndex(1);
 
   ExecutionContext exe_ctx(m_process->GetTarget());
-  if (first_insn == nullptr || second_insn == nullptr ||
-      strcmp(first_insn->GetMnemonic(&exe_ctx), "jmpl") != 0 ||
-      strcmp(second_insn->GetMnemonic(&exe_ctx), "nop") != 0) {
+  if (first_insn == nullptr || second_insn == nullptr)
+    return ThreadPlanSP();
+
+  const char *first_mnemonic = first_insn->GetMnemonic(&exe_ctx);
+  const char *second_mnemonic = second_insn->GetMnemonic(&exe_ctx);
+  if (!first_mnemonic || !second_mnemonic ||
+      strcmp(first_mnemonic, "jmpl") != 0 ||
+      strcmp(second_mnemonic, "nop") != 0)
     return ThreadPlanSP();
-  }
 
   assert(first_insn->DoesBranch() && !second_insn->DoesBranch());
 


        


More information about the lldb-commits mailing list