Files
clang-p2996/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
Greg Clayton d4a2b37091 Huge memory and performance improvements in the DWARF parser.
Address ranges are now split up into two different tables: 
- one in DWARFDebugInfo that is compile unit specific
- one in each DWARFCompileUnit that has exact function DIE offsets

This helps keep the size of the aranges down since the main table will get
uniqued and sorted and have consecutive ranges merged. We then only parse the
compile unit one on demand once we have determined that a compile unit contains
the address in question. We also now use the .debug_aranges section if there 
is one instead of always indexing the DWARF manually.

NameToDIE now uses a UniqueCStringMap<dw_offset> map instead of a std::map.
std::map is very bulky as each node has 3 pointers and the key and value types.
This gets our NameToDIE entry down to 12 bytes each instead of 48 which saves
us a lot of memory when we have very large DWARF.

DWARFDebugAranges now has a smaller footprint for each range it contains to 
save on memory.

llvm-svn: 139557
2011-09-12 23:21:58 +00:00

76 lines
2.0 KiB
C++

//===-- NameToDIE.cpp -------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "NameToDIE.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Symbol/ObjectFile.h"
#include "DWARFCompileUnit.h"
#include "DWARFDebugInfo.h"
#include "DWARFDebugInfoEntry.h"
#include "SymbolFileDWARF.h"
using namespace lldb;
using namespace lldb_private;
void
NameToDIE::Finalize()
{
m_map.Sort ();
m_map.SizeToFit ();
}
void
NameToDIE::Insert (const ConstString& name, uint32_t die_offset)
{
m_map.Append(name.GetCString(), die_offset);
}
size_t
NameToDIE::Find (const ConstString &name, DIEArray &info_array) const
{
return m_map.GetValues (name.GetCString(), info_array);
}
size_t
NameToDIE::Find (const RegularExpression& regex, DIEArray &info_array) const
{
return m_map.GetValues (regex, info_array);
}
size_t
NameToDIE::FindAllEntriesForCompileUnit (uint32_t cu_offset,
uint32_t cu_end_offset,
DIEArray &info_array) const
{
const size_t initial_size = info_array.size();
const uint32_t size = m_map.GetSize();
for (uint32_t i=0; i<size; ++i)
{
const uint32_t die_offset = m_map.GetValueAtIndexUnchecked(i);
if (cu_offset < die_offset && die_offset < cu_end_offset)
info_array.push_back (die_offset);
}
return info_array.size() - initial_size;
}
void
NameToDIE::Dump (Stream *s)
{
const uint32_t size = m_map.GetSize();
for (uint32_t i=0; i<size; ++i)
{
const char *cstr = m_map.GetCStringAtIndex(i);
s->Printf("%p: {0x%8.8x} \"%s\"\n", cstr, m_map.GetValueAtIndexUnchecked(i), cstr);
}
}