This is an archive of the discontinued LLVM Phabricator instance.

[llvm-dwarfdump][test] Add missing dedicated tests for some options
ClosedPublic

Authored by gbreynoo on May 27 2021, 7:22 AM.

Details

Summary

This change adds tests specifically for --parent-recurse-depth, --quiet and -o. The test for -o found a typo in an error message which is also fixed in this change.

Diff Detail

Event Timeline

gbreynoo created this revision.May 27 2021, 7:22 AM
gbreynoo requested review of this revision.May 27 2021, 7:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2021, 7:22 AM
Higuoxing added inline comments.May 27 2021, 8:10 PM
llvm/test/tools/llvm-dwarfdump/X86/output.s
5

It looks that you have some typos in this test file which are causing testing failures.

8

Ditto.

12

Ditto.

llvm/test/tools/llvm-dwarfdump/X86/parent_recurse_depth.s
23

I think the following yaml code is more readable than raw assembly code. What do you think?

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_EXEC
  Machine: EM_X86_64
DWARF:
  debug_abbrev:
    - Table:
      - Tag:      DW_TAG_compile_unit
        Children: DW_CHILDREN_yes
        Attributes:
          - Attribute: DW_AT_producer
            Form:      DW_FORM_string
      - Tag:      DW_TAG_subprogram
        Children: DW_CHILDREN_yes
        Attributes:
          - Attribute: DW_AT_name
            Form:      DW_FORM_string
      - Tag:      DW_TAG_namespace
        Children: DW_CHILDREN_yes
        Attributes:
          - Attribute: DW_AT_name
            Form:      DW_FORM_string
      - Tag:      DW_TAG_base_type
        Children: DW_CHILDREN_no
        Attributes:
          - Attribute: DW_AT_name
            Form:      DW_FORM_string
  debug_info:
    - Version: 4
      Entries:
        - AbbrCode: 1
          Values:
            - CStr: by_hand
        - AbbrCode: 2
          Values:
            - CStr: main
        - AbbrCode: 3
          Values:
            - CStr: test
        - AbbrCode: 4
          Values:
            - CStr: int
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
638

I think it might be good to surround file names with single quotes '. e.g.

Unable to open output file '/path/to/file': permission denied
jhenderson added inline comments.May 28 2021, 12:26 AM
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
638

Whilst you're changing this message, I'd also change Unable to unable, in line with the LLVM error message style policy.

gbreynoo updated this revision to Diff 348529.May 28 2021, 8:07 AM

Changed parent_recurse_depth.s to use yaml rather than assembly, fixed typo of FileCheck and fixed the error message.

gbreynoo marked 4 inline comments as done.May 28 2021, 8:15 AM
gbreynoo added inline comments.
llvm/test/tools/llvm-dwarfdump/X86/parent_recurse_depth.s
23

Much better thanks.

llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
638

I'd have to check if OutputFilename is empty or an error like unable to open output file '': no such file or directory can be output which looks strange IMHO . Would it better to leave it as is?

gbreynoo marked an inline comment as done.May 28 2021, 8:20 AM
Higuoxing added inline comments.May 29 2021, 8:42 PM
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
638

Sounds reasonable to me. Thanks!

gbreynoo updated this revision to Diff 348915.Jun 1 2021, 2:43 AM

Fix the testing of error output that has of OS specific capitalization.

Higuoxing accepted this revision.Jun 1 2021, 4:21 AM

LGTM. Thanks!

This revision is now accepted and ready to land.Jun 1 2021, 4:21 AM
thopre added a subscriber: thopre.Jun 4 2021, 1:52 AM

Hi,

The test is a bit fragile as it fails if "main" is somewhere in the path of the object file created, which is likely with the development branch being called main (I personally use 1 git worktree per branch) or with the use of the term "mainline". How about the following change to consume the file name?

diff --git a/llvm/test/tools/llvm-dwarfdump/X86/parent_recurse_depth.s b/llvm/test/tools/llvm-dwarfdump/X86/parent_recurse_depth.s
index 2d573344191c..a63a918a865d 100644

  • a/llvm/test/tools/llvm-dwarfdump/X86/parent_recurse_depth.s

+++ b/llvm/test/tools/llvm-dwarfdump/X86/parent_recurse_depth.s
@@ -1,8 +1,10 @@

  1. RUN: yaml2obj %s -o %t.o
  2. RUN: llvm-dwarfdump --debug-info=0x00000020 -p -parent-recurse-depth 0 %t.o | FileCheck %s --check-prefix=ALL
  3. RUN: llvm-dwarfdump --debug-info=0x00000020 -p -parent-recurse-depth 1 %t.o | FileCheck %s --check-prefix=ONE
  4. RUN: llvm-dwarfdump --debug-info=0x00000020 -p -parent-recurse-depth 2 %t.o | FileCheck %s --check-prefix=TWO
  5. RUN: llvm-dwarfdump --debug-info=0x00000020 -p -parent-recurse-depth 3 %t.o | FileCheck %s --check-prefix=ALL

+# RUN: llvm-dwarfdump --debug-info=0x00000020 -p -parent-recurse-depth 0 %t.o | FileCheck %s --check-prefixes=COMMON,ALL^M
+# RUN: llvm-dwarfdump --debug-info=0x00000020 -p -parent-recurse-depth 1 %t.o | FileCheck %s --check-prefixes=COMMON,ONE^M
+# RUN: llvm-dwarfdump --debug-info=0x00000020 -p -parent-recurse-depth 2 %t.o | FileCheck %s --check-prefixes=COMMON,TWO^M
+# RUN: llvm-dwarfdump --debug-info=0x00000020 -p -parent-recurse-depth 3 %t.o | FileCheck %s --check-prefixes=COMMON,ALL^M
+^M
+# COMMON: .o: file format^M

Thanks thopre, good catch.