LLVM: lib/DebugInfo/LogicalView/Core/LVOptions.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

16

17using namespace llvm;

19

20#define DEBUG_TYPE "Options"

21

22

23

24

28

30

31 auto StandardAttributes = [&]() {

32

33 setAttributeStandard();

34

35 setAttributeBase();

36 setAttributeCoverage();

37 setAttributeDirectories();

38 setAttributeDiscriminator();

39 setAttributeFilename();

40 setAttributeFiles();

41 setAttributeFormat();

42 setAttributeLanguage();

43 setAttributeLevel();

44 setAttributeProducer();

45 setAttributePublics();

46 setAttributeRange();

47 setAttributeReference();

48 setAttributeZero();

49 };

50

51

52 auto ExtendedAttributes = [&]() {

53

54 setAttributeExtended();

55

56 setAttributeArgument();

57 setAttributeDiscarded();

58 setAttributeEncoded();

59 setAttributeGaps();

60 setAttributeGenerated();

61 setAttributeGlobal();

62 setAttributeInserted();

63 setAttributeLinkage();

64 setAttributeLocal();

65 setAttributeLocation();

66 setAttributeOffset();

67 setAttributePathname();

68 setAttributeQualified();

69 setAttributeQualifier();

70 setAttributeRegister();

71 setAttributeSize();

72 setAttributeSubrange();

73 setAttributeSystem();

74 setAttributeTypename();

75 };

76

77

78 if (getAttributeStandard())

79 StandardAttributes();

80

81

82 if (getAttributeExtended())

83 ExtendedAttributes();

84

85

86 if (getAttributeAll()) {

87 StandardAttributes();

88 ExtendedAttributes();

89 }

90

91

92 if (getAttributePathname())

93 resetAttributeFilename();

94

95

96 if (!getOutputText() && !getOutputJson())

97 setOutputText();

98

99

100 if (getOutputAll()) {

101 setOutputJson();

102 setOutputSplit();

103 setOutputText();

104 }

105

106

107 if (getOutputFolder().length())

108 setOutputSplit();

109

110

111 if (getOutputSplit())

112 setAttributePathname();

113

114

115 if (getPrintElements()) {

116 setPrintInstructions();

117 setPrintLines();

118 setPrintScopes();

119 setPrintSymbols();

120 setPrintTypes();

121 }

122

123

124 if (getPrintAll()) {

125 setPrintInstructions();

126 setPrintLines();

127 setPrintScopes();

128 setPrintSizes();

129 setPrintSymbols();

130 setPrintSummary();

131 setPrintTypes();

132 setPrintWarnings();

133 }

134

135

136 if (getWarningAll()) {

137 setWarningCoverages();

138 setWarningLines();

139 setWarningLocations();

140 setWarningRanges();

141 }

142

143

144 if (getInternalAll()) {

145 setInternalCmdline();

146 setInternalID();

147 setInternalIntegrity();

148 setInternalNone();

149 setInternalTag();

150 }

151

152

153 if (getCompareAll()) {

154 setCompareLines();

155 setCompareScopes();

156 setCompareSymbols();

157 setCompareTypes();

158 }

159

160

161 if (getCompareLines() || getCompareSymbols() || getCompareTypes())

162 setCompareScopes();

163

164

165 if (getCompareScopes())

166 setCompareExecute();

167

168

169 if (getPrintInstructions() || getPrintLines())

170 setPrintAnyLine();

171

172

173 if (getPrintAnyLine() || getPrintScopes() || getPrintSymbols() ||

174 getPrintTypes())

175 setPrintAnyElement();

176

177

178 if (getPrintSizes() && getPrintSummary())

179 setPrintSizesSummary();

180

181

182 if (getPrintAll() || getPrintAnyElement() || getPrintSizesSummary() ||

183 getPrintWarnings())

184 setPrintExecute();

185

186

187 if (getReportAll()) {

188 setReportChildren();

189 setReportList();

190 setReportParents();

191 setReportView();

192 }

193

194

195 if (getReportView()) {

196 setReportChildren();

197 setReportParents();

198 }

199

200

201 if (getReportParents() || getReportChildren() || getReportView())

202 setReportAnyView();

203

204

205 if (getReportList() || getReportAnyView())

206 setReportExecute();

207

208

209

210

211

212

213

214

215

216 if (getCompareExecute()) {

217 resetPrintExecute();

218 setComparePrint();

220 setAttributeAdded();

221 setAttributeArgument();

222 setAttributeEncoded();

223 setAttributeInserted();

224 setAttributeMissing();

225 setAttributeQualified();

226 setAttributeSize();

227 }

228

229

230 setPrintFormatting();

231

232

233 if (getAttributeCoverage() || getAttributeGaps() || getAttributeRegister())

234 setAttributeLocation();

235

236

237 if (!getPrintSymbols()) {

238 resetAttributeCoverage();

239 resetAttributeGaps();

240 resetAttributeLocation();

241 resetAttributeRegister();

242 }

243

244

245 if (getAttributeFilename() || getAttributePathname())

246 setAttributeAnySource();

247

248

249 if (getAttributeLocation() || getAttributeRange())

250 setAttributeAnyLocation();

251

252 if (getAttributeRange() || getPrintAnyLine())

253 setGeneralCollectRanges();

254

255 calculateIndentationSize();

256

257

259}

260

261void LVOptions::calculateIndentationSize() {

262 if (getInternalID()) {

264 IndentationSize += String.length();

265 }

266 if (getCompareExecute() && (getAttributeAdded() || getAttributeMissing()))

267 ++IndentationSize;

268 if (getAttributeOffset()) {

270 IndentationSize += String.length();

271 }

272 if (getAttributeLevel()) {

273 std::stringstream Stream;

274 Stream.str(std::string());

275 Stream << "[" << std::setfill('0') << std::setw(3) << 0 << "]";

276 IndentationSize += Stream.tellp();

277 }

278 if (getAttributeGlobal())

279 ++IndentationSize;

280}

281

282

283

285

286 OS << "** Attributes **\n"

287 << "All: " << getAttributeAll() << ", "

288 << "Argument: " << getAttributeArgument() << ", "

289 << "Base: " << getAttributeBase() << ", "

290 << "Coverage: " << getAttributeCoverage() << "\n"

291 << "Directories: " << getAttributeDirectories() << ", "

292 << "Discarded: " << getAttributeDiscarded() << ", "

293 << "Discriminator: " << getAttributeDiscriminator() << ", "

294 << "Encoded: " << getAttributeEncoded() << "\n"

295 << "Extended: " << getAttributeExtended() << ", "

296 << "Filename: " << getAttributeFilename() << ", "

297 << "Files: " << getAttributeFiles() << ", "

298 << "Format: " << getAttributeFormat() << "\n"

299 << "Gaps: " << getAttributeGaps() << ", "

300 << "Generated: " << getAttributeGenerated() << ", "

301 << "Global: " << getAttributeGlobal() << ", "

302 << "Inserted: " << getAttributeInserted() << "\n"

303 << "Level: " << getAttributeLevel() << ", "

304 << "Linkage: " << getAttributeLinkage() << ", "

305 << "Local: " << getAttributeLocal() << ", "

306 << "Location: " << getAttributeLocation() << "\n"

307 << "Offset: " << getAttributeOffset() << ", "

308 << "Pathname: " << getAttributePathname() << ", "

309 << "Producer: " << getAttributeProducer() << ", "

310 << "Publics: " << getAttributePublics() << "\n"

311 << "Qualified: " << getAttributeQualified() << ", "

312 << "Qualifier: " << getAttributeQualifier() << ", "

313 << "Range: " << getAttributeRange() << ", "

314 << "Reference: " << getAttributeReference() << "\n"

315 << "Register: " << getAttributeRegister() << ", "

316 << "Size: " << getAttributeSize() << ", "

317 << "Standard: " << getAttributeStandard() << ", "

318 << "Subrange: " << getAttributeSubrange() << "\n"

319 << "System: " << getAttributeSystem() << ", "

320 << "Typename: " << getAttributeTypename() << ", "

321 << "Underlying: " << getAttributeUnderlying() << ", "

322 << "Zero: " << getAttributeZero() << "\n";

323 OS << "Added: " << getAttributeAdded() << ", "

324 << "AnyLocation: " << getAttributeAnyLocation() << ", "

325 << "AnySource: " << getAttributeAnySource() << ", "

326 << "Missing: " << getAttributeMissing() << "\n"

327 << "\n";

328

329

330 OS << "** Compare **\n"

331 << "All: " << getCompareAll() << ", "

332 << "Lines: " << getCompareLines() << ", "

333 << "Scopes: " << getCompareScopes() << ", "

334 << "Symbols: " << getCompareSymbols() << ", "

335 << "Types: " << getCompareTypes() << "\n";

336 OS << "Context: " << getCompareContext() << ", "

337 << "Execute: " << getCompareExecute() << ", "

338 << "Print: " << getComparePrint() << "\n"

339 << "\n";

340

341

342 OS << "** Print **\n"

343 << "All: " << getPrintAll() << ", "

344 << "Elements: " << getPrintElements() << ", "

345 << "Instructions: " << getPrintInstructions() << ", "

346 << "Lines: " << getPrintLines() << "\n"

347 << "Scopes: " << getPrintScopes() << ", "

348 << "Sizes: " << getPrintSizes() << ", "

349 << "Summary: " << getPrintSummary() << ", "

350 << "Symbols: " << getPrintSymbols() << "\n"

351 << "Types: " << getPrintTypes() << ", "

352 << "Warnings: " << getPrintWarnings() << "\n";

353 OS << "AnyElemeny: " << getPrintAnyElement() << ", "

354 << "AnyLine: " << getPrintAnyLine() << ", "

355 << "Execute: " << getPrintExecute() << ", "

356 << "Formatting: " << getPrintFormatting() << "\n"

357 << "Offset: " << getPrintOffset() << ", "

358 << "SizesSummary: " << getPrintSizesSummary() << "\n"

359 << "\n";

360

361

362 OS << "** Report **\n"

363 << "All: " << getReportAll() << ", "

364 << "Children: " << getReportChildren() << ", "

365 << "List: " << getReportList() << ", "

366 << "Parents: " << getReportParents() << ", "

367 << "View: " << getReportView() << "\n";

368 OS << "AnyView: " << getReportAnyView() << ", "

369 << "Execute: " << getReportExecute() << "\n"

370 << "\n";

371

372

373 OS << "** Select **\n"

374 << "IgnoreCase: " << getSelectIgnoreCase() << ", "

375 << "UseRegex: " << getSelectUseRegex() << ", "

376 << "Execute: " << getSelectExecute() << ", "

377 << "GenericKind: " << getSelectGenericKind() << "\n"

378 << "GenericPattern: " << getSelectGenericPattern() << ", "

379 << "OffsetPattern: " << getSelectOffsetPattern() << "\n"

380 << "\n";

381

382

383 OS << "** Warning **\n"

384 << "All: " << getWarningAll() << ", "

385 << "Coverage: " << getWarningCoverages() << ", "

386 << "Lines: " << getWarningLines() << ", "

387 << "Locations: " << getWarningLocations() << ", "

388 << "Ranges: " << getWarningRanges() << "\n"

389 << "\n";

390

391

392 OS << "** Internal **\n"

393 << "All: " << Options.getInternalAll() << ", "

394 << "Cmdline: " << Options.getInternalCmdline() << ", "

395 << "ID: " << Options.getInternalID() << ", "

396 << "Integrity: " << Options.getInternalIntegrity() << ", "

397 << "None: " << Options.getInternalNone() << "\n"

398 << "Tag: " << Options.getInternalTag() << "\n"

399 << "\n";

400}

401

402

403

404

407 return &Patterns;

408}

409

411 bool IgnoreCase, bool UseRegex) {

412 LVMatch Match;

413

414 if (UseRegex) {

415 Match.Pattern = std::string(Pattern);

419 std::string Error;

420 if (!Match.RE->isValid(Error))

422 "Error in regular expression: %s",

424

425 Match.Mode = LVMatchMode::Regex;

426 Filters.push_back(Match);

428 }

429 }

430

431

432 Match.Pattern = std::string(Pattern);

433 if (Match.Pattern.size()) {

434 Match.Mode = IgnoreCase ? LVMatchMode::NoCase : LVMatchMode::Match;

435 Filters.push_back(Match);

436 }

437

439}

440

443 if (GenericMatchInfo.size()) {

444 options().setSelectGenericPattern();

445 options().setSelectExecute();

446 }

447}

448

451 if (OffsetMatchInfo.size()) {

452 options().setSelectOffsetPattern();

453 options().setSelectExecute();

454 }

455}

456

458 bool IgnoreCase = options().getSelectIgnoreCase();

459 bool UseRegex = options().getSelectUseRegex();

462 if (Error Err = createMatchEntry(Filters, Pattern, IgnoreCase, UseRegex))

464 }

465

467 dbgs() << "\nPattern Information:\n";

468 for (LVMatch &Match : Filters)

469 dbgs() << "Mode: "

470 << (Match.Mode == LVMatchMode::Match ? "Match" : "Regex")

471 << " Pattern: '" << Match.Pattern << "'\n";

472 });

473}

474

475void LVPatterns::addElement(LVElement *Element) {

476

477 Element->setIsMatched();

478 options().setSelectExecute();

479 if (options().getReportList())

481 if (options().getReportAnyView()) {

483 ? static_cast<LVScope *>(Element)

485

486 if (!Element->getIsScope())

487 Element->setHasPattern();

488 }

489}

490

492 if (ElementRequest.size() || LineRequest.size() || ScopeRequest.size() ||

493 SymbolRequest.size() || TypeRequest.size()) {

494 options().setSelectGenericKind();

495 options().setSelectExecute();

496 }

497

498

499

500 if (options().getSelectExecute() && options().getReportExecute()) {

501 options().setReportExecute();

502 options().setReportList();

503 }

504}

505

506

508 bool Matched = false;

509

510 if (Input.empty())

511 return Matched;

512

513 for (const LVMatch &Match : MatchInfo) {

514 switch (Match.Mode) {

515 case LVMatchMode::Match:

516 Matched = Input == Match.Pattern;

517 break;

518 case LVMatchMode::NoCase:

519 Matched = Input.equals_insensitive(Match.Pattern);

520 break;

521 case LVMatchMode::Regex:

522 Matched = Match.RE->match(Input);

523 break;

524 default:

525 break;

526 }

527

528 if (Matched)

529 return true;

530 }

531 return Matched;

532}

533

535 return (options().getPrintLines() && Line->getIsLineDebug()) ||

536 (options().getPrintInstructions() && Line->getIsLineAssembler());

537}

538

540 if (options().getAttributeAll())

541 return true;

542 bool DoPrint = options().getAttributeAnyLocation();

543

545 DoPrint = options().getAttributeGaps();

546 return DoPrint;

547}

548

550

551

552

553

554

555 return options().getPrintScopes() ||

556 (options().getPrintSymbols() && Scope->getHasSymbols()) ||

557 (options().getPrintAnyLine() && Scope->getHasLines()) ||

558 (options().getPrintTypes() && Scope->getHasTypes()) ||

559 ((options().getPrintSizesSummary() || options().getPrintWarnings()) &&

560 (Scope->getIsRoot() || Scope->getIsCompileUnit()));

561}

562

564

565 if (Symbol->getIsArtificial())

566 return options().getAttributeGenerated() && options().getPrintSymbols();

567 return options().getPrintSymbols();

568}

569

571

572 if (Type->getIsSubrange())

573 return options().getAttributeSubrange() && options().getPrintTypes();

574 return options().getPrintTypes();

575}

576

578 OS << "LVPatterns\n";

580}

static LVOptions Options

Definition LVOptions.cpp:25

The Input class is used to parse a yaml document into in-memory structs and vectors.

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

@ IgnoreCase

Compile for matching that ignores upper/lower case distinctions.

StringMapEntry< EmptyStringSetTag > value_type

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

StringSet - A wrapper for StringMap that provides set-like functionality.

The instances of the Type class are immutable: once they are created, they are never changed.

LVScope * getParentScope() const

static LLVM_ABI void setOptions(LVOptions *Options)

Definition LVOptions.cpp:27

LLVM_ABI void resolveDependencies()

Definition LVOptions.cpp:29

static LLVM_ABI LVOptions * getOptions()

Definition LVOptions.cpp:26

LLVM_ABI void print(raw_ostream &OS) const

Definition LVOptions.cpp:284

void setSortMode(LVSortMode SortMode)

LLVM_ABI void addGenericPatterns(StringSet<> &Patterns)

Definition LVOptions.cpp:441

LLVM_ABI bool matchPattern(StringRef Input, const LVMatchInfo &MatchInfo)

Definition LVOptions.cpp:507

LLVM_ABI bool printObject(const LVLocation *Location) const

Definition LVOptions.cpp:539

LLVM_ABI void print(raw_ostream &OS) const

Definition LVOptions.cpp:577

LLVM_ABI bool printElement(const LVLine *Line) const

Definition LVOptions.cpp:534

LLVM_ABI void addPatterns(StringSet<> &Patterns, LVMatchInfo &Filters)

Definition LVOptions.cpp:457

LLVM_ABI void updateReportOptions()

Definition LVOptions.cpp:491

LLVM_ABI void addOffsetPatterns(const LVOffsetSet &Patterns)

Definition LVOptions.cpp:449

static LLVM_ABI LVPatterns * getPatterns()

Definition LVOptions.cpp:405

void addMatched(LVElement *Element)

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

LVScopeCompileUnit * getReaderCompileUnit()

std::string hexSquareString(uint64_t Value)

std::set< uint64_t > LVOffsetSet

This is an optimization pass for GlobalISel generic memory operations.

void append_range(Container &C, Range &&R)

Wrapper function to append range R to container C.

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

Create formatted StringError object.

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

void consumeError(Error Err)

Consume a Error without doing anything.