Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:42

0001 //===- ExtractRanges.h ------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_DEBUGINFO_GSYM_EXTRACTRANGES_H
0010 #define LLVM_DEBUGINFO_GSYM_EXTRACTRANGES_H
0011 
0012 #include "llvm/ADT/AddressRanges.h"
0013 #include "llvm/Support/Format.h"
0014 #include "llvm/Support/raw_ostream.h"
0015 #include <stdint.h>
0016 
0017 #define HEX8(v) llvm::format_hex(v, 4)
0018 #define HEX16(v) llvm::format_hex(v, 6)
0019 #define HEX32(v) llvm::format_hex(v, 10)
0020 #define HEX64(v) llvm::format_hex(v, 18)
0021 
0022 namespace llvm {
0023 class DataExtractor;
0024 class raw_ostream;
0025 
0026 namespace gsym {
0027 
0028 class FileWriter;
0029 
0030 /// AddressRange objects are encoded and decoded to be relative to a base
0031 /// address. This will be the FunctionInfo's start address if the AddressRange
0032 /// is directly contained in a FunctionInfo, or a base address of the
0033 /// containing parent AddressRange or AddressRanges. This allows address
0034 /// ranges to be efficiently encoded using ULEB128 encodings as we encode the
0035 /// offset and size of each range instead of full addresses. This also makes
0036 /// encoded addresses easy to relocate as we just need to relocate one base
0037 /// address.
0038 /// @{
0039 AddressRange decodeRange(DataExtractor &Data, uint64_t BaseAddr,
0040                          uint64_t &Offset);
0041 void encodeRange(const AddressRange &Range, FileWriter &O, uint64_t BaseAddr);
0042 /// @}
0043 
0044 /// Skip an address range object in the specified data a the specified
0045 /// offset.
0046 ///
0047 /// \param Data The binary stream to read the data from.
0048 ///
0049 /// \param Offset The byte offset within \a Data.
0050 void skipRange(DataExtractor &Data, uint64_t &Offset);
0051 
0052 /// Address ranges are decoded and encoded to be relative to a base address.
0053 /// See the AddressRange comment for the encode and decode methods for full
0054 /// details.
0055 /// @{
0056 void decodeRanges(AddressRanges &Ranges, DataExtractor &Data, uint64_t BaseAddr,
0057                   uint64_t &Offset);
0058 void encodeRanges(const AddressRanges &Ranges, FileWriter &O,
0059                   uint64_t BaseAddr);
0060 /// @}
0061 
0062 /// Skip an address range object in the specified data a the specified
0063 /// offset.
0064 ///
0065 /// \param Data The binary stream to read the data from.
0066 ///
0067 /// \param Offset The byte offset within \a Data.
0068 ///
0069 /// \returns The number of address ranges that were skipped.
0070 uint64_t skipRanges(DataExtractor &Data, uint64_t &Offset);
0071 
0072 } // namespace gsym
0073 
0074 raw_ostream &operator<<(raw_ostream &OS, const AddressRange &R);
0075 
0076 raw_ostream &operator<<(raw_ostream &OS, const AddressRanges &AR);
0077 
0078 } // namespace llvm
0079 
0080 #endif // LLVM_DEBUGINFO_GSYM_EXTRACTRANGES_H