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

1

2

3

4

5

6

7

8

9#ifndef LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H

10#define LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H

11

27#include

28#include

29#include

30

31namespace llvm {

32

45

46

47

48

50public:

51

52

53

54

55

56

57

59 protected:

60

61

68

70 public:

97 virtual std::shared_ptr

102

103

104 LLVM_ABI std::unique_ptr

106 };

108

109private:

110

111

112 std::unique_ptr State;

113

114

115 unsigned MaxVersion = 0;

116

117 std::function<void(Error)> RecoverableErrorHandler =

120

121

122

123

124

125 enum { EagerParse = false, LazyParse = true };

127

128 std::unique_ptr DObj;

129

130

131

132 bool ParseCUTUIndexManually = false;

133

134public:

135 DWARFContext(std::unique_ptr DObj,

136 std::string DWPName = "",

137 std::function<void(Error)> RecoverableErrorHandler =

139 std::function<void(Error)> WarningHandler =

141 bool ThreadSafe = false);

143

146

148

152

153

154

156 std::array<std::optional<uint64_t>, DIDT_ID_Count> DumpOffsets);

157

159 std::array<std::optional<uint64_t>, DIDT_ID_Count> DumpOffsets;

160 dump(OS, DumpOpts, DumpOffsets);

161 }

162

164

167

168

172 NormalUnits.begin() +

174 }

175

177 return State->getNormalUnits();

178 }

179

180

186

187

191

192

193

194

195

198 return NormalUnits;

199 }

200

201

207

209 return State->getDWOUnits();

210 }

211

212

213 bool isDWP() const;

214

215

219 DWOUnits.end());

220 }

221

222

226

227

228

229

230

231

234 return DWOUnits;

235 }

236

237

239 return State->getNormalUnits().getNumInfoUnits();

240 }

241

242

244 return State->getNormalUnits().getNumTypesUnits();

245 }

246

247

249 return State->getDWOUnits().getNumInfoUnits();

250 }

251

252

254 return State->getDWOUnits().getNumTypesUnits();

255 }

256

257

259 return State->getNormalUnits()[index].get();

260 }

261

262

264 return State->getDWOUnits()[index].get();

265 }

266

269

270

272

273

275

276

278

280

282 return MaxVersion;

283 }

284

286

288 return MaxVersion;

289 }

290

292 if (Version > MaxVersion)

294 }

295

299

300

302

303

305

306

308

309

311

312

314

315

317

318

320

321

323

324

326

327

329

330

332

333

335

336

338

339

341

342

344

345

346

348

349

350

352 getLineTableForUnit(DWARFUnit *U,

354

355

356

357 void clearLineTableForUnit(DWARFUnit *U);

358

363 return DataExtractor(DObj->getStrDWOSection(), false, 0);

364 }

366 return DataExtractor(DObj->getLineStrSection(), false, 0);

367 }

368

369

376

377

378

379

380

381

382

383

384

385

386

387 DIEsForAddress getDIEsForAddress(uint64_t Address, bool CheckDWO = false);

388

389 std::optional getLineInfoForAddress(

392 std::optional

400

401 std::vector

403

409

411 return {2, 4, 8};

412 }

416 template <typename... Ts>

418 std::error_code EC, char const *Fmt,

419 const Ts &...Vals) {

422 std::string Buffer;

424 Stream << format(Fmt, Vals...)

425 << " has unsupported address size: " << AddressSize

426 << " (supported are ";

429 Stream << LS << Size;

430 Stream << ')';

432 }

433

434 std::shared_ptr getDWOContext(StringRef AbsolutePath);

435

437 return RecoverableErrorHandler;

438 }

439

441

443

444 static std::unique_ptr

446 ProcessDebugRelocations RelocAction = ProcessDebugRelocations::Process,

447 const LoadedObjectInfo *L = nullptr, std::string DWPName = "",

448 std::function<void(Error)> RecoverableErrorHandler =

450 std::function<void(Error)> WarningHandler =

452 bool ThreadSafe = false);

453

454 static std::unique_ptr

455 create(const StringMap<std::unique_ptr> &Sections,

457 std::function<void(Error)> RecoverableErrorHandler =

459 std::function<void(Error)> WarningHandler =

461 bool ThreadSafe = false);

462

463

464

466

470

471

472

473

474

476

477

478

479

480

481

482

483

485

486

487

489

490

491

493

494private:

496 std::vector &Result);

497};

498

499}

500

501#endif

This file defines the StringMap class.

static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)

Return the first DebugLoc that has line number information, given a range of instructions.

This file defines the SmallVector class.

This implements the Apple accelerator table format, a precursor of the DWARF 5 accelerator table form...

DIContextKind getKind() const

DIContext(DIContextKind K)

A format-neutral container for inlined code description.

DWARFContextState This structure contains all member variables for DWARFContext that need to be prote...

Definition DWARFContext.h:58

virtual void clearLineTableForUnit(DWARFUnit *U)=0

virtual DWARFGdbIndex & getGdbIndex()=0

virtual Expected< const DWARFDebugFrame * > getEHFrame()=0

virtual const DWARFUnitIndex & getCUIndex()=0

MacroSecType

Helper enum to distinguish between macro[.dwo] and macinfo[.dwo] section.

Definition DWARFContext.h:62

@ MacinfoDwoSection

Definition DWARFContext.h:64

@ MacinfoSection

Definition DWARFContext.h:63

@ MacroSection

Definition DWARFContext.h:65

@ MacroDwoSection

Definition DWARFContext.h:66

virtual bool isThreadSafe() const =0

virtual const DWARFUnitIndex & getTUIndex()=0

virtual const DWARFDebugMacro * getDebugMacinfoDWO()=0

virtual const DWARFDebugMacro * getDebugMacroDWO()=0

virtual const DenseMap< uint64_t, DWARFTypeUnit * > & getTypeUnitMap(bool IsDWO)=0

virtual Expected< const DWARFDebugLine::LineTable * > getLineTableForUnit(DWARFUnit *U, function_ref< void(Error)> RecoverableErrHandler)=0

virtual const DWARFDebugAbbrev * getDebugAbbrevDWO()=0

virtual const DWARFDebugMacro * getDebugMacro()=0

virtual const DWARFDebugAranges * getDebugAranges()=0

virtual ~DWARFContextState()=default

virtual const AppleAcceleratorTable & getAppleNames()=0

LLVM_ABI std::unique_ptr< DWARFDebugMacro > parseMacroOrMacinfo(MacroSecType SectionType)

Parse a macro[.dwo] or macinfo[.dwo] section.

DWARFContextState(DWARFContext &DC)

Definition DWARFContext.h:71

virtual Expected< const DWARFDebugFrame * > getDebugFrame()=0

virtual DWARFUnitVector & getDWOUnits(bool Lazy=false)=0

virtual const DWARFDebugLoc * getDebugLoc()=0

DWARFContext & D

Definition DWARFContext.h:69

virtual DWARFUnitVector & getNormalUnits()=0

virtual const DWARFDebugAbbrev * getDebugAbbrev()=0

virtual const DWARFDebugNames & getDebugNames()=0

virtual const AppleAcceleratorTable & getAppleTypes()=0

virtual const AppleAcceleratorTable & getAppleNamespaces()=0

virtual const DWARFDebugMacro * getDebugMacinfo()=0

virtual const AppleAcceleratorTable & getAppleObjC()=0

virtual std::shared_ptr< DWARFContext > getDWOContext(StringRef AbsolutePath)=0

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

Definition DWARFContext.h:49

static bool isSupportedVersion(unsigned version)

Definition DWARFContext.h:406

Triple::ArchType getArch() const

Definition DWARFContext.h:467

function_ref< void(Error)> getRecoverableErrorHandler()

Definition DWARFContext.h:436

unsigned getNumCompileUnits()

Get the number of compile units in this context.

Definition DWARFContext.h:238

DWARFUnitVector::compile_unit_range compile_unit_range

Definition DWARFContext.h:166

static SmallVector< uint8_t, 3 > getSupportedAddressSizes()

Definition DWARFContext.h:410

DWARFContext(std::unique_ptr< const DWARFObject > DObj, std::string DWPName="", std::function< void(Error)> RecoverableErrorHandler=WithColor::defaultErrorHandler, std::function< void(Error)> WarningHandler=WithColor::defaultWarningHandler, bool ThreadSafe=false)

unsigned getNumTypeUnits()

Get the number of type units in this context.

Definition DWARFContext.h:243

DWARFUnitVector::iterator_range unit_iterator_range

Definition DWARFContext.h:165

static bool classof(const DIContext *DICtx)

Definition DWARFContext.h:149

compile_unit_range compile_units()

Get compile units in this context.

Definition DWARFContext.h:188

unsigned getMaxVersion()

Definition DWARFContext.h:279

DWARFUnit * getDWOUnitAtIndex(unsigned index)

Get the unit at the specified index for the DWO units.

Definition DWARFContext.h:263

DataExtractor getStringExtractor() const

Definition DWARFContext.h:359

void setParseCUTUIndexManually(bool PCUTU)

Sets whether CU/TU should be populated manually.

Definition DWARFContext.h:492

unsigned getNumDWOTypeUnits()

Get the number of type units in the DWO context.

Definition DWARFContext.h:253

static Error checkAddressSizeSupported(unsigned AddressSize, std::error_code EC, char const *Fmt, const Ts &...Vals)

Definition DWARFContext.h:417

function_ref< void(Error)> getWarningHandler()

Definition DWARFContext.h:440

bool isLittleEndian() const

Definition DWARFContext.h:404

DWARFUnit * getUnitAtIndex(unsigned index)

Get the unit at the specified index.

Definition DWARFContext.h:258

DWARFContext & operator=(DWARFContext &)=delete

ProcessDebugRelocations

Definition DWARFContext.h:442

@ Process

Definition DWARFContext.h:442

@ Ignore

Definition DWARFContext.h:442

void setMaxVersionIfGreater(unsigned Version)

Definition DWARFContext.h:291

compile_unit_range dwo_compile_units()

Get compile units in the DWO context.

Definition DWARFContext.h:223

const DWARFUnitVector & getNormalUnitsVector()

Definition DWARFContext.h:176

unit_iterator_range dwo_types_section_units()

Get units from .debug_types.dwo in the DWO context.

Definition DWARFContext.h:216

void dump(raw_ostream &OS, DIDumpOptions DumpOpts, std::array< std::optional< uint64_t >, DIDT_ID_Count > DumpOffsets)

Dump a textual representation to OS.

unit_iterator_range normal_units()

Get all normal compile/type units in this context.

Definition DWARFContext.h:196

static unsigned getMaxSupportedVersion()

Definition DWARFContext.h:405

unit_iterator_range types_section_units()

Get units from .debug_types in this context.

Definition DWARFContext.h:181

void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override

Definition DWARFContext.h:158

unsigned getNumDWOCompileUnits()

Get the number of compile units in the DWO context.

Definition DWARFContext.h:248

DWARFContext(DWARFContext &)=delete

DataExtractor getLineStringExtractor() const

Definition DWARFContext.h:365

unit_iterator_range info_section_units()

Get units from .debug_info in this context.

Definition DWARFContext.h:169

bool getParseCUTUIndexManually() const

Returns whether CU/TU should be populated manually.

Definition DWARFContext.h:488

unit_iterator_range dwo_info_section_units()

Get units from .debug_info..dwo in the DWO context.

Definition DWARFContext.h:202

DataExtractor getStringDWOExtractor() const

Definition DWARFContext.h:362

static bool isAddressSizeSupported(unsigned AddressSize)

Definition DWARFContext.h:413

const DWARFUnitVector & getDWOUnitsVector()

Definition DWARFContext.h:208

unit_iterator_range dwo_units()

Get all units in the DWO context.

Definition DWARFContext.h:232

const DWARFObject & getDWARFObj() const

Definition DWARFContext.h:147

unsigned getMaxDWOVersion()

Definition DWARFContext.h:285

A parsed .debug_frame or .eh_frame section.

.debug_names section consists of one or more units.

Utility class that carries the DWARF compile/type unit and the debug info entry in an object.

Describe a collection of units.

unsigned getNumInfoUnits() const

Returns number of units from all .debug_info[.dwo] sections.

llvm::iterator_range< UnitVector::iterator > iterator_range

decltype(make_filter_range(std::declval< iterator_range >(), isCompileUnit)) compile_unit_range

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.

A helper class to return the specified delimiter string after the first invocation of operator String...

An inferface for inquiring the load address of a loaded object file to be used by the DIContext imple...

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

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...

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

static LLVM_ABI void defaultWarningHandler(Error Warning)

Implement default handling for Warning.

static LLVM_ABI void defaultErrorHandler(Error Err)

Implement default handling for Error.

An efficient, type-erasing, non-owning reference to a callable.

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

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

A raw_ostream that writes to an std::string.

constexpr bool IsLittleEndianHost

This is an optimization pass for GlobalISel generic memory operations.

void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)

SmallVector< std::pair< uint64_t, DILineInfo >, 16 > DILineInfoTable

static CompileUnit * getUnitForOffset(const UnitListTy &Units, uint64_t Offset)

Similar to DWARFUnitSection::getUnitForOffset(), but returning our CompileUnit object instead.

FunctionAddr VTableAddr uintptr_t uintptr_t Version

iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)

Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...

format_object< Ts... > format(const char *Fmt, const Ts &... Vals)

These are helper functions used to produce formatted output.

Error make_error(ArgTs &&... Args)

Make a Error instance representing failure using the given error info type.

bool is_contained(R &&Range, const E &Element)

Returns true if Element is found in Range.

bool isCompileUnit(const std::unique_ptr< DWARFUnit > &U)

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

Controls which fields of DILineInfo container should be filled with data.

Wraps the returned DIEs for a given address.

Definition DWARFContext.h:370

DWARFDie FunctionDIE

Definition DWARFContext.h:372

DWARFDie BlockDIE

Definition DWARFContext.h:373

DWARFCompileUnit * CompileUnit

Definition DWARFContext.h:371