LLVM 23.0.0git
GlobalData.cpp
Go to the documentation of this file.
1//===- GlobalData.cpp -----------------------------------------------------===//
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
12#include <inttypes.h>
13
14using namespace llvm;
15using namespace gsym;
16
18 O.writeU32(static_cast<uint32_t>(Type));
19 O.writeU64(FileOffset);
20 O.writeU64(FileSize);
21}
22
25 if (!GsymData.isValidOffsetForDataOfSize(Offset, 20))
26 return createStringError(std::errc::invalid_argument,
27 "not enough data for a GlobalData entry");
28 GlobalData GD;
29 GD.Type = static_cast<GlobalInfoType>(GsymData.getU32(&Offset));
30 GD.FileOffset = GsymData.getU64(&Offset);
31 GD.FileSize = GsymData.getU64(&Offset);
32 return GD;
33}
34
36 switch (Type) {
38 return "EndOfList";
40 return "AddrOffsets";
42 return "AddrInfoOffsets";
44 return "StringTable";
46 return "FileTable";
48 return "FunctionInfo";
50 return "UUID";
51 }
52 return "Unknown";
53}
LLVM_ABI uint32_t getU32(uint64_t *offset_ptr, Error *Err=nullptr) const
Extract a uint32_t value from *offset_ptr.
LLVM_ABI uint64_t getU64(uint64_t *offset_ptr, Error *Err=nullptr) const
Extract a uint64_t value from *offset_ptr.
bool isValidOffsetForDataOfSize(uint64_t offset, uint64_t length) const
Test the availability of length bytes of data from offset.
Tagged union holding either a T or a Error.
Definition Error.h:485
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
A simplified binary data writer class that doesn't require targets, target definitions,...
Definition FileWriter.h:30
A DataExtractor subclass that adds GSYM-specific string offset support.
LLVM_ABI StringRef getNameForGlobalInfoType(GlobalInfoType Type)
GlobalInfoType
GlobalInfoType allows GSYM files to encode global information within a GSYM file in a way that is ext...
Definition GlobalData.h:26
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:532
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition Error.h:1321
GlobalData describes a section of data in a GSYM file by its type, file offset, and size.
Definition GlobalData.h:61
static LLVM_ABI llvm::Expected< GlobalData > decode(GsymDataExtractor &GsymData, uint64_t &Offset)
Decode a GlobalData entry from a binary data stream.
LLVM_ABI void encode(FileWriter &O) const
Encode this GlobalData entry into a FileWriter stream.
GlobalInfoType Type
Definition GlobalData.h:62