[Lldb-commits] [PATCH] D58303: [win] Resolve the module only if there isn't one already

Stella Stamenova via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 15 13:41:53 PST 2019


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB354172: [win] Resolve the module only if there isn't one already (authored by stella.stamenova, committed by ).

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D58303

Files:
  source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
  source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
  source/Plugins/Process/Windows/Common/ProcessWindows.cpp


Index: source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===================================================================
--- source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -924,9 +924,7 @@
   }
 
   if (auto dyld = GetDynamicLoader())
-    dyld->OnLoadModule(
-        ModuleSpec(module->GetFileSpec(), module->GetArchitecture()),
-        image_base);
+    dyld->OnLoadModule(module, ModuleSpec(), image_base);
 
   // Add the main executable module to the list of pending module loads.  We
   // can't call GetTarget().ModulesDidLoad() here because we still haven't
@@ -1033,7 +1031,7 @@
 void ProcessWindows::OnLoadDll(const ModuleSpec &module_spec,
                                lldb::addr_t module_addr) {
   if (auto dyld = GetDynamicLoader())
-    dyld->OnLoadModule(module_spec, module_addr);
+    dyld->OnLoadModule(nullptr, module_spec, module_addr);
 }
 
 void ProcessWindows::OnUnloadDll(lldb::addr_t module_addr) {
Index: source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
===================================================================
--- source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
+++ source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
@@ -29,7 +29,8 @@
 
   static DynamicLoader *CreateInstance(Process *process, bool force);
 
-  void OnLoadModule(const ModuleSpec &module_spec, lldb::addr_t module_addr);
+  void OnLoadModule(lldb::ModuleSP module_sp, const ModuleSpec module_spec,
+                    lldb::addr_t module_addr);
   void OnUnloadModule(lldb::addr_t module_addr);
 
   void DidAttach() override;
Index: source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
===================================================================
--- source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
+++ source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
@@ -62,19 +62,26 @@
   return nullptr;
 }
 
-void DynamicLoaderWindowsDYLD::OnLoadModule(const ModuleSpec &module_spec,
+void DynamicLoaderWindowsDYLD::OnLoadModule(lldb::ModuleSP module_sp,
+                                            const ModuleSpec module_spec,
                                             lldb::addr_t module_addr) {
-  // Confusingly, there is no Target::AddSharedModule.  Instead, calling
-  // GetSharedModule() with a new module will add it to the module list and
-  // return a corresponding ModuleSP.
-  Status error;
-  ModuleSP module_sp =
-      m_process->GetTarget().GetSharedModule(module_spec, &error);
-  if (error.Fail())
-    return;
+
+  // Resolve the module unless we already have one.
+  if (!module_sp) {
+    // Confusingly, there is no Target::AddSharedModule.  Instead, calling
+    // GetSharedModule() with a new module will add it to the module list and
+    // return a corresponding ModuleSP.
+    Status error;
+    module_sp = m_process->GetTarget().GetSharedModule(module_spec, &error);
+    if (error.Fail())
+      return;
+  }
 
   m_loaded_modules[module_sp] = module_addr;
   UpdateLoadedSectionsCommon(module_sp, module_addr, false);
+  ModuleList module_list;
+  module_list.Append(module_sp);
+  m_process->GetTarget().ModulesDidLoad(module_list);
 }
 
 void DynamicLoaderWindowsDYLD::OnUnloadModule(lldb::addr_t module_addr) {
@@ -86,6 +93,9 @@
   if (module_sp) {
     m_loaded_modules.erase(module_sp);
     UnloadSectionsCommon(module_sp);
+    ModuleList module_list;
+    module_list.Append(module_sp);
+    m_process->GetTarget().ModulesDidUnload(module_list, false);
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58303.187078.patch
Type: text/x-patch
Size: 3627 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190215/b78c1bc6/attachment-0001.bin>


More information about the lldb-commits mailing list