[Lldb-commits] [lldb] [lldb][windows] refactor null handling in DynamicLoaderWindowsDYLD (PR #200821)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 1 06:47:21 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Charles Zablit (charles-zablit)
<details>
<summary>Changes</summary>
This patch thightens the null guards.
---
Full diff: https://github.com/llvm/llvm-project/pull/200821.diff
1 Files Affected:
- (modified) lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp (+19-12)
``````````diff
diff --git a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
index 79fb4d46eff41..0c9fe73d4d62c 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,13 +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();
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/200821
More information about the lldb-commits
mailing list