LLVM: include/llvm/DebugInfo/DWARF/DWARFFormValue.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_DEBUGINFO_DWARF_DWARFFORMVALUE_H

10#define LLVM_DEBUGINFO_DWARF_DWARFFORMVALUE_H

11

17#include

18

19namespace llvm {

20

26

27class DWARFFormValue {

28public:

41

47

48 union {

52 };

55 };

56

57private:

58 dwarf::Form Form;

60 dwarf::DWARF32;

61 ValueType Value;

62 const DWARFUnit *U = nullptr;

63 const DWARFContext *C = nullptr;

64

66

67public:

69

77 LLVM_ABI static std::optionalobject::SectionedAddress

80

83

97

98

99

100

101

105 const DWARFUnit *Unit = nullptr);

106

111

112

113

122 LLVM_ABI std::optionalobject::SectionedAddress

128

129

130

131

132

133

134

135

136

137

138

139 LLVM_ABI std::optionalstd::string

141

142

143

144

145

146

147

148

149

150

155

156

157

158

159

160

161

162

163

164

165

169

170private:

172};

173

174namespace dwarf {

175

176

177

178

179

180

181inline std::optional<const char *>

182toString(const std::optional &V) {

183 if (!V)

184 return std::nullopt;

186 if (E) {

188 return std::nullopt;

189 }

190 return *E;

191}

192

193

194

195

196

197

200 if (!V)

202 auto S = V->getAsCString();

203 if (!S) {

206 }

207 if (!*S)

209 return *S;

210}

211

212

213

214

215

216

217

218inline const char *toString(const std::optional &V,

221 return *E;

223}

224

225

226

227

228

229

230inline std::optional<uint64_t>

231toUnsigned(const std::optional &V) {

232 if (V)

233 return V->getAsUnsignedConstant();

234 return std::nullopt;

235}

236

237

238

239

240

241

242

247

248

249

250

251

252

253

254inline std::optional<uint64_t>

256 if (V)

257 return V->getAsRelativeReference();

258 return std::nullopt;

259}

260

261

262

263

264

265

266

271

272

273

274

275

276

277

278inline std::optional<uint64_t>

280 if (V)

281 return V->getAsDebugInfoReference();

282 return std::nullopt;

283}

284

285

286

287

288

289

290

291

292

297

298

299

300

301

302

303inline std::optional<uint64_t>

305 if (V)

306 return V->getAsSignatureReference();

307 return std::nullopt;

308}

309

310

311

312

313

314

315

320

321

322

323

324

325

326

327inline std::optional<uint64_t>

329 if (V)

330 return V->getAsSupplementaryReference();

331 return std::nullopt;

332}

333

334

335

336

337

338

339

340

345

346

347

348

349

350

351inline std::optional<int64_t> toSigned(const std::optional &V) {

352 if (V)

353 return V->getAsSignedConstant();

354 return std::nullopt;

355}

356

357

358

359

360

361

362

363inline int64_t toSigned(const std::optional &V,

366}

367

368

369

370

371

372

373inline std::optional<uint64_t>

374toAddress(const std::optional &V) {

375 if (V)

376 return V->getAsAddress();

377 return std::nullopt;

378}

379

380inline std::optionalobject::SectionedAddress

382 if (V)

383 return V->getAsSectionedAddress();

384 return std::nullopt;

385}

386

387

388

389

390

391

392

397

398

399

400

401

402

403inline std::optional<uint64_t>

405 if (V)

406 return V->getAsSectionOffset();

407 return std::nullopt;

408}

409

410

411

412

413

414

415

420

421

422

423

424

425

426inline std::optional<ArrayRef<uint8_t>>

427toBlock(const std::optional &V) {

428 if (V)

429 return V->getAsBlock();

430 return std::nullopt;

431}

432

433

434

435

436

437

441

442}

443

444}

445

446#endif

static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

This file contains constants used for implementing Dwarf debug support.

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

DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...

Definition DWARFFormValue.h:27

FormClass

Definition DWARFFormValue.h:29

@ FC_String

Definition DWARFFormValue.h:34

@ FC_Exprloc

Definition DWARFFormValue.h:39

@ FC_Indirect

Definition DWARFFormValue.h:37

@ FC_Constant

Definition DWARFFormValue.h:33

@ FC_Flag

Definition DWARFFormValue.h:35

@ FC_Unknown

Definition DWARFFormValue.h:30

@ FC_Block

Definition DWARFFormValue.h:32

@ FC_Address

Definition DWARFFormValue.h:31

@ FC_SectionOffset

Definition DWARFFormValue.h:38

@ FC_Reference

Definition DWARFFormValue.h:36

static LLVM_ABI void dumpAddressSection(const DWARFObject &Obj, raw_ostream &OS, DIDumpOptions DumpOpts, uint64_t SectionIndex)

static LLVM_ABI DWARFFormValue createFromPValue(dwarf::Form F, const char *V)

LLVM_ABI std::optional< uint64_t > getAsCStringOffset() const

static LLVM_ABI DWARFFormValue createFromUValue(dwarf::Form F, uint64_t V)

LLVM_ABI std::optional< uint64_t > getAsSupplementaryReference() const

LLVM_ABI std::optional< std::string > getAsFile(DILineInfoSpecifier::FileLineInfoKind Kind) const

Correctly extract any file paths from a form value.

LLVM_ABI std::optional< ArrayRef< uint8_t > > getAsBlock() const

LLVM_ABI std::optional< uint64_t > getAsSectionOffset() const

LLVM_ABI void dumpSectionedAddress(raw_ostream &OS, DIDumpOptions DumpOpts, object::SectionedAddress SA) const

LLVM_ABI bool isFormClass(FormClass FC) const

LLVM_ABI std::optional< object::SectionedAddress > getAsSectionedAddress() const

LLVM_ABI std::optional< uint64_t > getAsReferenceUVal() const

LLVM_ABI void dumpAddress(raw_ostream &OS, uint64_t Address) const

LLVM_ABI std::optional< int64_t > getAsSignedConstant() const

LLVM_ABI std::optional< uint64_t > getAsAddress() const

LLVM_ABI bool extractValue(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, dwarf::FormParams FormParams, const DWARFContext *Context=nullptr, const DWARFUnit *Unit=nullptr)

Extracts a value in Data at offset *OffsetPtr.

LLVM_ABI std::optional< uint64_t > getAsRelativeReference() const

getAsFoo functions below return the extracted value as Foo if only DWARFFormValue has form class is s...

LLVM_ABI std::optional< uint64_t > getAsSignatureReference() const

bool extractValue(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, dwarf::FormParams FormParams, const DWARFUnit *U)

Definition DWARFFormValue.h:107

LLVM_ABI std::optional< uint64_t > getAsDebugInfoReference() const

static LLVM_ABI DWARFFormValue createFromBlockValue(dwarf::Form F, ArrayRef< uint8_t > D)

LLVM_ABI void dump(raw_ostream &OS, DIDumpOptions DumpOpts=DIDumpOptions()) const

static LLVM_ABI DWARFFormValue createFromSValue(dwarf::Form F, int64_t V)

LLVM_ABI std::optional< uint64_t > getAsUnsignedConstant() const

bool skipValue(DataExtractor DebugInfoData, uint64_t *OffsetPtr, const dwarf::FormParams Params) const

Skip a form's value in DebugInfoData at the offset specified by OffsetPtr.

Definition DWARFFormValue.h:151

static LLVM_ABI DWARFFormValue createFromUnit(dwarf::Form F, const DWARFUnit *Unit, uint64_t *OffsetPtr)

LLVM_ABI Expected< const char * > getAsCString() const

DWARFFormValue(dwarf::Form F=dwarf::Form(0))

Definition DWARFFormValue.h:68

const DWARFUnit * getUnit() const

Definition DWARFFormValue.h:85

dwarf::Form getForm() const

Definition DWARFFormValue.h:81

uint64_t getRawUValue() const

Definition DWARFFormValue.h:82

Tagged union holding either a T or a Error.

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

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

std::optional< uint64_t > toAddress(const std::optional< DWARFFormValue > &V)

Take an optional DWARFFormValue and try to extract an address.

Definition DWARFFormValue.h:374

std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)

Take an optional DWARFFormValue and try to extract a string value from it.

Definition DWARFFormValue.h:182

std::optional< object::SectionedAddress > toSectionedAddress(const std::optional< DWARFFormValue > &V)

Definition DWARFFormValue.h:381

std::optional< int64_t > toSigned(const std::optional< DWARFFormValue > &V)

Take an optional DWARFFormValue and try to extract an signed constant.

Definition DWARFFormValue.h:351

std::optional< uint64_t > toSignatureReference(const std::optional< DWARFFormValue > &V)

Take an optional DWARFFormValue and try to extract a signature reference.

Definition DWARFFormValue.h:304

DwarfFormat

Constants that define the DWARF format as 32 or 64 bit.

std::optional< uint64_t > toDebugInfoReference(const std::optional< DWARFFormValue > &V)

Take an optional DWARFFormValue and try to extract an absolute debug info offset reference.

Definition DWARFFormValue.h:279

LLVM_ABI bool doesFormBelongToClass(dwarf::Form Form, DWARFFormValue::FormClass FC, uint16_t DwarfVersion)

Check whether specified Form belongs to the FC class.

std::optional< uint64_t > toSectionOffset(const std::optional< DWARFFormValue > &V)

Take an optional DWARFFormValue and try to extract an section offset.

Definition DWARFFormValue.h:404

StringRef toStringRef(const std::optional< DWARFFormValue > &V, StringRef Default={})

Take an optional DWARFFormValue and try to extract a string value from it.

Definition DWARFFormValue.h:198

std::optional< ArrayRef< uint8_t > > toBlock(const std::optional< DWARFFormValue > &V)

Take an optional DWARFFormValue and try to extract block data.

Definition DWARFFormValue.h:427

std::optional< uint64_t > toRelativeReference(const std::optional< DWARFFormValue > &V)

Take an optional DWARFFormValue and try to extract a relative offset reference.

Definition DWARFFormValue.h:255

std::optional< uint64_t > toSupplementaryReference(const std::optional< DWARFFormValue > &V)

Take an optional DWARFFormValue and try to extract a supplementary debug info reference.

Definition DWARFFormValue.h:328

std::optional< uint64_t > toUnsigned(const std::optional< DWARFFormValue > &V)

Take an optional DWARFFormValue and try to extract an unsigned constant.

Definition DWARFFormValue.h:231

This is an optimization pass for GlobalISel generic memory operations.

FunctionAddr VTableAddr uintptr_t uintptr_t Data

PointerUnion< const Value *, const PseudoSourceValue * > ValueType

@ Default

The result values are uniform if and only if all operands are uniform.

void consumeError(Error Err)

Consume a Error without doing anything.

Container for dump options that control which debug information will be dumped.

Definition DWARFFormValue.h:42

ValueType(const char *V)

Definition DWARFFormValue.h:46

uint64_t uval

Definition DWARFFormValue.h:49

ValueType(uint64_t V)

Definition DWARFFormValue.h:45

const uint8_t * data

Definition DWARFFormValue.h:53

ValueType()

Definition DWARFFormValue.h:43

const char * cstr

Definition DWARFFormValue.h:51

ValueType(int64_t V)

Definition DWARFFormValue.h:44

uint64_t SectionIndex

Definition DWARFFormValue.h:54

int64_t sval

Definition DWARFFormValue.h:50

A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...