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
This commit is contained in:
Greg Clayton 2015-02-05 02:01:34 +00:00
parent 50ad727051
commit 08928f308b
6 changed files with 40 additions and 20 deletions

View File

@ -941,17 +941,8 @@ public:
const ConstString &object_name); const ConstString &object_name);
bool bool
GetIsDynamicLinkEditor () const GetIsDynamicLinkEditor ();
{
return m_is_dynamic_loader_module;
}
void
SetIsDynamicLinkEditor (bool b)
{
m_is_dynamic_loader_module = b;
}
ClangASTContext & ClangASTContext &
GetClangASTContext (); GetClangASTContext ();
@ -1124,8 +1115,7 @@ protected:
bool m_did_load_objfile:1, bool m_did_load_objfile:1,
m_did_load_symbol_vendor:1, m_did_load_symbol_vendor:1,
m_did_parse_uuid:1, m_did_parse_uuid:1,
m_did_init_ast:1, m_did_init_ast:1;
m_is_dynamic_loader_module:1;
mutable bool m_file_has_changed: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. m_first_file_changed_log:1; /// See if the module was modified after it was initially opened.

View File

@ -767,6 +767,23 @@ public:
return 0; 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 // Member Functions
//------------------------------------------------------------------ //------------------------------------------------------------------

View File

@ -152,7 +152,6 @@ Module::Module (const ModuleSpec &module_spec) :
m_did_load_symbol_vendor (false), m_did_load_symbol_vendor (false),
m_did_parse_uuid (false), m_did_parse_uuid (false),
m_did_init_ast (false), m_did_init_ast (false),
m_is_dynamic_loader_module (false),
m_file_has_changed (false), m_file_has_changed (false),
m_first_file_changed_log (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_load_symbol_vendor (false),
m_did_parse_uuid (false), m_did_parse_uuid (false),
m_did_init_ast (false), m_did_init_ast (false),
m_is_dynamic_loader_module (false),
m_file_has_changed (false), m_file_has_changed (false),
m_first_file_changed_log (false) m_first_file_changed_log (false)
{ {
@ -304,7 +302,6 @@ Module::Module () :
m_did_load_symbol_vendor (false), m_did_load_symbol_vendor (false),
m_did_parse_uuid (false), m_did_parse_uuid (false),
m_did_init_ast (false), m_did_init_ast (false),
m_is_dynamic_loader_module (false),
m_file_has_changed (false), m_file_has_changed (false),
m_first_file_changed_log (false) m_first_file_changed_log (false)
{ {
@ -1825,3 +1822,13 @@ Module::CreateJITModule (const lldb::ObjectFileJITDelegateSP &delegate_sp)
return ModuleSP(); return ModuleSP();
} }
bool
Module::GetIsDynamicLinkEditor()
{
ObjectFile * obj_file = GetObjectFile ();
if (obj_file)
return obj_file->GetIsDynamicLinkEditor();
return false;
}

View File

@ -832,9 +832,6 @@ DynamicLoaderMacOSXDYLD::AddModulesUsingImageInfos (DYLDImageInfo::collection &i
if (image_module_sp) 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 (); ObjectFile *objfile = image_module_sp->GetObjectFile ();
if (objfile) if (objfile)
{ {

View File

@ -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 // PluginInterface protocol
//------------------------------------------------------------------ //------------------------------------------------------------------

View File

@ -173,7 +173,10 @@ public:
virtual uint32_t virtual uint32_t
GetSDKVersion (uint32_t *versions, uint32_t num_versions); GetSDKVersion (uint32_t *versions, uint32_t num_versions);
virtual bool
GetIsDynamicLinkEditor();
static bool static bool
ParseHeader (lldb_private::DataExtractor &data, ParseHeader (lldb_private::DataExtractor &data,
lldb::offset_t *data_offset_ptr, lldb::offset_t *data_offset_ptr,