[Lldb-commits] [lldb] Clean up PlatformDarwinKernel::GetSharedModule, document (PR #78652)
Will Hawkins via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 18 20:39:28 PST 2024
================
@@ -836,36 +834,18 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
module_sp.reset(new Module(kern_spec));
if (module_sp && module_sp->GetObjectFile() &&
module_sp->MatchesModuleSpec(kern_spec)) {
- // module_sp is an actual kernel binary we want to add.
- if (process) {
- const bool notify = false;
- process->GetTarget().GetImages().AppendIfNeeded(module_sp, notify);
- error.Clear();
- return error;
- } else {
- error = ModuleList::GetSharedModule(kern_spec, module_sp, nullptr,
- nullptr, nullptr);
- if (module_sp && module_sp->GetObjectFile() &&
- module_sp->GetObjectFile()->GetType() !=
- ObjectFile::Type::eTypeCoreFile) {
- return error;
- }
- module_sp.reset();
- }
+ if (did_create_ptr)
+ *did_create_ptr = true;
+ return {};
}
}
}
// Give the generic methods, including possibly calling into DebugSymbols
// framework on macOS systems, a chance.
- error = PlatformDarwin::GetSharedModule(module_spec, process, module_sp,
- module_search_paths_ptr, old_modules,
- did_create_ptr);
- if (error.Success() && module_sp.get()) {
- return error;
- }
-
- return error;
+ return PlatformDarwin::GetSharedModule(module_spec, process, module_sp,
----------------
hawkinsw wrote:
I am *sure* that this is a dumb question, so forgive me ...
It seems like we can end up here with a "useless" pointer to an instance of `Module` in `module_sp`. Fortunately, the first thing that `PlatformDarwin::GetSharedModule` does is to reset that pointer which means that there is no leak. However, would it make sense to do a `reset` before calling just in case the code in that function changes in the future?
Again, I apologize if this is a stupid question!
https://github.com/llvm/llvm-project/pull/78652
More information about the lldb-commits
mailing list