HashedNameToDIE.h revision d74270e83908066c946d150faec9516349e1118b
1//===-- HashedNameToDIE.h ---------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef SymbolFileDWARF_HashedNameToDIE_h_ 11#define SymbolFileDWARF_HashedNameToDIE_h_ 12 13#include <vector> 14#include "lldb/lldb-defines.h" 15#include "lldb/Core/dwarf.h" 16 17class SymbolFileDWARF; 18 19typedef std::vector<dw_offset_t> DIEArray; 20 21class HashedNameToDIE 22{ 23public: 24 struct Header 25 { 26 uint16_t version; 27 uint8_t hash_type; 28 uint8_t hash_index_bitsize; 29 uint32_t num_buckets; 30 uint32_t num_hashes; 31 uint32_t die_offset_base; 32 33 Header() : 34 version(0), 35 hash_type (0), 36 hash_index_bitsize (0), 37 num_buckets(0), 38 num_hashes (0), 39 die_offset_base(0) 40 { 41 } 42 }; 43 44 45 HashedNameToDIE (SymbolFileDWARF *dwarf, 46 const lldb_private::DataExtractor &data); 47 48 ~HashedNameToDIE () 49 { 50 } 51 52 bool 53 IsValid () const 54 { 55 return m_header.version > 0; 56 } 57 58 uint32_t 59 GetHashIndexMask () const 60 { 61 return (1u << m_header.hash_index_bitsize) - 1u; 62 } 63 64 uint32_t 65 GetOffsetOfBucketEntry (uint32_t idx) const 66 { 67 if (idx < m_header.num_buckets) 68 return sizeof(Header) + 4 * idx; 69 return UINT32_MAX; 70 } 71 72 uint32_t 73 GetOffsetOfHashValue (uint32_t idx) const 74 { 75 if (idx < m_header.num_hashes) 76 return sizeof(Header) + 77 4 * m_header.num_buckets + 78 4 * idx; 79 return UINT32_MAX; 80 } 81 82 uint32_t 83 GetOffsetOfHashDataOffset (uint32_t idx) const 84 { 85 if (idx < m_header.num_hashes) 86 { 87 return sizeof(Header) + 88 4 * m_header.num_buckets + 89 4 * m_header.num_hashes + 90 4 * idx; 91 } 92 return UINT32_MAX; 93 } 94 95 void 96 Dump (lldb_private::Stream *s); 97 98 size_t 99 Find (const lldb_private::ConstString &name, 100 DIEArray &die_ofsets) const; 101 102 size_t 103 Find (const lldb_private::RegularExpression& regex, 104 DIEArray &die_ofsets) const; 105 106 void 107 Initialize(); 108 109protected: 110 SymbolFileDWARF *m_dwarf; 111 const lldb_private::DataExtractor &m_data; 112 Header m_header; 113}; 114 115#endif // SymbolFileDWARF_HashedNameToDIE_h_ 116