xref: /llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_location-DW_AT_const_value.s (revision 8a64d80a959bf2844df33f9112e456f33de7b468)
1## Test that we don't get confused by variables with both location and
2## const_value attributes. Such values are produced in C++ for class-level
3## static constexpr variables.
4
5# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t
6# RUN: %lldb %t -o "target variable A::x A::y" -o exit | FileCheck %s
7
8# CHECK-LABEL: target variable
9# CHECK: (const int) A::x = 142
10# CHECK: (const int) A::y = 242
11
12        .section        .rodata,"a",@progbits
13        .p2align        2
14_ZN1A1xE:
15        .long   142
16_ZN1A1yE:
17        .long   242
18
19        .section        .debug_abbrev,"",@progbits
20        .byte   1                               # Abbreviation Code
21        .byte   17                              # DW_TAG_compile_unit
22        .byte   1                               # DW_CHILDREN_yes
23        .byte   37                              # DW_AT_producer
24        .byte   8                               # DW_FORM_string
25        .byte   3                               # DW_AT_name
26        .byte   8                               # DW_FORM_string
27        .byte   0                               # EOM(1)
28        .byte   0                               # EOM(2)
29        .byte   3                               # Abbreviation Code
30        .byte   19                              # DW_TAG_structure_type
31        .byte   1                               # DW_CHILDREN_yes
32        .byte   3                               # DW_AT_name
33        .byte   8                               # DW_FORM_string
34        .byte   11                              # DW_AT_byte_size
35        .byte   11                              # DW_FORM_data1
36        .byte   0                               # EOM(1)
37        .byte   0                               # EOM(2)
38        .byte   4                               # Abbreviation Code
39        .byte   13                              # DW_TAG_member
40        .byte   0                               # DW_CHILDREN_no
41        .byte   3                               # DW_AT_name
42        .byte   8                               # DW_FORM_string
43        .byte   73                              # DW_AT_type
44        .byte   19                              # DW_FORM_ref4
45        .byte   60                              # DW_AT_declaration
46        .byte   25                              # DW_FORM_flag_present
47        .byte   28                              # DW_AT_const_value
48        .byte   13                              # DW_FORM_sdata
49        .byte   0                               # EOM(1)
50        .byte   0                               # EOM(2)
51        .byte   5                               # Abbreviation Code
52        .byte   38                              # DW_TAG_const_type
53        .byte   0                               # DW_CHILDREN_no
54        .byte   73                              # DW_AT_type
55        .byte   19                              # DW_FORM_ref4
56        .byte   0                               # EOM(1)
57        .byte   0                               # EOM(2)
58        .byte   6                               # Abbreviation Code
59        .byte   36                              # DW_TAG_base_type
60        .byte   0                               # DW_CHILDREN_no
61        .byte   3                               # DW_AT_name
62        .byte   8                               # DW_FORM_string
63        .byte   62                              # DW_AT_encoding
64        .byte   11                              # DW_FORM_data1
65        .byte   11                              # DW_AT_byte_size
66        .byte   11                              # DW_FORM_data1
67        .byte   0                               # EOM(1)
68        .byte   0                               # EOM(2)
69        .byte   7                               # Abbreviation Code
70        .byte   52                              # DW_TAG_variable
71        .byte   0                               # DW_CHILDREN_no
72        .byte   71                              # DW_AT_specification
73        .byte   19                              # DW_FORM_ref4
74        .byte   2                               # DW_AT_location
75        .byte   24                              # DW_FORM_exprloc
76        .byte   110                             # DW_AT_linkage_name
77        .byte   8                               # DW_FORM_string
78        .byte   0                               # EOM(1)
79        .byte   0                               # EOM(2)
80## This deliberately inverts the order of the specification and location
81## attributes.
82        .byte   8                               # Abbreviation Code
83        .byte   52                              # DW_TAG_variable
84        .byte   0                               # DW_CHILDREN_no
85        .byte   2                               # DW_AT_location
86        .byte   24                              # DW_FORM_exprloc
87        .byte   71                              # DW_AT_specification
88        .byte   19                              # DW_FORM_ref4
89        .byte   110                             # DW_AT_linkage_name
90        .byte   8                               # DW_FORM_string
91        .byte   0                               # EOM(1)
92        .byte   0                               # EOM(2)
93        .byte   0                               # EOM(3)
94
95        .section        .debug_info,"",@progbits
96.Lcu_begin0:
97        .long   .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
98.Ldebug_info_start0:
99        .short  4                               # DWARF version number
100        .long   .debug_abbrev                   # Offset Into Abbrev. Section
101        .byte   8                               # Address Size (in bytes)
102        .byte   1                               # Abbrev DW_TAG_compile_unit
103        .asciz  "Hand-written DWARF"            # DW_AT_producer
104        .asciz  "a.cc"                          # DW_AT_name
105        .byte   7                               # Abbrev DW_TAG_variable
106        .long   .LA__x-.Lcu_begin0              # DW_AT_specification
107        .byte   9                               # DW_AT_location
108        .byte   3
109        .quad   _ZN1A1xE
110        .asciz  "_ZN1A1xE"                      # DW_AT_linkage_name
111        .byte   8                               # Abbrev DW_TAG_variable
112        .byte   9                               # DW_AT_location
113        .byte   3
114        .quad   _ZN1A1yE
115        .long   .LA__y-.Lcu_begin0              # DW_AT_specification
116        .asciz  "_ZN1A1yE"                      # DW_AT_linkage_name
117        .byte   3                               # Abbrev DW_TAG_structure_type
118        .asciz  "A"                             # DW_AT_name
119        .byte   1                               # DW_AT_byte_size
120.LA__x:
121        .byte   4                               # Abbrev DW_TAG_member
122        .asciz  "x"                             # DW_AT_name
123        .long   .Lconst_int-.Lcu_begin0         # DW_AT_type
124                                                # DW_AT_declaration
125        .sleb128 147                            # DW_AT_const_value
126.LA__y:
127        .byte   4                               # Abbrev DW_TAG_member
128        .asciz  "y"                             # DW_AT_name
129        .long   .Lconst_int-.Lcu_begin0         # DW_AT_type
130                                                # DW_AT_declaration
131        .sleb128 247                            # DW_AT_const_value
132        .byte   0                               # End Of Children Mark
133.Lconst_int:
134        .byte   5                               # Abbrev DW_TAG_const_type
135        .long   .Lint-.Lcu_begin0               # DW_AT_type
136.Lint:
137        .byte   6                               # Abbrev DW_TAG_base_type
138        .asciz  "int"                           # DW_AT_name
139        .byte   5                               # DW_AT_encoding
140        .byte   4                               # DW_AT_byte_size
141        .byte   0                               # End Of Children Mark
142.Ldebug_info_end0:
143