[Lldb-commits] [lldb] r354172 - [win] Resolve the module only if there isn't one already

Stella Stamenova via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 15 13:40:59 PST 2019


Author: stella.stamenova
Date: Fri Feb 15 13:40:59 2019
New Revision: 354172

URL: http://llvm.org/viewvc/llvm-project?rev=354172&view=rev
Log:
[win] Resolve the module only if there isn't one already

Summary:
This commit modifies the OnLoadModule method to resolve the module
unless we already have one

Change by Hui Huang to fix the failing LLDB tests on Windows

Reviewers: labath, asmith

Subscribers: abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D58303

Modified:
    lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
    lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
    lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp

Modified: lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp?rev=354172&r1=354171&r2=354172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp Fri Feb 15 13:40:59 2019
@@ -62,19 +62,26 @@ DynamicLoader *DynamicLoaderWindowsDYLD:
   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 @@ void DynamicLoaderWindowsDYLD::OnUnloadM
   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);
   }
 }
 

Modified: lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h?rev=354172&r1=354171&r2=354172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h Fri Feb 15 13:40:59 2019
@@ -29,7 +29,8 @@ public:
 
   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;

Modified: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp?rev=354172&r1=354171&r2=354172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp Fri Feb 15 13:40:59 2019
@@ -924,9 +924,7 @@ void ProcessWindows::OnDebuggerConnected
   }
 
   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::OnExitThread(lldb::
 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) {




More information about the lldb-commits mailing list