LCOV - code coverage report
Current view: top level - lib/DebugInfo - DWARFDebugRangeList.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 32 34 94.1 %
Date: 2015-01-30 11:55:44 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- DWARFDebugRangesList.cpp ------------------------------------------===//
       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             : #include "llvm/DebugInfo/DWARFDebugRangeList.h"
      11             : #include "llvm/Support/Format.h"
      12             : #include "llvm/Support/raw_ostream.h"
      13             : 
      14             : using namespace llvm;
      15             : 
      16       23764 : void DWARFDebugRangeList::clear() {
      17       23764 :   Offset = -1U;
      18       23764 :   AddressSize = 0;
      19       23764 :   Entries.clear();
      20       23764 : }
      21             : 
      22       11906 : bool DWARFDebugRangeList::extract(DataExtractor data, uint32_t *offset_ptr) {
      23       11906 :   clear();
      24       23812 :   if (!data.isValidOffset(*offset_ptr))
      25             :     return false;
      26       11811 :   AddressSize = data.getAddressSize();
      27       11811 :   if (AddressSize != 4 && AddressSize != 8)
      28             :     return false;
      29       11811 :   Offset = *offset_ptr;
      30             :   while (true) {
      31             :     RangeListEntry entry;
      32      511988 :     uint32_t prev_offset = *offset_ptr;
      33      511988 :     entry.StartAddress = data.getAddress(offset_ptr);
      34      511988 :     entry.EndAddress = data.getAddress(offset_ptr);
      35             :     // Check that both values were extracted correctly.
      36      511988 :     if (*offset_ptr != prev_offset + 2 * AddressSize) {
      37           0 :       clear();
      38           0 :       return false;
      39             :     }
      40      511988 :     if (entry.isEndOfListEntry())
      41             :       break;
      42      500177 :     Entries.push_back(entry);
      43             :   }
      44      500177 :   return true;
      45             : }
      46             : 
      47          48 : void DWARFDebugRangeList::dump(raw_ostream &OS) const {
      48         203 :   for (const RangeListEntry &RLE : Entries) {
      49          11 :     const char *format_str = (AddressSize == 4
      50             :                               ? "%08x %08"  PRIx64 " %08"  PRIx64 "\n"
      51          11 :                               : "%08x %016" PRIx64 " %016" PRIx64 "\n");
      52          33 :     OS << format(format_str, Offset, RLE.StartAddress, RLE.EndAddress);
      53             :   }
      54         144 :   OS << format("%08x <End of list>\n", Offset);
      55          48 : }
      56             : 
      57             : DWARFAddressRangesVector
      58       11763 : DWARFDebugRangeList::getAbsoluteRanges(uint64_t BaseAddress) const {
      59             :   DWARFAddressRangesVector Res;
      60      547218 :   for (const RangeListEntry &RLE : Entries) {
      61     1000332 :     if (RLE.isBaseAddressSelectionEntry(AddressSize)) {
      62           2 :       BaseAddress = RLE.EndAddress;
      63             :     } else {
      64      500164 :       Res.push_back(std::make_pair(BaseAddress + RLE.StartAddress,
      65     2000656 :                                    BaseAddress + RLE.EndAddress));
      66             :     }
      67             :   }
      68       11763 :   return Res;
      69             : }

Generated by: LCOV version 1.11