[Lldb-commits] [lldb] r143249 - in /lldb/trunk: include/lldb/Core/SearchFilter.h include/lldb/Target/Platform.h include/lldb/Target/Target.h source/Core/SearchFilter.cpp source/Plugins/Platform/MacOSX/PlatformDarwin.cpp source/Plugins/Platform/MacOSX/PlatformDarwin.h source/Target/Platform.cpp source/Target/Target.cpp

Jim Ingham jingham at apple.com
Fri Oct 28 16:14:11 PDT 2011


Author: jingham
Date: Fri Oct 28 18:14:11 2011
New Revision: 143249

URL: http://llvm.org/viewvc/llvm-project?rev=143249&view=rev
Log:
Added the ability for the target to specify Modules that will not be searched
when setting breakpoints, but only if no module is specified.  The Darwin 
platform uses this to not set breakpoints in dyld.

Modified:
    lldb/trunk/include/lldb/Core/SearchFilter.h
    lldb/trunk/include/lldb/Target/Platform.h
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/source/Core/SearchFilter.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
    lldb/trunk/source/Target/Platform.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Core/SearchFilter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SearchFilter.h?rev=143249&r1=143248&r2=143249&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/SearchFilter.h (original)
+++ lldb/trunk/include/lldb/Core/SearchFilter.h Fri Oct 28 18:14:11 2011
@@ -274,6 +274,24 @@
 };
 
 //----------------------------------------------------------------------
+/// @class SearchFilterForNonModuleSpecificSearches SearchFilter.h "lldb/Core/SearchFilter.h"
+/// @brief This is a SearchFilter that searches through all modules.  It also consults the Target::ModuleIsExcludedForNonModuleSpecificSearches.
+//----------------------------------------------------------------------
+class SearchFilterForNonModuleSpecificSearches :
+    public SearchFilter
+{
+public:
+    SearchFilterForNonModuleSpecificSearches (lldb::TargetSP &targetSP) : SearchFilter(targetSP) {};
+    ~SearchFilterForNonModuleSpecificSearches () {}
+    
+    virtual bool 
+    ModulePasses (const FileSpec &module_spec);
+    
+    virtual bool
+    ModulePasses (const lldb::ModuleSP &module_sp);
+};
+
+//----------------------------------------------------------------------
 /// @class SearchFilterByModule SearchFilter.h "lldb/Core/SearchFilter.h"
 /// @brief This is a SearchFilter that restricts the search to a given module.
 //----------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=143249&r1=143248&r2=143249&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Fri Oct 28 18:14:11 2011
@@ -417,7 +417,15 @@
             m_sdk_build = sdk_build;
         }    
         
-
+        // There may be modules that we don't want to find by default for operations like "setting breakpoint by name".
+        // The platform will return "true" from this call if the passed in module happens to be one of these.
+        
+        virtual bool
+        ModuleIsExcludedForNonModuleSpecificSearches (Target &target, const lldb::ModuleSP &module_sp)
+        {
+            return false;
+        }
+                
     protected:
         bool m_is_host;
         // Set to true when we are able to actually set the OS version while 

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=143249&r1=143248&r2=143249&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Fri Oct 28 18:14:11 2011
@@ -96,6 +96,12 @@
     {
         return m_max_strlen_length;
     }
+    
+    bool
+    GetBreakpointsConsultPlatformAvoidList ()
+    {
+        return m_breakpoints_use_platform_avoid;
+    }
 
 protected:
 
@@ -113,6 +119,7 @@
     PathMappingList m_source_map;
     uint32_t m_max_children_display;
     uint32_t m_max_strlen_length;
+    OptionValueBoolean m_breakpoints_use_platform_avoid;
     
 
 };
@@ -482,6 +489,48 @@
     {
         return m_images;
     }
+    
+    
+    //------------------------------------------------------------------
+    /// Return whether this FileSpec corresponds to a module that should be considered for general searches.
+    ///
+    /// This API will be consulted by the SearchFilterForNonModuleSpecificSearches
+    /// and any module that returns \b true will not be searched.  Note the
+    /// SearchFilterForNonModuleSpecificSearches is the search filter that
+    /// gets used in the CreateBreakpoint calls when no modules is provided.
+    ///
+    /// The target call at present just consults the Platform's call of the
+    /// same name.
+    /// 
+    /// @param[in] module_sp
+    ///     A shared pointer reference to the module that checked.
+    ///
+    /// @return \b true if the module should be excluded, \b false otherwise.
+    //------------------------------------------------------------------
+    const bool
+    ModuleIsExcludedForNonModuleSpecificSearches (const FileSpec &module_spec);
+    
+    //------------------------------------------------------------------
+    /// Return whether this module should be considered for general searches.
+    ///
+    /// This API will be consulted by the SearchFilterForNonModuleSpecificSearches
+    /// and any module that returns \b true will not be searched.  Note the
+    /// SearchFilterForNonModuleSpecificSearches is the search filter that
+    /// gets used in the CreateBreakpoint calls when no modules is provided.
+    ///
+    /// The target call at present just consults the Platform's call of the
+    /// same name.
+    ///
+    /// FIXME: When we get time we should add a way for the user to set modules that they
+    /// don't want searched, in addition to or instead of the platform ones.
+    /// 
+    /// @param[in] module_sp
+    ///     A shared pointer reference to the module that checked.
+    ///
+    /// @return \b true if the module should be excluded, \b false otherwise.
+    //------------------------------------------------------------------
+    const bool
+    ModuleIsExcludedForNonModuleSpecificSearches (const lldb::ModuleSP &module_sp);
 
     ArchSpec &
     GetArchitecture ()

Modified: lldb/trunk/source/Core/SearchFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SearchFilter.cpp?rev=143249&r1=143248&r2=143249&view=diff
==============================================================================
--- lldb/trunk/source/Core/SearchFilter.cpp (original)
+++ lldb/trunk/source/Core/SearchFilter.cpp Fri Oct 28 18:14:11 2011
@@ -287,6 +287,29 @@
 }
 
 //----------------------------------------------------------------------
+//  SearchFilterForNonModuleSpecificSearches:
+//  Selects a shared library matching a given file spec, consulting the targets "black list".
+//----------------------------------------------------------------------
+
+    bool 
+    SearchFilterForNonModuleSpecificSearches::ModulePasses (const FileSpec &module_spec)
+    {
+        if (m_target_sp->ModuleIsExcludedForNonModuleSpecificSearches (module_spec))
+            return false;
+        else
+            return true;
+    }
+    
+    bool
+    SearchFilterForNonModuleSpecificSearches::ModulePasses (const lldb::ModuleSP &module_sp)
+    {
+        if (m_target_sp->ModuleIsExcludedForNonModuleSpecificSearches (module_sp))
+            return false;
+        else
+            return true;
+    }
+
+//----------------------------------------------------------------------
 //  SearchFilterByModule:
 //  Selects a shared library matching a given file spec
 //----------------------------------------------------------------------

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=143249&r1=143248&r2=143249&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Fri Oct 28 18:14:11 2011
@@ -481,4 +481,16 @@
     return NULL;
 }
 
-
+bool
+PlatformDarwin::ModuleIsExcludedForNonModuleSpecificSearches (lldb_private::Target &target, const lldb::ModuleSP &module_sp)
+{
+    ObjectFile *obj_file = module_sp->GetObjectFile();
+    if (!obj_file)
+        return false;
+    
+    ObjectFile::Type obj_type = obj_file->GetType();
+    if (obj_type == ObjectFile::eTypeDynamicLinker)
+        return true;
+    else
+        return false;
+}

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h?rev=143249&r1=143248&r2=143249&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h Fri Oct 28 18:14:11 2011
@@ -85,6 +85,9 @@
             lldb_private::Listener &listener, 
             lldb_private::Error &error);
 
+    virtual bool
+    ModuleIsExcludedForNonModuleSpecificSearches (lldb_private::Target &target, const lldb::ModuleSP &module_sp);
+                
 protected:
     lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote darwin OS
 

Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=143249&r1=143248&r2=143249&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Fri Oct 28 18:14:11 2011
@@ -591,4 +591,3 @@
     }
     return process_sp;
 }
-

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=143249&r1=143248&r2=143249&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Fri Oct 28 18:14:11 2011
@@ -252,7 +252,7 @@
 Target::CreateBreakpoint (Address &addr, bool internal)
 {
     TargetSP target_sp = this->GetSP();
-    SearchFilterSP filter_sp(new SearchFilter (target_sp));
+    SearchFilterSP filter_sp(new SearchFilterForNonModuleSpecificSearches (target_sp));
     BreakpointResolverSP resolver_sp (new BreakpointResolverAddress (NULL, addr));
     return CreateBreakpoint (filter_sp, resolver_sp, internal);
 }
@@ -295,7 +295,7 @@
     else
     {
         if (m_search_filter_sp.get() == NULL)
-            m_search_filter_sp.reset (new SearchFilter (target_sp));
+            m_search_filter_sp.reset (new SearchFilterForNonModuleSpecificSearches (target_sp));
         filter_sp = m_search_filter_sp;
     }
     return filter_sp;
@@ -315,7 +315,7 @@
     else
     {
         if (m_search_filter_sp.get() == NULL)
-            m_search_filter_sp.reset (new SearchFilter (target_sp));
+            m_search_filter_sp.reset (new SearchFilterForNonModuleSpecificSearches (target_sp));
         filter_sp = m_search_filter_sp;
     }
     return filter_sp;
@@ -934,6 +934,50 @@
     BroadcastEvent (eBroadcastBitModulesUnloaded, NULL);
 }
 
+
+const bool
+Target::ModuleIsExcludedForNonModuleSpecificSearches (const FileSpec &module_spec)
+{
+
+    if (!m_breakpoints_use_platform_avoid)
+        return false;
+    else
+    {
+        ModuleList matchingModules;
+        const ArchSpec *arch_ptr = NULL;
+        const lldb_private::UUID *uuid_ptr= NULL;
+        const ConstString *object_name = NULL;
+        size_t num_modules = GetImages().FindModules(&module_spec, arch_ptr, uuid_ptr, object_name, matchingModules);
+        
+        // If there is more than one module for this file spec, only return true if ALL the modules are on the
+        // black list.
+        if (num_modules > 0)
+        {
+            for (int i  = 0; i < num_modules; i++)
+            {
+                if (!ModuleIsExcludedForNonModuleSpecificSearches (matchingModules.GetModuleAtIndex(i)))
+                    return false;
+            }
+            return true;
+        }
+        else
+            return false;
+    }
+}
+
+const bool
+Target::ModuleIsExcludedForNonModuleSpecificSearches (const lldb::ModuleSP &module_sp)
+{
+    if (!m_breakpoints_use_platform_avoid)
+        return false;
+    else if (GetPlatform())
+    {
+        return GetPlatform()->ModuleIsExcludedForNonModuleSpecificSearches (*this, module_sp);
+    }
+    else
+        return false;
+}
+
 size_t
 Target::ReadMemoryFromFileCache (const Address& addr, void *dst, size_t dst_len, Error &error)
 {
@@ -1935,6 +1979,7 @@
 #define TSC_SOURCE_MAP        "source-map"
 #define TSC_MAX_CHILDREN      "max-children-count"
 #define TSC_MAX_STRLENSUMMARY "max-string-summary-length"
+#define TSC_PLATFORM_AVOID    "breakpoints-use-platform-avoid-list"
 
 
 static const ConstString &
@@ -1986,6 +2031,14 @@
     return g_const_string;
 }
 
+static const ConstString &
+GetSettingNameForPlatformAvoid ()
+{
+    static ConstString g_const_string (TSC_PLATFORM_AVOID);
+    return g_const_string;
+}
+
+
 bool
 Target::SettingsController::SetGlobalVariable (const ConstString &var_name,
                                                const char *index_value,
@@ -2039,7 +2092,8 @@
     m_skip_prologue (true, true),
     m_source_map (NULL, NULL),
     m_max_children_display(256),
-    m_max_strlen_length(1024)
+    m_max_strlen_length(1024),
+    m_breakpoints_use_platform_avoid (true, true)
 {
     // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called
     // until the vtables for TargetInstanceSettings are properly set up, i.e. AFTER all the initializers.
@@ -2067,7 +2121,8 @@
     m_skip_prologue (rhs.m_skip_prologue),
     m_source_map (rhs.m_source_map),
     m_max_children_display(rhs.m_max_children_display),
-    m_max_strlen_length(rhs.m_max_strlen_length)
+    m_max_strlen_length(rhs.m_max_strlen_length),
+    m_breakpoints_use_platform_avoid (rhs.m_breakpoints_use_platform_avoid)
 {
     if (m_instance_name != InstanceSettings::GetDefaultName())
     {
@@ -2214,6 +2269,10 @@
                 break;
         }        
     }
+    else if (var_name == GetSettingNameForPlatformAvoid ())
+    {
+        err = UserSettingsController::UpdateBooleanOptionValue (value, op, m_breakpoints_use_platform_avoid);
+    }
 }
 
 void
@@ -2224,12 +2283,13 @@
     if (!new_settings_ptr)
         return;
     
-    m_expr_prefix_file          = new_settings_ptr->m_expr_prefix_file;
-    m_expr_prefix_contents_sp   = new_settings_ptr->m_expr_prefix_contents_sp;
-    m_prefer_dynamic_value      = new_settings_ptr->m_prefer_dynamic_value;
-    m_skip_prologue             = new_settings_ptr->m_skip_prologue;
-    m_max_children_display      = new_settings_ptr->m_max_children_display;
-    m_max_strlen_length         = new_settings_ptr->m_max_strlen_length;
+    m_expr_prefix_file               = new_settings_ptr->m_expr_prefix_file;
+    m_expr_prefix_contents_sp        = new_settings_ptr->m_expr_prefix_contents_sp;
+    m_prefer_dynamic_value           = new_settings_ptr->m_prefer_dynamic_value;
+    m_skip_prologue                  = new_settings_ptr->m_skip_prologue;
+    m_max_children_display           = new_settings_ptr->m_max_children_display;
+    m_max_strlen_length              = new_settings_ptr->m_max_strlen_length;
+    m_breakpoints_use_platform_avoid = new_settings_ptr->m_breakpoints_use_platform_avoid;
 }
 
 bool
@@ -2271,6 +2331,13 @@
         count_str.Printf ("%d", m_max_strlen_length);
         value.AppendString (count_str.GetData());
     }
+    else if (var_name == GetSettingNameForPlatformAvoid())
+    {
+        if (m_breakpoints_use_platform_avoid)
+            value.AppendString ("true");
+        else
+            value.AppendString ("false");
+    }
     else 
     {
         if (err)
@@ -2326,5 +2393,6 @@
     { TSC_SOURCE_MAP        , eSetVarTypeArray  , NULL          , NULL,                  false, false, "Source path remappings to use when locating source files from debug information." },
     { TSC_MAX_CHILDREN      , eSetVarTypeInt    , "256"         , NULL,                  true,  false, "Maximum number of children to expand in any level of depth." },
     { TSC_MAX_STRLENSUMMARY , eSetVarTypeInt    , "1024"        , NULL,                  true,  false, "Maximum number of characters to show when using %s in summary strings." },
+    { TSC_PLATFORM_AVOID    , eSetVarTypeBoolean, "true"        , NULL,                  false, false, "Consult the platform module avoid list when setting non-module specific breakpoints." },
     { NULL                  , eSetVarTypeNone   , NULL          , NULL,                  false, false, NULL }
 };





More information about the lldb-commits mailing list