1 //===-- DIERef.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_DIERef_h_ 11 #define SymbolFileDWARF_DIERef_h_ 12 13 #include "lldb/Core/dwarf.h" 14 #include "lldb/lldb-defines.h" 15 16 class DWARFFormValue; 17 class SymbolFileDWARF; 18 19 struct DIERef { 20 DIERef() = default; 21 DIERefDIERef22 DIERef(dw_offset_t c, dw_offset_t d) : cu_offset(c), die_offset(d) {} 23 24 //---------------------------------------------------------------------- 25 // In order to properly decode a lldb::user_id_t back into a DIERef we 26 // need the DWARF file since it knows if DWARF in .o files is being used 27 // (MacOSX) or if DWO files are being used. The encoding of the user ID 28 // differs between the two types of DWARF. 29 //---------------------------------------------------------------------- 30 explicit DIERef(lldb::user_id_t uid, SymbolFileDWARF *dwarf); 31 32 explicit DIERef(const DWARFFormValue &form_value); 33 34 //---------------------------------------------------------------------- 35 // In order to properly encode a DIERef unto a lldb::user_id_t we need 36 // the DWARF file since it knows if DWARF in .o files is being used 37 // (MacOSX) or if DWO files are being used. The encoding of the user ID 38 // differs between the two types of DWARF. 39 //---------------------------------------------------------------------- 40 lldb::user_id_t GetUID(SymbolFileDWARF *dwarf) const; 41 42 bool operator<(const DIERef &ref) const { 43 return die_offset < ref.die_offset; 44 } 45 46 bool operator<(const DIERef &ref) { return die_offset < ref.die_offset; } 47 48 explicit operator bool() const { 49 return cu_offset != DW_INVALID_OFFSET || die_offset != DW_INVALID_OFFSET; 50 } 51 52 dw_offset_t cu_offset = DW_INVALID_OFFSET; 53 dw_offset_t die_offset = DW_INVALID_OFFSET; 54 }; 55 56 typedef std::vector<DIERef> DIEArray; 57 58 #endif // SymbolFileDWARF_DIERef_h_ 59