summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/Module.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2015-03-31 21:01:48 +0000
committerGreg Clayton <gclayton@apple.com>2015-03-31 21:01:48 +0000
commit902716728c221edf80284a21e4f3bac0ead5c7f7 (patch)
tree910f4c4b23f166a450ed0f69a60cfaec98251231 /lldb/source/Core/Module.cpp
parent30daf915ba7d93132d070a5f8688e698a9c8de3c (diff)
downloadbcm5719-llvm-902716728c221edf80284a21e4f3bac0ead5c7f7.tar.gz
bcm5719-llvm-902716728c221edf80284a21e4f3bac0ead5c7f7.zip
Make sure that "add-dsym" can't crash us when using it.
I am fixing this by: 1 - make sure we aren't trying to set the symbol file for a module to the same thing it already has and leaving it alone if it is the same 2 - keep all old symbol files around in the module in case there are any outstanding type references <rdar://problem/18029116> llvm-svn: 233757
Diffstat (limited to 'lldb/source/Core/Module.cpp')
-rw-r--r--lldb/source/Core/Module.cpp46
1 files changed, 38 insertions, 8 deletions
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index c5c4f5df745..010900b05cf 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1469,9 +1469,11 @@ Module::FindSymbolsMatchingRegExAndType (const RegularExpression &regex, SymbolT
void
Module::SetSymbolFileFileSpec (const FileSpec &file)
{
- // Remove any sections in the unified section list that come from the current symbol vendor.
+ if (!file.Exists())
+ return;
if (m_symfile_ap)
{
+ // Remove any sections in the unified section list that come from the current symbol vendor.
SectionList *section_list = GetSectionList();
SymbolFile *symbol_file = m_symfile_ap->GetSymbolFile();
if (section_list && symbol_file)
@@ -1479,21 +1481,49 @@ Module::SetSymbolFileFileSpec (const FileSpec &file)
ObjectFile *obj_file = symbol_file->GetObjectFile();
// Make sure we have an object file and that the symbol vendor's objfile isn't
// the same as the module's objfile before we remove any sections for it...
- if (obj_file && obj_file != m_objfile_sp.get())
+ if (obj_file)
{
- size_t num_sections = section_list->GetNumSections (0);
- for (size_t idx = num_sections; idx > 0; --idx)
+ // Check to make sure we aren't trying to specify the file we already have
+ if (obj_file->GetFileSpec() == file)
+ {
+ // We are being told to add the exact same file that we already have
+ // we don't have to do anything.
+ return;
+ }
+
+ // The symbol file might be a directory bundle ("/tmp/a.out.dSYM") instead
+ // of a full path to the symbol file within the bundle
+ // ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need to check this
+
+ if (file.IsDirectory())
{
- lldb::SectionSP section_sp (section_list->GetSectionAtIndex (idx - 1));
- if (section_sp->GetObjectFile() == obj_file)
+ std::string new_path(file.GetPath());
+ std::string old_path(obj_file->GetFileSpec().GetPath());
+ if (old_path.find(new_path) == 0)
{
- section_list->DeleteSection (idx - 1);
+ // We specified the same bundle as the symbol file that we already have
+ return;
+ }
+ }
+
+ if (obj_file != m_objfile_sp.get())
+ {
+ size_t num_sections = section_list->GetNumSections (0);
+ for (size_t idx = num_sections; idx > 0; --idx)
+ {
+ lldb::SectionSP section_sp (section_list->GetSectionAtIndex (idx - 1));
+ if (section_sp->GetObjectFile() == obj_file)
+ {
+ section_list->DeleteSection (idx - 1);
+ }
}
}
}
}
+ // Keep all old symbol files around in case there are any lingering type references in
+ // any SBValue objects that might have been handed out.
+ m_old_symfiles.push_back(std::move(m_symfile_ap));
}
-
m_symfile_spec = file;
m_symfile_ap.reset();
m_did_load_symbol_vendor = false;
OpenPOWER on IntegriCloud