summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2015-02-05 02:01:34 +0000
committerGreg Clayton <gclayton@apple.com>2015-02-05 02:01:34 +0000
commit08928f308b0a7a738e1e9a14d0531db00cd8bf15 (patch)
tree8a94b0942755d08569e2d97d01ac5ce13f76241f
parent50ad72705182f9313578c587d6142e9d92dbe964 (diff)
downloadbcm5719-llvm-08928f308b0a7a738e1e9a14d0531db00cd8bf15.tar.gz
bcm5719-llvm-08928f308b0a7a738e1e9a14d0531db00cd8bf15.zip
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> llvm-svn: 228261
-rw-r--r--lldb/include/lldb/Core/Module.h16
-rw-r--r--lldb/include/lldb/Symbol/ObjectFile.h17
-rw-r--r--lldb/source/Core/Module.cpp13
-rw-r--r--lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp3
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp6
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h5
6 files changed, 40 insertions, 20 deletions
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index bfde7cbc5db..60fbb989502 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -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.
diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h
index bdc6ae8c9e8..8bcf92de42e 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -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
//------------------------------------------------------------------
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 1672eed8fb9..891bd87a20d 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -152,7 +152,6 @@ Module::Module (const ModuleSpec &module_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)
{
@@ -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::ObjectFileJITDelegateSP &delegate_sp)
return ModuleSP();
}
+bool
+Module::GetIsDynamicLinkEditor()
+{
+ ObjectFile * obj_file = GetObjectFile ();
+
+ if (obj_file)
+ return obj_file->GetIsDynamicLinkEditor();
+
+ return false;
+}
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index c5db15b4908..fe276913925 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -832,9 +832,6 @@ DynamicLoaderMacOSXDYLD::AddModulesUsingImageInfos (DYLDImageInfo::collection &i
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)
{
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 11663efb1bd..b4e42f4bc18 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -5296,6 +5296,12 @@ ObjectFileMachO::GetSDKVersion(uint32_t *versions, uint32_t num_versions)
}
+bool
+ObjectFileMachO::GetIsDynamicLinkEditor()
+{
+ return m_header.filetype == llvm::MachO::MH_DYLINKER;
+}
+
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
index 64a4c054fea..c0d57a3f2f7 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
@@ -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,
OpenPOWER on IntegriCloud