1## Show that llvm-dwarfdump prints a range of different structures in the
2## .debug_abbrev section when requested. As well as basic cases, this test also
3## shows how llvm-dwarfdump handles unknown tag, attribute and form values.
4
5# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o %t.o
6# RUN: llvm-dwarfdump --debug-abbrev %t.o | FileCheck %s --match-full-lines
7
8# CHECK:      .debug_abbrev contents:
9# CHECK-NEXT: Abbrev table for offset: 0x00000000
10# CHECK-NEXT: [66] DW_TAG_compile_unit        DW_CHILDREN_yes
11# CHECK-NEXT:         DW_AT_name      DW_FORM_string
12# CHECK-NEXT:         DW_AT_stmt_list DW_FORM_data2
13# CHECK-EMPTY:
14# CHECK-NEXT: [128] DW_TAG_unknown_ffff       DW_CHILDREN_no
15# CHECK-NEXT:         DW_AT_unknown_5 DW_FORM_unknown_2
16# CHECK-EMPTY:
17# CHECK-NEXT: [66] DW_TAG_unknown_4080        DW_CHILDREN_no
18# CHECK-EMPTY:
19# CHECK-NEXT: [1] DW_TAG_unknown_4000 DW_CHILDREN_no
20# CHECK-NEXT:         DW_AT_unknown_2000      DW_FORM_unknown_ffff
21# CHECK-NEXT:         DW_AT_unknown_3fff      DW_FORM_unknown_7f
22# CHECK-NEXT:         DW_AT_unknown_1fff      DW_FORM_block2
23# CHECK-NEXT:         DW_AT_unknown_4000      DW_FORM_block4
24# CHECK-EMPTY:
25# CHECK-NEXT: [2] DW_TAG_unknown_407f DW_CHILDREN_no
26# CHECK-EMPTY:
27# CHECK-NEXT: Abbrev table for offset: 0x00000038
28# CHECK-NEXT: [66] DW_TAG_entry_point DW_CHILDREN_no
29# CHECK-NEXT:         DW_AT_elemental DW_FORM_flag_present
30
31## All values in this assembly are intended to be arbitrary, except where
32## specified.
33.section .debug_abbrev,"",@progbits
34    .byte 0x42 ## Abbreviation Code
35    ## Known tag with children and known attributes and forms.
36    .byte 0x11 ## DW_TAG_compile_unit
37    .byte 0x01 ## DW_CHILDREN_yes
38        .byte 0x03 ## DW_AT_name
39        .byte 0x08 ## DW_FORM_string (valid form for DW_AT_name).
40        .byte 0x10 ## DW_AT_stmt_list
41        .byte 0x05 ## DW_FORM_data2 (invalid form for DW_AT_stmt_list).
42        .byte 0, 0 ## End of attributes
43
44    ## Tag without children and reserved form/attribute values.
45    .byte 0x80, 0x01       ## Multi-byte Abbreviation Code
46    .byte 0xFF, 0xFF, 0x03 ## 0xFFFF == DW_TAG_hi_user
47    .byte 0x00             ## DW_CHILDREN_no
48        ## Reserved attribute and form.
49        .byte 0x05 ## Reserved DW_AT_*
50        .byte 0x02 ## Reserved DW_FORM_*
51        .byte 0, 0 ## End of attributes.
52
53    ## Tag with no attributes.
54    .byte 0x42             ## Abbreviation Code (duplicate)
55    .byte 0x80, 0x81, 0x01 ## 0x4080 == DW_TAG_lo_user
56    .byte 0x00             ## DW_CHILDREN_no
57        .byte 0, 0         ## End of attributes.
58
59    ## Tag with attributes/forms with unknown values/values in user-defined ranges.
60    .byte 0x01                 ## Abbreviation Code
61    ## FIXME: https://bugs.llvm.org/show_bug.cgi?id=44258 means that 0x80, 0x80, 0x04
62    ## results in a failure to parse correctly, whilst the following tag value is
63    ## interpreted incorrectly as 0x4000.
64    .byte 0x80, 0x80, 0x05     ## 0x10001 == DW_TAG_hi_user + 2
65    .byte 0x00                 ## DW_CHILDREN_no
66        .byte 0x80, 0x40       ## 0x2000 == DW_AT_lo_user
67        .byte 0xFF, 0xFF, 0x03 ## 0xFFFF == Unknown multi-byte form.
68        .byte 0xFF, 0x7F       ## DW_AT_hi_user
69        .byte 0x7F             ## Unknown single-byte form.
70        .byte 0xFF, 0x3F       ## DW_AT_lo_user - 1
71        .byte 0x03             ## DW_FORM_block2
72        .byte 0x80, 0x80, 0x01 ## DW_AT_hi_user + 1
73        .byte 0x04             ## DW_FORM_block4
74        .byte 0, 0             ## End of attributes.
75
76    ## Tag with invalid children encoding.
77    .byte 0x02             ## Abbreviation Code
78    .byte 0xFF, 0x80, 0x01 ## 0x407F == DW_TAG_lo_user - 1
79    .byte 0x02 ## Invalid children encoding (interpreted as DW_CHILDREN_no).
80        .byte 0, 0         ## End of attributes.
81
82    .byte 0 ## End of abbrevs.
83
84    ## Second .debug_abbrev set.
85    .byte 0x42 ## Abbreviation Code (duplicate in different unit)
86    .byte 0x03 ## DW_TAG_entry_point
87    .byte 0x00 ## DW_CHILDREN_no
88        .byte 0x66 ## DW_AT_elemental
89        .byte 0x19 ## DW_FORM_flag_present
90        .byte 0, 0 ## End of attributes.
91