[Lldb-commits] [lldb] r121069 - in /lldb/trunk: include/lldb/Core/ModuleList.h include/lldb/lldb-enumerations.h source/Breakpoint/Breakpoint.cpp source/Core/ModuleList.cpp source/Target/Target.cpp

Greg Clayton gclayton at apple.com
Mon Dec 6 15:51:26 PST 2010


Author: gclayton
Date: Mon Dec  6 17:51:26 2010
New Revision: 121069

URL: http://llvm.org/viewvc/llvm-project?rev=121069&view=rev
Log:
When shared libraries are unloaded, they are now removed from the target
ModuleList so they don't show up in the images. Breakpoint locations that are
in shared libraries that get unloaded will persist though so that if you
have plug-ins that load/unload and you have a breakpoint set on functions
in the plug-ins, the hit counts will persist between loads/unloads.


Modified:
    lldb/trunk/include/lldb/Core/ModuleList.h
    lldb/trunk/include/lldb/lldb-enumerations.h
    lldb/trunk/source/Breakpoint/Breakpoint.cpp
    lldb/trunk/source/Core/ModuleList.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Core/ModuleList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=121069&r1=121068&r2=121069&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ModuleList.h (original)
+++ lldb/trunk/include/lldb/Core/ModuleList.h Mon Dec  6 17:51:26 2010
@@ -313,6 +313,9 @@
     bool
     Remove (lldb::ModuleSP &module_sp);
 
+    size_t
+    Remove (ModuleList &module_list);
+    
     bool
     ResolveFileAddress (lldb::addr_t vm_addr,
                         Address& so_addr);

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=121069&r1=121068&r2=121069&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Mon Dec  6 17:51:26 2010
@@ -56,7 +56,8 @@
 {
     eLaunchFlagNone         = 0u,
     eLaunchFlagDisableASLR  = (1u << 0),  ///< Disable Address Space Layout Randomization
-    eLaunchFlagDisableSTDIO = (1u << 1)   /// Disable stdio for inferior process (e.g. for a GUI app)
+    eLaunchFlagDisableSTDIO = (1u << 1),  ///< Disable stdio for inferior process (e.g. for a GUI app)
+    eLaunchFlagLaunchInTTY  = (1u << 2)   ///< Launch the process in a new TTY if supported by the host 
 } LaunchFlags;
     
 //----------------------------------------------------------------------

Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=121069&r1=121068&r2=121069&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Mon Dec  6 17:51:26 2010
@@ -291,9 +291,9 @@
             if (!m_filter_sp->ModulePasses (module_sp))
                 continue;
 
-            for (size_t j = 0; j < m_locations.GetSize(); j++)
+            for (size_t loc_idx = 0; loc_idx < m_locations.GetSize(); loc_idx++)
             {
-                BreakpointLocationSP break_loc = m_locations.GetByIndex(j);
+                BreakpointLocationSP break_loc = m_locations.GetByIndex(loc_idx);
                 if (!break_loc->IsEnabled())
                     continue;
                 const Section *section = break_loc->GetAddress().GetSection();
@@ -333,24 +333,22 @@
         for (size_t i = 0; i < module_list.GetSize(); i++)
         {
             ModuleSP module_sp (module_list.GetModuleAtIndex (i));
-            if (!m_filter_sp->ModulePasses (module_sp))
-                continue;
-
-            for (size_t j = 0; j < m_locations.GetSize(); j++)
+            if (m_filter_sp->ModulePasses (module_sp))
             {
-                BreakpointLocationSP break_loc = m_locations.GetByIndex(j);
-                const Section *section = break_loc->GetAddress().GetSection();
-                if (section)
+                const size_t num_locs = m_locations.GetSize();
+                for (size_t loc_idx = 0; loc_idx < num_locs; ++loc_idx)
                 {
-                    if (section->GetModule() == module_sp.get())
+                    BreakpointLocationSP break_loc = m_locations.GetByIndex(loc_idx);
+                    const Section *section = break_loc->GetAddress().GetSection();
+                    if (section && section->GetModule() == module_sp.get())
+                    {
+                        // Remove this breakpoint since the shared library is 
+                        // unloaded, but keep the breakpoint location around
+                        // so we always get complete hit count and breakpoint
+                        // lifetime info
                         break_loc->ClearBreakpointSite();
+                    }
                 }
-//                else
-//                {
-//                    Address temp_addr;
-//                    if (module->ResolveLoadAddress(break_loc->GetLoadAddress(), m_target->GetProcess(), temp_addr))
-//                        break_loc->ClearBreakpointSite();
-//                }
             }
         }
     }

Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=121069&r1=121068&r2=121069&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Mon Dec  6 17:51:26 2010
@@ -97,6 +97,20 @@
     return false;
 }
 
+size_t
+ModuleList::Remove (ModuleList &module_list)
+{
+    Mutex::Locker locker(m_modules_mutex);
+    size_t num_removed = 0;
+    collection::iterator pos, end = module_list.m_modules.end();
+    for (pos = module_list.m_modules.begin(); pos != end; ++pos)
+    {
+        if (Remove (*pos))
+            ++num_removed;
+    }
+    return num_removed;
+}
+
 
 
 void

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=121069&r1=121068&r2=121069&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Mon Dec  6 17:51:26 2010
@@ -576,6 +576,10 @@
 Target::ModulesDidUnload (ModuleList &module_list)
 {
     m_breakpoint_list.UpdateBreakpoints (module_list, false);
+
+    // Remove the images from the target image list
+    m_images.Remove(module_list);
+
     // TODO: make event data that packages up the module_list
     BroadcastEvent (eBroadcastBitModulesUnloaded, NULL);
 }





More information about the lldb-commits mailing list