Summary: This patch adds the ability to precisely address debug info in situations when a single file can have more than one debug-info-bearing sections (as is the case with type units in DWARF v4). The changes here can be classified into roughly three categories: - the code which addresses a debug info by offset gets an additional argument, which specifies the section one should look into. - the DIERef class also gets an additional member variable specifying the section. This way, code dealing with DIERefs can know which section is the object referring to. - the user_id_t encoding steals one bit from the dwarf_id field to store the section. This means the total number of separate object files (apple .o, or normal .dwo) is limited to 2 billion, but that is fine as it's not possible to hit that number without switching to DWARF64 anyway. This patch is functionally equivalent to (and inspired by) the two patches (D61503 and D61504) by Jan Kratochvil, but there are differences in the implementation: - it uses an enum instead of a bool flag to differentiate the sections - it increases the size of DIERef struct instead of reducing the amount of addressable debug info - it sets up DWARFDebugInfo to store the units in a single vector instead of two. This sets us up for the future in which type units can also live in the debug_info section, and I believe it's cleaner because there's no need for unit index remapping There are no tests with this patch as this is essentially NFC until we start parsing type units from the debug_types section. Reviewers: JDevlieghere, clayborg, aprantl Subscribers: arphaman, jankratochvil, lldb-commits Differential Revision: https://reviews.llvm.org/D61908 llvm-svn: 360872
188 lines
6.5 KiB
C++
188 lines
6.5 KiB
C++
//===-- HashedNameToDIE.h ---------------------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SymbolFileDWARF_HashedNameToDIE_h_
|
|
#define SymbolFileDWARF_HashedNameToDIE_h_
|
|
|
|
#include <vector>
|
|
|
|
#include "lldb/Core/MappedHash.h"
|
|
#include "lldb/Core/dwarf.h"
|
|
#include "lldb/Utility/RegularExpression.h"
|
|
#include "lldb/lldb-defines.h"
|
|
|
|
#include "DWARFDefines.h"
|
|
#include "DWARFFormValue.h"
|
|
#include "NameToDIE.h"
|
|
|
|
class DWARFMappedHash {
|
|
public:
|
|
enum AtomType : uint16_t {
|
|
eAtomTypeNULL = 0u,
|
|
eAtomTypeDIEOffset = 1u, // DIE offset, check form for encoding
|
|
eAtomTypeCUOffset = 2u, // DIE offset of the compiler unit header that
|
|
// contains the item in question
|
|
eAtomTypeTag = 3u, // DW_TAG_xxx value, should be encoded as DW_FORM_data1
|
|
// (if no tags exceed 255) or DW_FORM_data2
|
|
eAtomTypeNameFlags = 4u, // Flags from enum NameFlags
|
|
eAtomTypeTypeFlags = 5u, // Flags from enum TypeFlags,
|
|
eAtomTypeQualNameHash = 6u // A 32 bit hash of the full qualified name
|
|
// (since all hash entries are basename only)
|
|
// For example a type like "std::vector<int>::iterator" would have a name of
|
|
// "iterator"
|
|
// and a 32 bit hash for "std::vector<int>::iterator" to allow us to not
|
|
// have to pull
|
|
// in debug info for a type when we know the fully qualified name.
|
|
};
|
|
|
|
// Bit definitions for the eAtomTypeTypeFlags flags
|
|
enum TypeFlags {
|
|
// Always set for C++, only set for ObjC if this is the
|
|
// @implementation for class
|
|
eTypeFlagClassIsImplementation = (1u << 1)
|
|
};
|
|
|
|
struct DIEInfo {
|
|
DIERef die_ref;
|
|
dw_tag_t tag;
|
|
uint32_t type_flags; // Any flags for this DIEInfo
|
|
uint32_t qualified_name_hash; // A 32 bit hash of the fully qualified name
|
|
|
|
DIEInfo();
|
|
DIEInfo(dw_offset_t c, dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h);
|
|
|
|
explicit operator DIERef() const { return die_ref; }
|
|
};
|
|
|
|
struct Atom {
|
|
AtomType type;
|
|
dw_form_t form;
|
|
};
|
|
|
|
typedef std::vector<DIEInfo> DIEInfoArray;
|
|
typedef std::vector<Atom> AtomArray;
|
|
|
|
class Prologue {
|
|
public:
|
|
Prologue(dw_offset_t _die_base_offset = 0);
|
|
|
|
void ClearAtoms();
|
|
|
|
bool ContainsAtom(AtomType atom_type) const;
|
|
|
|
void Clear();
|
|
|
|
void AppendAtom(AtomType type, dw_form_t form);
|
|
|
|
lldb::offset_t Read(const lldb_private::DataExtractor &data,
|
|
lldb::offset_t offset);
|
|
|
|
size_t GetByteSize() const;
|
|
|
|
size_t GetMinimumHashDataByteSize() const;
|
|
|
|
bool HashDataHasFixedByteSize() const;
|
|
|
|
// DIE offset base so die offsets in hash_data can be CU relative
|
|
dw_offset_t die_base_offset;
|
|
AtomArray atoms;
|
|
uint32_t atom_mask;
|
|
size_t min_hash_data_byte_size;
|
|
bool hash_data_has_fixed_byte_size;
|
|
};
|
|
|
|
class Header : public MappedHash::Header<Prologue> {
|
|
public:
|
|
size_t GetByteSize(const HeaderData &header_data) override;
|
|
|
|
lldb::offset_t Read(lldb_private::DataExtractor &data,
|
|
lldb::offset_t offset) override;
|
|
|
|
bool Read(const lldb_private::DWARFDataExtractor &data,
|
|
lldb::offset_t *offset_ptr, DIEInfo &hash_data) const;
|
|
};
|
|
|
|
// A class for reading and using a saved hash table from a block of data
|
|
// in memory
|
|
class MemoryTable
|
|
: public MappedHash::MemoryTable<uint32_t, DWARFMappedHash::Header,
|
|
DIEInfoArray> {
|
|
public:
|
|
MemoryTable(lldb_private::DWARFDataExtractor &table_data,
|
|
const lldb_private::DWARFDataExtractor &string_table,
|
|
const char *name);
|
|
|
|
const char *GetStringForKeyType(KeyType key) const override;
|
|
|
|
bool ReadHashData(uint32_t hash_data_offset,
|
|
HashData &hash_data) const override;
|
|
|
|
size_t
|
|
AppendAllDIEsThatMatchingRegex(const lldb_private::RegularExpression ®ex,
|
|
DIEInfoArray &die_info_array) const;
|
|
|
|
size_t AppendAllDIEsInRange(const uint32_t die_offset_start,
|
|
const uint32_t die_offset_end,
|
|
DIEInfoArray &die_info_array) const;
|
|
|
|
size_t FindByName(llvm::StringRef name, DIEArray &die_offsets);
|
|
|
|
size_t FindByNameAndTag(llvm::StringRef name, const dw_tag_t tag,
|
|
DIEArray &die_offsets);
|
|
|
|
size_t FindByNameAndTagAndQualifiedNameHash(
|
|
llvm::StringRef name, const dw_tag_t tag,
|
|
const uint32_t qualified_name_hash, DIEArray &die_offsets);
|
|
|
|
size_t FindCompleteObjCClassByName(llvm::StringRef name,
|
|
DIEArray &die_offsets,
|
|
bool must_be_implementation);
|
|
|
|
protected:
|
|
Result AppendHashDataForRegularExpression(
|
|
const lldb_private::RegularExpression ®ex,
|
|
lldb::offset_t *hash_data_offset_ptr, Pair &pair) const;
|
|
|
|
size_t FindByName(llvm::StringRef name, DIEInfoArray &die_info_array);
|
|
|
|
Result GetHashDataForName(llvm::StringRef name,
|
|
lldb::offset_t *hash_data_offset_ptr,
|
|
Pair &pair) const override;
|
|
|
|
lldb_private::DWARFDataExtractor m_data;
|
|
lldb_private::DWARFDataExtractor m_string_table;
|
|
std::string m_name;
|
|
};
|
|
|
|
static void ExtractDIEArray(const DIEInfoArray &die_info_array,
|
|
DIEArray &die_offsets);
|
|
|
|
protected:
|
|
static void ExtractDIEArray(const DIEInfoArray &die_info_array,
|
|
const dw_tag_t tag, DIEArray &die_offsets);
|
|
|
|
static void ExtractDIEArray(const DIEInfoArray &die_info_array,
|
|
const dw_tag_t tag,
|
|
const uint32_t qualified_name_hash,
|
|
DIEArray &die_offsets);
|
|
|
|
static void
|
|
ExtractClassOrStructDIEArray(const DIEInfoArray &die_info_array,
|
|
bool return_implementation_only_if_available,
|
|
DIEArray &die_offsets);
|
|
|
|
static void ExtractTypesFromDIEArray(const DIEInfoArray &die_info_array,
|
|
uint32_t type_flag_mask,
|
|
uint32_t type_flag_value,
|
|
DIEArray &die_offsets);
|
|
|
|
static const char *GetAtomTypeName(uint16_t atom);
|
|
};
|
|
|
|
#endif // SymbolFileDWARF_HashedNameToDIE_h_
|