diff options
| author | Greg Clayton <gclayton@apple.com> | 2010-09-15 04:15:46 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2010-09-15 04:15:46 +0000 |
| commit | c685f8e5402284f4a743f2e4d7d7168578cfb687 (patch) | |
| tree | 08cafa1431519ca5789105907e1e15669f86e81d /lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp | |
| parent | 81ce17386075dcdbae3891837ce0316ad9bcbd19 (diff) | |
| download | bcm5719-llvm-c685f8e5402284f4a743f2e4d7d7168578cfb687.tar.gz bcm5719-llvm-c685f8e5402284f4a743f2e4d7d7168578cfb687.zip | |
So we can't use .debug_pubtypes as it, as designed, does not tell us about
all types in all compile units. I added a new kind of accelerator table to
the DWARF that allows us to index the DWARF compile units and DIEs in a way
that doesn't require the data to stay loaded. Currently when indexing the
DWARF we check if the compile unit had parsed its DIEs and if it hasn't we
index the data and free all of the DIEs so we can reparse later when we need
to after using one of our complete accelerator tables to determine we need
to reparse some DWARF. If the DIEs had already been parsed we leave them
loaded. The new accelerator table uses the "const char *" pointers from our
ConstString class as the keys, and NameToDIE::Info as the value. This info
contains the compile unit index and the DIE index which means we are pointed
right to the DIE we need unlike the other DWARF accelerator tables that often
just point us to the compile unit we would find our answer in.
llvm-svn: 113933
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp')
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp new file mode 100644 index 00000000000..48acf30d583 --- /dev/null +++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp @@ -0,0 +1,60 @@ +//===-- 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/Stream.h" + +size_t +NameToDIE::Find (const lldb_private::ConstString &name, std::vector<Info> &info_array) const +{ + const char *name_cstr = name.AsCString(); + const size_t initial_info_array_size = info_array.size(); + collection::const_iterator pos, end = m_collection.end(); + for (pos = m_collection.lower_bound (name_cstr); pos != end && pos->first == name_cstr; ++pos) + { + info_array.push_back (pos->second); + } + return info_array.size() - initial_info_array_size; +} + +size_t +NameToDIE::Find (const lldb_private::RegularExpression& regex, std::vector<Info> &info_array) const +{ + const size_t initial_info_array_size = info_array.size(); + collection::const_iterator pos, end = m_collection.end(); + for (pos = m_collection.begin(); pos != end; ++pos) + { + if (regex.Execute(pos->first)) + info_array.push_back (pos->second); + } + return info_array.size() - initial_info_array_size; +} + +size_t +NameToDIE::FindAllEntriesForCompileUnitWithIndex (const uint32_t cu_idx, std::vector<Info> &info_array) const +{ + const size_t initial_info_array_size = info_array.size(); + collection::const_iterator pos, end = m_collection.end(); + for (pos = m_collection.begin(); pos != end; ++pos) + { + if (cu_idx == pos->second.cu_idx) + info_array.push_back (pos->second); + } + return info_array.size() - initial_info_array_size; +} + +void +NameToDIE::Dump (lldb_private::Stream *s) +{ + collection::const_iterator pos, end = m_collection.end(); + for (pos = m_collection.begin(); pos != end; ++pos) + { + s->Printf("%p: 0x%8.8x 0x%8.8x \"%s\"\n", pos->first, pos->second.cu_idx, pos->second.die_idx, pos->first); + } +} |

