[Lldb-commits] [lldb] r228261 - Don't wait for the dynamic loader to set a module as a dynamic link editor, figure it out through the ObjectFile.

Greg Clayton gclayton at apple.com
Wed Feb 4 18:01:34 PST 2015


Author: gclayton
Date: Wed Feb  4 20:01:34 2015
New Revision: 228261

URL: http://llvm.org/viewvc/llvm-project?rev=228261&view=rev
Log:
Don't wait for the dynamic loader to set a module as a dynamic link editor, figure it out through the ObjectFile.

Background: dyld binaries often have extra symbols in their symbol table like "malloc" and "free" for the early bringup of dyld and we often don't want to set breakpoints in dynamic linker binaries. We also don't want to call the "malloc" or "free" function in dyld when a user writes an expression like "(void *)malloc(123)" so we need to avoid doing name lookups in dyld. We mark Modules as being dynamic link editors and this helps do correct lookups for breakpoints by name and function lookups.

<rdar://problem/19716267>


Modified:
    lldb/trunk/include/lldb/Core/Module.h
    lldb/trunk/include/lldb/Symbol/ObjectFile.h
    lldb/trunk/source/Core/Module.cpp
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h

Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=228261&r1=228260&r2=228261&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Wed Feb  4 20:01:34 2015
@@ -941,17 +941,8 @@ public:
                               const ConstString &object_name);
 
     bool
-    GetIsDynamicLinkEditor () const
-    {
-        return m_is_dynamic_loader_module;
-    }
-    
-    void
-    SetIsDynamicLinkEditor (bool b)
-    {
-        m_is_dynamic_loader_module = b;
-    }
-    
+    GetIsDynamicLinkEditor ();
+
     ClangASTContext &
     GetClangASTContext ();
 
@@ -1124,8 +1115,7 @@ protected:
     bool                        m_did_load_objfile:1,
                                 m_did_load_symbol_vendor:1,
                                 m_did_parse_uuid:1,
-                                m_did_init_ast:1,
-                                m_is_dynamic_loader_module:1;
+                                m_did_init_ast:1;
     mutable bool                m_file_has_changed:1,
                                 m_first_file_changed_log:1;   /// See if the module was modified after it was initially opened.
     

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=228261&r1=228260&r2=228261&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Wed Feb  4 20:01:34 2015
@@ -767,6 +767,23 @@ public:
         return 0;
     }
 
+
+    //------------------------------------------------------------------
+    /// Return true if this file is a dynamic link editor (dyld)
+    ///
+    /// Often times dyld has symbols that mirror symbols in libc and
+    /// other shared libraries (like "malloc" and "free") and the user
+    /// does _not_ want to stop in these shared libraries by default.
+    /// We can ask the ObjectFile if it is such a file and should be
+    /// avoided for things like settings breakpoints and doing function
+    /// lookups for expressions.
+    //------------------------------------------------------------------
+    virtual bool
+    GetIsDynamicLinkEditor()
+    {
+        return false;
+    }
+
     //------------------------------------------------------------------
     // Member Functions
     //------------------------------------------------------------------

Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=228261&r1=228260&r2=228261&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Wed Feb  4 20:01:34 2015
@@ -152,7 +152,6 @@ Module::Module (const ModuleSpec &module
     m_did_load_symbol_vendor (false),
     m_did_parse_uuid (false),
     m_did_init_ast (false),
-    m_is_dynamic_loader_module (false),
     m_file_has_changed (false),
     m_first_file_changed_log (false)
 {
@@ -257,7 +256,6 @@ Module::Module(const FileSpec& file_spec
     m_did_load_symbol_vendor (false),
     m_did_parse_uuid (false),
     m_did_init_ast (false),
-    m_is_dynamic_loader_module (false),
     m_file_has_changed (false),
     m_first_file_changed_log (false)
 {
@@ -304,7 +302,6 @@ Module::Module () :
     m_did_load_symbol_vendor (false),
     m_did_parse_uuid (false),
     m_did_init_ast (false),
-    m_is_dynamic_loader_module (false),
     m_file_has_changed (false),
     m_first_file_changed_log (false)
 {
@@ -1825,3 +1822,13 @@ Module::CreateJITModule (const lldb::Obj
     return ModuleSP();
 }
 
+bool
+Module::GetIsDynamicLinkEditor()
+{
+    ObjectFile * obj_file = GetObjectFile ();
+
+    if (obj_file)
+        return obj_file->GetIsDynamicLinkEditor();
+
+    return false;
+}

Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=228261&r1=228260&r2=228261&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Wed Feb  4 20:01:34 2015
@@ -832,9 +832,6 @@ DynamicLoaderMacOSXDYLD::AddModulesUsing
 
         if (image_module_sp)
         {
-            if (image_infos[idx].header.filetype == llvm::MachO::MH_DYLINKER)
-                image_module_sp->SetIsDynamicLinkEditor (true);
-
             ObjectFile *objfile = image_module_sp->GetObjectFile ();
             if (objfile)
             {

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=228261&r1=228260&r2=228261&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Feb  4 20:01:34 2015
@@ -5296,6 +5296,12 @@ ObjectFileMachO::GetSDKVersion(uint32_t
 }
 
 
+bool
+ObjectFileMachO::GetIsDynamicLinkEditor()
+{
+    return m_header.filetype == llvm::MachO::MH_DYLINKER;
+}
+
 //------------------------------------------------------------------
 // PluginInterface protocol
 //------------------------------------------------------------------

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h?rev=228261&r1=228260&r2=228261&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h Wed Feb  4 20:01:34 2015
@@ -173,7 +173,10 @@ public:
     
     virtual uint32_t
     GetSDKVersion (uint32_t *versions, uint32_t num_versions);
-    
+
+    virtual bool
+    GetIsDynamicLinkEditor();
+
     static bool
     ParseHeader (lldb_private::DataExtractor &data,
                  lldb::offset_t *data_offset_ptr,





More information about the lldb-commits mailing list