[PATCH] D37334: [llvm-dwarfdump] Brief mode only dumps debug_info by default

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 31 09:24:14 PDT 2017


On Thu, Aug 31, 2017 at 7:32 AM Jonas Devlieghere via Phabricator <
reviews at reviews.llvm.org> wrote:

> JDevlieghere created this revision.
>
> This patch changes the default behavior in brief mode to only show the
> debug_info section. This is undoubtedly the most popular and likely the
> one you'd want in brief mode.
>
> Non-brief mode behavior is not affected and still defaults to all.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D37334
>
> Files:
>   test/tools/llvm-dwarfdump/X86/brief.s
>   tools/llvm-dwarfdump/llvm-dwarfdump.cpp
>
>
> Index: tools/llvm-dwarfdump/llvm-dwarfdump.cpp
> ===================================================================
> --- tools/llvm-dwarfdump/llvm-dwarfdump.cpp
> +++ tools/llvm-dwarfdump/llvm-dwarfdump.cpp
> @@ -41,7 +41,7 @@
>                 cl::ZeroOrMore);
>
>  static cl::opt<DIDumpType> DumpType(
> -    "debug-dump", cl::init(DIDT_All), cl::desc("Dump of debug sections:"),
> +    "debug-dump", cl::init(DIDT_Null), cl::desc("Dump of debug
> sections:"),
>      cl::values(
>          clEnumValN(DIDT_All, "all", "Dump all debug sections"),
>          clEnumValN(DIDT_Abbrev, "abbrev", ".debug_abbrev"),
> @@ -154,12 +154,12 @@
>    MemoryBuffer::getFileOrSTDIN(Filename);
>    error(Filename, BuffOrErr.getError());
>    std::unique_ptr<MemoryBuffer> Buff = std::move(BuffOrErr.get());
> -
> +
>    Expected<std::unique_ptr<Binary>> BinOrErr =
>    object::createBinary(Buff->getMemBufferRef());
>    if (!BinOrErr)
>      error(Filename, errorToErrorCode(BinOrErr.takeError()));
> -
> +
>    bool Result = true;
>    if (auto *Obj = dyn_cast<ObjectFile>(BinOrErr->get()))
>      Result = VerifyObjectFile(*Obj, Filename);
> @@ -217,6 +217,15 @@
>
>    cl::ParseCommandLineOptions(argc, argv, "llvm dwarf dumper\n");
>
> +  // Defaults to dumping all sections, unless brief mode is specified in
> which
> +  // case only the .debug_info section in dumped.
> +  if (DumpType == DIDT_Null) {
> +    if (Brief)
> +      DumpType = DIDT_Info;
> +    else
> +      DumpType = DIDT_All;
> +  }
> +
>    // Defaults to a.out if no filenames specified.
>    if (InputFilenames.size() == 0)
>      InputFilenames.push_back("a.out");
> Index: test/tools/llvm-dwarfdump/X86/brief.s
> ===================================================================
> --- test/tools/llvm-dwarfdump/X86/brief.s
> +++ test/tools/llvm-dwarfdump/X86/brief.s
> @@ -2,12 +2,39 @@
>  # RUN: | llvm-dwarfdump -debug-dump=info -brief - \
>  # RUN: | FileCheck %s
>
> +# CHECK-NOT: .debug_abbrev contents
> +#
> +# CHECK: .debug_info contents
>  # CHECK: DW_TAG_compile_unit
>  # CHECK-NOT: DW_FORM
> -# CHECK: DW_AT
> +# CHECK: DW_AT_name        ("brief.c")
> +# CHECK: DW_AT_name      ("main")
> +# CHECK: DW_AT_name      ("int")
>  # CHECK-NOT: debug_str
>  # CHECK-NOT: DW_AT_type {{.*}} =>
> -
> +#
> +# CHECK-NOT: .debug_abbrev.dwo contents
> +# CHECK-NOT: .debug_abbrev.dwo contents
> +# CHECK-NOT: .debug_loc contents:
> +# CHECK-NOT: .debug_loc.dwo contents:
> +# CHECK-NOT: .debug_frame contents:
> +# CHECK-NOT: .debug_macinfo contents:
> +# CHECK-NOT: .debug_aranges contents:
> +# CHECK-NOT: .debug_line contents:
> +# CHECK-NOT: .debug_cu_index contents:
> +# CHECK-NOT: .debug_tu_index contents:
> +# CHECK-NOT: .debug_line.dwo contents:
> +# CHECK-NOT: .debug_str contents:
> +# CHECK-NOT: .debug_ranges contents:
> +# CHECK-NOT: .debug_pubnames contents:
> +# CHECK-NOT: .debug_pubtypes contents:
> +# CHECK-NOT: .debug_gnu_pubnames contents:
> +# CHECK-NOT: .debug_gnu_pubtypes contents:
> +# CHECK-NOT: .apple_names contents:
> +# CHECK-NOT: .apple_types contents:
> +# CHECK-NOT: .apple_namespaces contents:
> +# CHECK-NOT: .apple_objc contents:
>

Maybe this ^ should just be a single "CHECK-NOT: contents:" ?


> +#
>  # This test is meant to verify that -brief hides DW_FORMs and abbreviation
>  # codes from .debug_info section. Furthermore it verifies that it also
> hides
>  # .debug_str and die reference offsets into the CU.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170831/408e37d9/attachment.html>


More information about the llvm-commits mailing list