Files
clang-p2996/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
Greg Clayton f02500c74c Added the ability to get a list of types from a SBModule or SBCompileUnit. Sebastien Metrot wanted this, and sent a hollowed out patch. I filled in the blanks and did the low level implementation. The new functions are:
//------------------------------------------------------------------
/// Get all types matching \a type_mask from debug info in this
/// module.
///
/// @param[in] type_mask
///     A bitfield that consists of one or more bits logically OR'ed
///     together from the lldb::TypeClass enumeration. This allows
///     you to request only structure types, or only class, struct
///     and union types. Passing in lldb::eTypeClassAny will return
///     all types found in the debug information for this module.
///
/// @return
///     A list of types in this module that match \a type_mask
//------------------------------------------------------------------
lldb::SBTypeList
SBModule::GetTypes (uint32_t type_mask)


//------------------------------------------------------------------
/// Get all types matching \a type_mask from debug info in this
/// compile unit.
///
/// @param[in] type_mask
///    A bitfield that consists of one or more bits logically OR'ed
///    together from the lldb::TypeClass enumeration. This allows
///    you to request only structure types, or only class, struct
///    and union types. Passing in lldb::eTypeClassAny will return
///    all types found in the debug information for this compile
///    unit.
///
/// @return
///    A list of types in this compile unit that match \a type_mask
//------------------------------------------------------------------
lldb::SBTypeList
SBCompileUnit::GetTypes (uint32_t type_mask = lldb::eTypeClassAny);

This lets you request types by filling out a mask that contains one or more bits from the lldb::TypeClass enumerations, so you can only get the types you really want.

llvm-svn: 184251
2013-06-18 22:51:05 +00:00

88 lines
2.4 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);
}
}
void
NameToDIE::ForEach (std::function <bool(const char *name, uint32_t die_offset)> 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;
}
}