Files
clang-p2996/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
Greg Clayton 2f869fe9d2 When support for DWO files was added, there were two ways to pass lldb::user_id_t out to the rest of LLDB:
1 - DWARF in .o files with debug map in executable: we would place the compile unit index in the upper 32 bits of the 64 bit value and the lower 32 bits would be the DIE offset
2 - DWO: we would place the compile unit offset in the upper 32 bits of the 64 bit value and the lower 32 bits would be the DIE offset

There was a mixing and matching of this and it wasn't done consistently.

Major changes include:

The DIERef constructor that takes a lldb::user_id_t now requires a SymbolFileDWARF:

DIERef(lldb::user_id_t uid, SymbolFileDWARF *dwarf)

It is needed so that it can be decoded correctly. If it is DWARF in .o files with debug map in executable, then we get the right compile unit from the SymbolFileDWARFDebugMap, otherwise, we use the compile unit offset and DIE offset for DWO or normal DWARF.

The function:

lldb::user_id_t DIERef::GetUID() const;

Now becomes

lldb::user_id_t DIERef::GetUID(SymbolFileDWARF *dwarf) const;

Again, we need the DWARF file to encode it correctly.

This removes the need for "lldb::user_id_t SymbolFileDWARF::MakeUserID() const" and for bool SymbolFileDWARF::UserIDMatches (lldb::user_id_t uid) const". There were also many places were doing things inneficiently like:

1 - encode a dw_offset_t into a lldb::user_id_t
2 - call the public SymbolFile interface to resolve types using the lldb::user_id_t
3 - This would then decode the lldb::user_id_t into a DIERef, and then try to find that type.

There are many places that are now doing this more efficiently by storing DW_AT_type form values as DWARFFormValue objects and then making a DIERef from them and directly calling the underlying function to resolve the lldb_private::Type, lldb_private::CompilerType, lldb_private::CompilerDecl, lldb_private::CompilerDeclContext.

If there are any regressions in DWARF with DWO, we will need to fix any issues that arise since the original patch wasn't functional for the much more widely used DWARF in .o files with debug map.

<rdar://problem/25200976>

llvm-svn: 264909
2016-03-30 20:14:35 +00:00

88 lines
3.3 KiB
C++

//===-- DWARFDebugInfo.h ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef SymbolFileDWARF_DWARFDebugInfo_h_
#define SymbolFileDWARF_DWARFDebugInfo_h_
#include <vector>
#include <map>
#include "lldb/lldb-private.h"
#include "lldb/lldb-private.h"
#include "SymbolFileDWARF.h"
#include "DWARFDIE.h"
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,
DWARFCompileUnit* cu,
DWARFDebugInfoEntry* die,
const dw_offset_t next_offset,
const uint32_t depth,
void* userData);
DWARFDebugInfo();
void SetDwarfData(SymbolFileDWARF* dwarf2Data);
size_t GetNumCompileUnits();
bool ContainsCompileUnit (const DWARFCompileUnit *cu) const;
DWARFCompileUnit* GetCompileUnitAtIndex (uint32_t idx);
DWARFCompileUnit* GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr = NULL);
DWARFCompileUnit* GetCompileUnitContainingDIEOffset (dw_offset_t die_offset);
DWARFCompileUnit* GetCompileUnit(const DIERef& die_ref);
DWARFDIE GetDIEForDIEOffset(dw_offset_t die_offset);
DWARFDIE GetDIE (const DIERef& die_ref);
void Dump(lldb_private::Stream *s, const uint32_t die_offset, const uint32_t recurse_depth);
static void Parse(SymbolFileDWARF* parser, Callback callback, void* userData);
static void Verify(lldb_private::Stream *s, SymbolFileDWARF* dwarf2Data);
static void Dump(lldb_private::Stream *s, SymbolFileDWARF* dwarf2Data, const uint32_t die_offset, const uint32_t recurse_depth);
bool Find(const char* name, bool ignore_case, std::vector<dw_offset_t>& die_offsets) const;
bool Find(lldb_private::RegularExpression& re, std::vector<dw_offset_t>& die_offsets) const;
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
};
DWARFDebugAranges &
GetCompileUnitAranges ();
protected:
typedef std::shared_ptr<DWARFCompileUnit> DWARFCompileUnitSP;
static bool
OffsetLessThanCompileUnitOffset (dw_offset_t offset, const DWARFCompileUnitSP& cu_sp);
typedef std::vector<DWARFCompileUnitSP> CompileUnitColl;
//----------------------------------------------------------------------
// Member variables
//----------------------------------------------------------------------
SymbolFileDWARF* m_dwarf2Data;
CompileUnitColl m_compile_units;
std::unique_ptr<DWARFDebugAranges> m_cu_aranges_ap; // 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_