LLVM's DWARF parsing library has a class called DWARFContext which holds all of the various DWARF data sections and lots of other information. LLDB's on the other hand stores all of this directly in SymbolFileDWARF / SymbolFileDWARFDwo and passes this interface around through the parsing library. Obviously this is incompatible with a world where the low level interface does not depend on the high level interface, so we need to move towards a model similar to LLVM's - i.e. all of the context needed for low level parsing should be in a single class, and that class gets passed around. This patch is a small incremental step towards achieving this. The interface and internals deviate from LLVM's for technical reasons, but the high level idea is the same. The goal is, eventually, to remove all occurrences of SymbolFileDWARF from the low level parsing code. For now I've chosen a very simple section - the .debug_aranges section to move into DWARFContext while leaving everything else unchanged. In the short term this is a bit confusing because now the information you need might come from either of 2 different locations. But it's a huge refactor to do this all at once and runs a much higher risk of breaking things. So I think it would be wise to do this in very small pieces. TL;DR - No functional change Differential Revision: https://reviews.llvm.org/D59562 llvm-svn: 356612
83 lines
2.8 KiB
C++
83 lines
2.8 KiB
C++
//===-- DWARFDebugInfo.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_DWARFDebugInfo_h_
|
|
#define SymbolFileDWARF_DWARFDebugInfo_h_
|
|
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
#include "DWARFDIE.h"
|
|
#include "DWARFUnit.h"
|
|
#include "SymbolFileDWARF.h"
|
|
#include "lldb/Core/STLUtils.h"
|
|
#include "lldb/lldb-private.h"
|
|
#include "llvm/Support/Error.h"
|
|
|
|
namespace lldb_private {
|
|
class DWARFContext;
|
|
}
|
|
|
|
typedef std::multimap<const char *, dw_offset_t, CStringCompareFunctionObject>
|
|
CStringToDIEMap;
|
|
typedef CStringToDIEMap::iterator CStringToDIEMapIter;
|
|
typedef CStringToDIEMap::const_iterator CStringToDIEMapConstIter;
|
|
|
|
class DWARFDebugInfo {
|
|
public:
|
|
typedef dw_offset_t (*Callback)(SymbolFileDWARF *dwarf2Data,
|
|
DWARFUnit *cu,
|
|
DWARFDebugInfoEntry *die,
|
|
const dw_offset_t next_offset,
|
|
const uint32_t depth, void *userData);
|
|
|
|
explicit DWARFDebugInfo(lldb_private::DWARFContext &context);
|
|
void SetDwarfData(SymbolFileDWARF *dwarf2Data);
|
|
|
|
size_t GetNumCompileUnits();
|
|
DWARFUnit *GetCompileUnitAtIndex(uint32_t idx);
|
|
DWARFUnit *GetCompileUnit(dw_offset_t cu_offset, uint32_t *idx_ptr = NULL);
|
|
DWARFUnit *GetCompileUnitContainingDIEOffset(dw_offset_t die_offset);
|
|
DWARFUnit *GetCompileUnit(const DIERef &die_ref);
|
|
DWARFDIE GetDIEForDIEOffset(dw_offset_t die_offset);
|
|
DWARFDIE GetDIE(const DIERef &die_ref);
|
|
|
|
enum {
|
|
eDumpFlag_Verbose = (1 << 0), // Verbose dumping
|
|
eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type
|
|
eDumpFlag_ShowAncestors =
|
|
(1 << 2) // Show all parent DIEs when dumping single DIEs
|
|
};
|
|
|
|
llvm::Expected<DWARFDebugAranges &> GetCompileUnitAranges();
|
|
|
|
protected:
|
|
static bool OffsetLessThanCompileUnitOffset(dw_offset_t offset,
|
|
const DWARFUnitSP &cu_sp);
|
|
|
|
typedef std::vector<DWARFUnitSP> CompileUnitColl;
|
|
|
|
//----------------------------------------------------------------------
|
|
// Member variables
|
|
//----------------------------------------------------------------------
|
|
SymbolFileDWARF *m_dwarf2Data;
|
|
lldb_private::DWARFContext &m_context;
|
|
CompileUnitColl m_compile_units;
|
|
std::unique_ptr<DWARFDebugAranges>
|
|
m_cu_aranges_up; // A quick address to compile unit table
|
|
|
|
private:
|
|
// All parsing needs to be done partially any managed by this class as
|
|
// accessors are called.
|
|
void ParseCompileUnitHeadersIfNeeded();
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(DWARFDebugInfo);
|
|
};
|
|
|
|
#endif // SymbolFileDWARF_DWARFDebugInfo_h_
|