Home | History | Annotate | Download | only in DWARF
      1 //===- DWARFDebugLoc.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 LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H
     11 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H
     12 
     13 #include "llvm/ADT/SmallVector.h"
     14 #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
     15 #include "llvm/Support/DataExtractor.h"
     16 #include <cstdint>
     17 
     18 namespace llvm {
     19 
     20 class raw_ostream;
     21 
     22 class DWARFDebugLoc {
     23   /// A single location within a location list.
     24   struct Entry {
     25     /// The beginning address of the instruction range.
     26     uint64_t Begin;
     27     /// The ending address of the instruction range.
     28     uint64_t End;
     29     /// The location of the variable within the specified range.
     30     SmallVector<unsigned char, 4> Loc;
     31   };
     32 
     33   /// A list of locations that contain one variable.
     34   struct LocationList {
     35     /// The beginning offset where this location list is stored in the debug_loc
     36     /// section.
     37     unsigned Offset;
     38     /// All the locations in which the variable is stored.
     39     SmallVector<Entry, 2> Entries;
     40   };
     41 
     42   typedef SmallVector<LocationList, 4> LocationLists;
     43 
     44   /// A list of all the variables in the debug_loc section, each one describing
     45   /// the locations in which the variable is stored.
     46   LocationLists Locations;
     47 
     48   /// A map used to resolve binary relocations.
     49   const RelocAddrMap &RelocMap;
     50 
     51 public:
     52   DWARFDebugLoc(const RelocAddrMap &LocRelocMap) : RelocMap(LocRelocMap) {}
     53 
     54   /// Print the location lists found within the debug_loc section.
     55   void dump(raw_ostream &OS) const;
     56 
     57   /// Parse the debug_loc section accessible via the 'data' parameter using the
     58   /// specified address size to interpret the address ranges.
     59   void parse(DataExtractor data, unsigned AddressSize);
     60 };
     61 
     62 class DWARFDebugLocDWO {
     63   struct Entry {
     64     uint64_t Start;
     65     uint32_t Length;
     66     SmallVector<unsigned char, 4> Loc;
     67   };
     68 
     69   struct LocationList {
     70     unsigned Offset;
     71     SmallVector<Entry, 2> Entries;
     72   };
     73 
     74   typedef SmallVector<LocationList, 4> LocationLists;
     75 
     76   LocationLists Locations;
     77 
     78 public:
     79   void parse(DataExtractor data);
     80   void dump(raw_ostream &OS) const;
     81 };
     82 
     83 } // end namespace llvm
     84 
     85 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H
     86