[PATCH] D84817: Add verification for DW_AT_decl_file and DW_AT_call_file.

Xing GUO via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 29 06:57:37 PDT 2020


Higuoxing added inline comments.


================
Comment at: llvm/test/tools/llvm-dwarfdump/X86/verify_attr_file_indexes.yaml:20
+# CHECK:      Errors detected.
+--- !mach-o
+FileHeader:
----------------
jhenderson wrote:
> Rather than using mach-o, which has a lot of noise in its YAML, it might be worth switching to ELF. I think yaml2obj's ELF support is more-or-less sufficient now to achieve the desired goal. I think all you'd need to do is to use an ELF file header (you can find some simple examples in the yaml2obj tests), but keep the DWARF block the same.
> 
> There are probably ways to reduce the DWARF bit of the YAML too. @Higuoxing is actively working on improving this, so might be able to offer some tips, but I don't know how much could be done there yet.
Yes, this YAML file is able to be reduced by replacing the Mach-O header with ELF header. I've tested it.

```
--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_EXEC
  Machine: EM_X86_64
DWARF:
  debug_str:
    - ''
    - '/tmp/main.c'
    - main
    - inline1
  debug_abbrev:
    - Code:            0x0000000000000001
      Tag:             DW_TAG_compile_unit
      Children:        DW_CHILDREN_yes
      Attributes:
        - Attribute:       DW_AT_name
          Form:            DW_FORM_strp
        - Attribute:       DW_AT_language
          Form:            DW_FORM_data2
        - Attribute:       DW_AT_low_pc
          Form:            DW_FORM_addr
        - Attribute:       DW_AT_stmt_list
          Form:            DW_FORM_sec_offset
    - Code:            0x0000000000000002
      Tag:             DW_TAG_subprogram
      Children:        DW_CHILDREN_yes
      Attributes:
        - Attribute:       DW_AT_name
          Form:            DW_FORM_strp
        - Attribute:       DW_AT_low_pc
          Form:            DW_FORM_addr
        - Attribute:       DW_AT_high_pc
          Form:            DW_FORM_addr
        - Attribute:       DW_AT_decl_file
          Form:            DW_FORM_data1
        - Attribute:       DW_AT_call_line
          Form:            DW_FORM_data1
    - Code:            0x0000000000000003
      Tag:             DW_TAG_inlined_subroutine
      Children:        DW_CHILDREN_no
      Attributes:
        - Attribute:       DW_AT_name
          Form:            DW_FORM_strp
        - Attribute:       DW_AT_low_pc
          Form:            DW_FORM_addr
        - Attribute:       DW_AT_high_pc
          Form:            DW_FORM_data4
        - Attribute:       DW_AT_call_file
          Form:            DW_FORM_data1
        - Attribute:       DW_AT_call_line
          Form:            DW_FORM_data1
  debug_info:
    - Length:          0x0000000000000046
      Version:         4
      AbbrOffset:      0x0000000000000000
      AddrSize:        8
      Entries:
        - AbbrCode:        0x00000001
          Values:
            - Value:           0x0000000000000001
            - Value:           0x0000000000000002
            - Value:           0x0000000000000000
            - Value:           0x0000000000000000
        - AbbrCode:        0x00000002
          Values:
            - Value:           0x000000000000000D
            - Value:           0x0000000000001000
            - Value:           0x0000000000002000
            - Value:           0x0000000000000002
            - Value:           0x0000000000000005
        - AbbrCode:        0x00000003
          Values:
            - Value:           0x0000000000000012
            - Value:           0x0000000000001100
            - Value:           0x0000000000000100
            - Value:           0x0000000000000003
            - Value:           0x000000000000000A
        - AbbrCode:        0x00000000
          Values:          []
        - AbbrCode:        0x00000000
          Values:          []
  debug_line:
    - Length:          40
      Version:         2
      PrologueLength:  34
      MinInstLength:   1
      DefaultIsStmt:   1
      LineBase:        251
      LineRange:       14
      OpcodeBase:      13
      StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
      IncludeDirs:
        - '/tmp'
      Files:
        - Name:            main.c
          DirIdx:          1
          ModTime:         0
          Length:          0
      Opcodes:         []
```

> There are probably ways to reduce the DWARF bit of the YAML too.

I would like not to reduce the DWARF for now since most of the fields are required.


================
Comment at: llvm/test/tools/llvm-dwarfdump/X86/verify_file_encoding.yaml:18
+
+--- !mach-o
+FileHeader:
----------------
jhenderson wrote:
> Same comments as other test.
We can use ELF YAML for this test as well.

```
--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_EXEC
  Machine: EM_X86_64
DWARF:
  debug_str:
    - ''
    - '/tmp/main.c'
    - main
    - ''
    - inline1
  debug_abbrev:
    - Code:            0x0000000000000001
      Tag:             DW_TAG_compile_unit
      Children:        DW_CHILDREN_yes
      Attributes:
        - Attribute:       DW_AT_name
          Form:            DW_FORM_strp
        - Attribute:       DW_AT_language
          Form:            DW_FORM_data2
        - Attribute:       DW_AT_low_pc
          Form:            DW_FORM_addr
    - Code:            0x0000000000000002
      Tag:             DW_TAG_subprogram
      Children:        DW_CHILDREN_yes
      Attributes:
        - Attribute:       DW_AT_name
          Form:            DW_FORM_strp
        - Attribute:       DW_AT_low_pc
          Form:            DW_FORM_addr
        - Attribute:       DW_AT_high_pc
          Form:            DW_FORM_addr
        - Attribute:       DW_AT_decl_file
          Form:            DW_FORM_strp
        - Attribute:       DW_AT_call_line
          Form:            DW_FORM_data1
    - Code:            0x0000000000000003
      Tag:             DW_TAG_inlined_subroutine
      Children:        DW_CHILDREN_no
      Attributes:
        - Attribute:       DW_AT_name
          Form:            DW_FORM_strp
        - Attribute:       DW_AT_low_pc
          Form:            DW_FORM_addr
        - Attribute:       DW_AT_high_pc
          Form:            DW_FORM_data4
        - Attribute:       DW_AT_call_file
          Form:            DW_FORM_strp
        - Attribute:       DW_AT_call_line
          Form:            DW_FORM_data1
  debug_info:
    - Length:          0x0000000000000048
      Version:         4
      AbbrOffset:      0x0000000000000000
      AddrSize:        8
      Entries:
        - AbbrCode:        0x00000001
          Values:
            - Value:           0x0000000000000001
            - Value:           0x0000000000000002
            - Value:           0x0000000000000000
        - AbbrCode:        0x00000002
          Values:
            - Value:           0x000000000000000D
            - Value:           0x0000000000001000
            - Value:           0x0000000000002000
            - Value:           0x0000000000000012
            - Value:           0x0000000000000005
        - AbbrCode:        0x00000003
          Values:
            - Value:           0x0000000000000013
            - Value:           0x0000000000001100
            - Value:           0x0000000000000100
            - Value:           0x0000000000000012
            - Value:           0x000000000000000A
        - AbbrCode:        0x00000000
          Values:          []
        - AbbrCode:        0x00000000
          Values:          []

```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84817/new/

https://reviews.llvm.org/D84817



More information about the llvm-commits mailing list