LLVM: include/llvm/DebugInfo/GSYM/GsymReader.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_DEBUGINFO_GSYM_GSYMREADER_H

10#define LLVM_DEBUGINFO_GSYM_GSYMREADER_H

11

22#include <inttypes.h>

23#include

24#include <stdint.h>

25#include

26

27namespace llvm {

30

31namespace gsym {

32

33

34

35

36

37

38

39

40

41

42

43

44

45class GsymReader {

46 GsymReader(std::unique_ptr Buffer);

48

49 std::unique_ptr MemBuffer;

52 const Header *Hdr = nullptr;

57

58

59

60

61 struct SwappedData {

63 std::vector<uint8_t> AddrOffsets;

64 std::vector<uint32_t> AddrInfoOffsets;

65 std::vector Files;

66 };

67 std::unique_ptr Swap;

68

69public:

72

73

74

75

76

77

79

80

81

82

83

84

85

87

88

89

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

109

110

111

112

113

114

115

116

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

142 std::optional *MergedFuncsData = nullptr) const;

143

144

145

146

147

148

149

150

151

152

153

156

157

158

159

160

162

163

164

165

166

167

168

169

170

171

173 if (Index < Files.size())

174 return Files[Index];

175 return std::nullopt;

176 }

177

178

179

180

182

183

184

185

186

187

188

189

190

191

192

193

196

197

198

199

200

201

202

203

204

206

207

208

209

210

211

212

213

214

216

217

218

219

220

221

222

223

224

225

226

227

230

231

232

233

234

235

236

237

238

239

240

241

242

244

245

246

247

248

249

250

251

252

253

254

255

258

259

260

261

262

263

264

265

266

268

269

271 return Hdr->NumAddresses;

272 }

273

274

275

276

277

278

279

280

282

283protected:

284

285

286

287

288

289

290

291

292

293

294

297 return ArrayRef(reinterpret_cast<const T *>(AddrOffsets.data()),

298 AddrOffsets.size()/sizeof(T));

299 }

300

301

302

303

304

305

306

307

308

309

310

311

312

313 template

316 if (Index < AIO.size())

317 return AIO[Index] + Hdr->BaseAddress;

318 return std::nullopt;

319 }

320

321

322

323

324

325

326

327

328

329 template

330 std::optional<uint64_t>

333 const auto Begin = AIO.begin();

334 const auto End = AIO.end();

335 auto Iter = std::lower_bound(Begin, End, AddrOffset);

336

337

338 if (Iter == Begin && AddrOffset < *Begin)

339 return std::nullopt;

340 if (Iter == End || AddrOffset < *Iter)

341 --Iter;

342

343

344

345

346

347 while (Iter != Begin) {

348 auto Prev = Iter - 1;

349 if (*Prev == *Iter)

350 Iter = Prev;

351 else

352 break;

353 }

354

355 return std::distance(Begin, Iter);

356 }

357

358

359

360

361

362

363

364

365

366

368 create(std::unique_ptr &MemBuffer);

369

370

371

372

373

374

375

376

377

378

380

381

382

383

384

385

386

387

388

389

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

413

414

415

416

417

418

419

420

423};

424

425}

426}

427

428#endif

Provides ErrorOr smart pointer.

uint64_t IntrinsicInst * II

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

size_t size() const

size - Get the array size.

Lightweight error class with error context and mandatory checking.

Tagged union holding either a T or a Error.

This interface provides simple read-only access to a block of memory, and provides simple methods for...

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

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

Get the a file entry for the suppplied file index.

Definition GsymReader.h:172

LLVM_ABI void dump(raw_ostream &OS)

Dump the entire Gsym data contained in this object.

uint32_t getNumAddresses() const

Get the number of addresses in this Gsym file.

Definition GsymReader.h:270

static LLVM_ABI llvm::Expected< GsymReader > openFile(StringRef Path)

Construct a GsymReader from a file on disk.

LLVM_ABI std::optional< uint64_t > getAddress(size_t Index) const

Gets an address from the address table.

LLVM_ABI std::optional< uint64_t > getAddressInfoOffset(size_t Index) const

Given an address index, get the offset for the FunctionInfo.

ArrayRef< T > getAddrOffsets() const

Get an appropriate address info offsets array.

Definition GsymReader.h:296

StringRef getString(uint32_t Offset) const

Get a string from the string table.

Definition GsymReader.h:161

LLVM_ABI llvm::Expected< FunctionInfo > getFunctionInfo(uint64_t Addr) const

Get the full function info for an address.

LLVM_ABI const Header & getHeader() const

Access the GSYM header.

std::optional< uint64_t > addressForIndex(size_t Index) const

Get an appropriate address from the address table.

Definition GsymReader.h:314

LLVM_ABI llvm::Expected< llvm::DataExtractor > getFunctionInfoDataAtIndex(uint64_t AddrIdx, uint64_t &FuncStartAddr) const

Get the function data and address given an address index.

LLVM_ABI Expected< uint64_t > getAddressIndex(const uint64_t Addr) const

Given an address, find the address index.

LLVM_ABI GsymReader(GsymReader &&RHS)

static LLVM_ABI llvm::Expected< GsymReader > copyBuffer(StringRef Bytes)

Construct a GsymReader from a buffer.

LLVM_ABI llvm::Expected< LookupResult > lookup(uint64_t Addr, std::optional< DataExtractor > *MergedFuncsData=nullptr) const

Lookup an address in the a GSYM.

static LLVM_ABI llvm::Expected< llvm::gsym::GsymReader > create(std::unique_ptr< MemoryBuffer > &MemBuffer)

Create a GSYM from a memory buffer.

LLVM_ABI llvm::Expected< FunctionInfo > getFunctionInfoAtIndex(uint64_t AddrIdx) const

Get the full function info given an address index.

LLVM_ABI llvm::Expected< llvm::DataExtractor > getFunctionInfoDataForAddress(uint64_t Addr, uint64_t &FuncStartAddr) const

Given an address, find the correct function info data and function address.

LLVM_ABI llvm::Expected< std::vector< LookupResult > > lookupAll(uint64_t Addr) const

Lookup all merged functions for a given address.

std::optional< uint64_t > getAddressOffsetIndex(const uint64_t AddrOffset) const

Lookup an address offset in the AddrOffsets table.

Definition GsymReader.h:331

LineTable class contains deserialized versions of line tables for each function's address ranges.

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

This is an optimization pass for GlobalISel generic memory operations.

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

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

String tables in GSYM files are required to start with an empty string at offset zero.