This moves the following classes from Core -> Utility. ConstString Error RegularExpression Stream StreamString The goal here is to get lldbUtility into a state where it has no dependendencies except on itself and LLVM, so it can be the starting point at which to start untangling LLDB's dependencies. These are all low level and very widely used classes, and previously lldbUtility had dependencies up to lldbCore in order to use these classes. So moving then down to lldbUtility makes sense from both the short term and long term perspective in solving this problem. Differential Revision: https://reviews.llvm.org/D29427 llvm-svn: 293941
83 lines
2.6 KiB
C++
83 lines
2.6 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/Symbol/ObjectFile.h"
|
|
#include "lldb/Utility/ConstString.h"
|
|
#include "lldb/Utility/RegularExpression.h"
|
|
#include "lldb/Utility/Stream.h"
|
|
#include "lldb/Utility/StreamString.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, const DIERef &die_ref) {
|
|
m_map.Append(name.GetStringRef(), die_ref);
|
|
}
|
|
|
|
size_t NameToDIE::Find(const ConstString &name, DIEArray &info_array) const {
|
|
return m_map.GetValues(name.GetStringRef(), info_array);
|
|
}
|
|
|
|
size_t NameToDIE::Find(const RegularExpression ®ex,
|
|
DIEArray &info_array) const {
|
|
return m_map.GetValues(regex, info_array);
|
|
}
|
|
|
|
size_t NameToDIE::FindAllEntriesForCompileUnit(dw_offset_t cu_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 DIERef &die_ref = m_map.GetValueAtIndexUnchecked(i);
|
|
if (cu_offset == die_ref.cu_offset)
|
|
info_array.push_back(die_ref);
|
|
}
|
|
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) {
|
|
llvm::StringRef cstr = m_map.GetCStringAtIndex(i);
|
|
const DIERef &die_ref = m_map.GetValueAtIndexUnchecked(i);
|
|
s->Printf("%p: {0x%8.8x/0x%8.8x} \"%s\"\n", (const void *)cstr.data(),
|
|
die_ref.cu_offset, die_ref.die_offset, cstr.str().c_str());
|
|
}
|
|
}
|
|
|
|
void NameToDIE::ForEach(
|
|
std::function<bool(llvm::StringRef name, const DIERef &die_ref)> const
|
|
&callback) const {
|
|
const uint32_t size = m_map.GetSize();
|
|
for (uint32_t i = 0; i < size; ++i) {
|
|
if (!callback(m_map.GetCStringAtIndexUnchecked(i),
|
|
m_map.GetValueAtIndexUnchecked(i)))
|
|
break;
|
|
}
|
|
}
|
|
|
|
void NameToDIE::Append(const NameToDIE &other) {
|
|
const uint32_t size = other.m_map.GetSize();
|
|
for (uint32_t i = 0; i < size; ++i) {
|
|
m_map.Append(other.m_map.GetCStringAtIndexUnchecked(i),
|
|
other.m_map.GetValueAtIndexUnchecked(i));
|
|
}
|
|
}
|