LLVM: lib/DebugInfo/GSYM/ObjectFileTransformer.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

14

18

19using namespace llvm;

20using namespace gsym;

21

23

25

26 std::vector<uint8_t> UUID;

27 if (auto *MachO = dyn_castobject::MachOObjectFile(&Obj)) {

29 if (!MachUUID.empty())

30 UUID.assign(MachUUID.data(), MachUUID.data() + MachUUID.size());

31 } else if (isaobject::ELFObjectFileBase(&Obj)) {

32 const StringRef GNUBuildID(".note.gnu.build-id");

35 if (!SectNameOrErr) {

37 continue;

38 }

39 StringRef SectName(*SectNameOrErr);

40 if (SectName != GNUBuildID)

41 continue;

44 if (E)

45 BuildIDData = *E;

46 else {

48 continue;

49 }

59 if (!UUIDBytes.empty()) {

60 auto Ptr = reinterpret_cast<const uint8_t *>(UUIDBytes.data());

62 }

63 }

64 }

65 }

67}

68

73

74 const bool IsMachO = isa(&Obj);

75 const bool IsELF = isa(&Obj);

76

77

79

80

84 if (!SymType) {

86 continue;

87 }

89 if (!AddrOrErr)

90

92

93 if (SymType.get() != SymbolRef::Type::ST_Function ||

95 continue;

96

97 constexpr bool NoCopy = false;

103 "ObjectFileTransformer: ");

104 else

106 continue;

107 }

108

109

110 if (IsMachO)

111 Name->consume_front("_");

114 }

117 *Out.GetOS() << "Loaded " << FunctionsAddedCount

118 << " functions from symbol table.\n";

120}

static std::vector< uint8_t > getUUID(const object::ObjectFile &Obj)

constexpr uint32_t NT_GNU_BUILD_ID_TAG

std::pair< llvm::MachO::Target, std::string > UUID

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

size_t size() const

size - Get the array size.

bool empty() const

empty - Check if the array is empty.

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

Tagged union holding either a T or a Error.

Error takeError()

Take ownership of the stored error.

reference get()

Returns a reference to the stored T value.

StringRef - Represent a constant reference to a string, i.e.

constexpr bool empty() const

empty - Check if the string is empty.

constexpr size_t size() const

size - Get the string size.

constexpr const char * data() const

data - Get a pointer to the start of the string (which may not be null terminated).

bool isLittleEndian() const

Tests whether the target triple is little endian.

GsymCreator is used to emit GSYM data to a stand alone file or section within a file.

void addFunctionInfo(FunctionInfo &&FI)

Add a function info to this GSYM creator.

uint32_t insertString(StringRef S, bool Copy=true)

Insert a string into the GSYM string table.

void setUUID(llvm::ArrayRef< uint8_t > UUIDBytes)

Set the UUID value.

size_t getNumFunctionInfos() const

Get the current number of FunctionInfo objects contained in this object.

bool IsValidTextAddress(uint64_t Addr) const

Check if an address is a valid code address.

static llvm::Error convert(const object::ObjectFile &Obj, OutputAggregator &Output, GsymCreator &Gsym)

Extract any object file data that is needed by the GsymCreator.

raw_ostream * GetOS() const

This class is the base class for all object file types.

Triple makeTriple() const

Create a triple from the data in this object file.

section_iterator_range sections() const

symbol_iterator_range symbols() const

This is a value type class that represents a single section in the list of sections in the object fil...

This is a value type class that represents a single symbol in the list of symbols in the object file.

constexpr size_t NameSize

This is an optimization pass for GlobalISel generic memory operations.

void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})

Log all errors (if any) in E to OS.

auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)

Get the size of a range.

uint64_t alignTo(uint64_t Size, Align A)

Returns a multiple of A needed to store Size bytes.

void consumeError(Error Err)

Consume a Error without doing anything.

Function information in GSYM files encodes information for one contiguous address range.