Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 14 | pmbaty | 1 | //===- ExtractRanges.h ------------------------------------------*- C++ -*-===// |
| 2 | // |
||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
||
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
||
| 6 | // |
||
| 7 | //===----------------------------------------------------------------------===// |
||
| 8 | |||
| 9 | #ifndef LLVM_DEBUGINFO_GSYM_EXTRACTRANGES_H |
||
| 10 | #define LLVM_DEBUGINFO_GSYM_EXTRACTRANGES_H |
||
| 11 | |||
| 12 | #include "llvm/ADT/AddressRanges.h" |
||
| 13 | #include "llvm/Support/Format.h" |
||
| 14 | #include "llvm/Support/raw_ostream.h" |
||
| 15 | #include <stdint.h> |
||
| 16 | #include <vector> |
||
| 17 | |||
| 18 | #define HEX8(v) llvm::format_hex(v, 4) |
||
| 19 | #define HEX16(v) llvm::format_hex(v, 6) |
||
| 20 | #define HEX32(v) llvm::format_hex(v, 10) |
||
| 21 | #define HEX64(v) llvm::format_hex(v, 18) |
||
| 22 | |||
| 23 | namespace llvm { |
||
| 24 | class DataExtractor; |
||
| 25 | class raw_ostream; |
||
| 26 | |||
| 27 | namespace gsym { |
||
| 28 | |||
| 29 | class FileWriter; |
||
| 30 | |||
| 31 | /// AddressRange objects are encoded and decoded to be relative to a base |
||
| 32 | /// address. This will be the FunctionInfo's start address if the AddressRange |
||
| 33 | /// is directly contained in a FunctionInfo, or a base address of the |
||
| 34 | /// containing parent AddressRange or AddressRanges. This allows address |
||
| 35 | /// ranges to be efficiently encoded using ULEB128 encodings as we encode the |
||
| 36 | /// offset and size of each range instead of full addresses. This also makes |
||
| 37 | /// encoded addresses easy to relocate as we just need to relocate one base |
||
| 38 | /// address. |
||
| 39 | /// @{ |
||
| 40 | AddressRange decodeRange(DataExtractor &Data, uint64_t BaseAddr, |
||
| 41 | uint64_t &Offset); |
||
| 42 | void encodeRange(const AddressRange &Range, FileWriter &O, uint64_t BaseAddr); |
||
| 43 | /// @} |
||
| 44 | |||
| 45 | /// Skip an address range object in the specified data a the specified |
||
| 46 | /// offset. |
||
| 47 | /// |
||
| 48 | /// \param Data The binary stream to read the data from. |
||
| 49 | /// |
||
| 50 | /// \param Offset The byte offset within \a Data. |
||
| 51 | void skipRange(DataExtractor &Data, uint64_t &Offset); |
||
| 52 | |||
| 53 | /// Address ranges are decoded and encoded to be relative to a base address. |
||
| 54 | /// See the AddressRange comment for the encode and decode methods for full |
||
| 55 | /// details. |
||
| 56 | /// @{ |
||
| 57 | void decodeRanges(AddressRanges &Ranges, DataExtractor &Data, uint64_t BaseAddr, |
||
| 58 | uint64_t &Offset); |
||
| 59 | void encodeRanges(const AddressRanges &Ranges, FileWriter &O, |
||
| 60 | uint64_t BaseAddr); |
||
| 61 | /// @} |
||
| 62 | |||
| 63 | /// Skip an address range object in the specified data a the specified |
||
| 64 | /// offset. |
||
| 65 | /// |
||
| 66 | /// \param Data The binary stream to read the data from. |
||
| 67 | /// |
||
| 68 | /// \param Offset The byte offset within \a Data. |
||
| 69 | /// |
||
| 70 | /// \returns The number of address ranges that were skipped. |
||
| 71 | uint64_t skipRanges(DataExtractor &Data, uint64_t &Offset); |
||
| 72 | |||
| 73 | } // namespace gsym |
||
| 74 | |||
| 75 | raw_ostream &operator<<(raw_ostream &OS, const AddressRange &R); |
||
| 76 | |||
| 77 | raw_ostream &operator<<(raw_ostream &OS, const AddressRanges &AR); |
||
| 78 | |||
| 79 | } // namespace llvm |
||
| 80 | |||
| 81 | #endif // LLVM_DEBUGINFO_GSYM_EXTRACTRANGES_H |