llvm.org GIT mirror llvm / b5b768d
dwarfdump: Add support for the --diff option. --diff Emit the output in a diff-friendly way by omitting offsets and addresses. <rdar://problem/34502625> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320214 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 1 year, 9 months ago
7 changed file(s) with 47 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
3333 Show a debug info entry's children when using
3434 the :option:`--debug-info`, :option:`--find`,
3535 and :option:`--name` options.
36
37 .. option:: --diff
38
39 Emit the output in a diff-friendly way by omitting offsets and
40 addresses.
3641
3742 .. option:: -f , --find=
3843
152152 struct DIDumpOptions {
153153 unsigned DumpType = DIDT_All;
154154 unsigned RecurseDepth = -1U;
155 bool ShowAddresses = true;
155156 bool ShowChildren = false;
156157 bool ShowParents = false;
157158 bool ShowForm = false;
235235 OS << *formValue.getAsUnsignedConstant();
236236 else if (Attr == DW_AT_high_pc && !DumpOpts.ShowForm && !DumpOpts.Verbose &&
237237 formValue.getAsUnsignedConstant()) {
238 // Print the actual address rather than the offset.
239 uint64_t LowPC, HighPC, Index;
240 if (Die.getLowAndHighPC(LowPC, HighPC, Index))
241 OS << format("0x%016" PRIx64, HighPC);
242 else
243 formValue.dump(OS, DumpOpts);
238 if (DumpOpts.ShowAddresses) {
239 // Print the actual address rather than the offset.
240 uint64_t LowPC, HighPC, Index;
241 if (Die.getLowAndHighPC(LowPC, HighPC, Index))
242 OS << format("0x%016" PRIx64, HighPC);
243 else
244 formValue.dump(OS, DumpOpts);
245 }
244246 } else if (Attr == DW_AT_location || Attr == DW_AT_frame_base ||
245247 Attr == DW_AT_data_member_location ||
246248 Attr == DW_AT_GNU_call_site_value)
457459
458460 if (debug_info_data.isValidOffset(offset)) {
459461 uint32_t abbrCode = debug_info_data.getULEB128(&offset);
460 WithColor(OS, syntax::Address).get() << format("\n0x%8.8x: ", Offset);
462 if (DumpOpts.ShowAddresses)
463 WithColor(OS, syntax::Address).get() << format("\n0x%8.8x: ", Offset);
461464
462465 if (abbrCode) {
463466 auto AbbrevDecl = getAbbreviationDeclarationPtr();
395395 void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
396396 uint64_t UValue = Value.uval;
397397 bool CURelativeOffset = false;
398
398 raw_ostream &AddrOS =
399 DumpOpts.ShowAddresses ? WithColor(OS, syntax::Address).get() : nulls();
399400 switch (Form) {
400401 case DW_FORM_addr:
401 OS << format("0x%016" PRIx64, UValue);
402 AddrOS << format("0x%016" PRIx64, UValue);
402403 break;
403404 case DW_FORM_GNU_addr_index: {
404 OS << format(" indexed (%8.8x) address = ", (uint32_t)UValue);
405 AddrOS << format(" indexed (%8.8x) address = ", (uint32_t)UValue);
405406 uint64_t Address;
406407 if (U == nullptr)
407408 OS << "";
408409 else if (U->getAddrOffsetSectionItem(UValue, Address))
409 OS << format("0x%016" PRIx64, Address);
410 AddrOS << format("0x%016" PRIx64, Address);
410411 else
411412 OS << "";
412413 break;
425426 OS << format("0x%08x", (uint32_t)UValue);
426427 break;
427428 case DW_FORM_ref_sig8:
429 AddrOS << format("0x%016" PRIx64, UValue);
430 break;
428431 case DW_FORM_data8:
429432 OS << format("0x%016" PRIx64, UValue);
430433 break;
487490 case DW_FORM_strx3:
488491 case DW_FORM_strx4:
489492 case DW_FORM_GNU_str_index:
490 OS << format(" indexed (%8.8x) string = ", (uint32_t)UValue);
493 if (DumpOpts.Verbose)
494 OS << format(" indexed (%8.8x) string = ", (uint32_t)UValue);
491495 dumpString(OS);
492496 break;
493497 case DW_FORM_GNU_strp_alt:
494 OS << format("alt indirect string, offset: 0x%" PRIx64 "", UValue);
498 if (DumpOpts.Verbose)
499 OS << format("alt indirect string, offset: 0x%" PRIx64 "", UValue);
495500 dumpString(OS);
496501 break;
497502 case DW_FORM_ref_addr:
498 OS << format("0x%016" PRIx64, UValue);
503 AddrOS << format("0x%016" PRIx64, UValue);
499504 break;
500505 case DW_FORM_ref1:
501506 CURelativeOffset = true;
502 OS << format("cu + 0x%2.2x", (uint8_t)UValue);
507 AddrOS << format("cu + 0x%2.2x", (uint8_t)UValue);
503508 break;
504509 case DW_FORM_ref2:
505510 CURelativeOffset = true;
506 OS << format("cu + 0x%4.4x", (uint16_t)UValue);
511 AddrOS << format("cu + 0x%4.4x", (uint16_t)UValue);
507512 break;
508513 case DW_FORM_ref4:
509514 CURelativeOffset = true;
510 OS << format("cu + 0x%4.4x", (uint32_t)UValue);
515 AddrOS << format("cu + 0x%4.4x", (uint32_t)UValue);
511516 break;
512517 case DW_FORM_ref8:
513518 CURelativeOffset = true;
514 OS << format("cu + 0x%8.8" PRIx64, UValue);
519 AddrOS << format("cu + 0x%8.8" PRIx64, UValue);
515520 break;
516521 case DW_FORM_ref_udata:
517522 CURelativeOffset = true;
518 OS << format("cu + 0x%" PRIx64, UValue);
523 AddrOS << format("cu + 0x%" PRIx64, UValue);
519524 break;
520525 case DW_FORM_GNU_ref_alt:
521 OS << format("", UValue);
526 AddrOS << format("", UValue);
522527 break;
523528
524529 // All DW_FORM_indirect attributes should be resolved prior to calling
529534
530535 // Should be formatted to 64-bit for DWARF64.
531536 case DW_FORM_sec_offset:
532 OS << format("0x%08x", (uint32_t)UValue);
537 AddrOS << format("0x%08x", (uint32_t)UValue);
533538 break;
534539
535540 default:
0 RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
1 RUN: | llvm-dwarfdump -diff - | FileCheck %s
2 CHECK: {{^DW_TAG_compile_unit}}
3 CHECK: DW_AT_stmt_list ()
4 CHECK: DW_AT_low_pc ()
5 CHECK: DW_AT_high_pc ()
55 HELP: -debug-info - Dump the .debug_info section
66 HELP: -eh-frame
77 HELP: Specific Options
8 HELP: -diff
89 HELP: -find
910 HELP: -ignore-case
1011 HELP: -lookup
135135 "name or by number. This option can be specified "
136136 "multiple times, once for each desired architecture."),
137137 cat(DwarfDumpCategory));
138 static opt
139 Diff("diff",
140 desc("Emit diff-friendly output by omitting offsets and addresses."),
141 cat(DwarfDumpCategory));
138142 static list
139143 Find("find",
140144 desc("Search for the exact match for in the accelerator tables "
236240 DIDumpOptions DumpOpts;
237241 DumpOpts.DumpType = DumpType;
238242 DumpOpts.RecurseDepth = RecurseDepth;
243 DumpOpts.ShowAddresses = !Diff;
239244 DumpOpts.ShowChildren = ShowChildren;
240245 DumpOpts.ShowParents = ShowParents;
241246 DumpOpts.ShowForm = ShowForm;