xref: /llvm-project/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/odr-string.test (revision 9de73b20404f0b2db1cbf70d164cfe0789d5bb94)
1# RUN: dsymutil --linker=parallel -f -o - -oso-prepend-path=%p/../ -y %s | llvm-dwarfdump --verify - | FileCheck -check-prefixes=VERIFY %s
2# RUN: dsymutil --linker=parallel -f -o - -oso-prepend-path=%p/../ -y %s | llvm-dwarfdump -a - | FileCheck %s
3
4# This test checks that types from several object files are
5# uniqued(moved into the artificial compile unit for types).
6# It also checks that information between different debug
7# tables is consistent.
8#
9# To recreate a test compile following example:
10#
11# main.cpp:
12#
13# include <string>
14#
15# void PrintSize ( const std::string& String );
16# void PrintNewString ( const std::string& String );
17# void PrintNewString2 ( const char* String );
18#
19# int main ( void ) {
20#
21#   PrintSize("hello");
22#   PrintNewString("hello");
23#   PrintNewString2("hello");
24#   printf("\n");
25#
26#   return 0;
27# }
28#
29# foo1.cpp:
30#
31# #include <string>
32#
33# void PrintSize ( const std::string& String ) {
34#   printf("\n String size %lu", String.size() );
35# };
36#
37# foo2.cpp:
38#
39# #include <string>
40#
41# void PrintNewString ( const std::string& String ) {
42#  std::string NewString(String);
43#  NewString += "++";
44#  printf("\n String %s", NewString.c_str());
45#};
46#
47# foo3.cpp:
48# #include <string>
49#
50# void PrintNewString2 ( const char* String ) {
51#   std::string NewString(String);
52#   NewString += "++";
53#   printf("\n String2 %s", NewString.c_str());
54# };
55#
56# with clang++ -O -fno-inline -g -std=c++11
57
58---
59triple:          'x86_64-apple-darwin'
60objects:
61  - filename:        'Inputs/String/foo1.o'
62    timestamp:       1638904719
63    symbols:
64      - { sym: __ZNKSt3__122__compressed_pair_elemINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5__repELi0ELb0EE5__getEv, objAddr: 0x00000000000000A0, binAddr: 0x0000000100000B10, size: 0x00000009 }
65      - { sym: __ZNKSt3__117__compressed_pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5__repES5_E5firstEv, objAddr: 0x0000000000000090, binAddr: 0x0000000100000B00, size: 0x00000010 }
66      - { sym: __Z9PrintSizeRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE, objAddr: 0x0000000000000000, binAddr: 0x0000000100000A70, size: 0x00000020 }
67      - { sym: __ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE15__get_long_sizeEv, objAddr: 0x0000000000000060, binAddr: 0x0000000100000AD0, size: 0x00000010 }
68      - { sym: __ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4sizeEv, objAddr: 0x0000000000000020, binAddr: 0x0000000100000A90, size: 0x00000030 }
69      - { sym: __ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16__get_short_sizeEv, objAddr: 0x0000000000000070, binAddr: 0x0000000100000AE0, size: 0x00000020 }
70      - { sym: __ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__is_longEv, objAddr: 0x0000000000000050, binAddr: 0x0000000100000AC0, size: 0x00000010 }
71  - filename:        'Inputs/String/foo2.o'
72    timestamp:       1638904723
73    symbols:
74      - { sym: __ZNSt3__112__to_addressIKcEEPT_S3_, objAddr: 0x00000000000000E0, binAddr: 0x0000000100000BD0, size: 0x00000010 }
75      - { sym: GCC_except_table0, objAddr: 0x000000000000016C, binAddr: 0x0000000100000F24, size: 0x00000000 }
76      - { sym: __ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE18__get_long_pointerEv, objAddr: 0x0000000000000120, binAddr: 0x0000000100000C10, size: 0x00000010 }
77      - { sym: __ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE19__get_short_pointerEv, objAddr: 0x0000000000000130, binAddr: 0x0000000100000C20, size: 0x00000020 }
78      - { sym: __ZNSt3__114pointer_traitsIPKcE10pointer_toERS1_, objAddr: 0x0000000000000150, binAddr: 0x0000000100000C40, size: 0x00000010 }
79      - { sym: __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEpLEPKc, objAddr: 0x0000000000000070, binAddr: 0x0000000100000B90, size: 0x00000010 }
80      - { sym: __ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4dataEv, objAddr: 0x00000000000000C0, binAddr: 0x0000000100000BB0, size: 0x00000020 }
81      - { sym: __Z14PrintNewStringRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE, objAddr: 0x0000000000000000, binAddr: 0x0000000100000B20, size: 0x00000070 }
82      - { sym: __ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5c_strEv, objAddr: 0x0000000000000080, binAddr: 0x0000000100000BA1, size: 0x00000010 }
83      - { sym: __ZNSt3__19addressofIKcEEPT_RS2_, objAddr: 0x0000000000000160, binAddr: 0x0000000100000C50, size: 0x00000009 }
84      - { sym: __ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE13__get_pointerEv, objAddr: 0x00000000000000F0, binAddr: 0x0000000100000BE0, size: 0x00000030 }
85  - filename:        'Inputs/String/foo3.o'
86    timestamp:       1638904727
87    symbols:
88      - { sym: __ZNSt3__117__compressed_pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5__repES5_EC2INS_18__default_init_tagESA_EEOT_OT0_, objAddr: 0x0000000000000130, binAddr: 0x0000000100000D40, size: 0x00000040 }
89      - { sym: __ZNSt3__117__compressed_pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5__repES5_EC1INS_18__default_init_tagESA_EEOT_OT0_, objAddr: 0x0000000000000110, binAddr: 0x0000000100000D20, size: 0x00000010 }
90      - { sym: __ZNSt3__111char_traitsIcE6lengthEPKc, objAddr: 0x0000000000000120, binAddr: 0x0000000100000D50, size: 0x00000010 }
91      - { sym: __ZNSt3__116__non_trivial_ifILb1ENS_9allocatorIcEEEC2Ev, objAddr: 0x00000000000001B0, binAddr: 0x0000000100000DC0, size: 0x00000010 }
92      - { sym: __ZNSt3__17forwardINS_18__default_init_tagEEEOT_RNS_16remove_referenceIS2_E4typeE, objAddr: 0x0000000000000170, binAddr: 0x0000000100000D80, size: 0x00000010 }
93      - { sym: __ZNSt3__122__compressed_pair_elemINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5__repELi0ELb0EEC2ENS_18__default_init_tagE, objAddr: 0x0000000000000180, binAddr: 0x0000000100000D90, size: 0x00000010 }
94      - { sym: __ZNSt3__122__compressed_pair_elemINS_9allocatorIcEELi1ELb1EEC2ENS_18__default_init_tagE, objAddr: 0x0000000000000190, binAddr: 0x0000000100000DA0, size: 0x00000010 }
95      - { sym: __ZNSt3__19allocatorIcEC2Ev, objAddr: 0x00000000000001A0, binAddr: 0x0000000100000DB0, size: 0x00000010 }
96      - { sym: __Z15PrintNewString2PKc, objAddr: 0x0000000000000000, binAddr: 0x0000000100000C60, size: 0x00000070 }
97      - { sym: GCC_except_table0, objAddr: 0x000000000000026C, binAddr: 0x0000000100000F34, size: 0x00000000 }
98      - { sym: __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1IDnEEPKc, objAddr: 0x0000000000000070, binAddr: 0x0000000100000CD0, size: 0x00000010 }
99      - { sym: __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2IDnEEPKc, objAddr: 0x00000000000000D0, binAddr: 0x0000000100000CE0, size: 0x00000040 }
100  - filename:        'Inputs/String/main.o'
101    timestamp:       1638904734
102    symbols:
103      - { sym: _main, objAddr: 0x0000000000000000, binAddr: 0x0000000100000DD0, size: 0x00000090 }
104      - { sym: GCC_except_table0, objAddr: 0x0000000000000188, binAddr: 0x0000000100000F44, size: 0x00000000 }
105...
106
107VERIFY: Verifying .debug_abbrev...
108VERIFY: Verifying .debug_info Unit Header Chain...
109VERIFY: Verifying .debug_types Unit Header Chain...
110VERIFY: Verifying .apple_names...
111VERIFY: Verifying .apple_types...
112VERIFY: Verifying .apple_namespaces...
113VERIFY: Verifying .apple_objc...
114VERIFY: No errors.
115
116CHECK: .debug_info contents:
117CHECK: Compile Unit:
118CHECK: DW_TAG_compile_unit
119CHECK: DW_AT_name{{.*}}"__artificial_type_unit"
120
121CHECK:DW_TAG_base_type
122
123CHECK: 0x[[BASE_INT:[0-9a-f]*]]: DW_TAG_base_type{{.*[[:space:]].*}}DW_AT_name{{.*}}"int"
124
125CHECK:DW_TAG_class_type
126
127CHECK: 0x[[BASIC_STRING:[0-9a-f]*]]: DW_TAG_class_type{{.*[[:space:]].*}}DW_AT_calling_convention{{.*}}{{.*[[:space:]].*}}DW_AT_name{{.*}}"basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >"
128
129CHECK:DW_TAG_typedef
130
131CHECK: 0x[[STRING:[0-9a-f]*]]: DW_TAG_typedef{{.*[[:space:]].*}}DW_AT_type{{.*}}0x[[BASIC_STRING]] "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >"){{.*[[:space:]].*}}DW_AT_name{{.*}}"string"
132
133CHECK:DW_TAG_reference_type
134
135CHECK: 0x[[CONST_STR_REF:[0-9a-f]*]]: DW_TAG_reference_type{{.*[[:space:]].*}}DW_AT_type{{.*}}0x[[CONST_STRING:[0-9a-f]*]] "const std::__1::string"
136
137CHECK:DW_TAG_const_type
138
139CHECK: 0x[[CONST_STRING]]: DW_TAG_const_type{{.*[[:space:]].*}}DW_AT_type{{.*}}0x[[STRING]] "std::__1::string"
140
141
142CHECK: Compile Unit:
143CHECK: DW_TAG_compile_unit
144CHECK: DW_AT_name{{.*}}"foo1.cpp"
145CHECK: DW_TAG_subprogram
146CHECK: DW_AT_low_pc
147CHECK: DW_AT_high_pc
148CHECK: DW_AT_name{{.*}}"PrintSize"
149CHECK: DW_TAG_formal_parameter
150CHECK: DW_AT_name{{.*}}"String"
151CHECK: DW_AT_type{{.*}}0x00000000[[CONST_STR_REF]] "const std::__1::string &"
152
153CHECK: Compile Unit:
154CHECK: DW_TAG_compile_unit
155CHECK: DW_AT_name{{.*}}"foo2.cpp"
156CHECK: DW_TAG_subprogram
157CHECK: DW_AT_low_pc
158CHECK: DW_AT_high_pc
159CHECK: DW_AT_name{{.*}}"PrintNewString"
160CHECK: DW_TAG_formal_parameter
161CHECK: DW_AT_name{{.*}}"String"
162
163CHECK: Compile Unit:
164CHECK: DW_TAG_compile_unit
165CHECK: DW_AT_name{{.*}}"foo3.cpp"
166CHECK: DW_TAG_subprogram
167CHECK: DW_AT_low_pc
168CHECK: DW_AT_high_pc
169CHECK: DW_AT_name{{.*}}"PrintNewString2"
170CHECK: DW_TAG_formal_parameter
171CHECK: DW_AT_name{{.*}}"String"
172
173CHECK: Compile Unit:
174CHECK: DW_TAG_compile_unit
175CHECK: DW_AT_name{{.*}}"main.cpp"
176CHECK: DW_TAG_subprogram
177CHECK: DW_AT_low_pc
178CHECK: DW_AT_high_pc
179CHECK: DW_AT_name{{.*}}"main"
180CHECK: DW_AT_type{{.*}}0x00000000[[BASE_INT]] "int"
181