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

1

2

3

4

5

6

7

8

15#include

16

17using namespace llvm;

18using namespace gsym;

19

20

21

29

31 OS << FI.Range << ": " << "Name=" << HEX32(FI.Name) << '\n';

35 OS << FI.Inline << '\n';

38 return OS;

39}

40

45 if (Data.isValidOffsetForDataOfSize(Offset, 4))

47 "0x%8.8" PRIx64 ": missing FunctionInfo Size", Offset);

49 if (Data.isValidOffsetForDataOfSize(Offset, 4))

51 "0x%8.8" PRIx64 ": missing FunctionInfo Name", Offset);

53 if (FI.Name == 0)

55 "0x%8.8" PRIx64 ": invalid FunctionInfo Name value 0x%8.8x",

57 bool Done = false;

58 while (Done) {

59 if (Data.isValidOffsetForDataOfSize(Offset, 4))

61 "0x%8.8" PRIx64 ": missing FunctionInfo InfoType value", Offset);

63 if (Data.isValidOffsetForDataOfSize(Offset, 4))

65 "0x%8.8" PRIx64 ": missing FunctionInfo InfoType length", Offset);

67 if (Data.isValidOffsetForDataOfSize(Offset, InfoLength))

69 "0x%8.8" PRIx64 ": missing FunctionInfo data for InfoType %u",

72 Data.isLittleEndian(),

73 Data.getAddressSize());

74 switch (IT) {

77 break;

78

82 else

83 return LT.takeError();

84 break;

85

88 FI.Inline = std::move(II.get());

89 else

90 return II.takeError();

91 break;

92

97 else

98 return MI.takeError();

99 break;

100

104 FI.CallSites = std::move(CI.get());

105 else

106 return CI.takeError();

107 break;

108

109 default:

111 "0x%8.8" PRIx64 ": unsupported InfoType %u",

113 }

114 Offset += InfoLength;

115 }

116 return std::move(FI);

117}

118

122 return 0;

126 if (!Result) {

129 return 0;

130 }

132}

133

135 bool NoPadding) const {

138 "attempted to encode invalid FunctionInfo object");

139

140 if (NoPadding == false)

143

144

145

146

149

152 return FuncInfoOffset;

153 }

154

155

157

159

162

163

165 const auto StartOffset = Out.tell();

167 if (err)

168 return std::move(err);

169 const auto Length = Out.tell() - StartOffset;

170 if (Length > UINT32_MAX)

172 "LineTable length is greater than UINT32_MAX");

173

175 }

176

177

180

181

183 const auto StartOffset = Out.tell();

185 if (err)

186 return std::move(err);

187 const auto Length = Out.tell() - StartOffset;

188 if (Length > UINT32_MAX)

190 "InlineInfo length is greater than UINT32_MAX");

191

193 }

194

195

198

199

201 const auto StartOffset = Out.tell();

203 if (err)

204 return std::move(err);

205 const auto Length = Out.tell() - StartOffset;

206 if (Length > UINT32_MAX)

208 std::errc::invalid_argument,

209 "MergedFunctionsInfo length is greater than UINT32_MAX");

210

212 }

213

214

217

218

220 const auto StartOffset = Out.tell();

222 if (Err)

223 return std::move(Err);

224 const auto Length = Out.tell() - StartOffset;

225 if (Length > UINT32_MAX)

227 "CallSites length is greater than UINT32_MAX");

228

230 }

231

232

235 return FuncInfoOffset;

236}

237

241 std::optional *MergedFuncsData) {

247

248

249

252 "FunctionInfo data is truncated");

253

254

255

258 "address 0x%" PRIx64 " is not in GSYM", Addr);

259

260 if (NameOffset == 0)

262 "0x%8.8" PRIx64 ": invalid FunctionInfo Name value 0x00000000",

265 bool Done = false;

266 std::optional LineEntry;

267 std::optional InlineInfoData;

268 while (Done) {

269 if (Data.isValidOffsetForDataOfSize(Offset, 8))

271 "FunctionInfo data is truncated");

275 if (InfoLength != InfoBytes.size())

277 "FunctionInfo data is truncated");

279 Data.getAddressSize());

280 switch (IT) {

283 break;

284

286 if (auto ExpectedLE = LineTable::lookup(InfoData, FuncAddr, Addr))

288 else

289 return ExpectedLE.takeError();

290 break;

291

293

294 if (MergedFuncsData)

295 *MergedFuncsData = InfoData;

296 break;

297

299

300

301 InlineInfoData = InfoData;

302 break;

303

306

307 for (const auto &CS : CSIC->CallSites) {

308

309 if (CS.ReturnOffset == Addr - FuncAddr) {

310

311 for (uint32_t RegexOffset : CS.MatchRegex) {

313 }

314 break;

315 }

316 }

317 } else {

318 return CSIC.takeError();

319 }

320 break;

321

322 default:

323 break;

324 }

325 Offset += InfoLength;

326 }

327

329

330

333 SrcLoc.Offset = Addr - FuncAddr;

335 return LR;

336 }

337

339 if (!LineEntryFile)

341 "failed to extract file[%" PRIu32 "]",

343

346 SrcLoc.Offset = Addr - FuncAddr;

347 SrcLoc.Dir = GR.getString(LineEntryFile->Dir);

351

352 if (!InlineInfoData)

353 return LR;

354

355

358 if (Err)

359 return std::move(Err);

360 return LR;

361}

static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))

InfoType

FunctionInfo information type that is used to encode the optional data that is associated with a Func...

Definition FunctionInfo.cpp:22

@ MergedFunctionsInfo

Definition FunctionInfo.cpp:26

@ EndOfList

Definition FunctionInfo.cpp:23

@ CallSiteInfo

Definition FunctionInfo.cpp:27

@ InlineInfo

Definition FunctionInfo.cpp:25

@ LineTableInfo

Definition FunctionInfo.cpp:24

uint64_t IntrinsicInst * II

bool contains(uint64_t Addr) const

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

Lightweight error class with error context and mandatory checking.

Tagged union holding either a T or a Error.

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

constexpr size_t size() const

size - Get the string size.

A simplified binary data writer class that doesn't require targets, target definitions,...

LLVM_ABI uint64_t tell()

Return the current offset within the file.

LLVM_ABI void fixup32(uint32_t Value, uint64_t Offset)

Fixup a uint32_t value at the specified offset in the stream.

LLVM_ABI void alignTo(size_t Align)

Pad with zeroes at the current file position until the current file position matches the specified al...

LLVM_ABI void writeU32(uint32_t Value)

Write a single uint32_t value into the stream at the current file position.

LLVM_ABI void writeData(llvm::ArrayRef< uint8_t > Data)

Write an array of uint8_t values into the stream at the current file position.

llvm::endianness getByteOrder() const

GsymReader is used to read GSYM data from a file or buffer.

std::optional< FileEntry > getFile(uint32_t Index) const

Get the a file entry for the suppplied file index.

StringRef getString(uint32_t Offset) const

Get a string from the string table.

static LLVM_ABI llvm::Expected< LineTable > decode(DataExtractor &Data, uint64_t BaseAddr)

Decode an LineTable object from a binary data stream.

static LLVM_ABI Expected< LineEntry > lookup(DataExtractor &Data, uint64_t BaseAddr, uint64_t Addr)

Lookup a single address within a line table's data.

This class implements an extremely fast bulk output stream that can only output to a stream.

A raw_ostream that writes to an SmallVector or SmallString.

LLVM_ABI raw_ostream & operator<<(raw_ostream &OS, const CallSiteInfo &CSI)

This is an optimization pass for GlobalISel generic memory operations.

Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)

Create formatted StringError object.

FunctionAddr VTableAddr uintptr_t uintptr_t Data

void consumeError(Error Err)

Consume a Error without doing anything.

static LLVM_ABI llvm::Expected< CallSiteInfoCollection > decode(DataExtractor &Data)

Decode a CallSiteInfoCollection object from a binary data stream.

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

std::optional< InlineInfo > Inline

std::optional< MergedFunctionsInfo > MergedFunctions

bool isValid() const

Query if a FunctionInfo object is valid.

std::optional< CallSiteInfoCollection > CallSites

static LLVM_ABI llvm::Expected< LookupResult > lookup(DataExtractor &Data, const GsymReader &GR, uint64_t FuncAddr, uint64_t Addr, std::optional< DataExtractor > *MergedFuncsData=nullptr)

Lookup an address within a FunctionInfo object's data stream.

Definition FunctionInfo.cpp:239

LLVM_ABI uint64_t cacheEncoding()

Encode this function info into the internal byte cache and return the size in bytes.

Definition FunctionInfo.cpp:119

uint32_t Name

String table offset in the string table.

LLVM_ABI llvm::Expected< uint64_t > encode(FileWriter &O, bool NoPadding=false) const

Encode this object into FileWriter stream.

Definition FunctionInfo.cpp:134

SmallString< 32 > EncodingCache

If we encode a FunctionInfo during segmenting so we know its size, we can cache that encoding here so...

std::optional< LineTable > OptLineTable

FunctionInfo(uint64_t Addr=0, uint64_t Size=0, uint32_t N=0)

static LLVM_ABI llvm::Expected< FunctionInfo > decode(DataExtractor &Data, uint64_t BaseAddr)

Decode an object from a binary data stream.

Definition FunctionInfo.cpp:41

Inline information stores the name of the inline function along with an array of address ranges.

static LLVM_ABI llvm::Error lookup(const GsymReader &GR, DataExtractor &Data, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs)

Lookup a single address within the inline info data.

static LLVM_ABI llvm::Expected< InlineInfo > decode(DataExtractor &Data, uint64_t BaseAddr)

Decode an InlineInfo object from a binary data stream.

Line entries are used to encode the line tables in FunctionInfo objects.

uint32_t File

1 based index of file in FileTable

uint32_t Line

Source line number.

uint64_t LookupAddr

The address that this lookup pertains to.

AddressRange FuncRange

The concrete function address range.

std::vector< StringRef > CallSiteFuncRegex

Function name regex patterns associated with a call site at the lookup address.

StringRef FuncName

The concrete function name that contains LookupAddr.

SourceLocations Locations

The source locations that match this address.

static LLVM_ABI llvm::Expected< MergedFunctionsInfo > decode(DataExtractor &Data, uint64_t BaseAddr)

Decode an MergedFunctionsInfo object from a binary data stream.

StringRef Base

Line entry source file basename.

uint32_t Line

Source file line number.

uint32_t Offset

Byte size offset within the named function.

StringRef Dir

Line entry source file directory path.

StringRef Name

Function or symbol name.