[Lldb-commits] [PATCH] D145547: When setting load addresses on darwin kernel kexts, handle case where in-memory load commands are not updated

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 8 16:43:50 PST 2023


jasonmolenda marked an inline comment as done.
jasonmolenda added inline comments.


================
Comment at: lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:835
+                      m_name.c_str(), m_uuid.GetAsString().c_str());
+            m_module_sp.reset();
+          }
----------------
JDevlieghere wrote:
> What's the purpose of reseting the shared pointer? It'll just go out of scope right after. 
No, this method is trying a few different ways to find the on-disk binary for the kext, and it puts that Module in m_module_sp once it finds it.  (there's a bunch of blocks that start like `if (!m_module_sp) { ... try another way of finding the Module ...}` and the goal when we have a non-kext/non-kernel image that is already in the Target is to avoid re-loading it into the Target.  So by clearing it, we're behaving as if it couldn't be found.  

altho, tbh, looking this method I could just `return` here and it would accomplish the same.  And be clearer.


================
Comment at: lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:881-883
+        ObjectFileMachO *memory_objfile_macho =
+            llvm::dyn_cast<ObjectFileMachO>(memory_object_file);
+        if (memory_objfile_macho) {
----------------
JDevlieghere wrote:
> Since you already did it for `Section` below...
> ```
> if(ObjectFileMachO *memory_objfile_macho =
>             llvm::dyn_cast<ObjectFileMachO>(memory_object_file)) {
> ```
yeah, I thought about that but it made for a really long line that would be a multi-line expression in the `if` and i wasn't thrilled about it.  but i don't care that much.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145547/new/

https://reviews.llvm.org/D145547



More information about the lldb-commits mailing list