1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
20788
20789
20790
20791
20792
20793
20794
20795
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
20812
20813
20814
20815
20816
20817
20818
20819
20820
20821
20822
20823
20824
20825
20826
20827
20828
20829
20830
20831
20832
20833
20834
20835
20836
20837
20838
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848
20849
20850
20851
20852
20853
20854
20855
20856
20857
20858
20859
20860
20861
20862
20863
20864
20865
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887
20888
20889
20890
20891
20892
20893
20894
20895
20896
20897
20898
20899
20900
20901
20902
20903
20904
20905
20906
20907
20908
20909
20910
20911
20912
20913
20914
20915
20916
20917
20918
20919
20920
20921
20922
20923
20924
20925
20926
20927
20928
20929
20930
20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
20950
20951
20952
20953
20954
20955
20956
20957
20958
20959
20960
20961
20962
20963
20964
20965
20966
20967
20968
20969
20970
20971
20972
20973
20974
20975
20976
20977
20978
20979
20980
20981
20982
20983
20984
20985
20986
20987
20988
20989
20990
20991
20992
20993
20994
20995
20996
20997
20998
20999
21000
21001
21002
21003
21004
21005
21006
21007
21008
21009
21010
21011
21012
21013
21014
21015
21016
21017
21018
21019
21020
21021
21022
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041
21042
21043
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063
21064
21065
21066
21067
21068
21069
21070
21071
21072
21073
21074
21075
21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
21100
21101
21102
21103
21104
21105
21106
21107
21108
21109
21110
21111
21112
21113
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123
21124
21125
21126
21127
21128
21129
21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159
21160
21161
21162
21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
21179
21180
21181
21182
21183
21184
21185
21186
21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
21197
21198
21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
21209
21210
21211
21212
21213
21214
21215
21216
21217
21218
21219
21220
21221
21222
21223
21224
21225
21226
21227
21228
21229
21230
21231
21232
21233
21234
21235
21236
21237
21238
21239
21240
21241
21242
21243
21244
21245
21246
21247
21248
21249
21250
21251
21252
21253
21254
21255
21256
21257
21258
21259
21260
21261
21262
21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
21296
21297
21298
21299
21300
21301
21302
21303
21304
21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
21347
21348
21349
21350
21351
21352
21353
21354
21355
21356
21357
21358
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
21371
21372
21373
21374
21375
21376
21377
21378
21379
21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
21390
21391
21392
21393
21394
21395
21396
21397
21398
21399
21400
21401
21402
21403
21404
21405
21406
21407
21408
21409
21410
21411
21412
21413
21414
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425
21426
21427
21428
21429
21430
21431
21432
21433
21434
21435
21436
21437
21438
21439
21440
21441
21442
21443
21444
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
21471
21472
21473
21474
21475
21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
21495
21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
21526
21527
21528
21529
21530
21531
21532
21533
21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
21689
21690
21691
21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
21707
21708
21709
21710
21711
21712
21713
21714
21715
21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
21731
21732
21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
21743
21744
21745
21746
21747
21748
21749
21750
21751
21752
21753
21754
21755
21756
21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
21772
21773
21774
21775
21776
21777
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
21792
21793
21794
21795
21796
21797
21798
21799
21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
21833
21834
21835
21836
21837
21838
21839
21840
21841
21842
21843
21844
21845
21846
21847
21848
21849
21850
21851
21852
21853
21854
21855
21856
21857
21858
21859
21860
21861
21862
21863
21864
21865
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879
21880
21881
21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
21898
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
21919
21920
21921
21922
21923
21924
21925
21926
21927
21928
21929
21930
21931
21932
21933
21934
21935
21936
21937
21938
21939
21940
21941
21942
21943
21944
21945
21946
21947
21948
21949
21950
21951
21952
21953
21954
21955
21956
21957
21958
21959
21960
21961
21962
21963
21964
21965
21966
21967
21968
21969
21970
21971
21972
21973
21974
21975
21976
21977
21978
21979
21980
21981
21982
21983
21984
21985
21986
21987
21988
21989
21990
21991
21992
21993
21994
21995
21996
21997
21998
21999
22000
22001
22002
22003
22004
22005
22006
22007
22008
22009
22010
22011
22012
22013
22014
22015
22016
22017
22018
22019
22020
22021
22022
22023
22024
22025
22026
22027
22028
22029
22030
22031
22032
22033
22034
22035
22036
22037
22038
22039
22040
22041
22042
22043
22044
22045
22046
22047
22048
22049
22050
22051
22052
22053
22054
22055
22056
22057
22058
22059
22060
22061
22062
22063
22064
22065
22066
22067
22068
22069
22070
22071
22072
22073
22074
22075
22076
22077
22078
22079
22080
22081
22082
22083
22084
22085
22086
22087
22088
22089
22090
22091
22092
22093
22094
22095
22096
22097
22098
22099
22100
22101
22102
22103
22104
22105
22106
22107
22108
22109
22110
22111
22112
22113
22114
22115
22116
22117
22118
22119
22120
22121
22122
22123
22124
22125
22126
22127
22128
22129
22130
22131
22132
22133
22134
22135
22136
22137
22138
22139
22140
22141
22142
22143
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170
22171
22172
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186
22187
22188
22189
22190
22191
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201
22202
22203
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
22219
22220
22221
22222
22223
22224
22225
22226
22227
22228
22229
22230
22231
22232
22233
22234
22235
22236
22237
22238
22239
22240
22241
22242
22243
22244
22245
22246
22247
22248
22249
22250
22251
22252
22253
22254
22255
22256
22257
22258
22259
22260
22261
22262
22263
22264
22265
22266
22267
22268
22269
22270
22271
22272
22273
22274
22275
22276
22277
22278
22279
22280
22281
22282
22283
22284
22285
22286
22287
22288
22289
22290
22291
22292
22293
22294
22295
22296
22297
22298
22299
22300
22301
22302
22303
22304
22305
22306
22307
22308
22309
22310
22311
22312
22313
22314
22315
22316
22317
22318
22319
22320
22321
22322
22323
22324
22325
22326
22327
22328
22329
22330
22331
22332
22333
22334
22335
22336
22337
22338
22339
22340
22341
22342
22343
22344
22345
22346
22347
22348
22349
22350
22351
22352
22353
22354
22355
22356
22357
22358
22359
22360
22361
22362
22363
22364
22365
22366
22367
22368
22369
22370
22371
22372
22373
22374
22375
22376
22377
22378
22379
22380
22381
22382
22383
22384
22385
22386
22387
22388
22389
22390
22391
22392
22393
22394
22395
22396
22397
22398
22399
22400
22401
22402
22403
22404
22405
22406
22407
22408
22409
22410
22411
22412
22413
22414
22415
22416
22417
22418
22419
22420
22421
22422
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
22437
22438
22439
22440
22441
22442
22443
22444
22445
22446
22447
22448
22449
22450
22451
22452
22453
22454
22455
22456
22457
22458
22459
22460
22461
22462
22463
22464
22465
22466
22467
22468
22469
22470
22471
22472
22473
22474
22475
22476
22477
22478
22479
22480
22481
22482
22483
22484
22485
22486
22487
22488
22489
22490
22491
22492
22493
22494
22495
22496
22497
22498
22499
22500
22501
22502
22503
22504
22505
22506
22507
22508
22509
22510
22511
22512
22513
22514
22515
22516
22517
22518
22519
22520
22521
22522
22523
22524
22525
22526
22527
22528
22529
22530
22531
22532
22533
22534
22535
22536
22537
22538
22539
22540
22541
22542
22543
22544
22545
22546
22547
22548
22549
22550
22551
22552
22553
22554
22555
22556
22557
22558
22559
22560
22561
22562
22563
22564
22565
22566
22567
22568
22569
22570
22571
22572
22573
22574
22575
22576
22577
22578
22579
22580
22581
22582
22583
22584
22585
22586
22587
22588
22589
22590
22591
22592
22593
22594
22595
22596
22597
22598
22599
22600
22601
22602
22603
22604
22605
22606
22607
22608
22609
22610
22611
22612
22613
22614
22615
22616
22617
22618
22619
22620
22621
22622
22623
22624
22625
22626
22627
22628
22629
22630
22631
22632
22633
22634
22635
22636
22637
22638
22639
22640
22641
22642
22643
22644
22645
22646
22647
22648
22649
22650
22651
22652
22653
22654
22655
22656
22657
22658
22659
22660
22661
22662
22663
22664
22665
22666
22667
22668
22669
22670
22671
22672
22673
22674
22675
22676
22677
22678
22679
22680
22681
22682
22683
22684
22685
22686
22687
22688
22689
22690
22691
22692
22693
22694
22695
22696
22697
22698
22699
22700
22701
22702
22703
22704
22705
22706
22707
22708
22709
22710
22711
22712
22713
22714
22715
22716
22717
22718
22719
22720
22721
22722
22723
22724
22725
22726
22727
22728
22729
22730
22731
22732
22733
22734
22735
22736
22737
22738
22739
22740
22741
22742
22743
22744
22745
22746
22747
22748
22749
22750
22751
22752
22753
22754
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768
22769
22770
22771
22772
22773
22774
22775
22776
22777
22778
22779
22780
22781
22782
22783
22784
22785
22786
22787
22788
22789
22790
22791
22792
22793
22794
22795
22796
22797
22798
22799
22800
22801
22802
22803
22804
22805
22806
22807
22808
22809
22810
22811
22812
22813
22814
22815
22816
22817
22818
22819
22820
22821
22822
22823
22824
22825
22826
22827
22828
22829
22830
22831
22832
22833
22834
22835
22836
22837
22838
22839
22840
22841
22842
22843
22844
22845
22846
22847
22848
22849
22850
22851
22852
22853
22854
22855
22856
22857
22858
22859
22860
22861
22862
22863
22864
22865
22866
22867
22868
22869
22870
22871
22872
22873
22874
22875
22876
22877
22878
22879
22880
22881
22882
22883
22884
22885
22886
22887
22888
22889
22890
22891
22892
22893
22894
22895
22896
22897
22898
22899
22900
22901
22902
22903
22904
22905
22906
22907
22908
22909
22910
22911
22912
22913
22914
22915
22916
22917
22918
22919
22920
22921
22922
22923
22924
22925
22926
22927
22928
22929
22930
22931
22932
22933
22934
22935
22936
22937
22938
22939
22940
22941
22942
22943
22944
22945
22946
22947
22948
22949
22950
22951
22952
22953
22954
22955
22956
22957
22958
22959
22960
22961
22962
22963
22964
22965
22966
22967
22968
22969
22970
22971
22972
22973
22974
22975
22976
22977
22978
22979
22980
22981
22982
22983
22984
22985
22986
22987
22988
22989
22990
22991
22992
22993
22994
22995
22996
22997
22998
22999
23000
23001
23002
23003
23004
23005
23006
23007
23008
23009
23010
23011
23012
23013
23014
23015
23016
23017
23018
23019
23020
23021
23022
23023
23024
23025
23026
23027
23028
23029
23030
23031
23032
23033
23034
23035
23036
23037
23038
23039
23040
23041
23042
23043
23044
23045
23046
23047
23048
23049
23050
23051
23052
23053
23054
23055
23056
23057
23058
23059
23060
23061
23062
23063
23064
23065
23066
23067
23068
23069
23070
23071
23072
23073
23074
23075
23076
23077
23078
23079
23080
23081
23082
23083
23084
23085
23086
23087
23088
23089
23090
23091
23092
23093
23094
23095
23096
23097
23098
23099
23100
23101
23102
23103
23104
23105
23106
23107
23108
23109
23110
23111
23112
23113
23114
23115
23116
23117
23118
23119
23120
23121
23122
23123
23124
23125
23126
23127
23128
23129
23130
23131
23132
23133
23134
23135
23136
23137
23138
23139
23140
23141
23142
23143
23144
23145
23146
23147
23148
23149
23150
23151
23152
23153
23154
23155
23156
23157
23158
23159
23160
23161
23162
23163
23164
23165
23166
23167
23168
23169
23170
23171
23172
23173
23174
23175
23176
23177
23178
23179
23180
23181
23182
23183
23184
23185
23186
23187
23188
23189
23190
23191
23192
23193
23194
23195
23196
23197
23198
23199
23200
23201
23202
23203
23204
23205
23206
23207
23208
23209
23210
23211
23212
23213
23214
23215
23216
23217
23218
23219
23220
23221
23222
23223
23224
23225
23226
23227
23228
23229
23230
23231
23232
23233
23234
23235
23236
23237
23238
23239
23240
23241
23242
23243
23244
23245
23246
23247
23248
23249
23250
23251
23252
23253
23254
23255
23256
23257
23258
23259
23260
23261
23262
23263
23264
23265
23266
23267
23268
23269
23270
23271
23272
23273
23274
23275
23276
23277
23278
23279
23280
23281
23282
23283
23284
23285
23286
23287
23288
23289
23290
23291
23292
23293
23294
23295
23296
23297
23298
23299
23300
23301
23302
23303
23304
23305
23306
23307
23308
23309
23310
23311
23312
23313
23314
23315
23316
23317
23318
23319
23320
23321
23322
23323
23324
23325
23326
23327
23328
23329
23330
23331
23332
23333
23334
23335
23336
23337
23338
23339
23340
23341
23342
23343
23344
23345
23346
23347
23348
23349
23350
23351
23352
23353
23354
23355
23356
23357
23358
23359
23360
23361
23362
23363
23364
23365
23366
23367
23368
23369
23370
23371
23372
23373
23374
23375
23376
23377
23378
23379
23380
23381
23382
23383
23384
23385
23386
23387
23388
23389
23390
23391
23392
23393
23394
23395
23396
23397
23398
23399
23400
23401
23402
23403
23404
23405
23406
23407
23408
23409
23410
23411
23412
23413
23414
23415
23416
23417
23418
23419
23420
23421
23422
23423
23424
23425
23426
23427
23428
23429
23430
23431
23432
23433
23434
23435
23436
23437
23438
23439
23440
23441
23442
23443
23444
23445
23446
23447
23448
23449
23450
23451
23452
23453
23454
23455
23456
23457
23458
23459
23460
23461
23462
23463
23464
23465
23466
23467
23468
23469
23470
23471
23472
23473
23474
23475
23476
23477
23478
23479
23480
23481
23482
23483
23484
23485
23486
23487
23488
23489
23490
23491
23492
23493
23494
23495
23496
23497
23498
23499
23500
23501
23502
23503
23504
23505
23506
23507
23508
23509
23510
23511
23512
23513
23514
23515
23516
23517
23518
23519
23520
23521
23522
23523
23524
23525
23526
23527
23528
23529
23530
23531
23532
23533
23534
23535
23536
23537
23538
23539
23540
23541
23542
23543
23544
23545
23546
23547
23548
23549
23550
23551
23552
23553
23554
23555
23556
23557
23558
23559
23560
23561
23562
23563
23564
23565
23566
23567
23568
23569
23570
23571
23572
23573
23574
23575
23576
23577
23578
23579
23580
23581
23582
23583
23584
23585
23586
23587
23588
23589
23590
23591
23592
23593
23594
23595
23596
23597
23598
23599
23600
23601
23602
23603
23604
23605
23606
23607
23608
23609
23610
23611
23612
23613
23614
23615
23616
23617
23618
23619
23620
23621
23622
23623
23624
23625
23626
23627
23628
23629
23630
23631
23632
23633
23634
23635
23636
23637
23638
23639
23640
23641
23642
23643
23644
23645
23646
23647
23648
23649
23650
23651
23652
23653
23654
23655
23656
23657
23658
23659
23660
23661
23662
23663
23664
23665
23666
23667
23668
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
23679
23680
23681
23682
23683
23684
23685
23686
23687
23688
23689
23690
23691
23692
23693
23694
23695
23696
23697
23698
23699
23700
23701
23702
23703
23704
23705
23706
23707
23708
23709
23710
23711
23712
23713
23714
23715
23716
23717
23718
23719
23720
23721
23722
23723
23724
23725
23726
23727
23728
23729
23730
23731
23732
23733
23734
23735
23736
23737
23738
23739
23740
23741
23742
23743
23744
23745
23746
23747
23748
23749
23750
23751
23752
23753
23754
23755
23756
23757
23758
23759
23760
23761
23762
23763
23764
23765
23766
23767
23768
23769
23770
23771
23772
23773
23774
23775
23776
23777
23778
23779
23780
23781
23782
23783
23784
23785
23786
23787
23788
23789
23790
23791
23792
23793
23794
23795
23796
23797
23798
23799
23800
23801
23802
23803
23804
23805
23806
23807
23808
23809
23810
23811
23812
23813
23814
23815
23816
23817
23818
23819
23820
23821
23822
23823
23824
23825
23826
23827
23828
23829
23830
23831
23832
23833
23834
23835
23836
23837
23838
23839
23840
23841
23842
23843
23844
23845
23846
23847
23848
23849
23850
23851
23852
23853
23854
23855
23856
23857
23858
23859
23860
23861
23862
23863
23864
23865
23866
23867
23868
23869
23870
23871
23872
23873
23874
23875
23876
23877
23878
23879
23880
23881
23882
23883
23884
23885
23886
23887
23888
23889
23890
23891
23892
23893
23894
23895
23896
23897
23898
23899
23900
23901
23902
23903
23904
23905
23906
23907
23908
23909
23910
23911
23912
23913
23914
23915
23916
23917
23918
23919
23920
23921
23922
23923
23924
23925
23926
23927
23928
23929
23930
23931
23932
23933
23934
23935
23936
23937
23938
23939
23940
23941
23942
23943
23944
23945
23946
23947
23948
23949
23950
23951
23952
23953
23954
23955
23956
23957
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
23974
23975
23976
23977
23978
23979
23980
23981
23982
23983
23984
23985
23986
23987
23988
23989
23990
23991
23992
23993
23994
23995
23996
23997
23998
23999
24000
24001
24002
24003
24004
24005
24006
24007
24008
24009
24010
24011
24012
24013
24014
24015
24016
24017
24018
24019
24020
24021
24022
24023
24024
24025
24026
24027
24028
24029
24030
24031
24032
24033
24034
24035
24036
24037
24038
24039
24040
24041
24042
24043
24044
24045
24046
24047
24048
24049
24050
24051
24052
24053
24054
24055
24056
24057
24058
24059
24060
24061
24062
24063
24064
24065
24066
24067
24068
24069
24070
24071
24072
24073
24074
24075
24076
24077
24078
24079
24080
24081
24082
24083
24084
24085
24086
24087
24088
24089
24090
24091
24092
24093
24094
24095
24096
24097
24098
24099
24100
24101
24102
24103
24104
24105
24106
24107
24108
24109
24110
24111
24112
24113
24114
24115
24116
24117
24118
24119
24120
24121
24122
24123
24124
24125
24126
24127
24128
24129
24130
24131
24132
24133
24134
24135
24136
24137
24138
24139
24140
24141
24142
24143
24144
24145
24146
24147
24148
24149
24150
24151
24152
24153
24154
24155
24156
24157
24158
24159
24160
24161
24162
24163
24164
24165
24166
24167
24168
24169
24170
24171
24172
24173
24174
24175
24176
24177
24178
24179
24180
24181
24182
24183
24184
24185
24186
24187
24188
24189
24190
24191
24192
24193
24194
24195
24196
24197
24198
24199
24200
24201
24202
24203
24204
24205
24206
24207
24208
24209
24210
24211
24212
24213
24214
24215
24216
24217
24218
24219
24220
24221
24222
24223
24224
24225
24226
24227
24228
24229
24230
24231
24232
24233
24234
24235
24236
24237
24238
24239
24240
24241
24242
24243
24244
24245
24246
24247
24248
24249
24250
24251
24252
24253
24254
24255
24256
24257
24258
24259
24260
24261
24262
24263
24264
24265
24266
24267
24268
24269
24270
24271
24272
24273
24274
24275
24276
24277
24278
24279
24280
24281
24282
24283
24284
24285
24286
24287
24288
24289
24290
24291
24292
24293
24294
24295
24296
24297
24298
24299
24300
24301
24302
24303
24304
24305
24306
24307
24308
24309
24310
24311
24312
24313
24314
24315
24316
24317
24318
24319
24320
24321
24322
24323
24324
24325
24326
24327
24328
24329
24330
24331
24332
24333
24334
24335
24336
24337
24338
24339
24340
24341
24342
24343
24344
24345
24346
24347
24348
24349
24350
24351
24352
24353
24354
24355
24356
24357
24358
24359
24360
24361
24362
24363
24364
24365
24366
24367
24368
24369
24370
24371
24372
24373
24374
24375
24376
24377
24378
24379
24380
24381
24382
24383
24384
24385
24386
24387
24388
24389
24390
24391
24392
24393
24394
24395
24396
24397
24398
24399
24400
24401
24402
24403
24404
24405
24406
24407
24408
24409
24410
24411
24412
24413
24414
24415
24416
24417
24418
24419
24420
24421
24422
24423
24424
24425
24426
24427
24428
24429
24430
24431
24432
24433
24434
24435
24436
24437
24438
24439
24440
24441
24442
24443
24444
24445
24446
24447
24448
24449
24450
24451
24452
24453
24454
24455
24456
24457
24458
24459
24460
24461
24462
24463
24464
24465
24466
24467
24468
24469
24470
24471
24472
24473
24474
24475
24476
24477
24478
24479
24480
24481
24482
24483
24484
24485
24486
24487
24488
24489
24490
24491
24492
24493
24494
24495
24496
24497
24498
24499
24500
24501
24502
24503
24504
24505
24506
24507
24508
24509
24510
24511
24512
24513
24514
24515
24516
24517
24518
24519
24520
24521
24522
24523
24524
24525
24526
24527
24528
24529
24530
24531
24532
24533
24534
24535
24536
24537
24538
24539
24540
24541
24542
24543
24544
24545
24546
24547
24548
24549
24550
24551
24552
24553
24554
24555
24556
24557
24558
24559
24560
24561
24562
24563
24564
24565
24566
24567
24568
24569
24570
24571
24572
24573
24574
24575
24576
24577
24578
24579
24580
24581
24582
24583
24584
24585
24586
24587
24588
24589
24590
24591
24592
24593
24594
24595
24596
24597
24598
24599
24600
24601
24602
24603
24604
24605
24606
24607
24608
24609
24610
24611
24612
24613
24614
24615
24616
24617
24618
24619
24620
24621
24622
24623
24624
24625
24626
24627
24628
24629
24630
24631
24632
24633
24634
24635
24636
24637
24638
24639
24640
24641
24642
24643
24644
24645
24646
24647
24648
24649
24650
24651
24652
24653
24654
24655
24656
24657
24658
24659
24660
24661
24662
24663
24664
24665
24666
24667
24668
24669
24670
24671
24672
24673
24674
24675
24676
24677
24678
24679
24680
24681
24682
24683
24684
24685
24686
24687
24688
24689
24690
24691
24692
24693
24694
24695
24696
24697
24698
24699
24700
24701
24702
24703
24704
24705
24706
24707
24708
24709
24710
24711
24712
24713
24714
24715
24716
24717
24718
24719
24720
24721
24722
24723
24724
24725
24726
24727
24728
24729
24730
24731
24732
24733
24734
24735
24736
24737
24738
24739
24740
24741
24742
24743
24744
24745
24746
24747
24748
24749
24750
24751
24752
24753
24754
24755
24756
24757
24758
24759
24760
24761
24762
24763
24764
24765
24766
24767
24768
24769
24770
24771
24772
24773
24774
24775
24776
24777
24778
24779
24780
24781
24782
24783
24784
24785
24786
24787
24788
24789
24790
24791
24792
24793
24794
24795
24796
24797
24798
24799
24800
24801
24802
24803
24804
24805
24806
24807
24808
24809
24810
24811
24812
24813
24814
24815
24816
24817
24818
24819
24820
24821
24822
24823
24824
24825
24826
24827
24828
24829
24830
24831
24832
24833
24834
24835
24836
24837
24838
24839
24840
24841
24842
24843
24844
24845
24846
24847
24848
24849
24850
24851
24852
24853
24854
24855
24856
24857
24858
24859
24860
24861
24862
24863
24864
24865
24866
24867
24868
24869
24870
24871
24872
24873
24874
24875
24876
24877
24878
24879
24880
24881
24882
24883
24884
24885
24886
24887
24888
24889
24890
24891
24892
24893
24894
24895
24896
24897
24898
24899
24900
24901
24902
24903
24904
24905
24906
24907
24908
24909
24910
24911
24912
24913
24914
24915
24916
24917
24918
24919
24920
24921
24922
24923
24924
24925
24926
24927
24928
24929
24930
24931
24932
24933
24934
24935
24936
24937
24938
24939
24940
24941
24942
24943
24944
24945
24946
24947
24948
24949
24950
24951
24952
24953
24954
24955
24956
24957
24958
24959
24960
24961
24962
24963
24964
24965
24966
24967
24968
24969
24970
24971
24972
24973
24974
24975
24976
24977
24978
24979
24980
24981
24982
24983
24984
24985
24986
24987
24988
24989
24990
24991
24992
24993
24994
24995
24996
24997
24998
24999
25000
25001
25002
25003
25004
25005
25006
25007
25008
25009
25010
25011
25012
25013
25014
25015
25016
25017
25018
25019
25020
25021
25022
25023
25024
25025
25026
25027
25028
25029
25030
25031
25032
25033
25034
25035
25036
25037
25038
25039
25040
25041
25042
25043
25044
25045
25046
25047
25048
25049
25050
25051
25052
25053
25054
25055
25056
25057
25058
25059
25060
25061
25062
25063
25064
25065
25066
25067
25068
25069
25070
25071
25072
25073
25074
25075
25076
25077
25078
25079
25080
25081
25082
25083
25084
25085
25086
25087
25088
25089
25090
25091
25092
25093
25094
25095
25096
25097
25098
25099
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
25117
25118
25119
25120
25121
25122
25123
25124
25125
25126
25127
25128
25129
25130
25131
25132
25133
25134
25135
25136
25137
25138
25139
25140
25141
25142
25143
25144
25145
25146
25147
25148
25149
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159
25160
25161
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183
25184
25185
25186
25187
25188
25189
25190
25191
25192
25193
25194
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204
25205
25206
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217
25218
25219
25220
25221
25222
25223
25224
25225
25226
25227
25228
25229
25230
25231
25232
25233
25234
25235
25236
25237
25238
25239
25240
25241
25242
25243
25244
25245
25246
25247
25248
25249
25250
25251
25252
25253
25254
25255
25256
25257
25258
25259
25260
25261
25262
25263
25264
25265
25266
25267
25268
25269
25270
25271
25272
25273
25274
25275
25276
25277
25278
25279
25280
25281
25282
25283
25284
25285
25286
25287
25288
25289
25290
25291
25292
25293
25294
25295
25296
25297
25298
25299
25300
25301
25302
25303
25304
25305
25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
25325
25326
25327
25328
25329
25330
25331
25332
25333
25334
25335
25336
25337
25338
25339
25340
25341
25342
25343
25344
25345
25346
25347
25348
25349
25350
25351
25352
25353
25354
25355
25356
25357
25358
25359
25360
25361
25362
25363
25364
25365
25366
25367
25368
25369
25370
25371
25372
25373
25374
25375
25376
25377
25378
25379
25380
25381
25382
25383
25384
25385
25386
25387
25388
25389
25390
25391
25392
25393
25394
25395
25396
25397
25398
25399
25400
25401
25402
25403
25404
25405
25406
25407
25408
25409
25410
25411
25412
25413
25414
25415
25416
25417
25418
25419
25420
25421
25422
25423
25424
25425
25426
25427
25428
25429
25430
25431
25432
25433
25434
25435
25436
25437
25438
25439
25440
25441
25442
25443
25444
25445
25446
25447
25448
25449
25450
25451
25452
25453
25454
25455
25456
25457
25458
25459
25460
25461
25462
25463
25464
25465
25466
25467
25468
25469
25470
25471
25472
25473
25474
25475
25476
25477
25478
25479
25480
25481
25482
25483
25484
25485
25486
25487
25488
25489
25490
25491
25492
25493
25494
25495
25496
25497
25498
25499
25500
25501
25502
25503
25504
25505
25506
25507
25508
25509
25510
25511
25512
25513
25514
25515
25516
25517
25518
25519
25520
25521
25522
25523
25524
25525
25526
25527
25528
25529
25530
25531
25532
25533
25534
25535
25536
25537
25538
25539
25540
25541
25542
25543
25544
25545
25546
25547
25548
25549
25550
25551
25552
25553
25554
25555
25556
25557
25558
25559
25560
25561
25562
25563
25564
25565
25566
25567
25568
25569
25570
25571
25572
25573
25574
25575
25576
25577
25578
25579
25580
25581
25582
25583
25584
25585
25586
25587
25588
25589
25590
25591
25592
25593
25594
25595
25596
25597
25598
25599
25600
25601
25602
25603
25604
25605
25606
25607
25608
25609
25610
25611
25612
25613
25614
25615
25616
25617
25618
25619
25620
25621
25622
25623
25624
25625
25626
25627
25628
25629
25630
25631
25632
25633
25634
25635
25636
25637
25638
25639
25640
25641
25642
25643
25644
25645
25646
25647
25648
25649
25650
25651
25652
25653
25654
25655
25656
25657
25658
25659
25660
25661
25662
25663
25664
25665
25666
25667
25668
25669
25670
25671
25672
25673
25674
25675
25676
25677
25678
25679
25680
25681
25682
25683
25684
25685
25686
25687
25688
25689
25690
25691
25692
25693
25694
25695
25696
25697
25698
25699
25700
25701
25702
25703
25704
25705
25706
25707
25708
25709
25710
25711
25712
25713
25714
25715
25716
25717
25718
25719
25720
25721
25722
25723
25724
25725
25726
25727
25728
25729
25730
25731
25732
25733
25734
25735
25736
25737
25738
25739
25740
25741
25742
25743
25744
25745
25746
25747
25748
25749
25750
25751
25752
25753
25754
25755
25756
25757
25758
25759
25760
25761
25762
25763
25764
25765
25766
25767
25768
25769
25770
25771
25772
25773
25774
25775
25776
25777
25778
25779
25780
25781
25782
25783
25784
25785
25786
25787
25788
25789
25790
25791
25792
25793
25794
25795
25796
25797
25798
25799
25800
25801
25802
25803
25804
25805
25806
25807
25808
25809
25810
25811
25812
25813
25814
25815
25816
25817
25818
25819
25820
25821
25822
25823
25824
25825
25826
25827
25828
25829
25830
25831
25832
25833
25834
25835
25836
25837
25838
25839
25840
25841
25842
25843
25844
25845
25846
25847
25848
25849
25850
25851
25852
25853
25854
25855
25856
25857
25858
25859
25860
25861
25862
25863
25864
25865
25866
25867
25868
25869
25870
25871
25872
25873
25874
25875
25876
25877
25878
25879
25880
25881
25882
25883
25884
25885
25886
25887
25888
25889
25890
25891
25892
25893
25894
25895
25896
25897
25898
25899
25900
25901
25902
25903
25904
25905
25906
25907
25908
25909
25910
25911
25912
25913
25914
25915
25916
25917
25918
25919
25920
25921
25922
25923
25924
25925
25926
25927
25928
25929
25930
25931
25932
25933
25934
25935
25936
25937
25938
25939
25940
25941
25942
25943
25944
25945
25946
25947
25948
25949
25950
25951
25952
25953
25954
25955
25956
25957
25958
25959
25960
25961
25962
25963
25964
25965
25966
25967
25968
25969
25970
25971
25972
25973
25974
25975
25976
25977
25978
25979
25980
25981
25982
25983
25984
25985
25986
25987
25988
25989
25990
25991
25992
25993
25994
25995
25996
25997
25998
25999
26000
26001
26002
26003
26004
26005
26006
26007
26008
26009
26010
26011
26012
26013
26014
26015
26016
26017
26018
26019
26020
26021
26022
26023
26024
26025
26026
26027
26028
26029
26030
26031
26032
26033
26034
26035
26036
26037
26038
26039
26040
26041
26042
26043
26044
26045
26046
26047
26048
26049
26050
26051
26052
26053
26054
26055
26056
26057
26058
26059
26060
26061
26062
26063
26064
26065
26066
26067
26068
26069
26070
26071
26072
26073
26074
26075
26076
26077
26078
26079
26080
26081
26082
26083
26084
26085
26086
26087
26088
26089
26090
26091
26092
26093
26094
26095
26096
26097
26098
26099
26100
26101
26102
26103
26104
26105
26106
26107
26108
26109
26110
26111
26112
26113
26114
26115
26116
26117
26118
26119
26120
26121
26122
26123
26124
26125
26126
26127
26128
26129
26130
26131
26132
26133
26134
26135
26136
26137
26138
26139
26140
26141
26142
26143
26144
26145
26146
26147
26148
26149
26150
26151
26152
26153
26154
26155
26156
26157
26158
26159
26160
26161
26162
26163
26164
26165
26166
26167
26168
26169
26170
26171
26172
26173
26174
26175
26176
26177
26178
26179
26180
26181
26182
26183
26184
26185
26186
26187
26188
26189
26190
26191
26192
26193
26194
26195
26196
26197
26198
26199
26200
26201
26202
26203
26204
26205
26206
26207
26208
26209
26210
26211
26212
26213
26214
26215
26216
26217
26218
26219
26220
26221
26222
26223
26224
26225
26226
26227
26228
26229
26230
26231
26232
26233
26234
26235
26236
26237
26238
26239
26240
26241
26242
26243
26244
26245
26246
26247
26248
26249
26250
26251
26252
26253
26254
26255
26256
26257
26258
26259
26260
26261
26262
26263
26264
26265
26266
26267
26268
26269
26270
26271
26272
26273
26274
26275
26276
26277
26278
26279
26280
26281
26282
26283
26284
26285
26286
26287
26288
26289
26290
26291
26292
26293
26294
26295
26296
26297
26298
26299
26300
26301
26302
26303
26304
26305
26306
26307
26308
26309
26310
26311
26312
26313
26314
26315
26316
26317
26318
26319
26320
26321
26322
26323
26324
26325
26326
26327
26328
26329
26330
26331
26332
26333
26334
26335
26336
26337
26338
26339
26340
26341
26342
26343
26344
26345
26346
26347
26348
26349
26350
26351
26352
26353
26354
26355
26356
26357
26358
26359
26360
26361
26362
26363
26364
26365
26366
26367
26368
26369
26370
26371
26372
26373
26374
26375
26376
26377
26378
26379
26380
26381
26382
26383
26384
26385
26386
26387
26388
26389
26390
26391
26392
26393
26394
26395
26396
26397
26398
26399
26400
26401
26402
26403
26404
26405
26406
26407
26408
26409
26410
26411
26412
26413
26414
26415
26416
26417
26418
26419
26420
26421
26422
26423
26424
26425
26426
26427
26428
26429
26430
26431
26432
26433
26434
26435
26436
26437
26438
26439
26440
26441
26442
26443
26444
26445
26446
26447
26448
26449
26450
26451
26452
26453
26454
26455
26456
26457
26458
26459
26460
26461
26462
26463
26464
26465
26466
26467
26468
26469
26470
26471
26472
26473
26474
26475
26476
26477
26478
26479
26480
26481
26482
26483
26484
26485
26486
26487
26488
26489
26490
26491
26492
26493
26494
26495
26496
26497
26498
26499
26500
26501
26502
26503
26504
26505
26506
26507
26508
26509
26510
26511
26512
26513
26514
26515
26516
26517
26518
26519
26520
26521
26522
26523
26524
26525
26526
26527
26528
26529
26530
26531
26532
26533
26534
26535
26536
26537
26538
26539
26540
26541
26542
26543
26544
26545
26546
26547
26548
26549
26550
26551
26552
26553
26554
26555
26556
26557
26558
26559
26560
26561
26562
26563
26564
26565
26566
26567
26568
26569
26570
26571
26572
26573
26574
26575
26576
26577
26578
26579
26580
26581
26582
26583
26584
26585
26586
26587
26588
26589
26590
26591
26592
26593
26594
26595
26596
26597
26598
26599
26600
26601
26602
26603
26604
26605
26606
26607
26608
26609
26610
26611
26612
26613
26614
26615
26616
26617
26618
26619
26620
26621
26622
26623
26624
26625
26626
26627
26628
26629
26630
26631
26632
26633
26634
26635
26636
26637
26638
26639
26640
26641
26642
26643
26644
26645
26646
26647
26648
26649
26650
26651
26652
26653
26654
26655
26656
26657
26658
26659
26660
26661
26662
26663
26664
26665
26666
26667
26668
26669
26670
26671
26672
26673
26674
26675
26676
26677
26678
26679
26680
26681
26682
26683
26684
26685
26686
26687
26688
26689
26690
26691
26692
26693
26694
26695
26696
26697
26698
26699
26700
26701
26702
26703
26704
26705
26706
26707
26708
26709
26710
26711
26712
26713
26714
26715
26716
26717
26718
26719
26720
26721
26722
26723
26724
26725
26726
26727
26728
26729
26730
26731
26732
26733
26734
26735
26736
26737
26738
26739
26740
26741
26742
26743
26744
26745
26746
26747
26748
26749
26750
26751
26752
26753
26754
26755
26756
26757
26758
26759
26760
26761
26762
26763
26764
26765
26766
26767
26768
26769
26770
26771
26772
26773
26774
26775
26776
26777
26778
26779
26780
26781
26782
26783
26784
26785
26786
26787
26788
26789
26790
26791
26792
26793
26794
26795
26796
26797
26798
26799
26800
26801
26802
26803
26804
26805
26806
26807
26808
26809
26810
26811
26812
26813
26814
26815
26816
26817
26818
26819
26820
26821
26822
26823
26824
26825
26826
26827
26828
26829
26830
26831
26832
26833
26834
26835
26836
26837
26838
26839
26840
26841
26842
26843
26844
26845
26846
26847
26848
26849
26850
26851
26852
26853
26854
26855
26856
26857
26858
26859
26860
26861
26862
26863
26864
26865
26866
26867
26868
26869
26870
26871
26872
26873
26874
26875
26876
26877
26878
26879
26880
26881
26882
26883
26884
26885
26886
26887
26888
26889
26890
26891
26892
26893
26894
26895
26896
26897
26898
26899
26900
26901
26902
26903
26904
26905
26906
26907
26908
26909
26910
26911
26912
26913
26914
26915
26916
26917
26918
26919
26920
26921
26922
26923
26924
26925
26926
26927
26928
26929
26930
26931
26932
26933
26934
26935
26936
26937
26938
26939
26940
26941
26942
26943
26944
26945
26946
26947
26948
26949
26950
26951
26952
26953
26954
26955
26956
26957
26958
26959
26960
26961
26962
26963
26964
26965
26966
26967
26968
26969
26970
26971
26972
26973
26974
26975
26976
26977
26978
26979
26980
26981
26982
26983
26984
26985
26986
26987
26988
26989
26990
26991
26992
26993
26994
26995
26996
26997
26998
26999
27000
27001
27002
27003
27004
27005
27006
27007
27008
27009
27010
27011
27012
27013
27014
27015
27016
27017
27018
27019
27020
27021
27022
27023
27024
27025
27026
27027
27028
27029
27030
27031
27032
27033
27034
27035
27036
27037
27038
27039
27040
27041
27042
27043
27044
27045
27046
27047
27048
27049
27050
27051
27052
27053
27054
27055
27056
27057
27058
27059
27060
27061
27062
27063
27064
27065
27066
27067
27068
27069
27070
27071
27072
27073
27074
27075
27076
27077
27078
27079
27080
27081
27082
27083
27084
27085
27086
27087
27088
27089
27090
27091
27092
27093
27094
27095
27096
27097
27098
27099
27100
27101
27102
27103
27104
27105
27106
27107
27108
27109
27110
27111
27112
27113
27114
27115
27116
27117
27118
27119
27120
27121
27122
27123
27124
27125
27126
27127
27128
27129
27130
27131
27132
27133
27134
27135
27136
27137
27138
27139
27140
27141
27142
27143
27144
27145
27146
27147
27148
27149
27150
27151
27152
27153
27154
27155
27156
27157
27158
27159
27160
27161
27162
27163
27164
27165
27166
27167
27168
27169
27170
27171
27172
27173
27174
27175
27176
27177
27178
27179
27180
27181
27182
27183
27184
27185
27186
27187
27188
27189
27190
27191
27192
27193
27194
27195
27196
27197
27198
27199
27200
27201
27202
27203
27204
27205
27206
27207
27208
27209
27210
27211
27212
27213
27214
27215
27216
27217
27218
27219
27220
27221
27222
27223
27224
27225
27226
27227
27228
27229
27230
27231
27232
27233
27234
27235
27236
27237
27238
27239
27240
27241
27242
27243
27244
27245
27246
27247
27248
27249
27250
27251
27252
27253
27254
27255
27256
27257
27258
27259
27260
27261
27262
27263
27264
27265
27266
27267
27268
27269
27270
27271
27272
27273
27274
27275
27276
27277
27278
27279
27280
27281
27282
27283
27284
27285
27286
27287
27288
27289
27290
27291
27292
27293
27294
27295
27296
27297
27298
27299
27300
27301
27302
27303
27304
27305
27306
27307
27308
27309
27310
27311
27312
27313
27314
27315
27316
27317
27318
27319
27320
27321
27322
27323
27324
27325
27326
27327
27328
27329
27330
27331
27332
27333
27334
27335
27336
27337
27338
27339
27340
27341
27342
27343
27344
27345
27346
27347
27348
27349
27350
27351
27352
27353
27354
27355
27356
27357
27358
27359
27360
27361
27362
27363
27364
27365
27366
27367
27368
27369
27370
27371
27372
27373
27374
27375
27376
27377
27378
27379
27380
27381
27382
27383
27384
27385
27386
27387
27388
27389
27390
27391
27392
27393
27394
27395
27396
27397
27398
27399
27400
27401
27402
27403
27404
27405
27406
27407
27408
27409
27410
27411
27412
27413
27414
27415
27416
27417
27418
27419
27420
27421
27422
27423
27424
27425
27426
27427
27428
27429
27430
27431
27432
27433
27434
27435
27436
27437
27438
27439
27440
27441
27442
27443
27444
27445
27446
27447
27448
27449
27450
27451
27452
27453
27454
27455
27456
27457
27458
27459
27460
27461
27462
27463
27464
27465
27466
27467
27468
27469
27470
27471
27472
27473
27474
27475
27476
27477
27478
27479
27480
27481
27482
27483
27484
27485
27486
27487
27488
27489
27490
27491
27492
27493
27494
27495
27496
27497
27498
27499
27500
27501
27502
27503
27504
27505
27506
27507
27508
27509
27510
27511
27512
27513
27514
27515
27516
27517
27518
27519
27520
27521
27522
27523
27524
27525
27526
27527
27528
27529
27530
27531
27532
27533
27534
27535
27536
27537
27538
27539
27540
27541
27542
27543
27544
27545
27546
27547
27548
27549
27550
27551
27552
27553
27554
27555
27556
27557
27558
27559
27560
27561
27562
27563
27564
27565
27566
27567
27568
27569
27570
27571
27572
27573
27574
27575
27576
27577
27578
27579
27580
27581
27582
27583
27584
27585
27586
27587
27588
27589
27590
27591
27592
27593
27594
27595
27596
27597
27598
27599
27600
27601
27602
27603
27604
27605
27606
27607
27608
27609
27610
27611
27612
27613
27614
27615
27616
27617
27618
27619
27620
27621
27622
27623
27624
27625
27626
27627
27628
27629
27630
27631
27632
27633
27634
27635
27636
27637
27638
27639
27640
27641
27642
27643
27644
27645
27646
27647
27648
27649
27650
27651
27652
27653
27654
27655
27656
27657
27658
27659
27660
27661
27662
27663
27664
27665
27666
27667
27668
27669
27670
27671
27672
27673
27674
27675
27676
27677
27678
27679
27680
27681
27682
27683
27684
27685
27686
27687
27688
27689
27690
27691
27692
27693
27694
27695
27696
27697
27698
27699
27700
27701
27702
27703
27704
27705
27706
27707
27708
27709
27710
27711
27712
27713
27714
27715
27716
27717
27718
27719
27720
27721
27722
27723
27724
27725
27726
27727
27728
27729
27730
27731
27732
27733
27734
27735
27736
27737
27738
27739
27740
27741
27742
27743
27744
27745
27746
27747
27748
27749
27750
27751
27752
27753
27754
27755
27756
27757
27758
27759
27760
27761
27762
27763
27764
27765
27766
27767
27768
27769
27770
27771
27772
27773
27774
27775
27776
27777
27778
27779
27780
27781
27782
27783
27784
27785
27786
27787
27788
27789
27790
27791
27792
27793
27794
27795
27796
27797
27798
27799
27800
27801
27802
27803
27804
27805
27806
27807
27808
27809
27810
27811
27812
27813
27814
27815
27816
27817
27818
27819
27820
27821
27822
27823
27824
27825
27826
27827
27828
27829
27830
27831
27832
27833
27834
27835
27836
27837
27838
27839
27840
27841
27842
27843
27844
27845
27846
27847
27848
27849
27850
27851
27852
27853
27854
27855
27856
27857
27858
27859
27860
27861
27862
27863
27864
27865
27866
27867
27868
27869
27870
27871
27872
27873
27874
27875
27876
27877
27878
27879
27880
27881
27882
27883
27884
27885
27886
27887
27888
27889
27890
27891
27892
27893
27894
27895
27896
27897
27898
27899
27900
27901
27902
27903
27904
27905
27906
27907
27908
27909
27910
27911
27912
27913
27914
27915
27916
27917
27918
27919
27920
27921
27922
27923
27924
27925
27926
27927
27928
27929
27930
27931
27932
27933
27934
27935
27936
27937
27938
27939
27940
27941
27942
27943
27944
27945
27946
27947
27948
27949
27950
27951
27952
27953
27954
27955
27956
27957
27958
27959
27960
27961
27962
27963
27964
27965
27966
27967
27968
27969
27970
27971
27972
27973
27974
27975
27976
27977
27978
27979
27980
27981
27982
27983
27984
27985
27986
27987
27988
27989
27990
27991
27992
27993
27994
27995
27996
27997
27998
27999
28000
28001
28002
28003
28004
28005
28006
28007
28008
28009
28010
28011
28012
28013
28014
28015
28016
28017
28018
28019
28020
28021
28022
28023
28024
28025
28026
28027
28028
28029
28030
28031
28032
28033
28034
28035
28036
28037
28038
28039
28040
28041
28042
28043
28044
28045
28046
28047
28048
28049
28050
28051
28052
28053
28054
28055
28056
28057
28058
28059
28060
28061
28062
28063
28064
28065
28066
28067
28068
28069
28070
28071
28072
28073
28074
28075
28076
28077
28078
28079
28080
28081
28082
28083
28084
28085
28086
28087
28088
28089
28090
28091
28092
28093
28094
28095
28096
28097
28098
28099
28100
28101
28102
28103
28104
28105
28106
28107
28108
28109
28110
28111
28112
28113
28114
28115
28116
28117
28118
28119
28120
28121
28122
28123
28124
28125
28126
28127
28128
28129
28130
28131
28132
28133
28134
28135
28136
28137
28138
28139
28140
28141
28142
28143
28144
28145
28146
28147
28148
28149
28150
28151
28152
28153
28154
28155
28156
28157
28158
28159
28160
28161
28162
28163
28164
28165
28166
28167
28168
28169
28170
28171
28172
28173
28174
28175
28176
28177
28178
28179
28180
28181
28182
28183
28184
28185
28186
28187
28188
28189
28190
28191
28192
28193
28194
28195
28196
28197
28198
28199
28200
28201
28202
28203
28204
28205
28206
28207
28208
28209
28210
28211
28212
28213
28214
28215
28216
28217
28218
28219
28220
28221
28222
28223
28224
28225
28226
28227
28228
28229
28230
28231
28232
28233
28234
28235
28236
28237
28238
28239
28240
28241
28242
28243
28244
28245
28246
28247
28248
28249
28250
28251
28252
28253
28254
28255
28256
28257
28258
28259
28260
28261
28262
28263
28264
28265
28266
28267
28268
28269
28270
28271
28272
28273
28274
28275
28276
28277
28278
28279
28280
28281
28282
28283
28284
28285
28286
28287
28288
28289
28290
28291
28292
28293
28294
28295
28296
28297
28298
28299
28300
28301
28302
28303
28304
28305
28306
28307
28308
28309
28310
28311
28312
28313
28314
28315
28316
28317
28318
28319
28320
28321
28322
28323
28324
28325
28326
28327
28328
28329
28330
28331
28332
28333
28334
28335
28336
28337
28338
28339
28340
28341
28342
28343
28344
28345
28346
28347
28348
28349
28350
28351
28352
28353
28354
28355
28356
28357
28358
28359
28360
28361
28362
28363
28364
28365
28366
28367
28368
28369
28370
28371
28372
28373
28374
28375
28376
28377
28378
28379
28380
28381
28382
28383
28384
28385
28386
28387
28388
28389
28390
28391
28392
28393
28394
28395
28396
28397
28398
28399
28400
28401
28402
28403
28404
28405
28406
28407
28408
28409
28410
28411
28412
28413
28414
28415
28416
28417
28418
28419
28420
28421
28422
28423
28424
28425
28426
28427
28428
28429
28430
28431
28432
28433
28434
28435
28436
28437
28438
28439
28440
28441
28442
28443
28444
28445
28446
28447
28448
28449
28450
28451
28452
28453
28454
28455
28456
28457
28458
28459
28460
28461
28462
28463
28464
28465
28466
28467
28468
28469
28470
28471
28472
28473
28474
28475
28476
28477
28478
28479
28480
28481
28482
28483
28484
28485
28486
28487
28488
28489
28490
28491
28492
28493
28494
28495
28496
28497
28498
28499
28500
28501
28502
28503
28504
28505
28506
28507
28508
28509
28510
28511
28512
28513
28514
28515
28516
28517
28518
28519
28520
28521
28522
28523
28524
28525
28526
28527
28528
28529
28530
28531
28532
28533
28534
28535
28536
28537
28538
28539
28540
28541
28542
28543
28544
28545
28546
28547
28548
28549
28550
28551
28552
28553
28554
28555
28556
28557
28558
28559
28560
28561
28562
28563
28564
28565
28566
28567
28568
28569
28570
28571
28572
28573
28574
28575
28576
28577
28578
28579
28580
28581
28582
28583
28584
28585
28586
28587
28588
28589
28590
28591
28592
28593
28594
28595
28596
28597
28598
28599
28600
28601
28602
28603
28604
28605
28606
28607
28608
28609
28610
28611
28612
28613
28614
28615
28616
28617
28618
28619
28620
28621
28622
28623
28624
28625
28626
28627
28628
28629
28630
28631
28632
28633
28634
28635
28636
28637
28638
28639
28640
28641
28642
28643
28644
28645
28646
28647
28648
28649
28650
28651
28652
28653
28654
28655
28656
28657
28658
28659
28660
28661
28662
28663
28664
28665
28666
28667
28668
28669
28670
28671
28672
28673
28674
28675
28676
28677
28678
28679
28680
28681
28682
28683
28684
28685
28686
28687
28688
28689
28690
28691
28692
28693
28694
28695
28696
28697
28698
28699
28700
28701
28702
28703
28704
28705
28706
28707
28708
28709
28710
28711
28712
28713
28714
28715
28716
28717
28718
28719
28720
28721
28722
28723
28724
28725
28726
28727
28728
28729
28730
28731
28732
28733
28734
28735
28736
28737
28738
28739
28740
28741
28742
28743
28744
28745
28746
28747
28748
28749
28750
28751
28752
28753
28754
28755
28756
28757
28758
28759
28760
28761
28762
28763
28764
28765
28766
28767
28768
28769
28770
28771
28772
28773
28774
28775
28776
28777
28778
28779
28780
28781
28782
28783
28784
28785
28786
28787
28788
28789
28790
28791
28792
28793
28794
28795
28796
28797
28798
28799
28800
28801
28802
28803
28804
28805
28806
28807
28808
28809
28810
28811
28812
28813
28814
28815
28816
28817
28818
28819
28820
28821
28822
28823
28824
28825
28826
28827
28828
28829
28830
28831
28832
28833
28834
28835
28836
28837
28838
28839
28840
28841
28842
28843
28844
28845
28846
28847
28848
28849
28850
28851
28852
28853
28854
28855
28856
28857
28858
28859
28860
28861
28862
28863
28864
28865
28866
28867
28868
28869
28870
28871
28872
28873
28874
28875
28876
28877
28878
28879
28880
28881
28882
28883
28884
28885
28886
28887
28888
28889
28890
28891
28892
28893
28894
28895
28896
28897
28898
28899
28900
28901
28902
28903
28904
28905
28906
28907
28908
28909
28910
28911
28912
28913
28914
28915
28916
28917
28918
28919
28920
28921
28922
28923
28924
28925
28926
28927
28928
28929
28930
28931
28932
28933
28934
28935
28936
28937
28938
28939
28940
28941
28942
28943
28944
28945
28946
28947
28948
28949
28950
28951
28952
28953
28954
28955
28956
28957
28958
28959
28960
28961
28962
28963
28964
28965
28966
28967
28968
28969
28970
28971
28972
28973
28974
28975
28976
28977
28978
28979
28980
28981
28982
28983
28984
28985
28986
28987
28988
28989
28990
28991
28992
28993
28994
28995
28996
28997
28998
28999
29000
29001
29002
29003
29004
29005
29006
29007
29008
29009
29010
29011
29012
29013
29014
29015
29016
29017
29018
29019
29020
29021
29022
29023
29024
29025
29026
29027
29028
29029
29030
29031
29032
29033
29034
29035
29036
29037
29038
29039
29040
29041
29042
29043
29044
29045
29046
29047
29048
29049
29050
29051
29052
29053
29054
29055
29056
29057
29058
29059
29060
29061
29062
29063
29064
29065
29066
29067
29068
29069
29070
29071
29072
29073
29074
29075
29076
29077
29078
29079
29080
29081
29082
29083
29084
29085
29086
29087
29088
29089
29090
29091
29092
29093
29094
29095
29096
29097
29098
29099
29100
29101
29102
29103
29104
29105
29106
29107
29108
29109
29110
29111
29112
29113
29114
29115
29116
29117
29118
29119
29120
29121
29122
29123
29124
29125
29126
29127
29128
29129
29130
29131
29132
29133
29134
29135
29136
29137
29138
29139
29140
29141
29142
29143
29144
29145
29146
29147
29148
29149
29150
29151
29152
29153
29154
29155
29156
29157
29158
29159
29160
29161
29162
29163
29164
29165
29166
29167
29168
29169
29170
29171
29172
29173
29174
29175
29176
29177
29178
29179
29180
29181
29182
29183
29184
29185
29186
29187
29188
29189
29190
29191
29192
29193
29194
29195
29196
29197
29198
29199
29200
29201
29202
29203
29204
29205
29206
29207
29208
29209
29210
29211
29212
29213
29214
29215
29216
29217
29218
29219
29220
29221
29222
29223
29224
29225
29226
29227
29228
29229
29230
29231
29232
29233
29234
29235
29236
29237
29238
29239
29240
29241
29242
29243
29244
29245
29246
29247
29248
29249
29250
29251
29252
29253
29254
29255
29256
29257
29258
29259
29260
29261
29262
29263
29264
29265
29266
29267
29268
29269
29270
29271
29272
29273
29274
29275
29276
29277
29278
29279
29280
29281
29282
29283
29284
29285
29286
29287
29288
29289
29290
29291
29292
29293
29294
29295
29296
29297
29298
29299
29300
29301
29302
29303
29304
29305
29306
29307
29308
29309
29310
29311
29312
29313
29314
29315
29316
29317
29318
29319
29320
29321
29322
29323
29324
29325
29326
29327
29328
29329
29330
29331
29332
29333
29334
29335
29336
29337
29338
29339
29340
29341
29342
29343
29344
29345
29346
29347
29348
29349
29350
29351
29352
29353
29354
29355
29356
29357
29358
29359
29360
29361
29362
29363
29364
29365
29366
29367
29368
29369
29370
29371
29372
29373
29374
29375
29376
29377
29378
29379
29380
29381
29382
29383
29384
29385
29386
29387
29388
29389
29390
29391
29392
29393
29394
29395
29396
29397
29398
29399
29400
29401
29402
29403
29404
29405
29406
29407
29408
29409
29410
29411
29412
29413
29414
29415
29416
29417
29418
29419
29420
29421
29422
29423
29424
29425
29426
29427
29428
29429
29430
29431
29432
29433
29434
29435
29436
29437
29438
29439
29440
29441
29442
29443
29444
29445
29446
29447
29448
29449
29450
29451
29452
29453
29454
29455
29456
29457
29458
29459
29460
29461
29462
29463
29464
29465
29466
29467
29468
29469
29470
29471
29472
29473
29474
29475
29476
29477
29478
29479
29480
29481
29482
29483
29484
29485
29486
29487
29488
29489
29490
29491
29492
29493
29494
29495
29496
29497
29498
29499
29500
29501
29502
29503
29504
29505
29506
29507
29508
29509
29510
29511
29512
29513
29514
29515
29516
29517
29518
29519
29520
29521
29522
29523
29524
29525
29526
29527
29528
29529
29530
29531
29532
29533
29534
29535
29536
29537
29538
29539
29540
29541
29542
29543
29544
29545
29546
29547
29548
29549
29550
29551
29552
29553
29554
29555
29556
29557
29558
29559
29560
29561
29562
29563
29564
29565
29566
29567
29568
29569
29570
29571
29572
29573
29574
29575
29576
29577
29578
29579
29580
29581
29582
29583
29584
29585
29586
29587
29588
29589
29590
29591
29592
29593
29594
29595
29596
29597
29598
29599
29600
29601
29602
29603
29604
29605
29606
29607
29608
29609
29610
29611
29612
29613
29614
29615
29616
29617
29618
29619
29620
29621
29622
29623
29624
29625
29626
29627
29628
29629
29630
29631
29632
29633
29634
29635
29636
29637
29638
29639
29640
29641
29642
29643
29644
29645
29646
29647
29648
29649
29650
29651
29652
29653
29654
29655
29656
29657
29658
29659
29660
29661
29662
29663
29664
29665
29666
29667
29668
29669
29670
29671
29672
29673
29674
29675
29676
29677
29678
29679
29680
29681
29682
29683
29684
29685
29686
29687
29688
29689
29690
29691
29692
29693
29694
29695
29696
29697
29698
29699
29700
29701
29702
29703
29704
29705
29706
29707
29708
29709
29710
29711
29712
29713
29714
29715
29716
29717
29718
29719
29720
29721
29722
29723
29724
29725
29726
29727
29728
29729
29730
29731
29732
29733
29734
29735
29736
29737
29738
29739
29740
29741
29742
29743
29744
29745
29746
29747
29748
29749
29750
29751
29752
29753
29754
29755
29756
29757
29758
29759
29760
29761
29762
29763
29764
29765
29766
29767
29768
29769
29770
29771
29772
29773
29774
29775
29776
29777
29778
29779
29780
29781
29782
29783
29784
29785
29786
29787
29788
29789
29790
29791
29792
29793
29794
29795
29796
29797
29798
29799
29800
29801
29802
29803
29804
29805
29806
29807
29808
29809
29810
29811
29812
29813
29814
29815
29816
29817
29818
29819
29820
29821
29822
29823
29824
29825
29826
29827
29828
29829
29830
29831
29832
29833
29834
29835
29836
29837
29838
29839
29840
29841
29842
29843
29844
29845
29846
29847
29848
29849
29850
29851
29852
29853
29854
29855
29856
29857
29858
29859
29860
29861
29862
29863
29864
29865
29866
29867
29868
29869
29870
29871
29872
29873
29874
29875
29876
29877
29878
29879
29880
29881
29882
29883
29884
29885
29886
29887
29888
29889
29890
29891
29892
29893
29894
29895
29896
29897
29898
29899
29900
29901
29902
29903
29904
29905
29906
29907
29908
29909
29910
29911
29912
29913
29914
29915
29916
29917
29918
29919
29920
29921
29922
29923
29924
29925
29926
29927
29928
29929
29930
29931
29932
29933
29934
29935
29936
29937
29938
29939
29940
29941
29942
29943
29944
29945
29946
29947
29948
29949
29950
29951
29952
29953
29954
29955
29956
29957
29958
29959
29960
29961
29962
29963
29964
29965
29966
29967
29968
29969
29970
29971
29972
29973
29974
29975
29976
29977
29978
29979
29980
29981
29982
29983
29984
29985
29986
29987
29988
29989
29990
29991
29992
29993
29994
29995
29996
29997
29998
29999
30000
30001
30002
30003
30004
30005
30006
30007
30008
30009
30010
30011
30012
30013
30014
30015
30016
30017
30018
30019
30020
30021
30022
30023
30024
30025
30026
30027
30028
30029
30030
30031
30032
30033
30034
30035
30036
30037
30038
30039
30040
30041
30042
30043
30044
30045
30046
30047
30048
30049
30050
30051
30052
30053
30054
30055
30056
30057
30058
30059
30060
30061
30062
30063
30064
30065
30066
30067
30068
30069
30070
30071
30072
30073
30074
30075
30076
30077
30078
30079
30080
30081
30082
30083
30084
30085
30086
30087
30088
30089
30090
30091
30092
30093
30094
30095
30096
30097
30098
30099
30100
30101
30102
30103
30104
30105
30106
30107
30108
30109
30110
30111
30112
30113
30114
30115
30116
30117
30118
30119
30120
30121
30122
30123
30124
30125
30126
30127
30128
30129
30130
30131
30132
30133
30134
30135
30136
30137
30138
30139
30140
30141
30142
30143
30144
30145
30146
30147
30148
30149
30150
30151
30152
30153
30154
30155
30156
30157
30158
30159
30160
30161
30162
30163
30164
30165
30166
30167
30168
30169
30170
30171
30172
30173
30174
30175
30176
30177
30178
30179
30180
30181
30182
30183
30184
30185
30186
30187
30188
30189
30190
30191
30192
30193
30194
30195
30196
30197
30198
30199
30200
30201
30202
30203
30204
30205
30206
30207
30208
30209
30210
30211
30212
30213
30214
30215
30216
30217
30218
30219
30220
30221
30222
30223
30224
30225
30226
30227
30228
30229
30230
30231
30232
30233
30234
30235
30236
30237
30238
30239
30240
30241
30242
30243
30244
30245
30246
30247
30248
30249
30250
30251
30252
30253
30254
30255
30256
30257
30258
30259
30260
30261
30262
30263
30264
30265
30266
30267
30268
30269
30270
30271
30272
30273
30274
30275
30276
30277
30278
30279
30280
30281
30282
30283
30284
30285
30286
30287
30288
30289
30290
30291
30292
30293
30294
30295
30296
30297
30298
30299
30300
30301
30302
30303
30304
30305
30306
30307
30308
30309
30310
30311
30312
30313
30314
30315
30316
30317
30318
30319
30320
30321
30322
30323
30324
30325
30326
30327
30328
30329
30330
30331
30332
30333
30334
30335
30336
30337
30338
30339
30340
30341
30342
30343
30344
30345
30346
30347
30348
30349
30350
30351
30352
30353
30354
30355
30356
30357
30358
30359
30360
30361
30362
30363
30364
30365
30366
30367
30368
30369
30370
30371
30372
30373
30374
30375
30376
30377
30378
30379
30380
30381
30382
30383
30384
30385
30386
30387
30388
30389
30390
30391
30392
30393
30394
30395
30396
30397
30398
30399
30400
30401
30402
30403
30404
30405
30406
30407
30408
30409
30410
30411
30412
30413
30414
30415
30416
30417
30418
30419
30420
30421
30422
30423
30424
30425
30426
30427
30428
30429
30430
30431
30432
30433
30434
30435
30436
30437
30438
30439
30440
30441
30442
30443
30444
30445
30446
30447
30448
30449
30450
30451
30452
30453
30454
30455
30456
30457
30458
30459
30460
30461
30462
30463
30464
30465
30466
30467
30468
30469
30470
30471
30472
30473
30474
30475
30476
30477
30478
30479
30480
30481
30482
30483
30484
30485
30486
30487
30488
30489
30490
30491
30492
30493
30494
30495
30496
30497
30498
30499
30500
30501
30502
30503
30504
30505
30506
30507
30508
30509
30510
30511
30512
30513
30514
30515
30516
30517
30518
30519
30520
30521
30522
30523
30524
30525
30526
30527
30528
30529
30530
30531
30532
30533
30534
30535
30536
30537
30538
30539
30540
30541
30542
30543
30544
30545
30546
30547
30548
30549
30550
30551
30552
30553
30554
30555
30556
30557
30558
30559
30560
30561
30562
30563
30564
30565
30566
30567
30568
30569
30570
30571
30572
30573
30574
30575
30576
30577
30578
30579
30580
30581
30582
30583
30584
30585
30586
30587
30588
30589
30590
30591
30592
30593
30594
30595
30596
30597
30598
30599
30600
30601
30602
30603
30604
30605
30606
30607
30608
30609
30610
30611
30612
30613
30614
30615
30616
30617
30618
30619
30620
30621
30622
30623
30624
30625
30626
30627
30628
30629
30630
30631
30632
30633
30634
30635
30636
30637
30638
30639
30640
30641
30642
30643
30644
30645
30646
30647
30648
30649
30650
30651
30652
30653
30654
30655
30656
30657
30658
30659
30660
30661
30662
30663
30664
30665
30666
30667
30668
30669
30670
30671
30672
30673
30674
30675
30676
30677
30678
30679
30680
30681
30682
30683
30684
30685
30686
30687
30688
30689
30690
30691
30692
30693
30694
30695
30696
30697
30698
30699
30700
30701
30702
30703
30704
30705
30706
30707
30708
30709
30710
30711
30712
30713
30714
30715
30716
30717
30718
30719
30720
30721
30722
30723
30724
30725
30726
30727
30728
30729
30730
30731
30732
30733
30734
30735
30736
30737
30738
30739
30740
30741
30742
30743
30744
30745
30746
30747
30748
30749
30750
30751
30752
30753
30754
30755
30756
30757
30758
30759
30760
30761
30762
30763
30764
30765
30766
30767
30768
30769
30770
30771
30772
30773
30774
30775
30776
30777
30778
30779
30780
30781
30782
30783
30784
30785
30786
30787
30788
30789
30790
30791
30792
30793
30794
30795
30796
30797
30798
30799
30800
30801
30802
30803
30804
30805
30806
30807
30808
30809
30810
30811
30812
30813
30814
30815
30816
30817
30818
30819
30820
30821
30822
30823
30824
30825
30826
30827
30828
30829
30830
30831
30832
30833
30834
30835
30836
30837
30838
30839
30840
30841
30842
30843
30844
30845
30846
30847
30848
30849
30850
30851
30852
30853
30854
30855
30856
30857
30858
30859
30860
30861
30862
30863
30864
30865
30866
30867
30868
30869
30870
30871
30872
30873
30874
30875
30876
30877
30878
30879
30880
30881
30882
30883
30884
30885
30886
30887
30888
30889
30890
30891
30892
30893
30894
30895
30896
30897
30898
30899
30900
30901
30902
30903
30904
30905
30906
30907
30908
30909
30910
30911
30912
30913
30914
30915
30916
30917
30918
30919
30920
30921
30922
30923
30924
30925
30926
30927
30928
30929
30930
30931
30932
30933
30934
30935
30936
30937
30938
30939
30940
30941
30942
30943
30944
30945
30946
30947
30948
30949
30950
30951
30952
30953
30954
30955
30956
30957
30958
30959
30960
30961
30962
30963
30964
30965
30966
30967
30968
30969
30970
30971
30972
30973
30974
30975
30976
30977
30978
30979
30980
30981
30982
30983
30984
30985
30986
30987
30988
30989
30990
30991
30992
30993
30994
30995
30996
30997
30998
30999
31000
31001
31002
31003
31004
31005
31006
31007
31008
31009
31010
31011
31012
31013
31014
31015
31016
31017
31018
31019
31020
31021
31022
31023
31024
31025
31026
31027
31028
31029
31030
31031
31032
31033
31034
31035
31036
31037
31038
31039
31040
31041
31042
31043
31044
31045
31046
31047
31048
31049
31050
31051
31052
31053
31054
31055
31056
31057
31058
31059
31060
31061
31062
31063
31064
31065
31066
31067
31068
31069
31070
31071
31072
31073
31074
31075
31076
31077
31078
31079
31080
31081
31082
31083
31084
31085
31086
31087
31088
31089
31090
31091
31092
31093
31094
31095
31096
31097
31098
31099
31100
31101
31102
31103
31104
31105
31106
31107
31108
31109
31110
31111
31112
31113
31114
31115
31116
31117
31118
31119
31120
31121
31122
31123
31124
31125
31126
31127
31128
31129
31130
31131
31132
31133
31134
31135
31136
31137
31138
31139
31140
31141
31142
31143
31144
31145
31146
31147
31148
31149
31150
31151
31152
31153
31154
31155
31156
31157
31158
31159
31160
31161
31162
31163
31164
31165
31166
31167
31168
31169
31170
31171
31172
31173
31174
31175
31176
31177
31178
31179
31180
31181
31182
31183
31184
31185
31186
31187
31188
31189
31190
31191
31192
31193
31194
31195
31196
31197
31198
31199
31200
31201
31202
31203
31204
31205
31206
31207
31208
31209
31210
31211
31212
31213
31214
31215
31216
31217
31218
31219
31220
31221
31222
31223
31224
31225
31226
31227
31228
31229
31230
31231
31232
31233
31234
31235
31236
31237
31238
31239
31240
31241
31242
31243
31244
31245
31246
31247
31248
31249
31250
31251
31252
31253
31254
31255
31256
31257
31258
31259
31260
31261
31262
31263
31264
31265
31266
31267
31268
31269
31270
31271
31272
31273
31274
31275
31276
31277
31278
31279
31280
31281
31282
31283
31284
31285
31286
31287
31288
31289
31290
31291
31292
31293
31294
31295
31296
31297
31298
31299
31300
31301
31302
31303
31304
31305
31306
31307
31308
31309
31310
31311
31312
31313
31314
31315
31316
31317
31318
31319
31320
31321
31322
31323
31324
31325
31326
31327
31328
31329
31330
31331
31332
31333
31334
31335
31336
31337
31338
31339
31340
31341
31342
31343
31344
31345
31346
31347
31348
31349
31350
31351
31352
31353
31354
31355
31356
31357
31358
31359
31360
31361
31362
31363
31364
31365
31366
31367
31368
31369
31370
31371
31372
31373
31374
31375
31376
31377
31378
31379
31380
31381
31382
31383
31384
31385
31386
31387
31388
31389
31390
31391
31392
31393
31394
31395
31396
31397
31398
31399
31400
31401
31402
31403
31404
31405
31406
31407
31408
31409
31410
31411
31412
31413
31414
31415
31416
31417
31418
31419
31420
31421
31422
31423
31424
31425
31426
31427
31428
31429
31430
31431
31432
31433
31434
31435
31436
31437
31438
31439
31440
31441
31442
31443
31444
31445
31446
31447
31448
31449
31450
31451
31452
31453
31454
31455
31456
31457
31458
31459
31460
31461
31462
31463
31464
31465
31466
31467
31468
31469
31470
31471
31472
31473
31474
31475
31476
31477
31478
31479
31480
31481
31482
31483
31484
31485
31486
31487
31488
31489
31490
31491
31492
31493
31494
31495
31496
31497
31498
31499
31500
31501
31502
31503
31504
31505
31506
31507
31508
31509
31510
31511
31512
31513
31514
31515
31516
31517
31518
31519
31520
31521
31522
31523
31524
31525
31526
31527
31528
31529
31530
31531
31532
31533
31534
31535
31536
31537
31538
31539
31540
31541
31542
31543
31544
31545
31546
31547
31548
31549
31550
31551
31552
31553
31554
31555
31556
31557
31558
31559
31560
31561
31562
31563
31564
31565
31566
31567
31568
31569
31570
31571
31572
31573
31574
31575
31576
31577
31578
31579
31580
31581
31582
31583
31584
31585
31586
31587
31588
31589
31590
31591
31592
31593
31594
31595
31596
31597
31598
31599
31600
31601
31602
31603
31604
31605
31606
31607
31608
31609
31610
31611
31612
31613
31614
31615
31616
31617
31618
31619
31620
31621
31622
31623
31624
31625
31626
31627
31628
31629
31630
31631
31632
31633
31634
31635
31636
31637
31638
31639
31640
31641
31642
31643
31644
31645
31646
31647
31648
31649
31650
31651
31652
31653
31654
31655
31656
31657
31658
31659
31660
31661
31662
31663
31664
31665
31666
31667
31668
31669
31670
31671
31672
31673
31674
31675
31676
31677
31678
31679
31680
31681
31682
31683
31684
31685
31686
31687
31688
31689
31690
31691
31692
31693
31694
31695
31696
31697
31698
31699
31700
31701
31702
31703
31704
31705
31706
31707
31708
31709
31710
31711
31712
31713
31714
31715
31716
31717
31718
31719
31720
31721
31722
31723
31724
31725
31726
31727
31728
31729
31730
31731
31732
31733
31734
31735
31736
31737
31738
31739
31740
31741
31742
31743
31744
31745
31746
31747
31748
31749
31750
31751
31752
31753
31754
31755
31756
31757
31758
31759
31760
31761
31762
31763
31764
31765
31766
31767
31768
31769
31770
31771
31772
31773
31774
31775
31776
31777
31778
31779
31780
31781
31782
31783
31784
31785
31786
31787
31788
31789
31790
31791
31792
31793
31794
31795
31796
31797
31798
31799
31800
31801
31802
31803
31804
31805
31806
31807
31808
31809
31810
31811
31812
31813
31814
31815
31816
31817
31818
31819
31820
31821
31822
31823
31824
31825
31826
31827
31828
31829
31830
31831
31832
31833
31834
31835
31836
31837
31838
31839
31840
31841
31842
31843
31844
31845
31846
31847
31848
31849
31850
31851
31852
31853
31854
31855
31856
31857
31858
31859
31860
31861
31862
31863
31864
31865
31866
31867
31868
31869
31870
31871
31872
31873
31874
31875
31876
31877
31878
31879
31880
31881
31882
31883
31884
31885
31886
31887
31888
31889
31890
31891
31892
31893
31894
31895
31896
31897
31898
31899
31900
31901
31902
31903
31904
31905
31906
31907
31908
31909
31910
31911
31912
31913
31914
31915
31916
31917
31918
31919
31920
31921
31922
31923
31924
31925
31926
31927
31928
31929
31930
31931
31932
31933
31934
31935
31936
31937
31938
31939
31940
31941
31942
31943
31944
31945
31946
31947
31948
31949
31950
31951
31952
31953
31954
31955
31956
31957
31958
31959
31960
31961
31962
31963
31964
31965
31966
31967
31968
31969
31970
31971
31972
31973
31974
31975
31976
31977
31978
31979
31980
31981
31982
31983
31984
31985
31986
31987
31988
31989
31990
31991
31992
31993
31994
31995
31996
31997
31998
31999
32000
32001
32002
32003
32004
32005
32006
32007
32008
32009
32010
32011
32012
32013
32014
32015
32016
32017
32018
32019
32020
32021
32022
32023
32024
32025
32026
32027
32028
32029
32030
32031
32032
32033
32034
32035
32036
32037
32038
32039
32040
32041
32042
32043
32044
32045
32046
32047
32048
32049
32050
32051
32052
32053
32054
32055
32056
32057
32058
32059
32060
32061
32062
32063
32064
32065
32066
32067
32068
32069
32070
32071
32072
32073
32074
32075
32076
32077
32078
32079
32080
32081
32082
32083
32084
32085
32086
32087
32088
32089
32090
32091
32092
32093
32094
32095
32096
32097
32098
32099
32100
32101
32102
32103
32104
32105
32106
32107
32108
32109
32110
32111
32112
32113
32114
32115
32116
32117
32118
32119
32120
32121
32122
32123
32124
32125
32126
32127
32128
32129
32130
32131
32132
32133
32134
32135
32136
32137
32138
32139
32140
32141
32142
32143
32144
32145
32146
32147
32148
32149
32150
32151
32152
32153
32154
32155
32156
32157
32158
32159
32160
32161
32162
32163
32164
32165
32166
32167
32168
32169
32170
32171
32172
32173
32174
32175
32176
32177
32178
32179
32180
32181
32182
32183
32184
32185
32186
32187
32188
32189
32190
32191
32192
32193
32194
32195
32196
32197
32198
32199
32200
32201
32202
32203
32204
32205
32206
32207
32208
32209
32210
32211
32212
32213
32214
32215
32216
32217
32218
32219
32220
32221
32222
32223
32224
32225
32226
32227
32228
32229
32230
32231
32232
32233
32234
32235
32236
32237
32238
32239
32240
32241
32242
32243
32244
32245
32246
32247
32248
32249
32250
32251
32252
32253
32254
32255
32256
32257
32258
32259
32260
32261
32262
32263
32264
32265
32266
32267
32268
32269
32270
32271
32272
32273
32274
32275
32276
32277
32278
32279
32280
32281
32282
32283
32284
32285
32286
32287
32288
32289
32290
32291
32292
32293
32294
32295
32296
32297
32298
32299
32300
32301
32302
32303
32304
32305
32306
32307
32308
32309
32310
32311
32312
32313
32314
32315
32316
32317
32318
32319
32320
32321
32322
32323
32324
32325
32326
32327
32328
32329
32330
32331
32332
32333
32334
32335
32336
32337
32338
32339
32340
32341
32342
32343
32344
32345
32346
32347
32348
32349
32350
32351
32352
32353
32354
32355
32356
32357
32358
32359
32360
32361
32362
32363
32364
32365
32366
32367
32368
32369
32370
32371
32372
32373
32374
32375
32376
32377
32378
32379
32380
32381
32382
32383
32384
32385
32386
32387
32388
32389
32390
32391
32392
32393
32394
32395
32396
32397
32398
32399
32400
32401
32402
32403
32404
32405
32406
32407
32408
32409
32410
32411
32412
32413
32414
32415
32416
32417
32418
32419
32420
32421
32422
32423
32424
32425
32426
32427
32428
32429
32430
32431
32432
32433
32434
32435
32436
32437
32438
32439
32440
32441
32442
32443
32444
32445
32446
32447
32448
32449
32450
32451
32452
32453
32454
32455
32456
32457
32458
32459
32460
32461
32462
32463
32464
32465
32466
32467
32468
32469
32470
32471
32472
32473
32474
32475
32476
32477
32478
|
/* Output Dwarf2 format symbol table information from GCC.
Copyright (C) 1992-2020 Free Software Foundation, Inc.
Contributed by Gary Funck (gary@intrepid.com).
Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com).
Extensively modified by Jason Merrill (jason@cygnus.com).
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* TODO: Emit .debug_line header even when there are no functions, since
the file numbers are used by .debug_info. Alternately, leave
out locations for types and decls.
Avoid talking about ctors and op= for PODs.
Factor out common prologue sequences into multiple CIEs. */
/* The first part of this file deals with the DWARF 2 frame unwind
information, which is also used by the GCC efficient exception handling
mechanism. The second part, controlled only by an #ifdef
DWARF2_DEBUGGING_INFO, deals with the other DWARF 2 debugging
information. */
/* DWARF2 Abbreviation Glossary:
CFA = Canonical Frame Address
a fixed address on the stack which identifies a call frame.
We define it to be the value of SP just before the call insn.
The CFA register and offset, which may change during the course
of the function, are used to calculate its value at runtime.
CFI = Call Frame Instruction
an instruction for the DWARF2 abstract machine
CIE = Common Information Entry
information describing information common to one or more FDEs
DIE = Debugging Information Entry
FDE = Frame Description Entry
information describing the stack call frame, in particular,
how to restore registers
DW_CFA_... = DWARF2 CFA call frame instruction
DW_TAG_... = DWARF2 DIE tag */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "target.h"
#include "function.h"
#include "rtl.h"
#include "tree.h"
#include "memmodel.h"
#include "tm_p.h"
#include "stringpool.h"
#include "insn-config.h"
#include "ira.h"
#include "cgraph.h"
#include "diagnostic.h"
#include "fold-const.h"
#include "stor-layout.h"
#include "varasm.h"
#include "version.h"
#include "flags.h"
#include "rtlhash.h"
#include "reload.h"
#include "output.h"
#include "expr.h"
#include "dwarf2out.h"
#include "dwarf2asm.h"
#include "toplev.h"
#include "md5.h"
#include "tree-pretty-print.h"
#include "print-rtl.h"
#include "debug.h"
#include "common/common-target.h"
#include "langhooks.h"
#include "lra.h"
#include "dumpfile.h"
#include "opts.h"
#include "tree-dfa.h"
#include "gdb/gdb-index.h"
#include "rtl-iter.h"
#include "stringpool.h"
#include "attribs.h"
#include "file-prefix-map.h" /* remap_debug_filename() */
static void dwarf2out_source_line (unsigned int, unsigned int, const char *,
int, bool);
static rtx_insn *last_var_location_insn;
static rtx_insn *cached_next_real_insn;
static void dwarf2out_decl (tree);
static bool is_redundant_typedef (const_tree);
#ifndef XCOFF_DEBUGGING_INFO
#define XCOFF_DEBUGGING_INFO 0
#endif
#ifndef HAVE_XCOFF_DWARF_EXTRAS
#define HAVE_XCOFF_DWARF_EXTRAS 0
#endif
#ifdef VMS_DEBUGGING_INFO
int vms_file_stats_name (const char *, long long *, long *, char *, int *);
/* Define this macro to be a nonzero value if the directory specifications
which are output in the debug info should end with a separator. */
#define DWARF2_DIR_SHOULD_END_WITH_SEPARATOR 1
/* Define this macro to evaluate to a nonzero value if GCC should refrain
from generating indirect strings in DWARF2 debug information, for instance
if your target is stuck with an old version of GDB that is unable to
process them properly or uses VMS Debug. */
#define DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET 1
#else
#define DWARF2_DIR_SHOULD_END_WITH_SEPARATOR 0
#define DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET 0
#endif
/* ??? Poison these here until it can be done generically. They've been
totally replaced in this file; make sure it stays that way. */
#undef DWARF2_UNWIND_INFO
#undef DWARF2_FRAME_INFO
#if (GCC_VERSION >= 3000)
#pragma GCC poison DWARF2_UNWIND_INFO DWARF2_FRAME_INFO
#endif
/* The size of the target's pointer type. */
#ifndef PTR_SIZE
#define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
#endif
/* Array of RTXes referenced by the debugging information, which therefore
must be kept around forever. */
static GTY(()) vec<rtx, va_gc> *used_rtx_array;
/* A pointer to the base of a list of incomplete types which might be
completed at some later time. incomplete_types_list needs to be a
vec<tree, va_gc> *because we want to tell the garbage collector about
it. */
static GTY(()) vec<tree, va_gc> *incomplete_types;
/* Pointers to various DWARF2 sections. */
static GTY(()) section *debug_info_section;
static GTY(()) section *debug_skeleton_info_section;
static GTY(()) section *debug_abbrev_section;
static GTY(()) section *debug_skeleton_abbrev_section;
static GTY(()) section *debug_aranges_section;
static GTY(()) section *debug_addr_section;
static GTY(()) section *debug_macinfo_section;
static const char *debug_macinfo_section_name;
static unsigned macinfo_label_base = 1;
static GTY(()) section *debug_line_section;
static GTY(()) section *debug_skeleton_line_section;
static GTY(()) section *debug_loc_section;
static GTY(()) section *debug_pubnames_section;
static GTY(()) section *debug_pubtypes_section;
static GTY(()) section *debug_str_section;
static GTY(()) section *debug_line_str_section;
static GTY(()) section *debug_str_dwo_section;
static GTY(()) section *debug_str_offsets_section;
static GTY(()) section *debug_ranges_section;
static GTY(()) section *debug_frame_section;
/* Maximum size (in bytes) of an artificially generated label. */
#define MAX_ARTIFICIAL_LABEL_BYTES 40
/* According to the (draft) DWARF 3 specification, the initial length
should either be 4 or 12 bytes. When it's 12 bytes, the first 4
bytes are 0xffffffff, followed by the length stored in the next 8
bytes.
However, the SGI/MIPS ABI uses an initial length which is equal to
DWARF_OFFSET_SIZE. It is defined (elsewhere) accordingly. */
#ifndef DWARF_INITIAL_LENGTH_SIZE
#define DWARF_INITIAL_LENGTH_SIZE (DWARF_OFFSET_SIZE == 4 ? 4 : 12)
#endif
#ifndef DWARF_INITIAL_LENGTH_SIZE_STR
#define DWARF_INITIAL_LENGTH_SIZE_STR (DWARF_OFFSET_SIZE == 4 ? "-4" : "-12")
#endif
/* Round SIZE up to the nearest BOUNDARY. */
#define DWARF_ROUND(SIZE,BOUNDARY) \
((((SIZE) + (BOUNDARY) - 1) / (BOUNDARY)) * (BOUNDARY))
/* CIE identifier. */
#if HOST_BITS_PER_WIDE_INT >= 64
#define DWARF_CIE_ID \
(unsigned HOST_WIDE_INT) (DWARF_OFFSET_SIZE == 4 ? DW_CIE_ID : DW64_CIE_ID)
#else
#define DWARF_CIE_ID DW_CIE_ID
#endif
/* A vector for a table that contains frame description
information for each routine. */
#define NOT_INDEXED (-1U)
#define NO_INDEX_ASSIGNED (-2U)
static GTY(()) vec<dw_fde_ref, va_gc> *fde_vec;
struct GTY((for_user)) indirect_string_node {
const char *str;
unsigned int refcount;
enum dwarf_form form;
char *label;
unsigned int index;
};
struct indirect_string_hasher : ggc_ptr_hash<indirect_string_node>
{
typedef const char *compare_type;
static hashval_t hash (indirect_string_node *);
static bool equal (indirect_string_node *, const char *);
};
static GTY (()) hash_table<indirect_string_hasher> *debug_str_hash;
static GTY (()) hash_table<indirect_string_hasher> *debug_line_str_hash;
/* With split_debug_info, both the comp_dir and dwo_name go in the
main object file, rather than the dwo, similar to the force_direct
parameter elsewhere but with additional complications:
1) The string is needed in both the main object file and the dwo.
That is, the comp_dir and dwo_name will appear in both places.
2) Strings can use four forms: DW_FORM_string, DW_FORM_strp,
DW_FORM_line_strp or DW_FORM_strx/GNU_str_index.
3) GCC chooses the form to use late, depending on the size and
reference count.
Rather than forcing the all debug string handling functions and
callers to deal with these complications, simply use a separate,
special-cased string table for any attribute that should go in the
main object file. This limits the complexity to just the places
that need it. */
static GTY (()) hash_table<indirect_string_hasher> *skeleton_debug_str_hash;
static GTY(()) int dw2_string_counter;
/* True if the compilation unit places functions in more than one section. */
static GTY(()) bool have_multiple_function_sections = false;
/* Whether the default text and cold text sections have been used at all. */
static GTY(()) bool text_section_used = false;
static GTY(()) bool cold_text_section_used = false;
/* The default cold text section. */
static GTY(()) section *cold_text_section;
/* The DIE for C++14 'auto' in a function return type. */
static GTY(()) dw_die_ref auto_die;
/* The DIE for C++14 'decltype(auto)' in a function return type. */
static GTY(()) dw_die_ref decltype_auto_die;
/* Forward declarations for functions defined in this file. */
static void output_call_frame_info (int);
static void dwarf2out_note_section_used (void);
/* Personality decl of current unit. Used only when assembler does not support
personality CFI. */
static GTY(()) rtx current_unit_personality;
/* Whether an eh_frame section is required. */
static GTY(()) bool do_eh_frame = false;
/* .debug_rnglists next index. */
static unsigned int rnglist_idx;
/* Data and reference forms for relocatable data. */
#define DW_FORM_data (DWARF_OFFSET_SIZE == 8 ? DW_FORM_data8 : DW_FORM_data4)
#define DW_FORM_ref (DWARF_OFFSET_SIZE == 8 ? DW_FORM_ref8 : DW_FORM_ref4)
#ifndef DEBUG_FRAME_SECTION
#define DEBUG_FRAME_SECTION ".debug_frame"
#endif
#ifndef FUNC_BEGIN_LABEL
#define FUNC_BEGIN_LABEL "LFB"
#endif
#ifndef FUNC_SECOND_SECT_LABEL
#define FUNC_SECOND_SECT_LABEL "LFSB"
#endif
#ifndef FUNC_END_LABEL
#define FUNC_END_LABEL "LFE"
#endif
#ifndef PROLOGUE_END_LABEL
#define PROLOGUE_END_LABEL "LPE"
#endif
#ifndef EPILOGUE_BEGIN_LABEL
#define EPILOGUE_BEGIN_LABEL "LEB"
#endif
#ifndef FRAME_BEGIN_LABEL
#define FRAME_BEGIN_LABEL "Lframe"
#endif
#define CIE_AFTER_SIZE_LABEL "LSCIE"
#define CIE_END_LABEL "LECIE"
#define FDE_LABEL "LSFDE"
#define FDE_AFTER_SIZE_LABEL "LASFDE"
#define FDE_END_LABEL "LEFDE"
#define LINE_NUMBER_BEGIN_LABEL "LSLT"
#define LINE_NUMBER_END_LABEL "LELT"
#define LN_PROLOG_AS_LABEL "LASLTP"
#define LN_PROLOG_END_LABEL "LELTP"
#define DIE_LABEL_PREFIX "DW"
/* Match the base name of a file to the base name of a compilation unit. */
static int
matches_main_base (const char *path)
{
/* Cache the last query. */
static const char *last_path = NULL;
static int last_match = 0;
if (path != last_path)
{
const char *base;
int length = base_of_path (path, &base);
last_path = path;
last_match = (length == main_input_baselength
&& memcmp (base, main_input_basename, length) == 0);
}
return last_match;
}
#ifdef DEBUG_DEBUG_STRUCT
static int
dump_struct_debug (tree type, enum debug_info_usage usage,
enum debug_struct_file criterion, int generic,
int matches, int result)
{
/* Find the type name. */
tree type_decl = TYPE_STUB_DECL (type);
tree t = type_decl;
const char *name = 0;
if (TREE_CODE (t) == TYPE_DECL)
t = DECL_NAME (t);
if (t)
name = IDENTIFIER_POINTER (t);
fprintf (stderr, " struct %d %s %s %s %s %d %p %s\n",
criterion,
DECL_IN_SYSTEM_HEADER (type_decl) ? "sys" : "usr",
matches ? "bas" : "hdr",
generic ? "gen" : "ord",
usage == DINFO_USAGE_DFN ? ";" :
usage == DINFO_USAGE_DIR_USE ? "." : "*",
result,
(void*) type_decl, name);
return result;
}
#define DUMP_GSTRUCT(type, usage, criterion, generic, matches, result) \
dump_struct_debug (type, usage, criterion, generic, matches, result)
#else
#define DUMP_GSTRUCT(type, usage, criterion, generic, matches, result) \
(result)
#endif
/* Get the number of HOST_WIDE_INTs needed to represent the precision
of the number. Some constants have a large uniform precision, so
we get the precision needed for the actual value of the number. */
static unsigned int
get_full_len (const wide_int &op)
{
int prec = wi::min_precision (op, UNSIGNED);
return ((prec + HOST_BITS_PER_WIDE_INT - 1)
/ HOST_BITS_PER_WIDE_INT);
}
static bool
should_emit_struct_debug (tree type, enum debug_info_usage usage)
{
if (debug_info_level <= DINFO_LEVEL_TERSE)
return false;
enum debug_struct_file criterion;
tree type_decl;
bool generic = lang_hooks.types.generic_p (type);
if (generic)
criterion = debug_struct_generic[usage];
else
criterion = debug_struct_ordinary[usage];
if (criterion == DINFO_STRUCT_FILE_NONE)
return DUMP_GSTRUCT (type, usage, criterion, generic, false, false);
if (criterion == DINFO_STRUCT_FILE_ANY)
return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);
type_decl = TYPE_STUB_DECL (TYPE_MAIN_VARIANT (type));
if (type_decl != NULL)
{
if (criterion == DINFO_STRUCT_FILE_SYS && DECL_IN_SYSTEM_HEADER (type_decl))
return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);
if (matches_main_base (DECL_SOURCE_FILE (type_decl)))
return DUMP_GSTRUCT (type, usage, criterion, generic, true, true);
}
return DUMP_GSTRUCT (type, usage, criterion, generic, false, false);
}
/* Switch [BACK] to eh_frame_section. If we don't have an eh_frame_section,
switch to the data section instead, and write out a synthetic start label
for collect2 the first time around. */
static void
switch_to_eh_frame_section (bool back ATTRIBUTE_UNUSED)
{
if (eh_frame_section == 0)
{
int flags;
if (EH_TABLES_CAN_BE_READ_ONLY)
{
int fde_encoding;
int per_encoding;
int lsda_encoding;
fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1,
/*global=*/0);
per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2,
/*global=*/1);
lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0,
/*global=*/0);
flags = ((! flag_pic
|| ((fde_encoding & 0x70) != DW_EH_PE_absptr
&& (fde_encoding & 0x70) != DW_EH_PE_aligned
&& (per_encoding & 0x70) != DW_EH_PE_absptr
&& (per_encoding & 0x70) != DW_EH_PE_aligned
&& (lsda_encoding & 0x70) != DW_EH_PE_absptr
&& (lsda_encoding & 0x70) != DW_EH_PE_aligned))
? 0 : SECTION_WRITE);
}
else
flags = SECTION_WRITE;
#ifdef EH_FRAME_SECTION_NAME
eh_frame_section = get_section (EH_FRAME_SECTION_NAME, flags, NULL);
#else
eh_frame_section = ((flags == SECTION_WRITE)
? data_section : readonly_data_section);
#endif /* EH_FRAME_SECTION_NAME */
}
switch_to_section (eh_frame_section);
#ifdef EH_FRAME_THROUGH_COLLECT2
/* We have no special eh_frame section. Emit special labels to guide
collect2. */
if (!back)
{
tree label = get_file_function_name ("F");
ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
targetm.asm_out.globalize_label (asm_out_file,
IDENTIFIER_POINTER (label));
ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
}
#endif
}
/* Switch [BACK] to the eh or debug frame table section, depending on
FOR_EH. */
static void
switch_to_frame_table_section (int for_eh, bool back)
{
if (for_eh)
switch_to_eh_frame_section (back);
else
{
if (!debug_frame_section)
debug_frame_section = get_section (DEBUG_FRAME_SECTION,
SECTION_DEBUG, NULL);
switch_to_section (debug_frame_section);
}
}
/* Describe for the GTY machinery what parts of dw_cfi_oprnd1 are used. */
enum dw_cfi_oprnd_type
dw_cfi_oprnd1_desc (enum dwarf_call_frame_info cfi)
{
switch (cfi)
{
case DW_CFA_nop:
case DW_CFA_GNU_window_save:
case DW_CFA_remember_state:
case DW_CFA_restore_state:
return dw_cfi_oprnd_unused;
case DW_CFA_set_loc:
case DW_CFA_advance_loc1:
case DW_CFA_advance_loc2:
case DW_CFA_advance_loc4:
case DW_CFA_MIPS_advance_loc8:
return dw_cfi_oprnd_addr;
case DW_CFA_offset:
case DW_CFA_offset_extended:
case DW_CFA_def_cfa:
case DW_CFA_offset_extended_sf:
case DW_CFA_def_cfa_sf:
case DW_CFA_restore:
case DW_CFA_restore_extended:
case DW_CFA_undefined:
case DW_CFA_same_value:
case DW_CFA_def_cfa_register:
case DW_CFA_register:
case DW_CFA_expression:
case DW_CFA_val_expression:
return dw_cfi_oprnd_reg_num;
case DW_CFA_def_cfa_offset:
case DW_CFA_GNU_args_size:
case DW_CFA_def_cfa_offset_sf:
return dw_cfi_oprnd_offset;
case DW_CFA_def_cfa_expression:
return dw_cfi_oprnd_loc;
default:
gcc_unreachable ();
}
}
/* Describe for the GTY machinery what parts of dw_cfi_oprnd2 are used. */
enum dw_cfi_oprnd_type
dw_cfi_oprnd2_desc (enum dwarf_call_frame_info cfi)
{
switch (cfi)
{
case DW_CFA_def_cfa:
case DW_CFA_def_cfa_sf:
case DW_CFA_offset:
case DW_CFA_offset_extended_sf:
case DW_CFA_offset_extended:
return dw_cfi_oprnd_offset;
case DW_CFA_register:
return dw_cfi_oprnd_reg_num;
case DW_CFA_expression:
case DW_CFA_val_expression:
return dw_cfi_oprnd_loc;
case DW_CFA_def_cfa_expression:
return dw_cfi_oprnd_cfa_loc;
default:
return dw_cfi_oprnd_unused;
}
}
/* Output one FDE. */
static void
output_fde (dw_fde_ref fde, bool for_eh, bool second,
char *section_start_label, int fde_encoding, char *augmentation,
bool any_lsda_needed, int lsda_encoding)
{
const char *begin, *end;
static unsigned int j;
char l1[MAX_ARTIFICIAL_LABEL_BYTES], l2[MAX_ARTIFICIAL_LABEL_BYTES];
targetm.asm_out.emit_unwind_label (asm_out_file, fde->decl, for_eh,
/* empty */ 0);
targetm.asm_out.internal_label (asm_out_file, FDE_LABEL,
for_eh + j);
ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + j);
ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + j);
if (!XCOFF_DEBUGGING_INFO || for_eh)
{
if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4 && !for_eh)
dw2_asm_output_data (4, 0xffffffff, "Initial length escape value"
" indicating 64-bit DWARF extension");
dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
"FDE Length");
}
ASM_OUTPUT_LABEL (asm_out_file, l1);
if (for_eh)
dw2_asm_output_delta (4, l1, section_start_label, "FDE CIE offset");
else
dw2_asm_output_offset (DWARF_OFFSET_SIZE, section_start_label,
debug_frame_section, "FDE CIE offset");
begin = second ? fde->dw_fde_second_begin : fde->dw_fde_begin;
end = second ? fde->dw_fde_second_end : fde->dw_fde_end;
if (for_eh)
{
rtx sym_ref = gen_rtx_SYMBOL_REF (Pmode, begin);
SYMBOL_REF_FLAGS (sym_ref) |= SYMBOL_FLAG_LOCAL;
dw2_asm_output_encoded_addr_rtx (fde_encoding, sym_ref, false,
"FDE initial location");
dw2_asm_output_delta (size_of_encoded_value (fde_encoding),
end, begin, "FDE address range");
}
else
{
dw2_asm_output_addr (DWARF2_ADDR_SIZE, begin, "FDE initial location");
dw2_asm_output_delta (DWARF2_ADDR_SIZE, end, begin, "FDE address range");
}
if (augmentation[0])
{
if (any_lsda_needed)
{
int size = size_of_encoded_value (lsda_encoding);
if (lsda_encoding == DW_EH_PE_aligned)
{
int offset = ( 4 /* Length */
+ 4 /* CIE offset */
+ 2 * size_of_encoded_value (fde_encoding)
+ 1 /* Augmentation size */ );
int pad = -offset & (PTR_SIZE - 1);
size += pad;
gcc_assert (size_of_uleb128 (size) == 1);
}
dw2_asm_output_data_uleb128 (size, "Augmentation size");
if (fde->uses_eh_lsda)
{
ASM_GENERATE_INTERNAL_LABEL (l1, second ? "LLSDAC" : "LLSDA",
fde->funcdef_number);
dw2_asm_output_encoded_addr_rtx (lsda_encoding,
gen_rtx_SYMBOL_REF (Pmode, l1),
false,
"Language Specific Data Area");
}
else
{
if (lsda_encoding == DW_EH_PE_aligned)
ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
dw2_asm_output_data (size_of_encoded_value (lsda_encoding), 0,
"Language Specific Data Area (none)");
}
}
else
dw2_asm_output_data_uleb128 (0, "Augmentation size");
}
/* Loop through the Call Frame Instructions associated with this FDE. */
fde->dw_fde_current_label = begin;
{
size_t from, until, i;
from = 0;
until = vec_safe_length (fde->dw_fde_cfi);
if (fde->dw_fde_second_begin == NULL)
;
else if (!second)
until = fde->dw_fde_switch_cfi_index;
else
from = fde->dw_fde_switch_cfi_index;
for (i = from; i < until; i++)
output_cfi ((*fde->dw_fde_cfi)[i], fde, for_eh);
}
/* If we are to emit a ref/link from function bodies to their frame tables,
do it now. This is typically performed to make sure that tables
associated with functions are dragged with them and not discarded in
garbage collecting links. We need to do this on a per function basis to
cope with -ffunction-sections. */
#ifdef ASM_OUTPUT_DWARF_TABLE_REF
/* Switch to the function section, emit the ref to the tables, and
switch *back* into the table section. */
switch_to_section (function_section (fde->decl));
ASM_OUTPUT_DWARF_TABLE_REF (section_start_label);
switch_to_frame_table_section (for_eh, true);
#endif
/* Pad the FDE out to an address sized boundary. */
ASM_OUTPUT_ALIGN (asm_out_file,
floor_log2 ((for_eh ? PTR_SIZE : DWARF2_ADDR_SIZE)));
ASM_OUTPUT_LABEL (asm_out_file, l2);
j += 2;
}
/* Return true if frame description entry FDE is needed for EH. */
static bool
fde_needed_for_eh_p (dw_fde_ref fde)
{
if (flag_asynchronous_unwind_tables)
return true;
if (TARGET_USES_WEAK_UNWIND_INFO && DECL_WEAK (fde->decl))
return true;
if (fde->uses_eh_lsda)
return true;
/* If exceptions are enabled, we have collected nothrow info. */
if (flag_exceptions && (fde->all_throwers_are_sibcalls || fde->nothrow))
return false;
return true;
}
/* Output the call frame information used to record information
that relates to calculating the frame pointer, and records the
location of saved registers. */
static void
output_call_frame_info (int for_eh)
{
unsigned int i;
dw_fde_ref fde;
dw_cfi_ref cfi;
char l1[MAX_ARTIFICIAL_LABEL_BYTES], l2[MAX_ARTIFICIAL_LABEL_BYTES];
char section_start_label[MAX_ARTIFICIAL_LABEL_BYTES];
bool any_lsda_needed = false;
char augmentation[6];
int augmentation_size;
int fde_encoding = DW_EH_PE_absptr;
int per_encoding = DW_EH_PE_absptr;
int lsda_encoding = DW_EH_PE_absptr;
int return_reg;
rtx personality = NULL;
int dw_cie_version;
/* Don't emit a CIE if there won't be any FDEs. */
if (!fde_vec)
return;
/* Nothing to do if the assembler's doing it all. */
if (dwarf2out_do_cfi_asm ())
return;
/* If we don't have any functions we'll want to unwind out of, don't emit
any EH unwind information. If we make FDEs linkonce, we may have to
emit an empty label for an FDE that wouldn't otherwise be emitted. We
want to avoid having an FDE kept around when the function it refers to
is discarded. Example where this matters: a primary function template
in C++ requires EH information, an explicit specialization doesn't. */
if (for_eh)
{
bool any_eh_needed = false;
FOR_EACH_VEC_ELT (*fde_vec, i, fde)
{
if (fde->uses_eh_lsda)
any_eh_needed = any_lsda_needed = true;
else if (fde_needed_for_eh_p (fde))
any_eh_needed = true;
else if (TARGET_USES_WEAK_UNWIND_INFO)
targetm.asm_out.emit_unwind_label (asm_out_file, fde->decl, 1, 1);
}
if (!any_eh_needed)
return;
}
/* We're going to be generating comments, so turn on app. */
if (flag_debug_asm)
app_enable ();
/* Switch to the proper frame section, first time. */
switch_to_frame_table_section (for_eh, false);
ASM_GENERATE_INTERNAL_LABEL (section_start_label, FRAME_BEGIN_LABEL, for_eh);
ASM_OUTPUT_LABEL (asm_out_file, section_start_label);
/* Output the CIE. */
ASM_GENERATE_INTERNAL_LABEL (l1, CIE_AFTER_SIZE_LABEL, for_eh);
ASM_GENERATE_INTERNAL_LABEL (l2, CIE_END_LABEL, for_eh);
if (!XCOFF_DEBUGGING_INFO || for_eh)
{
if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4 && !for_eh)
dw2_asm_output_data (4, 0xffffffff,
"Initial length escape value indicating 64-bit DWARF extension");
dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
"Length of Common Information Entry");
}
ASM_OUTPUT_LABEL (asm_out_file, l1);
/* Now that the CIE pointer is PC-relative for EH,
use 0 to identify the CIE. */
dw2_asm_output_data ((for_eh ? 4 : DWARF_OFFSET_SIZE),
(for_eh ? 0 : DWARF_CIE_ID),
"CIE Identifier Tag");
/* Use the CIE version 3 for DWARF3; allow DWARF2 to continue to
use CIE version 1, unless that would produce incorrect results
due to overflowing the return register column. */
return_reg = DWARF2_FRAME_REG_OUT (DWARF_FRAME_RETURN_COLUMN, for_eh);
dw_cie_version = 1;
if (return_reg >= 256 || dwarf_version > 2)
dw_cie_version = 3;
dw2_asm_output_data (1, dw_cie_version, "CIE Version");
augmentation[0] = 0;
augmentation_size = 0;
personality = current_unit_personality;
if (for_eh)
{
char *p;
/* Augmentation:
z Indicates that a uleb128 is present to size the
augmentation section.
L Indicates the encoding (and thus presence) of
an LSDA pointer in the FDE augmentation.
R Indicates a non-default pointer encoding for
FDE code pointers.
P Indicates the presence of an encoding + language
personality routine in the CIE augmentation. */
fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0);
per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1);
lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0);
p = augmentation + 1;
if (personality)
{
*p++ = 'P';
augmentation_size += 1 + size_of_encoded_value (per_encoding);
assemble_external_libcall (personality);
}
if (any_lsda_needed)
{
*p++ = 'L';
augmentation_size += 1;
}
if (fde_encoding != DW_EH_PE_absptr)
{
*p++ = 'R';
augmentation_size += 1;
}
if (p > augmentation + 1)
{
augmentation[0] = 'z';
*p = '\0';
}
/* Ug. Some platforms can't do unaligned dynamic relocations at all. */
if (personality && per_encoding == DW_EH_PE_aligned)
{
int offset = ( 4 /* Length */
+ 4 /* CIE Id */
+ 1 /* CIE version */
+ strlen (augmentation) + 1 /* Augmentation */
+ size_of_uleb128 (1) /* Code alignment */
+ size_of_sleb128 (DWARF_CIE_DATA_ALIGNMENT)
+ 1 /* RA column */
+ 1 /* Augmentation size */
+ 1 /* Personality encoding */ );
int pad = -offset & (PTR_SIZE - 1);
augmentation_size += pad;
/* Augmentations should be small, so there's scarce need to
iterate for a solution. Die if we exceed one uleb128 byte. */
gcc_assert (size_of_uleb128 (augmentation_size) == 1);
}
}
dw2_asm_output_nstring (augmentation, -1, "CIE Augmentation");
if (dw_cie_version >= 4)
{
dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "CIE Address Size");
dw2_asm_output_data (1, 0, "CIE Segment Size");
}
dw2_asm_output_data_uleb128 (1, "CIE Code Alignment Factor");
dw2_asm_output_data_sleb128 (DWARF_CIE_DATA_ALIGNMENT,
"CIE Data Alignment Factor");
if (dw_cie_version == 1)
dw2_asm_output_data (1, return_reg, "CIE RA Column");
else
dw2_asm_output_data_uleb128 (return_reg, "CIE RA Column");
if (augmentation[0])
{
dw2_asm_output_data_uleb128 (augmentation_size, "Augmentation size");
if (personality)
{
dw2_asm_output_data (1, per_encoding, "Personality (%s)",
eh_data_format_name (per_encoding));
dw2_asm_output_encoded_addr_rtx (per_encoding,
personality,
true, NULL);
}
if (any_lsda_needed)
dw2_asm_output_data (1, lsda_encoding, "LSDA Encoding (%s)",
eh_data_format_name (lsda_encoding));
if (fde_encoding != DW_EH_PE_absptr)
dw2_asm_output_data (1, fde_encoding, "FDE Encoding (%s)",
eh_data_format_name (fde_encoding));
}
FOR_EACH_VEC_ELT (*cie_cfi_vec, i, cfi)
output_cfi (cfi, NULL, for_eh);
/* Pad the CIE out to an address sized boundary. */
ASM_OUTPUT_ALIGN (asm_out_file,
floor_log2 (for_eh ? PTR_SIZE : DWARF2_ADDR_SIZE));
ASM_OUTPUT_LABEL (asm_out_file, l2);
/* Loop through all of the FDE's. */
FOR_EACH_VEC_ELT (*fde_vec, i, fde)
{
unsigned int k;
/* Don't emit EH unwind info for leaf functions that don't need it. */
if (for_eh && !fde_needed_for_eh_p (fde))
continue;
for (k = 0; k < (fde->dw_fde_second_begin ? 2 : 1); k++)
output_fde (fde, for_eh, k, section_start_label, fde_encoding,
augmentation, any_lsda_needed, lsda_encoding);
}
if (for_eh && targetm.terminate_dw2_eh_frame_info)
dw2_asm_output_data (4, 0, "End of Table");
/* Turn off app to make assembly quicker. */
if (flag_debug_asm)
app_disable ();
}
/* Emit .cfi_startproc and .cfi_personality/.cfi_lsda if needed. */
static void
dwarf2out_do_cfi_startproc (bool second)
{
int enc;
rtx ref;
fprintf (asm_out_file, "\t.cfi_startproc\n");
targetm.asm_out.post_cfi_startproc (asm_out_file, current_function_decl);
/* .cfi_personality and .cfi_lsda are only relevant to DWARF2
eh unwinders. */
if (targetm_common.except_unwind_info (&global_options) != UI_DWARF2)
return;
rtx personality = get_personality_function (current_function_decl);
if (personality)
{
enc = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1);
ref = personality;
/* ??? The GAS support isn't entirely consistent. We have to
handle indirect support ourselves, but PC-relative is done
in the assembler. Further, the assembler can't handle any
of the weirder relocation types. */
if (enc & DW_EH_PE_indirect)
{
if (targetm.asm_out.make_eh_symbol_indirect != NULL)
ref = targetm.asm_out.make_eh_symbol_indirect (ref, true);
else
ref = dw2_force_const_mem (ref, true);
}
fprintf (asm_out_file, "\t.cfi_personality %#x,", enc);
output_addr_const (asm_out_file, ref);
fputc ('\n', asm_out_file);
}
if (crtl->uses_eh_lsda)
{
char lab[MAX_ARTIFICIAL_LABEL_BYTES];
enc = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0);
ASM_GENERATE_INTERNAL_LABEL (lab, second ? "LLSDAC" : "LLSDA",
current_function_funcdef_no);
ref = gen_rtx_SYMBOL_REF (Pmode, lab);
SYMBOL_REF_FLAGS (ref) = SYMBOL_FLAG_LOCAL;
if (enc & DW_EH_PE_indirect)
{
if (targetm.asm_out.make_eh_symbol_indirect != NULL)
ref = targetm.asm_out.make_eh_symbol_indirect (ref, true);
else
ref = dw2_force_const_mem (ref, true);
}
fprintf (asm_out_file, "\t.cfi_lsda %#x,", enc);
output_addr_const (asm_out_file, ref);
fputc ('\n', asm_out_file);
}
}
/* Allocate CURRENT_FDE. Immediately initialize all we can, noting that
this allocation may be done before pass_final. */
dw_fde_ref
dwarf2out_alloc_current_fde (void)
{
dw_fde_ref fde;
fde = ggc_cleared_alloc<dw_fde_node> ();
fde->decl = current_function_decl;
fde->funcdef_number = current_function_funcdef_no;
fde->fde_index = vec_safe_length (fde_vec);
fde->all_throwers_are_sibcalls = crtl->all_throwers_are_sibcalls;
fde->uses_eh_lsda = crtl->uses_eh_lsda;
fde->nothrow = crtl->nothrow;
fde->drap_reg = INVALID_REGNUM;
fde->vdrap_reg = INVALID_REGNUM;
/* Record the FDE associated with this function. */
cfun->fde = fde;
vec_safe_push (fde_vec, fde);
return fde;
}
/* Output a marker (i.e. a label) for the beginning of a function, before
the prologue. */
void
dwarf2out_begin_prologue (unsigned int line ATTRIBUTE_UNUSED,
unsigned int column ATTRIBUTE_UNUSED,
const char *file ATTRIBUTE_UNUSED)
{
char label[MAX_ARTIFICIAL_LABEL_BYTES];
char * dup_label;
dw_fde_ref fde;
section *fnsec;
bool do_frame;
current_function_func_begin_label = NULL;
do_frame = dwarf2out_do_frame ();
/* ??? current_function_func_begin_label is also used by except.c for
call-site information. We must emit this label if it might be used. */
if (!do_frame
&& (!flag_exceptions
|| targetm_common.except_unwind_info (&global_options) == UI_SJLJ))
return;
fnsec = function_section (current_function_decl);
switch_to_section (fnsec);
ASM_GENERATE_INTERNAL_LABEL (label, FUNC_BEGIN_LABEL,
current_function_funcdef_no);
ASM_OUTPUT_DEBUG_LABEL (asm_out_file, FUNC_BEGIN_LABEL,
current_function_funcdef_no);
dup_label = xstrdup (label);
current_function_func_begin_label = dup_label;
/* We can elide FDE allocation if we're not emitting frame unwind info. */
if (!do_frame)
return;
/* Unlike the debug version, the EH version of frame unwind info is a per-
function setting so we need to record whether we need it for the unit. */
do_eh_frame |= dwarf2out_do_eh_frame ();
/* Cater to the various TARGET_ASM_OUTPUT_MI_THUNK implementations that
emit insns as rtx but bypass the bulk of rest_of_compilation, which
would include pass_dwarf2_frame. If we've not created the FDE yet,
do so now. */
fde = cfun->fde;
if (fde == NULL)
fde = dwarf2out_alloc_current_fde ();
/* Initialize the bits of CURRENT_FDE that were not available earlier. */
fde->dw_fde_begin = dup_label;
fde->dw_fde_current_label = dup_label;
fde->in_std_section = (fnsec == text_section
|| (cold_text_section && fnsec == cold_text_section));
/* We only want to output line number information for the genuine dwarf2
prologue case, not the eh frame case. */
#ifdef DWARF2_DEBUGGING_INFO
if (file)
dwarf2out_source_line (line, column, file, 0, true);
#endif
if (dwarf2out_do_cfi_asm ())
dwarf2out_do_cfi_startproc (false);
else
{
rtx personality = get_personality_function (current_function_decl);
if (!current_unit_personality)
current_unit_personality = personality;
/* We cannot keep a current personality per function as without CFI
asm, at the point where we emit the CFI data, there is no current
function anymore. */
if (personality && current_unit_personality != personality)
sorry ("multiple EH personalities are supported only with assemblers "
"supporting %<.cfi_personality%> directive");
}
}
/* Output a marker (i.e. a label) for the end of the generated code
for a function prologue. This gets called *after* the prologue code has
been generated. */
void
dwarf2out_vms_end_prologue (unsigned int line ATTRIBUTE_UNUSED,
const char *file ATTRIBUTE_UNUSED)
{
char label[MAX_ARTIFICIAL_LABEL_BYTES];
/* Output a label to mark the endpoint of the code generated for this
function. */
ASM_GENERATE_INTERNAL_LABEL (label, PROLOGUE_END_LABEL,
current_function_funcdef_no);
ASM_OUTPUT_DEBUG_LABEL (asm_out_file, PROLOGUE_END_LABEL,
current_function_funcdef_no);
cfun->fde->dw_fde_vms_end_prologue = xstrdup (label);
}
/* Output a marker (i.e. a label) for the beginning of the generated code
for a function epilogue. This gets called *before* the prologue code has
been generated. */
void
dwarf2out_vms_begin_epilogue (unsigned int line ATTRIBUTE_UNUSED,
const char *file ATTRIBUTE_UNUSED)
{
dw_fde_ref fde = cfun->fde;
char label[MAX_ARTIFICIAL_LABEL_BYTES];
if (fde->dw_fde_vms_begin_epilogue)
return;
/* Output a label to mark the endpoint of the code generated for this
function. */
ASM_GENERATE_INTERNAL_LABEL (label, EPILOGUE_BEGIN_LABEL,
current_function_funcdef_no);
ASM_OUTPUT_DEBUG_LABEL (asm_out_file, EPILOGUE_BEGIN_LABEL,
current_function_funcdef_no);
fde->dw_fde_vms_begin_epilogue = xstrdup (label);
}
/* Output a marker (i.e. a label) for the absolute end of the generated code
for a function definition. This gets called *after* the epilogue code has
been generated. */
void
dwarf2out_end_epilogue (unsigned int line ATTRIBUTE_UNUSED,
const char *file ATTRIBUTE_UNUSED)
{
dw_fde_ref fde;
char label[MAX_ARTIFICIAL_LABEL_BYTES];
last_var_location_insn = NULL;
cached_next_real_insn = NULL;
if (dwarf2out_do_cfi_asm ())
fprintf (asm_out_file, "\t.cfi_endproc\n");
/* Output a label to mark the endpoint of the code generated for this
function. */
ASM_GENERATE_INTERNAL_LABEL (label, FUNC_END_LABEL,
current_function_funcdef_no);
ASM_OUTPUT_LABEL (asm_out_file, label);
fde = cfun->fde;
gcc_assert (fde != NULL);
if (fde->dw_fde_second_begin == NULL)
fde->dw_fde_end = xstrdup (label);
}
void
dwarf2out_frame_finish (void)
{
/* Output call frame information. */
if (targetm.debug_unwind_info () == UI_DWARF2)
output_call_frame_info (0);
/* Output another copy for the unwinder. */
if (do_eh_frame)
output_call_frame_info (1);
}
/* Note that the current function section is being used for code. */
static void
dwarf2out_note_section_used (void)
{
section *sec = current_function_section ();
if (sec == text_section)
text_section_used = true;
else if (sec == cold_text_section)
cold_text_section_used = true;
}
static void var_location_switch_text_section (void);
static void set_cur_line_info_table (section *);
void
dwarf2out_switch_text_section (void)
{
char label[MAX_ARTIFICIAL_LABEL_BYTES];
section *sect;
dw_fde_ref fde = cfun->fde;
gcc_assert (cfun && fde && fde->dw_fde_second_begin == NULL);
ASM_GENERATE_INTERNAL_LABEL (label, FUNC_SECOND_SECT_LABEL,
current_function_funcdef_no);
fde->dw_fde_second_begin = ggc_strdup (label);
if (!in_cold_section_p)
{
fde->dw_fde_end = crtl->subsections.cold_section_end_label;
fde->dw_fde_second_end = crtl->subsections.hot_section_end_label;
}
else
{
fde->dw_fde_end = crtl->subsections.hot_section_end_label;
fde->dw_fde_second_end = crtl->subsections.cold_section_end_label;
}
have_multiple_function_sections = true;
/* There is no need to mark used sections when not debugging. */
if (cold_text_section != NULL)
dwarf2out_note_section_used ();
if (dwarf2out_do_cfi_asm ())
fprintf (asm_out_file, "\t.cfi_endproc\n");
/* Now do the real section switch. */
sect = current_function_section ();
switch_to_section (sect);
fde->second_in_std_section
= (sect == text_section
|| (cold_text_section && sect == cold_text_section));
if (dwarf2out_do_cfi_asm ())
dwarf2out_do_cfi_startproc (true);
var_location_switch_text_section ();
if (cold_text_section != NULL)
set_cur_line_info_table (sect);
}
/* And now, the subset of the debugging information support code necessary
for emitting location expressions. */
/* Data about a single source file. */
struct GTY((for_user)) dwarf_file_data {
const char * filename;
int emitted_number;
};
/* Describe an entry into the .debug_addr section. */
enum ate_kind {
ate_kind_rtx,
ate_kind_rtx_dtprel,
ate_kind_label
};
struct GTY((for_user)) addr_table_entry {
enum ate_kind kind;
unsigned int refcount;
unsigned int index;
union addr_table_entry_struct_union
{
rtx GTY ((tag ("0"))) rtl;
char * GTY ((tag ("1"))) label;
}
GTY ((desc ("%1.kind"))) addr;
};
typedef unsigned int var_loc_view;
/* Location lists are ranges + location descriptions for that range,
so you can track variables that are in different places over
their entire life. */
typedef struct GTY(()) dw_loc_list_struct {
dw_loc_list_ref dw_loc_next;
const char *begin; /* Label and addr_entry for start of range */
addr_table_entry *begin_entry;
const char *end; /* Label for end of range */
char *ll_symbol; /* Label for beginning of location list.
Only on head of list. */
char *vl_symbol; /* Label for beginning of view list. Ditto. */
const char *section; /* Section this loclist is relative to */
dw_loc_descr_ref expr;
var_loc_view vbegin, vend;
hashval_t hash;
/* True if all addresses in this and subsequent lists are known to be
resolved. */
bool resolved_addr;
/* True if this list has been replaced by dw_loc_next. */
bool replaced;
/* True if it has been emitted into .debug_loc* / .debug_loclists*
section. */
unsigned char emitted : 1;
/* True if hash field is index rather than hash value. */
unsigned char num_assigned : 1;
/* True if .debug_loclists.dwo offset has been emitted for it already. */
unsigned char offset_emitted : 1;
/* True if note_variable_value_in_expr has been called on it. */
unsigned char noted_variable_value : 1;
/* True if the range should be emitted even if begin and end
are the same. */
bool force;
} dw_loc_list_node;
static dw_loc_descr_ref int_loc_descriptor (poly_int64);
static dw_loc_descr_ref uint_loc_descriptor (unsigned HOST_WIDE_INT);
/* Convert a DWARF stack opcode into its string name. */
static const char *
dwarf_stack_op_name (unsigned int op)
{
const char *name = get_DW_OP_name (op);
if (name != NULL)
return name;
return "OP_<unknown>";
}
/* Return TRUE iff we're to output location view lists as a separate
attribute next to the location lists, as an extension compatible
with DWARF 2 and above. */
static inline bool
dwarf2out_locviews_in_attribute ()
{
return debug_variable_location_views == 1;
}
/* Return TRUE iff we're to output location view lists as part of the
location lists, as proposed for standardization after DWARF 5. */
static inline bool
dwarf2out_locviews_in_loclist ()
{
#ifndef DW_LLE_view_pair
return false;
#else
return debug_variable_location_views == -1;
#endif
}
/* Return a pointer to a newly allocated location description. Location
descriptions are simple expression terms that can be strung
together to form more complicated location (address) descriptions. */
static inline dw_loc_descr_ref
new_loc_descr (enum dwarf_location_atom op, unsigned HOST_WIDE_INT oprnd1,
unsigned HOST_WIDE_INT oprnd2)
{
dw_loc_descr_ref descr = ggc_cleared_alloc<dw_loc_descr_node> ();
descr->dw_loc_opc = op;
descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const;
descr->dw_loc_oprnd1.val_entry = NULL;
descr->dw_loc_oprnd1.v.val_unsigned = oprnd1;
descr->dw_loc_oprnd2.val_class = dw_val_class_unsigned_const;
descr->dw_loc_oprnd2.val_entry = NULL;
descr->dw_loc_oprnd2.v.val_unsigned = oprnd2;
return descr;
}
/* Add a location description term to a location description expression. */
static inline void
add_loc_descr (dw_loc_descr_ref *list_head, dw_loc_descr_ref descr)
{
dw_loc_descr_ref *d;
/* Find the end of the chain. */
for (d = list_head; (*d) != NULL; d = &(*d)->dw_loc_next)
;
*d = descr;
}
/* Compare two location operands for exact equality. */
static bool
dw_val_equal_p (dw_val_node *a, dw_val_node *b)
{
if (a->val_class != b->val_class)
return false;
switch (a->val_class)
{
case dw_val_class_none:
return true;
case dw_val_class_addr:
return rtx_equal_p (a->v.val_addr, b->v.val_addr);
case dw_val_class_offset:
case dw_val_class_unsigned_const:
case dw_val_class_const:
case dw_val_class_unsigned_const_implicit:
case dw_val_class_const_implicit:
case dw_val_class_range_list:
/* These are all HOST_WIDE_INT, signed or unsigned. */
return a->v.val_unsigned == b->v.val_unsigned;
case dw_val_class_loc:
return a->v.val_loc == b->v.val_loc;
case dw_val_class_loc_list:
return a->v.val_loc_list == b->v.val_loc_list;
case dw_val_class_view_list:
return a->v.val_view_list == b->v.val_view_list;
case dw_val_class_die_ref:
return a->v.val_die_ref.die == b->v.val_die_ref.die;
case dw_val_class_fde_ref:
return a->v.val_fde_index == b->v.val_fde_index;
case dw_val_class_symview:
return strcmp (a->v.val_symbolic_view, b->v.val_symbolic_view) == 0;
case dw_val_class_lbl_id:
case dw_val_class_lineptr:
case dw_val_class_macptr:
case dw_val_class_loclistsptr:
case dw_val_class_high_pc:
return strcmp (a->v.val_lbl_id, b->v.val_lbl_id) == 0;
case dw_val_class_str:
return a->v.val_str == b->v.val_str;
case dw_val_class_flag:
return a->v.val_flag == b->v.val_flag;
case dw_val_class_file:
case dw_val_class_file_implicit:
return a->v.val_file == b->v.val_file;
case dw_val_class_decl_ref:
return a->v.val_decl_ref == b->v.val_decl_ref;
case dw_val_class_const_double:
return (a->v.val_double.high == b->v.val_double.high
&& a->v.val_double.low == b->v.val_double.low);
case dw_val_class_wide_int:
return *a->v.val_wide == *b->v.val_wide;
case dw_val_class_vec:
{
size_t a_len = a->v.val_vec.elt_size * a->v.val_vec.length;
size_t b_len = b->v.val_vec.elt_size * b->v.val_vec.length;
return (a_len == b_len
&& !memcmp (a->v.val_vec.array, b->v.val_vec.array, a_len));
}
case dw_val_class_data8:
return memcmp (a->v.val_data8, b->v.val_data8, 8) == 0;
case dw_val_class_vms_delta:
return (!strcmp (a->v.val_vms_delta.lbl1, b->v.val_vms_delta.lbl1)
&& !strcmp (a->v.val_vms_delta.lbl2, b->v.val_vms_delta.lbl2));
case dw_val_class_discr_value:
return (a->v.val_discr_value.pos == b->v.val_discr_value.pos
&& a->v.val_discr_value.v.uval == b->v.val_discr_value.v.uval);
case dw_val_class_discr_list:
/* It makes no sense comparing two discriminant value lists. */
return false;
}
gcc_unreachable ();
}
/* Compare two location atoms for exact equality. */
static bool
loc_descr_equal_p_1 (dw_loc_descr_ref a, dw_loc_descr_ref b)
{
if (a->dw_loc_opc != b->dw_loc_opc)
return false;
/* ??? This is only ever set for DW_OP_constNu, for N equal to the
address size, but since we always allocate cleared storage it
should be zero for other types of locations. */
if (a->dtprel != b->dtprel)
return false;
return (dw_val_equal_p (&a->dw_loc_oprnd1, &b->dw_loc_oprnd1)
&& dw_val_equal_p (&a->dw_loc_oprnd2, &b->dw_loc_oprnd2));
}
/* Compare two complete location expressions for exact equality. */
bool
loc_descr_equal_p (dw_loc_descr_ref a, dw_loc_descr_ref b)
{
while (1)
{
if (a == b)
return true;
if (a == NULL || b == NULL)
return false;
if (!loc_descr_equal_p_1 (a, b))
return false;
a = a->dw_loc_next;
b = b->dw_loc_next;
}
}
/* Add a constant POLY_OFFSET to a location expression. */
static void
loc_descr_plus_const (dw_loc_descr_ref *list_head, poly_int64 poly_offset)
{
dw_loc_descr_ref loc;
HOST_WIDE_INT *p;
gcc_assert (*list_head != NULL);
if (known_eq (poly_offset, 0))
return;
/* Find the end of the chain. */
for (loc = *list_head; loc->dw_loc_next != NULL; loc = loc->dw_loc_next)
;
HOST_WIDE_INT offset;
if (!poly_offset.is_constant (&offset))
{
loc->dw_loc_next = int_loc_descriptor (poly_offset);
add_loc_descr (&loc->dw_loc_next, new_loc_descr (DW_OP_plus, 0, 0));
return;
}
p = NULL;
if (loc->dw_loc_opc == DW_OP_fbreg
|| (loc->dw_loc_opc >= DW_OP_breg0 && loc->dw_loc_opc <= DW_OP_breg31))
p = &loc->dw_loc_oprnd1.v.val_int;
else if (loc->dw_loc_opc == DW_OP_bregx)
p = &loc->dw_loc_oprnd2.v.val_int;
/* If the last operation is fbreg, breg{0..31,x}, optimize by adjusting its
offset. Don't optimize if an signed integer overflow would happen. */
if (p != NULL
&& ((offset > 0 && *p <= INTTYPE_MAXIMUM (HOST_WIDE_INT) - offset)
|| (offset < 0 && *p >= INTTYPE_MINIMUM (HOST_WIDE_INT) - offset)))
*p += offset;
else if (offset > 0)
loc->dw_loc_next = new_loc_descr (DW_OP_plus_uconst, offset, 0);
else
{
loc->dw_loc_next
= uint_loc_descriptor (-(unsigned HOST_WIDE_INT) offset);
add_loc_descr (&loc->dw_loc_next, new_loc_descr (DW_OP_minus, 0, 0));
}
}
/* Return a pointer to a newly allocated location description for
REG and OFFSET. */
static inline dw_loc_descr_ref
new_reg_loc_descr (unsigned int reg, poly_int64 offset)
{
HOST_WIDE_INT const_offset;
if (offset.is_constant (&const_offset))
{
if (reg <= 31)
return new_loc_descr ((enum dwarf_location_atom) (DW_OP_breg0 + reg),
const_offset, 0);
else
return new_loc_descr (DW_OP_bregx, reg, const_offset);
}
else
{
dw_loc_descr_ref ret = new_reg_loc_descr (reg, 0);
loc_descr_plus_const (&ret, offset);
return ret;
}
}
/* Add a constant OFFSET to a location list. */
static void
loc_list_plus_const (dw_loc_list_ref list_head, poly_int64 offset)
{
dw_loc_list_ref d;
for (d = list_head; d != NULL; d = d->dw_loc_next)
loc_descr_plus_const (&d->expr, offset);
}
#define DWARF_REF_SIZE \
(dwarf_version == 2 ? DWARF2_ADDR_SIZE : DWARF_OFFSET_SIZE)
/* The number of bits that can be encoded by largest DW_FORM_dataN.
In DWARF4 and earlier it is DW_FORM_data8 with 64 bits, in DWARF5
DW_FORM_data16 with 128 bits. */
#define DWARF_LARGEST_DATA_FORM_BITS \
(dwarf_version >= 5 ? 128 : 64)
/* Utility inline function for construction of ops that were GNU extension
before DWARF 5. */
static inline enum dwarf_location_atom
dwarf_OP (enum dwarf_location_atom op)
{
switch (op)
{
case DW_OP_implicit_pointer:
if (dwarf_version < 5)
return DW_OP_GNU_implicit_pointer;
break;
case DW_OP_entry_value:
if (dwarf_version < 5)
return DW_OP_GNU_entry_value;
break;
case DW_OP_const_type:
if (dwarf_version < 5)
return DW_OP_GNU_const_type;
break;
case DW_OP_regval_type:
if (dwarf_version < 5)
return DW_OP_GNU_regval_type;
break;
case DW_OP_deref_type:
if (dwarf_version < 5)
return DW_OP_GNU_deref_type;
break;
case DW_OP_convert:
if (dwarf_version < 5)
return DW_OP_GNU_convert;
break;
case DW_OP_reinterpret:
if (dwarf_version < 5)
return DW_OP_GNU_reinterpret;
break;
case DW_OP_addrx:
if (dwarf_version < 5)
return DW_OP_GNU_addr_index;
break;
case DW_OP_constx:
if (dwarf_version < 5)
return DW_OP_GNU_const_index;
break;
default:
break;
}
return op;
}
/* Similarly for attributes. */
static inline enum dwarf_attribute
dwarf_AT (enum dwarf_attribute at)
{
switch (at)
{
case DW_AT_call_return_pc:
if (dwarf_version < 5)
return DW_AT_low_pc;
break;
case DW_AT_call_tail_call:
if (dwarf_version < 5)
return DW_AT_GNU_tail_call;
break;
case DW_AT_call_origin:
if (dwarf_version < 5)
return DW_AT_abstract_origin;
break;
case DW_AT_call_target:
if (dwarf_version < 5)
return DW_AT_GNU_call_site_target;
break;
case DW_AT_call_target_clobbered:
if (dwarf_version < 5)
return DW_AT_GNU_call_site_target_clobbered;
break;
case DW_AT_call_parameter:
if (dwarf_version < 5)
return DW_AT_abstract_origin;
break;
case DW_AT_call_value:
if (dwarf_version < 5)
return DW_AT_GNU_call_site_value;
break;
case DW_AT_call_data_value:
if (dwarf_version < 5)
return DW_AT_GNU_call_site_data_value;
break;
case DW_AT_call_all_calls:
if (dwarf_version < 5)
return DW_AT_GNU_all_call_sites;
break;
case DW_AT_call_all_tail_calls:
if (dwarf_version < 5)
return DW_AT_GNU_all_tail_call_sites;
break;
case DW_AT_dwo_name:
if (dwarf_version < 5)
return DW_AT_GNU_dwo_name;
break;
case DW_AT_addr_base:
if (dwarf_version < 5)
return DW_AT_GNU_addr_base;
break;
default:
break;
}
return at;
}
/* And similarly for tags. */
static inline enum dwarf_tag
dwarf_TAG (enum dwarf_tag tag)
{
switch (tag)
{
case DW_TAG_call_site:
if (dwarf_version < 5)
return DW_TAG_GNU_call_site;
break;
case DW_TAG_call_site_parameter:
if (dwarf_version < 5)
return DW_TAG_GNU_call_site_parameter;
break;
default:
break;
}
return tag;
}
/* And similarly for forms. */
static inline enum dwarf_form
dwarf_FORM (enum dwarf_form form)
{
switch (form)
{
case DW_FORM_addrx:
if (dwarf_version < 5)
return DW_FORM_GNU_addr_index;
break;
case DW_FORM_strx:
if (dwarf_version < 5)
return DW_FORM_GNU_str_index;
break;
default:
break;
}
return form;
}
static unsigned long int get_base_type_offset (dw_die_ref);
/* Return the size of a location descriptor. */
static unsigned long
size_of_loc_descr (dw_loc_descr_ref loc)
{
unsigned long size = 1;
switch (loc->dw_loc_opc)
{
case DW_OP_addr:
size += DWARF2_ADDR_SIZE;
break;
case DW_OP_GNU_addr_index:
case DW_OP_addrx:
case DW_OP_GNU_const_index:
case DW_OP_constx:
gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED);
size += size_of_uleb128 (loc->dw_loc_oprnd1.val_entry->index);
break;
case DW_OP_const1u:
case DW_OP_const1s:
size += 1;
break;
case DW_OP_const2u:
case DW_OP_const2s:
size += 2;
break;
case DW_OP_const4u:
case DW_OP_const4s:
size += 4;
break;
case DW_OP_const8u:
case DW_OP_const8s:
size += 8;
break;
case DW_OP_constu:
size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
break;
case DW_OP_consts:
size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
break;
case DW_OP_pick:
size += 1;
break;
case DW_OP_plus_uconst:
size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
break;
case DW_OP_skip:
case DW_OP_bra:
size += 2;
break;
case DW_OP_breg0:
case DW_OP_breg1:
case DW_OP_breg2:
case DW_OP_breg3:
case DW_OP_breg4:
case DW_OP_breg5:
case DW_OP_breg6:
case DW_OP_breg7:
case DW_OP_breg8:
case DW_OP_breg9:
case DW_OP_breg10:
case DW_OP_breg11:
case DW_OP_breg12:
case DW_OP_breg13:
case DW_OP_breg14:
case DW_OP_breg15:
case DW_OP_breg16:
case DW_OP_breg17:
case DW_OP_breg18:
case DW_OP_breg19:
case DW_OP_breg20:
case DW_OP_breg21:
case DW_OP_breg22:
case DW_OP_breg23:
case DW_OP_breg24:
case DW_OP_breg25:
case DW_OP_breg26:
case DW_OP_breg27:
case DW_OP_breg28:
case DW_OP_breg29:
case DW_OP_breg30:
case DW_OP_breg31:
size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
break;
case DW_OP_regx:
size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
break;
case DW_OP_fbreg:
size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
break;
case DW_OP_bregx:
size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
size += size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int);
break;
case DW_OP_piece:
size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
break;
case DW_OP_bit_piece:
size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
size += size_of_uleb128 (loc->dw_loc_oprnd2.v.val_unsigned);
break;
case DW_OP_deref_size:
case DW_OP_xderef_size:
size += 1;
break;
case DW_OP_call2:
size += 2;
break;
case DW_OP_call4:
size += 4;
break;
case DW_OP_call_ref:
case DW_OP_GNU_variable_value:
size += DWARF_REF_SIZE;
break;
case DW_OP_implicit_value:
size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned)
+ loc->dw_loc_oprnd1.v.val_unsigned;
break;
case DW_OP_implicit_pointer:
case DW_OP_GNU_implicit_pointer:
size += DWARF_REF_SIZE + size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int);
break;
case DW_OP_entry_value:
case DW_OP_GNU_entry_value:
{
unsigned long op_size = size_of_locs (loc->dw_loc_oprnd1.v.val_loc);
size += size_of_uleb128 (op_size) + op_size;
break;
}
case DW_OP_const_type:
case DW_OP_GNU_const_type:
{
unsigned long o
= get_base_type_offset (loc->dw_loc_oprnd1.v.val_die_ref.die);
size += size_of_uleb128 (o) + 1;
switch (loc->dw_loc_oprnd2.val_class)
{
case dw_val_class_vec:
size += loc->dw_loc_oprnd2.v.val_vec.length
* loc->dw_loc_oprnd2.v.val_vec.elt_size;
break;
case dw_val_class_const:
size += HOST_BITS_PER_WIDE_INT / BITS_PER_UNIT;
break;
case dw_val_class_const_double:
size += HOST_BITS_PER_DOUBLE_INT / BITS_PER_UNIT;
break;
case dw_val_class_wide_int:
size += (get_full_len (*loc->dw_loc_oprnd2.v.val_wide)
* HOST_BITS_PER_WIDE_INT / BITS_PER_UNIT);
break;
default:
gcc_unreachable ();
}
break;
}
case DW_OP_regval_type:
case DW_OP_GNU_regval_type:
{
unsigned long o
= get_base_type_offset (loc->dw_loc_oprnd2.v.val_die_ref.die);
size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned)
+ size_of_uleb128 (o);
}
break;
case DW_OP_deref_type:
case DW_OP_GNU_deref_type:
{
unsigned long o
= get_base_type_offset (loc->dw_loc_oprnd2.v.val_die_ref.die);
size += 1 + size_of_uleb128 (o);
}
break;
case DW_OP_convert:
case DW_OP_reinterpret:
case DW_OP_GNU_convert:
case DW_OP_GNU_reinterpret:
if (loc->dw_loc_oprnd1.val_class == dw_val_class_unsigned_const)
size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
else
{
unsigned long o
= get_base_type_offset (loc->dw_loc_oprnd1.v.val_die_ref.die);
size += size_of_uleb128 (o);
}
break;
case DW_OP_GNU_parameter_ref:
size += 4;
break;
default:
break;
}
return size;
}
/* Return the size of a series of location descriptors. */
unsigned long
size_of_locs (dw_loc_descr_ref loc)
{
dw_loc_descr_ref l;
unsigned long size;
/* If there are no skip or bra opcodes, don't fill in the dw_loc_addr
field, to avoid writing to a PCH file. */
for (size = 0, l = loc; l != NULL; l = l->dw_loc_next)
{
if (l->dw_loc_opc == DW_OP_skip || l->dw_loc_opc == DW_OP_bra)
break;
size += size_of_loc_descr (l);
}
if (! l)
return size;
for (size = 0, l = loc; l != NULL; l = l->dw_loc_next)
{
l->dw_loc_addr = size;
size += size_of_loc_descr (l);
}
return size;
}
/* Return the size of the value in a DW_AT_discr_value attribute. */
static int
size_of_discr_value (dw_discr_value *discr_value)
{
if (discr_value->pos)
return size_of_uleb128 (discr_value->v.uval);
else
return size_of_sleb128 (discr_value->v.sval);
}
/* Return the size of the value in a DW_AT_discr_list attribute. */
static int
size_of_discr_list (dw_discr_list_ref discr_list)
{
int size = 0;
for (dw_discr_list_ref list = discr_list;
list != NULL;
list = list->dw_discr_next)
{
/* One byte for the discriminant value descriptor, and then one or two
LEB128 numbers, depending on whether it's a single case label or a
range label. */
size += 1;
size += size_of_discr_value (&list->dw_discr_lower_bound);
if (list->dw_discr_range != 0)
size += size_of_discr_value (&list->dw_discr_upper_bound);
}
return size;
}
static HOST_WIDE_INT extract_int (const unsigned char *, unsigned);
static void get_ref_die_offset_label (char *, dw_die_ref);
static unsigned long int get_ref_die_offset (dw_die_ref);
/* Output location description stack opcode's operands (if any).
The for_eh_or_skip parameter controls whether register numbers are
converted using DWARF2_FRAME_REG_OUT, which is needed in the case that
hard reg numbers have been processed via DWARF_FRAME_REGNUM (i.e. for unwind
info). This should be suppressed for the cases that have not been converted
(i.e. symbolic debug info), by setting the parameter < 0. See PR47324. */
static void
output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip)
{
dw_val_ref val1 = &loc->dw_loc_oprnd1;
dw_val_ref val2 = &loc->dw_loc_oprnd2;
switch (loc->dw_loc_opc)
{
#ifdef DWARF2_DEBUGGING_INFO
case DW_OP_const2u:
case DW_OP_const2s:
dw2_asm_output_data (2, val1->v.val_int, NULL);
break;
case DW_OP_const4u:
if (loc->dtprel)
{
gcc_assert (targetm.asm_out.output_dwarf_dtprel);
targetm.asm_out.output_dwarf_dtprel (asm_out_file, 4,
val1->v.val_addr);
fputc ('\n', asm_out_file);
break;
}
/* FALLTHRU */
case DW_OP_const4s:
dw2_asm_output_data (4, val1->v.val_int, NULL);
break;
case DW_OP_const8u:
if (loc->dtprel)
{
gcc_assert (targetm.asm_out.output_dwarf_dtprel);
targetm.asm_out.output_dwarf_dtprel (asm_out_file, 8,
val1->v.val_addr);
fputc ('\n', asm_out_file);
break;
}
/* FALLTHRU */
case DW_OP_const8s:
gcc_assert (HOST_BITS_PER_WIDE_INT >= 64);
dw2_asm_output_data (8, val1->v.val_int, NULL);
break;
case DW_OP_skip:
case DW_OP_bra:
{
int offset;
gcc_assert (val1->val_class == dw_val_class_loc);
offset = val1->v.val_loc->dw_loc_addr - (loc->dw_loc_addr + 3);
dw2_asm_output_data (2, offset, NULL);
}
break;
case DW_OP_implicit_value:
dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
switch (val2->val_class)
{
case dw_val_class_const:
dw2_asm_output_data (val1->v.val_unsigned, val2->v.val_int, NULL);
break;
case dw_val_class_vec:
{
unsigned int elt_size = val2->v.val_vec.elt_size;
unsigned int len = val2->v.val_vec.length;
unsigned int i;
unsigned char *p;
if (elt_size > sizeof (HOST_WIDE_INT))
{
elt_size /= 2;
len *= 2;
}
for (i = 0, p = (unsigned char *) val2->v.val_vec.array;
i < len;
i++, p += elt_size)
dw2_asm_output_data (elt_size, extract_int (p, elt_size),
"fp or vector constant word %u", i);
}
break;
case dw_val_class_const_double:
{
unsigned HOST_WIDE_INT first, second;
if (WORDS_BIG_ENDIAN)
{
first = val2->v.val_double.high;
second = val2->v.val_double.low;
}
else
{
first = val2->v.val_double.low;
second = val2->v.val_double.high;
}
dw2_asm_output_data (HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR,
first, NULL);
dw2_asm_output_data (HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR,
second, NULL);
}
break;
case dw_val_class_wide_int:
{
int i;
int len = get_full_len (*val2->v.val_wide);
if (WORDS_BIG_ENDIAN)
for (i = len - 1; i >= 0; --i)
dw2_asm_output_data (HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR,
val2->v.val_wide->elt (i), NULL);
else
for (i = 0; i < len; ++i)
dw2_asm_output_data (HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR,
val2->v.val_wide->elt (i), NULL);
}
break;
case dw_val_class_addr:
gcc_assert (val1->v.val_unsigned == DWARF2_ADDR_SIZE);
dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, val2->v.val_addr, NULL);
break;
default:
gcc_unreachable ();
}
break;
#else
case DW_OP_const2u:
case DW_OP_const2s:
case DW_OP_const4u:
case DW_OP_const4s:
case DW_OP_const8u:
case DW_OP_const8s:
case DW_OP_skip:
case DW_OP_bra:
case DW_OP_implicit_value:
/* We currently don't make any attempt to make sure these are
aligned properly like we do for the main unwind info, so
don't support emitting things larger than a byte if we're
only doing unwinding. */
gcc_unreachable ();
#endif
case DW_OP_const1u:
case DW_OP_const1s:
dw2_asm_output_data (1, val1->v.val_int, NULL);
break;
case DW_OP_constu:
dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
break;
case DW_OP_consts:
dw2_asm_output_data_sleb128 (val1->v.val_int, NULL);
break;
case DW_OP_pick:
dw2_asm_output_data (1, val1->v.val_int, NULL);
break;
case DW_OP_plus_uconst:
dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
break;
case DW_OP_breg0:
case DW_OP_breg1:
case DW_OP_breg2:
case DW_OP_breg3:
case DW_OP_breg4:
case DW_OP_breg5:
case DW_OP_breg6:
case DW_OP_breg7:
case DW_OP_breg8:
case DW_OP_breg9:
case DW_OP_breg10:
case DW_OP_breg11:
case DW_OP_breg12:
case DW_OP_breg13:
case DW_OP_breg14:
case DW_OP_breg15:
case DW_OP_breg16:
case DW_OP_breg17:
case DW_OP_breg18:
case DW_OP_breg19:
case DW_OP_breg20:
case DW_OP_breg21:
case DW_OP_breg22:
case DW_OP_breg23:
case DW_OP_breg24:
case DW_OP_breg25:
case DW_OP_breg26:
case DW_OP_breg27:
case DW_OP_breg28:
case DW_OP_breg29:
case DW_OP_breg30:
case DW_OP_breg31:
dw2_asm_output_data_sleb128 (val1->v.val_int, NULL);
break;
case DW_OP_regx:
{
unsigned r = val1->v.val_unsigned;
if (for_eh_or_skip >= 0)
r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip);
gcc_assert (size_of_uleb128 (r)
== size_of_uleb128 (val1->v.val_unsigned));
dw2_asm_output_data_uleb128 (r, NULL);
}
break;
case DW_OP_fbreg:
dw2_asm_output_data_sleb128 (val1->v.val_int, NULL);
break;
case DW_OP_bregx:
{
unsigned r = val1->v.val_unsigned;
if (for_eh_or_skip >= 0)
r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip);
gcc_assert (size_of_uleb128 (r)
== size_of_uleb128 (val1->v.val_unsigned));
dw2_asm_output_data_uleb128 (r, NULL);
dw2_asm_output_data_sleb128 (val2->v.val_int, NULL);
}
break;
case DW_OP_piece:
dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
break;
case DW_OP_bit_piece:
dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
dw2_asm_output_data_uleb128 (val2->v.val_unsigned, NULL);
break;
case DW_OP_deref_size:
case DW_OP_xderef_size:
dw2_asm_output_data (1, val1->v.val_int, NULL);
break;
case DW_OP_addr:
if (loc->dtprel)
{
if (targetm.asm_out.output_dwarf_dtprel)
{
targetm.asm_out.output_dwarf_dtprel (asm_out_file,
DWARF2_ADDR_SIZE,
val1->v.val_addr);
fputc ('\n', asm_out_file);
}
else
gcc_unreachable ();
}
else
{
#ifdef DWARF2_DEBUGGING_INFO
dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, val1->v.val_addr, NULL);
#else
gcc_unreachable ();
#endif
}
break;
case DW_OP_GNU_addr_index:
case DW_OP_addrx:
case DW_OP_GNU_const_index:
case DW_OP_constx:
gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED);
dw2_asm_output_data_uleb128 (loc->dw_loc_oprnd1.val_entry->index,
"(index into .debug_addr)");
break;
case DW_OP_call2:
case DW_OP_call4:
{
unsigned long die_offset
= get_ref_die_offset (val1->v.val_die_ref.die);
/* Make sure the offset has been computed and that we can encode it as
an operand. */
gcc_assert (die_offset > 0
&& die_offset <= (loc->dw_loc_opc == DW_OP_call2
? 0xffff
: 0xffffffff));
dw2_asm_output_data ((loc->dw_loc_opc == DW_OP_call2) ? 2 : 4,
die_offset, NULL);
}
break;
case DW_OP_call_ref:
case DW_OP_GNU_variable_value:
{
char label[MAX_ARTIFICIAL_LABEL_BYTES
+ HOST_BITS_PER_WIDE_INT / 2 + 2];
gcc_assert (val1->val_class == dw_val_class_die_ref);
get_ref_die_offset_label (label, val1->v.val_die_ref.die);
dw2_asm_output_offset (DWARF_REF_SIZE, label, debug_info_section, NULL);
}
break;
case DW_OP_implicit_pointer:
case DW_OP_GNU_implicit_pointer:
{
char label[MAX_ARTIFICIAL_LABEL_BYTES
+ HOST_BITS_PER_WIDE_INT / 2 + 2];
gcc_assert (val1->val_class == dw_val_class_die_ref);
get_ref_die_offset_label (label, val1->v.val_die_ref.die);
dw2_asm_output_offset (DWARF_REF_SIZE, label, debug_info_section, NULL);
dw2_asm_output_data_sleb128 (val2->v.val_int, NULL);
}
break;
case DW_OP_entry_value:
case DW_OP_GNU_entry_value:
dw2_asm_output_data_uleb128 (size_of_locs (val1->v.val_loc), NULL);
output_loc_sequence (val1->v.val_loc, for_eh_or_skip);
break;
case DW_OP_const_type:
case DW_OP_GNU_const_type:
{
unsigned long o = get_base_type_offset (val1->v.val_die_ref.die), l;
gcc_assert (o);
dw2_asm_output_data_uleb128 (o, NULL);
switch (val2->val_class)
{
case dw_val_class_const:
l = HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR;
dw2_asm_output_data (1, l, NULL);
dw2_asm_output_data (l, val2->v.val_int, NULL);
break;
case dw_val_class_vec:
{
unsigned int elt_size = val2->v.val_vec.elt_size;
unsigned int len = val2->v.val_vec.length;
unsigned int i;
unsigned char *p;
l = len * elt_size;
dw2_asm_output_data (1, l, NULL);
if (elt_size > sizeof (HOST_WIDE_INT))
{
elt_size /= 2;
len *= 2;
}
for (i = 0, p = (unsigned char *) val2->v.val_vec.array;
i < len;
i++, p += elt_size)
dw2_asm_output_data (elt_size, extract_int (p, elt_size),
"fp or vector constant word %u", i);
}
break;
case dw_val_class_const_double:
{
unsigned HOST_WIDE_INT first, second;
l = HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR;
dw2_asm_output_data (1, 2 * l, NULL);
if (WORDS_BIG_ENDIAN)
{
first = val2->v.val_double.high;
second = val2->v.val_double.low;
}
else
{
first = val2->v.val_double.low;
second = val2->v.val_double.high;
}
dw2_asm_output_data (l, first, NULL);
dw2_asm_output_data (l, second, NULL);
}
break;
case dw_val_class_wide_int:
{
int i;
int len = get_full_len (*val2->v.val_wide);
l = HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR;
dw2_asm_output_data (1, len * l, NULL);
if (WORDS_BIG_ENDIAN)
for (i = len - 1; i >= 0; --i)
dw2_asm_output_data (l, val2->v.val_wide->elt (i), NULL);
else
for (i = 0; i < len; ++i)
dw2_asm_output_data (l, val2->v.val_wide->elt (i), NULL);
}
break;
default:
gcc_unreachable ();
}
}
break;
case DW_OP_regval_type:
case DW_OP_GNU_regval_type:
{
unsigned r = val1->v.val_unsigned;
unsigned long o = get_base_type_offset (val2->v.val_die_ref.die);
gcc_assert (o);
if (for_eh_or_skip >= 0)
{
r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip);
gcc_assert (size_of_uleb128 (r)
== size_of_uleb128 (val1->v.val_unsigned));
}
dw2_asm_output_data_uleb128 (r, NULL);
dw2_asm_output_data_uleb128 (o, NULL);
}
break;
case DW_OP_deref_type:
case DW_OP_GNU_deref_type:
{
unsigned long o = get_base_type_offset (val2->v.val_die_ref.die);
gcc_assert (o);
dw2_asm_output_data (1, val1->v.val_int, NULL);
dw2_asm_output_data_uleb128 (o, NULL);
}
break;
case DW_OP_convert:
case DW_OP_reinterpret:
case DW_OP_GNU_convert:
case DW_OP_GNU_reinterpret:
if (loc->dw_loc_oprnd1.val_class == dw_val_class_unsigned_const)
dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
else
{
unsigned long o = get_base_type_offset (val1->v.val_die_ref.die);
gcc_assert (o);
dw2_asm_output_data_uleb128 (o, NULL);
}
break;
case DW_OP_GNU_parameter_ref:
{
unsigned long o;
gcc_assert (val1->val_class == dw_val_class_die_ref);
o = get_ref_die_offset (val1->v.val_die_ref.die);
dw2_asm_output_data (4, o, NULL);
}
break;
default:
/* Other codes have no operands. */
break;
}
}
/* Output a sequence of location operations.
The for_eh_or_skip parameter controls whether register numbers are
converted using DWARF2_FRAME_REG_OUT, which is needed in the case that
hard reg numbers have been processed via DWARF_FRAME_REGNUM (i.e. for unwind
info). This should be suppressed for the cases that have not been converted
(i.e. symbolic debug info), by setting the parameter < 0. See PR47324. */
void
output_loc_sequence (dw_loc_descr_ref loc, int for_eh_or_skip)
{
for (; loc != NULL; loc = loc->dw_loc_next)
{
enum dwarf_location_atom opc = loc->dw_loc_opc;
/* Output the opcode. */
if (for_eh_or_skip >= 0
&& opc >= DW_OP_breg0 && opc <= DW_OP_breg31)
{
unsigned r = (opc - DW_OP_breg0);
r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip);
gcc_assert (r <= 31);
opc = (enum dwarf_location_atom) (DW_OP_breg0 + r);
}
else if (for_eh_or_skip >= 0
&& opc >= DW_OP_reg0 && opc <= DW_OP_reg31)
{
unsigned r = (opc - DW_OP_reg0);
r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip);
gcc_assert (r <= 31);
opc = (enum dwarf_location_atom) (DW_OP_reg0 + r);
}
dw2_asm_output_data (1, opc,
"%s", dwarf_stack_op_name (opc));
/* Output the operand(s) (if any). */
output_loc_operands (loc, for_eh_or_skip);
}
}
/* Output location description stack opcode's operands (if any).
The output is single bytes on a line, suitable for .cfi_escape. */
static void
output_loc_operands_raw (dw_loc_descr_ref loc)
{
dw_val_ref val1 = &loc->dw_loc_oprnd1;
dw_val_ref val2 = &loc->dw_loc_oprnd2;
switch (loc->dw_loc_opc)
{
case DW_OP_addr:
case DW_OP_GNU_addr_index:
case DW_OP_addrx:
case DW_OP_GNU_const_index:
case DW_OP_constx:
case DW_OP_implicit_value:
/* We cannot output addresses in .cfi_escape, only bytes. */
gcc_unreachable ();
case DW_OP_const1u:
case DW_OP_const1s:
case DW_OP_pick:
case DW_OP_deref_size:
case DW_OP_xderef_size:
fputc (',', asm_out_file);
dw2_asm_output_data_raw (1, val1->v.val_int);
break;
case DW_OP_const2u:
case DW_OP_const2s:
fputc (',', asm_out_file);
dw2_asm_output_data_raw (2, val1->v.val_int);
break;
case DW_OP_const4u:
case DW_OP_const4s:
fputc (',', asm_out_file);
dw2_asm_output_data_raw (4, val1->v.val_int);
break;
case DW_OP_const8u:
case DW_OP_const8s:
gcc_assert (HOST_BITS_PER_WIDE_INT >= 64);
fputc (',', asm_out_file);
dw2_asm_output_data_raw (8, val1->v.val_int);
break;
case DW_OP_skip:
case DW_OP_bra:
{
int offset;
gcc_assert (val1->val_class == dw_val_class_loc);
offset = val1->v.val_loc->dw_loc_addr - (loc->dw_loc_addr + 3);
fputc (',', asm_out_file);
dw2_asm_output_data_raw (2, offset);
}
break;
case DW_OP_regx:
{
unsigned r = DWARF2_FRAME_REG_OUT (val1->v.val_unsigned, 1);
gcc_assert (size_of_uleb128 (r)
== size_of_uleb128 (val1->v.val_unsigned));
fputc (',', asm_out_file);
dw2_asm_output_data_uleb128_raw (r);
}
break;
case DW_OP_constu:
case DW_OP_plus_uconst:
case DW_OP_piece:
fputc (',', asm_out_file);
dw2_asm_output_data_uleb128_raw (val1->v.val_unsigned);
break;
case DW_OP_bit_piece:
fputc (',', asm_out_file);
dw2_asm_output_data_uleb128_raw (val1->v.val_unsigned);
dw2_asm_output_data_uleb128_raw (val2->v.val_unsigned);
break;
case DW_OP_consts:
case DW_OP_breg0:
case DW_OP_breg1:
case DW_OP_breg2:
case DW_OP_breg3:
case DW_OP_breg4:
case DW_OP_breg5:
case DW_OP_breg6:
case DW_OP_breg7:
case DW_OP_breg8:
case DW_OP_breg9:
case DW_OP_breg10:
case DW_OP_breg11:
case DW_OP_breg12:
case DW_OP_breg13:
case DW_OP_breg14:
case DW_OP_breg15:
case DW_OP_breg16:
case DW_OP_breg17:
case DW_OP_breg18:
case DW_OP_breg19:
case DW_OP_breg20:
case DW_OP_breg21:
case DW_OP_breg22:
case DW_OP_breg23:
case DW_OP_breg24:
case DW_OP_breg25:
case DW_OP_breg26:
case DW_OP_breg27:
case DW_OP_breg28:
case DW_OP_breg29:
case DW_OP_breg30:
case DW_OP_breg31:
case DW_OP_fbreg:
fputc (',', asm_out_file);
dw2_asm_output_data_sleb128_raw (val1->v.val_int);
break;
case DW_OP_bregx:
{
unsigned r = DWARF2_FRAME_REG_OUT (val1->v.val_unsigned, 1);
gcc_assert (size_of_uleb128 (r)
== size_of_uleb128 (val1->v.val_unsigned));
fputc (',', asm_out_file);
dw2_asm_output_data_uleb128_raw (r);
fputc (',', asm_out_file);
dw2_asm_output_data_sleb128_raw (val2->v.val_int);
}
break;
case DW_OP_implicit_pointer:
case DW_OP_entry_value:
case DW_OP_const_type:
case DW_OP_regval_type:
case DW_OP_deref_type:
case DW_OP_convert:
case DW_OP_reinterpret:
case DW_OP_GNU_implicit_pointer:
case DW_OP_GNU_entry_value:
case DW_OP_GNU_const_type:
case DW_OP_GNU_regval_type:
case DW_OP_GNU_deref_type:
case DW_OP_GNU_convert:
case DW_OP_GNU_reinterpret:
case DW_OP_GNU_parameter_ref:
gcc_unreachable ();
break;
default:
/* Other codes have no operands. */
break;
}
}
void
output_loc_sequence_raw (dw_loc_descr_ref loc)
{
while (1)
{
enum dwarf_location_atom opc = loc->dw_loc_opc;
/* Output the opcode. */
if (opc >= DW_OP_breg0 && opc <= DW_OP_breg31)
{
unsigned r = (opc - DW_OP_breg0);
r = DWARF2_FRAME_REG_OUT (r, 1);
gcc_assert (r <= 31);
opc = (enum dwarf_location_atom) (DW_OP_breg0 + r);
}
else if (opc >= DW_OP_reg0 && opc <= DW_OP_reg31)
{
unsigned r = (opc - DW_OP_reg0);
r = DWARF2_FRAME_REG_OUT (r, 1);
gcc_assert (r <= 31);
opc = (enum dwarf_location_atom) (DW_OP_reg0 + r);
}
/* Output the opcode. */
fprintf (asm_out_file, "%#x", opc);
output_loc_operands_raw (loc);
if (!loc->dw_loc_next)
break;
loc = loc->dw_loc_next;
fputc (',', asm_out_file);
}
}
/* This function builds a dwarf location descriptor sequence from a
dw_cfa_location, adding the given OFFSET to the result of the
expression. */
struct dw_loc_descr_node *
build_cfa_loc (dw_cfa_location *cfa, poly_int64 offset)
{
struct dw_loc_descr_node *head, *tmp;
offset += cfa->offset;
if (cfa->indirect)
{
head = new_reg_loc_descr (cfa->reg, cfa->base_offset);
head->dw_loc_oprnd1.val_class = dw_val_class_const;
head->dw_loc_oprnd1.val_entry = NULL;
tmp = new_loc_descr (DW_OP_deref, 0, 0);
add_loc_descr (&head, tmp);
loc_descr_plus_const (&head, offset);
}
else
head = new_reg_loc_descr (cfa->reg, offset);
return head;
}
/* This function builds a dwarf location descriptor sequence for
the address at OFFSET from the CFA when stack is aligned to
ALIGNMENT byte. */
struct dw_loc_descr_node *
build_cfa_aligned_loc (dw_cfa_location *cfa,
poly_int64 offset, HOST_WIDE_INT alignment)
{
struct dw_loc_descr_node *head;
unsigned int dwarf_fp
= DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM);
/* When CFA is defined as FP+OFFSET, emulate stack alignment. */
if (cfa->reg == HARD_FRAME_POINTER_REGNUM && cfa->indirect == 0)
{
head = new_reg_loc_descr (dwarf_fp, 0);
add_loc_descr (&head, int_loc_descriptor (alignment));
add_loc_descr (&head, new_loc_descr (DW_OP_and, 0, 0));
loc_descr_plus_const (&head, offset);
}
else
head = new_reg_loc_descr (dwarf_fp, offset);
return head;
}
/* And now, the support for symbolic debugging information. */
/* .debug_str support. */
static void dwarf2out_init (const char *);
static void dwarf2out_finish (const char *);
static void dwarf2out_early_finish (const char *);
static void dwarf2out_assembly_start (void);
static void dwarf2out_define (unsigned int, const char *);
static void dwarf2out_undef (unsigned int, const char *);
static void dwarf2out_start_source_file (unsigned, const char *);
static void dwarf2out_end_source_file (unsigned);
static void dwarf2out_function_decl (tree);
static void dwarf2out_begin_block (unsigned, unsigned);
static void dwarf2out_end_block (unsigned, unsigned);
static bool dwarf2out_ignore_block (const_tree);
static void dwarf2out_early_global_decl (tree);
static void dwarf2out_late_global_decl (tree);
static void dwarf2out_type_decl (tree, int);
static void dwarf2out_imported_module_or_decl (tree, tree, tree, bool, bool);
static void dwarf2out_imported_module_or_decl_1 (tree, tree, tree,
dw_die_ref);
static void dwarf2out_abstract_function (tree);
static void dwarf2out_var_location (rtx_insn *);
static void dwarf2out_inline_entry (tree);
static void dwarf2out_size_function (tree);
static void dwarf2out_begin_function (tree);
static void dwarf2out_end_function (unsigned int);
static void dwarf2out_register_main_translation_unit (tree unit);
static void dwarf2out_set_name (tree, tree);
static void dwarf2out_register_external_die (tree decl, const char *sym,
unsigned HOST_WIDE_INT off);
static bool dwarf2out_die_ref_for_decl (tree decl, const char **sym,
unsigned HOST_WIDE_INT *off);
/* The debug hooks structure. */
const struct gcc_debug_hooks dwarf2_debug_hooks =
{
dwarf2out_init,
dwarf2out_finish,
dwarf2out_early_finish,
dwarf2out_assembly_start,
dwarf2out_define,
dwarf2out_undef,
dwarf2out_start_source_file,
dwarf2out_end_source_file,
dwarf2out_begin_block,
dwarf2out_end_block,
dwarf2out_ignore_block,
dwarf2out_source_line,
dwarf2out_begin_prologue,
#if VMS_DEBUGGING_INFO
dwarf2out_vms_end_prologue,
dwarf2out_vms_begin_epilogue,
#else
debug_nothing_int_charstar,
debug_nothing_int_charstar,
#endif
dwarf2out_end_epilogue,
dwarf2out_begin_function,
dwarf2out_end_function, /* end_function */
dwarf2out_register_main_translation_unit,
dwarf2out_function_decl, /* function_decl */
dwarf2out_early_global_decl,
dwarf2out_late_global_decl,
dwarf2out_type_decl, /* type_decl */
dwarf2out_imported_module_or_decl,
dwarf2out_die_ref_for_decl,
dwarf2out_register_external_die,
debug_nothing_tree, /* deferred_inline_function */
/* The DWARF 2 backend tries to reduce debugging bloat by not
emitting the abstract description of inline functions until
something tries to reference them. */
dwarf2out_abstract_function, /* outlining_inline_function */
debug_nothing_rtx_code_label, /* label */
debug_nothing_int, /* handle_pch */
dwarf2out_var_location,
dwarf2out_inline_entry, /* inline_entry */
dwarf2out_size_function, /* size_function */
dwarf2out_switch_text_section,
dwarf2out_set_name,
1, /* start_end_main_source_file */
TYPE_SYMTAB_IS_DIE /* tree_type_symtab_field */
};
const struct gcc_debug_hooks dwarf2_lineno_debug_hooks =
{
dwarf2out_init,
debug_nothing_charstar,
debug_nothing_charstar,
dwarf2out_assembly_start,
debug_nothing_int_charstar,
debug_nothing_int_charstar,
debug_nothing_int_charstar,
debug_nothing_int,
debug_nothing_int_int, /* begin_block */
debug_nothing_int_int, /* end_block */
debug_true_const_tree, /* ignore_block */
dwarf2out_source_line, /* source_line */
debug_nothing_int_int_charstar, /* begin_prologue */
debug_nothing_int_charstar, /* end_prologue */
debug_nothing_int_charstar, /* begin_epilogue */
debug_nothing_int_charstar, /* end_epilogue */
debug_nothing_tree, /* begin_function */
debug_nothing_int, /* end_function */
debug_nothing_tree, /* register_main_translation_unit */
debug_nothing_tree, /* function_decl */
debug_nothing_tree, /* early_global_decl */
debug_nothing_tree, /* late_global_decl */
debug_nothing_tree_int, /* type_decl */
debug_nothing_tree_tree_tree_bool_bool,/* imported_module_or_decl */
debug_false_tree_charstarstar_uhwistar,/* die_ref_for_decl */
debug_nothing_tree_charstar_uhwi, /* register_external_die */
debug_nothing_tree, /* deferred_inline_function */
debug_nothing_tree, /* outlining_inline_function */
debug_nothing_rtx_code_label, /* label */
debug_nothing_int, /* handle_pch */
debug_nothing_rtx_insn, /* var_location */
debug_nothing_tree, /* inline_entry */
debug_nothing_tree, /* size_function */
debug_nothing_void, /* switch_text_section */
debug_nothing_tree_tree, /* set_name */
0, /* start_end_main_source_file */
TYPE_SYMTAB_IS_ADDRESS /* tree_type_symtab_field */
};
/* NOTE: In the comments in this file, many references are made to
"Debugging Information Entries". This term is abbreviated as `DIE'
throughout the remainder of this file. */
/* An internal representation of the DWARF output is built, and then
walked to generate the DWARF debugging info. The walk of the internal
representation is done after the entire program has been compiled.
The types below are used to describe the internal representation. */
/* Whether to put type DIEs into their own section .debug_types instead
of making them part of the .debug_info section. Only supported for
Dwarf V4 or higher and the user didn't disable them through
-fno-debug-types-section. It is more efficient to put them in a
separate comdat sections since the linker will then be able to
remove duplicates. But not all tools support .debug_types sections
yet. For Dwarf V5 or higher .debug_types doesn't exist any more,
it is DW_UT_type unit type in .debug_info section. For late LTO
debug there should be almost no types emitted so avoid enabling
-fdebug-types-section there. */
#define use_debug_types (dwarf_version >= 4 \
&& flag_debug_types_section \
&& !in_lto_p)
/* Various DIE's use offsets relative to the beginning of the
.debug_info section to refer to each other. */
typedef long int dw_offset;
struct comdat_type_node;
/* The entries in the line_info table more-or-less mirror the opcodes
that are used in the real dwarf line table. Arrays of these entries
are collected per section when DWARF2_ASM_LINE_DEBUG_INFO is not
supported. */
enum dw_line_info_opcode {
/* Emit DW_LNE_set_address; the operand is the label index. */
LI_set_address,
/* Emit a row to the matrix with the given line. This may be done
via any combination of DW_LNS_copy, DW_LNS_advance_line, and
special opcodes. */
LI_set_line,
/* Emit a DW_LNS_set_file. */
LI_set_file,
/* Emit a DW_LNS_set_column. */
LI_set_column,
/* Emit a DW_LNS_negate_stmt; the operand is ignored. */
LI_negate_stmt,
/* Emit a DW_LNS_set_prologue_end/epilogue_begin; the operand is ignored. */
LI_set_prologue_end,
LI_set_epilogue_begin,
/* Emit a DW_LNE_set_discriminator. */
LI_set_discriminator,
/* Output a Fixed Advance PC; the target PC is the label index; the
base PC is the previous LI_adv_address or LI_set_address entry.
We only use this when emitting debug views without assembler
support, at explicit user request. Ideally, we should only use
it when the offset might be zero but we can't tell: it's the only
way to maybe change the PC without resetting the view number. */
LI_adv_address
};
typedef struct GTY(()) dw_line_info_struct {
enum dw_line_info_opcode opcode;
unsigned int val;
} dw_line_info_entry;
struct GTY(()) dw_line_info_table {
/* The label that marks the end of this section. */
const char *end_label;
/* The values for the last row of the matrix, as collected in the table.
These are used to minimize the changes to the next row. */
unsigned int file_num;
unsigned int line_num;
unsigned int column_num;
int discrim_num;
bool is_stmt;
bool in_use;
/* This denotes the NEXT view number.
If it is 0, it is known that the NEXT view will be the first view
at the given PC.
If it is -1, we're forcing the view number to be reset, e.g. at a
function entry.
The meaning of other nonzero values depends on whether we're
computing views internally or leaving it for the assembler to do
so. If we're emitting them internally, view denotes the view
number since the last known advance of PC. If we're leaving it
for the assembler, it denotes the LVU label number that we're
going to ask the assembler to assign. */
var_loc_view view;
/* This counts the number of symbolic views emitted in this table
since the latest view reset. Its max value, over all tables,
sets symview_upper_bound. */
var_loc_view symviews_since_reset;
#define FORCE_RESET_NEXT_VIEW(x) ((x) = (var_loc_view)-1)
#define RESET_NEXT_VIEW(x) ((x) = (var_loc_view)0)
#define FORCE_RESETTING_VIEW_P(x) ((x) == (var_loc_view)-1)
#define RESETTING_VIEW_P(x) ((x) == (var_loc_view)0 || FORCE_RESETTING_VIEW_P (x))
vec<dw_line_info_entry, va_gc> *entries;
};
/* This is an upper bound for view numbers that the assembler may
assign to symbolic views output in this translation. It is used to
decide how big a field to use to represent view numbers in
symview-classed attributes. */
static var_loc_view symview_upper_bound;
/* If we're keep track of location views and their reset points, and
INSN is a reset point (i.e., it necessarily advances the PC), mark
the next view in TABLE as reset. */
static void
maybe_reset_location_view (rtx_insn *insn, dw_line_info_table *table)
{
if (!debug_internal_reset_location_views)
return;
/* Maybe turn (part of?) this test into a default target hook. */
int reset = 0;
if (targetm.reset_location_view)
reset = targetm.reset_location_view (insn);
if (reset)
;
else if (JUMP_TABLE_DATA_P (insn))
reset = 1;
else if (GET_CODE (insn) == USE
|| GET_CODE (insn) == CLOBBER
|| GET_CODE (insn) == ASM_INPUT
|| asm_noperands (insn) >= 0)
;
else if (get_attr_min_length (insn) > 0)
reset = 1;
if (reset > 0 && !RESETTING_VIEW_P (table->view))
RESET_NEXT_VIEW (table->view);
}
/* Each DIE attribute has a field specifying the attribute kind,
a link to the next attribute in the chain, and an attribute value.
Attributes are typically linked below the DIE they modify. */
typedef struct GTY(()) dw_attr_struct {
enum dwarf_attribute dw_attr;
dw_val_node dw_attr_val;
}
dw_attr_node;
/* The Debugging Information Entry (DIE) structure. DIEs form a tree.
The children of each node form a circular list linked by
die_sib. die_child points to the node *before* the "first" child node. */
typedef struct GTY((chain_circular ("%h.die_sib"), for_user)) die_struct {
union die_symbol_or_type_node
{
const char * GTY ((tag ("0"))) die_symbol;
comdat_type_node *GTY ((tag ("1"))) die_type_node;
}
GTY ((desc ("%0.comdat_type_p"))) die_id;
vec<dw_attr_node, va_gc> *die_attr;
dw_die_ref die_parent;
dw_die_ref die_child;
dw_die_ref die_sib;
dw_die_ref die_definition; /* ref from a specification to its definition */
dw_offset die_offset;
unsigned long die_abbrev;
int die_mark;
unsigned int decl_id;
enum dwarf_tag die_tag;
/* Die is used and must not be pruned as unused. */
BOOL_BITFIELD die_perennial_p : 1;
BOOL_BITFIELD comdat_type_p : 1; /* DIE has a type signature */
/* For an external ref to die_symbol if die_offset contains an extra
offset to that symbol. */
BOOL_BITFIELD with_offset : 1;
/* Whether this DIE was removed from the DIE tree, for example via
prune_unused_types. We don't consider those present from the
DIE lookup routines. */
BOOL_BITFIELD removed : 1;
/* Lots of spare bits. */
}
die_node;
/* Set to TRUE while dwarf2out_early_global_decl is running. */
static bool early_dwarf;
static bool early_dwarf_finished;
class set_early_dwarf {
public:
bool saved;
set_early_dwarf () : saved(early_dwarf)
{
gcc_assert (! early_dwarf_finished);
early_dwarf = true;
}
~set_early_dwarf () { early_dwarf = saved; }
};
/* Evaluate 'expr' while 'c' is set to each child of DIE in order. */
#define FOR_EACH_CHILD(die, c, expr) do { \
c = die->die_child; \
if (c) do { \
c = c->die_sib; \
expr; \
} while (c != die->die_child); \
} while (0)
/* The pubname structure */
typedef struct GTY(()) pubname_struct {
dw_die_ref die;
const char *name;
}
pubname_entry;
struct GTY(()) dw_ranges {
const char *label;
/* If this is positive, it's a block number, otherwise it's a
bitwise-negated index into dw_ranges_by_label. */
int num;
/* Index for the range list for DW_FORM_rnglistx. */
unsigned int idx : 31;
/* True if this range might be possibly in a different section
from previous entry. */
unsigned int maybe_new_sec : 1;
};
/* A structure to hold a macinfo entry. */
typedef struct GTY(()) macinfo_struct {
unsigned char code;
unsigned HOST_WIDE_INT lineno;
const char *info;
}
macinfo_entry;
struct GTY(()) dw_ranges_by_label {
const char *begin;
const char *end;
};
/* The comdat type node structure. */
struct GTY(()) comdat_type_node
{
dw_die_ref root_die;
dw_die_ref type_die;
dw_die_ref skeleton_die;
char signature[DWARF_TYPE_SIGNATURE_SIZE];
comdat_type_node *next;
};
/* A list of DIEs for which we can't determine ancestry (parent_die
field) just yet. Later in dwarf2out_finish we will fill in the
missing bits. */
typedef struct GTY(()) limbo_die_struct {
dw_die_ref die;
/* The tree for which this DIE was created. We use this to
determine ancestry later. */
tree created_for;
struct limbo_die_struct *next;
}
limbo_die_node;
typedef struct skeleton_chain_struct
{
dw_die_ref old_die;
dw_die_ref new_die;
struct skeleton_chain_struct *parent;
}
skeleton_chain_node;
/* Define a macro which returns nonzero for a TYPE_DECL which was
implicitly generated for a type.
Note that, unlike the C front-end (which generates a NULL named
TYPE_DECL node for each complete tagged type, each array type,
and each function type node created) the C++ front-end generates
a _named_ TYPE_DECL node for each tagged type node created.
These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
generate a DW_TAG_typedef DIE for them. Likewise with the Ada
front-end, but for each type, tagged or not. */
#define TYPE_DECL_IS_STUB(decl) \
(DECL_NAME (decl) == NULL_TREE \
|| (DECL_ARTIFICIAL (decl) \
&& ((decl == TYPE_STUB_DECL (TREE_TYPE (decl))) \
/* This is necessary for stub decls that \
appear in nested inline functions. */ \
|| (DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE \
&& (decl_ultimate_origin (decl) \
== TYPE_STUB_DECL (TREE_TYPE (decl)))))))
/* Information concerning the compilation unit's programming
language, and compiler version. */
/* Fixed size portion of the DWARF compilation unit header. */
#define DWARF_COMPILE_UNIT_HEADER_SIZE \
(DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE \
+ (dwarf_version >= 5 ? 4 : 3))
/* Fixed size portion of the DWARF comdat type unit header. */
#define DWARF_COMDAT_TYPE_UNIT_HEADER_SIZE \
(DWARF_COMPILE_UNIT_HEADER_SIZE \
+ DWARF_TYPE_SIGNATURE_SIZE + DWARF_OFFSET_SIZE)
/* Fixed size portion of the DWARF skeleton compilation unit header. */
#define DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE \
(DWARF_COMPILE_UNIT_HEADER_SIZE + (dwarf_version >= 5 ? 8 : 0))
/* Fixed size portion of public names info. */
#define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
/* Fixed size portion of the address range info. */
#define DWARF_ARANGES_HEADER_SIZE \
(DWARF_ROUND (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE + 4, \
DWARF2_ADDR_SIZE * 2) \
- DWARF_INITIAL_LENGTH_SIZE)
/* Size of padding portion in the address range info. It must be
aligned to twice the pointer size. */
#define DWARF_ARANGES_PAD_SIZE \
(DWARF_ROUND (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE + 4, \
DWARF2_ADDR_SIZE * 2) \
- (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE + 4))
/* Use assembler line directives if available. */
#ifndef DWARF2_ASM_LINE_DEBUG_INFO
#ifdef HAVE_AS_DWARF2_DEBUG_LINE
#define DWARF2_ASM_LINE_DEBUG_INFO 1
#else
#define DWARF2_ASM_LINE_DEBUG_INFO 0
#endif
#endif
/* Use assembler views in line directives if available. */
#ifndef DWARF2_ASM_VIEW_DEBUG_INFO
#ifdef HAVE_AS_DWARF2_DEBUG_VIEW
#define DWARF2_ASM_VIEW_DEBUG_INFO 1
#else
#define DWARF2_ASM_VIEW_DEBUG_INFO 0
#endif
#endif
/* Return true if GCC configure detected assembler support for .loc. */
bool
dwarf2out_default_as_loc_support (void)
{
return DWARF2_ASM_LINE_DEBUG_INFO;
#if (GCC_VERSION >= 3000)
# undef DWARF2_ASM_LINE_DEBUG_INFO
# pragma GCC poison DWARF2_ASM_LINE_DEBUG_INFO
#endif
}
/* Return true if GCC configure detected assembler support for views
in .loc directives. */
bool
dwarf2out_default_as_locview_support (void)
{
return DWARF2_ASM_VIEW_DEBUG_INFO;
#if (GCC_VERSION >= 3000)
# undef DWARF2_ASM_VIEW_DEBUG_INFO
# pragma GCC poison DWARF2_ASM_VIEW_DEBUG_INFO
#endif
}
/* A bit is set in ZERO_VIEW_P if we are using the assembler-supported
view computation, and it refers to a view identifier for which we
will not emit a label because it is known to map to a view number
zero. We won't allocate the bitmap if we're not using assembler
support for location views, but we have to make the variable
visible for GGC and for code that will be optimized out for lack of
support but that's still parsed and compiled. We could abstract it
out with macros, but it's not worth it. */
static GTY(()) bitmap zero_view_p;
/* Evaluate to TRUE iff N is known to identify the first location view
at its PC. When not using assembler location view computation,
that must be view number zero. Otherwise, ZERO_VIEW_P is allocated
and views label numbers recorded in it are the ones known to be
zero. */
#define ZERO_VIEW_P(N) ((N) == (var_loc_view)0 \
|| (N) == (var_loc_view)-1 \
|| (zero_view_p \
&& bitmap_bit_p (zero_view_p, (N))))
/* Return true iff we're to emit .loc directives for the assembler to
generate line number sections.
When we're not emitting views, all we need from the assembler is
support for .loc directives.
If we are emitting views, we can only use the assembler's .loc
support if it also supports views.
When the compiler is emitting the line number programs and
computing view numbers itself, it resets view numbers at known PC
changes and counts from that, and then it emits view numbers as
literal constants in locviewlists. There are cases in which the
compiler is not sure about PC changes, e.g. when extra alignment is
requested for a label. In these cases, the compiler may not reset
the view counter, and the potential PC advance in the line number
program will use an opcode that does not reset the view counter
even if the PC actually changes, so that compiler and debug info
consumer can keep view numbers in sync.
When the compiler defers view computation to the assembler, it
emits symbolic view numbers in locviewlists, with the exception of
views known to be zero (forced resets, or reset after
compiler-visible PC changes): instead of emitting symbols for
these, we emit literal zero and assert the assembler agrees with
the compiler's assessment. We could use symbolic views everywhere,
instead of special-casing zero views, but then we'd be unable to
optimize out locviewlists that contain only zeros. */
static bool
output_asm_line_debug_info (void)
{
return (dwarf2out_as_loc_support
&& (dwarf2out_as_locview_support
|| !debug_variable_location_views));
}
static bool asm_outputs_debug_line_str (void);
/* Minimum line offset in a special line info. opcode.
This value was chosen to give a reasonable range of values. */
#define DWARF_LINE_BASE -10
/* First special line opcode - leave room for the standard opcodes. */
#define DWARF_LINE_OPCODE_BASE ((int)DW_LNS_set_isa + 1)
/* Range of line offsets in a special line info. opcode. */
#define DWARF_LINE_RANGE (254-DWARF_LINE_OPCODE_BASE+1)
/* Flag that indicates the initial value of the is_stmt_start flag.
In the present implementation, we do not mark any lines as
the beginning of a source statement, because that information
is not made available by the GCC front-end. */
#define DWARF_LINE_DEFAULT_IS_STMT_START 1
/* Maximum number of operations per instruction bundle. */
#ifndef DWARF_LINE_DEFAULT_MAX_OPS_PER_INSN
#define DWARF_LINE_DEFAULT_MAX_OPS_PER_INSN 1
#endif
/* This location is used by calc_die_sizes() to keep track
the offset of each DIE within the .debug_info section. */
static unsigned long next_die_offset;
/* Record the root of the DIE's built for the current compilation unit. */
static GTY(()) dw_die_ref single_comp_unit_die;
/* A list of type DIEs that have been separated into comdat sections. */
static GTY(()) comdat_type_node *comdat_type_list;
/* A list of CU DIEs that have been separated. */
static GTY(()) limbo_die_node *cu_die_list;
/* A list of DIEs with a NULL parent waiting to be relocated. */
static GTY(()) limbo_die_node *limbo_die_list;
/* A list of DIEs for which we may have to generate
DW_AT_{,MIPS_}linkage_name once their DECL_ASSEMBLER_NAMEs are set. */
static GTY(()) limbo_die_node *deferred_asm_name;
struct dwarf_file_hasher : ggc_ptr_hash<dwarf_file_data>
{
typedef const char *compare_type;
static hashval_t hash (dwarf_file_data *);
static bool equal (dwarf_file_data *, const char *);
};
/* Filenames referenced by this compilation unit. */
static GTY(()) hash_table<dwarf_file_hasher> *file_table;
struct decl_die_hasher : ggc_ptr_hash<die_node>
{
typedef tree compare_type;
static hashval_t hash (die_node *);
static bool equal (die_node *, tree);
};
/* A hash table of references to DIE's that describe declarations.
The key is a DECL_UID() which is a unique number identifying each decl. */
static GTY (()) hash_table<decl_die_hasher> *decl_die_table;
struct GTY ((for_user)) variable_value_struct {
unsigned int decl_id;
vec<dw_die_ref, va_gc> *dies;
};
struct variable_value_hasher : ggc_ptr_hash<variable_value_struct>
{
typedef tree compare_type;
static hashval_t hash (variable_value_struct *);
static bool equal (variable_value_struct *, tree);
};
/* A hash table of DIEs that contain DW_OP_GNU_variable_value with
dw_val_class_decl_ref class, indexed by FUNCTION_DECLs which is
DECL_CONTEXT of the referenced VAR_DECLs. */
static GTY (()) hash_table<variable_value_hasher> *variable_value_hash;
struct block_die_hasher : ggc_ptr_hash<die_struct>
{
static hashval_t hash (die_struct *);
static bool equal (die_struct *, die_struct *);
};
/* A hash table of references to DIE's that describe COMMON blocks.
The key is DECL_UID() ^ die_parent. */
static GTY (()) hash_table<block_die_hasher> *common_block_die_table;
typedef struct GTY(()) die_arg_entry_struct {
dw_die_ref die;
tree arg;
} die_arg_entry;
/* Node of the variable location list. */
struct GTY ((chain_next ("%h.next"))) var_loc_node {
/* Either NOTE_INSN_VAR_LOCATION, or, for SRA optimized variables,
EXPR_LIST chain. For small bitsizes, bitsize is encoded
in mode of the EXPR_LIST node and first EXPR_LIST operand
is either NOTE_INSN_VAR_LOCATION for a piece with a known
location or NULL for padding. For larger bitsizes,
mode is 0 and first operand is a CONCAT with bitsize
as first CONCAT operand and NOTE_INSN_VAR_LOCATION resp.
NULL as second operand. */
rtx GTY (()) loc;
const char * GTY (()) label;
struct var_loc_node * GTY (()) next;
var_loc_view view;
};
/* Variable location list. */
struct GTY ((for_user)) var_loc_list_def {
struct var_loc_node * GTY (()) first;
/* Pointer to the last but one or last element of the
chained list. If the list is empty, both first and
last are NULL, if the list contains just one node
or the last node certainly is not redundant, it points
to the last node, otherwise points to the last but one.
Do not mark it for GC because it is marked through the chain. */
struct var_loc_node * GTY ((skip ("%h"))) last;
/* Pointer to the last element before section switch,
if NULL, either sections weren't switched or first
is after section switch. */
struct var_loc_node * GTY ((skip ("%h"))) last_before_switch;
/* DECL_UID of the variable decl. */
unsigned int decl_id;
};
typedef struct var_loc_list_def var_loc_list;
/* Call argument location list. */
struct GTY ((chain_next ("%h.next"))) call_arg_loc_node {
rtx GTY (()) call_arg_loc_note;
const char * GTY (()) label;
tree GTY (()) block;
bool tail_call_p;
rtx GTY (()) symbol_ref;
struct call_arg_loc_node * GTY (()) next;
};
struct decl_loc_hasher : ggc_ptr_hash<var_loc_list>
{
typedef const_tree compare_type;
static hashval_t hash (var_loc_list *);
static bool equal (var_loc_list *, const_tree);
};
/* Table of decl location linked lists. */
static GTY (()) hash_table<decl_loc_hasher> *decl_loc_table;
/* Head and tail of call_arg_loc chain. */
static GTY (()) struct call_arg_loc_node *call_arg_locations;
static struct call_arg_loc_node *call_arg_loc_last;
/* Number of call sites in the current function. */
static int call_site_count = -1;
/* Number of tail call sites in the current function. */
static int tail_call_site_count = -1;
/* A cached location list. */
struct GTY ((for_user)) cached_dw_loc_list_def {
/* The DECL_UID of the decl that this entry describes. */
unsigned int decl_id;
/* The cached location list. */
dw_loc_list_ref loc_list;
};
typedef struct cached_dw_loc_list_def cached_dw_loc_list;
struct dw_loc_list_hasher : ggc_ptr_hash<cached_dw_loc_list>
{
typedef const_tree compare_type;
static hashval_t hash (cached_dw_loc_list *);
static bool equal (cached_dw_loc_list *, const_tree);
};
/* Table of cached location lists. */
static GTY (()) hash_table<dw_loc_list_hasher> *cached_dw_loc_list_table;
/* A vector of references to DIE's that are uniquely identified by their tag,
presence/absence of children DIE's, and list of attribute/value pairs. */
static GTY(()) vec<dw_die_ref, va_gc> *abbrev_die_table;
/* A hash map to remember the stack usage for DWARF procedures. The value
stored is the stack size difference between before the DWARF procedure
invokation and after it returned. In other words, for a DWARF procedure
that consumes N stack slots and that pushes M ones, this stores M - N. */
static hash_map<dw_die_ref, int> *dwarf_proc_stack_usage_map;
/* A global counter for generating labels for line number data. */
static unsigned int line_info_label_num;
/* The current table to which we should emit line number information
for the current function. This will be set up at the beginning of
assembly for the function. */
static GTY(()) dw_line_info_table *cur_line_info_table;
/* The two default tables of line number info. */
static GTY(()) dw_line_info_table *text_section_line_info;
static GTY(()) dw_line_info_table *cold_text_section_line_info;
/* The set of all non-default tables of line number info. */
static GTY(()) vec<dw_line_info_table *, va_gc> *separate_line_info;
/* A flag to tell pubnames/types export if there is an info section to
refer to. */
static bool info_section_emitted;
/* A pointer to the base of a table that contains a list of publicly
accessible names. */
static GTY (()) vec<pubname_entry, va_gc> *pubname_table;
/* A pointer to the base of a table that contains a list of publicly
accessible types. */
static GTY (()) vec<pubname_entry, va_gc> *pubtype_table;
/* A pointer to the base of a table that contains a list of macro
defines/undefines (and file start/end markers). */
static GTY (()) vec<macinfo_entry, va_gc> *macinfo_table;
/* True if .debug_macinfo or .debug_macros section is going to be
emitted. */
#define have_macinfo \
((!XCOFF_DEBUGGING_INFO || HAVE_XCOFF_DWARF_EXTRAS) \
&& debug_info_level >= DINFO_LEVEL_VERBOSE \
&& !macinfo_table->is_empty ())
/* Vector of dies for which we should generate .debug_ranges info. */
static GTY (()) vec<dw_ranges, va_gc> *ranges_table;
/* Vector of pairs of labels referenced in ranges_table. */
static GTY (()) vec<dw_ranges_by_label, va_gc> *ranges_by_label;
/* Whether we have location lists that need outputting */
static GTY(()) bool have_location_lists;
/* Unique label counter. */
static GTY(()) unsigned int loclabel_num;
/* Unique label counter for point-of-call tables. */
static GTY(()) unsigned int poc_label_num;
/* The last file entry emitted by maybe_emit_file(). */
static GTY(()) struct dwarf_file_data * last_emitted_file;
/* Number of internal labels generated by gen_internal_sym(). */
static GTY(()) int label_num;
static GTY(()) vec<die_arg_entry, va_gc> *tmpl_value_parm_die_table;
/* Instances of generic types for which we need to generate debug
info that describe their generic parameters and arguments. That
generation needs to happen once all types are properly laid out so
we do it at the end of compilation. */
static GTY(()) vec<tree, va_gc> *generic_type_instances;
/* Offset from the "steady-state frame pointer" to the frame base,
within the current function. */
static poly_int64 frame_pointer_fb_offset;
static bool frame_pointer_fb_offset_valid;
static vec<dw_die_ref> base_types;
/* Flags to represent a set of attribute classes for attributes that represent
a scalar value (bounds, pointers, ...). */
enum dw_scalar_form
{
dw_scalar_form_constant = 0x01,
dw_scalar_form_exprloc = 0x02,
dw_scalar_form_reference = 0x04
};
/* Forward declarations for functions defined in this file. */
static int is_pseudo_reg (const_rtx);
static tree type_main_variant (tree);
static int is_tagged_type (const_tree);
static const char *dwarf_tag_name (unsigned);
static const char *dwarf_attr_name (unsigned);
static const char *dwarf_form_name (unsigned);
static tree decl_ultimate_origin (const_tree);
static tree decl_class_context (tree);
static void add_dwarf_attr (dw_die_ref, dw_attr_node *);
static inline enum dw_val_class AT_class (dw_attr_node *);
static inline unsigned int AT_index (dw_attr_node *);
static void add_AT_flag (dw_die_ref, enum dwarf_attribute, unsigned);
static inline unsigned AT_flag (dw_attr_node *);
static void add_AT_int (dw_die_ref, enum dwarf_attribute, HOST_WIDE_INT);
static inline HOST_WIDE_INT AT_int (dw_attr_node *);
static void add_AT_unsigned (dw_die_ref, enum dwarf_attribute, unsigned HOST_WIDE_INT);
static inline unsigned HOST_WIDE_INT AT_unsigned (dw_attr_node *);
static void add_AT_double (dw_die_ref, enum dwarf_attribute,
HOST_WIDE_INT, unsigned HOST_WIDE_INT);
static inline void add_AT_vec (dw_die_ref, enum dwarf_attribute, unsigned int,
unsigned int, unsigned char *);
static void add_AT_data8 (dw_die_ref, enum dwarf_attribute, unsigned char *);
static void add_AT_string (dw_die_ref, enum dwarf_attribute, const char *);
static inline const char *AT_string (dw_attr_node *);
static enum dwarf_form AT_string_form (dw_attr_node *);
static void add_AT_die_ref (dw_die_ref, enum dwarf_attribute, dw_die_ref);
static void add_AT_specification (dw_die_ref, dw_die_ref);
static inline dw_die_ref AT_ref (dw_attr_node *);
static inline int AT_ref_external (dw_attr_node *);
static inline void set_AT_ref_external (dw_attr_node *, int);
static void add_AT_loc (dw_die_ref, enum dwarf_attribute, dw_loc_descr_ref);
static inline dw_loc_descr_ref AT_loc (dw_attr_node *);
static void add_AT_loc_list (dw_die_ref, enum dwarf_attribute,
dw_loc_list_ref);
static inline dw_loc_list_ref AT_loc_list (dw_attr_node *);
static void add_AT_view_list (dw_die_ref, enum dwarf_attribute);
static inline dw_loc_list_ref AT_loc_list (dw_attr_node *);
static addr_table_entry *add_addr_table_entry (void *, enum ate_kind);
static void remove_addr_table_entry (addr_table_entry *);
static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx, bool);
static inline rtx AT_addr (dw_attr_node *);
static void add_AT_symview (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_lineptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_macptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_range_list (dw_die_ref, enum dwarf_attribute,
unsigned long, bool);
static inline const char *AT_lbl (dw_attr_node *);
static dw_attr_node *get_AT (dw_die_ref, enum dwarf_attribute);
static const char *get_AT_low_pc (dw_die_ref);
static const char *get_AT_string (dw_die_ref, enum dwarf_attribute);
static int get_AT_flag (dw_die_ref, enum dwarf_attribute);
static unsigned get_AT_unsigned (dw_die_ref, enum dwarf_attribute);
static inline dw_die_ref get_AT_ref (dw_die_ref, enum dwarf_attribute);
static bool is_c (void);
static bool is_cxx (void);
static bool is_cxx (const_tree);
static bool is_fortran (void);
static bool is_ada (void);
static bool remove_AT (dw_die_ref, enum dwarf_attribute);
static void remove_child_TAG (dw_die_ref, enum dwarf_tag);
static void add_child_die (dw_die_ref, dw_die_ref);
static dw_die_ref new_die (enum dwarf_tag, dw_die_ref, tree);
static dw_die_ref lookup_type_die (tree);
static dw_die_ref strip_naming_typedef (tree, dw_die_ref);
static dw_die_ref lookup_type_die_strip_naming_typedef (tree);
static void equate_type_number_to_die (tree, dw_die_ref);
static dw_die_ref lookup_decl_die (tree);
static var_loc_list *lookup_decl_loc (const_tree);
static void equate_decl_number_to_die (tree, dw_die_ref);
static struct var_loc_node *add_var_loc_to_decl (tree, rtx, const char *, var_loc_view);
static void print_spaces (FILE *);
static void print_die (dw_die_ref, FILE *);
static void loc_checksum (dw_loc_descr_ref, struct md5_ctx *);
static void attr_checksum (dw_attr_node *, struct md5_ctx *, int *);
static void die_checksum (dw_die_ref, struct md5_ctx *, int *);
static void checksum_sleb128 (HOST_WIDE_INT, struct md5_ctx *);
static void checksum_uleb128 (unsigned HOST_WIDE_INT, struct md5_ctx *);
static void loc_checksum_ordered (dw_loc_descr_ref, struct md5_ctx *);
static void attr_checksum_ordered (enum dwarf_tag, dw_attr_node *,
struct md5_ctx *, int *);
struct checksum_attributes;
static void collect_checksum_attributes (struct checksum_attributes *, dw_die_ref);
static void die_checksum_ordered (dw_die_ref, struct md5_ctx *, int *);
static void checksum_die_context (dw_die_ref, struct md5_ctx *);
static void generate_type_signature (dw_die_ref, comdat_type_node *);
static int same_loc_p (dw_loc_descr_ref, dw_loc_descr_ref, int *);
static int same_dw_val_p (const dw_val_node *, const dw_val_node *, int *);
static int same_attr_p (dw_attr_node *, dw_attr_node *, int *);
static int same_die_p (dw_die_ref, dw_die_ref, int *);
static int is_type_die (dw_die_ref);
static inline bool is_template_instantiation (dw_die_ref);
static int is_declaration_die (dw_die_ref);
static int should_move_die_to_comdat (dw_die_ref);
static dw_die_ref clone_as_declaration (dw_die_ref);
static dw_die_ref clone_die (dw_die_ref);
static dw_die_ref clone_tree (dw_die_ref);
static dw_die_ref copy_declaration_context (dw_die_ref, dw_die_ref);
static void generate_skeleton_ancestor_tree (skeleton_chain_node *);
static void generate_skeleton_bottom_up (skeleton_chain_node *);
static dw_die_ref generate_skeleton (dw_die_ref);
static dw_die_ref remove_child_or_replace_with_skeleton (dw_die_ref,
dw_die_ref,
dw_die_ref);
static void break_out_comdat_types (dw_die_ref);
static void copy_decls_for_unworthy_types (dw_die_ref);
static void add_sibling_attributes (dw_die_ref);
static void output_location_lists (dw_die_ref);
static int constant_size (unsigned HOST_WIDE_INT);
static unsigned long size_of_die (dw_die_ref);
static void calc_die_sizes (dw_die_ref);
static void calc_base_type_die_sizes (void);
static void mark_dies (dw_die_ref);
static void unmark_dies (dw_die_ref);
static void unmark_all_dies (dw_die_ref);
static unsigned long size_of_pubnames (vec<pubname_entry, va_gc> *);
static unsigned long size_of_aranges (void);
static enum dwarf_form value_format (dw_attr_node *);
static void output_value_format (dw_attr_node *);
static void output_abbrev_section (void);
static void output_die_abbrevs (unsigned long, dw_die_ref);
static void output_die (dw_die_ref);
static void output_compilation_unit_header (enum dwarf_unit_type);
static void output_comp_unit (dw_die_ref, int, const unsigned char *);
static void output_comdat_type_unit (comdat_type_node *, bool);
static const char *dwarf2_name (tree, int);
static void add_pubname (tree, dw_die_ref);
static void add_enumerator_pubname (const char *, dw_die_ref);
static void add_pubname_string (const char *, dw_die_ref);
static void add_pubtype (tree, dw_die_ref);
static void output_pubnames (vec<pubname_entry, va_gc> *);
static void output_aranges (void);
static unsigned int add_ranges (const_tree, bool = false);
static void add_ranges_by_labels (dw_die_ref, const char *, const char *,
bool *, bool);
static void output_ranges (void);
static dw_line_info_table *new_line_info_table (void);
static void output_line_info (bool);
static void output_file_names (void);
static dw_die_ref base_type_die (tree, bool);
static int is_base_type (tree);
static dw_die_ref subrange_type_die (tree, tree, tree, tree, dw_die_ref);
static int decl_quals (const_tree);
static dw_die_ref modified_type_die (tree, int, bool, dw_die_ref);
static dw_die_ref generic_parameter_die (tree, tree, bool, dw_die_ref);
static dw_die_ref template_parameter_pack_die (tree, tree, dw_die_ref);
static unsigned int dbx_reg_number (const_rtx);
static void add_loc_descr_op_piece (dw_loc_descr_ref *, int);
static dw_loc_descr_ref reg_loc_descriptor (rtx, enum var_init_status);
static dw_loc_descr_ref one_reg_loc_descriptor (unsigned int,
enum var_init_status);
static dw_loc_descr_ref multiple_reg_loc_descriptor (rtx, rtx,
enum var_init_status);
static dw_loc_descr_ref based_loc_descr (rtx, poly_int64,
enum var_init_status);
static int is_based_loc (const_rtx);
static bool resolve_one_addr (rtx *);
static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx,
enum var_init_status);
static dw_loc_descr_ref loc_descriptor (rtx, machine_mode mode,
enum var_init_status);
struct loc_descr_context;
static void add_loc_descr_to_each (dw_loc_list_ref list, dw_loc_descr_ref ref);
static void add_loc_list (dw_loc_list_ref *ret, dw_loc_list_ref list);
static dw_loc_list_ref loc_list_from_tree (tree, int,
struct loc_descr_context *);
static dw_loc_descr_ref loc_descriptor_from_tree (tree, int,
struct loc_descr_context *);
static tree field_type (const_tree);
static unsigned int simple_type_align_in_bits (const_tree);
static unsigned int simple_decl_align_in_bits (const_tree);
static unsigned HOST_WIDE_INT simple_type_size_in_bits (const_tree);
struct vlr_context;
static dw_loc_descr_ref field_byte_offset (const_tree, struct vlr_context *,
HOST_WIDE_INT *);
static void add_AT_location_description (dw_die_ref, enum dwarf_attribute,
dw_loc_list_ref);
static void add_data_member_location_attribute (dw_die_ref, tree,
struct vlr_context *);
static bool add_const_value_attribute (dw_die_ref, rtx);
static void insert_int (HOST_WIDE_INT, unsigned, unsigned char *);
static void insert_wide_int (const wide_int &, unsigned char *, int);
static void insert_float (const_rtx, unsigned char *);
static rtx rtl_for_decl_location (tree);
static bool add_location_or_const_value_attribute (dw_die_ref, tree, bool);
static bool tree_add_const_value_attribute (dw_die_ref, tree);
static bool tree_add_const_value_attribute_for_decl (dw_die_ref, tree);
static void add_name_attribute (dw_die_ref, const char *);
static void add_desc_attribute (dw_die_ref, tree);
static void add_gnat_descriptive_type_attribute (dw_die_ref, tree, dw_die_ref);
static void add_comp_dir_attribute (dw_die_ref);
static void add_scalar_info (dw_die_ref, enum dwarf_attribute, tree, int,
struct loc_descr_context *);
static void add_bound_info (dw_die_ref, enum dwarf_attribute, tree,
struct loc_descr_context *);
static void add_subscript_info (dw_die_ref, tree, bool);
static void add_byte_size_attribute (dw_die_ref, tree);
static void add_alignment_attribute (dw_die_ref, tree);
static void add_bit_offset_attribute (dw_die_ref, tree);
static void add_bit_size_attribute (dw_die_ref, tree);
static void add_prototyped_attribute (dw_die_ref, tree);
static void add_abstract_origin_attribute (dw_die_ref, tree);
static void add_pure_or_virtual_attribute (dw_die_ref, tree);
static void add_src_coords_attributes (dw_die_ref, tree);
static void add_name_and_src_coords_attributes (dw_die_ref, tree, bool = false);
static void add_discr_value (dw_die_ref, dw_discr_value *);
static void add_discr_list (dw_die_ref, dw_discr_list_ref);
static inline dw_discr_list_ref AT_discr_list (dw_attr_node *);
static dw_die_ref scope_die_for (tree, dw_die_ref);
static inline int local_scope_p (dw_die_ref);
static inline int class_scope_p (dw_die_ref);
static inline int class_or_namespace_scope_p (dw_die_ref);
static void add_type_attribute (dw_die_ref, tree, int, bool, dw_die_ref);
static void add_calling_convention_attribute (dw_die_ref, tree);
static const char *type_tag (const_tree);
static tree member_declared_type (const_tree);
#if 0
static const char *decl_start_label (tree);
#endif
static void gen_array_type_die (tree, dw_die_ref);
static void gen_descr_array_type_die (tree, struct array_descr_info *, dw_die_ref);
#if 0
static void gen_entry_point_die (tree, dw_die_ref);
#endif
static dw_die_ref gen_enumeration_type_die (tree, dw_die_ref);
static dw_die_ref gen_formal_parameter_die (tree, tree, bool, dw_die_ref);
static dw_die_ref gen_formal_parameter_pack_die (tree, tree, dw_die_ref, tree*);
static void gen_unspecified_parameters_die (tree, dw_die_ref);
static void gen_formal_types_die (tree, dw_die_ref);
static void gen_subprogram_die (tree, dw_die_ref);
static void gen_variable_die (tree, tree, dw_die_ref);
static void gen_const_die (tree, dw_die_ref);
static void gen_label_die (tree, dw_die_ref);
static void gen_lexical_block_die (tree, dw_die_ref);
static void gen_inlined_subroutine_die (tree, dw_die_ref);
static void gen_field_die (tree, struct vlr_context *, dw_die_ref);
static void gen_ptr_to_mbr_type_die (tree, dw_die_ref);
static dw_die_ref gen_compile_unit_die (const char *);
static void gen_inheritance_die (tree, tree, tree, dw_die_ref);
static void gen_member_die (tree, dw_die_ref);
static void gen_struct_or_union_type_die (tree, dw_die_ref,
enum debug_info_usage);
static void gen_subroutine_type_die (tree, dw_die_ref);
static void gen_typedef_die (tree, dw_die_ref);
static void gen_type_die (tree, dw_die_ref);
static void gen_block_die (tree, dw_die_ref);
static void decls_for_scope (tree, dw_die_ref, bool = true);
static bool is_naming_typedef_decl (const_tree);
static inline dw_die_ref get_context_die (tree);
static void gen_namespace_die (tree, dw_die_ref);
static dw_die_ref gen_namelist_decl (tree, dw_die_ref, tree);
static dw_die_ref gen_decl_die (tree, tree, struct vlr_context *, dw_die_ref);
static dw_die_ref force_decl_die (tree);
static dw_die_ref force_type_die (tree);
static dw_die_ref setup_namespace_context (tree, dw_die_ref);
static dw_die_ref declare_in_namespace (tree, dw_die_ref);
static struct dwarf_file_data * lookup_filename (const char *);
static void retry_incomplete_types (void);
static void gen_type_die_for_member (tree, tree, dw_die_ref);
static void gen_generic_params_dies (tree);
static void gen_tagged_type_die (tree, dw_die_ref, enum debug_info_usage);
static void gen_type_die_with_usage (tree, dw_die_ref, enum debug_info_usage);
static void splice_child_die (dw_die_ref, dw_die_ref);
static int file_info_cmp (const void *, const void *);
static dw_loc_list_ref new_loc_list (dw_loc_descr_ref, const char *, var_loc_view,
const char *, var_loc_view, const char *);
static void output_loc_list (dw_loc_list_ref);
static char *gen_internal_sym (const char *);
static bool want_pubnames (void);
static void prune_unmark_dies (dw_die_ref);
static void prune_unused_types_mark_generic_parms_dies (dw_die_ref);
static void prune_unused_types_mark (dw_die_ref, int);
static void prune_unused_types_walk (dw_die_ref);
static void prune_unused_types_walk_attribs (dw_die_ref);
static void prune_unused_types_prune (dw_die_ref);
static void prune_unused_types (void);
static int maybe_emit_file (struct dwarf_file_data *fd);
static inline const char *AT_vms_delta1 (dw_attr_node *);
static inline const char *AT_vms_delta2 (dw_attr_node *);
static inline void add_AT_vms_delta (dw_die_ref, enum dwarf_attribute,
const char *, const char *);
static void append_entry_to_tmpl_value_parm_die_table (dw_die_ref, tree);
static void gen_remaining_tmpl_value_param_die_attribute (void);
static bool generic_type_p (tree);
static void schedule_generic_params_dies_gen (tree t);
static void gen_scheduled_generic_parms_dies (void);
static void resolve_variable_values (void);
static const char *comp_dir_string (void);
static void hash_loc_operands (dw_loc_descr_ref, inchash::hash &);
/* enum for tracking thread-local variables whose address is really an offset
relative to the TLS pointer, which will need link-time relocation, but will
not need relocation by the DWARF consumer. */
enum dtprel_bool
{
dtprel_false = 0,
dtprel_true = 1
};
/* Return the operator to use for an address of a variable. For dtprel_true, we
use DW_OP_const*. For regular variables, which need both link-time
relocation and consumer-level relocation (e.g., to account for shared objects
loaded at a random address), we use DW_OP_addr*. */
static inline enum dwarf_location_atom
dw_addr_op (enum dtprel_bool dtprel)
{
if (dtprel == dtprel_true)
return (dwarf_split_debug_info ? dwarf_OP (DW_OP_constx)
: (DWARF2_ADDR_SIZE == 4 ? DW_OP_const4u : DW_OP_const8u));
else
return dwarf_split_debug_info ? dwarf_OP (DW_OP_addrx) : DW_OP_addr;
}
/* Return a pointer to a newly allocated address location description. If
dwarf_split_debug_info is true, then record the address with the appropriate
relocation. */
static inline dw_loc_descr_ref
new_addr_loc_descr (rtx addr, enum dtprel_bool dtprel)
{
dw_loc_descr_ref ref = new_loc_descr (dw_addr_op (dtprel), 0, 0);
ref->dw_loc_oprnd1.val_class = dw_val_class_addr;
ref->dw_loc_oprnd1.v.val_addr = addr;
ref->dtprel = dtprel;
if (dwarf_split_debug_info)
ref->dw_loc_oprnd1.val_entry
= add_addr_table_entry (addr,
dtprel ? ate_kind_rtx_dtprel : ate_kind_rtx);
else
ref->dw_loc_oprnd1.val_entry = NULL;
return ref;
}
/* Section names used to hold DWARF debugging information. */
#ifndef DEBUG_INFO_SECTION
#define DEBUG_INFO_SECTION ".debug_info"
#endif
#ifndef DEBUG_DWO_INFO_SECTION
#define DEBUG_DWO_INFO_SECTION ".debug_info.dwo"
#endif
#ifndef DEBUG_LTO_INFO_SECTION
#define DEBUG_LTO_INFO_SECTION ".gnu.debuglto_.debug_info"
#endif
#ifndef DEBUG_LTO_DWO_INFO_SECTION
#define DEBUG_LTO_DWO_INFO_SECTION ".gnu.debuglto_.debug_info.dwo"
#endif
#ifndef DEBUG_ABBREV_SECTION
#define DEBUG_ABBREV_SECTION ".debug_abbrev"
#endif
#ifndef DEBUG_LTO_ABBREV_SECTION
#define DEBUG_LTO_ABBREV_SECTION ".gnu.debuglto_.debug_abbrev"
#endif
#ifndef DEBUG_DWO_ABBREV_SECTION
#define DEBUG_DWO_ABBREV_SECTION ".debug_abbrev.dwo"
#endif
#ifndef DEBUG_LTO_DWO_ABBREV_SECTION
#define DEBUG_LTO_DWO_ABBREV_SECTION ".gnu.debuglto_.debug_abbrev.dwo"
#endif
#ifndef DEBUG_ARANGES_SECTION
#define DEBUG_ARANGES_SECTION ".debug_aranges"
#endif
#ifndef DEBUG_ADDR_SECTION
#define DEBUG_ADDR_SECTION ".debug_addr"
#endif
#ifndef DEBUG_MACINFO_SECTION
#define DEBUG_MACINFO_SECTION ".debug_macinfo"
#endif
#ifndef DEBUG_LTO_MACINFO_SECTION
#define DEBUG_LTO_MACINFO_SECTION ".gnu.debuglto_.debug_macinfo"
#endif
#ifndef DEBUG_DWO_MACINFO_SECTION
#define DEBUG_DWO_MACINFO_SECTION ".debug_macinfo.dwo"
#endif
#ifndef DEBUG_LTO_DWO_MACINFO_SECTION
#define DEBUG_LTO_DWO_MACINFO_SECTION ".gnu.debuglto_.debug_macinfo.dwo"
#endif
#ifndef DEBUG_MACRO_SECTION
#define DEBUG_MACRO_SECTION ".debug_macro"
#endif
#ifndef DEBUG_LTO_MACRO_SECTION
#define DEBUG_LTO_MACRO_SECTION ".gnu.debuglto_.debug_macro"
#endif
#ifndef DEBUG_DWO_MACRO_SECTION
#define DEBUG_DWO_MACRO_SECTION ".debug_macro.dwo"
#endif
#ifndef DEBUG_LTO_DWO_MACRO_SECTION
#define DEBUG_LTO_DWO_MACRO_SECTION ".gnu.debuglto_.debug_macro.dwo"
#endif
#ifndef DEBUG_LINE_SECTION
#define DEBUG_LINE_SECTION ".debug_line"
#endif
#ifndef DEBUG_LTO_LINE_SECTION
#define DEBUG_LTO_LINE_SECTION ".gnu.debuglto_.debug_line"
#endif
#ifndef DEBUG_DWO_LINE_SECTION
#define DEBUG_DWO_LINE_SECTION ".debug_line.dwo"
#endif
#ifndef DEBUG_LTO_DWO_LINE_SECTION
#define DEBUG_LTO_DWO_LINE_SECTION ".gnu.debuglto_.debug_line.dwo"
#endif
#ifndef DEBUG_LOC_SECTION
#define DEBUG_LOC_SECTION ".debug_loc"
#endif
#ifndef DEBUG_DWO_LOC_SECTION
#define DEBUG_DWO_LOC_SECTION ".debug_loc.dwo"
#endif
#ifndef DEBUG_LOCLISTS_SECTION
#define DEBUG_LOCLISTS_SECTION ".debug_loclists"
#endif
#ifndef DEBUG_DWO_LOCLISTS_SECTION
#define DEBUG_DWO_LOCLISTS_SECTION ".debug_loclists.dwo"
#endif
#ifndef DEBUG_PUBNAMES_SECTION
#define DEBUG_PUBNAMES_SECTION \
((debug_generate_pub_sections == 2) \
? ".debug_gnu_pubnames" : ".debug_pubnames")
#endif
#ifndef DEBUG_PUBTYPES_SECTION
#define DEBUG_PUBTYPES_SECTION \
((debug_generate_pub_sections == 2) \
? ".debug_gnu_pubtypes" : ".debug_pubtypes")
#endif
#ifndef DEBUG_STR_OFFSETS_SECTION
#define DEBUG_STR_OFFSETS_SECTION ".debug_str_offsets"
#endif
#ifndef DEBUG_DWO_STR_OFFSETS_SECTION
#define DEBUG_DWO_STR_OFFSETS_SECTION ".debug_str_offsets.dwo"
#endif
#ifndef DEBUG_LTO_DWO_STR_OFFSETS_SECTION
#define DEBUG_LTO_DWO_STR_OFFSETS_SECTION ".gnu.debuglto_.debug_str_offsets.dwo"
#endif
#ifndef DEBUG_STR_SECTION
#define DEBUG_STR_SECTION ".debug_str"
#endif
#ifndef DEBUG_LTO_STR_SECTION
#define DEBUG_LTO_STR_SECTION ".gnu.debuglto_.debug_str"
#endif
#ifndef DEBUG_STR_DWO_SECTION
#define DEBUG_STR_DWO_SECTION ".debug_str.dwo"
#endif
#ifndef DEBUG_LTO_STR_DWO_SECTION
#define DEBUG_LTO_STR_DWO_SECTION ".gnu.debuglto_.debug_str.dwo"
#endif
#ifndef DEBUG_RANGES_SECTION
#define DEBUG_RANGES_SECTION ".debug_ranges"
#endif
#ifndef DEBUG_RNGLISTS_SECTION
#define DEBUG_RNGLISTS_SECTION ".debug_rnglists"
#endif
#ifndef DEBUG_LINE_STR_SECTION
#define DEBUG_LINE_STR_SECTION ".debug_line_str"
#endif
#ifndef DEBUG_LTO_LINE_STR_SECTION
#define DEBUG_LTO_LINE_STR_SECTION ".gnu.debuglto_.debug_line_str"
#endif
/* Standard ELF section names for compiled code and data. */
#ifndef TEXT_SECTION_NAME
#define TEXT_SECTION_NAME ".text"
#endif
/* Section flags for .debug_str section. */
#define DEBUG_STR_SECTION_FLAGS \
(HAVE_GAS_SHF_MERGE && flag_merge_debug_strings \
? SECTION_DEBUG | SECTION_MERGE | SECTION_STRINGS | 1 \
: SECTION_DEBUG)
/* Section flags for .debug_str.dwo section. */
#define DEBUG_STR_DWO_SECTION_FLAGS (SECTION_DEBUG | SECTION_EXCLUDE)
/* Attribute used to refer to the macro section. */
#define DEBUG_MACRO_ATTRIBUTE (dwarf_version >= 5 ? DW_AT_macros \
: dwarf_strict ? DW_AT_macro_info : DW_AT_GNU_macros)
/* Labels we insert at beginning sections we can reference instead of
the section names themselves. */
#ifndef TEXT_SECTION_LABEL
#define TEXT_SECTION_LABEL "Ltext"
#endif
#ifndef COLD_TEXT_SECTION_LABEL
#define COLD_TEXT_SECTION_LABEL "Ltext_cold"
#endif
#ifndef DEBUG_LINE_SECTION_LABEL
#define DEBUG_LINE_SECTION_LABEL "Ldebug_line"
#endif
#ifndef DEBUG_SKELETON_LINE_SECTION_LABEL
#define DEBUG_SKELETON_LINE_SECTION_LABEL "Lskeleton_debug_line"
#endif
#ifndef DEBUG_INFO_SECTION_LABEL
#define DEBUG_INFO_SECTION_LABEL "Ldebug_info"
#endif
#ifndef DEBUG_SKELETON_INFO_SECTION_LABEL
#define DEBUG_SKELETON_INFO_SECTION_LABEL "Lskeleton_debug_info"
#endif
#ifndef DEBUG_ABBREV_SECTION_LABEL
#define DEBUG_ABBREV_SECTION_LABEL "Ldebug_abbrev"
#endif
#ifndef DEBUG_SKELETON_ABBREV_SECTION_LABEL
#define DEBUG_SKELETON_ABBREV_SECTION_LABEL "Lskeleton_debug_abbrev"
#endif
#ifndef DEBUG_ADDR_SECTION_LABEL
#define DEBUG_ADDR_SECTION_LABEL "Ldebug_addr"
#endif
#ifndef DEBUG_LOC_SECTION_LABEL
#define DEBUG_LOC_SECTION_LABEL "Ldebug_loc"
#endif
#ifndef DEBUG_RANGES_SECTION_LABEL
#define DEBUG_RANGES_SECTION_LABEL "Ldebug_ranges"
#endif
#ifndef DEBUG_MACINFO_SECTION_LABEL
#define DEBUG_MACINFO_SECTION_LABEL "Ldebug_macinfo"
#endif
#ifndef DEBUG_MACRO_SECTION_LABEL
#define DEBUG_MACRO_SECTION_LABEL "Ldebug_macro"
#endif
#define SKELETON_COMP_DIE_ABBREV 1
#define SKELETON_TYPE_DIE_ABBREV 2
/* Definitions of defaults for formats and names of various special
(artificial) labels which may be generated within this file (when the -g
options is used and DWARF2_DEBUGGING_INFO is in effect.
If necessary, these may be overridden from within the tm.h file, but
typically, overriding these defaults is unnecessary. */
static char text_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char text_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char cold_text_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char cold_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char debug_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char debug_skeleton_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char debug_skeleton_abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char debug_addr_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char debug_skeleton_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char macinfo_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char loc_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char ranges_section_label[2 * MAX_ARTIFICIAL_LABEL_BYTES];
static char ranges_base_label[2 * MAX_ARTIFICIAL_LABEL_BYTES];
#ifndef TEXT_END_LABEL
#define TEXT_END_LABEL "Letext"
#endif
#ifndef COLD_END_LABEL
#define COLD_END_LABEL "Letext_cold"
#endif
#ifndef BLOCK_BEGIN_LABEL
#define BLOCK_BEGIN_LABEL "LBB"
#endif
#ifndef BLOCK_INLINE_ENTRY_LABEL
#define BLOCK_INLINE_ENTRY_LABEL "LBI"
#endif
#ifndef BLOCK_END_LABEL
#define BLOCK_END_LABEL "LBE"
#endif
#ifndef LINE_CODE_LABEL
#define LINE_CODE_LABEL "LM"
#endif
/* Return the root of the DIE's built for the current compilation unit. */
static dw_die_ref
comp_unit_die (void)
{
if (!single_comp_unit_die)
single_comp_unit_die = gen_compile_unit_die (NULL);
return single_comp_unit_die;
}
/* We allow a language front-end to designate a function that is to be
called to "demangle" any name before it is put into a DIE. */
static const char *(*demangle_name_func) (const char *);
void
dwarf2out_set_demangle_name_func (const char *(*func) (const char *))
{
demangle_name_func = func;
}
/* Test if rtl node points to a pseudo register. */
static inline int
is_pseudo_reg (const_rtx rtl)
{
return ((REG_P (rtl) && REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
|| (GET_CODE (rtl) == SUBREG
&& REGNO (SUBREG_REG (rtl)) >= FIRST_PSEUDO_REGISTER));
}
/* Return a reference to a type, with its const and volatile qualifiers
removed. */
static inline tree
type_main_variant (tree type)
{
type = TYPE_MAIN_VARIANT (type);
/* ??? There really should be only one main variant among any group of
variants of a given type (and all of the MAIN_VARIANT values for all
members of the group should point to that one type) but sometimes the C
front-end messes this up for array types, so we work around that bug
here. */
if (TREE_CODE (type) == ARRAY_TYPE)
while (type != TYPE_MAIN_VARIANT (type))
type = TYPE_MAIN_VARIANT (type);
return type;
}
/* Return nonzero if the given type node represents a tagged type. */
static inline int
is_tagged_type (const_tree type)
{
enum tree_code code = TREE_CODE (type);
return (code == RECORD_TYPE || code == UNION_TYPE
|| code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
}
/* Set label to debug_info_section_label + die_offset of a DIE reference. */
static void
get_ref_die_offset_label (char *label, dw_die_ref ref)
{
sprintf (label, "%s+%ld", debug_info_section_label, ref->die_offset);
}
/* Return die_offset of a DIE reference to a base type. */
static unsigned long int
get_base_type_offset (dw_die_ref ref)
{
if (ref->die_offset)
return ref->die_offset;
if (comp_unit_die ()->die_abbrev)
{
calc_base_type_die_sizes ();
gcc_assert (ref->die_offset);
}
return ref->die_offset;
}
/* Return die_offset of a DIE reference other than base type. */
static unsigned long int
get_ref_die_offset (dw_die_ref ref)
{
gcc_assert (ref->die_offset);
return ref->die_offset;
}
/* Convert a DIE tag into its string name. */
static const char *
dwarf_tag_name (unsigned int tag)
{
const char *name = get_DW_TAG_name (tag);
if (name != NULL)
return name;
return "DW_TAG_<unknown>";
}
/* Convert a DWARF attribute code into its string name. */
static const char *
dwarf_attr_name (unsigned int attr)
{
const char *name;
switch (attr)
{
#if VMS_DEBUGGING_INFO
case DW_AT_HP_prologue:
return "DW_AT_HP_prologue";
#else
case DW_AT_MIPS_loop_unroll_factor:
return "DW_AT_MIPS_loop_unroll_factor";
#endif
#if VMS_DEBUGGING_INFO
case DW_AT_HP_epilogue:
return "DW_AT_HP_epilogue";
#else
case DW_AT_MIPS_stride:
return "DW_AT_MIPS_stride";
#endif
}
name = get_DW_AT_name (attr);
if (name != NULL)
return name;
return "DW_AT_<unknown>";
}
/* Convert a DWARF value form code into its string name. */
static const char *
dwarf_form_name (unsigned int form)
{
const char *name = get_DW_FORM_name (form);
if (name != NULL)
return name;
return "DW_FORM_<unknown>";
}
/* Determine the "ultimate origin" of a decl. The decl may be an inlined
instance of an inlined instance of a decl which is local to an inline
function, so we have to trace all of the way back through the origin chain
to find out what sort of node actually served as the original seed for the
given block. */
static tree
decl_ultimate_origin (const_tree decl)
{
if (!CODE_CONTAINS_STRUCT (TREE_CODE (decl), TS_DECL_COMMON))
return NULL_TREE;
/* DECL_ABSTRACT_ORIGIN can point to itself; ignore that if
we're trying to output the abstract instance of this function. */
if (DECL_ABSTRACT_P (decl) && DECL_ABSTRACT_ORIGIN (decl) == decl)
return NULL_TREE;
/* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
most distant ancestor, this should never happen. */
gcc_assert (!DECL_FROM_INLINE (DECL_ORIGIN (decl)));
return DECL_ABSTRACT_ORIGIN (decl);
}
/* Get the class to which DECL belongs, if any. In g++, the DECL_CONTEXT
of a virtual function may refer to a base class, so we check the 'this'
parameter. */
static tree
decl_class_context (tree decl)
{
tree context = NULL_TREE;
if (TREE_CODE (decl) != FUNCTION_DECL || ! DECL_VINDEX (decl))
context = DECL_CONTEXT (decl);
else
context = TYPE_MAIN_VARIANT
(TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))));
if (context && !TYPE_P (context))
context = NULL_TREE;
return context;
}
/* Add an attribute/value pair to a DIE. */
static inline void
add_dwarf_attr (dw_die_ref die, dw_attr_node *attr)
{
/* Maybe this should be an assert? */
if (die == NULL)
return;
if (flag_checking)
{
/* Check we do not add duplicate attrs. Can't use get_AT here
because that recurses to the specification/abstract origin DIE. */
dw_attr_node *a;
unsigned ix;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
gcc_assert (a->dw_attr != attr->dw_attr);
}
vec_safe_reserve (die->die_attr, 1);
vec_safe_push (die->die_attr, *attr);
}
static inline enum dw_val_class
AT_class (dw_attr_node *a)
{
return a->dw_attr_val.val_class;
}
/* Return the index for any attribute that will be referenced with a
DW_FORM_addrx/GNU_addr_index or DW_FORM_strx/GNU_str_index. String
indices are stored in dw_attr_val.v.val_str for reference counting
pruning. */
static inline unsigned int
AT_index (dw_attr_node *a)
{
if (AT_class (a) == dw_val_class_str)
return a->dw_attr_val.v.val_str->index;
else if (a->dw_attr_val.val_entry != NULL)
return a->dw_attr_val.val_entry->index;
return NOT_INDEXED;
}
/* Add a flag value attribute to a DIE. */
static inline void
add_AT_flag (dw_die_ref die, enum dwarf_attribute attr_kind, unsigned int flag)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_flag;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_flag = flag;
add_dwarf_attr (die, &attr);
}
static inline unsigned
AT_flag (dw_attr_node *a)
{
gcc_assert (a && AT_class (a) == dw_val_class_flag);
return a->dw_attr_val.v.val_flag;
}
/* Add a signed integer attribute value to a DIE. */
static inline void
add_AT_int (dw_die_ref die, enum dwarf_attribute attr_kind, HOST_WIDE_INT int_val)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_const;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_int = int_val;
add_dwarf_attr (die, &attr);
}
static inline HOST_WIDE_INT
AT_int (dw_attr_node *a)
{
gcc_assert (a && (AT_class (a) == dw_val_class_const
|| AT_class (a) == dw_val_class_const_implicit));
return a->dw_attr_val.v.val_int;
}
/* Add an unsigned integer attribute value to a DIE. */
static inline void
add_AT_unsigned (dw_die_ref die, enum dwarf_attribute attr_kind,
unsigned HOST_WIDE_INT unsigned_val)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_unsigned_const;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_unsigned = unsigned_val;
add_dwarf_attr (die, &attr);
}
static inline unsigned HOST_WIDE_INT
AT_unsigned (dw_attr_node *a)
{
gcc_assert (a && (AT_class (a) == dw_val_class_unsigned_const
|| AT_class (a) == dw_val_class_unsigned_const_implicit));
return a->dw_attr_val.v.val_unsigned;
}
/* Add an unsigned wide integer attribute value to a DIE. */
static inline void
add_AT_wide (dw_die_ref die, enum dwarf_attribute attr_kind,
const wide_int& w)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_wide_int;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_wide = ggc_alloc<wide_int> ();
*attr.dw_attr_val.v.val_wide = w;
add_dwarf_attr (die, &attr);
}
/* Add an unsigned double integer attribute value to a DIE. */
static inline void
add_AT_double (dw_die_ref die, enum dwarf_attribute attr_kind,
HOST_WIDE_INT high, unsigned HOST_WIDE_INT low)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_const_double;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_double.high = high;
attr.dw_attr_val.v.val_double.low = low;
add_dwarf_attr (die, &attr);
}
/* Add a floating point attribute value to a DIE and return it. */
static inline void
add_AT_vec (dw_die_ref die, enum dwarf_attribute attr_kind,
unsigned int length, unsigned int elt_size, unsigned char *array)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_vec;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_vec.length = length;
attr.dw_attr_val.v.val_vec.elt_size = elt_size;
attr.dw_attr_val.v.val_vec.array = array;
add_dwarf_attr (die, &attr);
}
/* Add an 8-byte data attribute value to a DIE. */
static inline void
add_AT_data8 (dw_die_ref die, enum dwarf_attribute attr_kind,
unsigned char data8[8])
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_data8;
attr.dw_attr_val.val_entry = NULL;
memcpy (attr.dw_attr_val.v.val_data8, data8, 8);
add_dwarf_attr (die, &attr);
}
/* Add DW_AT_low_pc and DW_AT_high_pc to a DIE. When using
dwarf_split_debug_info, address attributes in dies destined for the
final executable have force_direct set to avoid using indexed
references. */
static inline void
add_AT_low_high_pc (dw_die_ref die, const char *lbl_low, const char *lbl_high,
bool force_direct)
{
dw_attr_node attr;
char * lbl_id;
lbl_id = xstrdup (lbl_low);
attr.dw_attr = DW_AT_low_pc;
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
attr.dw_attr_val.v.val_lbl_id = lbl_id;
if (dwarf_split_debug_info && !force_direct)
attr.dw_attr_val.val_entry
= add_addr_table_entry (lbl_id, ate_kind_label);
else
attr.dw_attr_val.val_entry = NULL;
add_dwarf_attr (die, &attr);
attr.dw_attr = DW_AT_high_pc;
if (dwarf_version < 4)
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
else
attr.dw_attr_val.val_class = dw_val_class_high_pc;
lbl_id = xstrdup (lbl_high);
attr.dw_attr_val.v.val_lbl_id = lbl_id;
if (attr.dw_attr_val.val_class == dw_val_class_lbl_id
&& dwarf_split_debug_info && !force_direct)
attr.dw_attr_val.val_entry
= add_addr_table_entry (lbl_id, ate_kind_label);
else
attr.dw_attr_val.val_entry = NULL;
add_dwarf_attr (die, &attr);
}
/* Hash and equality functions for debug_str_hash. */
hashval_t
indirect_string_hasher::hash (indirect_string_node *x)
{
return htab_hash_string (x->str);
}
bool
indirect_string_hasher::equal (indirect_string_node *x1, const char *x2)
{
return strcmp (x1->str, x2) == 0;
}
/* Add STR to the given string hash table. */
static struct indirect_string_node *
find_AT_string_in_table (const char *str,
hash_table<indirect_string_hasher> *table,
enum insert_option insert = INSERT)
{
struct indirect_string_node *node;
indirect_string_node **slot
= table->find_slot_with_hash (str, htab_hash_string (str), insert);
if (*slot == NULL)
{
node = ggc_cleared_alloc<indirect_string_node> ();
node->str = ggc_strdup (str);
*slot = node;
}
else
node = *slot;
node->refcount++;
return node;
}
/* Add STR to the indirect string hash table. */
static struct indirect_string_node *
find_AT_string (const char *str, enum insert_option insert = INSERT)
{
if (! debug_str_hash)
debug_str_hash = hash_table<indirect_string_hasher>::create_ggc (10);
return find_AT_string_in_table (str, debug_str_hash, insert);
}
/* Add a string attribute value to a DIE. */
static inline void
add_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind, const char *str)
{
dw_attr_node attr;
struct indirect_string_node *node;
node = find_AT_string (str);
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_str;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_str = node;
add_dwarf_attr (die, &attr);
}
static inline const char *
AT_string (dw_attr_node *a)
{
gcc_assert (a && AT_class (a) == dw_val_class_str);
return a->dw_attr_val.v.val_str->str;
}
/* Call this function directly to bypass AT_string_form's logic to put
the string inline in the die. */
static void
set_indirect_string (struct indirect_string_node *node)
{
char label[MAX_ARTIFICIAL_LABEL_BYTES];
/* Already indirect is a no op. */
if (node->form == DW_FORM_strp
|| node->form == DW_FORM_line_strp
|| node->form == dwarf_FORM (DW_FORM_strx))
{
gcc_assert (node->label);
return;
}
ASM_GENERATE_INTERNAL_LABEL (label, "LASF", dw2_string_counter);
++dw2_string_counter;
node->label = xstrdup (label);
if (!dwarf_split_debug_info)
{
node->form = DW_FORM_strp;
node->index = NOT_INDEXED;
}
else
{
node->form = dwarf_FORM (DW_FORM_strx);
node->index = NO_INDEX_ASSIGNED;
}
}
/* A helper function for dwarf2out_finish, called to reset indirect
string decisions done for early LTO dwarf output before fat object
dwarf output. */
int
reset_indirect_string (indirect_string_node **h, void *)
{
struct indirect_string_node *node = *h;
if (node->form == DW_FORM_strp || node->form == dwarf_FORM (DW_FORM_strx))
{
free (node->label);
node->label = NULL;
node->form = (dwarf_form) 0;
node->index = 0;
}
return 1;
}
/* Add a string representing a file or filepath attribute value to a DIE. */
static inline void
add_filepath_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind,
const char *str)
{
if (! asm_outputs_debug_line_str ())
add_AT_string (die, attr_kind, str);
else
{
dw_attr_node attr;
struct indirect_string_node *node;
if (!debug_line_str_hash)
debug_line_str_hash
= hash_table<indirect_string_hasher>::create_ggc (10);
node = find_AT_string_in_table (str, debug_line_str_hash);
set_indirect_string (node);
node->form = DW_FORM_line_strp;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_str;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_str = node;
add_dwarf_attr (die, &attr);
}
}
/* Find out whether a string should be output inline in DIE
or out-of-line in .debug_str section. */
static enum dwarf_form
find_string_form (struct indirect_string_node *node)
{
unsigned int len;
if (node->form)
return node->form;
len = strlen (node->str) + 1;
/* If the string is shorter or equal to the size of the reference, it is
always better to put it inline. */
if (len <= DWARF_OFFSET_SIZE || node->refcount == 0)
return node->form = DW_FORM_string;
/* If we cannot expect the linker to merge strings in .debug_str
section, only put it into .debug_str if it is worth even in this
single module. */
if (DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET
|| ((debug_str_section->common.flags & SECTION_MERGE) == 0
&& (len - DWARF_OFFSET_SIZE) * node->refcount <= len))
return node->form = DW_FORM_string;
set_indirect_string (node);
return node->form;
}
/* Find out whether the string referenced from the attribute should be
output inline in DIE or out-of-line in .debug_str section. */
static enum dwarf_form
AT_string_form (dw_attr_node *a)
{
gcc_assert (a && AT_class (a) == dw_val_class_str);
return find_string_form (a->dw_attr_val.v.val_str);
}
/* Add a DIE reference attribute value to a DIE. */
static inline void
add_AT_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, dw_die_ref targ_die)
{
dw_attr_node attr;
gcc_checking_assert (targ_die != NULL);
/* With LTO we can end up trying to reference something we didn't create
a DIE for. Avoid crashing later on a NULL referenced DIE. */
if (targ_die == NULL)
return;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_die_ref;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_die_ref.die = targ_die;
attr.dw_attr_val.v.val_die_ref.external = 0;
add_dwarf_attr (die, &attr);
}
/* Change DIE reference REF to point to NEW_DIE instead. */
static inline void
change_AT_die_ref (dw_attr_node *ref, dw_die_ref new_die)
{
gcc_assert (ref->dw_attr_val.val_class == dw_val_class_die_ref);
ref->dw_attr_val.v.val_die_ref.die = new_die;
ref->dw_attr_val.v.val_die_ref.external = 0;
}
/* Add an AT_specification attribute to a DIE, and also make the back
pointer from the specification to the definition. */
static inline void
add_AT_specification (dw_die_ref die, dw_die_ref targ_die)
{
add_AT_die_ref (die, DW_AT_specification, targ_die);
gcc_assert (!targ_die->die_definition);
targ_die->die_definition = die;
}
static inline dw_die_ref
AT_ref (dw_attr_node *a)
{
gcc_assert (a && AT_class (a) == dw_val_class_die_ref);
return a->dw_attr_val.v.val_die_ref.die;
}
static inline int
AT_ref_external (dw_attr_node *a)
{
if (a && AT_class (a) == dw_val_class_die_ref)
return a->dw_attr_val.v.val_die_ref.external;
return 0;
}
static inline void
set_AT_ref_external (dw_attr_node *a, int i)
{
gcc_assert (a && AT_class (a) == dw_val_class_die_ref);
a->dw_attr_val.v.val_die_ref.external = i;
}
/* Add a location description attribute value to a DIE. */
static inline void
add_AT_loc (dw_die_ref die, enum dwarf_attribute attr_kind, dw_loc_descr_ref loc)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_loc;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_loc = loc;
add_dwarf_attr (die, &attr);
}
static inline dw_loc_descr_ref
AT_loc (dw_attr_node *a)
{
gcc_assert (a && AT_class (a) == dw_val_class_loc);
return a->dw_attr_val.v.val_loc;
}
static inline void
add_AT_loc_list (dw_die_ref die, enum dwarf_attribute attr_kind, dw_loc_list_ref loc_list)
{
dw_attr_node attr;
if (XCOFF_DEBUGGING_INFO && !HAVE_XCOFF_DWARF_EXTRAS)
return;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_loc_list;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_loc_list = loc_list;
add_dwarf_attr (die, &attr);
have_location_lists = true;
}
static inline dw_loc_list_ref
AT_loc_list (dw_attr_node *a)
{
gcc_assert (a && AT_class (a) == dw_val_class_loc_list);
return a->dw_attr_val.v.val_loc_list;
}
/* Add a view list attribute to DIE. It must have a DW_AT_location
attribute, because the view list complements the location list. */
static inline void
add_AT_view_list (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node attr;
if (XCOFF_DEBUGGING_INFO && !HAVE_XCOFF_DWARF_EXTRAS)
return;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_view_list;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_view_list = die;
add_dwarf_attr (die, &attr);
gcc_checking_assert (get_AT (die, DW_AT_location));
gcc_assert (have_location_lists);
}
/* Return a pointer to the location list referenced by the attribute.
If the named attribute is a view list, look up the corresponding
DW_AT_location attribute and return its location list. */
static inline dw_loc_list_ref *
AT_loc_list_ptr (dw_attr_node *a)
{
gcc_assert (a);
switch (AT_class (a))
{
case dw_val_class_loc_list:
return &a->dw_attr_val.v.val_loc_list;
case dw_val_class_view_list:
{
dw_attr_node *l;
l = get_AT (a->dw_attr_val.v.val_view_list, DW_AT_location);
if (!l)
return NULL;
gcc_checking_assert (l + 1 == a);
return AT_loc_list_ptr (l);
}
default:
gcc_unreachable ();
}
}
/* Return the location attribute value associated with a view list
attribute value. */
static inline dw_val_node *
view_list_to_loc_list_val_node (dw_val_node *val)
{
gcc_assert (val->val_class == dw_val_class_view_list);
dw_attr_node *loc = get_AT (val->v.val_view_list, DW_AT_location);
if (!loc)
return NULL;
gcc_checking_assert (&(loc + 1)->dw_attr_val == val);
gcc_assert (AT_class (loc) == dw_val_class_loc_list);
return &loc->dw_attr_val;
}
struct addr_hasher : ggc_ptr_hash<addr_table_entry>
{
static hashval_t hash (addr_table_entry *);
static bool equal (addr_table_entry *, addr_table_entry *);
};
/* Table of entries into the .debug_addr section. */
static GTY (()) hash_table<addr_hasher> *addr_index_table;
/* Hash an address_table_entry. */
hashval_t
addr_hasher::hash (addr_table_entry *a)
{
inchash::hash hstate;
switch (a->kind)
{
case ate_kind_rtx:
hstate.add_int (0);
break;
case ate_kind_rtx_dtprel:
hstate.add_int (1);
break;
case ate_kind_label:
return htab_hash_string (a->addr.label);
default:
gcc_unreachable ();
}
inchash::add_rtx (a->addr.rtl, hstate);
return hstate.end ();
}
/* Determine equality for two address_table_entries. */
bool
addr_hasher::equal (addr_table_entry *a1, addr_table_entry *a2)
{
if (a1->kind != a2->kind)
return 0;
switch (a1->kind)
{
case ate_kind_rtx:
case ate_kind_rtx_dtprel:
return rtx_equal_p (a1->addr.rtl, a2->addr.rtl);
case ate_kind_label:
return strcmp (a1->addr.label, a2->addr.label) == 0;
default:
gcc_unreachable ();
}
}
/* Initialize an addr_table_entry. */
void
init_addr_table_entry (addr_table_entry *e, enum ate_kind kind, void *addr)
{
e->kind = kind;
switch (kind)
{
case ate_kind_rtx:
case ate_kind_rtx_dtprel:
e->addr.rtl = (rtx) addr;
break;
case ate_kind_label:
e->addr.label = (char *) addr;
break;
}
e->refcount = 0;
e->index = NO_INDEX_ASSIGNED;
}
/* Add attr to the address table entry to the table. Defer setting an
index until output time. */
static addr_table_entry *
add_addr_table_entry (void *addr, enum ate_kind kind)
{
addr_table_entry *node;
addr_table_entry finder;
gcc_assert (dwarf_split_debug_info);
if (! addr_index_table)
addr_index_table = hash_table<addr_hasher>::create_ggc (10);
init_addr_table_entry (&finder, kind, addr);
addr_table_entry **slot = addr_index_table->find_slot (&finder, INSERT);
if (*slot == HTAB_EMPTY_ENTRY)
{
node = ggc_cleared_alloc<addr_table_entry> ();
init_addr_table_entry (node, kind, addr);
*slot = node;
}
else
node = *slot;
node->refcount++;
return node;
}
/* Remove an entry from the addr table by decrementing its refcount.
Strictly, decrementing the refcount would be enough, but the
assertion that the entry is actually in the table has found
bugs. */
static void
remove_addr_table_entry (addr_table_entry *entry)
{
gcc_assert (dwarf_split_debug_info && addr_index_table);
/* After an index is assigned, the table is frozen. */
gcc_assert (entry->refcount > 0 && entry->index == NO_INDEX_ASSIGNED);
entry->refcount--;
}
/* Given a location list, remove all addresses it refers to from the
address_table. */
static void
remove_loc_list_addr_table_entries (dw_loc_descr_ref descr)
{
for (; descr; descr = descr->dw_loc_next)
if (descr->dw_loc_oprnd1.val_entry != NULL)
{
gcc_assert (descr->dw_loc_oprnd1.val_entry->index == NO_INDEX_ASSIGNED);
remove_addr_table_entry (descr->dw_loc_oprnd1.val_entry);
}
}
/* A helper function for dwarf2out_finish called through
htab_traverse. Assign an addr_table_entry its index. All entries
must be collected into the table when this function is called,
because the indexing code relies on htab_traverse to traverse nodes
in the same order for each run. */
int
index_addr_table_entry (addr_table_entry **h, unsigned int *index)
{
addr_table_entry *node = *h;
/* Don't index unreferenced nodes. */
if (node->refcount == 0)
return 1;
gcc_assert (node->index == NO_INDEX_ASSIGNED);
node->index = *index;
*index += 1;
return 1;
}
/* Add an address constant attribute value to a DIE. When using
dwarf_split_debug_info, address attributes in dies destined for the
final executable should be direct references--setting the parameter
force_direct ensures this behavior. */
static inline void
add_AT_addr (dw_die_ref die, enum dwarf_attribute attr_kind, rtx addr,
bool force_direct)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_addr;
attr.dw_attr_val.v.val_addr = addr;
if (dwarf_split_debug_info && !force_direct)
attr.dw_attr_val.val_entry = add_addr_table_entry (addr, ate_kind_rtx);
else
attr.dw_attr_val.val_entry = NULL;
add_dwarf_attr (die, &attr);
}
/* Get the RTX from to an address DIE attribute. */
static inline rtx
AT_addr (dw_attr_node *a)
{
gcc_assert (a && AT_class (a) == dw_val_class_addr);
return a->dw_attr_val.v.val_addr;
}
/* Add a file attribute value to a DIE. */
static inline void
add_AT_file (dw_die_ref die, enum dwarf_attribute attr_kind,
struct dwarf_file_data *fd)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_file;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_file = fd;
add_dwarf_attr (die, &attr);
}
/* Get the dwarf_file_data from a file DIE attribute. */
static inline struct dwarf_file_data *
AT_file (dw_attr_node *a)
{
gcc_assert (a && (AT_class (a) == dw_val_class_file
|| AT_class (a) == dw_val_class_file_implicit));
return a->dw_attr_val.v.val_file;
}
/* Add a vms delta attribute value to a DIE. */
static inline void
add_AT_vms_delta (dw_die_ref die, enum dwarf_attribute attr_kind,
const char *lbl1, const char *lbl2)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_vms_delta;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_vms_delta.lbl1 = xstrdup (lbl1);
attr.dw_attr_val.v.val_vms_delta.lbl2 = xstrdup (lbl2);
add_dwarf_attr (die, &attr);
}
/* Add a symbolic view identifier attribute value to a DIE. */
static inline void
add_AT_symview (dw_die_ref die, enum dwarf_attribute attr_kind,
const char *view_label)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_symview;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_symbolic_view = xstrdup (view_label);
add_dwarf_attr (die, &attr);
}
/* Add a label identifier attribute value to a DIE. */
static inline void
add_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind,
const char *lbl_id)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
if (dwarf_split_debug_info)
attr.dw_attr_val.val_entry
= add_addr_table_entry (attr.dw_attr_val.v.val_lbl_id,
ate_kind_label);
add_dwarf_attr (die, &attr);
}
/* Add a section offset attribute value to a DIE, an offset into the
debug_line section. */
static inline void
add_AT_lineptr (dw_die_ref die, enum dwarf_attribute attr_kind,
const char *label)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_lineptr;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_lbl_id = xstrdup (label);
add_dwarf_attr (die, &attr);
}
/* Add a section offset attribute value to a DIE, an offset into the
debug_macinfo section. */
static inline void
add_AT_macptr (dw_die_ref die, enum dwarf_attribute attr_kind,
const char *label)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_macptr;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_lbl_id = xstrdup (label);
add_dwarf_attr (die, &attr);
}
/* Add a range_list attribute value to a DIE. When using
dwarf_split_debug_info, address attributes in dies destined for the
final executable should be direct references--setting the parameter
force_direct ensures this behavior. */
#define UNRELOCATED_OFFSET ((addr_table_entry *) 1)
#define RELOCATED_OFFSET (NULL)
static void
add_AT_range_list (dw_die_ref die, enum dwarf_attribute attr_kind,
long unsigned int offset, bool force_direct)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_range_list;
/* For the range_list attribute, use val_entry to store whether the
offset should follow split-debug-info or normal semantics. This
value is read in output_range_list_offset. */
if (dwarf_split_debug_info && !force_direct)
attr.dw_attr_val.val_entry = UNRELOCATED_OFFSET;
else
attr.dw_attr_val.val_entry = RELOCATED_OFFSET;
attr.dw_attr_val.v.val_offset = offset;
add_dwarf_attr (die, &attr);
}
/* Return the start label of a delta attribute. */
static inline const char *
AT_vms_delta1 (dw_attr_node *a)
{
gcc_assert (a && (AT_class (a) == dw_val_class_vms_delta));
return a->dw_attr_val.v.val_vms_delta.lbl1;
}
/* Return the end label of a delta attribute. */
static inline const char *
AT_vms_delta2 (dw_attr_node *a)
{
gcc_assert (a && (AT_class (a) == dw_val_class_vms_delta));
return a->dw_attr_val.v.val_vms_delta.lbl2;
}
static inline const char *
AT_lbl (dw_attr_node *a)
{
gcc_assert (a && (AT_class (a) == dw_val_class_lbl_id
|| AT_class (a) == dw_val_class_lineptr
|| AT_class (a) == dw_val_class_macptr
|| AT_class (a) == dw_val_class_loclistsptr
|| AT_class (a) == dw_val_class_high_pc));
return a->dw_attr_val.v.val_lbl_id;
}
/* Get the attribute of type attr_kind. */
static dw_attr_node *
get_AT (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node *a;
unsigned ix;
dw_die_ref spec = NULL;
if (! die)
return NULL;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (a->dw_attr == attr_kind)
return a;
else if (a->dw_attr == DW_AT_specification
|| a->dw_attr == DW_AT_abstract_origin)
spec = AT_ref (a);
if (spec)
return get_AT (spec, attr_kind);
return NULL;
}
/* Returns the parent of the declaration of DIE. */
static dw_die_ref
get_die_parent (dw_die_ref die)
{
dw_die_ref t;
if (!die)
return NULL;
if ((t = get_AT_ref (die, DW_AT_abstract_origin))
|| (t = get_AT_ref (die, DW_AT_specification)))
die = t;
return die->die_parent;
}
/* Return the "low pc" attribute value, typically associated with a subprogram
DIE. Return null if the "low pc" attribute is either not present, or if it
cannot be represented as an assembler label identifier. */
static inline const char *
get_AT_low_pc (dw_die_ref die)
{
dw_attr_node *a = get_AT (die, DW_AT_low_pc);
return a ? AT_lbl (a) : NULL;
}
/* Return the value of the string attribute designated by ATTR_KIND, or
NULL if it is not present. */
static inline const char *
get_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node *a = get_AT (die, attr_kind);
return a ? AT_string (a) : NULL;
}
/* Return the value of the flag attribute designated by ATTR_KIND, or -1
if it is not present. */
static inline int
get_AT_flag (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node *a = get_AT (die, attr_kind);
return a ? AT_flag (a) : 0;
}
/* Return the value of the unsigned attribute designated by ATTR_KIND, or 0
if it is not present. */
static inline unsigned
get_AT_unsigned (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node *a = get_AT (die, attr_kind);
return a ? AT_unsigned (a) : 0;
}
static inline dw_die_ref
get_AT_ref (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node *a = get_AT (die, attr_kind);
return a ? AT_ref (a) : NULL;
}
static inline struct dwarf_file_data *
get_AT_file (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node *a = get_AT (die, attr_kind);
return a ? AT_file (a) : NULL;
}
/* Return TRUE if the language is C. */
static inline bool
is_c (void)
{
unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
return (lang == DW_LANG_C || lang == DW_LANG_C89 || lang == DW_LANG_C99
|| lang == DW_LANG_C11 || lang == DW_LANG_ObjC);
}
/* Return TRUE if the language is C++. */
static inline bool
is_cxx (void)
{
unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
return (lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus
|| lang == DW_LANG_C_plus_plus_11 || lang == DW_LANG_C_plus_plus_14);
}
/* Return TRUE if DECL was created by the C++ frontend. */
static bool
is_cxx (const_tree decl)
{
if (in_lto_p)
{
const_tree context = get_ultimate_context (decl);
if (context && TRANSLATION_UNIT_LANGUAGE (context))
return strncmp (TRANSLATION_UNIT_LANGUAGE (context), "GNU C++", 7) == 0;
}
return is_cxx ();
}
/* Return TRUE if the language is Fortran. */
static inline bool
is_fortran (void)
{
unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
return (lang == DW_LANG_Fortran77
|| lang == DW_LANG_Fortran90
|| lang == DW_LANG_Fortran95
|| lang == DW_LANG_Fortran03
|| lang == DW_LANG_Fortran08);
}
static inline bool
is_fortran (const_tree decl)
{
if (in_lto_p)
{
const_tree context = get_ultimate_context (decl);
if (context && TRANSLATION_UNIT_LANGUAGE (context))
return (strncmp (TRANSLATION_UNIT_LANGUAGE (context),
"GNU Fortran", 11) == 0
|| strcmp (TRANSLATION_UNIT_LANGUAGE (context),
"GNU F77") == 0);
}
return is_fortran ();
}
/* Return TRUE if the language is Ada. */
static inline bool
is_ada (void)
{
unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
return lang == DW_LANG_Ada95 || lang == DW_LANG_Ada83;
}
/* Return TRUE if the language is D. */
static inline bool
is_dlang (void)
{
unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
return lang == DW_LANG_D;
}
/* Remove the specified attribute if present. Return TRUE if removal
was successful. */
static bool
remove_AT (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node *a;
unsigned ix;
if (! die)
return false;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (a->dw_attr == attr_kind)
{
if (AT_class (a) == dw_val_class_str)
if (a->dw_attr_val.v.val_str->refcount)
a->dw_attr_val.v.val_str->refcount--;
/* vec::ordered_remove should help reduce the number of abbrevs
that are needed. */
die->die_attr->ordered_remove (ix);
return true;
}
return false;
}
/* Remove CHILD from its parent. PREV must have the property that
PREV->DIE_SIB == CHILD. Does not alter CHILD. */
static void
remove_child_with_prev (dw_die_ref child, dw_die_ref prev)
{
gcc_assert (child->die_parent == prev->die_parent);
gcc_assert (prev->die_sib == child);
if (prev == child)
{
gcc_assert (child->die_parent->die_child == child);
prev = NULL;
}
else
prev->die_sib = child->die_sib;
if (child->die_parent->die_child == child)
child->die_parent->die_child = prev;
child->die_sib = NULL;
}
/* Replace OLD_CHILD with NEW_CHILD. PREV must have the property that
PREV->DIE_SIB == OLD_CHILD. Does not alter OLD_CHILD. */
static void
replace_child (dw_die_ref old_child, dw_die_ref new_child, dw_die_ref prev)
{
dw_die_ref parent = old_child->die_parent;
gcc_assert (parent == prev->die_parent);
gcc_assert (prev->die_sib == old_child);
new_child->die_parent = parent;
if (prev == old_child)
{
gcc_assert (parent->die_child == old_child);
new_child->die_sib = new_child;
}
else
{
prev->die_sib = new_child;
new_child->die_sib = old_child->die_sib;
}
if (old_child->die_parent->die_child == old_child)
old_child->die_parent->die_child = new_child;
old_child->die_sib = NULL;
}
/* Move all children from OLD_PARENT to NEW_PARENT. */
static void
move_all_children (dw_die_ref old_parent, dw_die_ref new_parent)
{
dw_die_ref c;
new_parent->die_child = old_parent->die_child;
old_parent->die_child = NULL;
FOR_EACH_CHILD (new_parent, c, c->die_parent = new_parent);
}
/* Remove child DIE whose die_tag is TAG. Do nothing if no child
matches TAG. */
static void
remove_child_TAG (dw_die_ref die, enum dwarf_tag tag)
{
dw_die_ref c;
c = die->die_child;
if (c) do {
dw_die_ref prev = c;
c = c->die_sib;
while (c->die_tag == tag)
{
remove_child_with_prev (c, prev);
c->die_parent = NULL;
/* Might have removed every child. */
if (die->die_child == NULL)
return;
c = prev->die_sib;
}
} while (c != die->die_child);
}
/* Add a CHILD_DIE as the last child of DIE. */
static void
add_child_die (dw_die_ref die, dw_die_ref child_die)
{
/* FIXME this should probably be an assert. */
if (! die || ! child_die)
return;
gcc_assert (die != child_die);
child_die->die_parent = die;
if (die->die_child)
{
child_die->die_sib = die->die_child->die_sib;
die->die_child->die_sib = child_die;
}
else
child_die->die_sib = child_die;
die->die_child = child_die;
}
/* Like add_child_die, but put CHILD_DIE after AFTER_DIE. */
static void
add_child_die_after (dw_die_ref die, dw_die_ref child_die,
dw_die_ref after_die)
{
gcc_assert (die
&& child_die
&& after_die
&& die->die_child
&& die != child_die);
child_die->die_parent = die;
child_die->die_sib = after_die->die_sib;
after_die->die_sib = child_die;
if (die->die_child == after_die)
die->die_child = child_die;
}
/* Unassociate CHILD from its parent, and make its parent be
NEW_PARENT. */
static void
reparent_child (dw_die_ref child, dw_die_ref new_parent)
{
for (dw_die_ref p = child->die_parent->die_child; ; p = p->die_sib)
if (p->die_sib == child)
{
remove_child_with_prev (child, p);
break;
}
add_child_die (new_parent, child);
}
/* Move CHILD, which must be a child of PARENT or the DIE for which PARENT
is the specification, to the end of PARENT's list of children.
This is done by removing and re-adding it. */
static void
splice_child_die (dw_die_ref parent, dw_die_ref child)
{
/* We want the declaration DIE from inside the class, not the
specification DIE at toplevel. */
if (child->die_parent != parent)
{
dw_die_ref tmp = get_AT_ref (child, DW_AT_specification);
if (tmp)
child = tmp;
}
gcc_assert (child->die_parent == parent
|| (child->die_parent
== get_AT_ref (parent, DW_AT_specification)));
reparent_child (child, parent);
}
/* Create and return a new die with TAG_VALUE as tag. */
static inline dw_die_ref
new_die_raw (enum dwarf_tag tag_value)
{
dw_die_ref die = ggc_cleared_alloc<die_node> ();
die->die_tag = tag_value;
return die;
}
/* Create and return a new die with a parent of PARENT_DIE. If
PARENT_DIE is NULL, the new DIE is placed in limbo and an
associated tree T must be supplied to determine parenthood
later. */
static inline dw_die_ref
new_die (enum dwarf_tag tag_value, dw_die_ref parent_die, tree t)
{
dw_die_ref die = new_die_raw (tag_value);
if (parent_die != NULL)
add_child_die (parent_die, die);
else
{
limbo_die_node *limbo_node;
/* No DIEs created after early dwarf should end up in limbo,
because the limbo list should not persist past LTO
streaming. */
if (tag_value != DW_TAG_compile_unit
/* These are allowed because they're generated while
breaking out COMDAT units late. */
&& tag_value != DW_TAG_type_unit
&& tag_value != DW_TAG_skeleton_unit
&& !early_dwarf
/* Allow nested functions to live in limbo because they will
only temporarily live there, as decls_for_scope will fix
them up. */
&& (TREE_CODE (t) != FUNCTION_DECL
|| !decl_function_context (t))
/* Same as nested functions above but for types. Types that
are local to a function will be fixed in
decls_for_scope. */
&& (!RECORD_OR_UNION_TYPE_P (t)
|| !TYPE_CONTEXT (t)
|| TREE_CODE (TYPE_CONTEXT (t)) != FUNCTION_DECL)
/* FIXME debug-early: Allow late limbo DIE creation for LTO,
especially in the ltrans stage, but once we implement LTO
dwarf streaming, we should remove this exception. */
&& !in_lto_p)
{
fprintf (stderr, "symbol ended up in limbo too late:");
debug_generic_stmt (t);
gcc_unreachable ();
}
limbo_node = ggc_cleared_alloc<limbo_die_node> ();
limbo_node->die = die;
limbo_node->created_for = t;
limbo_node->next = limbo_die_list;
limbo_die_list = limbo_node;
}
return die;
}
/* Return the DIE associated with the given type specifier. */
static inline dw_die_ref
lookup_type_die (tree type)
{
dw_die_ref die = TYPE_SYMTAB_DIE (type);
if (die && die->removed)
{
TYPE_SYMTAB_DIE (type) = NULL;
return NULL;
}
return die;
}
/* Given a TYPE_DIE representing the type TYPE, if TYPE is an
anonymous type named by the typedef TYPE_DIE, return the DIE of the
anonymous type instead the one of the naming typedef. */
static inline dw_die_ref
strip_naming_typedef (tree type, dw_die_ref type_die)
{
if (type
&& TREE_CODE (type) == RECORD_TYPE
&& type_die
&& type_die->die_tag == DW_TAG_typedef
&& is_naming_typedef_decl (TYPE_NAME (type)))
type_die = get_AT_ref (type_die, DW_AT_type);
return type_die;
}
/* Like lookup_type_die, but if type is an anonymous type named by a
typedef[1], return the DIE of the anonymous type instead the one of
the naming typedef. This is because in gen_typedef_die, we did
equate the anonymous struct named by the typedef with the DIE of
the naming typedef. So by default, lookup_type_die on an anonymous
struct yields the DIE of the naming typedef.
[1]: Read the comment of is_naming_typedef_decl to learn about what
a naming typedef is. */
static inline dw_die_ref
lookup_type_die_strip_naming_typedef (tree type)
{
dw_die_ref die = lookup_type_die (type);
return strip_naming_typedef (type, die);
}
/* Equate a DIE to a given type specifier. */
static inline void
equate_type_number_to_die (tree type, dw_die_ref type_die)
{
TYPE_SYMTAB_DIE (type) = type_die;
}
static dw_die_ref maybe_create_die_with_external_ref (tree);
struct GTY(()) sym_off_pair
{
const char * GTY((skip)) sym;
unsigned HOST_WIDE_INT off;
};
static GTY(()) hash_map<tree, sym_off_pair> *external_die_map;
/* Returns a hash value for X (which really is a die_struct). */
inline hashval_t
decl_die_hasher::hash (die_node *x)
{
return (hashval_t) x->decl_id;
}
/* Return nonzero if decl_id of die_struct X is the same as UID of decl *Y. */
inline bool
decl_die_hasher::equal (die_node *x, tree y)
{
return (x->decl_id == DECL_UID (y));
}
/* Return the DIE associated with a given declaration. */
static inline dw_die_ref
lookup_decl_die (tree decl)
{
dw_die_ref *die = decl_die_table->find_slot_with_hash (decl, DECL_UID (decl),
NO_INSERT);
if (!die)
{
if (in_lto_p)
return maybe_create_die_with_external_ref (decl);
return NULL;
}
if ((*die)->removed)
{
decl_die_table->clear_slot (die);
return NULL;
}
return *die;
}
/* Return the DIE associated with BLOCK. */
static inline dw_die_ref
lookup_block_die (tree block)
{
dw_die_ref die = BLOCK_DIE (block);
if (!die && in_lto_p)
return maybe_create_die_with_external_ref (block);
return die;
}
/* Associate DIE with BLOCK. */
static inline void
equate_block_to_die (tree block, dw_die_ref die)
{
BLOCK_DIE (block) = die;
}
#undef BLOCK_DIE
/* For DECL which might have early dwarf output query a SYMBOL + OFFSET
style reference. Return true if we found one refering to a DIE for
DECL, otherwise return false. */
static bool
dwarf2out_die_ref_for_decl (tree decl, const char **sym,
unsigned HOST_WIDE_INT *off)
{
dw_die_ref die;
if (in_lto_p)
{
/* During WPA stage and incremental linking we use a hash-map
to store the decl <-> label + offset map. */
if (!external_die_map)
return false;
sym_off_pair *desc = external_die_map->get (decl);
if (!desc)
return false;
*sym = desc->sym;
*off = desc->off;
return true;
}
if (TREE_CODE (decl) == BLOCK)
die = lookup_block_die (decl);
else
die = lookup_decl_die (decl);
if (!die)
return false;
/* Similar to get_ref_die_offset_label, but using the "correct"
label. */
*off = die->die_offset;
while (die->die_parent)
die = die->die_parent;
/* For the containing CU DIE we compute a die_symbol in
compute_comp_unit_symbol. */
gcc_assert (die->die_tag == DW_TAG_compile_unit
&& die->die_id.die_symbol != NULL);
*sym = die->die_id.die_symbol;
return true;
}
/* Add a reference of kind ATTR_KIND to a DIE at SYMBOL + OFFSET to DIE. */
static void
add_AT_external_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind,
const char *symbol, HOST_WIDE_INT offset)
{
/* Create a fake DIE that contains the reference. Don't use
new_die because we don't want to end up in the limbo list. */
/* ??? We probably want to share these, thus put a ref to the DIE
we create here to the external_die_map entry. */
dw_die_ref ref = new_die_raw (die->die_tag);
ref->die_id.die_symbol = symbol;
ref->die_offset = offset;
ref->with_offset = 1;
add_AT_die_ref (die, attr_kind, ref);
}
/* Create a DIE for DECL if required and add a reference to a DIE
at SYMBOL + OFFSET which contains attributes dumped early. */
static void
dwarf2out_register_external_die (tree decl, const char *sym,
unsigned HOST_WIDE_INT off)
{
if (debug_info_level == DINFO_LEVEL_NONE)
return;
if (!external_die_map)
external_die_map = hash_map<tree, sym_off_pair>::create_ggc (1000);
gcc_checking_assert (!external_die_map->get (decl));
sym_off_pair p = { IDENTIFIER_POINTER (get_identifier (sym)), off };
external_die_map->put (decl, p);
}
/* If we have a registered external DIE for DECL return a new DIE for
the concrete instance with an appropriate abstract origin. */
static dw_die_ref
maybe_create_die_with_external_ref (tree decl)
{
if (!external_die_map)
return NULL;
sym_off_pair *desc = external_die_map->get (decl);
if (!desc)
return NULL;
const char *sym = desc->sym;
unsigned HOST_WIDE_INT off = desc->off;
external_die_map->remove (decl);
in_lto_p = false;
dw_die_ref die = (TREE_CODE (decl) == BLOCK
? lookup_block_die (decl) : lookup_decl_die (decl));
gcc_assert (!die);
in_lto_p = true;
tree ctx;
dw_die_ref parent = NULL;
/* Need to lookup a DIE for the decls context - the containing
function or translation unit. */
if (TREE_CODE (decl) == BLOCK)
{
ctx = BLOCK_SUPERCONTEXT (decl);
/* ??? We do not output DIEs for all scopes thus skip as
many DIEs as needed. */
while (TREE_CODE (ctx) == BLOCK
&& !lookup_block_die (ctx))
ctx = BLOCK_SUPERCONTEXT (ctx);
}
else
ctx = DECL_CONTEXT (decl);
/* Peel types in the context stack. */
while (ctx && TYPE_P (ctx))
ctx = TYPE_CONTEXT (ctx);
/* Likewise namespaces in case we do not want to emit DIEs for them. */
if (debug_info_level <= DINFO_LEVEL_TERSE)
while (ctx && TREE_CODE (ctx) == NAMESPACE_DECL)
ctx = DECL_CONTEXT (ctx);
if (ctx)
{
if (TREE_CODE (ctx) == BLOCK)
parent = lookup_block_die (ctx);
else if (TREE_CODE (ctx) == TRANSLATION_UNIT_DECL
/* Keep the 1:1 association during WPA. */
&& !flag_wpa
&& flag_incremental_link != INCREMENTAL_LINK_LTO)
/* Otherwise all late annotations go to the main CU which
imports the original CUs. */
parent = comp_unit_die ();
else if (TREE_CODE (ctx) == FUNCTION_DECL
&& TREE_CODE (decl) != FUNCTION_DECL
&& TREE_CODE (decl) != PARM_DECL
&& TREE_CODE (decl) != RESULT_DECL
&& TREE_CODE (decl) != BLOCK)
/* Leave function local entities parent determination to when
we process scope vars. */
;
else
parent = lookup_decl_die (ctx);
}
else
/* In some cases the FEs fail to set DECL_CONTEXT properly.
Handle this case gracefully by globalizing stuff. */
parent = comp_unit_die ();
/* Create a DIE "stub". */
switch (TREE_CODE (decl))
{
case TRANSLATION_UNIT_DECL:
{
die = comp_unit_die ();
/* We re-target all CU decls to the LTRANS CU DIE, so no need
to create a DIE for the original CUs. */
return die;
}
case NAMESPACE_DECL:
if (is_fortran (decl))
die = new_die (DW_TAG_module, parent, decl);
else
die = new_die (DW_TAG_namespace, parent, decl);
break;
case FUNCTION_DECL:
die = new_die (DW_TAG_subprogram, parent, decl);
break;
case VAR_DECL:
die = new_die (DW_TAG_variable, parent, decl);
break;
case RESULT_DECL:
die = new_die (DW_TAG_variable, parent, decl);
break;
case PARM_DECL:
die = new_die (DW_TAG_formal_parameter, parent, decl);
break;
case CONST_DECL:
die = new_die (DW_TAG_constant, parent, decl);
break;
case LABEL_DECL:
die = new_die (DW_TAG_label, parent, decl);
break;
case BLOCK:
die = new_die (DW_TAG_lexical_block, parent, decl);
break;
default:
gcc_unreachable ();
}
if (TREE_CODE (decl) == BLOCK)
equate_block_to_die (decl, die);
else
equate_decl_number_to_die (decl, die);
add_desc_attribute (die, decl);
/* Add a reference to the DIE providing early debug at $sym + off. */
add_AT_external_die_ref (die, DW_AT_abstract_origin, sym, off);
return die;
}
/* Returns a hash value for X (which really is a var_loc_list). */
inline hashval_t
decl_loc_hasher::hash (var_loc_list *x)
{
return (hashval_t) x->decl_id;
}
/* Return nonzero if decl_id of var_loc_list X is the same as
UID of decl *Y. */
inline bool
decl_loc_hasher::equal (var_loc_list *x, const_tree y)
{
return (x->decl_id == DECL_UID (y));
}
/* Return the var_loc list associated with a given declaration. */
static inline var_loc_list *
lookup_decl_loc (const_tree decl)
{
if (!decl_loc_table)
return NULL;
return decl_loc_table->find_with_hash (decl, DECL_UID (decl));
}
/* Returns a hash value for X (which really is a cached_dw_loc_list_list). */
inline hashval_t
dw_loc_list_hasher::hash (cached_dw_loc_list *x)
{
return (hashval_t) x->decl_id;
}
/* Return nonzero if decl_id of cached_dw_loc_list X is the same as
UID of decl *Y. */
inline bool
dw_loc_list_hasher::equal (cached_dw_loc_list *x, const_tree y)
{
return (x->decl_id == DECL_UID (y));
}
/* Equate a DIE to a particular declaration. */
static void
equate_decl_number_to_die (tree decl, dw_die_ref decl_die)
{
unsigned int decl_id = DECL_UID (decl);
*decl_die_table->find_slot_with_hash (decl, decl_id, INSERT) = decl_die;
decl_die->decl_id = decl_id;
}
/* Return how many bits covers PIECE EXPR_LIST. */
static HOST_WIDE_INT
decl_piece_bitsize (rtx piece)
{
int ret = (int) GET_MODE (piece);
if (ret)
return ret;
gcc_assert (GET_CODE (XEXP (piece, 0)) == CONCAT
&& CONST_INT_P (XEXP (XEXP (piece, 0), 0)));
return INTVAL (XEXP (XEXP (piece, 0), 0));
}
/* Return pointer to the location of location note in PIECE EXPR_LIST. */
static rtx *
decl_piece_varloc_ptr (rtx piece)
{
if ((int) GET_MODE (piece))
return &XEXP (piece, 0);
else
return &XEXP (XEXP (piece, 0), 1);
}
/* Create an EXPR_LIST for location note LOC_NOTE covering BITSIZE bits.
Next is the chain of following piece nodes. */
static rtx_expr_list *
decl_piece_node (rtx loc_note, HOST_WIDE_INT bitsize, rtx next)
{
if (bitsize > 0 && bitsize <= (int) MAX_MACHINE_MODE)
return alloc_EXPR_LIST (bitsize, loc_note, next);
else
return alloc_EXPR_LIST (0, gen_rtx_CONCAT (VOIDmode,
GEN_INT (bitsize),
loc_note), next);
}
/* Return rtx that should be stored into loc field for
LOC_NOTE and BITPOS/BITSIZE. */
static rtx
construct_piece_list (rtx loc_note, HOST_WIDE_INT bitpos,
HOST_WIDE_INT bitsize)
{
if (bitsize != -1)
{
loc_note = decl_piece_node (loc_note, bitsize, NULL_RTX);
if (bitpos != 0)
loc_note = decl_piece_node (NULL_RTX, bitpos, loc_note);
}
return loc_note;
}
/* This function either modifies location piece list *DEST in
place (if SRC and INNER is NULL), or copies location piece list
*SRC to *DEST while modifying it. Location BITPOS is modified
to contain LOC_NOTE, any pieces overlapping it are removed resp.
not copied and if needed some padding around it is added.
When modifying in place, DEST should point to EXPR_LIST where
earlier pieces cover PIECE_BITPOS bits, when copying SRC points
to the start of the whole list and INNER points to the EXPR_LIST
where earlier pieces cover PIECE_BITPOS bits. */
static void
adjust_piece_list (rtx *dest, rtx *src, rtx *inner,
HOST_WIDE_INT bitpos, HOST_WIDE_INT piece_bitpos,
HOST_WIDE_INT bitsize, rtx loc_note)
{
HOST_WIDE_INT diff;
bool copy = inner != NULL;
if (copy)
{
/* First copy all nodes preceding the current bitpos. */
while (src != inner)
{
*dest = decl_piece_node (*decl_piece_varloc_ptr (*src),
decl_piece_bitsize (*src), NULL_RTX);
dest = &XEXP (*dest, 1);
src = &XEXP (*src, 1);
}
}
/* Add padding if needed. */
if (bitpos != piece_bitpos)
{
*dest = decl_piece_node (NULL_RTX, bitpos - piece_bitpos,
copy ? NULL_RTX : *dest);
dest = &XEXP (*dest, 1);
}
else if (*dest && decl_piece_bitsize (*dest) == bitsize)
{
gcc_assert (!copy);
/* A piece with correct bitpos and bitsize already exist,
just update the location for it and return. */
*decl_piece_varloc_ptr (*dest) = loc_note;
return;
}
/* Add the piece that changed. */
*dest = decl_piece_node (loc_note, bitsize, copy ? NULL_RTX : *dest);
dest = &XEXP (*dest, 1);
/* Skip over pieces that overlap it. */
diff = bitpos - piece_bitpos + bitsize;
if (!copy)
src = dest;
while (diff > 0 && *src)
{
rtx piece = *src;
diff -= decl_piece_bitsize (piece);
if (copy)
src = &XEXP (piece, 1);
else
{
*src = XEXP (piece, 1);
free_EXPR_LIST_node (piece);
}
}
/* Add padding if needed. */
if (diff < 0 && *src)
{
if (!copy)
dest = src;
*dest = decl_piece_node (NULL_RTX, -diff, copy ? NULL_RTX : *dest);
dest = &XEXP (*dest, 1);
}
if (!copy)
return;
/* Finally copy all nodes following it. */
while (*src)
{
*dest = decl_piece_node (*decl_piece_varloc_ptr (*src),
decl_piece_bitsize (*src), NULL_RTX);
dest = &XEXP (*dest, 1);
src = &XEXP (*src, 1);
}
}
/* Add a variable location node to the linked list for DECL. */
static struct var_loc_node *
add_var_loc_to_decl (tree decl, rtx loc_note, const char *label, var_loc_view view)
{
unsigned int decl_id;
var_loc_list *temp;
struct var_loc_node *loc = NULL;
HOST_WIDE_INT bitsize = -1, bitpos = -1;
if (VAR_P (decl) && DECL_HAS_DEBUG_EXPR_P (decl))
{
tree realdecl = DECL_DEBUG_EXPR (decl);
if (handled_component_p (realdecl)
|| (TREE_CODE (realdecl) == MEM_REF
&& TREE_CODE (TREE_OPERAND (realdecl, 0)) == ADDR_EXPR))
{
bool reverse;
tree innerdecl = get_ref_base_and_extent_hwi (realdecl, &bitpos,
&bitsize, &reverse);
if (!innerdecl
|| !DECL_P (innerdecl)
|| DECL_IGNORED_P (innerdecl)
|| TREE_STATIC (innerdecl)
|| bitsize == 0
|| bitpos + bitsize > 256)
return NULL;
decl = innerdecl;
}
}
decl_id = DECL_UID (decl);
var_loc_list **slot
= decl_loc_table->find_slot_with_hash (decl, decl_id, INSERT);
if (*slot == NULL)
{
temp = ggc_cleared_alloc<var_loc_list> ();
temp->decl_id = decl_id;
*slot = temp;
}
else
temp = *slot;
/* For PARM_DECLs try to keep around the original incoming value,
even if that means we'll emit a zero-range .debug_loc entry. */
if (temp->last
&& temp->first == temp->last
&& TREE_CODE (decl) == PARM_DECL
&& NOTE_P (temp->first->loc)
&& NOTE_VAR_LOCATION_DECL (temp->first->loc) == decl
&& DECL_INCOMING_RTL (decl)
&& NOTE_VAR_LOCATION_LOC (temp->first->loc)
&& GET_CODE (NOTE_VAR_LOCATION_LOC (temp->first->loc))
== GET_CODE (DECL_INCOMING_RTL (decl))
&& prev_real_insn (as_a<rtx_insn *> (temp->first->loc)) == NULL_RTX
&& (bitsize != -1
|| !rtx_equal_p (NOTE_VAR_LOCATION_LOC (temp->first->loc),
NOTE_VAR_LOCATION_LOC (loc_note))
|| (NOTE_VAR_LOCATION_STATUS (temp->first->loc)
!= NOTE_VAR_LOCATION_STATUS (loc_note))))
{
loc = ggc_cleared_alloc<var_loc_node> ();
temp->first->next = loc;
temp->last = loc;
loc->loc = construct_piece_list (loc_note, bitpos, bitsize);
}
else if (temp->last)
{
struct var_loc_node *last = temp->last, *unused = NULL;
rtx *piece_loc = NULL, last_loc_note;
HOST_WIDE_INT piece_bitpos = 0;
if (last->next)
{
last = last->next;
gcc_assert (last->next == NULL);
}
if (bitsize != -1 && GET_CODE (last->loc) == EXPR_LIST)
{
piece_loc = &last->loc;
do
{
HOST_WIDE_INT cur_bitsize = decl_piece_bitsize (*piece_loc);
if (piece_bitpos + cur_bitsize > bitpos)
break;
piece_bitpos += cur_bitsize;
piece_loc = &XEXP (*piece_loc, 1);
}
while (*piece_loc);
}
/* TEMP->LAST here is either pointer to the last but one or
last element in the chained list, LAST is pointer to the
last element. */
if (label && strcmp (last->label, label) == 0 && last->view == view)
{
/* For SRA optimized variables if there weren't any real
insns since last note, just modify the last node. */
if (piece_loc != NULL)
{
adjust_piece_list (piece_loc, NULL, NULL,
bitpos, piece_bitpos, bitsize, loc_note);
return NULL;
}
/* If the last note doesn't cover any instructions, remove it. */
if (temp->last != last)
{
temp->last->next = NULL;
unused = last;
last = temp->last;
gcc_assert (strcmp (last->label, label) != 0 || last->view != view);
}
else
{
gcc_assert (temp->first == temp->last
|| (temp->first->next == temp->last
&& TREE_CODE (decl) == PARM_DECL));
memset (temp->last, '\0', sizeof (*temp->last));
temp->last->loc = construct_piece_list (loc_note, bitpos, bitsize);
return temp->last;
}
}
if (bitsize == -1 && NOTE_P (last->loc))
last_loc_note = last->loc;
else if (piece_loc != NULL
&& *piece_loc != NULL_RTX
&& piece_bitpos == bitpos
&& decl_piece_bitsize (*piece_loc) == bitsize)
last_loc_note = *decl_piece_varloc_ptr (*piece_loc);
else
last_loc_note = NULL_RTX;
/* If the current location is the same as the end of the list,
and either both or neither of the locations is uninitialized,
we have nothing to do. */
if (last_loc_note == NULL_RTX
|| (!rtx_equal_p (NOTE_VAR_LOCATION_LOC (last_loc_note),
NOTE_VAR_LOCATION_LOC (loc_note)))
|| ((NOTE_VAR_LOCATION_STATUS (last_loc_note)
!= NOTE_VAR_LOCATION_STATUS (loc_note))
&& ((NOTE_VAR_LOCATION_STATUS (last_loc_note)
== VAR_INIT_STATUS_UNINITIALIZED)
|| (NOTE_VAR_LOCATION_STATUS (loc_note)
== VAR_INIT_STATUS_UNINITIALIZED))))
{
/* Add LOC to the end of list and update LAST. If the last
element of the list has been removed above, reuse its
memory for the new node, otherwise allocate a new one. */
if (unused)
{
loc = unused;
memset (loc, '\0', sizeof (*loc));
}
else
loc = ggc_cleared_alloc<var_loc_node> ();
if (bitsize == -1 || piece_loc == NULL)
loc->loc = construct_piece_list (loc_note, bitpos, bitsize);
else
adjust_piece_list (&loc->loc, &last->loc, piece_loc,
bitpos, piece_bitpos, bitsize, loc_note);
last->next = loc;
/* Ensure TEMP->LAST will point either to the new last but one
element of the chain, or to the last element in it. */
if (last != temp->last)
temp->last = last;
}
else if (unused)
ggc_free (unused);
}
else
{
loc = ggc_cleared_alloc<var_loc_node> ();
temp->first = loc;
temp->last = loc;
loc->loc = construct_piece_list (loc_note, bitpos, bitsize);
}
return loc;
}
/* Keep track of the number of spaces used to indent the
output of the debugging routines that print the structure of
the DIE internal representation. */
static int print_indent;
/* Indent the line the number of spaces given by print_indent. */
static inline void
print_spaces (FILE *outfile)
{
fprintf (outfile, "%*s", print_indent, "");
}
/* Print a type signature in hex. */
static inline void
print_signature (FILE *outfile, char *sig)
{
int i;
for (i = 0; i < DWARF_TYPE_SIGNATURE_SIZE; i++)
fprintf (outfile, "%02x", sig[i] & 0xff);
}
static inline void
print_discr_value (FILE *outfile, dw_discr_value *discr_value)
{
if (discr_value->pos)
fprintf (outfile, HOST_WIDE_INT_PRINT_UNSIGNED, discr_value->v.sval);
else
fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, discr_value->v.uval);
}
static void print_loc_descr (dw_loc_descr_ref, FILE *);
/* Print the value associated to the VAL DWARF value node to OUTFILE. If
RECURSE, output location descriptor operations. */
static void
print_dw_val (dw_val_node *val, bool recurse, FILE *outfile)
{
switch (val->val_class)
{
case dw_val_class_addr:
fprintf (outfile, "address");
break;
case dw_val_class_offset:
fprintf (outfile, "offset");
break;
case dw_val_class_loc:
fprintf (outfile, "location descriptor");
if (val->v.val_loc == NULL)
fprintf (outfile, " -> <null>\n");
else if (recurse)
{
fprintf (outfile, ":\n");
print_indent += 4;
print_loc_descr (val->v.val_loc, outfile);
print_indent -= 4;
}
else
{
if (flag_dump_noaddr || flag_dump_unnumbered)
fprintf (outfile, " #\n");
else
fprintf (outfile, " (%p)\n", (void *) val->v.val_loc);
}
break;
case dw_val_class_loc_list:
fprintf (outfile, "location list -> label:%s",
val->v.val_loc_list->ll_symbol);
break;
case dw_val_class_view_list:
val = view_list_to_loc_list_val_node (val);
fprintf (outfile, "location list with views -> labels:%s and %s",
val->v.val_loc_list->ll_symbol,
val->v.val_loc_list->vl_symbol);
break;
case dw_val_class_range_list:
fprintf (outfile, "range list");
break;
case dw_val_class_const:
case dw_val_class_const_implicit:
fprintf (outfile, HOST_WIDE_INT_PRINT_DEC, val->v.val_int);
break;
case dw_val_class_unsigned_const:
case dw_val_class_unsigned_const_implicit:
fprintf (outfile, HOST_WIDE_INT_PRINT_UNSIGNED, val->v.val_unsigned);
break;
case dw_val_class_const_double:
fprintf (outfile, "constant (" HOST_WIDE_INT_PRINT_DEC","\
HOST_WIDE_INT_PRINT_UNSIGNED")",
val->v.val_double.high,
val->v.val_double.low);
break;
case dw_val_class_wide_int:
{
int i = val->v.val_wide->get_len ();
fprintf (outfile, "constant (");
gcc_assert (i > 0);
if (val->v.val_wide->elt (i - 1) == 0)
fprintf (outfile, "0x");
fprintf (outfile, HOST_WIDE_INT_PRINT_HEX,
val->v.val_wide->elt (--i));
while (--i >= 0)
fprintf (outfile, HOST_WIDE_INT_PRINT_PADDED_HEX,
val->v.val_wide->elt (i));
fprintf (outfile, ")");
break;
}
case dw_val_class_vec:
fprintf (outfile, "floating-point or vector constant");
break;
case dw_val_class_flag:
fprintf (outfile, "%u", val->v.val_flag);
break;
case dw_val_class_die_ref:
if (val->v.val_die_ref.die != NULL)
{
dw_die_ref die = val->v.val_die_ref.die;
if (die->comdat_type_p)
{
fprintf (outfile, "die -> signature: ");
print_signature (outfile,
die->die_id.die_type_node->signature);
}
else if (die->die_id.die_symbol)
{
fprintf (outfile, "die -> label: %s", die->die_id.die_symbol);
if (die->with_offset)
fprintf (outfile, " + %ld", die->die_offset);
}
else
fprintf (outfile, "die -> %ld", die->die_offset);
if (flag_dump_noaddr || flag_dump_unnumbered)
fprintf (outfile, " #");
else
fprintf (outfile, " (%p)", (void *) die);
}
else
fprintf (outfile, "die -> <null>");
break;
case dw_val_class_vms_delta:
fprintf (outfile, "delta: @slotcount(%s-%s)",
val->v.val_vms_delta.lbl2, val->v.val_vms_delta.lbl1);
break;
case dw_val_class_symview:
fprintf (outfile, "view: %s", val->v.val_symbolic_view);
break;
case dw_val_class_lbl_id:
case dw_val_class_lineptr:
case dw_val_class_macptr:
case dw_val_class_loclistsptr:
case dw_val_class_high_pc:
fprintf (outfile, "label: %s", val->v.val_lbl_id);
break;
case dw_val_class_str:
if (val->v.val_str->str != NULL)
fprintf (outfile, "\"%s\"", val->v.val_str->str);
else
fprintf (outfile, "<null>");
break;
case dw_val_class_file:
case dw_val_class_file_implicit:
fprintf (outfile, "\"%s\" (%d)", val->v.val_file->filename,
val->v.val_file->emitted_number);
break;
case dw_val_class_data8:
{
int i;
for (i = 0; i < 8; i++)
fprintf (outfile, "%02x", val->v.val_data8[i]);
break;
}
case dw_val_class_discr_value:
print_discr_value (outfile, &val->v.val_discr_value);
break;
case dw_val_class_discr_list:
for (dw_discr_list_ref node = val->v.val_discr_list;
node != NULL;
node = node->dw_discr_next)
{
if (node->dw_discr_range)
{
fprintf (outfile, " .. ");
print_discr_value (outfile, &node->dw_discr_lower_bound);
print_discr_value (outfile, &node->dw_discr_upper_bound);
}
else
print_discr_value (outfile, &node->dw_discr_lower_bound);
if (node->dw_discr_next != NULL)
fprintf (outfile, " | ");
}
default:
break;
}
}
/* Likewise, for a DIE attribute. */
static void
print_attribute (dw_attr_node *a, bool recurse, FILE *outfile)
{
print_dw_val (&a->dw_attr_val, recurse, outfile);
}
/* Print the list of operands in the LOC location description to OUTFILE. This
routine is a debugging aid only. */
static void
print_loc_descr (dw_loc_descr_ref loc, FILE *outfile)
{
dw_loc_descr_ref l = loc;
if (loc == NULL)
{
print_spaces (outfile);
fprintf (outfile, "<null>\n");
return;
}
for (l = loc; l != NULL; l = l->dw_loc_next)
{
print_spaces (outfile);
if (flag_dump_noaddr || flag_dump_unnumbered)
fprintf (outfile, "#");
else
fprintf (outfile, "(%p)", (void *) l);
fprintf (outfile, " %s",
dwarf_stack_op_name (l->dw_loc_opc));
if (l->dw_loc_oprnd1.val_class != dw_val_class_none)
{
fprintf (outfile, " ");
print_dw_val (&l->dw_loc_oprnd1, false, outfile);
}
if (l->dw_loc_oprnd2.val_class != dw_val_class_none)
{
fprintf (outfile, ", ");
print_dw_val (&l->dw_loc_oprnd2, false, outfile);
}
fprintf (outfile, "\n");
}
}
/* Print the information associated with a given DIE, and its children.
This routine is a debugging aid only. */
static void
print_die (dw_die_ref die, FILE *outfile)
{
dw_attr_node *a;
dw_die_ref c;
unsigned ix;
print_spaces (outfile);
fprintf (outfile, "DIE %4ld: %s ",
die->die_offset, dwarf_tag_name (die->die_tag));
if (flag_dump_noaddr || flag_dump_unnumbered)
fprintf (outfile, "#\n");
else
fprintf (outfile, "(%p)\n", (void*) die);
print_spaces (outfile);
fprintf (outfile, " abbrev id: %lu", die->die_abbrev);
fprintf (outfile, " offset: %ld", die->die_offset);
fprintf (outfile, " mark: %d\n", die->die_mark);
if (die->comdat_type_p)
{
print_spaces (outfile);
fprintf (outfile, " signature: ");
print_signature (outfile, die->die_id.die_type_node->signature);
fprintf (outfile, "\n");
}
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
{
print_spaces (outfile);
fprintf (outfile, " %s: ", dwarf_attr_name (a->dw_attr));
print_attribute (a, true, outfile);
fprintf (outfile, "\n");
}
if (die->die_child != NULL)
{
print_indent += 4;
FOR_EACH_CHILD (die, c, print_die (c, outfile));
print_indent -= 4;
}
if (print_indent == 0)
fprintf (outfile, "\n");
}
/* Print the list of operations in the LOC location description. */
DEBUG_FUNCTION void
debug_dwarf_loc_descr (dw_loc_descr_ref loc)
{
print_loc_descr (loc, stderr);
}
/* Print the information collected for a given DIE. */
DEBUG_FUNCTION void
debug_dwarf_die (dw_die_ref die)
{
print_die (die, stderr);
}
DEBUG_FUNCTION void
debug (die_struct &ref)
{
print_die (&ref, stderr);
}
DEBUG_FUNCTION void
debug (die_struct *ptr)
{
if (ptr)
debug (*ptr);
else
fprintf (stderr, "<nil>\n");
}
/* Print all DWARF information collected for the compilation unit.
This routine is a debugging aid only. */
DEBUG_FUNCTION void
debug_dwarf (void)
{
print_indent = 0;
print_die (comp_unit_die (), stderr);
}
/* Verify the DIE tree structure. */
DEBUG_FUNCTION void
verify_die (dw_die_ref die)
{
gcc_assert (!die->die_mark);
if (die->die_parent == NULL
&& die->die_sib == NULL)
return;
/* Verify the die_sib list is cyclic. */
dw_die_ref x = die;
do
{
x->die_mark = 1;
x = x->die_sib;
}
while (x && !x->die_mark);
gcc_assert (x == die);
x = die;
do
{
/* Verify all dies have the same parent. */
gcc_assert (x->die_parent == die->die_parent);
if (x->die_child)
{
/* Verify the child has the proper parent and recurse. */
gcc_assert (x->die_child->die_parent == x);
verify_die (x->die_child);
}
x->die_mark = 0;
x = x->die_sib;
}
while (x && x->die_mark);
}
/* Sanity checks on DIEs. */
static void
check_die (dw_die_ref die)
{
unsigned ix;
dw_attr_node *a;
bool inline_found = false;
int n_location = 0, n_low_pc = 0, n_high_pc = 0, n_artificial = 0;
int n_decl_line = 0, n_decl_column = 0, n_decl_file = 0;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
{
switch (a->dw_attr)
{
case DW_AT_inline:
if (a->dw_attr_val.v.val_unsigned)
inline_found = true;
break;
case DW_AT_location:
++n_location;
break;
case DW_AT_low_pc:
++n_low_pc;
break;
case DW_AT_high_pc:
++n_high_pc;
break;
case DW_AT_artificial:
++n_artificial;
break;
case DW_AT_decl_column:
++n_decl_column;
break;
case DW_AT_decl_line:
++n_decl_line;
break;
case DW_AT_decl_file:
++n_decl_file;
break;
default:
break;
}
}
if (n_location > 1 || n_low_pc > 1 || n_high_pc > 1 || n_artificial > 1
|| n_decl_column > 1 || n_decl_line > 1 || n_decl_file > 1)
{
fprintf (stderr, "Duplicate attributes in DIE:\n");
debug_dwarf_die (die);
gcc_unreachable ();
}
if (inline_found)
{
/* A debugging information entry that is a member of an abstract
instance tree [that has DW_AT_inline] should not contain any
attributes which describe aspects of the subroutine which vary
between distinct inlined expansions or distinct out-of-line
expansions. */
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
gcc_assert (a->dw_attr != DW_AT_low_pc
&& a->dw_attr != DW_AT_high_pc
&& a->dw_attr != DW_AT_location
&& a->dw_attr != DW_AT_frame_base
&& a->dw_attr != DW_AT_call_all_calls
&& a->dw_attr != DW_AT_GNU_all_call_sites);
}
}
#define CHECKSUM(FOO) md5_process_bytes (&(FOO), sizeof (FOO), ctx)
#define CHECKSUM_BLOCK(FOO, SIZE) md5_process_bytes ((FOO), (SIZE), ctx)
#define CHECKSUM_STRING(FOO) md5_process_bytes ((FOO), strlen (FOO), ctx)
/* Calculate the checksum of a location expression. */
static inline void
loc_checksum (dw_loc_descr_ref loc, struct md5_ctx *ctx)
{
int tem;
inchash::hash hstate;
hashval_t hash;
tem = (loc->dtprel << 8) | ((unsigned int) loc->dw_loc_opc);
CHECKSUM (tem);
hash_loc_operands (loc, hstate);
hash = hstate.end();
CHECKSUM (hash);
}
/* Calculate the checksum of an attribute. */
static void
attr_checksum (dw_attr_node *at, struct md5_ctx *ctx, int *mark)
{
dw_loc_descr_ref loc;
rtx r;
CHECKSUM (at->dw_attr);
/* We don't care that this was compiled with a different compiler
snapshot; if the output is the same, that's what matters. */
if (at->dw_attr == DW_AT_producer)
return;
switch (AT_class (at))
{
case dw_val_class_const:
case dw_val_class_const_implicit:
CHECKSUM (at->dw_attr_val.v.val_int);
break;
case dw_val_class_unsigned_const:
case dw_val_class_unsigned_const_implicit:
CHECKSUM (at->dw_attr_val.v.val_unsigned);
break;
case dw_val_class_const_double:
CHECKSUM (at->dw_attr_val.v.val_double);
break;
case dw_val_class_wide_int:
CHECKSUM_BLOCK (at->dw_attr_val.v.val_wide->get_val (),
get_full_len (*at->dw_attr_val.v.val_wide)
* HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR);
break;
case dw_val_class_vec:
CHECKSUM_BLOCK (at->dw_attr_val.v.val_vec.array,
(at->dw_attr_val.v.val_vec.length
* at->dw_attr_val.v.val_vec.elt_size));
break;
case dw_val_class_flag:
CHECKSUM (at->dw_attr_val.v.val_flag);
break;
case dw_val_class_str:
CHECKSUM_STRING (AT_string (at));
break;
case dw_val_class_addr:
r = AT_addr (at);
gcc_assert (GET_CODE (r) == SYMBOL_REF);
CHECKSUM_STRING (XSTR (r, 0));
break;
case dw_val_class_offset:
CHECKSUM (at->dw_attr_val.v.val_offset);
break;
case dw_val_class_loc:
for (loc = AT_loc (at); loc; loc = loc->dw_loc_next)
loc_checksum (loc, ctx);
break;
case dw_val_class_die_ref:
die_checksum (AT_ref (at), ctx, mark);
break;
case dw_val_class_fde_ref:
case dw_val_class_vms_delta:
case dw_val_class_symview:
case dw_val_class_lbl_id:
case dw_val_class_lineptr:
case dw_val_class_macptr:
case dw_val_class_loclistsptr:
case dw_val_class_high_pc:
break;
case dw_val_class_file:
case dw_val_class_file_implicit:
CHECKSUM_STRING (AT_file (at)->filename);
break;
case dw_val_class_data8:
CHECKSUM (at->dw_attr_val.v.val_data8);
break;
default:
break;
}
}
/* Calculate the checksum of a DIE. */
static void
die_checksum (dw_die_ref die, struct md5_ctx *ctx, int *mark)
{
dw_die_ref c;
dw_attr_node *a;
unsigned ix;
/* To avoid infinite recursion. */
if (die->die_mark)
{
CHECKSUM (die->die_mark);
return;
}
die->die_mark = ++(*mark);
CHECKSUM (die->die_tag);
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
attr_checksum (a, ctx, mark);
FOR_EACH_CHILD (die, c, die_checksum (c, ctx, mark));
}
#undef CHECKSUM
#undef CHECKSUM_BLOCK
#undef CHECKSUM_STRING
/* For DWARF-4 types, include the trailing NULL when checksumming strings. */
#define CHECKSUM(FOO) md5_process_bytes (&(FOO), sizeof (FOO), ctx)
#define CHECKSUM_BLOCK(FOO, SIZE) md5_process_bytes ((FOO), (SIZE), ctx)
#define CHECKSUM_STRING(FOO) md5_process_bytes ((FOO), strlen (FOO) + 1, ctx)
#define CHECKSUM_SLEB128(FOO) checksum_sleb128 ((FOO), ctx)
#define CHECKSUM_ULEB128(FOO) checksum_uleb128 ((FOO), ctx)
#define CHECKSUM_ATTR(FOO) \
if (FOO) attr_checksum_ordered (die->die_tag, (FOO), ctx, mark)
/* Calculate the checksum of a number in signed LEB128 format. */
static void
checksum_sleb128 (HOST_WIDE_INT value, struct md5_ctx *ctx)
{
unsigned char byte;
bool more;
while (1)
{
byte = (value & 0x7f);
value >>= 7;
more = !((value == 0 && (byte & 0x40) == 0)
|| (value == -1 && (byte & 0x40) != 0));
if (more)
byte |= 0x80;
CHECKSUM (byte);
if (!more)
break;
}
}
/* Calculate the checksum of a number in unsigned LEB128 format. */
static void
checksum_uleb128 (unsigned HOST_WIDE_INT value, struct md5_ctx *ctx)
{
while (1)
{
unsigned char byte = (value & 0x7f);
value >>= 7;
if (value != 0)
/* More bytes to follow. */
byte |= 0x80;
CHECKSUM (byte);
if (value == 0)
break;
}
}
/* Checksum the context of the DIE. This adds the names of any
surrounding namespaces or structures to the checksum. */
static void
checksum_die_context (dw_die_ref die, struct md5_ctx *ctx)
{
const char *name;
dw_die_ref spec;
int tag = die->die_tag;
if (tag != DW_TAG_namespace
&& tag != DW_TAG_structure_type
&& tag != DW_TAG_class_type)
return;
name = get_AT_string (die, DW_AT_name);
spec = get_AT_ref (die, DW_AT_specification);
if (spec != NULL)
die = spec;
if (die->die_parent != NULL)
checksum_die_context (die->die_parent, ctx);
CHECKSUM_ULEB128 ('C');
CHECKSUM_ULEB128 (tag);
if (name != NULL)
CHECKSUM_STRING (name);
}
/* Calculate the checksum of a location expression. */
static inline void
loc_checksum_ordered (dw_loc_descr_ref loc, struct md5_ctx *ctx)
{
/* Special case for lone DW_OP_plus_uconst: checksum as if the location
were emitted as a DW_FORM_sdata instead of a location expression. */
if (loc->dw_loc_opc == DW_OP_plus_uconst && loc->dw_loc_next == NULL)
{
CHECKSUM_ULEB128 (DW_FORM_sdata);
CHECKSUM_SLEB128 ((HOST_WIDE_INT) loc->dw_loc_oprnd1.v.val_unsigned);
return;
}
/* Otherwise, just checksum the raw location expression. */
while (loc != NULL)
{
inchash::hash hstate;
hashval_t hash;
CHECKSUM_ULEB128 (loc->dtprel);
CHECKSUM_ULEB128 (loc->dw_loc_opc);
hash_loc_operands (loc, hstate);
hash = hstate.end ();
CHECKSUM (hash);
loc = loc->dw_loc_next;
}
}
/* Calculate the checksum of an attribute. */
static void
attr_checksum_ordered (enum dwarf_tag tag, dw_attr_node *at,
struct md5_ctx *ctx, int *mark)
{
dw_loc_descr_ref loc;
rtx r;
if (AT_class (at) == dw_val_class_die_ref)
{
dw_die_ref target_die = AT_ref (at);
/* For pointer and reference types, we checksum only the (qualified)
name of the target type (if there is a name). For friend entries,
we checksum only the (qualified) name of the target type or function.
This allows the checksum to remain the same whether the target type
is complete or not. */
if ((at->dw_attr == DW_AT_type
&& (tag == DW_TAG_pointer_type
|| tag == DW_TAG_reference_type
|| tag == DW_TAG_rvalue_reference_type
|| tag == DW_TAG_ptr_to_member_type))
|| (at->dw_attr == DW_AT_friend
&& tag == DW_TAG_friend))
{
dw_attr_node *name_attr = get_AT (target_die, DW_AT_name);
if (name_attr != NULL)
{
dw_die_ref decl = get_AT_ref (target_die, DW_AT_specification);
if (decl == NULL)
decl = target_die;
CHECKSUM_ULEB128 ('N');
CHECKSUM_ULEB128 (at->dw_attr);
if (decl->die_parent != NULL)
checksum_die_context (decl->die_parent, ctx);
CHECKSUM_ULEB128 ('E');
CHECKSUM_STRING (AT_string (name_attr));
return;
}
}
/* For all other references to another DIE, we check to see if the
target DIE has already been visited. If it has, we emit a
backward reference; if not, we descend recursively. */
if (target_die->die_mark > 0)
{
CHECKSUM_ULEB128 ('R');
CHECKSUM_ULEB128 (at->dw_attr);
CHECKSUM_ULEB128 (target_die->die_mark);
}
else
{
dw_die_ref decl = get_AT_ref (target_die, DW_AT_specification);
if (decl == NULL)
decl = target_die;
target_die->die_mark = ++(*mark);
CHECKSUM_ULEB128 ('T');
CHECKSUM_ULEB128 (at->dw_attr);
if (decl->die_parent != NULL)
checksum_die_context (decl->die_parent, ctx);
die_checksum_ordered (target_die, ctx, mark);
}
return;
}
CHECKSUM_ULEB128 ('A');
CHECKSUM_ULEB128 (at->dw_attr);
switch (AT_class (at))
{
case dw_val_class_const:
case dw_val_class_const_implicit:
CHECKSUM_ULEB128 (DW_FORM_sdata);
CHECKSUM_SLEB128 (at->dw_attr_val.v.val_int);
break;
case dw_val_class_unsigned_const:
case dw_val_class_unsigned_const_implicit:
CHECKSUM_ULEB128 (DW_FORM_sdata);
CHECKSUM_SLEB128 ((int) at->dw_attr_val.v.val_unsigned);
break;
case dw_val_class_const_double:
CHECKSUM_ULEB128 (DW_FORM_block);
CHECKSUM_ULEB128 (sizeof (at->dw_attr_val.v.val_double));
CHECKSUM (at->dw_attr_val.v.val_double);
break;
case dw_val_class_wide_int:
CHECKSUM_ULEB128 (DW_FORM_block);
CHECKSUM_ULEB128 (get_full_len (*at->dw_attr_val.v.val_wide)
* HOST_BITS_PER_WIDE_INT / BITS_PER_UNIT);
CHECKSUM_BLOCK (at->dw_attr_val.v.val_wide->get_val (),
get_full_len (*at->dw_attr_val.v.val_wide)
* HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR);
break;
case dw_val_class_vec:
CHECKSUM_ULEB128 (DW_FORM_block);
CHECKSUM_ULEB128 (at->dw_attr_val.v.val_vec.length
* at->dw_attr_val.v.val_vec.elt_size);
CHECKSUM_BLOCK (at->dw_attr_val.v.val_vec.array,
(at->dw_attr_val.v.val_vec.length
* at->dw_attr_val.v.val_vec.elt_size));
break;
case dw_val_class_flag:
CHECKSUM_ULEB128 (DW_FORM_flag);
CHECKSUM_ULEB128 (at->dw_attr_val.v.val_flag ? 1 : 0);
break;
case dw_val_class_str:
CHECKSUM_ULEB128 (DW_FORM_string);
CHECKSUM_STRING (AT_string (at));
break;
case dw_val_class_addr:
r = AT_addr (at);
gcc_assert (GET_CODE (r) == SYMBOL_REF);
CHECKSUM_ULEB128 (DW_FORM_string);
CHECKSUM_STRING (XSTR (r, 0));
break;
case dw_val_class_offset:
CHECKSUM_ULEB128 (DW_FORM_sdata);
CHECKSUM_ULEB128 (at->dw_attr_val.v.val_offset);
break;
case dw_val_class_loc:
for (loc = AT_loc (at); loc; loc = loc->dw_loc_next)
loc_checksum_ordered (loc, ctx);
break;
case dw_val_class_fde_ref:
case dw_val_class_symview:
case dw_val_class_lbl_id:
case dw_val_class_lineptr:
case dw_val_class_macptr:
case dw_val_class_loclistsptr:
case dw_val_class_high_pc:
break;
case dw_val_class_file:
case dw_val_class_file_implicit:
CHECKSUM_ULEB128 (DW_FORM_string);
CHECKSUM_STRING (AT_file (at)->filename);
break;
case dw_val_class_data8:
CHECKSUM (at->dw_attr_val.v.val_data8);
break;
default:
break;
}
}
struct checksum_attributes
{
dw_attr_node *at_name;
dw_attr_node *at_type;
dw_attr_node *at_friend;
dw_attr_node *at_accessibility;
dw_attr_node *at_address_class;
dw_attr_node *at_alignment;
dw_attr_node *at_allocated;
dw_attr_node *at_artificial;
dw_attr_node *at_associated;
dw_attr_node *at_binary_scale;
dw_attr_node *at_bit_offset;
dw_attr_node *at_bit_size;
dw_attr_node *at_bit_stride;
dw_attr_node *at_byte_size;
dw_attr_node *at_byte_stride;
dw_attr_node *at_const_value;
dw_attr_node *at_containing_type;
dw_attr_node *at_count;
dw_attr_node *at_data_location;
dw_attr_node *at_data_member_location;
dw_attr_node *at_decimal_scale;
dw_attr_node *at_decimal_sign;
dw_attr_node *at_default_value;
dw_attr_node *at_digit_count;
dw_attr_node *at_discr;
dw_attr_node *at_discr_list;
dw_attr_node *at_discr_value;
dw_attr_node *at_encoding;
dw_attr_node *at_endianity;
dw_attr_node *at_explicit;
dw_attr_node *at_is_optional;
dw_attr_node *at_location;
dw_attr_node *at_lower_bound;
dw_attr_node *at_mutable;
dw_attr_node *at_ordering;
dw_attr_node *at_picture_string;
dw_attr_node *at_prototyped;
dw_attr_node *at_small;
dw_attr_node *at_segment;
dw_attr_node *at_string_length;
dw_attr_node *at_string_length_bit_size;
dw_attr_node *at_string_length_byte_size;
dw_attr_node *at_threads_scaled;
dw_attr_node *at_upper_bound;
dw_attr_node *at_use_location;
dw_attr_node *at_use_UTF8;
dw_attr_node *at_variable_parameter;
dw_attr_node *at_virtuality;
dw_attr_node *at_visibility;
dw_attr_node *at_vtable_elem_location;
};
/* Collect the attributes that we will want to use for the checksum. */
static void
collect_checksum_attributes (struct checksum_attributes *attrs, dw_die_ref die)
{
dw_attr_node *a;
unsigned ix;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
{
switch (a->dw_attr)
{
case DW_AT_name:
attrs->at_name = a;
break;
case DW_AT_type:
attrs->at_type = a;
break;
case DW_AT_friend:
attrs->at_friend = a;
break;
case DW_AT_accessibility:
attrs->at_accessibility = a;
break;
case DW_AT_address_class:
attrs->at_address_class = a;
break;
case DW_AT_alignment:
attrs->at_alignment = a;
break;
case DW_AT_allocated:
attrs->at_allocated = a;
break;
case DW_AT_artificial:
attrs->at_artificial = a;
break;
case DW_AT_associated:
attrs->at_associated = a;
break;
case DW_AT_binary_scale:
attrs->at_binary_scale = a;
break;
case DW_AT_bit_offset:
attrs->at_bit_offset = a;
break;
case DW_AT_bit_size:
attrs->at_bit_size = a;
break;
case DW_AT_bit_stride:
attrs->at_bit_stride = a;
break;
case DW_AT_byte_size:
attrs->at_byte_size = a;
break;
case DW_AT_byte_stride:
attrs->at_byte_stride = a;
break;
case DW_AT_const_value:
attrs->at_const_value = a;
break;
case DW_AT_containing_type:
attrs->at_containing_type = a;
break;
case DW_AT_count:
attrs->at_count = a;
break;
case DW_AT_data_location:
attrs->at_data_location = a;
break;
case DW_AT_data_member_location:
attrs->at_data_member_location = a;
break;
case DW_AT_decimal_scale:
attrs->at_decimal_scale = a;
break;
case DW_AT_decimal_sign:
attrs->at_decimal_sign = a;
break;
case DW_AT_default_value:
attrs->at_default_value = a;
break;
case DW_AT_digit_count:
attrs->at_digit_count = a;
break;
case DW_AT_discr:
attrs->at_discr = a;
break;
case DW_AT_discr_list:
attrs->at_discr_list = a;
break;
case DW_AT_discr_value:
attrs->at_discr_value = a;
break;
case DW_AT_encoding:
attrs->at_encoding = a;
break;
case DW_AT_endianity:
attrs->at_endianity = a;
break;
case DW_AT_explicit:
attrs->at_explicit = a;
break;
case DW_AT_is_optional:
attrs->at_is_optional = a;
break;
case DW_AT_location:
attrs->at_location = a;
break;
case DW_AT_lower_bound:
attrs->at_lower_bound = a;
break;
case DW_AT_mutable:
attrs->at_mutable = a;
break;
case DW_AT_ordering:
attrs->at_ordering = a;
break;
case DW_AT_picture_string:
attrs->at_picture_string = a;
break;
case DW_AT_prototyped:
attrs->at_prototyped = a;
break;
case DW_AT_small:
attrs->at_small = a;
break;
case DW_AT_segment:
attrs->at_segment = a;
break;
case DW_AT_string_length:
attrs->at_string_length = a;
break;
case DW_AT_string_length_bit_size:
attrs->at_string_length_bit_size = a;
break;
case DW_AT_string_length_byte_size:
attrs->at_string_length_byte_size = a;
break;
case DW_AT_threads_scaled:
attrs->at_threads_scaled = a;
break;
case DW_AT_upper_bound:
attrs->at_upper_bound = a;
break;
case DW_AT_use_location:
attrs->at_use_location = a;
break;
case DW_AT_use_UTF8:
attrs->at_use_UTF8 = a;
break;
case DW_AT_variable_parameter:
attrs->at_variable_parameter = a;
break;
case DW_AT_virtuality:
attrs->at_virtuality = a;
break;
case DW_AT_visibility:
attrs->at_visibility = a;
break;
case DW_AT_vtable_elem_location:
attrs->at_vtable_elem_location = a;
break;
default:
break;
}
}
}
/* Calculate the checksum of a DIE, using an ordered subset of attributes. */
static void
die_checksum_ordered (dw_die_ref die, struct md5_ctx *ctx, int *mark)
{
dw_die_ref c;
dw_die_ref decl;
struct checksum_attributes attrs;
CHECKSUM_ULEB128 ('D');
CHECKSUM_ULEB128 (die->die_tag);
memset (&attrs, 0, sizeof (attrs));
decl = get_AT_ref (die, DW_AT_specification);
if (decl != NULL)
collect_checksum_attributes (&attrs, decl);
collect_checksum_attributes (&attrs, die);
CHECKSUM_ATTR (attrs.at_name);
CHECKSUM_ATTR (attrs.at_accessibility);
CHECKSUM_ATTR (attrs.at_address_class);
CHECKSUM_ATTR (attrs.at_allocated);
CHECKSUM_ATTR (attrs.at_artificial);
CHECKSUM_ATTR (attrs.at_associated);
CHECKSUM_ATTR (attrs.at_binary_scale);
CHECKSUM_ATTR (attrs.at_bit_offset);
CHECKSUM_ATTR (attrs.at_bit_size);
CHECKSUM_ATTR (attrs.at_bit_stride);
CHECKSUM_ATTR (attrs.at_byte_size);
CHECKSUM_ATTR (attrs.at_byte_stride);
CHECKSUM_ATTR (attrs.at_const_value);
CHECKSUM_ATTR (attrs.at_containing_type);
CHECKSUM_ATTR (attrs.at_count);
CHECKSUM_ATTR (attrs.at_data_location);
CHECKSUM_ATTR (attrs.at_data_member_location);
CHECKSUM_ATTR (attrs.at_decimal_scale);
CHECKSUM_ATTR (attrs.at_decimal_sign);
CHECKSUM_ATTR (attrs.at_default_value);
CHECKSUM_ATTR (attrs.at_digit_count);
CHECKSUM_ATTR (attrs.at_discr);
CHECKSUM_ATTR (attrs.at_discr_list);
CHECKSUM_ATTR (attrs.at_discr_value);
CHECKSUM_ATTR (attrs.at_encoding);
CHECKSUM_ATTR (attrs.at_endianity);
CHECKSUM_ATTR (attrs.at_explicit);
CHECKSUM_ATTR (attrs.at_is_optional);
CHECKSUM_ATTR (attrs.at_location);
CHECKSUM_ATTR (attrs.at_lower_bound);
CHECKSUM_ATTR (attrs.at_mutable);
CHECKSUM_ATTR (attrs.at_ordering);
CHECKSUM_ATTR (attrs.at_picture_string);
CHECKSUM_ATTR (attrs.at_prototyped);
CHECKSUM_ATTR (attrs.at_small);
CHECKSUM_ATTR (attrs.at_segment);
CHECKSUM_ATTR (attrs.at_string_length);
CHECKSUM_ATTR (attrs.at_string_length_bit_size);
CHECKSUM_ATTR (attrs.at_string_length_byte_size);
CHECKSUM_ATTR (attrs.at_threads_scaled);
CHECKSUM_ATTR (attrs.at_upper_bound);
CHECKSUM_ATTR (attrs.at_use_location);
CHECKSUM_ATTR (attrs.at_use_UTF8);
CHECKSUM_ATTR (attrs.at_variable_parameter);
CHECKSUM_ATTR (attrs.at_virtuality);
CHECKSUM_ATTR (attrs.at_visibility);
CHECKSUM_ATTR (attrs.at_vtable_elem_location);
CHECKSUM_ATTR (attrs.at_type);
CHECKSUM_ATTR (attrs.at_friend);
CHECKSUM_ATTR (attrs.at_alignment);
/* Checksum the child DIEs. */
c = die->die_child;
if (c) do {
dw_attr_node *name_attr;
c = c->die_sib;
name_attr = get_AT (c, DW_AT_name);
if (is_template_instantiation (c))
{
/* Ignore instantiations of member type and function templates. */
}
else if (name_attr != NULL
&& (is_type_die (c) || c->die_tag == DW_TAG_subprogram))
{
/* Use a shallow checksum for named nested types and member
functions. */
CHECKSUM_ULEB128 ('S');
CHECKSUM_ULEB128 (c->die_tag);
CHECKSUM_STRING (AT_string (name_attr));
}
else
{
/* Use a deep checksum for other children. */
/* Mark this DIE so it gets processed when unmarking. */
if (c->die_mark == 0)
c->die_mark = -1;
die_checksum_ordered (c, ctx, mark);
}
} while (c != die->die_child);
CHECKSUM_ULEB128 (0);
}
/* Add a type name and tag to a hash. */
static void
die_odr_checksum (int tag, const char *name, md5_ctx *ctx)
{
CHECKSUM_ULEB128 (tag);
CHECKSUM_STRING (name);
}
#undef CHECKSUM
#undef CHECKSUM_STRING
#undef CHECKSUM_ATTR
#undef CHECKSUM_LEB128
#undef CHECKSUM_ULEB128
/* Generate the type signature for DIE. This is computed by generating an
MD5 checksum over the DIE's tag, its relevant attributes, and its
children. Attributes that are references to other DIEs are processed
by recursion, using the MARK field to prevent infinite recursion.
If the DIE is nested inside a namespace or another type, we also
need to include that context in the signature. The lower 64 bits
of the resulting MD5 checksum comprise the signature. */
static void
generate_type_signature (dw_die_ref die, comdat_type_node *type_node)
{
int mark;
const char *name;
unsigned char checksum[16];
struct md5_ctx ctx;
dw_die_ref decl;
dw_die_ref parent;
name = get_AT_string (die, DW_AT_name);
decl = get_AT_ref (die, DW_AT_specification);
parent = get_die_parent (die);
/* First, compute a signature for just the type name (and its surrounding
context, if any. This is stored in the type unit DIE for link-time
ODR (one-definition rule) checking. */
if (is_cxx () && name != NULL)
{
md5_init_ctx (&ctx);
/* Checksum the names of surrounding namespaces and structures. */
if (parent != NULL)
checksum_die_context (parent, &ctx);
/* Checksum the current DIE. */
die_odr_checksum (die->die_tag, name, &ctx);
md5_finish_ctx (&ctx, checksum);
add_AT_data8 (type_node->root_die, DW_AT_GNU_odr_signature, &checksum[8]);
}
/* Next, compute the complete type signature. */
md5_init_ctx (&ctx);
mark = 1;
die->die_mark = mark;
/* Checksum the names of surrounding namespaces and structures. */
if (parent != NULL)
checksum_die_context (parent, &ctx);
/* Checksum the DIE and its children. */
die_checksum_ordered (die, &ctx, &mark);
unmark_all_dies (die);
md5_finish_ctx (&ctx, checksum);
/* Store the signature in the type node and link the type DIE and the
type node together. */
memcpy (type_node->signature, &checksum[16 - DWARF_TYPE_SIGNATURE_SIZE],
DWARF_TYPE_SIGNATURE_SIZE);
die->comdat_type_p = true;
die->die_id.die_type_node = type_node;
type_node->type_die = die;
/* If the DIE is a specification, link its declaration to the type node
as well. */
if (decl != NULL)
{
decl->comdat_type_p = true;
decl->die_id.die_type_node = type_node;
}
}
/* Do the location expressions look same? */
static inline int
same_loc_p (dw_loc_descr_ref loc1, dw_loc_descr_ref loc2, int *mark)
{
return loc1->dw_loc_opc == loc2->dw_loc_opc
&& same_dw_val_p (&loc1->dw_loc_oprnd1, &loc2->dw_loc_oprnd1, mark)
&& same_dw_val_p (&loc1->dw_loc_oprnd2, &loc2->dw_loc_oprnd2, mark);
}
/* Do the values look the same? */
static int
same_dw_val_p (const dw_val_node *v1, const dw_val_node *v2, int *mark)
{
dw_loc_descr_ref loc1, loc2;
rtx r1, r2;
if (v1->val_class != v2->val_class)
return 0;
switch (v1->val_class)
{
case dw_val_class_const:
case dw_val_class_const_implicit:
return v1->v.val_int == v2->v.val_int;
case dw_val_class_unsigned_const:
case dw_val_class_unsigned_const_implicit:
return v1->v.val_unsigned == v2->v.val_unsigned;
case dw_val_class_const_double:
return v1->v.val_double.high == v2->v.val_double.high
&& v1->v.val_double.low == v2->v.val_double.low;
case dw_val_class_wide_int:
return *v1->v.val_wide == *v2->v.val_wide;
case dw_val_class_vec:
if (v1->v.val_vec.length != v2->v.val_vec.length
|| v1->v.val_vec.elt_size != v2->v.val_vec.elt_size)
return 0;
if (memcmp (v1->v.val_vec.array, v2->v.val_vec.array,
v1->v.val_vec.length * v1->v.val_vec.elt_size))
return 0;
return 1;
case dw_val_class_flag:
return v1->v.val_flag == v2->v.val_flag;
case dw_val_class_str:
return !strcmp (v1->v.val_str->str, v2->v.val_str->str);
case dw_val_class_addr:
r1 = v1->v.val_addr;
r2 = v2->v.val_addr;
if (GET_CODE (r1) != GET_CODE (r2))
return 0;
return !rtx_equal_p (r1, r2);
case dw_val_class_offset:
return v1->v.val_offset == v2->v.val_offset;
case dw_val_class_loc:
for (loc1 = v1->v.val_loc, loc2 = v2->v.val_loc;
loc1 && loc2;
loc1 = loc1->dw_loc_next, loc2 = loc2->dw_loc_next)
if (!same_loc_p (loc1, loc2, mark))
return 0;
return !loc1 && !loc2;
case dw_val_class_die_ref:
return same_die_p (v1->v.val_die_ref.die, v2->v.val_die_ref.die, mark);
case dw_val_class_symview:
return strcmp (v1->v.val_symbolic_view, v2->v.val_symbolic_view) == 0;
case dw_val_class_fde_ref:
case dw_val_class_vms_delta:
case dw_val_class_lbl_id:
case dw_val_class_lineptr:
case dw_val_class_macptr:
case dw_val_class_loclistsptr:
case dw_val_class_high_pc:
return 1;
case dw_val_class_file:
case dw_val_class_file_implicit:
return v1->v.val_file == v2->v.val_file;
case dw_val_class_data8:
return !memcmp (v1->v.val_data8, v2->v.val_data8, 8);
default:
return 1;
}
}
/* Do the attributes look the same? */
static int
same_attr_p (dw_attr_node *at1, dw_attr_node *at2, int *mark)
{
if (at1->dw_attr != at2->dw_attr)
return 0;
/* We don't care that this was compiled with a different compiler
snapshot; if the output is the same, that's what matters. */
if (at1->dw_attr == DW_AT_producer)
return 1;
return same_dw_val_p (&at1->dw_attr_val, &at2->dw_attr_val, mark);
}
/* Do the dies look the same? */
static int
same_die_p (dw_die_ref die1, dw_die_ref die2, int *mark)
{
dw_die_ref c1, c2;
dw_attr_node *a1;
unsigned ix;
/* To avoid infinite recursion. */
if (die1->die_mark)
return die1->die_mark == die2->die_mark;
die1->die_mark = die2->die_mark = ++(*mark);
if (die1->die_tag != die2->die_tag)
return 0;
if (vec_safe_length (die1->die_attr) != vec_safe_length (die2->die_attr))
return 0;
FOR_EACH_VEC_SAFE_ELT (die1->die_attr, ix, a1)
if (!same_attr_p (a1, &(*die2->die_attr)[ix], mark))
return 0;
c1 = die1->die_child;
c2 = die2->die_child;
if (! c1)
{
if (c2)
return 0;
}
else
for (;;)
{
if (!same_die_p (c1, c2, mark))
return 0;
c1 = c1->die_sib;
c2 = c2->die_sib;
if (c1 == die1->die_child)
{
if (c2 == die2->die_child)
break;
else
return 0;
}
}
return 1;
}
/* Calculate the MD5 checksum of the compilation unit DIE UNIT_DIE and its
children, and set die_symbol. */
static void
compute_comp_unit_symbol (dw_die_ref unit_die)
{
const char *die_name = get_AT_string (unit_die, DW_AT_name);
const char *base = die_name ? lbasename (die_name) : "anonymous";
char *name = XALLOCAVEC (char, strlen (base) + 64);
char *p;
int i, mark;
unsigned char checksum[16];
struct md5_ctx ctx;
/* Compute the checksum of the DIE, then append part of it as hex digits to
the name filename of the unit. */
md5_init_ctx (&ctx);
mark = 0;
die_checksum (unit_die, &ctx, &mark);
unmark_all_dies (unit_die);
md5_finish_ctx (&ctx, checksum);
/* When we this for comp_unit_die () we have a DW_AT_name that might
not start with a letter but with anything valid for filenames and
clean_symbol_name doesn't fix that up. Prepend 'g' if the first
character is not a letter. */
sprintf (name, "%s%s.", ISALPHA (*base) ? "" : "g", base);
clean_symbol_name (name);
p = name + strlen (name);
for (i = 0; i < 4; i++)
{
sprintf (p, "%.2x", checksum[i]);
p += 2;
}
unit_die->die_id.die_symbol = xstrdup (name);
}
/* Returns nonzero if DIE represents a type, in the sense of TYPE_P. */
static int
is_type_die (dw_die_ref die)
{
switch (die->die_tag)
{
case DW_TAG_array_type:
case DW_TAG_class_type:
case DW_TAG_interface_type:
case DW_TAG_enumeration_type:
case DW_TAG_pointer_type:
case DW_TAG_reference_type:
case DW_TAG_rvalue_reference_type:
case DW_TAG_string_type:
case DW_TAG_structure_type:
case DW_TAG_subroutine_type:
case DW_TAG_union_type:
case DW_TAG_ptr_to_member_type:
case DW_TAG_set_type:
case DW_TAG_subrange_type:
case DW_TAG_base_type:
case DW_TAG_const_type:
case DW_TAG_file_type:
case DW_TAG_packed_type:
case DW_TAG_volatile_type:
case DW_TAG_typedef:
return 1;
default:
return 0;
}
}
/* Returns true iff C is a compile-unit DIE. */
static inline bool
is_cu_die (dw_die_ref c)
{
return c && (c->die_tag == DW_TAG_compile_unit
|| c->die_tag == DW_TAG_skeleton_unit);
}
/* Returns true iff C is a unit DIE of some sort. */
static inline bool
is_unit_die (dw_die_ref c)
{
return c && (c->die_tag == DW_TAG_compile_unit
|| c->die_tag == DW_TAG_partial_unit
|| c->die_tag == DW_TAG_type_unit
|| c->die_tag == DW_TAG_skeleton_unit);
}
/* Returns true iff C is a namespace DIE. */
static inline bool
is_namespace_die (dw_die_ref c)
{
return c && c->die_tag == DW_TAG_namespace;
}
/* Return non-zero if this DIE is a template parameter. */
static inline bool
is_template_parameter (dw_die_ref die)
{
switch (die->die_tag)
{
case DW_TAG_template_type_param:
case DW_TAG_template_value_param:
case DW_TAG_GNU_template_template_param:
case DW_TAG_GNU_template_parameter_pack:
return true;
default:
return false;
}
}
/* Return non-zero if this DIE represents a template instantiation. */
static inline bool
is_template_instantiation (dw_die_ref die)
{
dw_die_ref c;
if (!is_type_die (die) && die->die_tag != DW_TAG_subprogram)
return false;
FOR_EACH_CHILD (die, c, if (is_template_parameter (c)) return true);
return false;
}
static char *
gen_internal_sym (const char *prefix)
{
char buf[MAX_ARTIFICIAL_LABEL_BYTES];
ASM_GENERATE_INTERNAL_LABEL (buf, prefix, label_num++);
return xstrdup (buf);
}
/* Return non-zero if this DIE is a declaration. */
static int
is_declaration_die (dw_die_ref die)
{
dw_attr_node *a;
unsigned ix;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (a->dw_attr == DW_AT_declaration)
return 1;
return 0;
}
/* Return non-zero if this DIE is nested inside a subprogram. */
static int
is_nested_in_subprogram (dw_die_ref die)
{
dw_die_ref decl = get_AT_ref (die, DW_AT_specification);
if (decl == NULL)
decl = die;
return local_scope_p (decl);
}
/* Return non-zero if this DIE contains a defining declaration of a
subprogram. */
static int
contains_subprogram_definition (dw_die_ref die)
{
dw_die_ref c;
if (die->die_tag == DW_TAG_subprogram && ! is_declaration_die (die))
return 1;
FOR_EACH_CHILD (die, c, if (contains_subprogram_definition (c)) return 1);
return 0;
}
/* Return non-zero if this is a type DIE that should be moved to a
COMDAT .debug_types section or .debug_info section with DW_UT_*type
unit type. */
static int
should_move_die_to_comdat (dw_die_ref die)
{
switch (die->die_tag)
{
case DW_TAG_class_type:
case DW_TAG_structure_type:
case DW_TAG_enumeration_type:
case DW_TAG_union_type:
/* Don't move declarations, inlined instances, types nested in a
subprogram, or types that contain subprogram definitions. */
if (is_declaration_die (die)
|| get_AT (die, DW_AT_abstract_origin)
|| is_nested_in_subprogram (die)
|| contains_subprogram_definition (die))
return 0;
return 1;
case DW_TAG_array_type:
case DW_TAG_interface_type:
case DW_TAG_pointer_type:
case DW_TAG_reference_type:
case DW_TAG_rvalue_reference_type:
case DW_TAG_string_type:
case DW_TAG_subroutine_type:
case DW_TAG_ptr_to_member_type:
case DW_TAG_set_type:
case DW_TAG_subrange_type:
case DW_TAG_base_type:
case DW_TAG_const_type:
case DW_TAG_file_type:
case DW_TAG_packed_type:
case DW_TAG_volatile_type:
case DW_TAG_typedef:
default:
return 0;
}
}
/* Make a clone of DIE. */
static dw_die_ref
clone_die (dw_die_ref die)
{
dw_die_ref clone = new_die_raw (die->die_tag);
dw_attr_node *a;
unsigned ix;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
add_dwarf_attr (clone, a);
return clone;
}
/* Make a clone of the tree rooted at DIE. */
static dw_die_ref
clone_tree (dw_die_ref die)
{
dw_die_ref c;
dw_die_ref clone = clone_die (die);
FOR_EACH_CHILD (die, c, add_child_die (clone, clone_tree (c)));
return clone;
}
/* Make a clone of DIE as a declaration. */
static dw_die_ref
clone_as_declaration (dw_die_ref die)
{
dw_die_ref clone;
dw_die_ref decl;
dw_attr_node *a;
unsigned ix;
/* If the DIE is already a declaration, just clone it. */
if (is_declaration_die (die))
return clone_die (die);
/* If the DIE is a specification, just clone its declaration DIE. */
decl = get_AT_ref (die, DW_AT_specification);
if (decl != NULL)
{
clone = clone_die (decl);
if (die->comdat_type_p)
add_AT_die_ref (clone, DW_AT_signature, die);
return clone;
}
clone = new_die_raw (die->die_tag);
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
{
/* We don't want to copy over all attributes.
For example we don't want DW_AT_byte_size because otherwise we will no
longer have a declaration and GDB will treat it as a definition. */
switch (a->dw_attr)
{
case DW_AT_abstract_origin:
case DW_AT_artificial:
case DW_AT_containing_type:
case DW_AT_external:
case DW_AT_name:
case DW_AT_type:
case DW_AT_virtuality:
case DW_AT_linkage_name:
case DW_AT_MIPS_linkage_name:
add_dwarf_attr (clone, a);
break;
case DW_AT_byte_size:
case DW_AT_alignment:
default:
break;
}
}
if (die->comdat_type_p)
add_AT_die_ref (clone, DW_AT_signature, die);
add_AT_flag (clone, DW_AT_declaration, 1);
return clone;
}
/* Structure to map a DIE in one CU to its copy in a comdat type unit. */
struct decl_table_entry
{
dw_die_ref orig;
dw_die_ref copy;
};
/* Helpers to manipulate hash table of copied declarations. */
/* Hashtable helpers. */
struct decl_table_entry_hasher : free_ptr_hash <decl_table_entry>
{
typedef die_struct *compare_type;
static inline hashval_t hash (const decl_table_entry *);
static inline bool equal (const decl_table_entry *, const die_struct *);
};
inline hashval_t
decl_table_entry_hasher::hash (const decl_table_entry *entry)
{
return htab_hash_pointer (entry->orig);
}
inline bool
decl_table_entry_hasher::equal (const decl_table_entry *entry1,
const die_struct *entry2)
{
return entry1->orig == entry2;
}
typedef hash_table<decl_table_entry_hasher> decl_hash_type;
/* Copy DIE and its ancestors, up to, but not including, the compile unit
or type unit entry, to a new tree. Adds the new tree to UNIT and returns
a pointer to the copy of DIE. If DECL_TABLE is provided, it is used
to check if the ancestor has already been copied into UNIT. */
static dw_die_ref
copy_ancestor_tree (dw_die_ref unit, dw_die_ref die,
decl_hash_type *decl_table)
{
dw_die_ref parent = die->die_parent;
dw_die_ref new_parent = unit;
dw_die_ref copy;
decl_table_entry **slot = NULL;
struct decl_table_entry *entry = NULL;
/* If DIE refers to a stub unfold that so we get the appropriate
DIE registered as orig in decl_table. */
if (dw_die_ref c = get_AT_ref (die, DW_AT_signature))
die = c;
if (decl_table)
{
/* Check if the entry has already been copied to UNIT. */
slot = decl_table->find_slot_with_hash (die, htab_hash_pointer (die),
INSERT);
if (*slot != HTAB_EMPTY_ENTRY)
{
entry = *slot;
return entry->copy;
}
/* Record in DECL_TABLE that DIE has been copied to UNIT. */
entry = XCNEW (struct decl_table_entry);
entry->orig = die;
entry->copy = NULL;
*slot = entry;
}
if (parent != NULL)
{
dw_die_ref spec = get_AT_ref (parent, DW_AT_specification);
if (spec != NULL)
parent = spec;
if (!is_unit_die (parent))
new_parent = copy_ancestor_tree (unit, parent, decl_table);
}
copy = clone_as_declaration (die);
add_child_die (new_parent, copy);
if (decl_table)
{
/* Record the pointer to the copy. */
entry->copy = copy;
}
return copy;
}
/* Copy the declaration context to the new type unit DIE. This includes
any surrounding namespace or type declarations. If the DIE has an
AT_specification attribute, it also includes attributes and children
attached to the specification, and returns a pointer to the original
parent of the declaration DIE. Returns NULL otherwise. */
static dw_die_ref
copy_declaration_context (dw_die_ref unit, dw_die_ref die)
{
dw_die_ref decl;
dw_die_ref new_decl;
dw_die_ref orig_parent = NULL;
decl = get_AT_ref (die, DW_AT_specification);
if (decl == NULL)
decl = die;
else
{
unsigned ix;
dw_die_ref c;
dw_attr_node *a;
/* The original DIE will be changed to a declaration, and must
be moved to be a child of the original declaration DIE. */
orig_parent = decl->die_parent;
/* Copy the type node pointer from the new DIE to the original
declaration DIE so we can forward references later. */
decl->comdat_type_p = true;
decl->die_id.die_type_node = die->die_id.die_type_node;
remove_AT (die, DW_AT_specification);
FOR_EACH_VEC_SAFE_ELT (decl->die_attr, ix, a)
{
if (a->dw_attr != DW_AT_name
&& a->dw_attr != DW_AT_declaration
&& a->dw_attr != DW_AT_external)
add_dwarf_attr (die, a);
}
FOR_EACH_CHILD (decl, c, add_child_die (die, clone_tree (c)));
}
if (decl->die_parent != NULL
&& !is_unit_die (decl->die_parent))
{
new_decl = copy_ancestor_tree (unit, decl, NULL);
if (new_decl != NULL)
{
remove_AT (new_decl, DW_AT_signature);
add_AT_specification (die, new_decl);
}
}
return orig_parent;
}
/* Generate the skeleton ancestor tree for the given NODE, then clone
the DIE and add the clone into the tree. */
static void
generate_skeleton_ancestor_tree (skeleton_chain_node *node)
{
if (node->new_die != NULL)
return;
node->new_die = clone_as_declaration (node->old_die);
if (node->parent != NULL)
{
generate_skeleton_ancestor_tree (node->parent);
add_child_die (node->parent->new_die, node->new_die);
}
}
/* Generate a skeleton tree of DIEs containing any declarations that are
found in the original tree. We traverse the tree looking for declaration
DIEs, and construct the skeleton from the bottom up whenever we find one. */
static void
generate_skeleton_bottom_up (skeleton_chain_node *parent)
{
skeleton_chain_node node;
dw_die_ref c;
dw_die_ref first;
dw_die_ref prev = NULL;
dw_die_ref next = NULL;
node.parent = parent;
first = c = parent->old_die->die_child;
if (c)
next = c->die_sib;
if (c) do {
if (prev == NULL || prev->die_sib == c)
prev = c;
c = next;
next = (c == first ? NULL : c->die_sib);
node.old_die = c;
node.new_die = NULL;
if (is_declaration_die (c))
{
if (is_template_instantiation (c))
{
/* Instantiated templates do not need to be cloned into the
type unit. Just move the DIE and its children back to
the skeleton tree (in the main CU). */
remove_child_with_prev (c, prev);
add_child_die (parent->new_die, c);
c = prev;
}
else if (c->comdat_type_p)
{
/* This is the skeleton of earlier break_out_comdat_types
type. Clone the existing DIE, but keep the children
under the original (which is in the main CU). */
dw_die_ref clone = clone_die (c);
replace_child (c, clone, prev);
generate_skeleton_ancestor_tree (parent);
add_child_die (parent->new_die, c);
c = clone;
continue;
}
else
{
/* Clone the existing DIE, move the original to the skeleton
tree (which is in the main CU), and put the clone, with
all the original's children, where the original came from
(which is about to be moved to the type unit). */
dw_die_ref clone = clone_die (c);
move_all_children (c, clone);
/* If the original has a DW_AT_object_pointer attribute,
it would now point to a child DIE just moved to the
cloned tree, so we need to remove that attribute from
the original. */
remove_AT (c, DW_AT_object_pointer);
replace_child (c, clone, prev);
generate_skeleton_ancestor_tree (parent);
add_child_die (parent->new_die, c);
node.old_die = clone;
node.new_die = c;
c = clone;
}
}
generate_skeleton_bottom_up (&node);
} while (next != NULL);
}
/* Wrapper function for generate_skeleton_bottom_up. */
static dw_die_ref
generate_skeleton (dw_die_ref die)
{
skeleton_chain_node node;
node.old_die = die;
node.new_die = NULL;
node.parent = NULL;
/* If this type definition is nested inside another type,
and is not an instantiation of a template, always leave
at least a declaration in its place. */
if (die->die_parent != NULL
&& is_type_die (die->die_parent)
&& !is_template_instantiation (die))
node.new_die = clone_as_declaration (die);
generate_skeleton_bottom_up (&node);
return node.new_die;
}
/* Remove the CHILD DIE from its parent, possibly replacing it with a cloned
declaration. The original DIE is moved to a new compile unit so that
existing references to it follow it to the new location. If any of the
original DIE's descendants is a declaration, we need to replace the
original DIE with a skeleton tree and move the declarations back into the
skeleton tree. */
static dw_die_ref
remove_child_or_replace_with_skeleton (dw_die_ref unit, dw_die_ref child,
dw_die_ref prev)
{
dw_die_ref skeleton, orig_parent;
/* Copy the declaration context to the type unit DIE. If the returned
ORIG_PARENT is not NULL, the skeleton needs to be added as a child of
that DIE. */
orig_parent = copy_declaration_context (unit, child);
skeleton = generate_skeleton (child);
if (skeleton == NULL)
remove_child_with_prev (child, prev);
else
{
skeleton->comdat_type_p = true;
skeleton->die_id.die_type_node = child->die_id.die_type_node;
/* If the original DIE was a specification, we need to put
the skeleton under the parent DIE of the declaration.
This leaves the original declaration in the tree, but
it will be pruned later since there are no longer any
references to it. */
if (orig_parent != NULL)
{
remove_child_with_prev (child, prev);
add_child_die (orig_parent, skeleton);
}
else
replace_child (child, skeleton, prev);
}
return skeleton;
}
static void
copy_dwarf_procs_ref_in_attrs (dw_die_ref die,
comdat_type_node *type_node,
hash_map<dw_die_ref, dw_die_ref> &copied_dwarf_procs);
/* Helper for copy_dwarf_procs_ref_in_dies. Make a copy of the DIE DWARF
procedure, put it under TYPE_NODE and return the copy. Continue looking for
DWARF procedure references in the DW_AT_location attribute. */
static dw_die_ref
copy_dwarf_procedure (dw_die_ref die,
comdat_type_node *type_node,
hash_map<dw_die_ref, dw_die_ref> &copied_dwarf_procs)
{
gcc_assert (die->die_tag == DW_TAG_dwarf_procedure);
/* DWARF procedures are not supposed to have children... */
gcc_assert (die->die_child == NULL);
/* ... and they are supposed to have only one attribute: DW_AT_location. */
gcc_assert (vec_safe_length (die->die_attr) == 1
&& ((*die->die_attr)[0].dw_attr == DW_AT_location));
/* Do not copy more than once DWARF procedures. */
bool existed;
dw_die_ref &die_copy = copied_dwarf_procs.get_or_insert (die, &existed);
if (existed)
return die_copy;
die_copy = clone_die (die);
add_child_die (type_node->root_die, die_copy);
copy_dwarf_procs_ref_in_attrs (die_copy, type_node, copied_dwarf_procs);
return die_copy;
}
/* Helper for copy_dwarf_procs_ref_in_dies. Look for references to DWARF
procedures in DIE's attributes. */
static void
copy_dwarf_procs_ref_in_attrs (dw_die_ref die,
comdat_type_node *type_node,
hash_map<dw_die_ref, dw_die_ref> &copied_dwarf_procs)
{
dw_attr_node *a;
unsigned i;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, i, a)
{
dw_loc_descr_ref loc;
if (a->dw_attr_val.val_class != dw_val_class_loc)
continue;
for (loc = a->dw_attr_val.v.val_loc; loc != NULL; loc = loc->dw_loc_next)
{
switch (loc->dw_loc_opc)
{
case DW_OP_call2:
case DW_OP_call4:
case DW_OP_call_ref:
gcc_assert (loc->dw_loc_oprnd1.val_class
== dw_val_class_die_ref);
loc->dw_loc_oprnd1.v.val_die_ref.die
= copy_dwarf_procedure (loc->dw_loc_oprnd1.v.val_die_ref.die,
type_node,
copied_dwarf_procs);
default:
break;
}
}
}
}
/* Copy DWARF procedures that are referenced by the DIE tree to TREE_NODE and
rewrite references to point to the copies.
References are looked for in DIE's attributes and recursively in all its
children attributes that are location descriptions. COPIED_DWARF_PROCS is a
mapping from old DWARF procedures to their copy. It is used not to copy
twice the same DWARF procedure under TYPE_NODE. */
static void
copy_dwarf_procs_ref_in_dies (dw_die_ref die,
comdat_type_node *type_node,
hash_map<dw_die_ref, dw_die_ref> &copied_dwarf_procs)
{
dw_die_ref c;
copy_dwarf_procs_ref_in_attrs (die, type_node, copied_dwarf_procs);
FOR_EACH_CHILD (die, c, copy_dwarf_procs_ref_in_dies (c,
type_node,
copied_dwarf_procs));
}
/* Traverse the DIE and set up additional .debug_types or .debug_info
DW_UT_*type sections for each type worthy of being placed in a COMDAT
section. */
static void
break_out_comdat_types (dw_die_ref die)
{
dw_die_ref c;
dw_die_ref first;
dw_die_ref prev = NULL;
dw_die_ref next = NULL;
dw_die_ref unit = NULL;
first = c = die->die_child;
if (c)
next = c->die_sib;
if (c) do {
if (prev == NULL || prev->die_sib == c)
prev = c;
c = next;
next = (c == first ? NULL : c->die_sib);
if (should_move_die_to_comdat (c))
{
dw_die_ref replacement;
comdat_type_node *type_node;
/* Break out nested types into their own type units. */
break_out_comdat_types (c);
/* Create a new type unit DIE as the root for the new tree. */
unit = new_die (DW_TAG_type_unit, NULL, NULL);
add_AT_unsigned (unit, DW_AT_language,
get_AT_unsigned (comp_unit_die (), DW_AT_language));
/* Add the new unit's type DIE into the comdat type list. */
type_node = ggc_cleared_alloc<comdat_type_node> ();
type_node->root_die = unit;
type_node->next = comdat_type_list;
comdat_type_list = type_node;
/* Generate the type signature. */
generate_type_signature (c, type_node);
/* Copy the declaration context, attributes, and children of the
declaration into the new type unit DIE, then remove this DIE
from the main CU (or replace it with a skeleton if necessary). */
replacement = remove_child_or_replace_with_skeleton (unit, c, prev);
type_node->skeleton_die = replacement;
/* Add the DIE to the new compunit. */
add_child_die (unit, c);
/* Types can reference DWARF procedures for type size or data location
expressions. Calls in DWARF expressions cannot target procedures
that are not in the same section. So we must copy DWARF procedures
along with this type and then rewrite references to them. */
hash_map<dw_die_ref, dw_die_ref> copied_dwarf_procs;
copy_dwarf_procs_ref_in_dies (c, type_node, copied_dwarf_procs);
if (replacement != NULL)
c = replacement;
}
else if (c->die_tag == DW_TAG_namespace
|| c->die_tag == DW_TAG_class_type
|| c->die_tag == DW_TAG_structure_type
|| c->die_tag == DW_TAG_union_type)
{
/* Look for nested types that can be broken out. */
break_out_comdat_types (c);
}
} while (next != NULL);
}
/* Like clone_tree, but copy DW_TAG_subprogram DIEs as declarations.
Enter all the cloned children into the hash table decl_table. */
static dw_die_ref
clone_tree_partial (dw_die_ref die, decl_hash_type *decl_table)
{
dw_die_ref c;
dw_die_ref clone;
struct decl_table_entry *entry;
decl_table_entry **slot;
if (die->die_tag == DW_TAG_subprogram)
clone = clone_as_declaration (die);
else
clone = clone_die (die);
slot = decl_table->find_slot_with_hash (die,
htab_hash_pointer (die), INSERT);
/* Assert that DIE isn't in the hash table yet. If it would be there
before, the ancestors would be necessarily there as well, therefore
clone_tree_partial wouldn't be called. */
gcc_assert (*slot == HTAB_EMPTY_ENTRY);
entry = XCNEW (struct decl_table_entry);
entry->orig = die;
entry->copy = clone;
*slot = entry;
if (die->die_tag != DW_TAG_subprogram)
FOR_EACH_CHILD (die, c,
add_child_die (clone, clone_tree_partial (c, decl_table)));
return clone;
}
/* Walk the DIE and its children, looking for references to incomplete
or trivial types that are unmarked (i.e., that are not in the current
type_unit). */
static void
copy_decls_walk (dw_die_ref unit, dw_die_ref die, decl_hash_type *decl_table)
{
dw_die_ref c;
dw_attr_node *a;
unsigned ix;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
{
if (AT_class (a) == dw_val_class_die_ref)
{
dw_die_ref targ = AT_ref (a);
decl_table_entry **slot;
struct decl_table_entry *entry;
if (targ->die_mark != 0 || targ->comdat_type_p)
continue;
slot = decl_table->find_slot_with_hash (targ,
htab_hash_pointer (targ),
INSERT);
if (*slot != HTAB_EMPTY_ENTRY)
{
/* TARG has already been copied, so we just need to
modify the reference to point to the copy. */
entry = *slot;
a->dw_attr_val.v.val_die_ref.die = entry->copy;
}
else
{
dw_die_ref parent = unit;
dw_die_ref copy = clone_die (targ);
/* Record in DECL_TABLE that TARG has been copied.
Need to do this now, before the recursive call,
because DECL_TABLE may be expanded and SLOT
would no longer be a valid pointer. */
entry = XCNEW (struct decl_table_entry);
entry->orig = targ;
entry->copy = copy;
*slot = entry;
/* If TARG is not a declaration DIE, we need to copy its
children. */
if (!is_declaration_die (targ))
{
FOR_EACH_CHILD (
targ, c,
add_child_die (copy,
clone_tree_partial (c, decl_table)));
}
/* Make sure the cloned tree is marked as part of the
type unit. */
mark_dies (copy);
/* If TARG has surrounding context, copy its ancestor tree
into the new type unit. */
if (targ->die_parent != NULL
&& !is_unit_die (targ->die_parent))
parent = copy_ancestor_tree (unit, targ->die_parent,
decl_table);
add_child_die (parent, copy);
a->dw_attr_val.v.val_die_ref.die = copy;
/* Make sure the newly-copied DIE is walked. If it was
installed in a previously-added context, it won't
get visited otherwise. */
if (parent != unit)
{
/* Find the highest point of the newly-added tree,
mark each node along the way, and walk from there. */
parent->die_mark = 1;
while (parent->die_parent
&& parent->die_parent->die_mark == 0)
{
parent = parent->die_parent;
parent->die_mark = 1;
}
copy_decls_walk (unit, parent, decl_table);
}
}
}
}
FOR_EACH_CHILD (die, c, copy_decls_walk (unit, c, decl_table));
}
/* Collect skeleton dies in DIE created by break_out_comdat_types already
and record them in DECL_TABLE. */
static void
collect_skeleton_dies (dw_die_ref die, decl_hash_type *decl_table)
{
dw_die_ref c;
if (dw_attr_node *a = get_AT (die, DW_AT_signature))
{
dw_die_ref targ = AT_ref (a);
gcc_assert (targ->die_mark == 0 && targ->comdat_type_p);
decl_table_entry **slot
= decl_table->find_slot_with_hash (targ,
htab_hash_pointer (targ),
INSERT);
gcc_assert (*slot == HTAB_EMPTY_ENTRY);
/* Record in DECL_TABLE that TARG has been already copied
by remove_child_or_replace_with_skeleton. */
decl_table_entry *entry = XCNEW (struct decl_table_entry);
entry->orig = targ;
entry->copy = die;
*slot = entry;
}
FOR_EACH_CHILD (die, c, collect_skeleton_dies (c, decl_table));
}
/* Copy declarations for "unworthy" types into the new comdat section.
Incomplete types, modified types, and certain other types aren't broken
out into comdat sections of their own, so they don't have a signature,
and we need to copy the declaration into the same section so that we
don't have an external reference. */
static void
copy_decls_for_unworthy_types (dw_die_ref unit)
{
mark_dies (unit);
decl_hash_type decl_table (10);
collect_skeleton_dies (unit, &decl_table);
copy_decls_walk (unit, unit, &decl_table);
unmark_dies (unit);
}
/* Traverse the DIE and add a sibling attribute if it may have the
effect of speeding up access to siblings. To save some space,
avoid generating sibling attributes for DIE's without children. */
static void
add_sibling_attributes (dw_die_ref die)
{
dw_die_ref c;
if (! die->die_child)
return;
if (die->die_parent && die != die->die_parent->die_child)
add_AT_die_ref (die, DW_AT_sibling, die->die_sib);
FOR_EACH_CHILD (die, c, add_sibling_attributes (c));
}
/* Output all location lists for the DIE and its children. */
static void
output_location_lists (dw_die_ref die)
{
dw_die_ref c;
dw_attr_node *a;
unsigned ix;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (AT_class (a) == dw_val_class_loc_list)
output_loc_list (AT_loc_list (a));
FOR_EACH_CHILD (die, c, output_location_lists (c));
}
/* During assign_location_list_indexes and output_loclists_offset the
current index, after it the number of assigned indexes (i.e. how
large the .debug_loclists* offset table should be). */
static unsigned int loc_list_idx;
/* Output all location list offsets for the DIE and its children. */
static void
output_loclists_offsets (dw_die_ref die)
{
dw_die_ref c;
dw_attr_node *a;
unsigned ix;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (AT_class (a) == dw_val_class_loc_list)
{
dw_loc_list_ref l = AT_loc_list (a);
if (l->offset_emitted)
continue;
dw2_asm_output_delta (DWARF_OFFSET_SIZE, l->ll_symbol,
loc_section_label, NULL);
gcc_assert (l->hash == loc_list_idx);
loc_list_idx++;
l->offset_emitted = true;
}
FOR_EACH_CHILD (die, c, output_loclists_offsets (c));
}
/* Recursively set indexes of location lists. */
static void
assign_location_list_indexes (dw_die_ref die)
{
dw_die_ref c;
dw_attr_node *a;
unsigned ix;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (AT_class (a) == dw_val_class_loc_list)
{
dw_loc_list_ref list = AT_loc_list (a);
if (!list->num_assigned)
{
list->num_assigned = true;
list->hash = loc_list_idx++;
}
}
FOR_EACH_CHILD (die, c, assign_location_list_indexes (c));
}
/* We want to limit the number of external references, because they are
larger than local references: a relocation takes multiple words, and
even a sig8 reference is always eight bytes, whereas a local reference
can be as small as one byte (though DW_FORM_ref is usually 4 in GCC).
So if we encounter multiple external references to the same type DIE, we
make a local typedef stub for it and redirect all references there.
This is the element of the hash table for keeping track of these
references. */
struct external_ref
{
dw_die_ref type;
dw_die_ref stub;
unsigned n_refs;
};
/* Hashtable helpers. */
struct external_ref_hasher : free_ptr_hash <external_ref>
{
static inline hashval_t hash (const external_ref *);
static inline bool equal (const external_ref *, const external_ref *);
};
inline hashval_t
external_ref_hasher::hash (const external_ref *r)
{
dw_die_ref die = r->type;
hashval_t h = 0;
/* We can't use the address of the DIE for hashing, because
that will make the order of the stub DIEs non-deterministic. */
if (! die->comdat_type_p)
/* We have a symbol; use it to compute a hash. */
h = htab_hash_string (die->die_id.die_symbol);
else
{
/* We have a type signature; use a subset of the bits as the hash.
The 8-byte signature is at least as large as hashval_t. */
comdat_type_node *type_node = die->die_id.die_type_node;
memcpy (&h, type_node->signature, sizeof (h));
}
return h;
}
inline bool
external_ref_hasher::equal (const external_ref *r1, const external_ref *r2)
{
return r1->type == r2->type;
}
typedef hash_table<external_ref_hasher> external_ref_hash_type;
/* Return a pointer to the external_ref for references to DIE. */
static struct external_ref *
lookup_external_ref (external_ref_hash_type *map, dw_die_ref die)
{
struct external_ref ref, *ref_p;
external_ref **slot;
ref.type = die;
slot = map->find_slot (&ref, INSERT);
if (*slot != HTAB_EMPTY_ENTRY)
return *slot;
ref_p = XCNEW (struct external_ref);
ref_p->type = die;
*slot = ref_p;
return ref_p;
}
/* Subroutine of optimize_external_refs, below.
If we see a type skeleton, record it as our stub. If we see external
references, remember how many we've seen. */
static void
optimize_external_refs_1 (dw_die_ref die, external_ref_hash_type *map)
{
dw_die_ref c;
dw_attr_node *a;
unsigned ix;
struct external_ref *ref_p;
if (is_type_die (die)
&& (c = get_AT_ref (die, DW_AT_signature)))
{
/* This is a local skeleton; use it for local references. */
ref_p = lookup_external_ref (map, c);
ref_p->stub = die;
}
/* Scan the DIE references, and remember any that refer to DIEs from
other CUs (i.e. those which are not marked). */
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (AT_class (a) == dw_val_class_die_ref
&& (c = AT_ref (a))->die_mark == 0
&& is_type_die (c))
{
ref_p = lookup_external_ref (map, c);
ref_p->n_refs++;
}
FOR_EACH_CHILD (die, c, optimize_external_refs_1 (c, map));
}
/* htab_traverse callback function for optimize_external_refs, below. SLOT
points to an external_ref, DATA is the CU we're processing. If we don't
already have a local stub, and we have multiple refs, build a stub. */
int
dwarf2_build_local_stub (external_ref **slot, dw_die_ref data)
{
struct external_ref *ref_p = *slot;
if (ref_p->stub == NULL && ref_p->n_refs > 1 && !dwarf_strict)
{
/* We have multiple references to this type, so build a small stub.
Both of these forms are a bit dodgy from the perspective of the
DWARF standard, since technically they should have names. */
dw_die_ref cu = data;
dw_die_ref type = ref_p->type;
dw_die_ref stub = NULL;
if (type->comdat_type_p)
{
/* If we refer to this type via sig8, use AT_signature. */
stub = new_die (type->die_tag, cu, NULL_TREE);
add_AT_die_ref (stub, DW_AT_signature, type);
}
else
{
/* Otherwise, use a typedef with no name. */
stub = new_die (DW_TAG_typedef, cu, NULL_TREE);
add_AT_die_ref (stub, DW_AT_type, type);
}
stub->die_mark++;
ref_p->stub = stub;
}
return 1;
}
/* DIE is a unit; look through all the DIE references to see if there are
any external references to types, and if so, create local stubs for
them which will be applied in build_abbrev_table. This is useful because
references to local DIEs are smaller. */
static external_ref_hash_type *
optimize_external_refs (dw_die_ref die)
{
external_ref_hash_type *map = new external_ref_hash_type (10);
optimize_external_refs_1 (die, map);
map->traverse <dw_die_ref, dwarf2_build_local_stub> (die);
return map;
}
/* The following 3 variables are temporaries that are computed only during the
build_abbrev_table call and used and released during the following
optimize_abbrev_table call. */
/* First abbrev_id that can be optimized based on usage. */
static unsigned int abbrev_opt_start;
/* Maximum abbrev_id of a base type plus one (we can't optimize DIEs with
abbrev_id smaller than this, because they must be already sized
during build_abbrev_table). */
static unsigned int abbrev_opt_base_type_end;
/* Vector of usage counts during build_abbrev_table. Indexed by
abbrev_id - abbrev_opt_start. */
static vec<unsigned int> abbrev_usage_count;
/* Vector of all DIEs added with die_abbrev >= abbrev_opt_start. */
static vec<dw_die_ref> sorted_abbrev_dies;
/* The format of each DIE (and its attribute value pairs) is encoded in an
abbreviation table. This routine builds the abbreviation table and assigns
a unique abbreviation id for each abbreviation entry. The children of each
die are visited recursively. */
static void
build_abbrev_table (dw_die_ref die, external_ref_hash_type *extern_map)
{
unsigned int abbrev_id = 0;
dw_die_ref c;
dw_attr_node *a;
unsigned ix;
dw_die_ref abbrev;
/* Scan the DIE references, and replace any that refer to
DIEs from other CUs (i.e. those which are not marked) with
the local stubs we built in optimize_external_refs. */
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (AT_class (a) == dw_val_class_die_ref
&& (c = AT_ref (a))->die_mark == 0)
{
struct external_ref *ref_p;
gcc_assert (AT_ref (a)->comdat_type_p || AT_ref (a)->die_id.die_symbol);
if (is_type_die (c)
&& (ref_p = lookup_external_ref (extern_map, c))
&& ref_p->stub && ref_p->stub != die)
{
gcc_assert (a->dw_attr != DW_AT_signature);
change_AT_die_ref (a, ref_p->stub);
}
else
/* We aren't changing this reference, so mark it external. */
set_AT_ref_external (a, 1);
}
FOR_EACH_VEC_SAFE_ELT (abbrev_die_table, abbrev_id, abbrev)
{
dw_attr_node *die_a, *abbrev_a;
unsigned ix;
bool ok = true;
if (abbrev_id == 0)
continue;
if (abbrev->die_tag != die->die_tag)
continue;
if ((abbrev->die_child != NULL) != (die->die_child != NULL))
continue;
if (vec_safe_length (abbrev->die_attr) != vec_safe_length (die->die_attr))
continue;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, die_a)
{
abbrev_a = &(*abbrev->die_attr)[ix];
if ((abbrev_a->dw_attr != die_a->dw_attr)
|| (value_format (abbrev_a) != value_format (die_a)))
{
ok = false;
break;
}
}
if (ok)
break;
}
if (abbrev_id >= vec_safe_length (abbrev_die_table))
{
vec_safe_push (abbrev_die_table, die);
if (abbrev_opt_start)
abbrev_usage_count.safe_push (0);
}
if (abbrev_opt_start && abbrev_id >= abbrev_opt_start)
{
abbrev_usage_count[abbrev_id - abbrev_opt_start]++;
sorted_abbrev_dies.safe_push (die);
}
die->die_abbrev = abbrev_id;
FOR_EACH_CHILD (die, c, build_abbrev_table (c, extern_map));
}
/* Callback function for sorted_abbrev_dies vector sorting. We sort
by die_abbrev's usage count, from the most commonly used
abbreviation to the least. */
static int
die_abbrev_cmp (const void *p1, const void *p2)
{
dw_die_ref die1 = *(const dw_die_ref *) p1;
dw_die_ref die2 = *(const dw_die_ref *) p2;
gcc_checking_assert (die1->die_abbrev >= abbrev_opt_start);
gcc_checking_assert (die2->die_abbrev >= abbrev_opt_start);
if (die1->die_abbrev >= abbrev_opt_base_type_end
&& die2->die_abbrev >= abbrev_opt_base_type_end)
{
if (abbrev_usage_count[die1->die_abbrev - abbrev_opt_start]
> abbrev_usage_count[die2->die_abbrev - abbrev_opt_start])
return -1;
if (abbrev_usage_count[die1->die_abbrev - abbrev_opt_start]
< abbrev_usage_count[die2->die_abbrev - abbrev_opt_start])
return 1;
}
/* Stabilize the sort. */
if (die1->die_abbrev < die2->die_abbrev)
return -1;
if (die1->die_abbrev > die2->die_abbrev)
return 1;
return 0;
}
/* Convert dw_val_class_const and dw_val_class_unsigned_const class attributes
of DIEs in between sorted_abbrev_dies[first_id] and abbrev_dies[end_id - 1]
into dw_val_class_const_implicit or
dw_val_class_unsigned_const_implicit. */
static void
optimize_implicit_const (unsigned int first_id, unsigned int end,
vec<bool> &implicit_consts)
{
/* It never makes sense if there is just one DIE using the abbreviation. */
if (end < first_id + 2)
return;
dw_attr_node *a;
unsigned ix, i;
dw_die_ref die = sorted_abbrev_dies[first_id];
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (implicit_consts[ix])
{
enum dw_val_class new_class = dw_val_class_none;
switch (AT_class (a))
{
case dw_val_class_unsigned_const:
if ((HOST_WIDE_INT) AT_unsigned (a) < 0)
continue;
/* The .debug_abbrev section will grow by
size_of_sleb128 (AT_unsigned (a)) and we avoid the constants
in all the DIEs using that abbreviation. */
if (constant_size (AT_unsigned (a)) * (end - first_id)
<= (unsigned) size_of_sleb128 (AT_unsigned (a)))
continue;
new_class = dw_val_class_unsigned_const_implicit;
break;
case dw_val_class_const:
new_class = dw_val_class_const_implicit;
break;
case dw_val_class_file:
new_class = dw_val_class_file_implicit;
break;
default:
continue;
}
for (i = first_id; i < end; i++)
(*sorted_abbrev_dies[i]->die_attr)[ix].dw_attr_val.val_class
= new_class;
}
}
/* Attempt to optimize abbreviation table from abbrev_opt_start
abbreviation above. */
static void
optimize_abbrev_table (void)
{
if (abbrev_opt_start
&& vec_safe_length (abbrev_die_table) > abbrev_opt_start
&& (dwarf_version >= 5 || vec_safe_length (abbrev_die_table) > 127))
{
auto_vec<bool, 32> implicit_consts;
sorted_abbrev_dies.qsort (die_abbrev_cmp);
unsigned int abbrev_id = abbrev_opt_start - 1;
unsigned int first_id = ~0U;
unsigned int last_abbrev_id = 0;
unsigned int i;
dw_die_ref die;
if (abbrev_opt_base_type_end > abbrev_opt_start)
abbrev_id = abbrev_opt_base_type_end - 1;
/* Reassign abbreviation ids from abbrev_opt_start above, so that
most commonly used abbreviations come first. */
FOR_EACH_VEC_ELT (sorted_abbrev_dies, i, die)
{
dw_attr_node *a;
unsigned ix;
/* If calc_base_type_die_sizes has been called, the CU and
base types after it can't be optimized, because we've already
calculated their DIE offsets. We've sorted them first. */
if (die->die_abbrev < abbrev_opt_base_type_end)
continue;
if (die->die_abbrev != last_abbrev_id)
{
last_abbrev_id = die->die_abbrev;
if (dwarf_version >= 5 && first_id != ~0U)
optimize_implicit_const (first_id, i, implicit_consts);
abbrev_id++;
(*abbrev_die_table)[abbrev_id] = die;
if (dwarf_version >= 5)
{
first_id = i;
implicit_consts.truncate (0);
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
switch (AT_class (a))
{
case dw_val_class_const:
case dw_val_class_unsigned_const:
case dw_val_class_file:
implicit_consts.safe_push (true);
break;
default:
implicit_consts.safe_push (false);
break;
}
}
}
else if (dwarf_version >= 5)
{
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (!implicit_consts[ix])
continue;
else
{
dw_attr_node *other_a
= &(*(*abbrev_die_table)[abbrev_id]->die_attr)[ix];
if (!dw_val_equal_p (&a->dw_attr_val,
&other_a->dw_attr_val))
implicit_consts[ix] = false;
}
}
die->die_abbrev = abbrev_id;
}
gcc_assert (abbrev_id == vec_safe_length (abbrev_die_table) - 1);
if (dwarf_version >= 5 && first_id != ~0U)
optimize_implicit_const (first_id, i, implicit_consts);
}
abbrev_opt_start = 0;
abbrev_opt_base_type_end = 0;
abbrev_usage_count.release ();
sorted_abbrev_dies.release ();
}
/* Return the power-of-two number of bytes necessary to represent VALUE. */
static int
constant_size (unsigned HOST_WIDE_INT value)
{
int log;
if (value == 0)
log = 0;
else
log = floor_log2 (value);
log = log / 8;
log = 1 << (floor_log2 (log) + 1);
return log;
}
/* Return the size of a DIE as it is represented in the
.debug_info section. */
static unsigned long
size_of_die (dw_die_ref die)
{
unsigned long size = 0;
dw_attr_node *a;
unsigned ix;
enum dwarf_form form;
size += size_of_uleb128 (die->die_abbrev);
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
{
switch (AT_class (a))
{
case dw_val_class_addr:
if (dwarf_split_debug_info && AT_index (a) != NOT_INDEXED)
{
gcc_assert (AT_index (a) != NO_INDEX_ASSIGNED);
size += size_of_uleb128 (AT_index (a));
}
else
size += DWARF2_ADDR_SIZE;
break;
case dw_val_class_offset:
size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_loc:
{
unsigned long lsize = size_of_locs (AT_loc (a));
/* Block length. */
if (dwarf_version >= 4)
size += size_of_uleb128 (lsize);
else
size += constant_size (lsize);
size += lsize;
}
break;
case dw_val_class_loc_list:
if (dwarf_split_debug_info && dwarf_version >= 5)
{
gcc_assert (AT_loc_list (a)->num_assigned);
size += size_of_uleb128 (AT_loc_list (a)->hash);
}
else
size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_view_list:
size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_range_list:
if (value_format (a) == DW_FORM_rnglistx)
{
gcc_assert (rnglist_idx);
dw_ranges *r = &(*ranges_table)[a->dw_attr_val.v.val_offset];
size += size_of_uleb128 (r->idx);
}
else
size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_const:
size += size_of_sleb128 (AT_int (a));
break;
case dw_val_class_unsigned_const:
{
int csize = constant_size (AT_unsigned (a));
if (dwarf_version == 3
&& a->dw_attr == DW_AT_data_member_location
&& csize >= 4)
size += size_of_uleb128 (AT_unsigned (a));
else
size += csize;
}
break;
case dw_val_class_symview:
if (symview_upper_bound <= 0xff)
size += 1;
else if (symview_upper_bound <= 0xffff)
size += 2;
else if (symview_upper_bound <= 0xffffffff)
size += 4;
else
size += 8;
break;
case dw_val_class_const_implicit:
case dw_val_class_unsigned_const_implicit:
case dw_val_class_file_implicit:
/* These occupy no size in the DIE, just an extra sleb128 in
.debug_abbrev. */
break;
case dw_val_class_const_double:
size += HOST_BITS_PER_DOUBLE_INT / HOST_BITS_PER_CHAR;
if (HOST_BITS_PER_WIDE_INT >= DWARF_LARGEST_DATA_FORM_BITS)
size++; /* block */
break;
case dw_val_class_wide_int:
size += (get_full_len (*a->dw_attr_val.v.val_wide)
* HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR);
if (get_full_len (*a->dw_attr_val.v.val_wide)
* HOST_BITS_PER_WIDE_INT > DWARF_LARGEST_DATA_FORM_BITS)
size++; /* block */
break;
case dw_val_class_vec:
size += constant_size (a->dw_attr_val.v.val_vec.length
* a->dw_attr_val.v.val_vec.elt_size)
+ a->dw_attr_val.v.val_vec.length
* a->dw_attr_val.v.val_vec.elt_size; /* block */
break;
case dw_val_class_flag:
if (dwarf_version >= 4)
/* Currently all add_AT_flag calls pass in 1 as last argument,
so DW_FORM_flag_present can be used. If that ever changes,
we'll need to use DW_FORM_flag and have some optimization
in build_abbrev_table that will change those to
DW_FORM_flag_present if it is set to 1 in all DIEs using
the same abbrev entry. */
gcc_assert (a->dw_attr_val.v.val_flag == 1);
else
size += 1;
break;
case dw_val_class_die_ref:
if (AT_ref_external (a))
{
/* In DWARF4, we use DW_FORM_ref_sig8; for earlier versions
we use DW_FORM_ref_addr. In DWARF2, DW_FORM_ref_addr
is sized by target address length, whereas in DWARF3
it's always sized as an offset. */
if (AT_ref (a)->comdat_type_p)
size += DWARF_TYPE_SIGNATURE_SIZE;
else if (dwarf_version == 2)
size += DWARF2_ADDR_SIZE;
else
size += DWARF_OFFSET_SIZE;
}
else
size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_fde_ref:
size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_lbl_id:
if (dwarf_split_debug_info && AT_index (a) != NOT_INDEXED)
{
gcc_assert (AT_index (a) != NO_INDEX_ASSIGNED);
size += size_of_uleb128 (AT_index (a));
}
else
size += DWARF2_ADDR_SIZE;
break;
case dw_val_class_lineptr:
case dw_val_class_macptr:
case dw_val_class_loclistsptr:
size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_str:
form = AT_string_form (a);
if (form == DW_FORM_strp || form == DW_FORM_line_strp)
size += DWARF_OFFSET_SIZE;
else if (form == dwarf_FORM (DW_FORM_strx))
size += size_of_uleb128 (AT_index (a));
else
size += strlen (a->dw_attr_val.v.val_str->str) + 1;
break;
case dw_val_class_file:
size += constant_size (maybe_emit_file (a->dw_attr_val.v.val_file));
break;
case dw_val_class_data8:
size += 8;
break;
case dw_val_class_vms_delta:
size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_high_pc:
size += DWARF2_ADDR_SIZE;
break;
case dw_val_class_discr_value:
size += size_of_discr_value (&a->dw_attr_val.v.val_discr_value);
break;
case dw_val_class_discr_list:
{
unsigned block_size = size_of_discr_list (AT_discr_list (a));
/* This is a block, so we have the block length and then its
data. */
size += constant_size (block_size) + block_size;
}
break;
default:
gcc_unreachable ();
}
}
return size;
}
/* Size the debugging information associated with a given DIE. Visits the
DIE's children recursively. Updates the global variable next_die_offset, on
each time through. Uses the current value of next_die_offset to update the
die_offset field in each DIE. */
static void
calc_die_sizes (dw_die_ref die)
{
dw_die_ref c;
gcc_assert (die->die_offset == 0
|| (unsigned long int) die->die_offset == next_die_offset);
die->die_offset = next_die_offset;
next_die_offset += size_of_die (die);
FOR_EACH_CHILD (die, c, calc_die_sizes (c));
if (die->die_child != NULL)
/* Count the null byte used to terminate sibling lists. */
next_die_offset += 1;
}
/* Size just the base type children at the start of the CU.
This is needed because build_abbrev needs to size locs
and sizing of type based stack ops needs to know die_offset
values for the base types. */
static void
calc_base_type_die_sizes (void)
{
unsigned long die_offset = (dwarf_split_debug_info
? DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE
: DWARF_COMPILE_UNIT_HEADER_SIZE);
unsigned int i;
dw_die_ref base_type;
#if ENABLE_ASSERT_CHECKING
dw_die_ref prev = comp_unit_die ()->die_child;
#endif
die_offset += size_of_die (comp_unit_die ());
for (i = 0; base_types.iterate (i, &base_type); i++)
{
#if ENABLE_ASSERT_CHECKING
gcc_assert (base_type->die_offset == 0
&& prev->die_sib == base_type
&& base_type->die_child == NULL
&& base_type->die_abbrev);
prev = base_type;
#endif
if (abbrev_opt_start
&& base_type->die_abbrev >= abbrev_opt_base_type_end)
abbrev_opt_base_type_end = base_type->die_abbrev + 1;
base_type->die_offset = die_offset;
die_offset += size_of_die (base_type);
}
}
/* Set the marks for a die and its children. We do this so
that we know whether or not a reference needs to use FORM_ref_addr; only
DIEs in the same CU will be marked. We used to clear out the offset
and use that as the flag, but ran into ordering problems. */
static void
mark_dies (dw_die_ref die)
{
dw_die_ref c;
gcc_assert (!die->die_mark);
die->die_mark = 1;
FOR_EACH_CHILD (die, c, mark_dies (c));
}
/* Clear the marks for a die and its children. */
static void
unmark_dies (dw_die_ref die)
{
dw_die_ref c;
if (! use_debug_types)
gcc_assert (die->die_mark);
die->die_mark = 0;
FOR_EACH_CHILD (die, c, unmark_dies (c));
}
/* Clear the marks for a die, its children and referred dies. */
static void
unmark_all_dies (dw_die_ref die)
{
dw_die_ref c;
dw_attr_node *a;
unsigned ix;
if (!die->die_mark)
return;
die->die_mark = 0;
FOR_EACH_CHILD (die, c, unmark_all_dies (c));
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (AT_class (a) == dw_val_class_die_ref)
unmark_all_dies (AT_ref (a));
}
/* Calculate if the entry should appear in the final output file. It may be
from a pruned a type. */
static bool
include_pubname_in_output (vec<pubname_entry, va_gc> *table, pubname_entry *p)
{
/* By limiting gnu pubnames to definitions only, gold can generate a
gdb index without entries for declarations, which don't include
enough information to be useful. */
if (debug_generate_pub_sections == 2 && is_declaration_die (p->die))
return false;
if (table == pubname_table)
{
/* Enumerator names are part of the pubname table, but the
parent DW_TAG_enumeration_type die may have been pruned.
Don't output them if that is the case. */
if (p->die->die_tag == DW_TAG_enumerator &&
(p->die->die_parent == NULL
|| !p->die->die_parent->die_perennial_p))
return false;
/* Everything else in the pubname table is included. */
return true;
}
/* The pubtypes table shouldn't include types that have been
pruned. */
return (p->die->die_offset != 0
|| !flag_eliminate_unused_debug_types);
}
/* Return the size of the .debug_pubnames or .debug_pubtypes table
generated for the compilation unit. */
static unsigned long
size_of_pubnames (vec<pubname_entry, va_gc> *names)
{
unsigned long size;
unsigned i;
pubname_entry *p;
int space_for_flags = (debug_generate_pub_sections == 2) ? 1 : 0;
size = DWARF_PUBNAMES_HEADER_SIZE;
FOR_EACH_VEC_ELT (*names, i, p)
if (include_pubname_in_output (names, p))
size += strlen (p->name) + DWARF_OFFSET_SIZE + 1 + space_for_flags;
size += DWARF_OFFSET_SIZE;
return size;
}
/* Return the size of the information in the .debug_aranges section. */
static unsigned long
size_of_aranges (void)
{
unsigned long size;
size = DWARF_ARANGES_HEADER_SIZE;
/* Count the address/length pair for this compilation unit. */
if (text_section_used)
size += 2 * DWARF2_ADDR_SIZE;
if (cold_text_section_used)
size += 2 * DWARF2_ADDR_SIZE;
if (have_multiple_function_sections)
{
unsigned fde_idx;
dw_fde_ref fde;
FOR_EACH_VEC_ELT (*fde_vec, fde_idx, fde)
{
if (DECL_IGNORED_P (fde->decl))
continue;
if (!fde->in_std_section)
size += 2 * DWARF2_ADDR_SIZE;
if (fde->dw_fde_second_begin && !fde->second_in_std_section)
size += 2 * DWARF2_ADDR_SIZE;
}
}
/* Count the two zero words used to terminated the address range table. */
size += 2 * DWARF2_ADDR_SIZE;
return size;
}
/* Select the encoding of an attribute value. */
static enum dwarf_form
value_format (dw_attr_node *a)
{
switch (AT_class (a))
{
case dw_val_class_addr:
/* Only very few attributes allow DW_FORM_addr. */
switch (a->dw_attr)
{
case DW_AT_low_pc:
case DW_AT_high_pc:
case DW_AT_entry_pc:
case DW_AT_trampoline:
return (AT_index (a) == NOT_INDEXED
? DW_FORM_addr : dwarf_FORM (DW_FORM_addrx));
default:
break;
}
switch (DWARF2_ADDR_SIZE)
{
case 1:
return DW_FORM_data1;
case 2:
return DW_FORM_data2;
case 4:
return DW_FORM_data4;
case 8:
return DW_FORM_data8;
default:
gcc_unreachable ();
}
case dw_val_class_loc_list:
if (dwarf_split_debug_info
&& dwarf_version >= 5
&& AT_loc_list (a)->num_assigned)
return DW_FORM_loclistx;
/* FALLTHRU */
case dw_val_class_view_list:
case dw_val_class_range_list:
/* For range lists in DWARF 5, use DW_FORM_rnglistx from .debug_info.dwo
but in .debug_info use DW_FORM_sec_offset, which is shorter if we
care about sizes of .debug* sections in shared libraries and
executables and don't take into account relocations that affect just
relocatable objects - for DW_FORM_rnglistx we'd have to emit offset
table in the .debug_rnglists section. */
if (dwarf_split_debug_info
&& dwarf_version >= 5
&& AT_class (a) == dw_val_class_range_list
&& rnglist_idx
&& a->dw_attr_val.val_entry != RELOCATED_OFFSET)
return DW_FORM_rnglistx;
if (dwarf_version >= 4)
return DW_FORM_sec_offset;
/* FALLTHRU */
case dw_val_class_vms_delta:
case dw_val_class_offset:
switch (DWARF_OFFSET_SIZE)
{
case 4:
return DW_FORM_data4;
case 8:
return DW_FORM_data8;
default:
gcc_unreachable ();
}
case dw_val_class_loc:
if (dwarf_version >= 4)
return DW_FORM_exprloc;
switch (constant_size (size_of_locs (AT_loc (a))))
{
case 1:
return DW_FORM_block1;
case 2:
return DW_FORM_block2;
case 4:
return DW_FORM_block4;
default:
gcc_unreachable ();
}
case dw_val_class_const:
return DW_FORM_sdata;
case dw_val_class_unsigned_const:
switch (constant_size (AT_unsigned (a)))
{
case 1:
return DW_FORM_data1;
case 2:
return DW_FORM_data2;
case 4:
/* In DWARF3 DW_AT_data_member_location with
DW_FORM_data4 or DW_FORM_data8 is a loclistptr, not
constant, so we need to use DW_FORM_udata if we need
a large constant. */
if (dwarf_version == 3 && a->dw_attr == DW_AT_data_member_location)
return DW_FORM_udata;
return DW_FORM_data4;
case 8:
if (dwarf_version == 3 && a->dw_attr == DW_AT_data_member_location)
return DW_FORM_udata;
return DW_FORM_data8;
default:
gcc_unreachable ();
}
case dw_val_class_const_implicit:
case dw_val_class_unsigned_const_implicit:
case dw_val_class_file_implicit:
return DW_FORM_implicit_const;
case dw_val_class_const_double:
switch (HOST_BITS_PER_WIDE_INT)
{
case 8:
return DW_FORM_data2;
case 16:
return DW_FORM_data4;
case 32:
return DW_FORM_data8;
case 64:
if (dwarf_version >= 5)
return DW_FORM_data16;
/* FALLTHRU */
default:
return DW_FORM_block1;
}
case dw_val_class_wide_int:
switch (get_full_len (*a->dw_attr_val.v.val_wide) * HOST_BITS_PER_WIDE_INT)
{
case 8:
return DW_FORM_data1;
case 16:
return DW_FORM_data2;
case 32:
return DW_FORM_data4;
case 64:
return DW_FORM_data8;
case 128:
if (dwarf_version >= 5)
return DW_FORM_data16;
/* FALLTHRU */
default:
return DW_FORM_block1;
}
case dw_val_class_symview:
/* ??? We might use uleb128, but then we'd have to compute
.debug_info offsets in the assembler. */
if (symview_upper_bound <= 0xff)
return DW_FORM_data1;
else if (symview_upper_bound <= 0xffff)
return DW_FORM_data2;
else if (symview_upper_bound <= 0xffffffff)
return DW_FORM_data4;
else
return DW_FORM_data8;
case dw_val_class_vec:
switch (constant_size (a->dw_attr_val.v.val_vec.length
* a->dw_attr_val.v.val_vec.elt_size))
{
case 1:
return DW_FORM_block1;
case 2:
return DW_FORM_block2;
case 4:
return DW_FORM_block4;
default:
gcc_unreachable ();
}
case dw_val_class_flag:
if (dwarf_version >= 4)
{
/* Currently all add_AT_flag calls pass in 1 as last argument,
so DW_FORM_flag_present can be used. If that ever changes,
we'll need to use DW_FORM_flag and have some optimization
in build_abbrev_table that will change those to
DW_FORM_flag_present if it is set to 1 in all DIEs using
the same abbrev entry. */
gcc_assert (a->dw_attr_val.v.val_flag == 1);
return DW_FORM_flag_present;
}
return DW_FORM_flag;
case dw_val_class_die_ref:
if (AT_ref_external (a))
{
if (AT_ref (a)->comdat_type_p)
return DW_FORM_ref_sig8;
else
return DW_FORM_ref_addr;
}
else
return DW_FORM_ref;
case dw_val_class_fde_ref:
return DW_FORM_data;
case dw_val_class_lbl_id:
return (AT_index (a) == NOT_INDEXED
? DW_FORM_addr : dwarf_FORM (DW_FORM_addrx));
case dw_val_class_lineptr:
case dw_val_class_macptr:
case dw_val_class_loclistsptr:
return dwarf_version >= 4 ? DW_FORM_sec_offset : DW_FORM_data;
case dw_val_class_str:
return AT_string_form (a);
case dw_val_class_file:
switch (constant_size (maybe_emit_file (a->dw_attr_val.v.val_file)))
{
case 1:
return DW_FORM_data1;
case 2:
return DW_FORM_data2;
case 4:
return DW_FORM_data4;
default:
gcc_unreachable ();
}
case dw_val_class_data8:
return DW_FORM_data8;
case dw_val_class_high_pc:
switch (DWARF2_ADDR_SIZE)
{
case 1:
return DW_FORM_data1;
case 2:
return DW_FORM_data2;
case 4:
return DW_FORM_data4;
case 8:
return DW_FORM_data8;
default:
gcc_unreachable ();
}
case dw_val_class_discr_value:
return (a->dw_attr_val.v.val_discr_value.pos
? DW_FORM_udata
: DW_FORM_sdata);
case dw_val_class_discr_list:
switch (constant_size (size_of_discr_list (AT_discr_list (a))))
{
case 1:
return DW_FORM_block1;
case 2:
return DW_FORM_block2;
case 4:
return DW_FORM_block4;
default:
gcc_unreachable ();
}
default:
gcc_unreachable ();
}
}
/* Output the encoding of an attribute value. */
static void
output_value_format (dw_attr_node *a)
{
enum dwarf_form form = value_format (a);
dw2_asm_output_data_uleb128 (form, "(%s)", dwarf_form_name (form));
}
/* Given a die and id, produce the appropriate abbreviations. */
static void
output_die_abbrevs (unsigned long abbrev_id, dw_die_ref abbrev)
{
unsigned ix;
dw_attr_node *a_attr;
dw2_asm_output_data_uleb128 (abbrev_id, "(abbrev code)");
dw2_asm_output_data_uleb128 (abbrev->die_tag, "(TAG: %s)",
dwarf_tag_name (abbrev->die_tag));
if (abbrev->die_child != NULL)
dw2_asm_output_data (1, DW_children_yes, "DW_children_yes");
else
dw2_asm_output_data (1, DW_children_no, "DW_children_no");
for (ix = 0; vec_safe_iterate (abbrev->die_attr, ix, &a_attr); ix++)
{
dw2_asm_output_data_uleb128 (a_attr->dw_attr, "(%s)",
dwarf_attr_name (a_attr->dw_attr));
output_value_format (a_attr);
if (value_format (a_attr) == DW_FORM_implicit_const)
{
if (AT_class (a_attr) == dw_val_class_file_implicit)
{
int f = maybe_emit_file (a_attr->dw_attr_val.v.val_file);
const char *filename = a_attr->dw_attr_val.v.val_file->filename;
dw2_asm_output_data_sleb128 (f, "(%s)", filename);
}
else
dw2_asm_output_data_sleb128 (a_attr->dw_attr_val.v.val_int, NULL);
}
}
dw2_asm_output_data (1, 0, NULL);
dw2_asm_output_data (1, 0, NULL);
}
/* Output the .debug_abbrev section which defines the DIE abbreviation
table. */
static void
output_abbrev_section (void)
{
unsigned int abbrev_id;
dw_die_ref abbrev;
FOR_EACH_VEC_SAFE_ELT (abbrev_die_table, abbrev_id, abbrev)
if (abbrev_id != 0)
output_die_abbrevs (abbrev_id, abbrev);
/* Terminate the table. */
dw2_asm_output_data (1, 0, NULL);
}
/* Return a new location list, given the begin and end range, and the
expression. */
static inline dw_loc_list_ref
new_loc_list (dw_loc_descr_ref expr, const char *begin, var_loc_view vbegin,
const char *end, var_loc_view vend,
const char *section)
{
dw_loc_list_ref retlist = ggc_cleared_alloc<dw_loc_list_node> ();
retlist->begin = begin;
retlist->begin_entry = NULL;
retlist->end = end;
retlist->expr = expr;
retlist->section = section;
retlist->vbegin = vbegin;
retlist->vend = vend;
return retlist;
}
/* Return true iff there's any nonzero view number in the loc list.
??? When views are not enabled, we'll often extend a single range
to the entire function, so that we emit a single location
expression rather than a location list. With views, even with a
single range, we'll output a list if start or end have a nonzero
view. If we change this, we may want to stop splitting a single
range in dw_loc_list just because of a nonzero view, even if it
straddles across hot/cold partitions. */
static bool
loc_list_has_views (dw_loc_list_ref list)
{
if (!debug_variable_location_views)
return false;
for (dw_loc_list_ref loc = list;
loc != NULL; loc = loc->dw_loc_next)
if (!ZERO_VIEW_P (loc->vbegin) || !ZERO_VIEW_P (loc->vend))
return true;
return false;
}
/* Generate a new internal symbol for this location list node, if it
hasn't got one yet. */
static inline void
gen_llsym (dw_loc_list_ref list)
{
gcc_assert (!list->ll_symbol);
list->ll_symbol = gen_internal_sym ("LLST");
if (!loc_list_has_views (list))
return;
if (dwarf2out_locviews_in_attribute ())
{
/* Use the same label_num for the view list. */
label_num--;
list->vl_symbol = gen_internal_sym ("LVUS");
}
else
list->vl_symbol = list->ll_symbol;
}
/* Generate a symbol for the list, but only if we really want to emit
it as a list. */
static inline void
maybe_gen_llsym (dw_loc_list_ref list)
{
if (!list || (!list->dw_loc_next && !loc_list_has_views (list)))
return;
gen_llsym (list);
}
/* Determine whether or not to skip loc_list entry CURR. If SIZEP is
NULL, don't consider size of the location expression. If we're not
to skip it, and SIZEP is non-null, store the size of CURR->expr's
representation in *SIZEP. */
static bool
skip_loc_list_entry (dw_loc_list_ref curr, unsigned long *sizep = NULL)
{
/* Don't output an entry that starts and ends at the same address. */
if (strcmp (curr->begin, curr->end) == 0
&& curr->vbegin == curr->vend && !curr->force)
return true;
if (!sizep)
return false;
unsigned long size = size_of_locs (curr->expr);
/* If the expression is too large, drop it on the floor. We could
perhaps put it into DW_TAG_dwarf_procedure and refer to that
in the expression, but >= 64KB expressions for a single value
in a single range are unlikely very useful. */
if (dwarf_version < 5 && size > 0xffff)
return true;
*sizep = size;
return false;
}
/* Output a view pair loclist entry for CURR, if it requires one. */
static void
dwarf2out_maybe_output_loclist_view_pair (dw_loc_list_ref curr)
{
if (!dwarf2out_locviews_in_loclist ())
return;
if (ZERO_VIEW_P (curr->vbegin) && ZERO_VIEW_P (curr->vend))
return;
#ifdef DW_LLE_view_pair
dw2_asm_output_data (1, DW_LLE_view_pair, "DW_LLE_view_pair");
if (dwarf2out_as_locview_support)
{
if (ZERO_VIEW_P (curr->vbegin))
dw2_asm_output_data_uleb128 (0, "Location view begin");
else
{
char label[MAX_ARTIFICIAL_LABEL_BYTES];
ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vbegin);
dw2_asm_output_symname_uleb128 (label, "Location view begin");
}
if (ZERO_VIEW_P (curr->vend))
dw2_asm_output_data_uleb128 (0, "Location view end");
else
{
char label[MAX_ARTIFICIAL_LABEL_BYTES];
ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vend);
dw2_asm_output_symname_uleb128 (label, "Location view end");
}
}
else
{
dw2_asm_output_data_uleb128 (curr->vbegin, "Location view begin");
dw2_asm_output_data_uleb128 (curr->vend, "Location view end");
}
#endif /* DW_LLE_view_pair */
return;
}
/* Output the location list given to us. */
static void
output_loc_list (dw_loc_list_ref list_head)
{
int vcount = 0, lcount = 0;
if (list_head->emitted)
return;
list_head->emitted = true;
if (list_head->vl_symbol && dwarf2out_locviews_in_attribute ())
{
ASM_OUTPUT_LABEL (asm_out_file, list_head->vl_symbol);
for (dw_loc_list_ref curr = list_head; curr != NULL;
curr = curr->dw_loc_next)
{
unsigned long size;
if (skip_loc_list_entry (curr, &size))
continue;
vcount++;
/* ?? dwarf_split_debug_info? */
if (dwarf2out_as_locview_support)
{
char label[MAX_ARTIFICIAL_LABEL_BYTES];
if (!ZERO_VIEW_P (curr->vbegin))
{
ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vbegin);
dw2_asm_output_symname_uleb128 (label,
"View list begin (%s)",
list_head->vl_symbol);
}
else
dw2_asm_output_data_uleb128 (0,
"View list begin (%s)",
list_head->vl_symbol);
if (!ZERO_VIEW_P (curr->vend))
{
ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vend);
dw2_asm_output_symname_uleb128 (label,
"View list end (%s)",
list_head->vl_symbol);
}
else
dw2_asm_output_data_uleb128 (0,
"View list end (%s)",
list_head->vl_symbol);
}
else
{
dw2_asm_output_data_uleb128 (curr->vbegin,
"View list begin (%s)",
list_head->vl_symbol);
dw2_asm_output_data_uleb128 (curr->vend,
"View list end (%s)",
list_head->vl_symbol);
}
}
}
ASM_OUTPUT_LABEL (asm_out_file, list_head->ll_symbol);
const char *last_section = NULL;
const char *base_label = NULL;
/* Walk the location list, and output each range + expression. */
for (dw_loc_list_ref curr = list_head; curr != NULL;
curr = curr->dw_loc_next)
{
unsigned long size;
/* Skip this entry? If we skip it here, we must skip it in the
view list above as well. */
if (skip_loc_list_entry (curr, &size))
continue;
lcount++;
if (dwarf_version >= 5)
{
if (dwarf_split_debug_info)
{
dwarf2out_maybe_output_loclist_view_pair (curr);
/* For -gsplit-dwarf, emit DW_LLE_starx_length, which has
uleb128 index into .debug_addr and uleb128 length. */
dw2_asm_output_data (1, DW_LLE_startx_length,
"DW_LLE_startx_length (%s)",
list_head->ll_symbol);
dw2_asm_output_data_uleb128 (curr->begin_entry->index,
"Location list range start index "
"(%s)", curr->begin);
/* FIXME: This will ICE ifndef HAVE_AS_LEB128.
For that case we probably need to emit DW_LLE_startx_endx,
but we'd need 2 .debug_addr entries rather than just one. */
dw2_asm_output_delta_uleb128 (curr->end, curr->begin,
"Location list length (%s)",
list_head->ll_symbol);
}
else if (!have_multiple_function_sections && HAVE_AS_LEB128)
{
dwarf2out_maybe_output_loclist_view_pair (curr);
/* If all code is in .text section, the base address is
already provided by the CU attributes. Use
DW_LLE_offset_pair where both addresses are uleb128 encoded
offsets against that base. */
dw2_asm_output_data (1, DW_LLE_offset_pair,
"DW_LLE_offset_pair (%s)",
list_head->ll_symbol);
dw2_asm_output_delta_uleb128 (curr->begin, curr->section,
"Location list begin address (%s)",
list_head->ll_symbol);
dw2_asm_output_delta_uleb128 (curr->end, curr->section,
"Location list end address (%s)",
list_head->ll_symbol);
}
else if (HAVE_AS_LEB128)
{
/* Otherwise, find out how many consecutive entries could share
the same base entry. If just one, emit DW_LLE_start_length,
otherwise emit DW_LLE_base_address for the base address
followed by a series of DW_LLE_offset_pair. */
if (last_section == NULL || curr->section != last_section)
{
dw_loc_list_ref curr2;
for (curr2 = curr->dw_loc_next; curr2 != NULL;
curr2 = curr2->dw_loc_next)
{
if (strcmp (curr2->begin, curr2->end) == 0
&& !curr2->force)
continue;
break;
}
if (curr2 == NULL || curr->section != curr2->section)
last_section = NULL;
else
{
last_section = curr->section;
base_label = curr->begin;
dw2_asm_output_data (1, DW_LLE_base_address,
"DW_LLE_base_address (%s)",
list_head->ll_symbol);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, base_label,
"Base address (%s)",
list_head->ll_symbol);
}
}
/* Only one entry with the same base address. Use
DW_LLE_start_length with absolute address and uleb128
length. */
if (last_section == NULL)
{
dwarf2out_maybe_output_loclist_view_pair (curr);
dw2_asm_output_data (1, DW_LLE_start_length,
"DW_LLE_start_length (%s)",
list_head->ll_symbol);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, curr->begin,
"Location list begin address (%s)",
list_head->ll_symbol);
dw2_asm_output_delta_uleb128 (curr->end, curr->begin,
"Location list length "
"(%s)", list_head->ll_symbol);
}
/* Otherwise emit DW_LLE_offset_pair, relative to above emitted
DW_LLE_base_address. */
else
{
dwarf2out_maybe_output_loclist_view_pair (curr);
dw2_asm_output_data (1, DW_LLE_offset_pair,
"DW_LLE_offset_pair (%s)",
list_head->ll_symbol);
dw2_asm_output_delta_uleb128 (curr->begin, base_label,
"Location list begin address "
"(%s)", list_head->ll_symbol);
dw2_asm_output_delta_uleb128 (curr->end, base_label,
"Location list end address "
"(%s)", list_head->ll_symbol);
}
}
/* The assembler does not support .uleb128 directive. Emit
DW_LLE_start_end with a pair of absolute addresses. */
else
{
dwarf2out_maybe_output_loclist_view_pair (curr);
dw2_asm_output_data (1, DW_LLE_start_end,
"DW_LLE_start_end (%s)",
list_head->ll_symbol);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, curr->begin,
"Location list begin address (%s)",
list_head->ll_symbol);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, curr->end,
"Location list end address (%s)",
list_head->ll_symbol);
}
}
else if (dwarf_split_debug_info)
{
/* For -gsplit-dwarf -gdwarf-{2,3,4} emit index into .debug_addr
and 4 byte length. */
dw2_asm_output_data (1, DW_LLE_GNU_start_length_entry,
"Location list start/length entry (%s)",
list_head->ll_symbol);
dw2_asm_output_data_uleb128 (curr->begin_entry->index,
"Location list range start index (%s)",
curr->begin);
/* The length field is 4 bytes. If we ever need to support
an 8-byte length, we can add a new DW_LLE code or fall back
to DW_LLE_GNU_start_end_entry. */
dw2_asm_output_delta (4, curr->end, curr->begin,
"Location list range length (%s)",
list_head->ll_symbol);
}
else if (!have_multiple_function_sections)
{
/* Pair of relative addresses against start of text section. */
dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->begin, curr->section,
"Location list begin address (%s)",
list_head->ll_symbol);
dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->end, curr->section,
"Location list end address (%s)",
list_head->ll_symbol);
}
else
{
/* Pair of absolute addresses. */
dw2_asm_output_addr (DWARF2_ADDR_SIZE, curr->begin,
"Location list begin address (%s)",
list_head->ll_symbol);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, curr->end,
"Location list end address (%s)",
list_head->ll_symbol);
}
/* Output the block length for this list of location operations. */
if (dwarf_version >= 5)
dw2_asm_output_data_uleb128 (size, "Location expression size");
else
{
gcc_assert (size <= 0xffff);
dw2_asm_output_data (2, size, "Location expression size");
}
output_loc_sequence (curr->expr, -1);
}
/* And finally list termination. */
if (dwarf_version >= 5)
dw2_asm_output_data (1, DW_LLE_end_of_list,
"DW_LLE_end_of_list (%s)", list_head->ll_symbol);
else if (dwarf_split_debug_info)
dw2_asm_output_data (1, DW_LLE_GNU_end_of_list_entry,
"Location list terminator (%s)",
list_head->ll_symbol);
else
{
dw2_asm_output_data (DWARF2_ADDR_SIZE, 0,
"Location list terminator begin (%s)",
list_head->ll_symbol);
dw2_asm_output_data (DWARF2_ADDR_SIZE, 0,
"Location list terminator end (%s)",
list_head->ll_symbol);
}
gcc_assert (!list_head->vl_symbol
|| vcount == lcount * (dwarf2out_locviews_in_attribute () ? 1 : 0));
}
/* Output a range_list offset into the .debug_ranges or .debug_rnglists
section. Emit a relocated reference if val_entry is NULL, otherwise,
emit an indirect reference. */
static void
output_range_list_offset (dw_attr_node *a)
{
const char *name = dwarf_attr_name (a->dw_attr);
if (a->dw_attr_val.val_entry == RELOCATED_OFFSET)
{
if (dwarf_version >= 5)
{
dw_ranges *r = &(*ranges_table)[a->dw_attr_val.v.val_offset];
dw2_asm_output_offset (DWARF_OFFSET_SIZE, r->label,
debug_ranges_section, "%s", name);
}
else
{
char *p = strchr (ranges_section_label, '\0');
sprintf (p, "+" HOST_WIDE_INT_PRINT_HEX,
a->dw_attr_val.v.val_offset * 2 * DWARF2_ADDR_SIZE);
dw2_asm_output_offset (DWARF_OFFSET_SIZE, ranges_section_label,
debug_ranges_section, "%s", name);
*p = '\0';
}
}
else if (dwarf_version >= 5)
{
dw_ranges *r = &(*ranges_table)[a->dw_attr_val.v.val_offset];
gcc_assert (rnglist_idx);
dw2_asm_output_data_uleb128 (r->idx, "%s", name);
}
else
dw2_asm_output_data (DWARF_OFFSET_SIZE,
a->dw_attr_val.v.val_offset * 2 * DWARF2_ADDR_SIZE,
"%s (offset from %s)", name, ranges_section_label);
}
/* Output the offset into the debug_loc section. */
static void
output_loc_list_offset (dw_attr_node *a)
{
char *sym = AT_loc_list (a)->ll_symbol;
gcc_assert (sym);
if (!dwarf_split_debug_info)
dw2_asm_output_offset (DWARF_OFFSET_SIZE, sym, debug_loc_section,
"%s", dwarf_attr_name (a->dw_attr));
else if (dwarf_version >= 5)
{
gcc_assert (AT_loc_list (a)->num_assigned);
dw2_asm_output_data_uleb128 (AT_loc_list (a)->hash, "%s (%s)",
dwarf_attr_name (a->dw_attr),
sym);
}
else
dw2_asm_output_delta (DWARF_OFFSET_SIZE, sym, loc_section_label,
"%s", dwarf_attr_name (a->dw_attr));
}
/* Output the offset into the debug_loc section. */
static void
output_view_list_offset (dw_attr_node *a)
{
char *sym = (*AT_loc_list_ptr (a))->vl_symbol;
gcc_assert (sym);
if (dwarf_split_debug_info)
dw2_asm_output_delta (DWARF_OFFSET_SIZE, sym, loc_section_label,
"%s", dwarf_attr_name (a->dw_attr));
else
dw2_asm_output_offset (DWARF_OFFSET_SIZE, sym, debug_loc_section,
"%s", dwarf_attr_name (a->dw_attr));
}
/* Output an attribute's index or value appropriately. */
static void
output_attr_index_or_value (dw_attr_node *a)
{
const char *name = dwarf_attr_name (a->dw_attr);
if (dwarf_split_debug_info && AT_index (a) != NOT_INDEXED)
{
dw2_asm_output_data_uleb128 (AT_index (a), "%s", name);
return;
}
switch (AT_class (a))
{
case dw_val_class_addr:
dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, AT_addr (a), "%s", name);
break;
case dw_val_class_high_pc:
case dw_val_class_lbl_id:
dw2_asm_output_addr (DWARF2_ADDR_SIZE, AT_lbl (a), "%s", name);
break;
default:
gcc_unreachable ();
}
}
/* Output a type signature. */
static inline void
output_signature (const char *sig, const char *name)
{
int i;
for (i = 0; i < DWARF_TYPE_SIGNATURE_SIZE; i++)
dw2_asm_output_data (1, sig[i], i == 0 ? "%s" : NULL, name);
}
/* Output a discriminant value. */
static inline void
output_discr_value (dw_discr_value *discr_value, const char *name)
{
if (discr_value->pos)
dw2_asm_output_data_uleb128 (discr_value->v.uval, "%s", name);
else
dw2_asm_output_data_sleb128 (discr_value->v.sval, "%s", name);
}
/* Output the DIE and its attributes. Called recursively to generate
the definitions of each child DIE. */
static void
output_die (dw_die_ref die)
{
dw_attr_node *a;
dw_die_ref c;
unsigned long size;
unsigned ix;
dw2_asm_output_data_uleb128 (die->die_abbrev, "(DIE (%#lx) %s)",
(unsigned long)die->die_offset,
dwarf_tag_name (die->die_tag));
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
{
const char *name = dwarf_attr_name (a->dw_attr);
switch (AT_class (a))
{
case dw_val_class_addr:
output_attr_index_or_value (a);
break;
case dw_val_class_offset:
dw2_asm_output_data (DWARF_OFFSET_SIZE, a->dw_attr_val.v.val_offset,
"%s", name);
break;
case dw_val_class_range_list:
output_range_list_offset (a);
break;
case dw_val_class_loc:
size = size_of_locs (AT_loc (a));
/* Output the block length for this list of location operations. */
if (dwarf_version >= 4)
dw2_asm_output_data_uleb128 (size, "%s", name);
else
dw2_asm_output_data (constant_size (size), size, "%s", name);
output_loc_sequence (AT_loc (a), -1);
break;
case dw_val_class_const:
/* ??? It would be slightly more efficient to use a scheme like is
used for unsigned constants below, but gdb 4.x does not sign
extend. Gdb 5.x does sign extend. */
dw2_asm_output_data_sleb128 (AT_int (a), "%s", name);
break;
case dw_val_class_unsigned_const:
{
int csize = constant_size (AT_unsigned (a));
if (dwarf_version == 3
&& a->dw_attr == DW_AT_data_member_location
&& csize >= 4)
dw2_asm_output_data_uleb128 (AT_unsigned (a), "%s", name);
else
dw2_asm_output_data (csize, AT_unsigned (a), "%s", name);
}
break;
case dw_val_class_symview:
{
int vsize;
if (symview_upper_bound <= 0xff)
vsize = 1;
else if (symview_upper_bound <= 0xffff)
vsize = 2;
else if (symview_upper_bound <= 0xffffffff)
vsize = 4;
else
vsize = 8;
dw2_asm_output_addr (vsize, a->dw_attr_val.v.val_symbolic_view,
"%s", name);
}
break;
case dw_val_class_const_implicit:
if (flag_debug_asm)
fprintf (asm_out_file, "\t\t\t%s %s ("
HOST_WIDE_INT_PRINT_DEC ")\n",
ASM_COMMENT_START, name, AT_int (a));
break;
case dw_val_class_unsigned_const_implicit:
if (flag_debug_asm)
fprintf (asm_out_file, "\t\t\t%s %s ("
HOST_WIDE_INT_PRINT_HEX ")\n",
ASM_COMMENT_START, name, AT_unsigned (a));
break;
case dw_val_class_const_double:
{
unsigned HOST_WIDE_INT first, second;
if (HOST_BITS_PER_WIDE_INT >= DWARF_LARGEST_DATA_FORM_BITS)
dw2_asm_output_data (1,
HOST_BITS_PER_DOUBLE_INT
/ HOST_BITS_PER_CHAR,
NULL);
if (WORDS_BIG_ENDIAN)
{
first = a->dw_attr_val.v.val_double.high;
second = a->dw_attr_val.v.val_double.low;
}
else
{
first = a->dw_attr_val.v.val_double.low;
second = a->dw_attr_val.v.val_double.high;
}
dw2_asm_output_data (HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR,
first, "%s", name);
dw2_asm_output_data (HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR,
second, NULL);
}
break;
case dw_val_class_wide_int:
{
int i;
int len = get_full_len (*a->dw_attr_val.v.val_wide);
int l = HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR;
if (len * HOST_BITS_PER_WIDE_INT > DWARF_LARGEST_DATA_FORM_BITS)
dw2_asm_output_data (1, get_full_len (*a->dw_attr_val.v.val_wide)
* l, NULL);
if (WORDS_BIG_ENDIAN)
for (i = len - 1; i >= 0; --i)
{
dw2_asm_output_data (l, a->dw_attr_val.v.val_wide->elt (i),
"%s", name);
name = "";
}
else
for (i = 0; i < len; ++i)
{
dw2_asm_output_data (l, a->dw_attr_val.v.val_wide->elt (i),
"%s", name);
name = "";
}
}
break;
case dw_val_class_vec:
{
unsigned int elt_size = a->dw_attr_val.v.val_vec.elt_size;
unsigned int len = a->dw_attr_val.v.val_vec.length;
unsigned int i;
unsigned char *p;
dw2_asm_output_data (constant_size (len * elt_size),
len * elt_size, "%s", name);
if (elt_size > sizeof (HOST_WIDE_INT))
{
elt_size /= 2;
len *= 2;
}
for (i = 0, p = (unsigned char *) a->dw_attr_val.v.val_vec.array;
i < len;
i++, p += elt_size)
dw2_asm_output_data (elt_size, extract_int (p, elt_size),
"fp or vector constant word %u", i);
break;
}
case dw_val_class_flag:
if (dwarf_version >= 4)
{
/* Currently all add_AT_flag calls pass in 1 as last argument,
so DW_FORM_flag_present can be used. If that ever changes,
we'll need to use DW_FORM_flag and have some optimization
in build_abbrev_table that will change those to
DW_FORM_flag_present if it is set to 1 in all DIEs using
the same abbrev entry. */
gcc_assert (AT_flag (a) == 1);
if (flag_debug_asm)
fprintf (asm_out_file, "\t\t\t%s %s\n",
ASM_COMMENT_START, name);
break;
}
dw2_asm_output_data (1, AT_flag (a), "%s", name);
break;
case dw_val_class_loc_list:
output_loc_list_offset (a);
break;
case dw_val_class_view_list:
output_view_list_offset (a);
break;
case dw_val_class_die_ref:
if (AT_ref_external (a))
{
if (AT_ref (a)->comdat_type_p)
{
comdat_type_node *type_node
= AT_ref (a)->die_id.die_type_node;
gcc_assert (type_node);
output_signature (type_node->signature, name);
}
else
{
const char *sym = AT_ref (a)->die_id.die_symbol;
int size;
gcc_assert (sym);
/* In DWARF2, DW_FORM_ref_addr is sized by target address
length, whereas in DWARF3 it's always sized as an
offset. */
if (dwarf_version == 2)
size = DWARF2_ADDR_SIZE;
else
size = DWARF_OFFSET_SIZE;
/* ??? We cannot unconditionally output die_offset if
non-zero - others might create references to those
DIEs via symbols.
And we do not clear its DIE offset after outputting it
(and the label refers to the actual DIEs, not the
DWARF CU unit header which is when using label + offset
would be the correct thing to do).
??? This is the reason for the with_offset flag. */
if (AT_ref (a)->with_offset)
dw2_asm_output_offset (size, sym, AT_ref (a)->die_offset,
debug_info_section, "%s", name);
else
dw2_asm_output_offset (size, sym, debug_info_section, "%s",
name);
}
}
else
{
gcc_assert (AT_ref (a)->die_offset);
dw2_asm_output_data (DWARF_OFFSET_SIZE, AT_ref (a)->die_offset,
"%s", name);
}
break;
case dw_val_class_fde_ref:
{
char l1[MAX_ARTIFICIAL_LABEL_BYTES];
ASM_GENERATE_INTERNAL_LABEL (l1, FDE_LABEL,
a->dw_attr_val.v.val_fde_index * 2);
dw2_asm_output_offset (DWARF_OFFSET_SIZE, l1, debug_frame_section,
"%s", name);
}
break;
case dw_val_class_vms_delta:
#ifdef ASM_OUTPUT_DWARF_VMS_DELTA
dw2_asm_output_vms_delta (DWARF_OFFSET_SIZE,
AT_vms_delta2 (a), AT_vms_delta1 (a),
"%s", name);
#else
dw2_asm_output_delta (DWARF_OFFSET_SIZE,
AT_vms_delta2 (a), AT_vms_delta1 (a),
"%s", name);
#endif
break;
case dw_val_class_lbl_id:
output_attr_index_or_value (a);
break;
case dw_val_class_lineptr:
dw2_asm_output_offset (DWARF_OFFSET_SIZE, AT_lbl (a),
debug_line_section, "%s", name);
break;
case dw_val_class_macptr:
dw2_asm_output_offset (DWARF_OFFSET_SIZE, AT_lbl (a),
debug_macinfo_section, "%s", name);
break;
case dw_val_class_loclistsptr:
dw2_asm_output_offset (DWARF_OFFSET_SIZE, AT_lbl (a),
debug_loc_section, "%s", name);
break;
case dw_val_class_str:
if (a->dw_attr_val.v.val_str->form == DW_FORM_strp)
dw2_asm_output_offset (DWARF_OFFSET_SIZE,
a->dw_attr_val.v.val_str->label,
debug_str_section,
"%s: \"%s\"", name, AT_string (a));
else if (a->dw_attr_val.v.val_str->form == DW_FORM_line_strp)
dw2_asm_output_offset (DWARF_OFFSET_SIZE,
a->dw_attr_val.v.val_str->label,
debug_line_str_section,
"%s: \"%s\"", name, AT_string (a));
else if (a->dw_attr_val.v.val_str->form == dwarf_FORM (DW_FORM_strx))
dw2_asm_output_data_uleb128 (AT_index (a),
"%s: \"%s\"", name, AT_string (a));
else
dw2_asm_output_nstring (AT_string (a), -1, "%s", name);
break;
case dw_val_class_file:
{
int f = maybe_emit_file (a->dw_attr_val.v.val_file);
dw2_asm_output_data (constant_size (f), f, "%s (%s)", name,
a->dw_attr_val.v.val_file->filename);
break;
}
case dw_val_class_file_implicit:
if (flag_debug_asm)
fprintf (asm_out_file, "\t\t\t%s %s (%d, %s)\n",
ASM_COMMENT_START, name,
maybe_emit_file (a->dw_attr_val.v.val_file),
a->dw_attr_val.v.val_file->filename);
break;
case dw_val_class_data8:
{
int i;
for (i = 0; i < 8; i++)
dw2_asm_output_data (1, a->dw_attr_val.v.val_data8[i],
i == 0 ? "%s" : NULL, name);
break;
}
case dw_val_class_high_pc:
dw2_asm_output_delta (DWARF2_ADDR_SIZE, AT_lbl (a),
get_AT_low_pc (die), "DW_AT_high_pc");
break;
case dw_val_class_discr_value:
output_discr_value (&a->dw_attr_val.v.val_discr_value, name);
break;
case dw_val_class_discr_list:
{
dw_discr_list_ref list = AT_discr_list (a);
const int size = size_of_discr_list (list);
/* This is a block, so output its length first. */
dw2_asm_output_data (constant_size (size), size,
"%s: block size", name);
for (; list != NULL; list = list->dw_discr_next)
{
/* One byte for the discriminant value descriptor, and then as
many LEB128 numbers as required. */
if (list->dw_discr_range)
dw2_asm_output_data (1, DW_DSC_range,
"%s: DW_DSC_range", name);
else
dw2_asm_output_data (1, DW_DSC_label,
"%s: DW_DSC_label", name);
output_discr_value (&list->dw_discr_lower_bound, name);
if (list->dw_discr_range)
output_discr_value (&list->dw_discr_upper_bound, name);
}
break;
}
default:
gcc_unreachable ();
}
}
FOR_EACH_CHILD (die, c, output_die (c));
/* Add null byte to terminate sibling list. */
if (die->die_child != NULL)
dw2_asm_output_data (1, 0, "end of children of DIE %#lx",
(unsigned long) die->die_offset);
}
/* Output the dwarf version number. */
static void
output_dwarf_version ()
{
/* ??? For now, if -gdwarf-6 is specified, we output version 5 with
views in loclist. That will change eventually. */
if (dwarf_version == 6)
{
static bool once;
if (!once)
{
warning (0, "%<-gdwarf-6%> is output as version 5 with "
"incompatibilities");
once = true;
}
dw2_asm_output_data (2, 5, "DWARF version number");
}
else
dw2_asm_output_data (2, dwarf_version, "DWARF version number");
}
/* Output the compilation unit that appears at the beginning of the
.debug_info section, and precedes the DIE descriptions. */
static void
output_compilation_unit_header (enum dwarf_unit_type ut)
{
if (!XCOFF_DEBUGGING_INFO)
{
if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
dw2_asm_output_data (4, 0xffffffff,
"Initial length escape value indicating 64-bit DWARF extension");
dw2_asm_output_data (DWARF_OFFSET_SIZE,
next_die_offset - DWARF_INITIAL_LENGTH_SIZE,
"Length of Compilation Unit Info");
}
output_dwarf_version ();
if (dwarf_version >= 5)
{
const char *name;
switch (ut)
{
case DW_UT_compile: name = "DW_UT_compile"; break;
case DW_UT_type: name = "DW_UT_type"; break;
case DW_UT_split_compile: name = "DW_UT_split_compile"; break;
case DW_UT_split_type: name = "DW_UT_split_type"; break;
default: gcc_unreachable ();
}
dw2_asm_output_data (1, ut, "%s", name);
dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)");
}
dw2_asm_output_offset (DWARF_OFFSET_SIZE, abbrev_section_label,
debug_abbrev_section,
"Offset Into Abbrev. Section");
if (dwarf_version < 5)
dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)");
}
/* Output the compilation unit DIE and its children. */
static void
output_comp_unit (dw_die_ref die, int output_if_empty,
const unsigned char *dwo_id)
{
const char *secname, *oldsym;
char *tmp;
/* Unless we are outputting main CU, we may throw away empty ones. */
if (!output_if_empty && die->die_child == NULL)
return;
/* Even if there are no children of this DIE, we must output the information
about the compilation unit. Otherwise, on an empty translation unit, we
will generate a present, but empty, .debug_info section. IRIX 6.5 `nm'
will then complain when examining the file. First mark all the DIEs in
this CU so we know which get local refs. */
mark_dies (die);
external_ref_hash_type *extern_map = optimize_external_refs (die);
/* For now, optimize only the main CU, in order to optimize the rest
we'd need to see all of them earlier. Leave the rest for post-linking
tools like DWZ. */
if (die == comp_unit_die ())
abbrev_opt_start = vec_safe_length (abbrev_die_table);
build_abbrev_table (die, extern_map);
optimize_abbrev_table ();
delete extern_map;
/* Initialize the beginning DIE offset - and calculate sizes/offsets. */
next_die_offset = (dwo_id
? DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE
: DWARF_COMPILE_UNIT_HEADER_SIZE);
calc_die_sizes (die);
oldsym = die->die_id.die_symbol;
if (oldsym && die->comdat_type_p)
{
tmp = XALLOCAVEC (char, strlen (oldsym) + 24);
sprintf (tmp, ".gnu.linkonce.wi.%s", oldsym);
secname = tmp;
die->die_id.die_symbol = NULL;
switch_to_section (get_section (secname, SECTION_DEBUG, NULL));
}
else
{
switch_to_section (debug_info_section);
ASM_OUTPUT_LABEL (asm_out_file, debug_info_section_label);
info_section_emitted = true;
}
/* For LTO cross unit DIE refs we want a symbol on the start of the
debuginfo section, not on the CU DIE. */
if ((flag_generate_lto || flag_generate_offload) && oldsym)
{
/* ??? No way to get visibility assembled without a decl. */
tree decl = build_decl (UNKNOWN_LOCATION, VAR_DECL,
get_identifier (oldsym), char_type_node);
TREE_PUBLIC (decl) = true;
TREE_STATIC (decl) = true;
DECL_ARTIFICIAL (decl) = true;
DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
DECL_VISIBILITY_SPECIFIED (decl) = true;
targetm.asm_out.assemble_visibility (decl, VISIBILITY_HIDDEN);
#ifdef ASM_WEAKEN_LABEL
/* We prefer a .weak because that handles duplicates from duplicate
archive members in a graceful way. */
ASM_WEAKEN_LABEL (asm_out_file, oldsym);
#else
targetm.asm_out.globalize_label (asm_out_file, oldsym);
#endif
ASM_OUTPUT_LABEL (asm_out_file, oldsym);
}
/* Output debugging information. */
output_compilation_unit_header (dwo_id
? DW_UT_split_compile : DW_UT_compile);
if (dwarf_version >= 5)
{
if (dwo_id != NULL)
for (int i = 0; i < 8; i++)
dw2_asm_output_data (1, dwo_id[i], i == 0 ? "DWO id" : NULL);
}
output_die (die);
/* Leave the marks on the main CU, so we can check them in
output_pubnames. */
if (oldsym)
{
unmark_dies (die);
die->die_id.die_symbol = oldsym;
}
}
/* Whether to generate the DWARF accelerator tables in .debug_pubnames
and .debug_pubtypes. This is configured per-target, but can be
overridden by the -gpubnames or -gno-pubnames options. */
static inline bool
want_pubnames (void)
{
if (debug_info_level <= DINFO_LEVEL_TERSE
/* Names and types go to the early debug part only. */
|| in_lto_p)
return false;
if (debug_generate_pub_sections != -1)
return debug_generate_pub_sections;
return targetm.want_debug_pub_sections;
}
/* Add the DW_AT_GNU_pubnames and DW_AT_GNU_pubtypes attributes. */
static void
add_AT_pubnames (dw_die_ref die)
{
if (want_pubnames ())
add_AT_flag (die, DW_AT_GNU_pubnames, 1);
}
/* Add a string attribute value to a skeleton DIE. */
static inline void
add_skeleton_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind,
const char *str)
{
dw_attr_node attr;
struct indirect_string_node *node;
if (! skeleton_debug_str_hash)
skeleton_debug_str_hash
= hash_table<indirect_string_hasher>::create_ggc (10);
node = find_AT_string_in_table (str, skeleton_debug_str_hash);
find_string_form (node);
if (node->form == dwarf_FORM (DW_FORM_strx))
node->form = DW_FORM_strp;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_str;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_str = node;
add_dwarf_attr (die, &attr);
}
/* Helper function to generate top-level dies for skeleton debug_info and
debug_types. */
static void
add_top_level_skeleton_die_attrs (dw_die_ref die)
{
const char *dwo_file_name = concat (aux_base_name, ".dwo", NULL);
const char *comp_dir = comp_dir_string ();
add_skeleton_AT_string (die, dwarf_AT (DW_AT_dwo_name), dwo_file_name);
if (comp_dir != NULL)
add_skeleton_AT_string (die, DW_AT_comp_dir, comp_dir);
add_AT_pubnames (die);
if (addr_index_table != NULL && addr_index_table->size () > 0)
add_AT_lineptr (die, dwarf_AT (DW_AT_addr_base), debug_addr_section_label);
}
/* Output skeleton debug sections that point to the dwo file. */
static void
output_skeleton_debug_sections (dw_die_ref comp_unit,
const unsigned char *dwo_id)
{
/* These attributes will be found in the full debug_info section. */
remove_AT (comp_unit, DW_AT_producer);
remove_AT (comp_unit, DW_AT_language);
switch_to_section (debug_skeleton_info_section);
ASM_OUTPUT_LABEL (asm_out_file, debug_skeleton_info_section_label);
/* Produce the skeleton compilation-unit header. This one differs enough from
a normal CU header that it's better not to call output_compilation_unit
header. */
if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
dw2_asm_output_data (4, 0xffffffff,
"Initial length escape value indicating 64-bit "
"DWARF extension");
dw2_asm_output_data (DWARF_OFFSET_SIZE,
DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE
- DWARF_INITIAL_LENGTH_SIZE
+ size_of_die (comp_unit),
"Length of Compilation Unit Info");
output_dwarf_version ();
if (dwarf_version >= 5)
{
dw2_asm_output_data (1, DW_UT_skeleton, "DW_UT_skeleton");
dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)");
}
dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_skeleton_abbrev_section_label,
debug_skeleton_abbrev_section,
"Offset Into Abbrev. Section");
if (dwarf_version < 5)
dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)");
else
for (int i = 0; i < 8; i++)
dw2_asm_output_data (1, dwo_id[i], i == 0 ? "DWO id" : NULL);
comp_unit->die_abbrev = SKELETON_COMP_DIE_ABBREV;
output_die (comp_unit);
/* Build the skeleton debug_abbrev section. */
switch_to_section (debug_skeleton_abbrev_section);
ASM_OUTPUT_LABEL (asm_out_file, debug_skeleton_abbrev_section_label);
output_die_abbrevs (SKELETON_COMP_DIE_ABBREV, comp_unit);
dw2_asm_output_data (1, 0, "end of skeleton .debug_abbrev");
}
/* Output a comdat type unit DIE and its children. */
static void
output_comdat_type_unit (comdat_type_node *node,
bool early_lto_debug ATTRIBUTE_UNUSED)
{
const char *secname;
char *tmp;
int i;
#if defined (OBJECT_FORMAT_ELF)
tree comdat_key;
#endif
/* First mark all the DIEs in this CU so we know which get local refs. */
mark_dies (node->root_die);
external_ref_hash_type *extern_map = optimize_external_refs (node->root_die);
build_abbrev_table (node->root_die, extern_map);
delete extern_map;
extern_map = NULL;
/* Initialize the beginning DIE offset - and calculate sizes/offsets. */
next_die_offset = DWARF_COMDAT_TYPE_UNIT_HEADER_SIZE;
calc_die_sizes (node->root_die);
#if defined (OBJECT_FORMAT_ELF)
if (dwarf_version >= 5)
{
if (!dwarf_split_debug_info)
secname = early_lto_debug ? DEBUG_LTO_INFO_SECTION : DEBUG_INFO_SECTION;
else
secname = (early_lto_debug
? DEBUG_LTO_DWO_INFO_SECTION : DEBUG_DWO_INFO_SECTION);
}
else if (!dwarf_split_debug_info)
secname = early_lto_debug ? ".gnu.debuglto_.debug_types" : ".debug_types";
else
secname = (early_lto_debug
? ".gnu.debuglto_.debug_types.dwo" : ".debug_types.dwo");
tmp = XALLOCAVEC (char, 4 + DWARF_TYPE_SIGNATURE_SIZE * 2);
sprintf (tmp, dwarf_version >= 5 ? "wi." : "wt.");
for (i = 0; i < DWARF_TYPE_SIGNATURE_SIZE; i++)
sprintf (tmp + 3 + i * 2, "%02x", node->signature[i] & 0xff);
comdat_key = get_identifier (tmp);
targetm.asm_out.named_section (secname,
SECTION_DEBUG | SECTION_LINKONCE,
comdat_key);
#else
tmp = XALLOCAVEC (char, 18 + DWARF_TYPE_SIGNATURE_SIZE * 2);
sprintf (tmp, (dwarf_version >= 5
? ".gnu.linkonce.wi." : ".gnu.linkonce.wt."));
for (i = 0; i < DWARF_TYPE_SIGNATURE_SIZE; i++)
sprintf (tmp + 17 + i * 2, "%02x", node->signature[i] & 0xff);
secname = tmp;
switch_to_section (get_section (secname, SECTION_DEBUG, NULL));
#endif
/* Output debugging information. */
output_compilation_unit_header (dwarf_split_debug_info
? DW_UT_split_type : DW_UT_type);
output_signature (node->signature, "Type Signature");
dw2_asm_output_data (DWARF_OFFSET_SIZE, node->type_die->die_offset,
"Offset to Type DIE");
output_die (node->root_die);
unmark_dies (node->root_die);
}
/* Return the DWARF2/3 pubname associated with a decl. */
static const char *
dwarf2_name (tree decl, int scope)
{
if (DECL_NAMELESS (decl))
return NULL;
return lang_hooks.dwarf_name (decl, scope ? 1 : 0);
}
/* Add a new entry to .debug_pubnames if appropriate. */
static void
add_pubname_string (const char *str, dw_die_ref die)
{
pubname_entry e;
e.die = die;
e.name = xstrdup (str);
vec_safe_push (pubname_table, e);
}
static void
add_pubname (tree decl, dw_die_ref die)
{
if (!want_pubnames ())
return;
/* Don't add items to the table when we expect that the consumer will have
just read the enclosing die. For example, if the consumer is looking at a
class_member, it will either be inside the class already, or will have just
looked up the class to find the member. Either way, searching the class is
faster than searching the index. */
if ((TREE_PUBLIC (decl) && !class_scope_p (die->die_parent))
|| is_cu_die (die->die_parent) || is_namespace_die (die->die_parent))
{
const char *name = dwarf2_name (decl, 1);
if (name)
add_pubname_string (name, die);
}
}
/* Add an enumerator to the pubnames section. */
static void
add_enumerator_pubname (const char *scope_name, dw_die_ref die)
{
pubname_entry e;
gcc_assert (scope_name);
e.name = concat (scope_name, get_AT_string (die, DW_AT_name), NULL);
e.die = die;
vec_safe_push (pubname_table, e);
}
/* Add a new entry to .debug_pubtypes if appropriate. */
static void
add_pubtype (tree decl, dw_die_ref die)
{
pubname_entry e;
if (!want_pubnames ())
return;
if ((TREE_PUBLIC (decl)
|| is_cu_die (die->die_parent) || is_namespace_die (die->die_parent))
&& (die->die_tag == DW_TAG_typedef || COMPLETE_TYPE_P (decl)))
{
tree scope = NULL;
const char *scope_name = "";
const char *sep = is_cxx () ? "::" : ".";
const char *name;
scope = TYPE_P (decl) ? TYPE_CONTEXT (decl) : NULL;
if (scope && TREE_CODE (scope) == NAMESPACE_DECL)
{
scope_name = lang_hooks.dwarf_name (scope, 1);
if (scope_name != NULL && scope_name[0] != '\0')
scope_name = concat (scope_name, sep, NULL);
else
scope_name = "";
}
if (TYPE_P (decl))
name = type_tag (decl);
else
name = lang_hooks.dwarf_name (decl, 1);
/* If we don't have a name for the type, there's no point in adding
it to the table. */
if (name != NULL && name[0] != '\0')
{
e.die = die;
e.name = concat (scope_name, name, NULL);
vec_safe_push (pubtype_table, e);
}
/* Although it might be more consistent to add the pubinfo for the
enumerators as their dies are created, they should only be added if the
enum type meets the criteria above. So rather than re-check the parent
enum type whenever an enumerator die is created, just output them all
here. This isn't protected by the name conditional because anonymous
enums don't have names. */
if (die->die_tag == DW_TAG_enumeration_type)
{
dw_die_ref c;
FOR_EACH_CHILD (die, c, add_enumerator_pubname (scope_name, c));
}
}
}
/* Output a single entry in the pubnames table. */
static void
output_pubname (dw_offset die_offset, pubname_entry *entry)
{
dw_die_ref die = entry->die;
int is_static = get_AT_flag (die, DW_AT_external) ? 0 : 1;
dw2_asm_output_data (DWARF_OFFSET_SIZE, die_offset, "DIE offset");
if (debug_generate_pub_sections == 2)
{
/* This logic follows gdb's method for determining the value of the flag
byte. */
uint32_t flags = GDB_INDEX_SYMBOL_KIND_NONE;
switch (die->die_tag)
{
case DW_TAG_typedef:
case DW_TAG_base_type:
case DW_TAG_subrange_type:
GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags, GDB_INDEX_SYMBOL_KIND_TYPE);
GDB_INDEX_SYMBOL_STATIC_SET_VALUE(flags, 1);
break;
case DW_TAG_enumerator:
GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags,
GDB_INDEX_SYMBOL_KIND_VARIABLE);
if (!is_cxx ())
GDB_INDEX_SYMBOL_STATIC_SET_VALUE(flags, 1);
break;
case DW_TAG_subprogram:
GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags,
GDB_INDEX_SYMBOL_KIND_FUNCTION);
if (!is_ada ())
GDB_INDEX_SYMBOL_STATIC_SET_VALUE(flags, is_static);
break;
case DW_TAG_constant:
GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags,
GDB_INDEX_SYMBOL_KIND_VARIABLE);
GDB_INDEX_SYMBOL_STATIC_SET_VALUE(flags, is_static);
break;
case DW_TAG_variable:
GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags,
GDB_INDEX_SYMBOL_KIND_VARIABLE);
GDB_INDEX_SYMBOL_STATIC_SET_VALUE(flags, is_static);
break;
case DW_TAG_namespace:
case DW_TAG_imported_declaration:
GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags, GDB_INDEX_SYMBOL_KIND_TYPE);
break;
case DW_TAG_class_type:
case DW_TAG_interface_type:
case DW_TAG_structure_type:
case DW_TAG_union_type:
case DW_TAG_enumeration_type:
GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags, GDB_INDEX_SYMBOL_KIND_TYPE);
if (!is_cxx ())
GDB_INDEX_SYMBOL_STATIC_SET_VALUE(flags, 1);
break;
default:
/* An unusual tag. Leave the flag-byte empty. */
break;
}
dw2_asm_output_data (1, flags >> GDB_INDEX_CU_BITSIZE,
"GDB-index flags");
}
dw2_asm_output_nstring (entry->name, -1, "external name");
}
/* Output the public names table used to speed up access to externally
visible names; or the public types table used to find type definitions. */
static void
output_pubnames (vec<pubname_entry, va_gc> *names)
{
unsigned i;
unsigned long pubnames_length = size_of_pubnames (names);
pubname_entry *pub;
if (!XCOFF_DEBUGGING_INFO)
{
if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
dw2_asm_output_data (4, 0xffffffff,
"Initial length escape value indicating 64-bit DWARF extension");
dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length,
"Pub Info Length");
}
/* Version number for pubnames/pubtypes is independent of dwarf version. */
dw2_asm_output_data (2, 2, "DWARF pubnames/pubtypes version");
if (dwarf_split_debug_info)
dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_skeleton_info_section_label,
debug_skeleton_info_section,
"Offset of Compilation Unit Info");
else
dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_info_section_label,
debug_info_section,
"Offset of Compilation Unit Info");
dw2_asm_output_data (DWARF_OFFSET_SIZE, next_die_offset,
"Compilation Unit Length");
FOR_EACH_VEC_ELT (*names, i, pub)
{
if (include_pubname_in_output (names, pub))
{
dw_offset die_offset = pub->die->die_offset;
/* We shouldn't see pubnames for DIEs outside of the main CU. */
if (names == pubname_table && pub->die->die_tag != DW_TAG_enumerator)
gcc_assert (pub->die->die_mark);
/* If we're putting types in their own .debug_types sections,
the .debug_pubtypes table will still point to the compile
unit (not the type unit), so we want to use the offset of
the skeleton DIE (if there is one). */
if (pub->die->comdat_type_p && names == pubtype_table)
{
comdat_type_node *type_node = pub->die->die_id.die_type_node;
if (type_node != NULL)
die_offset = (type_node->skeleton_die != NULL
? type_node->skeleton_die->die_offset
: comp_unit_die ()->die_offset);
}
output_pubname (die_offset, pub);
}
}
dw2_asm_output_data (DWARF_OFFSET_SIZE, 0, NULL);
}
/* Output public names and types tables if necessary. */
static void
output_pubtables (void)
{
if (!want_pubnames () || !info_section_emitted)
return;
switch_to_section (debug_pubnames_section);
output_pubnames (pubname_table);
/* ??? Only defined by DWARF3, but emitted by Darwin for DWARF2.
It shouldn't hurt to emit it always, since pure DWARF2 consumers
simply won't look for the section. */
switch_to_section (debug_pubtypes_section);
output_pubnames (pubtype_table);
}
/* Output the information that goes into the .debug_aranges table.
Namely, define the beginning and ending address range of the
text section generated for this compilation unit. */
static void
output_aranges (void)
{
unsigned i;
unsigned long aranges_length = size_of_aranges ();
if (!XCOFF_DEBUGGING_INFO)
{
if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
dw2_asm_output_data (4, 0xffffffff,
"Initial length escape value indicating 64-bit DWARF extension");
dw2_asm_output_data (DWARF_OFFSET_SIZE, aranges_length,
"Length of Address Ranges Info");
}
/* Version number for aranges is still 2, even up to DWARF5. */
dw2_asm_output_data (2, 2, "DWARF aranges version");
if (dwarf_split_debug_info)
dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_skeleton_info_section_label,
debug_skeleton_info_section,
"Offset of Compilation Unit Info");
else
dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_info_section_label,
debug_info_section,
"Offset of Compilation Unit Info");
dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Size of Address");
dw2_asm_output_data (1, 0, "Size of Segment Descriptor");
/* We need to align to twice the pointer size here. */
if (DWARF_ARANGES_PAD_SIZE)
{
/* Pad using a 2 byte words so that padding is correct for any
pointer size. */
dw2_asm_output_data (2, 0, "Pad to %d byte boundary",
2 * DWARF2_ADDR_SIZE);
for (i = 2; i < (unsigned) DWARF_ARANGES_PAD_SIZE; i += 2)
dw2_asm_output_data (2, 0, NULL);
}
/* It is necessary not to output these entries if the sections were
not used; if the sections were not used, the length will be 0 and
the address may end up as 0 if the section is discarded by ld
--gc-sections, leaving an invalid (0, 0) entry that can be
confused with the terminator. */
if (text_section_used)
{
dw2_asm_output_addr (DWARF2_ADDR_SIZE, text_section_label, "Address");
dw2_asm_output_delta (DWARF2_ADDR_SIZE, text_end_label,
text_section_label, "Length");
}
if (cold_text_section_used)
{
dw2_asm_output_addr (DWARF2_ADDR_SIZE, cold_text_section_label,
"Address");
dw2_asm_output_delta (DWARF2_ADDR_SIZE, cold_end_label,
cold_text_section_label, "Length");
}
if (have_multiple_function_sections)
{
unsigned fde_idx;
dw_fde_ref fde;
FOR_EACH_VEC_ELT (*fde_vec, fde_idx, fde)
{
if (DECL_IGNORED_P (fde->decl))
continue;
if (!fde->in_std_section)
{
dw2_asm_output_addr (DWARF2_ADDR_SIZE, fde->dw_fde_begin,
"Address");
dw2_asm_output_delta (DWARF2_ADDR_SIZE, fde->dw_fde_end,
fde->dw_fde_begin, "Length");
}
if (fde->dw_fde_second_begin && !fde->second_in_std_section)
{
dw2_asm_output_addr (DWARF2_ADDR_SIZE, fde->dw_fde_second_begin,
"Address");
dw2_asm_output_delta (DWARF2_ADDR_SIZE, fde->dw_fde_second_end,
fde->dw_fde_second_begin, "Length");
}
}
}
/* Output the terminator words. */
dw2_asm_output_data (DWARF2_ADDR_SIZE, 0, NULL);
dw2_asm_output_data (DWARF2_ADDR_SIZE, 0, NULL);
}
/* Add a new entry to .debug_ranges. Return its index into
ranges_table vector. */
static unsigned int
add_ranges_num (int num, bool maybe_new_sec)
{
dw_ranges r = { NULL, num, 0, maybe_new_sec };
vec_safe_push (ranges_table, r);
return vec_safe_length (ranges_table) - 1;
}
/* Add a new entry to .debug_ranges corresponding to a block, or a
range terminator if BLOCK is NULL. MAYBE_NEW_SEC is true if
this entry might be in a different section from previous range. */
static unsigned int
add_ranges (const_tree block, bool maybe_new_sec)
{
return add_ranges_num (block ? BLOCK_NUMBER (block) : 0, maybe_new_sec);
}
/* Note that (*rnglist_table)[offset] is either a head of a rnglist
chain, or middle entry of a chain that will be directly referred to. */
static void
note_rnglist_head (unsigned int offset)
{
if (dwarf_version < 5 || (*ranges_table)[offset].label)
return;
(*ranges_table)[offset].label = gen_internal_sym ("LLRL");
}
/* Add a new entry to .debug_ranges corresponding to a pair of labels.
When using dwarf_split_debug_info, address attributes in dies destined
for the final executable should be direct references--setting the
parameter force_direct ensures this behavior. */
static void
add_ranges_by_labels (dw_die_ref die, const char *begin, const char *end,
bool *added, bool force_direct)
{
unsigned int in_use = vec_safe_length (ranges_by_label);
unsigned int offset;
dw_ranges_by_label rbl = { begin, end };
vec_safe_push (ranges_by_label, rbl);
offset = add_ranges_num (-(int)in_use - 1, true);
if (!*added)
{
add_AT_range_list (die, DW_AT_ranges, offset, force_direct);
*added = true;
note_rnglist_head (offset);
}
}
/* Emit .debug_ranges section. */
static void
output_ranges (void)
{
unsigned i;
static const char *const start_fmt = "Offset %#x";
const char *fmt = start_fmt;
dw_ranges *r;
switch_to_section (debug_ranges_section);
ASM_OUTPUT_LABEL (asm_out_file, ranges_section_label);
FOR_EACH_VEC_SAFE_ELT (ranges_table, i, r)
{
int block_num = r->num;
if (block_num > 0)
{
char blabel[MAX_ARTIFICIAL_LABEL_BYTES];
char elabel[MAX_ARTIFICIAL_LABEL_BYTES];
ASM_GENERATE_INTERNAL_LABEL (blabel, BLOCK_BEGIN_LABEL, block_num);
ASM_GENERATE_INTERNAL_LABEL (elabel, BLOCK_END_LABEL, block_num);
/* If all code is in the text section, then the compilation
unit base address defaults to DW_AT_low_pc, which is the
base of the text section. */
if (!have_multiple_function_sections)
{
dw2_asm_output_delta (DWARF2_ADDR_SIZE, blabel,
text_section_label,
fmt, i * 2 * DWARF2_ADDR_SIZE);
dw2_asm_output_delta (DWARF2_ADDR_SIZE, elabel,
text_section_label, NULL);
}
/* Otherwise, the compilation unit base address is zero,
which allows us to use absolute addresses, and not worry
about whether the target supports cross-section
arithmetic. */
else
{
dw2_asm_output_addr (DWARF2_ADDR_SIZE, blabel,
fmt, i * 2 * DWARF2_ADDR_SIZE);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, elabel, NULL);
}
fmt = NULL;
}
/* Negative block_num stands for an index into ranges_by_label. */
else if (block_num < 0)
{
int lab_idx = - block_num - 1;
if (!have_multiple_function_sections)
{
gcc_unreachable ();
#if 0
/* If we ever use add_ranges_by_labels () for a single
function section, all we have to do is to take out
the #if 0 above. */
dw2_asm_output_delta (DWARF2_ADDR_SIZE,
(*ranges_by_label)[lab_idx].begin,
text_section_label,
fmt, i * 2 * DWARF2_ADDR_SIZE);
dw2_asm_output_delta (DWARF2_ADDR_SIZE,
(*ranges_by_label)[lab_idx].end,
text_section_label, NULL);
#endif
}
else
{
dw2_asm_output_addr (DWARF2_ADDR_SIZE,
(*ranges_by_label)[lab_idx].begin,
fmt, i * 2 * DWARF2_ADDR_SIZE);
dw2_asm_output_addr (DWARF2_ADDR_SIZE,
(*ranges_by_label)[lab_idx].end,
NULL);
}
}
else
{
dw2_asm_output_data (DWARF2_ADDR_SIZE, 0, NULL);
dw2_asm_output_data (DWARF2_ADDR_SIZE, 0, NULL);
fmt = start_fmt;
}
}
}
/* Non-zero if .debug_line_str should be used for .debug_line section
strings or strings that are likely shareable with those. */
#define DWARF5_USE_DEBUG_LINE_STR \
(!DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET \
&& (DEBUG_STR_SECTION_FLAGS & SECTION_MERGE) != 0 \
/* FIXME: there is no .debug_line_str.dwo section, \
for -gsplit-dwarf we should use DW_FORM_strx instead. */ \
&& !dwarf_split_debug_info)
/* Returns TRUE if we are outputting DWARF5 and the assembler supports
DWARF5 .debug_line tables using .debug_line_str or we generate
it ourselves, except for split-dwarf which doesn't have a
.debug_line_str. */
static bool
asm_outputs_debug_line_str (void)
{
if (dwarf_version >= 5
&& ! output_asm_line_debug_info ()
&& DWARF5_USE_DEBUG_LINE_STR)
return true;
else
{
#if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_N_FLAG)
return !dwarf_split_debug_info && dwarf_version >= 5;
#else
return false;
#endif
}
}
/* Assign .debug_rnglists indexes. */
static void
index_rnglists (void)
{
unsigned i;
dw_ranges *r;
FOR_EACH_VEC_SAFE_ELT (ranges_table, i, r)
if (r->label)
r->idx = rnglist_idx++;
}
/* Emit .debug_rnglists section. */
static void
output_rnglists (unsigned generation)
{
unsigned i;
dw_ranges *r;
char l1[MAX_ARTIFICIAL_LABEL_BYTES];
char l2[MAX_ARTIFICIAL_LABEL_BYTES];
char basebuf[MAX_ARTIFICIAL_LABEL_BYTES];
switch_to_section (debug_ranges_section);
ASM_OUTPUT_LABEL (asm_out_file, ranges_section_label);
/* There are up to 4 unique ranges labels per generation.
See also init_sections_and_labels. */
ASM_GENERATE_INTERNAL_LABEL (l1, DEBUG_RANGES_SECTION_LABEL,
2 + generation * 4);
ASM_GENERATE_INTERNAL_LABEL (l2, DEBUG_RANGES_SECTION_LABEL,
3 + generation * 4);
if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
dw2_asm_output_data (4, 0xffffffff,
"Initial length escape value indicating "
"64-bit DWARF extension");
dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
"Length of Range Lists");
ASM_OUTPUT_LABEL (asm_out_file, l1);
output_dwarf_version ();
dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Address Size");
dw2_asm_output_data (1, 0, "Segment Size");
/* Emit the offset table only for -gsplit-dwarf. If we don't care
about relocation sizes and primarily care about the size of .debug*
sections in linked shared libraries and executables, then
the offset table plus corresponding DW_FORM_rnglistx uleb128 indexes
into it are usually larger than just DW_FORM_sec_offset offsets
into the .debug_rnglists section. */
dw2_asm_output_data (4, dwarf_split_debug_info ? rnglist_idx : 0,
"Offset Entry Count");
if (dwarf_split_debug_info)
{
ASM_OUTPUT_LABEL (asm_out_file, ranges_base_label);
FOR_EACH_VEC_SAFE_ELT (ranges_table, i, r)
if (r->label)
dw2_asm_output_delta (DWARF_OFFSET_SIZE, r->label,
ranges_base_label, NULL);
}
const char *lab = "";
unsigned int len = vec_safe_length (ranges_table);
const char *base = NULL;
FOR_EACH_VEC_SAFE_ELT (ranges_table, i, r)
{
int block_num = r->num;
if (r->label)
{
ASM_OUTPUT_LABEL (asm_out_file, r->label);
lab = r->label;
}
if (HAVE_AS_LEB128 && (r->label || r->maybe_new_sec))
base = NULL;
if (block_num > 0)
{
char blabel[MAX_ARTIFICIAL_LABEL_BYTES];
char elabel[MAX_ARTIFICIAL_LABEL_BYTES];
ASM_GENERATE_INTERNAL_LABEL (blabel, BLOCK_BEGIN_LABEL, block_num);
ASM_GENERATE_INTERNAL_LABEL (elabel, BLOCK_END_LABEL, block_num);
if (HAVE_AS_LEB128)
{
/* If all code is in the text section, then the compilation
unit base address defaults to DW_AT_low_pc, which is the
base of the text section. */
if (!have_multiple_function_sections)
{
dw2_asm_output_data (1, DW_RLE_offset_pair,
"DW_RLE_offset_pair (%s)", lab);
dw2_asm_output_delta_uleb128 (blabel, text_section_label,
"Range begin address (%s)", lab);
dw2_asm_output_delta_uleb128 (elabel, text_section_label,
"Range end address (%s)", lab);
continue;
}
if (base == NULL)
{
dw_ranges *r2 = NULL;
if (i < len - 1)
r2 = &(*ranges_table)[i + 1];
if (r2
&& r2->num != 0
&& r2->label == NULL
&& !r2->maybe_new_sec)
{
dw2_asm_output_data (1, DW_RLE_base_address,
"DW_RLE_base_address (%s)", lab);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, blabel,
"Base address (%s)", lab);
strcpy (basebuf, blabel);
base = basebuf;
}
}
if (base)
{
dw2_asm_output_data (1, DW_RLE_offset_pair,
"DW_RLE_offset_pair (%s)", lab);
dw2_asm_output_delta_uleb128 (blabel, base,
"Range begin address (%s)", lab);
dw2_asm_output_delta_uleb128 (elabel, base,
"Range end address (%s)", lab);
continue;
}
dw2_asm_output_data (1, DW_RLE_start_length,
"DW_RLE_start_length (%s)", lab);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, blabel,
"Range begin address (%s)", lab);
dw2_asm_output_delta_uleb128 (elabel, blabel,
"Range length (%s)", lab);
}
else
{
dw2_asm_output_data (1, DW_RLE_start_end,
"DW_RLE_start_end (%s)", lab);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, blabel,
"Range begin address (%s)", lab);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, elabel,
"Range end address (%s)", lab);
}
}
/* Negative block_num stands for an index into ranges_by_label. */
else if (block_num < 0)
{
int lab_idx = - block_num - 1;
const char *blabel = (*ranges_by_label)[lab_idx].begin;
const char *elabel = (*ranges_by_label)[lab_idx].end;
if (!have_multiple_function_sections)
gcc_unreachable ();
if (HAVE_AS_LEB128)
{
dw2_asm_output_data (1, DW_RLE_start_length,
"DW_RLE_start_length (%s)", lab);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, blabel,
"Range begin address (%s)", lab);
dw2_asm_output_delta_uleb128 (elabel, blabel,
"Range length (%s)", lab);
}
else
{
dw2_asm_output_data (1, DW_RLE_start_end,
"DW_RLE_start_end (%s)", lab);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, blabel,
"Range begin address (%s)", lab);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, elabel,
"Range end address (%s)", lab);
}
}
else
dw2_asm_output_data (1, DW_RLE_end_of_list,
"DW_RLE_end_of_list (%s)", lab);
}
ASM_OUTPUT_LABEL (asm_out_file, l2);
}
/* Data structure containing information about input files. */
struct file_info
{
const char *path; /* Complete file name. */
const char *fname; /* File name part. */
int length; /* Length of entire string. */
struct dwarf_file_data * file_idx; /* Index in input file table. */
int dir_idx; /* Index in directory table. */
};
/* Data structure containing information about directories with source
files. */
struct dir_info
{
const char *path; /* Path including directory name. */
int length; /* Path length. */
int prefix; /* Index of directory entry which is a prefix. */
int count; /* Number of files in this directory. */
int dir_idx; /* Index of directory used as base. */
};
/* Callback function for file_info comparison. We sort by looking at
the directories in the path. */
static int
file_info_cmp (const void *p1, const void *p2)
{
const struct file_info *const s1 = (const struct file_info *) p1;
const struct file_info *const s2 = (const struct file_info *) p2;
const unsigned char *cp1;
const unsigned char *cp2;
/* Take care of file names without directories. We need to make sure that
we return consistent values to qsort since some will get confused if
we return the same value when identical operands are passed in opposite
orders. So if neither has a directory, return 0 and otherwise return
1 or -1 depending on which one has the directory. We want the one with
the directory to sort after the one without, so all no directory files
are at the start (normally only the compilation unit file). */
if ((s1->path == s1->fname || s2->path == s2->fname))
return (s2->path == s2->fname) - (s1->path == s1->fname);
cp1 = (const unsigned char *) s1->path;
cp2 = (const unsigned char *) s2->path;
while (1)
{
++cp1;
++cp2;
/* Reached the end of the first path? If so, handle like above,
but now we want longer directory prefixes before shorter ones. */
if ((cp1 == (const unsigned char *) s1->fname)
|| (cp2 == (const unsigned char *) s2->fname))
return ((cp1 == (const unsigned char *) s1->fname)
- (cp2 == (const unsigned char *) s2->fname));
/* Character of current path component the same? */
else if (*cp1 != *cp2)
return *cp1 - *cp2;
}
}
struct file_name_acquire_data
{
struct file_info *files;
int used_files;
int max_files;
};
/* Traversal function for the hash table. */
int
file_name_acquire (dwarf_file_data **slot, file_name_acquire_data *fnad)
{
struct dwarf_file_data *d = *slot;
struct file_info *fi;
const char *f;
gcc_assert (fnad->max_files >= d->emitted_number);
if (! d->emitted_number)
return 1;
gcc_assert (fnad->max_files != fnad->used_files);
fi = fnad->files + fnad->used_files++;
f = remap_debug_filename (d->filename);
/* Skip all leading "./". */
while (f[0] == '.' && IS_DIR_SEPARATOR (f[1]))
f += 2;
/* Create a new array entry. */
fi->path = f;
fi->length = strlen (f);
fi->file_idx = d;
/* Search for the file name part. */
f = strrchr (f, DIR_SEPARATOR);
#if defined (DIR_SEPARATOR_2)
{
const char *g = strrchr (fi->path, DIR_SEPARATOR_2);
if (g != NULL)
{
if (f == NULL || f < g)
f = g;
}
}
#endif
fi->fname = f == NULL ? fi->path : f + 1;
return 1;
}
/* Helper function for output_file_names. Emit a FORM encoded
string STR, with assembly comment start ENTRY_KIND and
index IDX */
static void
output_line_string (enum dwarf_form form, const char *str,
const char *entry_kind, unsigned int idx)
{
switch (form)
{
case DW_FORM_string:
dw2_asm_output_nstring (str, -1, "%s: %#x", entry_kind, idx);
break;
case DW_FORM_line_strp:
if (!debug_line_str_hash)
debug_line_str_hash
= hash_table<indirect_string_hasher>::create_ggc (10);
struct indirect_string_node *node;
node = find_AT_string_in_table (str, debug_line_str_hash);
set_indirect_string (node);
node->form = form;
dw2_asm_output_offset (DWARF_OFFSET_SIZE, node->label,
debug_line_str_section, "%s: %#x: \"%s\"",
entry_kind, 0, node->str);
break;
default:
gcc_unreachable ();
}
}
/* Output the directory table and the file name table. We try to minimize
the total amount of memory needed. A heuristic is used to avoid large
slowdowns with many input files. */
static void
output_file_names (void)
{
struct file_name_acquire_data fnad;
int numfiles;
struct file_info *files;
struct dir_info *dirs;
int *saved;
int *savehere;
int *backmap;
int ndirs;
int idx_offset;
int i;
if (!last_emitted_file)
{
if (dwarf_version >= 5)
{
dw2_asm_output_data (1, 0, "Directory entry format count");
dw2_asm_output_data_uleb128 (0, "Directories count");
dw2_asm_output_data (1, 0, "File name entry format count");
dw2_asm_output_data_uleb128 (0, "File names count");
}
else
{
dw2_asm_output_data (1, 0, "End directory table");
dw2_asm_output_data (1, 0, "End file name table");
}
return;
}
numfiles = last_emitted_file->emitted_number;
/* Allocate the various arrays we need. */
files = XALLOCAVEC (struct file_info, numfiles);
dirs = XALLOCAVEC (struct dir_info, numfiles);
fnad.files = files;
fnad.used_files = 0;
fnad.max_files = numfiles;
file_table->traverse<file_name_acquire_data *, file_name_acquire> (&fnad);
gcc_assert (fnad.used_files == fnad.max_files);
qsort (files, numfiles, sizeof (files[0]), file_info_cmp);
/* Find all the different directories used. */
dirs[0].path = files[0].path;
dirs[0].length = files[0].fname - files[0].path;
dirs[0].prefix = -1;
dirs[0].count = 1;
dirs[0].dir_idx = 0;
files[0].dir_idx = 0;
ndirs = 1;
for (i = 1; i < numfiles; i++)
if (files[i].fname - files[i].path == dirs[ndirs - 1].length
&& memcmp (dirs[ndirs - 1].path, files[i].path,
dirs[ndirs - 1].length) == 0)
{
/* Same directory as last entry. */
files[i].dir_idx = ndirs - 1;
++dirs[ndirs - 1].count;
}
else
{
int j;
/* This is a new directory. */
dirs[ndirs].path = files[i].path;
dirs[ndirs].length = files[i].fname - files[i].path;
dirs[ndirs].count = 1;
dirs[ndirs].dir_idx = ndirs;
files[i].dir_idx = ndirs;
/* Search for a prefix. */
dirs[ndirs].prefix = -1;
for (j = 0; j < ndirs; j++)
if (dirs[j].length < dirs[ndirs].length
&& dirs[j].length > 1
&& (dirs[ndirs].prefix == -1
|| dirs[j].length > dirs[dirs[ndirs].prefix].length)
&& memcmp (dirs[j].path, dirs[ndirs].path, dirs[j].length) == 0)
dirs[ndirs].prefix = j;
++ndirs;
}
/* Now to the actual work. We have to find a subset of the directories which
allow expressing the file name using references to the directory table
with the least amount of characters. We do not do an exhaustive search
where we would have to check out every combination of every single
possible prefix. Instead we use a heuristic which provides nearly optimal
results in most cases and never is much off. */
saved = XALLOCAVEC (int, ndirs);
savehere = XALLOCAVEC (int, ndirs);
memset (saved, '\0', ndirs * sizeof (saved[0]));
for (i = 0; i < ndirs; i++)
{
int j;
int total;
/* We can always save some space for the current directory. But this
does not mean it will be enough to justify adding the directory. */
savehere[i] = dirs[i].length;
total = (savehere[i] - saved[i]) * dirs[i].count;
for (j = i + 1; j < ndirs; j++)
{
savehere[j] = 0;
if (saved[j] < dirs[i].length)
{
/* Determine whether the dirs[i] path is a prefix of the
dirs[j] path. */
int k;
k = dirs[j].prefix;
while (k != -1 && k != (int) i)
k = dirs[k].prefix;
if (k == (int) i)
{
/* Yes it is. We can possibly save some memory by
writing the filenames in dirs[j] relative to
dirs[i]. */
savehere[j] = dirs[i].length;
total += (savehere[j] - saved[j]) * dirs[j].count;
}
}
}
/* Check whether we can save enough to justify adding the dirs[i]
directory. */
if (total > dirs[i].length + 1)
{
/* It's worthwhile adding. */
for (j = i; j < ndirs; j++)
if (savehere[j] > 0)
{
/* Remember how much we saved for this directory so far. */
saved[j] = savehere[j];
/* Remember the prefix directory. */
dirs[j].dir_idx = i;
}
}
}
/* Emit the directory name table. */
idx_offset = dirs[0].length > 0 ? 1 : 0;
enum dwarf_form str_form = DW_FORM_string;
enum dwarf_form idx_form = DW_FORM_udata;
if (dwarf_version >= 5)
{
const char *comp_dir = comp_dir_string ();
if (comp_dir == NULL)
comp_dir = "";
dw2_asm_output_data (1, 1, "Directory entry format count");
if (DWARF5_USE_DEBUG_LINE_STR)
str_form = DW_FORM_line_strp;
dw2_asm_output_data_uleb128 (DW_LNCT_path, "DW_LNCT_path");
dw2_asm_output_data_uleb128 (str_form, "%s",
get_DW_FORM_name (str_form));
dw2_asm_output_data_uleb128 (ndirs + idx_offset, "Directories count");
if (str_form == DW_FORM_string)
{
dw2_asm_output_nstring (comp_dir, -1, "Directory Entry: %#x", 0);
for (i = 1 - idx_offset; i < ndirs; i++)
dw2_asm_output_nstring (dirs[i].path,
dirs[i].length
- !DWARF2_DIR_SHOULD_END_WITH_SEPARATOR,
"Directory Entry: %#x", i + idx_offset);
}
else
{
output_line_string (str_form, comp_dir, "Directory Entry", 0);
for (i = 1 - idx_offset; i < ndirs; i++)
{
const char *str
= ggc_alloc_string (dirs[i].path,
dirs[i].length
- !DWARF2_DIR_SHOULD_END_WITH_SEPARATOR);
output_line_string (str_form, str, "Directory Entry",
(unsigned) i + idx_offset);
}
}
}
else
{
for (i = 1 - idx_offset; i < ndirs; i++)
dw2_asm_output_nstring (dirs[i].path,
dirs[i].length
- !DWARF2_DIR_SHOULD_END_WITH_SEPARATOR,
"Directory Entry: %#x", i + idx_offset);
dw2_asm_output_data (1, 0, "End directory table");
}
/* We have to emit them in the order of emitted_number since that's
used in the debug info generation. To do this efficiently we
generate a back-mapping of the indices first. */
backmap = XALLOCAVEC (int, numfiles);
for (i = 0; i < numfiles; i++)
backmap[files[i].file_idx->emitted_number - 1] = i;
if (dwarf_version >= 5)
{
const char *filename0 = get_AT_string (comp_unit_die (), DW_AT_name);
if (filename0 == NULL)
filename0 = "";
/* DW_LNCT_directory_index can use DW_FORM_udata, DW_FORM_data1 and
DW_FORM_data2. Choose one based on the number of directories
and how much space would they occupy in each encoding.
If we have at most 256 directories, all indexes fit into
a single byte, so DW_FORM_data1 is most compact (if there
are at most 128 directories, DW_FORM_udata would be as
compact as that, but not shorter and slower to decode). */
if (ndirs + idx_offset <= 256)
idx_form = DW_FORM_data1;
/* If there are more than 65536 directories, we have to use
DW_FORM_udata, DW_FORM_data2 can't refer to them.
Otherwise, compute what space would occupy if all the indexes
used DW_FORM_udata - sum - and compare that to how large would
be DW_FORM_data2 encoding, and pick the more efficient one. */
else if (ndirs + idx_offset <= 65536)
{
unsigned HOST_WIDE_INT sum = 1;
for (i = 0; i < numfiles; i++)
{
int file_idx = backmap[i];
int dir_idx = dirs[files[file_idx].dir_idx].dir_idx;
sum += size_of_uleb128 (dir_idx);
}
if (sum >= HOST_WIDE_INT_UC (2) * (numfiles + 1))
idx_form = DW_FORM_data2;
}
#ifdef VMS_DEBUGGING_INFO
dw2_asm_output_data (1, 4, "File name entry format count");
#else
dw2_asm_output_data (1, 2, "File name entry format count");
#endif
dw2_asm_output_data_uleb128 (DW_LNCT_path, "DW_LNCT_path");
dw2_asm_output_data_uleb128 (str_form, "%s",
get_DW_FORM_name (str_form));
dw2_asm_output_data_uleb128 (DW_LNCT_directory_index,
"DW_LNCT_directory_index");
dw2_asm_output_data_uleb128 (idx_form, "%s",
get_DW_FORM_name (idx_form));
#ifdef VMS_DEBUGGING_INFO
dw2_asm_output_data_uleb128 (DW_LNCT_timestamp, "DW_LNCT_timestamp");
dw2_asm_output_data_uleb128 (DW_FORM_udata, "DW_FORM_udata");
dw2_asm_output_data_uleb128 (DW_LNCT_size, "DW_LNCT_size");
dw2_asm_output_data_uleb128 (DW_FORM_udata, "DW_FORM_udata");
#endif
dw2_asm_output_data_uleb128 (numfiles + 1, "File names count");
output_line_string (str_form, filename0, "File Entry", 0);
/* Include directory index. */
if (idx_form != DW_FORM_udata)
dw2_asm_output_data (idx_form == DW_FORM_data1 ? 1 : 2,
0, NULL);
else
dw2_asm_output_data_uleb128 (0, NULL);
#ifdef VMS_DEBUGGING_INFO
dw2_asm_output_data_uleb128 (0, NULL);
dw2_asm_output_data_uleb128 (0, NULL);
#endif
}
/* Now write all the file names. */
for (i = 0; i < numfiles; i++)
{
int file_idx = backmap[i];
int dir_idx = dirs[files[file_idx].dir_idx].dir_idx;
#ifdef VMS_DEBUGGING_INFO
#define MAX_VMS_VERSION_LEN 6 /* ";32768" */
/* Setting these fields can lead to debugger miscomparisons,
but VMS Debug requires them to be set correctly. */
int ver;
long long cdt;
long siz;
int maxfilelen = (strlen (files[file_idx].path)
+ dirs[dir_idx].length
+ MAX_VMS_VERSION_LEN + 1);
char *filebuf = XALLOCAVEC (char, maxfilelen);
vms_file_stats_name (files[file_idx].path, 0, 0, 0, &ver);
snprintf (filebuf, maxfilelen, "%s;%d",
files[file_idx].path + dirs[dir_idx].length, ver);
output_line_string (str_form, filebuf, "File Entry", (unsigned) i + 1);
/* Include directory index. */
if (dwarf_version >= 5 && idx_form != DW_FORM_udata)
dw2_asm_output_data (idx_form == DW_FORM_data1 ? 1 : 2,
dir_idx + idx_offset, NULL);
else
dw2_asm_output_data_uleb128 (dir_idx + idx_offset, NULL);
/* Modification time. */
dw2_asm_output_data_uleb128 ((vms_file_stats_name (files[file_idx].path,
&cdt, 0, 0, 0) == 0)
? cdt : 0, NULL);
/* File length in bytes. */
dw2_asm_output_data_uleb128 ((vms_file_stats_name (files[file_idx].path,
0, &siz, 0, 0) == 0)
? siz : 0, NULL);
#else
output_line_string (str_form,
files[file_idx].path + dirs[dir_idx].length,
"File Entry", (unsigned) i + 1);
/* Include directory index. */
if (dwarf_version >= 5 && idx_form != DW_FORM_udata)
dw2_asm_output_data (idx_form == DW_FORM_data1 ? 1 : 2,
dir_idx + idx_offset, NULL);
else
dw2_asm_output_data_uleb128 (dir_idx + idx_offset, NULL);
if (dwarf_version >= 5)
continue;
/* Modification time. */
dw2_asm_output_data_uleb128 (0, NULL);
/* File length in bytes. */
dw2_asm_output_data_uleb128 (0, NULL);
#endif /* VMS_DEBUGGING_INFO */
}
if (dwarf_version < 5)
dw2_asm_output_data (1, 0, "End file name table");
}
/* Output one line number table into the .debug_line section. */
static void
output_one_line_info_table (dw_line_info_table *table)
{
char line_label[MAX_ARTIFICIAL_LABEL_BYTES];
unsigned int current_line = 1;
bool current_is_stmt = DWARF_LINE_DEFAULT_IS_STMT_START;
dw_line_info_entry *ent, *prev_addr;
size_t i;
unsigned int view;
view = 0;
FOR_EACH_VEC_SAFE_ELT (table->entries, i, ent)
{
switch (ent->opcode)
{
case LI_set_address:
/* ??? Unfortunately, we have little choice here currently, and
must always use the most general form. GCC does not know the
address delta itself, so we can't use DW_LNS_advance_pc. Many
ports do have length attributes which will give an upper bound
on the address range. We could perhaps use length attributes
to determine when it is safe to use DW_LNS_fixed_advance_pc. */
ASM_GENERATE_INTERNAL_LABEL (line_label, LINE_CODE_LABEL, ent->val);
view = 0;
/* This can handle any delta. This takes
4+DWARF2_ADDR_SIZE bytes. */
dw2_asm_output_data (1, 0, "set address %s%s", line_label,
debug_variable_location_views
? ", reset view to 0" : "");
dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL);
dw2_asm_output_data (1, DW_LNE_set_address, NULL);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, line_label, NULL);
prev_addr = ent;
break;
case LI_adv_address:
{
ASM_GENERATE_INTERNAL_LABEL (line_label, LINE_CODE_LABEL, ent->val);
char prev_label[MAX_ARTIFICIAL_LABEL_BYTES];
ASM_GENERATE_INTERNAL_LABEL (prev_label, LINE_CODE_LABEL, prev_addr->val);
view++;
dw2_asm_output_data (1, DW_LNS_fixed_advance_pc, "fixed advance PC, increment view to %i", view);
dw2_asm_output_delta (2, line_label, prev_label,
"from %s to %s", prev_label, line_label);
prev_addr = ent;
break;
}
case LI_set_line:
if (ent->val == current_line)
{
/* We still need to start a new row, so output a copy insn. */
dw2_asm_output_data (1, DW_LNS_copy,
"copy line %u", current_line);
}
else
{
int line_offset = ent->val - current_line;
int line_delta = line_offset - DWARF_LINE_BASE;
current_line = ent->val;
if (line_delta >= 0 && line_delta < (DWARF_LINE_RANGE - 1))
{
/* This can handle deltas from -10 to 234, using the current
definitions of DWARF_LINE_BASE and DWARF_LINE_RANGE.
This takes 1 byte. */
dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE + line_delta,
"line %u", current_line);
}
else
{
/* This can handle any delta. This takes at least 4 bytes,
depending on the value being encoded. */
dw2_asm_output_data (1, DW_LNS_advance_line,
"advance to line %u", current_line);
dw2_asm_output_data_sleb128 (line_offset, NULL);
dw2_asm_output_data (1, DW_LNS_copy, NULL);
}
}
break;
case LI_set_file:
dw2_asm_output_data (1, DW_LNS_set_file, "set file %u", ent->val);
dw2_asm_output_data_uleb128 (ent->val, "%u", ent->val);
break;
case LI_set_column:
dw2_asm_output_data (1, DW_LNS_set_column, "column %u", ent->val);
dw2_asm_output_data_uleb128 (ent->val, "%u", ent->val);
break;
case LI_negate_stmt:
current_is_stmt = !current_is_stmt;
dw2_asm_output_data (1, DW_LNS_negate_stmt,
"is_stmt %d", current_is_stmt);
break;
case LI_set_prologue_end:
dw2_asm_output_data (1, DW_LNS_set_prologue_end,
"set prologue end");
break;
case LI_set_epilogue_begin:
dw2_asm_output_data (1, DW_LNS_set_epilogue_begin,
"set epilogue begin");
break;
case LI_set_discriminator:
dw2_asm_output_data (1, 0, "discriminator %u", ent->val);
dw2_asm_output_data_uleb128 (1 + size_of_uleb128 (ent->val), NULL);
dw2_asm_output_data (1, DW_LNE_set_discriminator, NULL);
dw2_asm_output_data_uleb128 (ent->val, NULL);
break;
}
}
/* Emit debug info for the address of the end of the table. */
dw2_asm_output_data (1, 0, "set address %s", table->end_label);
dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL);
dw2_asm_output_data (1, DW_LNE_set_address, NULL);
dw2_asm_output_addr (DWARF2_ADDR_SIZE, table->end_label, NULL);
dw2_asm_output_data (1, 0, "end sequence");
dw2_asm_output_data_uleb128 (1, NULL);
dw2_asm_output_data (1, DW_LNE_end_sequence, NULL);
}
/* Output the source line number correspondence information. This
information goes into the .debug_line section. */
static void
output_line_info (bool prologue_only)
{
static unsigned int generation;
char l1[MAX_ARTIFICIAL_LABEL_BYTES], l2[MAX_ARTIFICIAL_LABEL_BYTES];
char p1[MAX_ARTIFICIAL_LABEL_BYTES], p2[MAX_ARTIFICIAL_LABEL_BYTES];
bool saw_one = false;
int opc;
ASM_GENERATE_INTERNAL_LABEL (l1, LINE_NUMBER_BEGIN_LABEL, generation);
ASM_GENERATE_INTERNAL_LABEL (l2, LINE_NUMBER_END_LABEL, generation);
ASM_GENERATE_INTERNAL_LABEL (p1, LN_PROLOG_AS_LABEL, generation);
ASM_GENERATE_INTERNAL_LABEL (p2, LN_PROLOG_END_LABEL, generation++);
if (!XCOFF_DEBUGGING_INFO)
{
if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
dw2_asm_output_data (4, 0xffffffff,
"Initial length escape value indicating 64-bit DWARF extension");
dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
"Length of Source Line Info");
}
ASM_OUTPUT_LABEL (asm_out_file, l1);
output_dwarf_version ();
if (dwarf_version >= 5)
{
dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Address Size");
dw2_asm_output_data (1, 0, "Segment Size");
}
dw2_asm_output_delta (DWARF_OFFSET_SIZE, p2, p1, "Prolog Length");
ASM_OUTPUT_LABEL (asm_out_file, p1);
/* Define the architecture-dependent minimum instruction length (in bytes).
In this implementation of DWARF, this field is used for information
purposes only. Since GCC generates assembly language, we have no
a priori knowledge of how many instruction bytes are generated for each
source line, and therefore can use only the DW_LNE_set_address and
DW_LNS_fixed_advance_pc line information commands. Accordingly, we fix
this as '1', which is "correct enough" for all architectures,
and don't let the target override. */
dw2_asm_output_data (1, 1, "Minimum Instruction Length");
if (dwarf_version >= 4)
dw2_asm_output_data (1, DWARF_LINE_DEFAULT_MAX_OPS_PER_INSN,
"Maximum Operations Per Instruction");
dw2_asm_output_data (1, DWARF_LINE_DEFAULT_IS_STMT_START,
"Default is_stmt_start flag");
dw2_asm_output_data (1, DWARF_LINE_BASE,
"Line Base Value (Special Opcodes)");
dw2_asm_output_data (1, DWARF_LINE_RANGE,
"Line Range Value (Special Opcodes)");
dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE,
"Special Opcode Base");
for (opc = 1; opc < DWARF_LINE_OPCODE_BASE; opc++)
{
int n_op_args;
switch (opc)
{
case DW_LNS_advance_pc:
case DW_LNS_advance_line:
case DW_LNS_set_file:
case DW_LNS_set_column:
case DW_LNS_fixed_advance_pc:
case DW_LNS_set_isa:
n_op_args = 1;
break;
default:
n_op_args = 0;
break;
}
dw2_asm_output_data (1, n_op_args, "opcode: %#x has %d args",
opc, n_op_args);
}
/* Write out the information about the files we use. */
output_file_names ();
ASM_OUTPUT_LABEL (asm_out_file, p2);
if (prologue_only)
{
/* Output the marker for the end of the line number info. */
ASM_OUTPUT_LABEL (asm_out_file, l2);
return;
}
if (separate_line_info)
{
dw_line_info_table *table;
size_t i;
FOR_EACH_VEC_ELT (*separate_line_info, i, table)
if (table->in_use)
{
output_one_line_info_table (table);
saw_one = true;
}
}
if (cold_text_section_line_info && cold_text_section_line_info->in_use)
{
output_one_line_info_table (cold_text_section_line_info);
saw_one = true;
}
/* ??? Some Darwin linkers crash on a .debug_line section with no
sequences. Further, merely a DW_LNE_end_sequence entry is not
sufficient -- the address column must also be initialized.
Make sure to output at least one set_address/end_sequence pair,
choosing .text since that section is always present. */
if (text_section_line_info->in_use || !saw_one)
output_one_line_info_table (text_section_line_info);
/* Output the marker for the end of the line number info. */
ASM_OUTPUT_LABEL (asm_out_file, l2);
}
/* Return true if DW_AT_endianity should be emitted according to REVERSE. */
static inline bool
need_endianity_attribute_p (bool reverse)
{
return reverse && (dwarf_version >= 3 || !dwarf_strict);
}
/* Given a pointer to a tree node for some base type, return a pointer to
a DIE that describes the given type. REVERSE is true if the type is
to be interpreted in the reverse storage order wrt the target order.
This routine must only be called for GCC type nodes that correspond to
Dwarf base (fundamental) types. */
static dw_die_ref
base_type_die (tree type, bool reverse)
{
dw_die_ref base_type_result;
enum dwarf_type encoding;
bool fpt_used = false;
struct fixed_point_type_info fpt_info;
tree type_bias = NULL_TREE;
/* If this is a subtype that should not be emitted as a subrange type,
use the base type. See subrange_type_for_debug_p. */
if (TREE_CODE (type) == INTEGER_TYPE && TREE_TYPE (type) != NULL_TREE)
type = TREE_TYPE (type);
switch (TREE_CODE (type))
{
case INTEGER_TYPE:
if ((dwarf_version >= 4 || !dwarf_strict)
&& TYPE_NAME (type)
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& DECL_IS_UNDECLARED_BUILTIN (TYPE_NAME (type))
&& DECL_NAME (TYPE_NAME (type)))
{
const char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
if (strcmp (name, "char16_t") == 0
|| strcmp (name, "char32_t") == 0)
{
encoding = DW_ATE_UTF;
break;
}
}
if ((dwarf_version >= 3 || !dwarf_strict)
&& lang_hooks.types.get_fixed_point_type_info)
{
memset (&fpt_info, 0, sizeof (fpt_info));
if (lang_hooks.types.get_fixed_point_type_info (type, &fpt_info))
{
fpt_used = true;
encoding = ((TYPE_UNSIGNED (type))
? DW_ATE_unsigned_fixed
: DW_ATE_signed_fixed);
break;
}
}
if (TYPE_STRING_FLAG (type))
{
if (TYPE_UNSIGNED (type))
encoding = DW_ATE_unsigned_char;
else
encoding = DW_ATE_signed_char;
}
else if (TYPE_UNSIGNED (type))
encoding = DW_ATE_unsigned;
else
encoding = DW_ATE_signed;
if (!dwarf_strict
&& lang_hooks.types.get_type_bias)
type_bias = lang_hooks.types.get_type_bias (type);
break;
case REAL_TYPE:
if (DECIMAL_FLOAT_MODE_P (TYPE_MODE (type)))
{
if (dwarf_version >= 3 || !dwarf_strict)
encoding = DW_ATE_decimal_float;
else
encoding = DW_ATE_lo_user;
}
else
encoding = DW_ATE_float;
break;
case FIXED_POINT_TYPE:
if (!(dwarf_version >= 3 || !dwarf_strict))
encoding = DW_ATE_lo_user;
else if (TYPE_UNSIGNED (type))
encoding = DW_ATE_unsigned_fixed;
else
encoding = DW_ATE_signed_fixed;
break;
/* Dwarf2 doesn't know anything about complex ints, so use
a user defined type for it. */
case COMPLEX_TYPE:
if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
encoding = DW_ATE_complex_float;
else
encoding = DW_ATE_lo_user;
break;
case BOOLEAN_TYPE:
/* GNU FORTRAN/Ada/C++ BOOLEAN type. */
encoding = DW_ATE_boolean;
break;
default:
/* No other TREE_CODEs are Dwarf fundamental types. */
gcc_unreachable ();
}
base_type_result = new_die_raw (DW_TAG_base_type);
add_AT_unsigned (base_type_result, DW_AT_byte_size,
int_size_in_bytes (type));
add_AT_unsigned (base_type_result, DW_AT_encoding, encoding);
if (need_endianity_attribute_p (reverse))
add_AT_unsigned (base_type_result, DW_AT_endianity,
BYTES_BIG_ENDIAN ? DW_END_little : DW_END_big);
add_alignment_attribute (base_type_result, type);
if (fpt_used)
{
switch (fpt_info.scale_factor_kind)
{
case fixed_point_scale_factor_binary:
add_AT_int (base_type_result, DW_AT_binary_scale,
fpt_info.scale_factor.binary);
break;
case fixed_point_scale_factor_decimal:
add_AT_int (base_type_result, DW_AT_decimal_scale,
fpt_info.scale_factor.decimal);
break;
case fixed_point_scale_factor_arbitrary:
/* Arbitrary scale factors cannot be described in standard DWARF. */
if (!dwarf_strict)
{
/* Describe the scale factor as a rational constant. */
const dw_die_ref scale_factor
= new_die (DW_TAG_constant, comp_unit_die (), type);
add_scalar_info (scale_factor, DW_AT_GNU_numerator,
fpt_info.scale_factor.arbitrary.numerator,
dw_scalar_form_constant, NULL);
add_scalar_info (scale_factor, DW_AT_GNU_denominator,
fpt_info.scale_factor.arbitrary.denominator,
dw_scalar_form_constant, NULL);
add_AT_die_ref (base_type_result, DW_AT_small, scale_factor);
}
break;
default:
gcc_unreachable ();
}
}
if (type_bias)
add_scalar_info (base_type_result, DW_AT_GNU_bias, type_bias,
dw_scalar_form_constant
| dw_scalar_form_exprloc
| dw_scalar_form_reference,
NULL);
return base_type_result;
}
/* A C++ function with deduced return type can have a TEMPLATE_TYPE_PARM
named 'auto' in its type: return true for it, false otherwise. */
static inline bool
is_cxx_auto (tree type)
{
if (is_cxx ())
{
tree name = TYPE_IDENTIFIER (type);
if (name == get_identifier ("auto")
|| name == get_identifier ("decltype(auto)"))
return true;
}
return false;
}
/* Given a pointer to an arbitrary ..._TYPE tree node, return nonzero if the
given input type is a Dwarf "fundamental" type. Otherwise return null. */
static inline int
is_base_type (tree type)
{
switch (TREE_CODE (type))
{
case INTEGER_TYPE:
case REAL_TYPE:
case FIXED_POINT_TYPE:
case COMPLEX_TYPE:
case BOOLEAN_TYPE:
return 1;
case VOID_TYPE:
case OPAQUE_TYPE:
case ARRAY_TYPE:
case RECORD_TYPE:
case UNION_TYPE:
case QUAL_UNION_TYPE:
case ENUMERAL_TYPE:
case FUNCTION_TYPE:
case METHOD_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
case NULLPTR_TYPE:
case OFFSET_TYPE:
case LANG_TYPE:
case VECTOR_TYPE:
return 0;
default:
if (is_cxx_auto (type))
return 0;
gcc_unreachable ();
}
return 0;
}
/* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
node, return the size in bits for the type if it is a constant, or else
return the alignment for the type if the type's size is not constant, or
else return BITS_PER_WORD if the type actually turns out to be an
ERROR_MARK node. */
static inline unsigned HOST_WIDE_INT
simple_type_size_in_bits (const_tree type)
{
if (TREE_CODE (type) == ERROR_MARK)
return BITS_PER_WORD;
else if (TYPE_SIZE (type) == NULL_TREE)
return 0;
else if (tree_fits_uhwi_p (TYPE_SIZE (type)))
return tree_to_uhwi (TYPE_SIZE (type));
else
return TYPE_ALIGN (type);
}
/* Similarly, but return an offset_int instead of UHWI. */
static inline offset_int
offset_int_type_size_in_bits (const_tree type)
{
if (TREE_CODE (type) == ERROR_MARK)
return BITS_PER_WORD;
else if (TYPE_SIZE (type) == NULL_TREE)
return 0;
else if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
return wi::to_offset (TYPE_SIZE (type));
else
return TYPE_ALIGN (type);
}
/* Given a pointer to a tree node for a subrange type, return a pointer
to a DIE that describes the given type. */
static dw_die_ref
subrange_type_die (tree type, tree low, tree high, tree bias,
dw_die_ref context_die)
{
dw_die_ref subrange_die;
const HOST_WIDE_INT size_in_bytes = int_size_in_bytes (type);
if (context_die == NULL)
context_die = comp_unit_die ();
subrange_die = new_die (DW_TAG_subrange_type, context_die, type);
if (int_size_in_bytes (TREE_TYPE (type)) != size_in_bytes)
{
/* The size of the subrange type and its base type do not match,
so we need to generate a size attribute for the subrange type. */
add_AT_unsigned (subrange_die, DW_AT_byte_size, size_in_bytes);
}
add_alignment_attribute (subrange_die, type);
if (low)
add_bound_info (subrange_die, DW_AT_lower_bound, low, NULL);
if (high)
add_bound_info (subrange_die, DW_AT_upper_bound, high, NULL);
if (bias && !dwarf_strict)
add_scalar_info (subrange_die, DW_AT_GNU_bias, bias,
dw_scalar_form_constant
| dw_scalar_form_exprloc
| dw_scalar_form_reference,
NULL);
return subrange_die;
}
/* Returns the (const and/or volatile) cv_qualifiers associated with
the decl node. This will normally be augmented with the
cv_qualifiers of the underlying type in add_type_attribute. */
static int
decl_quals (const_tree decl)
{
return ((TREE_READONLY (decl)
/* The C++ front-end correctly marks reference-typed
variables as readonly, but from a language (and debug
info) standpoint they are not const-qualified. */
&& TREE_CODE (TREE_TYPE (decl)) != REFERENCE_TYPE
? TYPE_QUAL_CONST : TYPE_UNQUALIFIED)
| (TREE_THIS_VOLATILE (decl)
? TYPE_QUAL_VOLATILE : TYPE_UNQUALIFIED));
}
/* Determine the TYPE whose qualifiers match the largest strict subset
of the given TYPE_QUALS, and return its qualifiers. Ignore all
qualifiers outside QUAL_MASK. */
static int
get_nearest_type_subqualifiers (tree type, int type_quals, int qual_mask)
{
tree t;
int best_rank = 0, best_qual = 0, max_rank;
type_quals &= qual_mask;
max_rank = popcount_hwi (type_quals) - 1;
for (t = TYPE_MAIN_VARIANT (type); t && best_rank < max_rank;
t = TYPE_NEXT_VARIANT (t))
{
int q = TYPE_QUALS (t) & qual_mask;
if ((q & type_quals) == q && q != type_quals
&& check_base_type (t, type))
{
int rank = popcount_hwi (q);
if (rank > best_rank)
{
best_rank = rank;
best_qual = q;
}
}
}
return best_qual;
}
struct dwarf_qual_info_t { int q; enum dwarf_tag t; };
static const dwarf_qual_info_t dwarf_qual_info[] =
{
{ TYPE_QUAL_CONST, DW_TAG_const_type },
{ TYPE_QUAL_VOLATILE, DW_TAG_volatile_type },
{ TYPE_QUAL_RESTRICT, DW_TAG_restrict_type },
{ TYPE_QUAL_ATOMIC, DW_TAG_atomic_type }
};
static const unsigned int dwarf_qual_info_size
= sizeof (dwarf_qual_info) / sizeof (dwarf_qual_info[0]);
/* If DIE is a qualified DIE of some base DIE with the same parent,
return the base DIE, otherwise return NULL. Set MASK to the
qualifiers added compared to the returned DIE. */
static dw_die_ref
qualified_die_p (dw_die_ref die, int *mask, unsigned int depth)
{
unsigned int i;
for (i = 0; i < dwarf_qual_info_size; i++)
if (die->die_tag == dwarf_qual_info[i].t)
break;
if (i == dwarf_qual_info_size)
return NULL;
if (vec_safe_length (die->die_attr) != 1)
return NULL;
dw_die_ref type = get_AT_ref (die, DW_AT_type);
if (type == NULL || type->die_parent != die->die_parent)
return NULL;
*mask |= dwarf_qual_info[i].q;
if (depth)
{
dw_die_ref ret = qualified_die_p (type, mask, depth - 1);
if (ret)
return ret;
}
return type;
}
/* Given a pointer to an arbitrary ..._TYPE tree node, return a debugging
entry that chains the modifiers specified by CV_QUALS in front of the
given type. REVERSE is true if the type is to be interpreted in the
reverse storage order wrt the target order. */
static dw_die_ref
modified_type_die (tree type, int cv_quals, bool reverse,
dw_die_ref context_die)
{
enum tree_code code = TREE_CODE (type);
dw_die_ref mod_type_die;
dw_die_ref sub_die = NULL;
tree item_type = NULL;
tree qualified_type;
tree name, low, high;
dw_die_ref mod_scope;
/* Only these cv-qualifiers are currently handled. */
const int cv_qual_mask = (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE
| TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC |
ENCODE_QUAL_ADDR_SPACE(~0U));
const bool reverse_base_type
= need_endianity_attribute_p (reverse) && is_base_type (type);
if (code == ERROR_MARK)
return NULL;
if (lang_hooks.types.get_debug_type)
{
tree debug_type = lang_hooks.types.get_debug_type (type);
if (debug_type != NULL_TREE && debug_type != type)
return modified_type_die (debug_type, cv_quals, reverse, context_die);
}
cv_quals &= cv_qual_mask;
/* Don't emit DW_TAG_restrict_type for DWARFv2, since it is a type
tag modifier (and not an attribute) old consumers won't be able
to handle it. */
if (dwarf_version < 3)
cv_quals &= ~TYPE_QUAL_RESTRICT;
/* Likewise for DW_TAG_atomic_type for DWARFv5. */
if (dwarf_version < 5)
cv_quals &= ~TYPE_QUAL_ATOMIC;
/* See if we already have the appropriately qualified variant of
this type. */
qualified_type = get_qualified_type (type, cv_quals);
if (qualified_type == sizetype)
{
/* Try not to expose the internal sizetype type's name. */
if (TYPE_NAME (qualified_type)
&& TREE_CODE (TYPE_NAME (qualified_type)) == TYPE_DECL)
{
tree t = TREE_TYPE (TYPE_NAME (qualified_type));
gcc_checking_assert (TREE_CODE (t) == INTEGER_TYPE
&& (TYPE_PRECISION (t)
== TYPE_PRECISION (qualified_type))
&& (TYPE_UNSIGNED (t)
== TYPE_UNSIGNED (qualified_type)));
qualified_type = t;
}
else if (qualified_type == sizetype
&& TREE_CODE (sizetype) == TREE_CODE (size_type_node)
&& TYPE_PRECISION (sizetype) == TYPE_PRECISION (size_type_node)
&& TYPE_UNSIGNED (sizetype) == TYPE_UNSIGNED (size_type_node))
qualified_type = size_type_node;
if (type == sizetype)
type = qualified_type;
}
/* If we do, then we can just use its DIE, if it exists. */
if (qualified_type)
{
mod_type_die = lookup_type_die (qualified_type);
/* DW_AT_endianity doesn't come from a qualifier on the type, so it is
dealt with specially: the DIE with the attribute, if it exists, is
placed immediately after the regular DIE for the same base type. */
if (mod_type_die
&& (!reverse_base_type
|| ((mod_type_die = mod_type_die->die_sib) != NULL
&& get_AT_unsigned (mod_type_die, DW_AT_endianity))))
return mod_type_die;
}
name = qualified_type ? TYPE_NAME (qualified_type) : NULL;
/* Handle C typedef types. */
if (name
&& TREE_CODE (name) == TYPE_DECL
&& DECL_ORIGINAL_TYPE (name)
&& !DECL_ARTIFICIAL (name))
{
tree dtype = TREE_TYPE (name);
/* Skip the typedef for base types with DW_AT_endianity, no big deal. */
if (qualified_type == dtype && !reverse_base_type)
{
tree origin = decl_ultimate_origin (name);
/* Typedef variants that have an abstract origin don't get their own
type DIE (see gen_typedef_die), so fall back on the ultimate
abstract origin instead. */
if (origin != NULL && origin != name)
return modified_type_die (TREE_TYPE (origin), cv_quals, reverse,
context_die);
/* For a named type, use the typedef. */
gen_type_die (qualified_type, context_die);
return lookup_type_die (qualified_type);
}
else
{
int dquals = TYPE_QUALS_NO_ADDR_SPACE (dtype);
dquals &= cv_qual_mask;
if ((dquals & ~cv_quals) != TYPE_UNQUALIFIED
|| (cv_quals == dquals && DECL_ORIGINAL_TYPE (name) != type))
/* cv-unqualified version of named type. Just use
the unnamed type to which it refers. */
return modified_type_die (DECL_ORIGINAL_TYPE (name), cv_quals,
reverse, context_die);
/* Else cv-qualified version of named type; fall through. */
}
}
mod_scope = scope_die_for (type, context_die);
if (cv_quals)
{
int sub_quals = 0, first_quals = 0;
unsigned i;
dw_die_ref first = NULL, last = NULL;
/* Determine a lesser qualified type that most closely matches
this one. Then generate DW_TAG_* entries for the remaining
qualifiers. */
sub_quals = get_nearest_type_subqualifiers (type, cv_quals,
cv_qual_mask);
if (sub_quals && use_debug_types)
{
bool needed = false;
/* If emitting type units, make sure the order of qualifiers
is canonical. Thus, start from unqualified type if
an earlier qualifier is missing in sub_quals, but some later
one is present there. */
for (i = 0; i < dwarf_qual_info_size; i++)
if (dwarf_qual_info[i].q & cv_quals & ~sub_quals)
needed = true;
else if (needed && (dwarf_qual_info[i].q & cv_quals))
{
sub_quals = 0;
break;
}
}
mod_type_die = modified_type_die (type, sub_quals, reverse, context_die);
if (mod_scope && mod_type_die && mod_type_die->die_parent == mod_scope)
{
/* As not all intermediate qualified DIEs have corresponding
tree types, ensure that qualified DIEs in the same scope
as their DW_AT_type are emitted after their DW_AT_type,
only with other qualified DIEs for the same type possibly
in between them. Determine the range of such qualified
DIEs now (first being the base type, last being corresponding
last qualified DIE for it). */
unsigned int count = 0;
first = qualified_die_p (mod_type_die, &first_quals,
dwarf_qual_info_size);
if (first == NULL)
first = mod_type_die;
gcc_assert ((first_quals & ~sub_quals) == 0);
for (count = 0, last = first;
count < (1U << dwarf_qual_info_size);
count++, last = last->die_sib)
{
int quals = 0;
if (last == mod_scope->die_child)
break;
if (qualified_die_p (last->die_sib, &quals, dwarf_qual_info_size)
!= first)
break;
}
}
for (i = 0; i < dwarf_qual_info_size; i++)
if (dwarf_qual_info[i].q & cv_quals & ~sub_quals)
{
dw_die_ref d;
if (first && first != last)
{
for (d = first->die_sib; ; d = d->die_sib)
{
int quals = 0;
qualified_die_p (d, &quals, dwarf_qual_info_size);
if (quals == (first_quals | dwarf_qual_info[i].q))
break;
if (d == last)
{
d = NULL;
break;
}
}
if (d)
{
mod_type_die = d;
continue;
}
}
if (first)
{
d = new_die_raw (dwarf_qual_info[i].t);
add_child_die_after (mod_scope, d, last);
last = d;
}
else
d = new_die (dwarf_qual_info[i].t, mod_scope, type);
if (mod_type_die)
add_AT_die_ref (d, DW_AT_type, mod_type_die);
mod_type_die = d;
first_quals |= dwarf_qual_info[i].q;
}
}
else if (code == POINTER_TYPE || code == REFERENCE_TYPE)
{
dwarf_tag tag = DW_TAG_pointer_type;
if (code == REFERENCE_TYPE)
{
if (TYPE_REF_IS_RVALUE (type) && dwarf_version >= 4)
tag = DW_TAG_rvalue_reference_type;
else
tag = DW_TAG_reference_type;
}
mod_type_die = new_die (tag, mod_scope, type);
add_AT_unsigned (mod_type_die, DW_AT_byte_size,
simple_type_size_in_bits (type) / BITS_PER_UNIT);
add_alignment_attribute (mod_type_die, type);
item_type = TREE_TYPE (type);
addr_space_t as = TYPE_ADDR_SPACE (item_type);
if (!ADDR_SPACE_GENERIC_P (as))
{
int action = targetm.addr_space.debug (as);
if (action >= 0)
{
/* Positive values indicate an address_class. */
add_AT_unsigned (mod_type_die, DW_AT_address_class, action);
}
else
{
/* Negative values indicate an (inverted) segment base reg. */
dw_loc_descr_ref d
= one_reg_loc_descriptor (~action, VAR_INIT_STATUS_INITIALIZED);
add_AT_loc (mod_type_die, DW_AT_segment, d);
}
}
}
else if (code == INTEGER_TYPE
&& TREE_TYPE (type) != NULL_TREE
&& subrange_type_for_debug_p (type, &low, &high))
{
tree bias = NULL_TREE;
if (lang_hooks.types.get_type_bias)
bias = lang_hooks.types.get_type_bias (type);
mod_type_die = subrange_type_die (type, low, high, bias, context_die);
item_type = TREE_TYPE (type);
}
else if (is_base_type (type))
{
mod_type_die = base_type_die (type, reverse);
/* The DIE with DW_AT_endianity is placed right after the naked DIE. */
if (reverse_base_type)
{
dw_die_ref after_die
= modified_type_die (type, cv_quals, false, context_die);
add_child_die_after (comp_unit_die (), mod_type_die, after_die);
}
else
add_child_die (comp_unit_die (), mod_type_die);
add_pubtype (type, mod_type_die);
}
else
{
gen_type_die (type, context_die);
/* We have to get the type_main_variant here (and pass that to the
`lookup_type_die' routine) because the ..._TYPE node we have
might simply be a *copy* of some original type node (where the
copy was created to help us keep track of typedef names) and
that copy might have a different TYPE_UID from the original
..._TYPE node. */
if (TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == METHOD_TYPE)
{
/* For function/method types, can't just use type_main_variant here,
because that can have different ref-qualifiers for C++,
but try to canonicalize. */
tree main = TYPE_MAIN_VARIANT (type);
for (tree t = main; t; t = TYPE_NEXT_VARIANT (t))
if (TYPE_QUALS_NO_ADDR_SPACE (t) == 0
&& check_base_type (t, main)
&& check_lang_type (t, type))
return lookup_type_die (t);
return lookup_type_die (type);
}
else if (TREE_CODE (type) != VECTOR_TYPE
&& TREE_CODE (type) != ARRAY_TYPE)
return lookup_type_die (type_main_variant (type));
else
/* Vectors have the debugging information in the type,
not the main variant. */
return lookup_type_die (type);
}
/* Builtin types don't have a DECL_ORIGINAL_TYPE. For those,
don't output a DW_TAG_typedef, since there isn't one in the
user's program; just attach a DW_AT_name to the type.
Don't attach a DW_AT_name to DW_TAG_const_type or DW_TAG_volatile_type
if the base type already has the same name. */
if (name
&& ((TREE_CODE (name) != TYPE_DECL
&& (qualified_type == TYPE_MAIN_VARIANT (type)
|| (cv_quals == TYPE_UNQUALIFIED)))
|| (TREE_CODE (name) == TYPE_DECL
&& TREE_TYPE (name) == qualified_type
&& DECL_NAME (name))))
{
if (TREE_CODE (name) == TYPE_DECL)
/* Could just call add_name_and_src_coords_attributes here,
but since this is a builtin type it doesn't have any
useful source coordinates anyway. */
name = DECL_NAME (name);
add_name_attribute (mod_type_die, IDENTIFIER_POINTER (name));
}
/* This probably indicates a bug. */
else if (mod_type_die && mod_type_die->die_tag == DW_TAG_base_type)
{
name = TYPE_IDENTIFIER (type);
add_name_attribute (mod_type_die,
name ? IDENTIFIER_POINTER (name) : "__unknown__");
}
if (qualified_type && !reverse_base_type)
equate_type_number_to_die (qualified_type, mod_type_die);
if (item_type)
/* We must do this after the equate_type_number_to_die call, in case
this is a recursive type. This ensures that the modified_type_die
recursion will terminate even if the type is recursive. Recursive
types are possible in Ada. */
sub_die = modified_type_die (item_type,
TYPE_QUALS_NO_ADDR_SPACE (item_type),
reverse,
context_die);
if (sub_die != NULL)
add_AT_die_ref (mod_type_die, DW_AT_type, sub_die);
add_gnat_descriptive_type_attribute (mod_type_die, type, context_die);
if (TYPE_ARTIFICIAL (type))
add_AT_flag (mod_type_die, DW_AT_artificial, 1);
return mod_type_die;
}
/* Generate DIEs for the generic parameters of T.
T must be either a generic type or a generic function.
See http://gcc.gnu.org/wiki/TemplateParmsDwarf for more. */
static void
gen_generic_params_dies (tree t)
{
tree parms, args;
int parms_num, i;
dw_die_ref die = NULL;
int non_default;
if (!t || (TYPE_P (t) && !COMPLETE_TYPE_P (t)))
return;
if (TYPE_P (t))
die = lookup_type_die (t);
else if (DECL_P (t))
die = lookup_decl_die (t);
gcc_assert (die);
parms = lang_hooks.get_innermost_generic_parms (t);
if (!parms)
/* T has no generic parameter. It means T is neither a generic type
or function. End of story. */
return;
parms_num = TREE_VEC_LENGTH (parms);
args = lang_hooks.get_innermost_generic_args (t);
if (TREE_CHAIN (args) && TREE_CODE (TREE_CHAIN (args)) == INTEGER_CST)
non_default = int_cst_value (TREE_CHAIN (args));
else
non_default = TREE_VEC_LENGTH (args);
for (i = 0; i < parms_num; i++)
{
tree parm, arg, arg_pack_elems;
dw_die_ref parm_die;
parm = TREE_VEC_ELT (parms, i);
arg = TREE_VEC_ELT (args, i);
arg_pack_elems = lang_hooks.types.get_argument_pack_elems (arg);
gcc_assert (parm && TREE_VALUE (parm) && arg);
if (parm && TREE_VALUE (parm) && arg)
{
/* If PARM represents a template parameter pack,
emit a DW_TAG_GNU_template_parameter_pack DIE, followed
by DW_TAG_template_*_parameter DIEs for the argument
pack elements of ARG. Note that ARG would then be
an argument pack. */
if (arg_pack_elems)
parm_die = template_parameter_pack_die (TREE_VALUE (parm),
arg_pack_elems,
die);
else
parm_die = generic_parameter_die (TREE_VALUE (parm), arg,
true /* emit name */, die);
if (i >= non_default)
add_AT_flag (parm_die, DW_AT_default_value, 1);
}
}
}
/* Create and return a DIE for PARM which should be
the representation of a generic type parameter.
For instance, in the C++ front end, PARM would be a template parameter.
ARG is the argument to PARM.
EMIT_NAME_P if tree, the DIE will have DW_AT_name attribute set to the
name of the PARM.
PARENT_DIE is the parent DIE which the new created DIE should be added to,
as a child node. */
static dw_die_ref
generic_parameter_die (tree parm, tree arg,
bool emit_name_p,
dw_die_ref parent_die)
{
dw_die_ref tmpl_die = NULL;
const char *name = NULL;
/* C++20 accepts class literals as template parameters, and var
decls with initializers represent them. The VAR_DECLs would be
rejected, but we can take the DECL_INITIAL constructor and
attempt to expand it. */
if (arg && VAR_P (arg))
arg = DECL_INITIAL (arg);
if (!parm || !DECL_NAME (parm) || !arg)
return NULL;
/* We support non-type generic parameters and arguments,
type generic parameters and arguments, as well as
generic generic parameters (a.k.a. template template parameters in C++)
and arguments. */
if (TREE_CODE (parm) == PARM_DECL)
/* PARM is a nontype generic parameter */
tmpl_die = new_die (DW_TAG_template_value_param, parent_die, parm);
else if (TREE_CODE (parm) == TYPE_DECL)
/* PARM is a type generic parameter. */
tmpl_die = new_die (DW_TAG_template_type_param, parent_die, parm);
else if (lang_hooks.decls.generic_generic_parameter_decl_p (parm))
/* PARM is a generic generic parameter.
Its DIE is a GNU extension. It shall have a
DW_AT_name attribute to represent the name of the template template
parameter, and a DW_AT_GNU_template_name attribute to represent the
name of the template template argument. */
tmpl_die = new_die (DW_TAG_GNU_template_template_param,
parent_die, parm);
else
gcc_unreachable ();
if (tmpl_die)
{
tree tmpl_type;
/* If PARM is a generic parameter pack, it means we are
emitting debug info for a template argument pack element.
In other terms, ARG is a template argument pack element.
In that case, we don't emit any DW_AT_name attribute for
the die. */
if (emit_name_p)
{
name = IDENTIFIER_POINTER (DECL_NAME (parm));
gcc_assert (name);
add_AT_string (tmpl_die, DW_AT_name, name);
}
if (!lang_hooks.decls.generic_generic_parameter_decl_p (parm))
{
/* DWARF3, 5.6.8 says if PARM is a non-type generic parameter
TMPL_DIE should have a child DW_AT_type attribute that is set
to the type of the argument to PARM, which is ARG.
If PARM is a type generic parameter, TMPL_DIE should have a
child DW_AT_type that is set to ARG. */
tmpl_type = TYPE_P (arg) ? arg : TREE_TYPE (arg);
add_type_attribute (tmpl_die, tmpl_type,
(TREE_THIS_VOLATILE (tmpl_type)
? TYPE_QUAL_VOLATILE : TYPE_UNQUALIFIED),
false, parent_die);
}
else
{
/* So TMPL_DIE is a DIE representing a
a generic generic template parameter, a.k.a template template
parameter in C++ and arg is a template. */
/* The DW_AT_GNU_template_name attribute of the DIE must be set
to the name of the argument. */
name = dwarf2_name (TYPE_P (arg) ? TYPE_NAME (arg) : arg, 1);
if (name)
add_AT_string (tmpl_die, DW_AT_GNU_template_name, name);
}
if (TREE_CODE (parm) == PARM_DECL)
/* So PARM is a non-type generic parameter.
DWARF3 5.6.8 says we must set a DW_AT_const_value child
attribute of TMPL_DIE which value represents the value
of ARG.
We must be careful here:
The value of ARG might reference some function decls.
We might currently be emitting debug info for a generic
type and types are emitted before function decls, we don't
know if the function decls referenced by ARG will actually be
emitted after cgraph computations.
So must defer the generation of the DW_AT_const_value to
after cgraph is ready. */
append_entry_to_tmpl_value_parm_die_table (tmpl_die, arg);
}
return tmpl_die;
}
/* Generate and return a DW_TAG_GNU_template_parameter_pack DIE representing.
PARM_PACK must be a template parameter pack. The returned DIE
will be child DIE of PARENT_DIE. */
static dw_die_ref
template_parameter_pack_die (tree parm_pack,
tree parm_pack_args,
dw_die_ref parent_die)
{
dw_die_ref die;
int j;
gcc_assert (parent_die && parm_pack);
die = new_die (DW_TAG_GNU_template_parameter_pack, parent_die, parm_pack);
add_name_and_src_coords_attributes (die, parm_pack);
for (j = 0; j < TREE_VEC_LENGTH (parm_pack_args); j++)
generic_parameter_die (parm_pack,
TREE_VEC_ELT (parm_pack_args, j),
false /* Don't emit DW_AT_name */,
die);
return die;
}
/* Return the DBX register number described by a given RTL node. */
static unsigned int
dbx_reg_number (const_rtx rtl)
{
unsigned regno = REGNO (rtl);
gcc_assert (regno < FIRST_PSEUDO_REGISTER);
#ifdef LEAF_REG_REMAP
if (crtl->uses_only_leaf_regs)
{
int leaf_reg = LEAF_REG_REMAP (regno);
if (leaf_reg != -1)
regno = (unsigned) leaf_reg;
}
#endif
regno = DBX_REGISTER_NUMBER (regno);
gcc_assert (regno != INVALID_REGNUM);
return regno;
}
/* Optionally add a DW_OP_piece term to a location description expression.
DW_OP_piece is only added if the location description expression already
doesn't end with DW_OP_piece. */
static void
add_loc_descr_op_piece (dw_loc_descr_ref *list_head, int size)
{
dw_loc_descr_ref loc;
if (*list_head != NULL)
{
/* Find the end of the chain. */
for (loc = *list_head; loc->dw_loc_next != NULL; loc = loc->dw_loc_next)
;
if (loc->dw_loc_opc != DW_OP_piece)
loc->dw_loc_next = new_loc_descr (DW_OP_piece, size, 0);
}
}
/* Return a location descriptor that designates a machine register or
zero if there is none. */
static dw_loc_descr_ref
reg_loc_descriptor (rtx rtl, enum var_init_status initialized)
{
rtx regs;
if (REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
return 0;
/* We only use "frame base" when we're sure we're talking about the
post-prologue local stack frame. We do this by *not* running
register elimination until this point, and recognizing the special
argument pointer and soft frame pointer rtx's.
Use DW_OP_fbreg offset DW_OP_stack_value in this case. */
if ((rtl == arg_pointer_rtx || rtl == frame_pointer_rtx)
&& eliminate_regs (rtl, VOIDmode, NULL_RTX) != rtl)
{
dw_loc_descr_ref result = NULL;
if (dwarf_version >= 4 || !dwarf_strict)
{
result = mem_loc_descriptor (rtl, GET_MODE (rtl), VOIDmode,
initialized);
if (result)
add_loc_descr (&result,
new_loc_descr (DW_OP_stack_value, 0, 0));
}
return result;
}
regs = targetm.dwarf_register_span (rtl);
if (REG_NREGS (rtl) > 1 || regs)
return multiple_reg_loc_descriptor (rtl, regs, initialized);
else
{
unsigned int dbx_regnum = dbx_reg_number (rtl);
if (dbx_regnum == IGNORED_DWARF_REGNUM)
return 0;
return one_reg_loc_descriptor (dbx_regnum, initialized);
}
}
/* Return a location descriptor that designates a machine register for
a given hard register number. */
static dw_loc_descr_ref
one_reg_loc_descriptor (unsigned int regno, enum var_init_status initialized)
{
dw_loc_descr_ref reg_loc_descr;
if (regno <= 31)
reg_loc_descr
= new_loc_descr ((enum dwarf_location_atom) (DW_OP_reg0 + regno), 0, 0);
else
reg_loc_descr = new_loc_descr (DW_OP_regx, regno, 0);
if (initialized == VAR_INIT_STATUS_UNINITIALIZED)
add_loc_descr (®_loc_descr, new_loc_descr (DW_OP_GNU_uninit, 0, 0));
return reg_loc_descr;
}
/* Given an RTL of a register, return a location descriptor that
designates a value that spans more than one register. */
static dw_loc_descr_ref
multiple_reg_loc_descriptor (rtx rtl, rtx regs,
enum var_init_status initialized)
{
int size, i;
dw_loc_descr_ref loc_result = NULL;
/* Simple, contiguous registers. */
if (regs == NULL_RTX)
{
unsigned reg = REGNO (rtl);
int nregs;
#ifdef LEAF_REG_REMAP
if (crtl->uses_only_leaf_regs)
{
int leaf_reg = LEAF_REG_REMAP (reg);
if (leaf_reg != -1)
reg = (unsigned) leaf_reg;
}
#endif
gcc_assert ((unsigned) DBX_REGISTER_NUMBER (reg) == dbx_reg_number (rtl));
nregs = REG_NREGS (rtl);
/* At present we only track constant-sized pieces. */
if (!GET_MODE_SIZE (GET_MODE (rtl)).is_constant (&size))
return NULL;
size /= nregs;
loc_result = NULL;
while (nregs--)
{
dw_loc_descr_ref t;
t = one_reg_loc_descriptor (DBX_REGISTER_NUMBER (reg),
VAR_INIT_STATUS_INITIALIZED);
add_loc_descr (&loc_result, t);
add_loc_descr_op_piece (&loc_result, size);
++reg;
}
return loc_result;
}
/* Now onto stupid register sets in non contiguous locations. */
gcc_assert (GET_CODE (regs) == PARALLEL);
/* At present we only track constant-sized pieces. */
if (!GET_MODE_SIZE (GET_MODE (XVECEXP (regs, 0, 0))).is_constant (&size))
return NULL;
loc_result = NULL;
for (i = 0; i < XVECLEN (regs, 0); ++i)
{
dw_loc_descr_ref t;
t = one_reg_loc_descriptor (dbx_reg_number (XVECEXP (regs, 0, i)),
VAR_INIT_STATUS_INITIALIZED);
add_loc_descr (&loc_result, t);
add_loc_descr_op_piece (&loc_result, size);
}
if (loc_result && initialized == VAR_INIT_STATUS_UNINITIALIZED)
add_loc_descr (&loc_result, new_loc_descr (DW_OP_GNU_uninit, 0, 0));
return loc_result;
}
static unsigned long size_of_int_loc_descriptor (HOST_WIDE_INT);
/* Return a location descriptor that designates a constant i,
as a compound operation from constant (i >> shift), constant shift
and DW_OP_shl. */
static dw_loc_descr_ref
int_shift_loc_descriptor (HOST_WIDE_INT i, int shift)
{
dw_loc_descr_ref ret = int_loc_descriptor (i >> shift);
add_loc_descr (&ret, int_loc_descriptor (shift));
add_loc_descr (&ret, new_loc_descr (DW_OP_shl, 0, 0));
return ret;
}
/* Return a location descriptor that designates constant POLY_I. */
static dw_loc_descr_ref
int_loc_descriptor (poly_int64 poly_i)
{
enum dwarf_location_atom op;
HOST_WIDE_INT i;
if (!poly_i.is_constant (&i))
{
/* Create location descriptions for the non-constant part and
add any constant offset at the end. */
dw_loc_descr_ref ret = NULL;
HOST_WIDE_INT constant = poly_i.coeffs[0];
for (unsigned int j = 1; j < NUM_POLY_INT_COEFFS; ++j)
{
HOST_WIDE_INT coeff = poly_i.coeffs[j];
if (coeff != 0)
{
dw_loc_descr_ref start = ret;
unsigned int factor;
int bias;
unsigned int regno = targetm.dwarf_poly_indeterminate_value
(j, &factor, &bias);
/* Add COEFF * ((REGNO / FACTOR) - BIAS) to the value:
add COEFF * (REGNO / FACTOR) now and subtract
COEFF * BIAS from the final constant part. */
constant -= coeff * bias;
add_loc_descr (&ret, new_reg_loc_descr (regno, 0));
if (coeff % factor == 0)
coeff /= factor;
else
{
int amount = exact_log2 (factor);
gcc_assert (amount >= 0);
add_loc_descr (&ret, int_loc_descriptor (amount));
add_loc_descr (&ret, new_loc_descr (DW_OP_shr, 0, 0));
}
if (coeff != 1)
{
add_loc_descr (&ret, int_loc_descriptor (coeff));
add_loc_descr (&ret, new_loc_descr (DW_OP_mul, 0, 0));
}
if (start)
add_loc_descr (&ret, new_loc_descr (DW_OP_plus, 0, 0));
}
}
loc_descr_plus_const (&ret, constant);
return ret;
}
/* Pick the smallest representation of a constant, rather than just
defaulting to the LEB encoding. */
if (i >= 0)
{
int clz = clz_hwi (i);
int ctz = ctz_hwi (i);
if (i <= 31)
op = (enum dwarf_location_atom) (DW_OP_lit0 + i);
else if (i <= 0xff)
op = DW_OP_const1u;
else if (i <= 0xffff)
op = DW_OP_const2u;
else if (clz + ctz >= HOST_BITS_PER_WIDE_INT - 5
&& clz + 5 + 255 >= HOST_BITS_PER_WIDE_INT)
/* DW_OP_litX DW_OP_litY DW_OP_shl takes just 3 bytes and
DW_OP_litX DW_OP_const1u Y DW_OP_shl takes just 4 bytes,
while DW_OP_const4u is 5 bytes. */
return int_shift_loc_descriptor (i, HOST_BITS_PER_WIDE_INT - clz - 5);
else if (clz + ctz >= HOST_BITS_PER_WIDE_INT - 8
&& clz + 8 + 31 >= HOST_BITS_PER_WIDE_INT)
/* DW_OP_const1u X DW_OP_litY DW_OP_shl takes just 4 bytes,
while DW_OP_const4u is 5 bytes. */
return int_shift_loc_descriptor (i, HOST_BITS_PER_WIDE_INT - clz - 8);
else if (DWARF2_ADDR_SIZE == 4 && i > 0x7fffffff
&& size_of_int_loc_descriptor ((HOST_WIDE_INT) (int32_t) i)
<= 4)
{
/* As i >= 2**31, the double cast above will yield a negative number.
Since wrapping is defined in DWARF expressions we can output big
positive integers as small negative ones, regardless of the size
of host wide ints.
Here, since the evaluator will handle 32-bit values and since i >=
2**31, we know it's going to be interpreted as a negative literal:
store it this way if we can do better than 5 bytes this way. */
return int_loc_descriptor ((HOST_WIDE_INT) (int32_t) i);
}
else if (HOST_BITS_PER_WIDE_INT == 32 || i <= 0xffffffff)
op = DW_OP_const4u;
/* Past this point, i >= 0x100000000 and thus DW_OP_constu will take at
least 6 bytes: see if we can do better before falling back to it. */
else if (clz + ctz >= HOST_BITS_PER_WIDE_INT - 8
&& clz + 8 + 255 >= HOST_BITS_PER_WIDE_INT)
/* DW_OP_const1u X DW_OP_const1u Y DW_OP_shl takes just 5 bytes. */
return int_shift_loc_descriptor (i, HOST_BITS_PER_WIDE_INT - clz - 8);
else if (clz + ctz >= HOST_BITS_PER_WIDE_INT - 16
&& clz + 16 + (size_of_uleb128 (i) > 5 ? 255 : 31)
>= HOST_BITS_PER_WIDE_INT)
/* DW_OP_const2u X DW_OP_litY DW_OP_shl takes just 5 bytes,
DW_OP_const2u X DW_OP_const1u Y DW_OP_shl takes 6 bytes. */
return int_shift_loc_descriptor (i, HOST_BITS_PER_WIDE_INT - clz - 16);
else if (clz + ctz >= HOST_BITS_PER_WIDE_INT - 32
&& clz + 32 + 31 >= HOST_BITS_PER_WIDE_INT
&& size_of_uleb128 (i) > 6)
/* DW_OP_const4u X DW_OP_litY DW_OP_shl takes just 7 bytes. */
return int_shift_loc_descriptor (i, HOST_BITS_PER_WIDE_INT - clz - 32);
else
op = DW_OP_constu;
}
else
{
if (i >= -0x80)
op = DW_OP_const1s;
else if (i >= -0x8000)
op = DW_OP_const2s;
else if (HOST_BITS_PER_WIDE_INT == 32 || i >= -0x80000000)
{
if (size_of_int_loc_descriptor (i) < 5)
{
dw_loc_descr_ref ret = int_loc_descriptor (-i);
add_loc_descr (&ret, new_loc_descr (DW_OP_neg, 0, 0));
return ret;
}
op = DW_OP_const4s;
}
else
{
if (size_of_int_loc_descriptor (i)
< (unsigned long) 1 + size_of_sleb128 (i))
{
dw_loc_descr_ref ret = int_loc_descriptor (-i);
add_loc_descr (&ret, new_loc_descr (DW_OP_neg, 0, 0));
return ret;
}
op = DW_OP_consts;
}
}
return new_loc_descr (op, i, 0);
}
/* Likewise, for unsigned constants. */
static dw_loc_descr_ref
uint_loc_descriptor (unsigned HOST_WIDE_INT i)
{
const unsigned HOST_WIDE_INT max_int = INTTYPE_MAXIMUM (HOST_WIDE_INT);
const unsigned HOST_WIDE_INT max_uint
= INTTYPE_MAXIMUM (unsigned HOST_WIDE_INT);
/* If possible, use the clever signed constants handling. */
if (i <= max_int)
return int_loc_descriptor ((HOST_WIDE_INT) i);
/* Here, we are left with positive numbers that cannot be represented as
HOST_WIDE_INT, i.e.:
max (HOST_WIDE_INT) < i <= max (unsigned HOST_WIDE_INT)
Using DW_OP_const4/8/./u operation to encode them consumes a lot of bytes
whereas may be better to output a negative integer: thanks to integer
wrapping, we know that:
x = x - 2 ** DWARF2_ADDR_SIZE
= x - 2 * (max (HOST_WIDE_INT) + 1)
So numbers close to max (unsigned HOST_WIDE_INT) could be represented as
small negative integers. Let's try that in cases it will clearly improve
the encoding: there is no gain turning DW_OP_const4u into
DW_OP_const4s. */
if (DWARF2_ADDR_SIZE * 8 == HOST_BITS_PER_WIDE_INT
&& ((DWARF2_ADDR_SIZE == 4 && i > max_uint - 0x8000)
|| (DWARF2_ADDR_SIZE == 8 && i > max_uint - 0x80000000)))
{
const unsigned HOST_WIDE_INT first_shift = i - max_int - 1;
/* Now, -1 < first_shift <= max (HOST_WIDE_INT)
i.e. 0 <= first_shift <= max (HOST_WIDE_INT). */
const HOST_WIDE_INT second_shift
= (HOST_WIDE_INT) first_shift - (HOST_WIDE_INT) max_int - 1;
/* So we finally have:
-max (HOST_WIDE_INT) - 1 <= second_shift <= -1.
i.e. min (HOST_WIDE_INT) <= second_shift < 0. */
return int_loc_descriptor (second_shift);
}
/* Last chance: fallback to a simple constant operation. */
return new_loc_descr
((HOST_BITS_PER_WIDE_INT == 32 || i <= 0xffffffff)
? DW_OP_const4u
: DW_OP_const8u,
i, 0);
}
/* Generate and return a location description that computes the unsigned
comparison of the two stack top entries (a OP b where b is the top-most
entry and a is the second one). The KIND of comparison can be LT_EXPR,
LE_EXPR, GT_EXPR or GE_EXPR. */
static dw_loc_descr_ref
uint_comparison_loc_list (enum tree_code kind)
{
enum dwarf_location_atom op, flip_op;
dw_loc_descr_ref ret, bra_node, jmp_node, tmp;
switch (kind)
{
case LT_EXPR:
op = DW_OP_lt;
break;
case LE_EXPR:
op = DW_OP_le;
break;
case GT_EXPR:
op = DW_OP_gt;
break;
case GE_EXPR:
op = DW_OP_ge;
break;
default:
gcc_unreachable ();
}
bra_node = new_loc_descr (DW_OP_bra, 0, 0);
jmp_node = new_loc_descr (DW_OP_skip, 0, 0);
/* Until DWARFv4, operations all work on signed integers. It is nevertheless
possible to perform unsigned comparisons: we just have to distinguish
three cases:
1. when a and b have the same sign (as signed integers); then we should
return: a OP(signed) b;
2. when a is a negative signed integer while b is a positive one, then a
is a greater unsigned integer than b; likewise when a and b's roles
are flipped.
So first, compare the sign of the two operands. */
ret = new_loc_descr (DW_OP_over, 0, 0);
add_loc_descr (&ret, new_loc_descr (DW_OP_over, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_xor, 0, 0));
/* If they have different signs (i.e. they have different sign bits), then
the stack top value has now the sign bit set and thus it's smaller than
zero. */
add_loc_descr (&ret, new_loc_descr (DW_OP_lit0, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_lt, 0, 0));
add_loc_descr (&ret, bra_node);
/* We are in case 1. At this point, we know both operands have the same
sign, to it's safe to use the built-in signed comparison. */
add_loc_descr (&ret, new_loc_descr (op, 0, 0));
add_loc_descr (&ret, jmp_node);
/* We are in case 2. Here, we know both operands do not have the same sign,
so we have to flip the signed comparison. */
flip_op = (kind == LT_EXPR || kind == LE_EXPR) ? DW_OP_gt : DW_OP_lt;
tmp = new_loc_descr (flip_op, 0, 0);
bra_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
bra_node->dw_loc_oprnd1.v.val_loc = tmp;
add_loc_descr (&ret, tmp);
/* This dummy operation is necessary to make the two branches join. */
tmp = new_loc_descr (DW_OP_nop, 0, 0);
jmp_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
jmp_node->dw_loc_oprnd1.v.val_loc = tmp;
add_loc_descr (&ret, tmp);
return ret;
}
/* Likewise, but takes the location description lists (might be destructive on
them). Return NULL if either is NULL or if concatenation fails. */
static dw_loc_list_ref
loc_list_from_uint_comparison (dw_loc_list_ref left, dw_loc_list_ref right,
enum tree_code kind)
{
if (left == NULL || right == NULL)
return NULL;
add_loc_list (&left, right);
if (left == NULL)
return NULL;
add_loc_descr_to_each (left, uint_comparison_loc_list (kind));
return left;
}
/* Return size_of_locs (int_shift_loc_descriptor (i, shift))
without actually allocating it. */
static unsigned long
size_of_int_shift_loc_descriptor (HOST_WIDE_INT i, int shift)
{
return size_of_int_loc_descriptor (i >> shift)
+ size_of_int_loc_descriptor (shift)
+ 1;
}
/* Return size_of_locs (int_loc_descriptor (i)) without
actually allocating it. */
static unsigned long
size_of_int_loc_descriptor (HOST_WIDE_INT i)
{
unsigned long s;
if (i >= 0)
{
int clz, ctz;
if (i <= 31)
return 1;
else if (i <= 0xff)
return 2;
else if (i <= 0xffff)
return 3;
clz = clz_hwi (i);
ctz = ctz_hwi (i);
if (clz + ctz >= HOST_BITS_PER_WIDE_INT - 5
&& clz + 5 + 255 >= HOST_BITS_PER_WIDE_INT)
return size_of_int_shift_loc_descriptor (i, HOST_BITS_PER_WIDE_INT
- clz - 5);
else if (clz + ctz >= HOST_BITS_PER_WIDE_INT - 8
&& clz + 8 + 31 >= HOST_BITS_PER_WIDE_INT)
return size_of_int_shift_loc_descriptor (i, HOST_BITS_PER_WIDE_INT
- clz - 8);
else if (DWARF2_ADDR_SIZE == 4 && i > 0x7fffffff
&& size_of_int_loc_descriptor ((HOST_WIDE_INT) (int32_t) i)
<= 4)
return size_of_int_loc_descriptor ((HOST_WIDE_INT) (int32_t) i);
else if (HOST_BITS_PER_WIDE_INT == 32 || i <= 0xffffffff)
return 5;
s = size_of_uleb128 ((unsigned HOST_WIDE_INT) i);
if (clz + ctz >= HOST_BITS_PER_WIDE_INT - 8
&& clz + 8 + 255 >= HOST_BITS_PER_WIDE_INT)
return size_of_int_shift_loc_descriptor (i, HOST_BITS_PER_WIDE_INT
- clz - 8);
else if (clz + ctz >= HOST_BITS_PER_WIDE_INT - 16
&& clz + 16 + (s > 5 ? 255 : 31) >= HOST_BITS_PER_WIDE_INT)
return size_of_int_shift_loc_descriptor (i, HOST_BITS_PER_WIDE_INT
- clz - 16);
else if (clz + ctz >= HOST_BITS_PER_WIDE_INT - 32
&& clz + 32 + 31 >= HOST_BITS_PER_WIDE_INT
&& s > 6)
return size_of_int_shift_loc_descriptor (i, HOST_BITS_PER_WIDE_INT
- clz - 32);
else
return 1 + s;
}
else
{
if (i >= -0x80)
return 2;
else if (i >= -0x8000)
return 3;
else if (HOST_BITS_PER_WIDE_INT == 32 || i >= -0x80000000)
{
if (-(unsigned HOST_WIDE_INT) i != (unsigned HOST_WIDE_INT) i)
{
s = size_of_int_loc_descriptor (-i) + 1;
if (s < 5)
return s;
}
return 5;
}
else
{
unsigned long r = 1 + size_of_sleb128 (i);
if (-(unsigned HOST_WIDE_INT) i != (unsigned HOST_WIDE_INT) i)
{
s = size_of_int_loc_descriptor (-i) + 1;
if (s < r)
return s;
}
return r;
}
}
}
/* Return loc description representing "address" of integer value.
This can appear only as toplevel expression. */
static dw_loc_descr_ref
address_of_int_loc_descriptor (int size, HOST_WIDE_INT i)
{
int litsize;
dw_loc_descr_ref loc_result = NULL;
if (!(dwarf_version >= 4 || !dwarf_strict))
return NULL;
litsize = size_of_int_loc_descriptor (i);
/* Determine if DW_OP_stack_value or DW_OP_implicit_value
is more compact. For DW_OP_stack_value we need:
litsize + 1 (DW_OP_stack_value)
and for DW_OP_implicit_value:
1 (DW_OP_implicit_value) + 1 (length) + size. */
if ((int) DWARF2_ADDR_SIZE >= size && litsize + 1 <= 1 + 1 + size)
{
loc_result = int_loc_descriptor (i);
add_loc_descr (&loc_result,
new_loc_descr (DW_OP_stack_value, 0, 0));
return loc_result;
}
loc_result = new_loc_descr (DW_OP_implicit_value,
size, 0);
loc_result->dw_loc_oprnd2.val_class = dw_val_class_const;
loc_result->dw_loc_oprnd2.v.val_int = i;
return loc_result;
}
/* Return a location descriptor that designates a base+offset location. */
static dw_loc_descr_ref
based_loc_descr (rtx reg, poly_int64 offset,
enum var_init_status initialized)
{
unsigned int regno;
dw_loc_descr_ref result;
dw_fde_ref fde = cfun->fde;
/* We only use "frame base" when we're sure we're talking about the
post-prologue local stack frame. We do this by *not* running
register elimination until this point, and recognizing the special
argument pointer and soft frame pointer rtx's. */
if (reg == arg_pointer_rtx || reg == frame_pointer_rtx)
{
rtx elim = (ira_use_lra_p
? lra_eliminate_regs (reg, VOIDmode, NULL_RTX)
: eliminate_regs (reg, VOIDmode, NULL_RTX));
if (elim != reg)
{
/* Allow hard frame pointer here even if frame pointer
isn't used since hard frame pointer is encoded with
DW_OP_fbreg which uses the DW_AT_frame_base attribute,
not hard frame pointer directly. */
elim = strip_offset_and_add (elim, &offset);
gcc_assert (elim == hard_frame_pointer_rtx
|| elim == stack_pointer_rtx);
/* If drap register is used to align stack, use frame
pointer + offset to access stack variables. If stack
is aligned without drap, use stack pointer + offset to
access stack variables. */
if (crtl->stack_realign_tried
&& reg == frame_pointer_rtx)
{
int base_reg
= DWARF_FRAME_REGNUM ((fde && fde->drap_reg != INVALID_REGNUM)
? HARD_FRAME_POINTER_REGNUM
: REGNO (elim));
return new_reg_loc_descr (base_reg, offset);
}
gcc_assert (frame_pointer_fb_offset_valid);
offset += frame_pointer_fb_offset;
HOST_WIDE_INT const_offset;
if (offset.is_constant (&const_offset))
return new_loc_descr (DW_OP_fbreg, const_offset, 0);
else
{
dw_loc_descr_ref ret = new_loc_descr (DW_OP_fbreg, 0, 0);
loc_descr_plus_const (&ret, offset);
return ret;
}
}
}
regno = REGNO (reg);
#ifdef LEAF_REG_REMAP
if (crtl->uses_only_leaf_regs)
{
int leaf_reg = LEAF_REG_REMAP (regno);
if (leaf_reg != -1)
regno = (unsigned) leaf_reg;
}
#endif
regno = DWARF_FRAME_REGNUM (regno);
HOST_WIDE_INT const_offset;
if (!optimize && fde
&& (fde->drap_reg == regno || fde->vdrap_reg == regno)
&& offset.is_constant (&const_offset))
{
/* Use cfa+offset to represent the location of arguments passed
on the stack when drap is used to align stack.
Only do this when not optimizing, for optimized code var-tracking
is supposed to track where the arguments live and the register
used as vdrap or drap in some spot might be used for something
else in other part of the routine. */
return new_loc_descr (DW_OP_fbreg, const_offset, 0);
}
result = new_reg_loc_descr (regno, offset);
if (initialized == VAR_INIT_STATUS_UNINITIALIZED)
add_loc_descr (&result, new_loc_descr (DW_OP_GNU_uninit, 0, 0));
return result;
}
/* Return true if this RTL expression describes a base+offset calculation. */
static inline int
is_based_loc (const_rtx rtl)
{
return (GET_CODE (rtl) == PLUS
&& ((REG_P (XEXP (rtl, 0))
&& REGNO (XEXP (rtl, 0)) < FIRST_PSEUDO_REGISTER
&& CONST_INT_P (XEXP (rtl, 1)))));
}
/* Try to handle TLS MEMs, for which mem_loc_descriptor on XEXP (mem, 0)
failed. */
static dw_loc_descr_ref
tls_mem_loc_descriptor (rtx mem)
{
tree base;
dw_loc_descr_ref loc_result;
if (MEM_EXPR (mem) == NULL_TREE || !MEM_OFFSET_KNOWN_P (mem))
return NULL;
base = get_base_address (MEM_EXPR (mem));
if (base == NULL
|| !VAR_P (base)
|| !DECL_THREAD_LOCAL_P (base))
return NULL;
loc_result = loc_descriptor_from_tree (MEM_EXPR (mem), 1, NULL);
if (loc_result == NULL)
return NULL;
if (maybe_ne (MEM_OFFSET (mem), 0))
loc_descr_plus_const (&loc_result, MEM_OFFSET (mem));
return loc_result;
}
/* Output debug info about reason why we failed to expand expression as dwarf
expression. */
static void
expansion_failed (tree expr, rtx rtl, char const *reason)
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Failed to expand as dwarf: ");
if (expr)
print_generic_expr (dump_file, expr, dump_flags);
if (rtl)
{
fprintf (dump_file, "\n");
print_rtl (dump_file, rtl);
}
fprintf (dump_file, "\nReason: %s\n", reason);
}
}
/* Helper function for const_ok_for_output. */
static bool
const_ok_for_output_1 (rtx rtl)
{
if (targetm.const_not_ok_for_debug_p (rtl))
{
if (GET_CODE (rtl) != UNSPEC)
{
expansion_failed (NULL_TREE, rtl,
"Expression rejected for debug by the backend.\n");
return false;
}
/* If delegitimize_address couldn't do anything with the UNSPEC, and
the target hook doesn't explicitly allow it in debug info, assume
we can't express it in the debug info. */
/* Don't complain about TLS UNSPECs, those are just too hard to
delegitimize. Note this could be a non-decl SYMBOL_REF such as
one in a constant pool entry, so testing SYMBOL_REF_TLS_MODEL
rather than DECL_THREAD_LOCAL_P is not just an optimization. */
if (flag_checking
&& (XVECLEN (rtl, 0) == 0
|| GET_CODE (XVECEXP (rtl, 0, 0)) != SYMBOL_REF
|| SYMBOL_REF_TLS_MODEL (XVECEXP (rtl, 0, 0)) == TLS_MODEL_NONE))
inform (current_function_decl
? DECL_SOURCE_LOCATION (current_function_decl)
: UNKNOWN_LOCATION,
#if NUM_UNSPEC_VALUES > 0
"non-delegitimized UNSPEC %s (%d) found in variable location",
((XINT (rtl, 1) >= 0 && XINT (rtl, 1) < NUM_UNSPEC_VALUES)
? unspec_strings[XINT (rtl, 1)] : "unknown"),
#else
"non-delegitimized UNSPEC %d found in variable location",
#endif
XINT (rtl, 1));
expansion_failed (NULL_TREE, rtl,
"UNSPEC hasn't been delegitimized.\n");
return false;
}
if (CONST_POLY_INT_P (rtl))
return false;
/* FIXME: Refer to PR60655. It is possible for simplification
of rtl expressions in var tracking to produce such expressions.
We should really identify / validate expressions
enclosed in CONST that can be handled by assemblers on various
targets and only handle legitimate cases here. */
switch (GET_CODE (rtl))
{
case SYMBOL_REF:
break;
case NOT:
case NEG:
return false;
case PLUS:
{
/* Make sure SYMBOL_REFs/UNSPECs are at most in one of the
operands. */
subrtx_var_iterator::array_type array;
bool first = false;
FOR_EACH_SUBRTX_VAR (iter, array, XEXP (rtl, 0), ALL)
if (SYMBOL_REF_P (*iter)
|| LABEL_P (*iter)
|| GET_CODE (*iter) == UNSPEC)
{
first = true;
break;
}
if (!first)
return true;
FOR_EACH_SUBRTX_VAR (iter, array, XEXP (rtl, 1), ALL)
if (SYMBOL_REF_P (*iter)
|| LABEL_P (*iter)
|| GET_CODE (*iter) == UNSPEC)
return false;
return true;
}
case MINUS:
{
/* Disallow negation of SYMBOL_REFs or UNSPECs when they
appear in the second operand of MINUS. */
subrtx_var_iterator::array_type array;
FOR_EACH_SUBRTX_VAR (iter, array, XEXP (rtl, 1), ALL)
if (SYMBOL_REF_P (*iter)
|| LABEL_P (*iter)
|| GET_CODE (*iter) == UNSPEC)
return false;
return true;
}
default:
return true;
}
if (CONSTANT_POOL_ADDRESS_P (rtl))
{
bool marked;
get_pool_constant_mark (rtl, &marked);
/* If all references to this pool constant were optimized away,
it was not output and thus we can't represent it. */
if (!marked)
{
expansion_failed (NULL_TREE, rtl,
"Constant was removed from constant pool.\n");
return false;
}
}
if (SYMBOL_REF_TLS_MODEL (rtl) != TLS_MODEL_NONE)
return false;
/* Avoid references to external symbols in debug info, on several targets
the linker might even refuse to link when linking a shared library,
and in many other cases the relocations for .debug_info/.debug_loc are
dropped, so the address becomes zero anyway. Hidden symbols, guaranteed
to be defined within the same shared library or executable are fine. */
if (SYMBOL_REF_EXTERNAL_P (rtl))
{
tree decl = SYMBOL_REF_DECL (rtl);
if (decl == NULL || !targetm.binds_local_p (decl))
{
expansion_failed (NULL_TREE, rtl,
"Symbol not defined in current TU.\n");
return false;
}
}
return true;
}
/* Return true if constant RTL can be emitted in DW_OP_addr or
DW_AT_const_value. TLS SYMBOL_REFs, external SYMBOL_REFs or
non-marked constant pool SYMBOL_REFs can't be referenced in it. */
static bool
const_ok_for_output (rtx rtl)
{
if (GET_CODE (rtl) == SYMBOL_REF)
return const_ok_for_output_1 (rtl);
if (GET_CODE (rtl) == CONST)
{
subrtx_var_iterator::array_type array;
FOR_EACH_SUBRTX_VAR (iter, array, XEXP (rtl, 0), ALL)
if (!const_ok_for_output_1 (*iter))
return false;
return true;
}
return true;
}
/* Return a reference to DW_TAG_base_type corresponding to MODE and UNSIGNEDP
if possible, NULL otherwise. */
static dw_die_ref
base_type_for_mode (machine_mode mode, bool unsignedp)
{
dw_die_ref type_die;
tree type = lang_hooks.types.type_for_mode (mode, unsignedp);
if (type == NULL)
return NULL;
switch (TREE_CODE (type))
{
case INTEGER_TYPE:
case REAL_TYPE:
break;
default:
return NULL;
}
type_die = lookup_type_die (type);
if (!type_die)
type_die = modified_type_die (type, TYPE_UNQUALIFIED, false,
comp_unit_die ());
if (type_die == NULL || type_die->die_tag != DW_TAG_base_type)
return NULL;
return type_die;
}
/* For OP descriptor assumed to be in unsigned MODE, convert it to a unsigned
type matching MODE, or, if MODE is narrower than or as wide as
DWARF2_ADDR_SIZE, untyped. Return NULL if the conversion is not
possible. */
static dw_loc_descr_ref
convert_descriptor_to_mode (scalar_int_mode mode, dw_loc_descr_ref op)
{
machine_mode outer_mode = mode;
dw_die_ref type_die;
dw_loc_descr_ref cvt;
if (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE)
{
add_loc_descr (&op, new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0));
return op;
}
type_die = base_type_for_mode (outer_mode, 1);
if (type_die == NULL)
return NULL;
cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die;
cvt->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&op, cvt);
return op;
}
/* Return location descriptor for comparison OP with operands OP0 and OP1. */
static dw_loc_descr_ref
compare_loc_descriptor (enum dwarf_location_atom op, dw_loc_descr_ref op0,
dw_loc_descr_ref op1)
{
dw_loc_descr_ref ret = op0;
add_loc_descr (&ret, op1);
add_loc_descr (&ret, new_loc_descr (op, 0, 0));
if (STORE_FLAG_VALUE != 1)
{
add_loc_descr (&ret, int_loc_descriptor (STORE_FLAG_VALUE));
add_loc_descr (&ret, new_loc_descr (DW_OP_mul, 0, 0));
}
return ret;
}
/* Subroutine of scompare_loc_descriptor for the case in which we're
comparing two scalar integer operands OP0 and OP1 that have mode OP_MODE,
and in which OP_MODE is bigger than DWARF2_ADDR_SIZE. */
static dw_loc_descr_ref
scompare_loc_descriptor_wide (enum dwarf_location_atom op,
scalar_int_mode op_mode,
dw_loc_descr_ref op0, dw_loc_descr_ref op1)
{
dw_die_ref type_die = base_type_for_mode (op_mode, 0);
dw_loc_descr_ref cvt;
if (type_die == NULL)
return NULL;
cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die;
cvt->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&op0, cvt);
cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die;
cvt->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&op1, cvt);
return compare_loc_descriptor (op, op0, op1);
}
/* Subroutine of scompare_loc_descriptor for the case in which we're
comparing two scalar integer operands OP0 and OP1 that have mode OP_MODE,
and in which OP_MODE is smaller than DWARF2_ADDR_SIZE. */
static dw_loc_descr_ref
scompare_loc_descriptor_narrow (enum dwarf_location_atom op, rtx rtl,
scalar_int_mode op_mode,
dw_loc_descr_ref op0, dw_loc_descr_ref op1)
{
int shift = (DWARF2_ADDR_SIZE - GET_MODE_SIZE (op_mode)) * BITS_PER_UNIT;
/* For eq/ne, if the operands are known to be zero-extended,
there is no need to do the fancy shifting up. */
if (op == DW_OP_eq || op == DW_OP_ne)
{
dw_loc_descr_ref last0, last1;
for (last0 = op0; last0->dw_loc_next != NULL; last0 = last0->dw_loc_next)
;
for (last1 = op1; last1->dw_loc_next != NULL; last1 = last1->dw_loc_next)
;
/* deref_size zero extends, and for constants we can check
whether they are zero extended or not. */
if (((last0->dw_loc_opc == DW_OP_deref_size
&& last0->dw_loc_oprnd1.v.val_int <= GET_MODE_SIZE (op_mode))
|| (CONST_INT_P (XEXP (rtl, 0))
&& (unsigned HOST_WIDE_INT) INTVAL (XEXP (rtl, 0))
== (INTVAL (XEXP (rtl, 0)) & GET_MODE_MASK (op_mode))))
&& ((last1->dw_loc_opc == DW_OP_deref_size
&& last1->dw_loc_oprnd1.v.val_int <= GET_MODE_SIZE (op_mode))
|| (CONST_INT_P (XEXP (rtl, 1))
&& (unsigned HOST_WIDE_INT) INTVAL (XEXP (rtl, 1))
== (INTVAL (XEXP (rtl, 1)) & GET_MODE_MASK (op_mode)))))
return compare_loc_descriptor (op, op0, op1);
/* EQ/NE comparison against constant in narrower type than
DWARF2_ADDR_SIZE can be performed either as
DW_OP_const1u <shift> DW_OP_shl DW_OP_const* <cst << shift>
DW_OP_{eq,ne}
or
DW_OP_const*u <mode_mask> DW_OP_and DW_OP_const* <cst & mode_mask>
DW_OP_{eq,ne}. Pick whatever is shorter. */
if (CONST_INT_P (XEXP (rtl, 1))
&& GET_MODE_BITSIZE (op_mode) < HOST_BITS_PER_WIDE_INT
&& (size_of_int_loc_descriptor (shift) + 1
+ size_of_int_loc_descriptor (UINTVAL (XEXP (rtl, 1)) << shift)
>= size_of_int_loc_descriptor (GET_MODE_MASK (op_mode)) + 1
+ size_of_int_loc_descriptor (INTVAL (XEXP (rtl, 1))
& GET_MODE_MASK (op_mode))))
{
add_loc_descr (&op0, int_loc_descriptor (GET_MODE_MASK (op_mode)));
add_loc_descr (&op0, new_loc_descr (DW_OP_and, 0, 0));
op1 = int_loc_descriptor (INTVAL (XEXP (rtl, 1))
& GET_MODE_MASK (op_mode));
return compare_loc_descriptor (op, op0, op1);
}
}
add_loc_descr (&op0, int_loc_descriptor (shift));
add_loc_descr (&op0, new_loc_descr (DW_OP_shl, 0, 0));
if (CONST_INT_P (XEXP (rtl, 1)))
op1 = int_loc_descriptor (UINTVAL (XEXP (rtl, 1)) << shift);
else
{
add_loc_descr (&op1, int_loc_descriptor (shift));
add_loc_descr (&op1, new_loc_descr (DW_OP_shl, 0, 0));
}
return compare_loc_descriptor (op, op0, op1);
}
/* Return location descriptor for unsigned comparison OP RTL. */
static dw_loc_descr_ref
scompare_loc_descriptor (enum dwarf_location_atom op, rtx rtl,
machine_mode mem_mode)
{
machine_mode op_mode = GET_MODE (XEXP (rtl, 0));
dw_loc_descr_ref op0, op1;
if (op_mode == VOIDmode)
op_mode = GET_MODE (XEXP (rtl, 1));
if (op_mode == VOIDmode)
return NULL;
scalar_int_mode int_op_mode;
if (dwarf_strict
&& dwarf_version < 5
&& (!is_a <scalar_int_mode> (op_mode, &int_op_mode)
|| GET_MODE_SIZE (int_op_mode) > DWARF2_ADDR_SIZE))
return NULL;
op0 = mem_loc_descriptor (XEXP (rtl, 0), op_mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
op1 = mem_loc_descriptor (XEXP (rtl, 1), op_mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (op0 == NULL || op1 == NULL)
return NULL;
if (is_a <scalar_int_mode> (op_mode, &int_op_mode))
{
if (GET_MODE_SIZE (int_op_mode) < DWARF2_ADDR_SIZE)
return scompare_loc_descriptor_narrow (op, rtl, int_op_mode, op0, op1);
if (GET_MODE_SIZE (int_op_mode) > DWARF2_ADDR_SIZE)
return scompare_loc_descriptor_wide (op, int_op_mode, op0, op1);
}
return compare_loc_descriptor (op, op0, op1);
}
/* Return location descriptor for unsigned comparison OP RTL. */
static dw_loc_descr_ref
ucompare_loc_descriptor (enum dwarf_location_atom op, rtx rtl,
machine_mode mem_mode)
{
dw_loc_descr_ref op0, op1;
machine_mode test_op_mode = GET_MODE (XEXP (rtl, 0));
if (test_op_mode == VOIDmode)
test_op_mode = GET_MODE (XEXP (rtl, 1));
scalar_int_mode op_mode;
if (!is_a <scalar_int_mode> (test_op_mode, &op_mode))
return NULL;
if (dwarf_strict
&& dwarf_version < 5
&& GET_MODE_SIZE (op_mode) > DWARF2_ADDR_SIZE)
return NULL;
op0 = mem_loc_descriptor (XEXP (rtl, 0), op_mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
op1 = mem_loc_descriptor (XEXP (rtl, 1), op_mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (op0 == NULL || op1 == NULL)
return NULL;
if (GET_MODE_SIZE (op_mode) < DWARF2_ADDR_SIZE)
{
HOST_WIDE_INT mask = GET_MODE_MASK (op_mode);
dw_loc_descr_ref last0, last1;
for (last0 = op0; last0->dw_loc_next != NULL; last0 = last0->dw_loc_next)
;
for (last1 = op1; last1->dw_loc_next != NULL; last1 = last1->dw_loc_next)
;
if (CONST_INT_P (XEXP (rtl, 0)))
op0 = int_loc_descriptor (INTVAL (XEXP (rtl, 0)) & mask);
/* deref_size zero extends, so no need to mask it again. */
else if (last0->dw_loc_opc != DW_OP_deref_size
|| last0->dw_loc_oprnd1.v.val_int > GET_MODE_SIZE (op_mode))
{
add_loc_descr (&op0, int_loc_descriptor (mask));
add_loc_descr (&op0, new_loc_descr (DW_OP_and, 0, 0));
}
if (CONST_INT_P (XEXP (rtl, 1)))
op1 = int_loc_descriptor (INTVAL (XEXP (rtl, 1)) & mask);
/* deref_size zero extends, so no need to mask it again. */
else if (last1->dw_loc_opc != DW_OP_deref_size
|| last1->dw_loc_oprnd1.v.val_int > GET_MODE_SIZE (op_mode))
{
add_loc_descr (&op1, int_loc_descriptor (mask));
add_loc_descr (&op1, new_loc_descr (DW_OP_and, 0, 0));
}
}
else if (GET_MODE_SIZE (op_mode) == DWARF2_ADDR_SIZE)
{
HOST_WIDE_INT bias = 1;
bias <<= (DWARF2_ADDR_SIZE * BITS_PER_UNIT - 1);
add_loc_descr (&op0, new_loc_descr (DW_OP_plus_uconst, bias, 0));
if (CONST_INT_P (XEXP (rtl, 1)))
op1 = int_loc_descriptor ((unsigned HOST_WIDE_INT) bias
+ INTVAL (XEXP (rtl, 1)));
else
add_loc_descr (&op1, new_loc_descr (DW_OP_plus_uconst,
bias, 0));
}
return compare_loc_descriptor (op, op0, op1);
}
/* Return location descriptor for {U,S}{MIN,MAX}. */
static dw_loc_descr_ref
minmax_loc_descriptor (rtx rtl, machine_mode mode,
machine_mode mem_mode)
{
enum dwarf_location_atom op;
dw_loc_descr_ref op0, op1, ret;
dw_loc_descr_ref bra_node, drop_node;
scalar_int_mode int_mode;
if (dwarf_strict
&& dwarf_version < 5
&& (!is_a <scalar_int_mode> (mode, &int_mode)
|| GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE))
return NULL;
op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
op1 = mem_loc_descriptor (XEXP (rtl, 1), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (op0 == NULL || op1 == NULL)
return NULL;
add_loc_descr (&op0, new_loc_descr (DW_OP_dup, 0, 0));
add_loc_descr (&op1, new_loc_descr (DW_OP_swap, 0, 0));
add_loc_descr (&op1, new_loc_descr (DW_OP_over, 0, 0));
if (GET_CODE (rtl) == UMIN || GET_CODE (rtl) == UMAX)
{
/* Checked by the caller. */
int_mode = as_a <scalar_int_mode> (mode);
if (GET_MODE_SIZE (int_mode) < DWARF2_ADDR_SIZE)
{
HOST_WIDE_INT mask = GET_MODE_MASK (int_mode);
add_loc_descr (&op0, int_loc_descriptor (mask));
add_loc_descr (&op0, new_loc_descr (DW_OP_and, 0, 0));
add_loc_descr (&op1, int_loc_descriptor (mask));
add_loc_descr (&op1, new_loc_descr (DW_OP_and, 0, 0));
}
else if (GET_MODE_SIZE (int_mode) == DWARF2_ADDR_SIZE)
{
HOST_WIDE_INT bias = 1;
bias <<= (DWARF2_ADDR_SIZE * BITS_PER_UNIT - 1);
add_loc_descr (&op0, new_loc_descr (DW_OP_plus_uconst, bias, 0));
add_loc_descr (&op1, new_loc_descr (DW_OP_plus_uconst, bias, 0));
}
}
else if (is_a <scalar_int_mode> (mode, &int_mode)
&& GET_MODE_SIZE (int_mode) < DWARF2_ADDR_SIZE)
{
int shift = (DWARF2_ADDR_SIZE - GET_MODE_SIZE (int_mode)) * BITS_PER_UNIT;
add_loc_descr (&op0, int_loc_descriptor (shift));
add_loc_descr (&op0, new_loc_descr (DW_OP_shl, 0, 0));
add_loc_descr (&op1, int_loc_descriptor (shift));
add_loc_descr (&op1, new_loc_descr (DW_OP_shl, 0, 0));
}
else if (is_a <scalar_int_mode> (mode, &int_mode)
&& GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE)
{
dw_die_ref type_die = base_type_for_mode (int_mode, 0);
dw_loc_descr_ref cvt;
if (type_die == NULL)
return NULL;
cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die;
cvt->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&op0, cvt);
cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die;
cvt->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&op1, cvt);
}
if (GET_CODE (rtl) == SMIN || GET_CODE (rtl) == UMIN)
op = DW_OP_lt;
else
op = DW_OP_gt;
ret = op0;
add_loc_descr (&ret, op1);
add_loc_descr (&ret, new_loc_descr (op, 0, 0));
bra_node = new_loc_descr (DW_OP_bra, 0, 0);
add_loc_descr (&ret, bra_node);
add_loc_descr (&ret, new_loc_descr (DW_OP_swap, 0, 0));
drop_node = new_loc_descr (DW_OP_drop, 0, 0);
add_loc_descr (&ret, drop_node);
bra_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
bra_node->dw_loc_oprnd1.v.val_loc = drop_node;
if ((GET_CODE (rtl) == SMIN || GET_CODE (rtl) == SMAX)
&& is_a <scalar_int_mode> (mode, &int_mode)
&& GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE)
ret = convert_descriptor_to_mode (int_mode, ret);
return ret;
}
/* Helper function for mem_loc_descriptor. Perform OP binary op,
but after converting arguments to type_die, afterwards
convert back to unsigned. */
static dw_loc_descr_ref
typed_binop (enum dwarf_location_atom op, rtx rtl, dw_die_ref type_die,
scalar_int_mode mode, machine_mode mem_mode)
{
dw_loc_descr_ref cvt, op0, op1;
if (type_die == NULL)
return NULL;
op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
op1 = mem_loc_descriptor (XEXP (rtl, 1), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (op0 == NULL || op1 == NULL)
return NULL;
cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die;
cvt->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&op0, cvt);
cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die;
cvt->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&op1, cvt);
add_loc_descr (&op0, op1);
add_loc_descr (&op0, new_loc_descr (op, 0, 0));
return convert_descriptor_to_mode (mode, op0);
}
/* CLZ (where constV is CLZ_DEFINED_VALUE_AT_ZERO computed value,
const0 is DW_OP_lit0 or corresponding typed constant,
const1 is DW_OP_lit1 or corresponding typed constant
and constMSB is constant with just the MSB bit set
for the mode):
DW_OP_dup DW_OP_bra <L1> DW_OP_drop constV DW_OP_skip <L4>
L1: const0 DW_OP_swap
L2: DW_OP_dup constMSB DW_OP_and DW_OP_bra <L3> const1 DW_OP_shl
DW_OP_swap DW_OP_plus_uconst <1> DW_OP_swap DW_OP_skip <L2>
L3: DW_OP_drop
L4: DW_OP_nop
CTZ is similar:
DW_OP_dup DW_OP_bra <L1> DW_OP_drop constV DW_OP_skip <L4>
L1: const0 DW_OP_swap
L2: DW_OP_dup const1 DW_OP_and DW_OP_bra <L3> const1 DW_OP_shr
DW_OP_swap DW_OP_plus_uconst <1> DW_OP_swap DW_OP_skip <L2>
L3: DW_OP_drop
L4: DW_OP_nop
FFS is similar:
DW_OP_dup DW_OP_bra <L1> DW_OP_drop const0 DW_OP_skip <L4>
L1: const1 DW_OP_swap
L2: DW_OP_dup const1 DW_OP_and DW_OP_bra <L3> const1 DW_OP_shr
DW_OP_swap DW_OP_plus_uconst <1> DW_OP_swap DW_OP_skip <L2>
L3: DW_OP_drop
L4: DW_OP_nop */
static dw_loc_descr_ref
clz_loc_descriptor (rtx rtl, scalar_int_mode mode,
machine_mode mem_mode)
{
dw_loc_descr_ref op0, ret, tmp;
HOST_WIDE_INT valv;
dw_loc_descr_ref l1jump, l1label;
dw_loc_descr_ref l2jump, l2label;
dw_loc_descr_ref l3jump, l3label;
dw_loc_descr_ref l4jump, l4label;
rtx msb;
if (GET_MODE (XEXP (rtl, 0)) != mode)
return NULL;
op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (op0 == NULL)
return NULL;
ret = op0;
if (GET_CODE (rtl) == CLZ)
{
if (!CLZ_DEFINED_VALUE_AT_ZERO (mode, valv))
valv = GET_MODE_BITSIZE (mode);
}
else if (GET_CODE (rtl) == FFS)
valv = 0;
else if (!CTZ_DEFINED_VALUE_AT_ZERO (mode, valv))
valv = GET_MODE_BITSIZE (mode);
add_loc_descr (&ret, new_loc_descr (DW_OP_dup, 0, 0));
l1jump = new_loc_descr (DW_OP_bra, 0, 0);
add_loc_descr (&ret, l1jump);
add_loc_descr (&ret, new_loc_descr (DW_OP_drop, 0, 0));
tmp = mem_loc_descriptor (GEN_INT (valv), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (tmp == NULL)
return NULL;
add_loc_descr (&ret, tmp);
l4jump = new_loc_descr (DW_OP_skip, 0, 0);
add_loc_descr (&ret, l4jump);
l1label = mem_loc_descriptor (GET_CODE (rtl) == FFS
? const1_rtx : const0_rtx,
mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (l1label == NULL)
return NULL;
add_loc_descr (&ret, l1label);
add_loc_descr (&ret, new_loc_descr (DW_OP_swap, 0, 0));
l2label = new_loc_descr (DW_OP_dup, 0, 0);
add_loc_descr (&ret, l2label);
if (GET_CODE (rtl) != CLZ)
msb = const1_rtx;
else if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
msb = GEN_INT (HOST_WIDE_INT_1U
<< (GET_MODE_BITSIZE (mode) - 1));
else
msb = immed_wide_int_const
(wi::set_bit_in_zero (GET_MODE_PRECISION (mode) - 1,
GET_MODE_PRECISION (mode)), mode);
if (GET_CODE (msb) == CONST_INT && INTVAL (msb) < 0)
tmp = new_loc_descr (HOST_BITS_PER_WIDE_INT == 32
? DW_OP_const4u : HOST_BITS_PER_WIDE_INT == 64
? DW_OP_const8u : DW_OP_constu, INTVAL (msb), 0);
else
tmp = mem_loc_descriptor (msb, mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (tmp == NULL)
return NULL;
add_loc_descr (&ret, tmp);
add_loc_descr (&ret, new_loc_descr (DW_OP_and, 0, 0));
l3jump = new_loc_descr (DW_OP_bra, 0, 0);
add_loc_descr (&ret, l3jump);
tmp = mem_loc_descriptor (const1_rtx, mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (tmp == NULL)
return NULL;
add_loc_descr (&ret, tmp);
add_loc_descr (&ret, new_loc_descr (GET_CODE (rtl) == CLZ
? DW_OP_shl : DW_OP_shr, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_swap, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_plus_uconst, 1, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_swap, 0, 0));
l2jump = new_loc_descr (DW_OP_skip, 0, 0);
add_loc_descr (&ret, l2jump);
l3label = new_loc_descr (DW_OP_drop, 0, 0);
add_loc_descr (&ret, l3label);
l4label = new_loc_descr (DW_OP_nop, 0, 0);
add_loc_descr (&ret, l4label);
l1jump->dw_loc_oprnd1.val_class = dw_val_class_loc;
l1jump->dw_loc_oprnd1.v.val_loc = l1label;
l2jump->dw_loc_oprnd1.val_class = dw_val_class_loc;
l2jump->dw_loc_oprnd1.v.val_loc = l2label;
l3jump->dw_loc_oprnd1.val_class = dw_val_class_loc;
l3jump->dw_loc_oprnd1.v.val_loc = l3label;
l4jump->dw_loc_oprnd1.val_class = dw_val_class_loc;
l4jump->dw_loc_oprnd1.v.val_loc = l4label;
return ret;
}
/* POPCOUNT (const0 is DW_OP_lit0 or corresponding typed constant,
const1 is DW_OP_lit1 or corresponding typed constant):
const0 DW_OP_swap
L1: DW_OP_dup DW_OP_bra <L2> DW_OP_dup DW_OP_rot const1 DW_OP_and
DW_OP_plus DW_OP_swap const1 DW_OP_shr DW_OP_skip <L1>
L2: DW_OP_drop
PARITY is similar:
L1: DW_OP_dup DW_OP_bra <L2> DW_OP_dup DW_OP_rot const1 DW_OP_and
DW_OP_xor DW_OP_swap const1 DW_OP_shr DW_OP_skip <L1>
L2: DW_OP_drop */
static dw_loc_descr_ref
popcount_loc_descriptor (rtx rtl, scalar_int_mode mode,
machine_mode mem_mode)
{
dw_loc_descr_ref op0, ret, tmp;
dw_loc_descr_ref l1jump, l1label;
dw_loc_descr_ref l2jump, l2label;
if (GET_MODE (XEXP (rtl, 0)) != mode)
return NULL;
op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (op0 == NULL)
return NULL;
ret = op0;
tmp = mem_loc_descriptor (const0_rtx, mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (tmp == NULL)
return NULL;
add_loc_descr (&ret, tmp);
add_loc_descr (&ret, new_loc_descr (DW_OP_swap, 0, 0));
l1label = new_loc_descr (DW_OP_dup, 0, 0);
add_loc_descr (&ret, l1label);
l2jump = new_loc_descr (DW_OP_bra, 0, 0);
add_loc_descr (&ret, l2jump);
add_loc_descr (&ret, new_loc_descr (DW_OP_dup, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_rot, 0, 0));
tmp = mem_loc_descriptor (const1_rtx, mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (tmp == NULL)
return NULL;
add_loc_descr (&ret, tmp);
add_loc_descr (&ret, new_loc_descr (DW_OP_and, 0, 0));
add_loc_descr (&ret, new_loc_descr (GET_CODE (rtl) == POPCOUNT
? DW_OP_plus : DW_OP_xor, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_swap, 0, 0));
tmp = mem_loc_descriptor (const1_rtx, mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
add_loc_descr (&ret, tmp);
add_loc_descr (&ret, new_loc_descr (DW_OP_shr, 0, 0));
l1jump = new_loc_descr (DW_OP_skip, 0, 0);
add_loc_descr (&ret, l1jump);
l2label = new_loc_descr (DW_OP_drop, 0, 0);
add_loc_descr (&ret, l2label);
l1jump->dw_loc_oprnd1.val_class = dw_val_class_loc;
l1jump->dw_loc_oprnd1.v.val_loc = l1label;
l2jump->dw_loc_oprnd1.val_class = dw_val_class_loc;
l2jump->dw_loc_oprnd1.v.val_loc = l2label;
return ret;
}
/* BSWAP (constS is initial shift count, either 56 or 24):
constS const0
L1: DW_OP_pick <2> constS DW_OP_pick <3> DW_OP_minus DW_OP_shr
const255 DW_OP_and DW_OP_pick <2> DW_OP_shl DW_OP_or
DW_OP_swap DW_OP_dup const0 DW_OP_eq DW_OP_bra <L2> const8
DW_OP_minus DW_OP_swap DW_OP_skip <L1>
L2: DW_OP_drop DW_OP_swap DW_OP_drop */
static dw_loc_descr_ref
bswap_loc_descriptor (rtx rtl, scalar_int_mode mode,
machine_mode mem_mode)
{
dw_loc_descr_ref op0, ret, tmp;
dw_loc_descr_ref l1jump, l1label;
dw_loc_descr_ref l2jump, l2label;
if (BITS_PER_UNIT != 8
|| (GET_MODE_BITSIZE (mode) != 32
&& GET_MODE_BITSIZE (mode) != 64))
return NULL;
op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (op0 == NULL)
return NULL;
ret = op0;
tmp = mem_loc_descriptor (GEN_INT (GET_MODE_BITSIZE (mode) - 8),
mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (tmp == NULL)
return NULL;
add_loc_descr (&ret, tmp);
tmp = mem_loc_descriptor (const0_rtx, mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (tmp == NULL)
return NULL;
add_loc_descr (&ret, tmp);
l1label = new_loc_descr (DW_OP_pick, 2, 0);
add_loc_descr (&ret, l1label);
tmp = mem_loc_descriptor (GEN_INT (GET_MODE_BITSIZE (mode) - 8),
mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
add_loc_descr (&ret, tmp);
add_loc_descr (&ret, new_loc_descr (DW_OP_pick, 3, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_minus, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_shr, 0, 0));
tmp = mem_loc_descriptor (GEN_INT (255), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (tmp == NULL)
return NULL;
add_loc_descr (&ret, tmp);
add_loc_descr (&ret, new_loc_descr (DW_OP_and, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_pick, 2, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_shl, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_or, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_swap, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_dup, 0, 0));
tmp = mem_loc_descriptor (const0_rtx, mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
add_loc_descr (&ret, tmp);
add_loc_descr (&ret, new_loc_descr (DW_OP_eq, 0, 0));
l2jump = new_loc_descr (DW_OP_bra, 0, 0);
add_loc_descr (&ret, l2jump);
tmp = mem_loc_descriptor (GEN_INT (8), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
add_loc_descr (&ret, tmp);
add_loc_descr (&ret, new_loc_descr (DW_OP_minus, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_swap, 0, 0));
l1jump = new_loc_descr (DW_OP_skip, 0, 0);
add_loc_descr (&ret, l1jump);
l2label = new_loc_descr (DW_OP_drop, 0, 0);
add_loc_descr (&ret, l2label);
add_loc_descr (&ret, new_loc_descr (DW_OP_swap, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_drop, 0, 0));
l1jump->dw_loc_oprnd1.val_class = dw_val_class_loc;
l1jump->dw_loc_oprnd1.v.val_loc = l1label;
l2jump->dw_loc_oprnd1.val_class = dw_val_class_loc;
l2jump->dw_loc_oprnd1.v.val_loc = l2label;
return ret;
}
/* ROTATE (constMASK is mode mask, BITSIZE is bitsize of mode):
DW_OP_over DW_OP_over DW_OP_shl [ constMASK DW_OP_and ] DW_OP_rot
[ DW_OP_swap constMASK DW_OP_and DW_OP_swap ] DW_OP_neg
DW_OP_plus_uconst <BITSIZE> DW_OP_shr DW_OP_or
ROTATERT is similar:
DW_OP_over DW_OP_over DW_OP_neg DW_OP_plus_uconst <BITSIZE>
DW_OP_shl [ constMASK DW_OP_and ] DW_OP_rot
[ DW_OP_swap constMASK DW_OP_and DW_OP_swap ] DW_OP_shr DW_OP_or */
static dw_loc_descr_ref
rotate_loc_descriptor (rtx rtl, scalar_int_mode mode,
machine_mode mem_mode)
{
rtx rtlop1 = XEXP (rtl, 1);
dw_loc_descr_ref op0, op1, ret, mask[2] = { NULL, NULL };
int i;
if (is_narrower_int_mode (GET_MODE (rtlop1), mode))
rtlop1 = gen_rtx_ZERO_EXTEND (mode, rtlop1);
op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
op1 = mem_loc_descriptor (rtlop1, mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (op0 == NULL || op1 == NULL)
return NULL;
if (GET_MODE_SIZE (mode) < DWARF2_ADDR_SIZE)
for (i = 0; i < 2; i++)
{
if (GET_MODE_BITSIZE (mode) < HOST_BITS_PER_WIDE_INT)
mask[i] = mem_loc_descriptor (GEN_INT (GET_MODE_MASK (mode)),
mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
else if (GET_MODE_BITSIZE (mode) == HOST_BITS_PER_WIDE_INT)
mask[i] = new_loc_descr (HOST_BITS_PER_WIDE_INT == 32
? DW_OP_const4u
: HOST_BITS_PER_WIDE_INT == 64
? DW_OP_const8u : DW_OP_constu,
GET_MODE_MASK (mode), 0);
else
mask[i] = NULL;
if (mask[i] == NULL)
return NULL;
add_loc_descr (&mask[i], new_loc_descr (DW_OP_and, 0, 0));
}
ret = op0;
add_loc_descr (&ret, op1);
add_loc_descr (&ret, new_loc_descr (DW_OP_over, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_over, 0, 0));
if (GET_CODE (rtl) == ROTATERT)
{
add_loc_descr (&ret, new_loc_descr (DW_OP_neg, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_plus_uconst,
GET_MODE_BITSIZE (mode), 0));
}
add_loc_descr (&ret, new_loc_descr (DW_OP_shl, 0, 0));
if (mask[0] != NULL)
add_loc_descr (&ret, mask[0]);
add_loc_descr (&ret, new_loc_descr (DW_OP_rot, 0, 0));
if (mask[1] != NULL)
{
add_loc_descr (&ret, new_loc_descr (DW_OP_swap, 0, 0));
add_loc_descr (&ret, mask[1]);
add_loc_descr (&ret, new_loc_descr (DW_OP_swap, 0, 0));
}
if (GET_CODE (rtl) == ROTATE)
{
add_loc_descr (&ret, new_loc_descr (DW_OP_neg, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_plus_uconst,
GET_MODE_BITSIZE (mode), 0));
}
add_loc_descr (&ret, new_loc_descr (DW_OP_shr, 0, 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_or, 0, 0));
return ret;
}
/* Helper function for mem_loc_descriptor. Return DW_OP_GNU_parameter_ref
for DEBUG_PARAMETER_REF RTL. */
static dw_loc_descr_ref
parameter_ref_descriptor (rtx rtl)
{
dw_loc_descr_ref ret;
dw_die_ref ref;
if (dwarf_strict)
return NULL;
gcc_assert (TREE_CODE (DEBUG_PARAMETER_REF_DECL (rtl)) == PARM_DECL);
/* With LTO during LTRANS we get the late DIE that refers to the early
DIE, thus we add another indirection here. This seems to confuse
gdb enough to make gcc.dg/guality/pr68860-1.c FAIL with LTO. */
ref = lookup_decl_die (DEBUG_PARAMETER_REF_DECL (rtl));
ret = new_loc_descr (DW_OP_GNU_parameter_ref, 0, 0);
if (ref)
{
ret->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
ret->dw_loc_oprnd1.v.val_die_ref.die = ref;
ret->dw_loc_oprnd1.v.val_die_ref.external = 0;
}
else
{
ret->dw_loc_oprnd1.val_class = dw_val_class_decl_ref;
ret->dw_loc_oprnd1.v.val_decl_ref = DEBUG_PARAMETER_REF_DECL (rtl);
}
return ret;
}
/* The following routine converts the RTL for a variable or parameter
(resident in memory) into an equivalent Dwarf representation of a
mechanism for getting the address of that same variable onto the top of a
hypothetical "address evaluation" stack.
When creating memory location descriptors, we are effectively transforming
the RTL for a memory-resident object into its Dwarf postfix expression
equivalent. This routine recursively descends an RTL tree, turning
it into Dwarf postfix code as it goes.
MODE is the mode that should be assumed for the rtl if it is VOIDmode.
MEM_MODE is the mode of the memory reference, needed to handle some
autoincrement addressing modes.
Return 0 if we can't represent the location. */
dw_loc_descr_ref
mem_loc_descriptor (rtx rtl, machine_mode mode,
machine_mode mem_mode,
enum var_init_status initialized)
{
dw_loc_descr_ref mem_loc_result = NULL;
enum dwarf_location_atom op;
dw_loc_descr_ref op0, op1;
rtx inner = NULL_RTX;
poly_int64 offset;
if (mode == VOIDmode)
mode = GET_MODE (rtl);
/* Note that for a dynamically sized array, the location we will generate a
description of here will be the lowest numbered location which is
actually within the array. That's *not* necessarily the same as the
zeroth element of the array. */
rtl = targetm.delegitimize_address (rtl);
if (mode != GET_MODE (rtl) && GET_MODE (rtl) != VOIDmode)
return NULL;
scalar_int_mode int_mode = BImode, inner_mode, op1_mode;
switch (GET_CODE (rtl))
{
case POST_INC:
case POST_DEC:
case POST_MODIFY:
return mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, initialized);
case SUBREG:
/* The case of a subreg may arise when we have a local (register)
variable or a formal (register) parameter which doesn't quite fill
up an entire register. For now, just assume that it is
legitimate to make the Dwarf info refer to the whole register which
contains the given subreg. */
if (!subreg_lowpart_p (rtl))
break;
inner = SUBREG_REG (rtl);
/* FALLTHRU */
case TRUNCATE:
if (inner == NULL_RTX)
inner = XEXP (rtl, 0);
if (is_a <scalar_int_mode> (mode, &int_mode)
&& is_a <scalar_int_mode> (GET_MODE (inner), &inner_mode)
&& (GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE
#ifdef POINTERS_EXTEND_UNSIGNED
|| (int_mode == Pmode && mem_mode != VOIDmode)
#endif
)
&& GET_MODE_SIZE (inner_mode) <= DWARF2_ADDR_SIZE)
{
mem_loc_result = mem_loc_descriptor (inner,
inner_mode,
mem_mode, initialized);
break;
}
if (dwarf_strict && dwarf_version < 5)
break;
if (is_a <scalar_int_mode> (mode, &int_mode)
&& is_a <scalar_int_mode> (GET_MODE (inner), &inner_mode)
? GET_MODE_SIZE (int_mode) <= GET_MODE_SIZE (inner_mode)
: known_eq (GET_MODE_SIZE (mode), GET_MODE_SIZE (GET_MODE (inner))))
{
dw_die_ref type_die;
dw_loc_descr_ref cvt;
mem_loc_result = mem_loc_descriptor (inner,
GET_MODE (inner),
mem_mode, initialized);
if (mem_loc_result == NULL)
break;
type_die = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode));
if (type_die == NULL)
{
mem_loc_result = NULL;
break;
}
if (maybe_ne (GET_MODE_SIZE (mode), GET_MODE_SIZE (GET_MODE (inner))))
cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
else
cvt = new_loc_descr (dwarf_OP (DW_OP_reinterpret), 0, 0);
cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die;
cvt->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&mem_loc_result, cvt);
if (is_a <scalar_int_mode> (mode, &int_mode)
&& GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE)
{
/* Convert it to untyped afterwards. */
cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
add_loc_descr (&mem_loc_result, cvt);
}
}
break;
case REG:
if (!is_a <scalar_int_mode> (mode, &int_mode)
|| (GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE
&& rtl != arg_pointer_rtx
&& rtl != frame_pointer_rtx
#ifdef POINTERS_EXTEND_UNSIGNED
&& (int_mode != Pmode || mem_mode == VOIDmode)
#endif
))
{
dw_die_ref type_die;
unsigned int dbx_regnum;
if (dwarf_strict && dwarf_version < 5)
break;
if (REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
break;
type_die = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode));
if (type_die == NULL)
break;
dbx_regnum = dbx_reg_number (rtl);
if (dbx_regnum == IGNORED_DWARF_REGNUM)
break;
mem_loc_result = new_loc_descr (dwarf_OP (DW_OP_regval_type),
dbx_regnum, 0);
mem_loc_result->dw_loc_oprnd2.val_class = dw_val_class_die_ref;
mem_loc_result->dw_loc_oprnd2.v.val_die_ref.die = type_die;
mem_loc_result->dw_loc_oprnd2.v.val_die_ref.external = 0;
break;
}
/* Whenever a register number forms a part of the description of the
method for calculating the (dynamic) address of a memory resident
object, DWARF rules require the register number be referred to as
a "base register". This distinction is not based in any way upon
what category of register the hardware believes the given register
belongs to. This is strictly DWARF terminology we're dealing with
here. Note that in cases where the location of a memory-resident
data object could be expressed as: OP_ADD (OP_BASEREG (basereg),
OP_CONST (0)) the actual DWARF location descriptor that we generate
may just be OP_BASEREG (basereg). This may look deceptively like
the object in question was allocated to a register (rather than in
memory) so DWARF consumers need to be aware of the subtle
distinction between OP_REG and OP_BASEREG. */
if (REGNO (rtl) < FIRST_PSEUDO_REGISTER)
mem_loc_result = based_loc_descr (rtl, 0, VAR_INIT_STATUS_INITIALIZED);
else if (stack_realign_drap
&& crtl->drap_reg
&& crtl->args.internal_arg_pointer == rtl
&& REGNO (crtl->drap_reg) < FIRST_PSEUDO_REGISTER)
{
/* If RTL is internal_arg_pointer, which has been optimized
out, use DRAP instead. */
mem_loc_result = based_loc_descr (crtl->drap_reg, 0,
VAR_INIT_STATUS_INITIALIZED);
}
break;
case SIGN_EXTEND:
case ZERO_EXTEND:
if (!is_a <scalar_int_mode> (mode, &int_mode)
|| !is_a <scalar_int_mode> (GET_MODE (XEXP (rtl, 0)), &inner_mode))
break;
op0 = mem_loc_descriptor (XEXP (rtl, 0), inner_mode,
mem_mode, VAR_INIT_STATUS_INITIALIZED);
if (op0 == 0)
break;
else if (GET_CODE (rtl) == ZERO_EXTEND
&& GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE
&& GET_MODE_BITSIZE (inner_mode) < HOST_BITS_PER_WIDE_INT
/* If DW_OP_const{1,2,4}u won't be used, it is shorter
to expand zero extend as two shifts instead of
masking. */
&& GET_MODE_SIZE (inner_mode) <= 4)
{
mem_loc_result = op0;
add_loc_descr (&mem_loc_result,
int_loc_descriptor (GET_MODE_MASK (inner_mode)));
add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_and, 0, 0));
}
else if (GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE)
{
int shift = DWARF2_ADDR_SIZE - GET_MODE_SIZE (inner_mode);
shift *= BITS_PER_UNIT;
if (GET_CODE (rtl) == SIGN_EXTEND)
op = DW_OP_shra;
else
op = DW_OP_shr;
mem_loc_result = op0;
add_loc_descr (&mem_loc_result, int_loc_descriptor (shift));
add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_shl, 0, 0));
add_loc_descr (&mem_loc_result, int_loc_descriptor (shift));
add_loc_descr (&mem_loc_result, new_loc_descr (op, 0, 0));
}
else if (!dwarf_strict || dwarf_version >= 5)
{
dw_die_ref type_die1, type_die2;
dw_loc_descr_ref cvt;
type_die1 = base_type_for_mode (inner_mode,
GET_CODE (rtl) == ZERO_EXTEND);
if (type_die1 == NULL)
break;
type_die2 = base_type_for_mode (int_mode, 1);
if (type_die2 == NULL)
break;
mem_loc_result = op0;
cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die1;
cvt->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&mem_loc_result, cvt);
cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die2;
cvt->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&mem_loc_result, cvt);
}
break;
case MEM:
{
rtx new_rtl = avoid_constant_pool_reference (rtl);
if (new_rtl != rtl)
{
mem_loc_result = mem_loc_descriptor (new_rtl, mode, mem_mode,
initialized);
if (mem_loc_result != NULL)
return mem_loc_result;
}
}
mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0),
get_address_mode (rtl), mode,
VAR_INIT_STATUS_INITIALIZED);
if (mem_loc_result == NULL)
mem_loc_result = tls_mem_loc_descriptor (rtl);
if (mem_loc_result != NULL)
{
if (!is_a <scalar_int_mode> (mode, &int_mode)
|| GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE)
{
dw_die_ref type_die;
dw_loc_descr_ref deref;
HOST_WIDE_INT size;
if (dwarf_strict && dwarf_version < 5)
return NULL;
if (!GET_MODE_SIZE (mode).is_constant (&size))
return NULL;
type_die
= base_type_for_mode (mode, SCALAR_INT_MODE_P (mode));
if (type_die == NULL)
return NULL;
deref = new_loc_descr (dwarf_OP (DW_OP_deref_type), size, 0);
deref->dw_loc_oprnd2.val_class = dw_val_class_die_ref;
deref->dw_loc_oprnd2.v.val_die_ref.die = type_die;
deref->dw_loc_oprnd2.v.val_die_ref.external = 0;
add_loc_descr (&mem_loc_result, deref);
}
else if (GET_MODE_SIZE (int_mode) == DWARF2_ADDR_SIZE)
add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0));
else
add_loc_descr (&mem_loc_result,
new_loc_descr (DW_OP_deref_size,
GET_MODE_SIZE (int_mode), 0));
}
break;
case LO_SUM:
return mem_loc_descriptor (XEXP (rtl, 1), mode, mem_mode, initialized);
case LABEL_REF:
/* Some ports can transform a symbol ref into a label ref, because
the symbol ref is too far away and has to be dumped into a constant
pool. */
case CONST:
case SYMBOL_REF:
case UNSPEC:
if (!is_a <scalar_int_mode> (mode, &int_mode)
|| (GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE
#ifdef POINTERS_EXTEND_UNSIGNED
&& (int_mode != Pmode || mem_mode == VOIDmode)
#endif
))
break;
if (GET_CODE (rtl) == UNSPEC)
{
/* If delegitimize_address couldn't do anything with the UNSPEC, we
can't express it in the debug info. This can happen e.g. with some
TLS UNSPECs. Allow UNSPECs formerly from CONST that the backend
approves. */
bool not_ok = false;
subrtx_var_iterator::array_type array;
FOR_EACH_SUBRTX_VAR (iter, array, rtl, ALL)
if (*iter != rtl && !CONSTANT_P (*iter))
{
not_ok = true;
break;
}
if (not_ok)
break;
FOR_EACH_SUBRTX_VAR (iter, array, rtl, ALL)
if (!const_ok_for_output_1 (*iter))
{
not_ok = true;
break;
}
if (not_ok)
break;
rtl = gen_rtx_CONST (GET_MODE (rtl), rtl);
goto symref;
}
if (GET_CODE (rtl) == SYMBOL_REF
&& SYMBOL_REF_TLS_MODEL (rtl) != TLS_MODEL_NONE)
{
dw_loc_descr_ref temp;
/* If this is not defined, we have no way to emit the data. */
if (!targetm.have_tls || !targetm.asm_out.output_dwarf_dtprel)
break;
temp = new_addr_loc_descr (rtl, dtprel_true);
/* We check for DWARF 5 here because gdb did not implement
DW_OP_form_tls_address until after 7.12. */
mem_loc_result = new_loc_descr ((dwarf_version >= 5
? DW_OP_form_tls_address
: DW_OP_GNU_push_tls_address),
0, 0);
add_loc_descr (&mem_loc_result, temp);
break;
}
if (!const_ok_for_output (rtl))
{
if (GET_CODE (rtl) == CONST)
switch (GET_CODE (XEXP (rtl, 0)))
{
case NOT:
op = DW_OP_not;
goto try_const_unop;
case NEG:
op = DW_OP_neg;
goto try_const_unop;
try_const_unop:
rtx arg;
arg = XEXP (XEXP (rtl, 0), 0);
if (!CONSTANT_P (arg))
arg = gen_rtx_CONST (int_mode, arg);
op0 = mem_loc_descriptor (arg, int_mode, mem_mode,
initialized);
if (op0)
{
mem_loc_result = op0;
add_loc_descr (&mem_loc_result, new_loc_descr (op, 0, 0));
}
break;
default:
mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), int_mode,
mem_mode, initialized);
break;
}
break;
}
symref:
mem_loc_result = new_addr_loc_descr (rtl, dtprel_false);
vec_safe_push (used_rtx_array, rtl);
break;
case CONCAT:
case CONCATN:
case VAR_LOCATION:
case DEBUG_IMPLICIT_PTR:
expansion_failed (NULL_TREE, rtl,
"CONCAT/CONCATN/VAR_LOCATION is handled only by loc_descriptor");
return 0;
case ENTRY_VALUE:
if (dwarf_strict && dwarf_version < 5)
return NULL;
if (REG_P (ENTRY_VALUE_EXP (rtl)))
{
if (!is_a <scalar_int_mode> (mode, &int_mode)
|| GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE)
op0 = mem_loc_descriptor (ENTRY_VALUE_EXP (rtl), mode,
VOIDmode, VAR_INIT_STATUS_INITIALIZED);
else
{
unsigned int dbx_regnum = dbx_reg_number (ENTRY_VALUE_EXP (rtl));
if (dbx_regnum == IGNORED_DWARF_REGNUM)
return NULL;
op0 = one_reg_loc_descriptor (dbx_regnum,
VAR_INIT_STATUS_INITIALIZED);
}
}
else if (MEM_P (ENTRY_VALUE_EXP (rtl))
&& REG_P (XEXP (ENTRY_VALUE_EXP (rtl), 0)))
{
op0 = mem_loc_descriptor (ENTRY_VALUE_EXP (rtl), mode,
VOIDmode, VAR_INIT_STATUS_INITIALIZED);
if (op0 && op0->dw_loc_opc == DW_OP_fbreg)
return NULL;
}
else
gcc_unreachable ();
if (op0 == NULL)
return NULL;
mem_loc_result = new_loc_descr (dwarf_OP (DW_OP_entry_value), 0, 0);
mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_loc;
mem_loc_result->dw_loc_oprnd1.v.val_loc = op0;
break;
case DEBUG_PARAMETER_REF:
mem_loc_result = parameter_ref_descriptor (rtl);
break;
case PRE_MODIFY:
/* Extract the PLUS expression nested inside and fall into
PLUS code below. */
rtl = XEXP (rtl, 1);
goto plus;
case PRE_INC:
case PRE_DEC:
/* Turn these into a PLUS expression and fall into the PLUS code
below. */
rtl = gen_rtx_PLUS (mode, XEXP (rtl, 0),
gen_int_mode (GET_CODE (rtl) == PRE_INC
? GET_MODE_UNIT_SIZE (mem_mode)
: -GET_MODE_UNIT_SIZE (mem_mode),
mode));
/* fall through */
case PLUS:
plus:
if (is_based_loc (rtl)
&& is_a <scalar_int_mode> (mode, &int_mode)
&& (GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE
|| XEXP (rtl, 0) == arg_pointer_rtx
|| XEXP (rtl, 0) == frame_pointer_rtx))
mem_loc_result = based_loc_descr (XEXP (rtl, 0),
INTVAL (XEXP (rtl, 1)),
VAR_INIT_STATUS_INITIALIZED);
else
{
mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (mem_loc_result == 0)
break;
if (CONST_INT_P (XEXP (rtl, 1))
&& (GET_MODE_SIZE (as_a <scalar_int_mode> (mode))
<= DWARF2_ADDR_SIZE))
loc_descr_plus_const (&mem_loc_result, INTVAL (XEXP (rtl, 1)));
else
{
op1 = mem_loc_descriptor (XEXP (rtl, 1), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (op1 == 0)
return NULL;
add_loc_descr (&mem_loc_result, op1);
add_loc_descr (&mem_loc_result,
new_loc_descr (DW_OP_plus, 0, 0));
}
}
break;
/* If a pseudo-reg is optimized away, it is possible for it to
be replaced with a MEM containing a multiply or shift. */
case MINUS:
op = DW_OP_minus;
goto do_binop;
case MULT:
op = DW_OP_mul;
goto do_binop;
case DIV:
if ((!dwarf_strict || dwarf_version >= 5)
&& is_a <scalar_int_mode> (mode, &int_mode)
&& GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE)
{
mem_loc_result = typed_binop (DW_OP_div, rtl,
base_type_for_mode (mode, 0),
int_mode, mem_mode);
break;
}
op = DW_OP_div;
goto do_binop;
case UMOD:
op = DW_OP_mod;
goto do_binop;
case ASHIFT:
op = DW_OP_shl;
goto do_shift;
case ASHIFTRT:
op = DW_OP_shra;
goto do_shift;
case LSHIFTRT:
op = DW_OP_shr;
goto do_shift;
do_shift:
if (!is_a <scalar_int_mode> (mode, &int_mode))
break;
op0 = mem_loc_descriptor (XEXP (rtl, 0), int_mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
{
rtx rtlop1 = XEXP (rtl, 1);
if (is_a <scalar_int_mode> (GET_MODE (rtlop1), &op1_mode)
&& GET_MODE_BITSIZE (op1_mode) < GET_MODE_BITSIZE (int_mode))
rtlop1 = gen_rtx_ZERO_EXTEND (int_mode, rtlop1);
op1 = mem_loc_descriptor (rtlop1, int_mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
}
if (op0 == 0 || op1 == 0)
break;
mem_loc_result = op0;
add_loc_descr (&mem_loc_result, op1);
add_loc_descr (&mem_loc_result, new_loc_descr (op, 0, 0));
break;
case AND:
op = DW_OP_and;
goto do_binop;
case IOR:
op = DW_OP_or;
goto do_binop;
case XOR:
op = DW_OP_xor;
goto do_binop;
do_binop:
op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
op1 = mem_loc_descriptor (XEXP (rtl, 1), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (op0 == 0 || op1 == 0)
break;
mem_loc_result = op0;
add_loc_descr (&mem_loc_result, op1);
add_loc_descr (&mem_loc_result, new_loc_descr (op, 0, 0));
break;
case MOD:
if ((!dwarf_strict || dwarf_version >= 5)
&& is_a <scalar_int_mode> (mode, &int_mode)
&& GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE)
{
mem_loc_result = typed_binop (DW_OP_mod, rtl,
base_type_for_mode (mode, 0),
int_mode, mem_mode);
break;
}
op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
op1 = mem_loc_descriptor (XEXP (rtl, 1), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (op0 == 0 || op1 == 0)
break;
mem_loc_result = op0;
add_loc_descr (&mem_loc_result, op1);
add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_over, 0, 0));
add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_over, 0, 0));
add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_div, 0, 0));
add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_mul, 0, 0));
add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_minus, 0, 0));
break;
case UDIV:
if ((!dwarf_strict || dwarf_version >= 5)
&& is_a <scalar_int_mode> (mode, &int_mode))
{
if (GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE)
{
op = DW_OP_div;
goto do_binop;
}
mem_loc_result = typed_binop (DW_OP_div, rtl,
base_type_for_mode (int_mode, 1),
int_mode, mem_mode);
}
break;
case NOT:
op = DW_OP_not;
goto do_unop;
case ABS:
op = DW_OP_abs;
goto do_unop;
case NEG:
op = DW_OP_neg;
goto do_unop;
do_unop:
op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (op0 == 0)
break;
mem_loc_result = op0;
add_loc_descr (&mem_loc_result, new_loc_descr (op, 0, 0));
break;
case CONST_INT:
if (!is_a <scalar_int_mode> (mode, &int_mode)
|| GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE
#ifdef POINTERS_EXTEND_UNSIGNED
|| (int_mode == Pmode
&& mem_mode != VOIDmode
&& trunc_int_for_mode (INTVAL (rtl), ptr_mode) == INTVAL (rtl))
#endif
)
{
mem_loc_result = int_loc_descriptor (INTVAL (rtl));
break;
}
if ((!dwarf_strict || dwarf_version >= 5)
&& (GET_MODE_BITSIZE (int_mode) == HOST_BITS_PER_WIDE_INT
|| GET_MODE_BITSIZE (int_mode) == HOST_BITS_PER_DOUBLE_INT))
{
dw_die_ref type_die = base_type_for_mode (int_mode, 1);
scalar_int_mode amode;
if (type_die == NULL)
return NULL;
if (INTVAL (rtl) >= 0
&& (int_mode_for_size (DWARF2_ADDR_SIZE * BITS_PER_UNIT, 0)
.exists (&amode))
&& trunc_int_for_mode (INTVAL (rtl), amode) == INTVAL (rtl)
/* const DW_OP_convert <XXX> vs.
DW_OP_const_type <XXX, 1, const>. */
&& size_of_int_loc_descriptor (INTVAL (rtl)) + 1 + 1
< (unsigned long) 1 + 1 + 1 + GET_MODE_SIZE (int_mode))
{
mem_loc_result = int_loc_descriptor (INTVAL (rtl));
op0 = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
op0->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
op0->dw_loc_oprnd1.v.val_die_ref.die = type_die;
op0->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&mem_loc_result, op0);
return mem_loc_result;
}
mem_loc_result = new_loc_descr (dwarf_OP (DW_OP_const_type), 0,
INTVAL (rtl));
mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
mem_loc_result->dw_loc_oprnd1.v.val_die_ref.die = type_die;
mem_loc_result->dw_loc_oprnd1.v.val_die_ref.external = 0;
if (GET_MODE_BITSIZE (int_mode) == HOST_BITS_PER_WIDE_INT)
mem_loc_result->dw_loc_oprnd2.val_class = dw_val_class_const;
else
{
mem_loc_result->dw_loc_oprnd2.val_class
= dw_val_class_const_double;
mem_loc_result->dw_loc_oprnd2.v.val_double
= double_int::from_shwi (INTVAL (rtl));
}
}
break;
case CONST_DOUBLE:
if (!dwarf_strict || dwarf_version >= 5)
{
dw_die_ref type_die;
/* Note that if TARGET_SUPPORTS_WIDE_INT == 0, a
CONST_DOUBLE rtx could represent either a large integer
or a floating-point constant. If TARGET_SUPPORTS_WIDE_INT != 0,
the value is always a floating point constant.
When it is an integer, a CONST_DOUBLE is used whenever
the constant requires 2 HWIs to be adequately represented.
We output CONST_DOUBLEs as blocks. */
if (mode == VOIDmode
|| (GET_MODE (rtl) == VOIDmode
&& maybe_ne (GET_MODE_BITSIZE (mode),
HOST_BITS_PER_DOUBLE_INT)))
break;
type_die = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode));
if (type_die == NULL)
return NULL;
mem_loc_result = new_loc_descr (dwarf_OP (DW_OP_const_type), 0, 0);
mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
mem_loc_result->dw_loc_oprnd1.v.val_die_ref.die = type_die;
mem_loc_result->dw_loc_oprnd1.v.val_die_ref.external = 0;
#if TARGET_SUPPORTS_WIDE_INT == 0
if (!SCALAR_FLOAT_MODE_P (mode))
{
mem_loc_result->dw_loc_oprnd2.val_class
= dw_val_class_const_double;
mem_loc_result->dw_loc_oprnd2.v.val_double
= rtx_to_double_int (rtl);
}
else
#endif
{
scalar_float_mode float_mode = as_a <scalar_float_mode> (mode);
unsigned int length = GET_MODE_SIZE (float_mode);
unsigned char *array = ggc_vec_alloc<unsigned char> (length);
insert_float (rtl, array);
mem_loc_result->dw_loc_oprnd2.val_class = dw_val_class_vec;
mem_loc_result->dw_loc_oprnd2.v.val_vec.length = length / 4;
mem_loc_result->dw_loc_oprnd2.v.val_vec.elt_size = 4;
mem_loc_result->dw_loc_oprnd2.v.val_vec.array = array;
}
}
break;
case CONST_WIDE_INT:
if (!dwarf_strict || dwarf_version >= 5)
{
dw_die_ref type_die;
type_die = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode));
if (type_die == NULL)
return NULL;
mem_loc_result = new_loc_descr (dwarf_OP (DW_OP_const_type), 0, 0);
mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
mem_loc_result->dw_loc_oprnd1.v.val_die_ref.die = type_die;
mem_loc_result->dw_loc_oprnd1.v.val_die_ref.external = 0;
mem_loc_result->dw_loc_oprnd2.val_class
= dw_val_class_wide_int;
mem_loc_result->dw_loc_oprnd2.v.val_wide = ggc_alloc<wide_int> ();
*mem_loc_result->dw_loc_oprnd2.v.val_wide = rtx_mode_t (rtl, mode);
}
break;
case CONST_POLY_INT:
mem_loc_result = int_loc_descriptor (rtx_to_poly_int64 (rtl));
break;
case EQ:
mem_loc_result = scompare_loc_descriptor (DW_OP_eq, rtl, mem_mode);
break;
case GE:
mem_loc_result = scompare_loc_descriptor (DW_OP_ge, rtl, mem_mode);
break;
case GT:
mem_loc_result = scompare_loc_descriptor (DW_OP_gt, rtl, mem_mode);
break;
case LE:
mem_loc_result = scompare_loc_descriptor (DW_OP_le, rtl, mem_mode);
break;
case LT:
mem_loc_result = scompare_loc_descriptor (DW_OP_lt, rtl, mem_mode);
break;
case NE:
mem_loc_result = scompare_loc_descriptor (DW_OP_ne, rtl, mem_mode);
break;
case GEU:
mem_loc_result = ucompare_loc_descriptor (DW_OP_ge, rtl, mem_mode);
break;
case GTU:
mem_loc_result = ucompare_loc_descriptor (DW_OP_gt, rtl, mem_mode);
break;
case LEU:
mem_loc_result = ucompare_loc_descriptor (DW_OP_le, rtl, mem_mode);
break;
case LTU:
mem_loc_result = ucompare_loc_descriptor (DW_OP_lt, rtl, mem_mode);
break;
case UMIN:
case UMAX:
if (!SCALAR_INT_MODE_P (mode))
break;
/* FALLTHRU */
case SMIN:
case SMAX:
mem_loc_result = minmax_loc_descriptor (rtl, mode, mem_mode);
break;
case ZERO_EXTRACT:
case SIGN_EXTRACT:
if (CONST_INT_P (XEXP (rtl, 1))
&& CONST_INT_P (XEXP (rtl, 2))
&& is_a <scalar_int_mode> (mode, &int_mode)
&& is_a <scalar_int_mode> (GET_MODE (XEXP (rtl, 0)), &inner_mode)
&& GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE
&& GET_MODE_SIZE (inner_mode) <= DWARF2_ADDR_SIZE
&& ((unsigned) INTVAL (XEXP (rtl, 1))
+ (unsigned) INTVAL (XEXP (rtl, 2))
<= GET_MODE_BITSIZE (int_mode)))
{
int shift, size;
op0 = mem_loc_descriptor (XEXP (rtl, 0), inner_mode,
mem_mode, VAR_INIT_STATUS_INITIALIZED);
if (op0 == 0)
break;
if (GET_CODE (rtl) == SIGN_EXTRACT)
op = DW_OP_shra;
else
op = DW_OP_shr;
mem_loc_result = op0;
size = INTVAL (XEXP (rtl, 1));
shift = INTVAL (XEXP (rtl, 2));
if (BITS_BIG_ENDIAN)
shift = GET_MODE_BITSIZE (inner_mode) - shift - size;
if (shift + size != (int) DWARF2_ADDR_SIZE)
{
add_loc_descr (&mem_loc_result,
int_loc_descriptor (DWARF2_ADDR_SIZE
- shift - size));
add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_shl, 0, 0));
}
if (size != (int) DWARF2_ADDR_SIZE)
{
add_loc_descr (&mem_loc_result,
int_loc_descriptor (DWARF2_ADDR_SIZE - size));
add_loc_descr (&mem_loc_result, new_loc_descr (op, 0, 0));
}
}
break;
case IF_THEN_ELSE:
{
dw_loc_descr_ref op2, bra_node, drop_node;
op0 = mem_loc_descriptor (XEXP (rtl, 0),
GET_MODE (XEXP (rtl, 0)) == VOIDmode
? word_mode : GET_MODE (XEXP (rtl, 0)),
mem_mode, VAR_INIT_STATUS_INITIALIZED);
op1 = mem_loc_descriptor (XEXP (rtl, 1), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
op2 = mem_loc_descriptor (XEXP (rtl, 2), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (op0 == NULL || op1 == NULL || op2 == NULL)
break;
mem_loc_result = op1;
add_loc_descr (&mem_loc_result, op2);
add_loc_descr (&mem_loc_result, op0);
bra_node = new_loc_descr (DW_OP_bra, 0, 0);
add_loc_descr (&mem_loc_result, bra_node);
add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_swap, 0, 0));
drop_node = new_loc_descr (DW_OP_drop, 0, 0);
add_loc_descr (&mem_loc_result, drop_node);
bra_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
bra_node->dw_loc_oprnd1.v.val_loc = drop_node;
}
break;
case FLOAT_EXTEND:
case FLOAT_TRUNCATE:
case FLOAT:
case UNSIGNED_FLOAT:
case FIX:
case UNSIGNED_FIX:
if (!dwarf_strict || dwarf_version >= 5)
{
dw_die_ref type_die;
dw_loc_descr_ref cvt;
op0 = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (XEXP (rtl, 0)),
mem_mode, VAR_INIT_STATUS_INITIALIZED);
if (op0 == NULL)
break;
if (is_a <scalar_int_mode> (GET_MODE (XEXP (rtl, 0)), &int_mode)
&& (GET_CODE (rtl) == FLOAT
|| GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE))
{
type_die = base_type_for_mode (int_mode,
GET_CODE (rtl) == UNSIGNED_FLOAT);
if (type_die == NULL)
break;
cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die;
cvt->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&op0, cvt);
}
type_die = base_type_for_mode (mode, GET_CODE (rtl) == UNSIGNED_FIX);
if (type_die == NULL)
break;
cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0);
cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die;
cvt->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&op0, cvt);
if (is_a <scalar_int_mode> (mode, &int_mode)
&& (GET_CODE (rtl) == FIX
|| GET_MODE_SIZE (int_mode) < DWARF2_ADDR_SIZE))
{
op0 = convert_descriptor_to_mode (int_mode, op0);
if (op0 == NULL)
break;
}
mem_loc_result = op0;
}
break;
case CLZ:
case CTZ:
case FFS:
if (is_a <scalar_int_mode> (mode, &int_mode))
mem_loc_result = clz_loc_descriptor (rtl, int_mode, mem_mode);
break;
case POPCOUNT:
case PARITY:
if (is_a <scalar_int_mode> (mode, &int_mode))
mem_loc_result = popcount_loc_descriptor (rtl, int_mode, mem_mode);
break;
case BSWAP:
if (is_a <scalar_int_mode> (mode, &int_mode))
mem_loc_result = bswap_loc_descriptor (rtl, int_mode, mem_mode);
break;
case ROTATE:
case ROTATERT:
if (is_a <scalar_int_mode> (mode, &int_mode))
mem_loc_result = rotate_loc_descriptor (rtl, int_mode, mem_mode);
break;
case COMPARE:
/* In theory, we could implement the above. */
/* DWARF cannot represent the unsigned compare operations
natively. */
case SS_MULT:
case US_MULT:
case SS_DIV:
case US_DIV:
case SS_PLUS:
case US_PLUS:
case SS_MINUS:
case US_MINUS:
case SS_NEG:
case US_NEG:
case SS_ABS:
case SS_ASHIFT:
case US_ASHIFT:
case SS_TRUNCATE:
case US_TRUNCATE:
case UNORDERED:
case ORDERED:
case UNEQ:
case UNGE:
case UNGT:
case UNLE:
case UNLT:
case LTGT:
case FRACT_CONVERT:
case UNSIGNED_FRACT_CONVERT:
case SAT_FRACT:
case UNSIGNED_SAT_FRACT:
case SQRT:
case ASM_OPERANDS:
case VEC_MERGE:
case VEC_SELECT:
case VEC_CONCAT:
case VEC_DUPLICATE:
case VEC_SERIES:
case HIGH:
case FMA:
case STRICT_LOW_PART:
case CONST_VECTOR:
case CONST_FIXED:
case CLRSB:
case CLOBBER:
break;
case CONST_STRING:
resolve_one_addr (&rtl);
goto symref;
/* RTL sequences inside PARALLEL record a series of DWARF operations for
the expression. An UNSPEC rtx represents a raw DWARF operation,
new_loc_descr is called for it to build the operation directly.
Otherwise mem_loc_descriptor is called recursively. */
case PARALLEL:
{
int index = 0;
dw_loc_descr_ref exp_result = NULL;
for (; index < XVECLEN (rtl, 0); index++)
{
rtx elem = XVECEXP (rtl, 0, index);
if (GET_CODE (elem) == UNSPEC)
{
/* Each DWARF operation UNSPEC contain two operands, if
one operand is not used for the operation, const0_rtx is
passed. */
gcc_assert (XVECLEN (elem, 0) == 2);
HOST_WIDE_INT dw_op = XINT (elem, 1);
HOST_WIDE_INT oprnd1 = INTVAL (XVECEXP (elem, 0, 0));
HOST_WIDE_INT oprnd2 = INTVAL (XVECEXP (elem, 0, 1));
exp_result
= new_loc_descr ((enum dwarf_location_atom) dw_op, oprnd1,
oprnd2);
}
else
exp_result
= mem_loc_descriptor (elem, mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
if (!mem_loc_result)
mem_loc_result = exp_result;
else
add_loc_descr (&mem_loc_result, exp_result);
}
break;
}
default:
if (flag_checking)
{
print_rtl (stderr, rtl);
gcc_unreachable ();
}
break;
}
if (mem_loc_result && initialized == VAR_INIT_STATUS_UNINITIALIZED)
add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_GNU_uninit, 0, 0));
return mem_loc_result;
}
/* Return a descriptor that describes the concatenation of two locations.
This is typically a complex variable. */
static dw_loc_descr_ref
concat_loc_descriptor (rtx x0, rtx x1, enum var_init_status initialized)
{
/* At present we only track constant-sized pieces. */
unsigned int size0, size1;
if (!GET_MODE_SIZE (GET_MODE (x0)).is_constant (&size0)
|| !GET_MODE_SIZE (GET_MODE (x1)).is_constant (&size1))
return 0;
dw_loc_descr_ref cc_loc_result = NULL;
dw_loc_descr_ref x0_ref
= loc_descriptor (x0, VOIDmode, VAR_INIT_STATUS_INITIALIZED);
dw_loc_descr_ref x1_ref
= loc_descriptor (x1, VOIDmode, VAR_INIT_STATUS_INITIALIZED);
if (x0_ref == 0 || x1_ref == 0)
return 0;
cc_loc_result = x0_ref;
add_loc_descr_op_piece (&cc_loc_result, size0);
add_loc_descr (&cc_loc_result, x1_ref);
add_loc_descr_op_piece (&cc_loc_result, size1);
if (initialized == VAR_INIT_STATUS_UNINITIALIZED)
add_loc_descr (&cc_loc_result, new_loc_descr (DW_OP_GNU_uninit, 0, 0));
return cc_loc_result;
}
/* Return a descriptor that describes the concatenation of N
locations. */
static dw_loc_descr_ref
concatn_loc_descriptor (rtx concatn, enum var_init_status initialized)
{
unsigned int i;
dw_loc_descr_ref cc_loc_result = NULL;
unsigned int n = XVECLEN (concatn, 0);
unsigned int size;
for (i = 0; i < n; ++i)
{
dw_loc_descr_ref ref;
rtx x = XVECEXP (concatn, 0, i);
/* At present we only track constant-sized pieces. */
if (!GET_MODE_SIZE (GET_MODE (x)).is_constant (&size))
return NULL;
ref = loc_descriptor (x, VOIDmode, VAR_INIT_STATUS_INITIALIZED);
if (ref == NULL)
return NULL;
add_loc_descr (&cc_loc_result, ref);
add_loc_descr_op_piece (&cc_loc_result, size);
}
if (cc_loc_result && initialized == VAR_INIT_STATUS_UNINITIALIZED)
add_loc_descr (&cc_loc_result, new_loc_descr (DW_OP_GNU_uninit, 0, 0));
return cc_loc_result;
}
/* Helper function for loc_descriptor. Return DW_OP_implicit_pointer
for DEBUG_IMPLICIT_PTR RTL. */
static dw_loc_descr_ref
implicit_ptr_descriptor (rtx rtl, HOST_WIDE_INT offset)
{
dw_loc_descr_ref ret;
dw_die_ref ref;
if (dwarf_strict && dwarf_version < 5)
return NULL;
gcc_assert (TREE_CODE (DEBUG_IMPLICIT_PTR_DECL (rtl)) == VAR_DECL
|| TREE_CODE (DEBUG_IMPLICIT_PTR_DECL (rtl)) == PARM_DECL
|| TREE_CODE (DEBUG_IMPLICIT_PTR_DECL (rtl)) == RESULT_DECL);
ref = lookup_decl_die (DEBUG_IMPLICIT_PTR_DECL (rtl));
ret = new_loc_descr (dwarf_OP (DW_OP_implicit_pointer), 0, offset);
ret->dw_loc_oprnd2.val_class = dw_val_class_const;
if (ref)
{
ret->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
ret->dw_loc_oprnd1.v.val_die_ref.die = ref;
ret->dw_loc_oprnd1.v.val_die_ref.external = 0;
}
else
{
ret->dw_loc_oprnd1.val_class = dw_val_class_decl_ref;
ret->dw_loc_oprnd1.v.val_decl_ref = DEBUG_IMPLICIT_PTR_DECL (rtl);
}
return ret;
}
/* Output a proper Dwarf location descriptor for a variable or parameter
which is either allocated in a register or in a memory location. For a
register, we just generate an OP_REG and the register number. For a
memory location we provide a Dwarf postfix expression describing how to
generate the (dynamic) address of the object onto the address stack.
MODE is mode of the decl if this loc_descriptor is going to be used in
.debug_loc section where DW_OP_stack_value and DW_OP_implicit_value are
allowed, VOIDmode otherwise.
If we don't know how to describe it, return 0. */
static dw_loc_descr_ref
loc_descriptor (rtx rtl, machine_mode mode,
enum var_init_status initialized)
{
dw_loc_descr_ref loc_result = NULL;
scalar_int_mode int_mode;
switch (GET_CODE (rtl))
{
case SUBREG:
/* The case of a subreg may arise when we have a local (register)
variable or a formal (register) parameter which doesn't quite fill
up an entire register. For now, just assume that it is
legitimate to make the Dwarf info refer to the whole register which
contains the given subreg. */
if (REG_P (SUBREG_REG (rtl)) && subreg_lowpart_p (rtl))
loc_result = loc_descriptor (SUBREG_REG (rtl),
GET_MODE (SUBREG_REG (rtl)), initialized);
else
goto do_default;
break;
case REG:
loc_result = reg_loc_descriptor (rtl, initialized);
break;
case MEM:
loc_result = mem_loc_descriptor (XEXP (rtl, 0), get_address_mode (rtl),
GET_MODE (rtl), initialized);
if (loc_result == NULL)
loc_result = tls_mem_loc_descriptor (rtl);
if (loc_result == NULL)
{
rtx new_rtl = avoid_constant_pool_reference (rtl);
if (new_rtl != rtl)
loc_result = loc_descriptor (new_rtl, mode, initialized);
}
break;
case CONCAT:
loc_result = concat_loc_descriptor (XEXP (rtl, 0), XEXP (rtl, 1),
initialized);
break;
case CONCATN:
loc_result = concatn_loc_descriptor (rtl, initialized);
break;
case VAR_LOCATION:
/* Single part. */
if (GET_CODE (PAT_VAR_LOCATION_LOC (rtl)) != PARALLEL)
{
rtx loc = PAT_VAR_LOCATION_LOC (rtl);
if (GET_CODE (loc) == EXPR_LIST)
loc = XEXP (loc, 0);
loc_result = loc_descriptor (loc, mode, initialized);
break;
}
rtl = XEXP (rtl, 1);
/* FALLTHRU */
case PARALLEL:
{
rtvec par_elems = XVEC (rtl, 0);
int num_elem = GET_NUM_ELEM (par_elems);
machine_mode mode;
int i, size;
/* Create the first one, so we have something to add to. */
loc_result = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0),
VOIDmode, initialized);
if (loc_result == NULL)
return NULL;
mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, 0), 0));
/* At present we only track constant-sized pieces. */
if (!GET_MODE_SIZE (mode).is_constant (&size))
return NULL;
add_loc_descr_op_piece (&loc_result, size);
for (i = 1; i < num_elem; i++)
{
dw_loc_descr_ref temp;
temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0),
VOIDmode, initialized);
if (temp == NULL)
return NULL;
add_loc_descr (&loc_result, temp);
mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, i), 0));
/* At present we only track constant-sized pieces. */
if (!GET_MODE_SIZE (mode).is_constant (&size))
return NULL;
add_loc_descr_op_piece (&loc_result, size);
}
}
break;
case CONST_INT:
if (mode != VOIDmode && mode != BLKmode)
{
int_mode = as_a <scalar_int_mode> (mode);
loc_result = address_of_int_loc_descriptor (GET_MODE_SIZE (int_mode),
INTVAL (rtl));
}
break;
case CONST_DOUBLE:
if (mode == VOIDmode)
mode = GET_MODE (rtl);
if (mode != VOIDmode && (dwarf_version >= 4 || !dwarf_strict))
{
gcc_assert (mode == GET_MODE (rtl) || VOIDmode == GET_MODE (rtl));
/* Note that a CONST_DOUBLE rtx could represent either an integer
or a floating-point constant. A CONST_DOUBLE is used whenever
the constant requires more than one word in order to be
adequately represented. We output CONST_DOUBLEs as blocks. */
scalar_mode smode = as_a <scalar_mode> (mode);
loc_result = new_loc_descr (DW_OP_implicit_value,
GET_MODE_SIZE (smode), 0);
#if TARGET_SUPPORTS_WIDE_INT == 0
if (!SCALAR_FLOAT_MODE_P (smode))
{
loc_result->dw_loc_oprnd2.val_class = dw_val_class_const_double;
loc_result->dw_loc_oprnd2.v.val_double
= rtx_to_double_int (rtl);
}
else
#endif
{
unsigned int length = GET_MODE_SIZE (smode);
unsigned char *array = ggc_vec_alloc<unsigned char> (length);
insert_float (rtl, array);
loc_result->dw_loc_oprnd2.val_class = dw_val_class_vec;
loc_result->dw_loc_oprnd2.v.val_vec.length = length / 4;
loc_result->dw_loc_oprnd2.v.val_vec.elt_size = 4;
loc_result->dw_loc_oprnd2.v.val_vec.array = array;
}
}
break;
case CONST_WIDE_INT:
if (mode == VOIDmode)
mode = GET_MODE (rtl);
if (mode != VOIDmode && (dwarf_version >= 4 || !dwarf_strict))
{
int_mode = as_a <scalar_int_mode> (mode);
loc_result = new_loc_descr (DW_OP_implicit_value,
GET_MODE_SIZE (int_mode), 0);
loc_result->dw_loc_oprnd2.val_class = dw_val_class_wide_int;
loc_result->dw_loc_oprnd2.v.val_wide = ggc_alloc<wide_int> ();
*loc_result->dw_loc_oprnd2.v.val_wide = rtx_mode_t (rtl, int_mode);
}
break;
case CONST_VECTOR:
if (mode == VOIDmode)
mode = GET_MODE (rtl);
if (mode != VOIDmode
/* The combination of a length and byte elt_size doesn't extend
naturally to boolean vectors, where several elements are packed
into the same byte. */
&& GET_MODE_CLASS (mode) != MODE_VECTOR_BOOL
&& (dwarf_version >= 4 || !dwarf_strict))
{
unsigned int length;
if (!CONST_VECTOR_NUNITS (rtl).is_constant (&length))
return NULL;
unsigned int elt_size = GET_MODE_UNIT_SIZE (GET_MODE (rtl));
unsigned char *array
= ggc_vec_alloc<unsigned char> (length * elt_size);
unsigned int i;
unsigned char *p;
machine_mode imode = GET_MODE_INNER (mode);
gcc_assert (mode == GET_MODE (rtl) || VOIDmode == GET_MODE (rtl));
switch (GET_MODE_CLASS (mode))
{
case MODE_VECTOR_INT:
for (i = 0, p = array; i < length; i++, p += elt_size)
{
rtx elt = CONST_VECTOR_ELT (rtl, i);
insert_wide_int (rtx_mode_t (elt, imode), p, elt_size);
}
break;
case MODE_VECTOR_FLOAT:
for (i = 0, p = array; i < length; i++, p += elt_size)
{
rtx elt = CONST_VECTOR_ELT (rtl, i);
insert_float (elt, p);
}
break;
default:
gcc_unreachable ();
}
loc_result = new_loc_descr (DW_OP_implicit_value,
length * elt_size, 0);
loc_result->dw_loc_oprnd2.val_class = dw_val_class_vec;
loc_result->dw_loc_oprnd2.v.val_vec.length = length;
loc_result->dw_loc_oprnd2.v.val_vec.elt_size = elt_size;
loc_result->dw_loc_oprnd2.v.val_vec.array = array;
}
break;
case CONST:
if (mode == VOIDmode
|| CONST_SCALAR_INT_P (XEXP (rtl, 0))
|| CONST_DOUBLE_AS_FLOAT_P (XEXP (rtl, 0))
|| GET_CODE (XEXP (rtl, 0)) == CONST_VECTOR)
{
loc_result = loc_descriptor (XEXP (rtl, 0), mode, initialized);
break;
}
/* FALLTHROUGH */
case SYMBOL_REF:
if (!const_ok_for_output (rtl))
break;
/* FALLTHROUGH */
case LABEL_REF:
if (is_a <scalar_int_mode> (mode, &int_mode)
&& GET_MODE_SIZE (int_mode) == DWARF2_ADDR_SIZE
&& (dwarf_version >= 4 || !dwarf_strict))
{
loc_result = new_addr_loc_descr (rtl, dtprel_false);
add_loc_descr (&loc_result, new_loc_descr (DW_OP_stack_value, 0, 0));
vec_safe_push (used_rtx_array, rtl);
}
break;
case DEBUG_IMPLICIT_PTR:
loc_result = implicit_ptr_descriptor (rtl, 0);
break;
case PLUS:
if (GET_CODE (XEXP (rtl, 0)) == DEBUG_IMPLICIT_PTR
&& CONST_INT_P (XEXP (rtl, 1)))
{
loc_result
= implicit_ptr_descriptor (XEXP (rtl, 0), INTVAL (XEXP (rtl, 1)));
break;
}
/* FALLTHRU */
do_default:
default:
if ((is_a <scalar_int_mode> (mode, &int_mode)
&& GET_MODE (rtl) == int_mode
&& GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE
&& dwarf_version >= 4)
|| (!dwarf_strict && mode != VOIDmode && mode != BLKmode))
{
/* Value expression. */
loc_result = mem_loc_descriptor (rtl, mode, VOIDmode, initialized);
if (loc_result)
add_loc_descr (&loc_result,
new_loc_descr (DW_OP_stack_value, 0, 0));
}
break;
}
return loc_result;
}
/* We need to figure out what section we should use as the base for the
address ranges where a given location is valid.
1. If this particular DECL has a section associated with it, use that.
2. If this function has a section associated with it, use that.
3. Otherwise, use the text section.
XXX: If you split a variable across multiple sections, we won't notice. */
static const char *
secname_for_decl (const_tree decl)
{
const char *secname;
if (VAR_OR_FUNCTION_DECL_P (decl)
&& (DECL_EXTERNAL (decl) || TREE_PUBLIC (decl) || TREE_STATIC (decl))
&& DECL_SECTION_NAME (decl))
secname = DECL_SECTION_NAME (decl);
else if (current_function_decl && DECL_SECTION_NAME (current_function_decl))
{
if (in_cold_section_p)
{
section *sec = current_function_section ();
if (sec->common.flags & SECTION_NAMED)
return sec->named.name;
}
secname = DECL_SECTION_NAME (current_function_decl);
}
else if (cfun && in_cold_section_p)
secname = crtl->subsections.cold_section_label;
else
secname = text_section_label;
return secname;
}
/* Return true when DECL_BY_REFERENCE is defined and set for DECL. */
static bool
decl_by_reference_p (tree decl)
{
return ((TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == RESULT_DECL
|| VAR_P (decl))
&& DECL_BY_REFERENCE (decl));
}
/* Helper function for dw_loc_list. Compute proper Dwarf location descriptor
for VARLOC. */
static dw_loc_descr_ref
dw_loc_list_1 (tree loc, rtx varloc, int want_address,
enum var_init_status initialized)
{
int have_address = 0;
dw_loc_descr_ref descr;
machine_mode mode;
if (want_address != 2)
{
gcc_assert (GET_CODE (varloc) == VAR_LOCATION);
/* Single part. */
if (GET_CODE (PAT_VAR_LOCATION_LOC (varloc)) != PARALLEL)
{
varloc = PAT_VAR_LOCATION_LOC (varloc);
if (GET_CODE (varloc) == EXPR_LIST)
varloc = XEXP (varloc, 0);
mode = GET_MODE (varloc);
if (MEM_P (varloc))
{
rtx addr = XEXP (varloc, 0);
descr = mem_loc_descriptor (addr, get_address_mode (varloc),
mode, initialized);
if (descr)
have_address = 1;
else
{
rtx x = avoid_constant_pool_reference (varloc);
if (x != varloc)
descr = mem_loc_descriptor (x, mode, VOIDmode,
initialized);
}
}
else
descr = mem_loc_descriptor (varloc, mode, VOIDmode, initialized);
}
else
return 0;
}
else
{
if (GET_CODE (varloc) == VAR_LOCATION)
mode = DECL_MODE (PAT_VAR_LOCATION_DECL (varloc));
else
mode = DECL_MODE (loc);
descr = loc_descriptor (varloc, mode, initialized);
have_address = 1;
}
if (!descr)
return 0;
if (want_address == 2 && !have_address
&& (dwarf_version >= 4 || !dwarf_strict))
{
if (int_size_in_bytes (TREE_TYPE (loc)) > DWARF2_ADDR_SIZE)
{
expansion_failed (loc, NULL_RTX,
"DWARF address size mismatch");
return 0;
}
add_loc_descr (&descr, new_loc_descr (DW_OP_stack_value, 0, 0));
have_address = 1;
}
/* Show if we can't fill the request for an address. */
if (want_address && !have_address)
{
expansion_failed (loc, NULL_RTX,
"Want address and only have value");
return 0;
}
/* If we've got an address and don't want one, dereference. */
if (!want_address && have_address)
{
HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (loc));
enum dwarf_location_atom op;
if (size > DWARF2_ADDR_SIZE || size == -1)
{
expansion_failed (loc, NULL_RTX,
"DWARF address size mismatch");
return 0;
}
else if (size == DWARF2_ADDR_SIZE)
op = DW_OP_deref;
else
op = DW_OP_deref_size;
add_loc_descr (&descr, new_loc_descr (op, size, 0));
}
return descr;
}
/* Create a DW_OP_piece or DW_OP_bit_piece for bitsize, or return NULL
if it is not possible. */
static dw_loc_descr_ref
new_loc_descr_op_bit_piece (HOST_WIDE_INT bitsize, HOST_WIDE_INT offset)
{
if ((bitsize % BITS_PER_UNIT) == 0 && offset == 0)
return new_loc_descr (DW_OP_piece, bitsize / BITS_PER_UNIT, 0);
else if (dwarf_version >= 3 || !dwarf_strict)
return new_loc_descr (DW_OP_bit_piece, bitsize, offset);
else
return NULL;
}
/* Helper function for dw_loc_list. Compute proper Dwarf location descriptor
for VAR_LOC_NOTE for variable DECL that has been optimized by SRA. */
static dw_loc_descr_ref
dw_sra_loc_expr (tree decl, rtx loc)
{
rtx p;
unsigned HOST_WIDE_INT padsize = 0;
dw_loc_descr_ref descr, *descr_tail;
unsigned HOST_WIDE_INT decl_size;
rtx varloc;
enum var_init_status initialized;
if (DECL_SIZE (decl) == NULL
|| !tree_fits_uhwi_p (DECL_SIZE (decl)))
return NULL;
decl_size = tree_to_uhwi (DECL_SIZE (decl));
descr = NULL;
descr_tail = &descr;
for (p = loc; p; p = XEXP (p, 1))
{
unsigned HOST_WIDE_INT bitsize = decl_piece_bitsize (p);
rtx loc_note = *decl_piece_varloc_ptr (p);
dw_loc_descr_ref cur_descr;
dw_loc_descr_ref *tail, last = NULL;
unsigned HOST_WIDE_INT opsize = 0;
if (loc_note == NULL_RTX
|| NOTE_VAR_LOCATION_LOC (loc_note) == NULL_RTX)
{
padsize += bitsize;
continue;
}
initialized = NOTE_VAR_LOCATION_STATUS (loc_note);
varloc = NOTE_VAR_LOCATION (loc_note);
cur_descr = dw_loc_list_1 (decl, varloc, 2, initialized);
if (cur_descr == NULL)
{
padsize += bitsize;
continue;
}
/* Check that cur_descr either doesn't use
DW_OP_*piece operations, or their sum is equal
to bitsize. Otherwise we can't embed it. */
for (tail = &cur_descr; *tail != NULL;
tail = &(*tail)->dw_loc_next)
if ((*tail)->dw_loc_opc == DW_OP_piece)
{
opsize += (*tail)->dw_loc_oprnd1.v.val_unsigned
* BITS_PER_UNIT;
last = *tail;
}
else if ((*tail)->dw_loc_opc == DW_OP_bit_piece)
{
opsize += (*tail)->dw_loc_oprnd1.v.val_unsigned;
last = *tail;
}
if (last != NULL && opsize != bitsize)
{
padsize += bitsize;
/* Discard the current piece of the descriptor and release any
addr_table entries it uses. */
remove_loc_list_addr_table_entries (cur_descr);
continue;
}
/* If there is a hole, add DW_OP_*piece after empty DWARF
expression, which means that those bits are optimized out. */
if (padsize)
{
if (padsize > decl_size)
{
remove_loc_list_addr_table_entries (cur_descr);
goto discard_descr;
}
decl_size -= padsize;
*descr_tail = new_loc_descr_op_bit_piece (padsize, 0);
if (*descr_tail == NULL)
{
remove_loc_list_addr_table_entries (cur_descr);
goto discard_descr;
}
descr_tail = &(*descr_tail)->dw_loc_next;
padsize = 0;
}
*descr_tail = cur_descr;
descr_tail = tail;
if (bitsize > decl_size)
goto discard_descr;
decl_size -= bitsize;
if (last == NULL)
{
HOST_WIDE_INT offset = 0;
if (GET_CODE (varloc) == VAR_LOCATION
&& GET_CODE (PAT_VAR_LOCATION_LOC (varloc)) != PARALLEL)
{
varloc = PAT_VAR_LOCATION_LOC (varloc);
if (GET_CODE (varloc) == EXPR_LIST)
varloc = XEXP (varloc, 0);
}
do
{
if (GET_CODE (varloc) == CONST
|| GET_CODE (varloc) == SIGN_EXTEND
|| GET_CODE (varloc) == ZERO_EXTEND)
varloc = XEXP (varloc, 0);
else if (GET_CODE (varloc) == SUBREG)
varloc = SUBREG_REG (varloc);
else
break;
}
while (1);
/* DW_OP_bit_size offset should be zero for register
or implicit location descriptions and empty location
descriptions, but for memory addresses needs big endian
adjustment. */
if (MEM_P (varloc))
{
unsigned HOST_WIDE_INT memsize;
if (!poly_uint64 (MEM_SIZE (varloc)).is_constant (&memsize))
goto discard_descr;
memsize *= BITS_PER_UNIT;
if (memsize != bitsize)
{
if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN
&& (memsize > BITS_PER_WORD || bitsize > BITS_PER_WORD))
goto discard_descr;
if (memsize < bitsize)
goto discard_descr;
if (BITS_BIG_ENDIAN)
offset = memsize - bitsize;
}
}
*descr_tail = new_loc_descr_op_bit_piece (bitsize, offset);
if (*descr_tail == NULL)
goto discard_descr;
descr_tail = &(*descr_tail)->dw_loc_next;
}
}
/* If there were any non-empty expressions, add padding till the end of
the decl. */
if (descr != NULL && decl_size != 0)
{
*descr_tail = new_loc_descr_op_bit_piece (decl_size, 0);
if (*descr_tail == NULL)
goto discard_descr;
}
return descr;
discard_descr:
/* Discard the descriptor and release any addr_table entries it uses. */
remove_loc_list_addr_table_entries (descr);
return NULL;
}
/* Return the dwarf representation of the location list LOC_LIST of
DECL. WANT_ADDRESS has the same meaning as in loc_list_from_tree
function. */
static dw_loc_list_ref
dw_loc_list (var_loc_list *loc_list, tree decl, int want_address)
{
const char *endname, *secname;
var_loc_view endview;
rtx varloc;
enum var_init_status initialized;
struct var_loc_node *node;
dw_loc_descr_ref descr;
char label_id[MAX_ARTIFICIAL_LABEL_BYTES];
dw_loc_list_ref list = NULL;
dw_loc_list_ref *listp = &list;
/* Now that we know what section we are using for a base,
actually construct the list of locations.
The first location information is what is passed to the
function that creates the location list, and the remaining
locations just get added on to that list.
Note that we only know the start address for a location
(IE location changes), so to build the range, we use
the range [current location start, next location start].
This means we have to special case the last node, and generate
a range of [last location start, end of function label]. */
if (cfun && crtl->has_bb_partition)
{
bool save_in_cold_section_p = in_cold_section_p;
in_cold_section_p = first_function_block_is_cold;
if (loc_list->last_before_switch == NULL)
in_cold_section_p = !in_cold_section_p;
secname = secname_for_decl (decl);
in_cold_section_p = save_in_cold_section_p;
}
else
secname = secname_for_decl (decl);
for (node = loc_list->first; node; node = node->next)
{
bool range_across_switch = false;
if (GET_CODE (node->loc) == EXPR_LIST
|| NOTE_VAR_LOCATION_LOC (node->loc) != NULL_RTX)
{
if (GET_CODE (node->loc) == EXPR_LIST)
{
descr = NULL;
/* This requires DW_OP_{,bit_}piece, which is not usable
inside DWARF expressions. */
if (want_address == 2)
descr = dw_sra_loc_expr (decl, node->loc);
}
else
{
initialized = NOTE_VAR_LOCATION_STATUS (node->loc);
varloc = NOTE_VAR_LOCATION (node->loc);
descr = dw_loc_list_1 (decl, varloc, want_address, initialized);
}
if (descr)
{
/* If section switch happens in between node->label
and node->next->label (or end of function) and
we can't emit it as a single entry list,
emit two ranges, first one ending at the end
of first partition and second one starting at the
beginning of second partition. */
if (node == loc_list->last_before_switch
&& (node != loc_list->first || loc_list->first->next
/* If we are to emit a view number, we will emit
a loclist rather than a single location
expression for the entire function (see
loc_list_has_views), so we have to split the
range that straddles across partitions. */
|| !ZERO_VIEW_P (node->view))
&& current_function_decl)
{
endname = cfun->fde->dw_fde_end;
endview = 0;
range_across_switch = true;
}
/* The variable has a location between NODE->LABEL and
NODE->NEXT->LABEL. */
else if (node->next)
endname = node->next->label, endview = node->next->view;
/* If the variable has a location at the last label
it keeps its location until the end of function. */
else if (!current_function_decl)
endname = text_end_label, endview = 0;
else
{
ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL,
current_function_funcdef_no);
endname = ggc_strdup (label_id);
endview = 0;
}
*listp = new_loc_list (descr, node->label, node->view,
endname, endview, secname);
if (TREE_CODE (decl) == PARM_DECL
&& node == loc_list->first
&& NOTE_P (node->loc)
&& strcmp (node->label, endname) == 0)
(*listp)->force = true;
listp = &(*listp)->dw_loc_next;
}
}
if (cfun
&& crtl->has_bb_partition
&& node == loc_list->last_before_switch)
{
bool save_in_cold_section_p = in_cold_section_p;
in_cold_section_p = !first_function_block_is_cold;
secname = secname_for_decl (decl);
in_cold_section_p = save_in_cold_section_p;
}
if (range_across_switch)
{
if (GET_CODE (node->loc) == EXPR_LIST)
descr = dw_sra_loc_expr (decl, node->loc);
else
{
initialized = NOTE_VAR_LOCATION_STATUS (node->loc);
varloc = NOTE_VAR_LOCATION (node->loc);
descr = dw_loc_list_1 (decl, varloc, want_address,
initialized);
}
gcc_assert (descr);
/* The variable has a location between NODE->LABEL and
NODE->NEXT->LABEL. */
if (node->next)
endname = node->next->label, endview = node->next->view;
else
endname = cfun->fde->dw_fde_second_end, endview = 0;
*listp = new_loc_list (descr, cfun->fde->dw_fde_second_begin, 0,
endname, endview, secname);
listp = &(*listp)->dw_loc_next;
}
}
/* Try to avoid the overhead of a location list emitting a location
expression instead, but only if we didn't have more than one
location entry in the first place. If some entries were not
representable, we don't want to pretend a single entry that was
applies to the entire scope in which the variable is
available. */
if (list && loc_list->first->next)
gen_llsym (list);
else
maybe_gen_llsym (list);
return list;
}
/* Return if the loc_list has only single element and thus can be represented
as location description. */
static bool
single_element_loc_list_p (dw_loc_list_ref list)
{
gcc_assert (!list->dw_loc_next || list->ll_symbol);
return !list->ll_symbol;
}
/* Duplicate a single element of location list. */
static inline dw_loc_descr_ref
copy_loc_descr (dw_loc_descr_ref ref)
{
dw_loc_descr_ref copy = ggc_alloc<dw_loc_descr_node> ();
memcpy (copy, ref, sizeof (dw_loc_descr_node));
return copy;
}
/* To each location in list LIST append loc descr REF. */
static void
add_loc_descr_to_each (dw_loc_list_ref list, dw_loc_descr_ref ref)
{
dw_loc_descr_ref copy;
add_loc_descr (&list->expr, ref);
list = list->dw_loc_next;
while (list)
{
copy = copy_loc_descr (ref);
add_loc_descr (&list->expr, copy);
while (copy->dw_loc_next)
copy = copy->dw_loc_next = copy_loc_descr (copy->dw_loc_next);
list = list->dw_loc_next;
}
}
/* To each location in list LIST prepend loc descr REF. */
static void
prepend_loc_descr_to_each (dw_loc_list_ref list, dw_loc_descr_ref ref)
{
dw_loc_descr_ref copy;
dw_loc_descr_ref ref_end = list->expr;
add_loc_descr (&ref, list->expr);
list->expr = ref;
list = list->dw_loc_next;
while (list)
{
dw_loc_descr_ref end = list->expr;
list->expr = copy = copy_loc_descr (ref);
while (copy->dw_loc_next != ref_end)
copy = copy->dw_loc_next = copy_loc_descr (copy->dw_loc_next);
copy->dw_loc_next = end;
list = list->dw_loc_next;
}
}
/* Given two lists RET and LIST
produce location list that is result of adding expression in LIST
to expression in RET on each position in program.
Might be destructive on both RET and LIST.
TODO: We handle only simple cases of RET or LIST having at most one
element. General case would involve sorting the lists in program order
and merging them that will need some additional work.
Adding that will improve quality of debug info especially for SRA-ed
structures. */
static void
add_loc_list (dw_loc_list_ref *ret, dw_loc_list_ref list)
{
if (!list)
return;
if (!*ret)
{
*ret = list;
return;
}
if (!list->dw_loc_next)
{
add_loc_descr_to_each (*ret, list->expr);
return;
}
if (!(*ret)->dw_loc_next)
{
prepend_loc_descr_to_each (list, (*ret)->expr);
*ret = list;
return;
}
expansion_failed (NULL_TREE, NULL_RTX,
"Don't know how to merge two non-trivial"
" location lists.\n");
*ret = NULL;
return;
}
/* LOC is constant expression. Try a luck, look it up in constant
pool and return its loc_descr of its address. */
static dw_loc_descr_ref
cst_pool_loc_descr (tree loc)
{
/* Get an RTL for this, if something has been emitted. */
rtx rtl = lookup_constant_def (loc);
if (!rtl || !MEM_P (rtl))
{
gcc_assert (!rtl);
return 0;
}
gcc_assert (GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF);
/* TODO: We might get more coverage if we was actually delaying expansion
of all expressions till end of compilation when constant pools are fully
populated. */
if (!TREE_ASM_WRITTEN (SYMBOL_REF_DECL (XEXP (rtl, 0))))
{
expansion_failed (loc, NULL_RTX,
"CST value in contant pool but not marked.");
return 0;
}
return mem_loc_descriptor (XEXP (rtl, 0), get_address_mode (rtl),
GET_MODE (rtl), VAR_INIT_STATUS_INITIALIZED);
}
/* Return dw_loc_list representing address of addr_expr LOC
by looking for inner INDIRECT_REF expression and turning
it into simple arithmetics.
See loc_list_from_tree for the meaning of CONTEXT. */
static dw_loc_list_ref
loc_list_for_address_of_addr_expr_of_indirect_ref (tree loc, bool toplev,
loc_descr_context *context)
{
tree obj, offset;
poly_int64 bitsize, bitpos, bytepos;
machine_mode mode;
int unsignedp, reversep, volatilep = 0;
dw_loc_list_ref list_ret = NULL, list_ret1 = NULL;
obj = get_inner_reference (TREE_OPERAND (loc, 0),
&bitsize, &bitpos, &offset, &mode,
&unsignedp, &reversep, &volatilep);
STRIP_NOPS (obj);
if (!multiple_p (bitpos, BITS_PER_UNIT, &bytepos))
{
expansion_failed (loc, NULL_RTX, "bitfield access");
return 0;
}
if (!INDIRECT_REF_P (obj))
{
expansion_failed (obj,
NULL_RTX, "no indirect ref in inner refrence");
return 0;
}
if (!offset && known_eq (bitpos, 0))
list_ret = loc_list_from_tree (TREE_OPERAND (obj, 0), toplev ? 2 : 1,
context);
else if (toplev
&& int_size_in_bytes (TREE_TYPE (loc)) <= DWARF2_ADDR_SIZE
&& (dwarf_version >= 4 || !dwarf_strict))
{
list_ret = loc_list_from_tree (TREE_OPERAND (obj, 0), 0, context);
if (!list_ret)
return 0;
if (offset)
{
/* Variable offset. */
list_ret1 = loc_list_from_tree (offset, 0, context);
if (list_ret1 == 0)
return 0;
add_loc_list (&list_ret, list_ret1);
if (!list_ret)
return 0;
add_loc_descr_to_each (list_ret,
new_loc_descr (DW_OP_plus, 0, 0));
}
HOST_WIDE_INT value;
if (bytepos.is_constant (&value) && value > 0)
add_loc_descr_to_each (list_ret,
new_loc_descr (DW_OP_plus_uconst, value, 0));
else if (maybe_ne (bytepos, 0))
loc_list_plus_const (list_ret, bytepos);
add_loc_descr_to_each (list_ret,
new_loc_descr (DW_OP_stack_value, 0, 0));
}
return list_ret;
}
/* Set LOC to the next operation that is not a DW_OP_nop operation. In the case
all operations from LOC are nops, move to the last one. Insert in NOPS all
operations that are skipped. */
static void
loc_descr_to_next_no_nop (dw_loc_descr_ref &loc,
hash_set<dw_loc_descr_ref> &nops)
{
while (loc->dw_loc_next != NULL && loc->dw_loc_opc == DW_OP_nop)
{
nops.add (loc);
loc = loc->dw_loc_next;
}
}
/* Helper for loc_descr_without_nops: free the location description operation
P. */
bool
free_loc_descr (const dw_loc_descr_ref &loc, void *data ATTRIBUTE_UNUSED)
{
ggc_free (loc);
return true;
}
/* Remove all DW_OP_nop operations from LOC except, if it exists, the one that
finishes LOC. */
static void
loc_descr_without_nops (dw_loc_descr_ref &loc)
{
if (loc->dw_loc_opc == DW_OP_nop && loc->dw_loc_next == NULL)
return;
/* Set of all DW_OP_nop operations we remove. */
hash_set<dw_loc_descr_ref> nops;
/* First, strip all prefix NOP operations in order to keep the head of the
operations list. */
loc_descr_to_next_no_nop (loc, nops);
for (dw_loc_descr_ref cur = loc; cur != NULL;)
{
/* For control flow operations: strip "prefix" nops in destination
labels. */
if (cur->dw_loc_oprnd1.val_class == dw_val_class_loc)
loc_descr_to_next_no_nop (cur->dw_loc_oprnd1.v.val_loc, nops);
if (cur->dw_loc_oprnd2.val_class == dw_val_class_loc)
loc_descr_to_next_no_nop (cur->dw_loc_oprnd2.v.val_loc, nops);
/* Do the same for the operations that follow, then move to the next
iteration. */
if (cur->dw_loc_next != NULL)
loc_descr_to_next_no_nop (cur->dw_loc_next, nops);
cur = cur->dw_loc_next;
}
nops.traverse<void *, free_loc_descr> (NULL);
}
struct dwarf_procedure_info;
/* Helper structure for location descriptions generation. */
struct loc_descr_context
{
/* The type that is implicitly referenced by DW_OP_push_object_address, or
NULL_TREE if DW_OP_push_object_address in invalid for this location
description. This is used when processing PLACEHOLDER_EXPR nodes. */
tree context_type;
/* The ..._DECL node that should be translated as a
DW_OP_push_object_address operation. */
tree base_decl;
/* Information about the DWARF procedure we are currently generating. NULL if
we are not generating a DWARF procedure. */
struct dwarf_procedure_info *dpi;
/* True if integral PLACEHOLDER_EXPR stands for the first argument passed
by consumer. Used for DW_TAG_generic_subrange attributes. */
bool placeholder_arg;
/* True if PLACEHOLDER_EXPR has been seen. */
bool placeholder_seen;
};
/* DWARF procedures generation
DWARF expressions (aka. location descriptions) are used to encode variable
things such as sizes or offsets. Such computations can have redundant parts
that can be factorized in order to reduce the size of the output debug
information. This is the whole point of DWARF procedures.
Thanks to stor-layout.c, size and offset expressions in GENERIC trees are
already factorized into functions ("size functions") in order to handle very
big and complex types. Such functions are quite simple: they have integral
arguments, they return an integral result and their body contains only a
return statement with arithmetic expressions. This is the only kind of
function we are interested in translating into DWARF procedures, here.
DWARF expressions and DWARF procedure are executed using a stack, so we have
to define some calling convention for them to interact. Let's say that:
- Before calling a DWARF procedure, DWARF expressions must push on the stack
all arguments in reverse order (right-to-left) so that when the DWARF
procedure execution starts, the first argument is the top of the stack.
- Then, when returning, the DWARF procedure must have consumed all arguments
on the stack, must have pushed the result and touched nothing else.
- Each integral argument and the result are integral types can be hold in a
single stack slot.
- We call "frame offset" the number of stack slots that are "under DWARF
procedure control": it includes the arguments slots, the temporaries and
the result slot. Thus, it is equal to the number of arguments when the
procedure execution starts and must be equal to one (the result) when it
returns. */
/* Helper structure used when generating operations for a DWARF procedure. */
struct dwarf_procedure_info
{
/* The FUNCTION_DECL node corresponding to the DWARF procedure that is
currently translated. */
tree fndecl;
/* The number of arguments FNDECL takes. */
unsigned args_count;
};
/* Return a pointer to a newly created DIE node for a DWARF procedure. Add
LOCATION as its DW_AT_location attribute. If FNDECL is not NULL_TREE,
equate it to this DIE. */
static dw_die_ref
new_dwarf_proc_die (dw_loc_descr_ref location, tree fndecl,
dw_die_ref parent_die)
{
dw_die_ref dwarf_proc_die;
if ((dwarf_version < 3 && dwarf_strict)
|| location == NULL)
return NULL;
dwarf_proc_die = new_die (DW_TAG_dwarf_procedure, parent_die, fndecl);
if (fndecl)
equate_decl_number_to_die (fndecl, dwarf_proc_die);
add_AT_loc (dwarf_proc_die, DW_AT_location, location);
return dwarf_proc_die;
}
/* Return whether TYPE is a supported type as a DWARF procedure argument
type or return type (we handle only scalar types and pointer types that
aren't wider than the DWARF expression evaluation stack. */
static bool
is_handled_procedure_type (tree type)
{
return ((INTEGRAL_TYPE_P (type)
|| TREE_CODE (type) == OFFSET_TYPE
|| TREE_CODE (type) == POINTER_TYPE)
&& int_size_in_bytes (type) <= DWARF2_ADDR_SIZE);
}
/* Helper for resolve_args_picking: do the same but stop when coming across
visited nodes. For each node we visit, register in FRAME_OFFSETS the frame
offset *before* evaluating the corresponding operation. */
static bool
resolve_args_picking_1 (dw_loc_descr_ref loc, unsigned initial_frame_offset,
struct dwarf_procedure_info *dpi,
hash_map<dw_loc_descr_ref, unsigned> &frame_offsets)
{
/* The "frame_offset" identifier is already used to name a macro... */
unsigned frame_offset_ = initial_frame_offset;
dw_loc_descr_ref l;
for (l = loc; l != NULL;)
{
bool existed;
unsigned &l_frame_offset = frame_offsets.get_or_insert (l, &existed);
/* If we already met this node, there is nothing to compute anymore. */
if (existed)
{
/* Make sure that the stack size is consistent wherever the execution
flow comes from. */
gcc_assert ((unsigned) l_frame_offset == frame_offset_);
break;
}
l_frame_offset = frame_offset_;
/* If needed, relocate the picking offset with respect to the frame
offset. */
if (l->frame_offset_rel)
{
unsigned HOST_WIDE_INT off;
switch (l->dw_loc_opc)
{
case DW_OP_pick:
off = l->dw_loc_oprnd1.v.val_unsigned;
break;
case DW_OP_dup:
off = 0;
break;
case DW_OP_over:
off = 1;
break;
default:
gcc_unreachable ();
}
/* frame_offset_ is the size of the current stack frame, including
incoming arguments. Besides, the arguments are pushed
right-to-left. Thus, in order to access the Nth argument from
this operation node, the picking has to skip temporaries *plus*
one stack slot per argument (0 for the first one, 1 for the second
one, etc.).
The targetted argument number (N) is already set as the operand,
and the number of temporaries can be computed with:
frame_offsets_ - dpi->args_count */
off += frame_offset_ - dpi->args_count;
/* DW_OP_pick handles only offsets from 0 to 255 (inclusive)... */
if (off > 255)
return false;
if (off == 0)
{
l->dw_loc_opc = DW_OP_dup;
l->dw_loc_oprnd1.v.val_unsigned = 0;
}
else if (off == 1)
{
l->dw_loc_opc = DW_OP_over;
l->dw_loc_oprnd1.v.val_unsigned = 0;
}
else
{
l->dw_loc_opc = DW_OP_pick;
l->dw_loc_oprnd1.v.val_unsigned = off;
}
}
/* Update frame_offset according to the effect the current operation has
on the stack. */
switch (l->dw_loc_opc)
{
case DW_OP_deref:
case DW_OP_swap:
case DW_OP_rot:
case DW_OP_abs:
case DW_OP_neg:
case DW_OP_not:
case DW_OP_plus_uconst:
case DW_OP_skip:
case DW_OP_reg0:
case DW_OP_reg1:
case DW_OP_reg2:
case DW_OP_reg3:
case DW_OP_reg4:
case DW_OP_reg5:
case DW_OP_reg6:
case DW_OP_reg7:
case DW_OP_reg8:
case DW_OP_reg9:
case DW_OP_reg10:
case DW_OP_reg11:
case DW_OP_reg12:
case DW_OP_reg13:
case DW_OP_reg14:
case DW_OP_reg15:
case DW_OP_reg16:
case DW_OP_reg17:
case DW_OP_reg18:
case DW_OP_reg19:
case DW_OP_reg20:
case DW_OP_reg21:
case DW_OP_reg22:
case DW_OP_reg23:
case DW_OP_reg24:
case DW_OP_reg25:
case DW_OP_reg26:
case DW_OP_reg27:
case DW_OP_reg28:
case DW_OP_reg29:
case DW_OP_reg30:
case DW_OP_reg31:
case DW_OP_bregx:
case DW_OP_piece:
case DW_OP_deref_size:
case DW_OP_nop:
case DW_OP_bit_piece:
case DW_OP_implicit_value:
case DW_OP_stack_value:
break;
case DW_OP_addr:
case DW_OP_const1u:
case DW_OP_const1s:
case DW_OP_const2u:
case DW_OP_const2s:
case DW_OP_const4u:
case DW_OP_const4s:
case DW_OP_const8u:
case DW_OP_const8s:
case DW_OP_constu:
case DW_OP_consts:
case DW_OP_dup:
case DW_OP_over:
case DW_OP_pick:
case DW_OP_lit0:
case DW_OP_lit1:
case DW_OP_lit2:
case DW_OP_lit3:
case DW_OP_lit4:
case DW_OP_lit5:
case DW_OP_lit6:
case DW_OP_lit7:
case DW_OP_lit8:
case DW_OP_lit9:
case DW_OP_lit10:
case DW_OP_lit11:
case DW_OP_lit12:
case DW_OP_lit13:
case DW_OP_lit14:
case DW_OP_lit15:
case DW_OP_lit16:
case DW_OP_lit17:
case DW_OP_lit18:
case DW_OP_lit19:
case DW_OP_lit20:
case DW_OP_lit21:
case DW_OP_lit22:
case DW_OP_lit23:
case DW_OP_lit24:
case DW_OP_lit25:
case DW_OP_lit26:
case DW_OP_lit27:
case DW_OP_lit28:
case DW_OP_lit29:
case DW_OP_lit30:
case DW_OP_lit31:
case DW_OP_breg0:
case DW_OP_breg1:
case DW_OP_breg2:
case DW_OP_breg3:
case DW_OP_breg4:
case DW_OP_breg5:
case DW_OP_breg6:
case DW_OP_breg7:
case DW_OP_breg8:
case DW_OP_breg9:
case DW_OP_breg10:
case DW_OP_breg11:
case DW_OP_breg12:
case DW_OP_breg13:
case DW_OP_breg14:
case DW_OP_breg15:
case DW_OP_breg16:
case DW_OP_breg17:
case DW_OP_breg18:
case DW_OP_breg19:
case DW_OP_breg20:
case DW_OP_breg21:
case DW_OP_breg22:
case DW_OP_breg23:
case DW_OP_breg24:
case DW_OP_breg25:
case DW_OP_breg26:
case DW_OP_breg27:
case DW_OP_breg28:
case DW_OP_breg29:
case DW_OP_breg30:
case DW_OP_breg31:
case DW_OP_fbreg:
case DW_OP_push_object_address:
case DW_OP_call_frame_cfa:
case DW_OP_GNU_variable_value:
case DW_OP_GNU_addr_index:
case DW_OP_GNU_const_index:
++frame_offset_;
break;
case DW_OP_drop:
case DW_OP_xderef:
case DW_OP_and:
case DW_OP_div:
case DW_OP_minus:
case DW_OP_mod:
case DW_OP_mul:
case DW_OP_or:
case DW_OP_plus:
case DW_OP_shl:
case DW_OP_shr:
case DW_OP_shra:
case DW_OP_xor:
case DW_OP_bra:
case DW_OP_eq:
case DW_OP_ge:
case DW_OP_gt:
case DW_OP_le:
case DW_OP_lt:
case DW_OP_ne:
case DW_OP_regx:
case DW_OP_xderef_size:
--frame_offset_;
break;
case DW_OP_call2:
case DW_OP_call4:
case DW_OP_call_ref:
{
dw_die_ref dwarf_proc = l->dw_loc_oprnd1.v.val_die_ref.die;
int *stack_usage = dwarf_proc_stack_usage_map->get (dwarf_proc);
if (stack_usage == NULL)
return false;
frame_offset_ += *stack_usage;
break;
}
case DW_OP_implicit_pointer:
case DW_OP_entry_value:
case DW_OP_const_type:
case DW_OP_regval_type:
case DW_OP_deref_type:
case DW_OP_convert:
case DW_OP_reinterpret:
case DW_OP_form_tls_address:
case DW_OP_GNU_push_tls_address:
case DW_OP_GNU_uninit:
case DW_OP_GNU_encoded_addr:
case DW_OP_GNU_implicit_pointer:
case DW_OP_GNU_entry_value:
case DW_OP_GNU_const_type:
case DW_OP_GNU_regval_type:
case DW_OP_GNU_deref_type:
case DW_OP_GNU_convert:
case DW_OP_GNU_reinterpret:
case DW_OP_GNU_parameter_ref:
/* loc_list_from_tree will probably not output these operations for
size functions, so assume they will not appear here. */
/* Fall through... */
default:
gcc_unreachable ();
}
/* Now, follow the control flow (except subroutine calls). */
switch (l->dw_loc_opc)
{
case DW_OP_bra:
if (!resolve_args_picking_1 (l->dw_loc_next, frame_offset_, dpi,
frame_offsets))
return false;
/* Fall through. */
case DW_OP_skip:
l = l->dw_loc_oprnd1.v.val_loc;
break;
case DW_OP_stack_value:
return true;
default:
l = l->dw_loc_next;
break;
}
}
return true;
}
/* Make a DFS over operations reachable through LOC (i.e. follow branch
operations) in order to resolve the operand of DW_OP_pick operations that
target DWARF procedure arguments (DPI). INITIAL_FRAME_OFFSET is the frame
offset *before* LOC is executed. Return if all relocations were
successful. */
static bool
resolve_args_picking (dw_loc_descr_ref loc, unsigned initial_frame_offset,
struct dwarf_procedure_info *dpi)
{
/* Associate to all visited operations the frame offset *before* evaluating
this operation. */
hash_map<dw_loc_descr_ref, unsigned> frame_offsets;
return resolve_args_picking_1 (loc, initial_frame_offset, dpi,
frame_offsets);
}
/* Try to generate a DWARF procedure that computes the same result as FNDECL.
Return NULL if it is not possible. */
static dw_die_ref
function_to_dwarf_procedure (tree fndecl)
{
struct loc_descr_context ctx;
struct dwarf_procedure_info dpi;
dw_die_ref dwarf_proc_die;
tree tree_body = DECL_SAVED_TREE (fndecl);
dw_loc_descr_ref loc_body, epilogue;
tree cursor;
unsigned i;
/* Do not generate multiple DWARF procedures for the same function
declaration. */
dwarf_proc_die = lookup_decl_die (fndecl);
if (dwarf_proc_die != NULL)
return dwarf_proc_die;
/* DWARF procedures are available starting with the DWARFv3 standard. */
if (dwarf_version < 3 && dwarf_strict)
return NULL;
/* We handle only functions for which we still have a body, that return a
supported type and that takes arguments with supported types. Note that
there is no point translating functions that return nothing. */
if (tree_body == NULL_TREE
|| DECL_RESULT (fndecl) == NULL_TREE
|| !is_handled_procedure_type (TREE_TYPE (DECL_RESULT (fndecl))))
return NULL;
for (cursor = DECL_ARGUMENTS (fndecl);
cursor != NULL_TREE;
cursor = TREE_CHAIN (cursor))
if (!is_handled_procedure_type (TREE_TYPE (cursor)))
return NULL;
/* Match only "expr" in: RETURN_EXPR (MODIFY_EXPR (RESULT_DECL, expr)). */
if (TREE_CODE (tree_body) != RETURN_EXPR)
return NULL;
tree_body = TREE_OPERAND (tree_body, 0);
if (TREE_CODE (tree_body) != MODIFY_EXPR
|| TREE_OPERAND (tree_body, 0) != DECL_RESULT (fndecl))
return NULL;
tree_body = TREE_OPERAND (tree_body, 1);
/* Try to translate the body expression itself. Note that this will probably
cause an infinite recursion if its call graph has a cycle. This is very
unlikely for size functions, however, so don't bother with such things at
the moment. */
ctx.context_type = NULL_TREE;
ctx.base_decl = NULL_TREE;
ctx.dpi = &dpi;
ctx.placeholder_arg = false;
ctx.placeholder_seen = false;
dpi.fndecl = fndecl;
dpi.args_count = list_length (DECL_ARGUMENTS (fndecl));
loc_body = loc_descriptor_from_tree (tree_body, 0, &ctx);
if (!loc_body)
return NULL;
/* After evaluating all operands in "loc_body", we should still have on the
stack all arguments plus the desired function result (top of the stack).
Generate code in order to keep only the result in our stack frame. */
epilogue = NULL;
for (i = 0; i < dpi.args_count; ++i)
{
dw_loc_descr_ref op_couple = new_loc_descr (DW_OP_swap, 0, 0);
op_couple->dw_loc_next = new_loc_descr (DW_OP_drop, 0, 0);
op_couple->dw_loc_next->dw_loc_next = epilogue;
epilogue = op_couple;
}
add_loc_descr (&loc_body, epilogue);
if (!resolve_args_picking (loc_body, dpi.args_count, &dpi))
return NULL;
/* Trailing nops from loc_descriptor_from_tree (if any) cannot be removed
because they are considered useful. Now there is an epilogue, they are
not anymore, so give it another try. */
loc_descr_without_nops (loc_body);
/* fndecl may be used both as a regular DW_TAG_subprogram DIE and as
a DW_TAG_dwarf_procedure, so we may have a conflict, here. It's unlikely,
though, given that size functions do not come from source, so they should
not have a dedicated DW_TAG_subprogram DIE. */
dwarf_proc_die
= new_dwarf_proc_die (loc_body, fndecl,
get_context_die (DECL_CONTEXT (fndecl)));
/* The called DWARF procedure consumes one stack slot per argument and
returns one stack slot. */
dwarf_proc_stack_usage_map->put (dwarf_proc_die, 1 - dpi.args_count);
return dwarf_proc_die;
}
/* Generate Dwarf location list representing LOC.
If WANT_ADDRESS is false, expression computing LOC will be computed
If WANT_ADDRESS is 1, expression computing address of LOC will be returned
if WANT_ADDRESS is 2, expression computing address useable in location
will be returned (i.e. DW_OP_reg can be used
to refer to register values).
CONTEXT provides information to customize the location descriptions
generation. Its context_type field specifies what type is implicitly
referenced by DW_OP_push_object_address. If it is NULL_TREE, this operation
will not be generated.
Its DPI field determines whether we are generating a DWARF expression for a
DWARF procedure, so PARM_DECL references are processed specifically.
If CONTEXT is NULL, the behavior is the same as if context_type, base_decl
and dpi fields were null. */
static dw_loc_list_ref
loc_list_from_tree_1 (tree loc, int want_address,
struct loc_descr_context *context)
{
dw_loc_descr_ref ret = NULL, ret1 = NULL;
dw_loc_list_ref list_ret = NULL, list_ret1 = NULL;
int have_address = 0;
enum dwarf_location_atom op;
/* ??? Most of the time we do not take proper care for sign/zero
extending the values properly. Hopefully this won't be a real
problem... */
if (context != NULL
&& context->base_decl == loc
&& want_address == 0)
{
if (dwarf_version >= 3 || !dwarf_strict)
return new_loc_list (new_loc_descr (DW_OP_push_object_address, 0, 0),
NULL, 0, NULL, 0, NULL);
else
return NULL;
}
switch (TREE_CODE (loc))
{
case ERROR_MARK:
expansion_failed (loc, NULL_RTX, "ERROR_MARK");
return 0;
case PLACEHOLDER_EXPR:
/* This case involves extracting fields from an object to determine the
position of other fields. It is supposed to appear only as the first
operand of COMPONENT_REF nodes and to reference precisely the type
that the context allows. */
if (context != NULL
&& TREE_TYPE (loc) == context->context_type
&& want_address >= 1)
{
if (dwarf_version >= 3 || !dwarf_strict)
{
ret = new_loc_descr (DW_OP_push_object_address, 0, 0);
have_address = 1;
break;
}
else
return NULL;
}
/* For DW_TAG_generic_subrange attributes, PLACEHOLDER_EXPR stands for
the single argument passed by consumer. */
else if (context != NULL
&& context->placeholder_arg
&& INTEGRAL_TYPE_P (TREE_TYPE (loc))
&& want_address == 0)
{
ret = new_loc_descr (DW_OP_pick, 0, 0);
ret->frame_offset_rel = 1;
context->placeholder_seen = true;
break;
}
else
expansion_failed (loc, NULL_RTX,
"PLACEHOLDER_EXPR for an unexpected type");
break;
case CALL_EXPR:
{
const int nargs = call_expr_nargs (loc);
tree callee = get_callee_fndecl (loc);
int i;
dw_die_ref dwarf_proc;
if (callee == NULL_TREE)
goto call_expansion_failed;
/* We handle only functions that return an integer. */
if (!is_handled_procedure_type (TREE_TYPE (TREE_TYPE (callee))))
goto call_expansion_failed;
dwarf_proc = function_to_dwarf_procedure (callee);
if (dwarf_proc == NULL)
goto call_expansion_failed;
/* Evaluate arguments right-to-left so that the first argument will
be the top-most one on the stack. */
for (i = nargs - 1; i >= 0; --i)
{
dw_loc_descr_ref loc_descr
= loc_descriptor_from_tree (CALL_EXPR_ARG (loc, i), 0,
context);
if (loc_descr == NULL)
goto call_expansion_failed;
add_loc_descr (&ret, loc_descr);
}
ret1 = new_loc_descr (DW_OP_call4, 0, 0);
ret1->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
ret1->dw_loc_oprnd1.v.val_die_ref.die = dwarf_proc;
ret1->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_loc_descr (&ret, ret1);
break;
call_expansion_failed:
expansion_failed (loc, NULL_RTX, "CALL_EXPR");
/* There are no opcodes for these operations. */
return 0;
}
case PREINCREMENT_EXPR:
case PREDECREMENT_EXPR:
case POSTINCREMENT_EXPR:
case POSTDECREMENT_EXPR:
expansion_failed (loc, NULL_RTX, "PRE/POST INDCREMENT/DECREMENT");
/* There are no opcodes for these operations. */
return 0;
case ADDR_EXPR:
/* If we already want an address, see if there is INDIRECT_REF inside
e.g. for &this->field. */
if (want_address)
{
list_ret = loc_list_for_address_of_addr_expr_of_indirect_ref
(loc, want_address == 2, context);
if (list_ret)
have_address = 1;
else if (decl_address_ip_invariant_p (TREE_OPERAND (loc, 0))
&& (ret = cst_pool_loc_descr (loc)))
have_address = 1;
}
/* Otherwise, process the argument and look for the address. */
if (!list_ret && !ret)
list_ret = loc_list_from_tree_1 (TREE_OPERAND (loc, 0), 1, context);
else
{
if (want_address)
expansion_failed (loc, NULL_RTX, "need address of ADDR_EXPR");
return NULL;
}
break;
case VAR_DECL:
if (DECL_THREAD_LOCAL_P (loc))
{
rtx rtl;
enum dwarf_location_atom tls_op;
enum dtprel_bool dtprel = dtprel_false;
if (targetm.have_tls)
{
/* If this is not defined, we have no way to emit the
data. */
if (!targetm.asm_out.output_dwarf_dtprel)
return 0;
/* The way DW_OP_GNU_push_tls_address is specified, we
can only look up addresses of objects in the current
module. We used DW_OP_addr as first op, but that's
wrong, because DW_OP_addr is relocated by the debug
info consumer, while DW_OP_GNU_push_tls_address
operand shouldn't be. */
if (DECL_EXTERNAL (loc) && !targetm.binds_local_p (loc))
return 0;
dtprel = dtprel_true;
/* We check for DWARF 5 here because gdb did not implement
DW_OP_form_tls_address until after 7.12. */
tls_op = (dwarf_version >= 5 ? DW_OP_form_tls_address
: DW_OP_GNU_push_tls_address);
}
else
{
if (!targetm.emutls.debug_form_tls_address
|| !(dwarf_version >= 3 || !dwarf_strict))
return 0;
/* We stuffed the control variable into the DECL_VALUE_EXPR
to signal (via DECL_HAS_VALUE_EXPR_P) that the decl should
no longer appear in gimple code. We used the control
variable in specific so that we could pick it up here. */
loc = DECL_VALUE_EXPR (loc);
tls_op = DW_OP_form_tls_address;
}
rtl = rtl_for_decl_location (loc);
if (rtl == NULL_RTX)
return 0;
if (!MEM_P (rtl))
return 0;
rtl = XEXP (rtl, 0);
if (! CONSTANT_P (rtl))
return 0;
ret = new_addr_loc_descr (rtl, dtprel);
ret1 = new_loc_descr (tls_op, 0, 0);
add_loc_descr (&ret, ret1);
have_address = 1;
break;
}
/* FALLTHRU */
case PARM_DECL:
if (context != NULL && context->dpi != NULL
&& DECL_CONTEXT (loc) == context->dpi->fndecl)
{
/* We are generating code for a DWARF procedure and we want to access
one of its arguments: find the appropriate argument offset and let
the resolve_args_picking pass compute the offset that complies
with the stack frame size. */
unsigned i = 0;
tree cursor;
for (cursor = DECL_ARGUMENTS (context->dpi->fndecl);
cursor != NULL_TREE && cursor != loc;
cursor = TREE_CHAIN (cursor), ++i)
;
/* If we are translating a DWARF procedure, all referenced parameters
must belong to the current function. */
gcc_assert (cursor != NULL_TREE);
ret = new_loc_descr (DW_OP_pick, i, 0);
ret->frame_offset_rel = 1;
break;
}
/* FALLTHRU */
case RESULT_DECL:
if (DECL_HAS_VALUE_EXPR_P (loc))
return loc_list_from_tree_1 (DECL_VALUE_EXPR (loc),
want_address, context);
/* FALLTHRU */
case FUNCTION_DECL:
{
rtx rtl;
var_loc_list *loc_list = lookup_decl_loc (loc);
if (loc_list && loc_list->first)
{
list_ret = dw_loc_list (loc_list, loc, want_address);
have_address = want_address != 0;
break;
}
rtl = rtl_for_decl_location (loc);
if (rtl == NULL_RTX)
{
if (TREE_CODE (loc) != FUNCTION_DECL
&& early_dwarf
&& current_function_decl
&& want_address != 1
&& ! DECL_IGNORED_P (loc)
&& (INTEGRAL_TYPE_P (TREE_TYPE (loc))
|| POINTER_TYPE_P (TREE_TYPE (loc)))
&& DECL_CONTEXT (loc) == current_function_decl
&& (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (loc)))
<= DWARF2_ADDR_SIZE))
{
dw_die_ref ref = lookup_decl_die (loc);
ret = new_loc_descr (DW_OP_GNU_variable_value, 0, 0);
if (ref)
{
ret->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
ret->dw_loc_oprnd1.v.val_die_ref.die = ref;
ret->dw_loc_oprnd1.v.val_die_ref.external = 0;
}
else
{
ret->dw_loc_oprnd1.val_class = dw_val_class_decl_ref;
ret->dw_loc_oprnd1.v.val_decl_ref = loc;
}
break;
}
expansion_failed (loc, NULL_RTX, "DECL has no RTL");
return 0;
}
else if (CONST_INT_P (rtl))
{
HOST_WIDE_INT val = INTVAL (rtl);
if (TYPE_UNSIGNED (TREE_TYPE (loc)))
val &= GET_MODE_MASK (DECL_MODE (loc));
ret = int_loc_descriptor (val);
}
else if (GET_CODE (rtl) == CONST_STRING)
{
expansion_failed (loc, NULL_RTX, "CONST_STRING");
return 0;
}
else if (CONSTANT_P (rtl) && const_ok_for_output (rtl))
ret = new_addr_loc_descr (rtl, dtprel_false);
else
{
machine_mode mode, mem_mode;
/* Certain constructs can only be represented at top-level. */
if (want_address == 2)
{
ret = loc_descriptor (rtl, VOIDmode,
VAR_INIT_STATUS_INITIALIZED);
have_address = 1;
}
else
{
mode = GET_MODE (rtl);
mem_mode = VOIDmode;
if (MEM_P (rtl))
{
mem_mode = mode;
mode = get_address_mode (rtl);
rtl = XEXP (rtl, 0);
have_address = 1;
}
ret = mem_loc_descriptor (rtl, mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED);
}
if (!ret)
expansion_failed (loc, rtl,
"failed to produce loc descriptor for rtl");
}
}
break;
case MEM_REF:
if (!integer_zerop (TREE_OPERAND (loc, 1)))
{
have_address = 1;
goto do_plus;
}
/* Fallthru. */
case INDIRECT_REF:
list_ret = loc_list_from_tree_1 (TREE_OPERAND (loc, 0), 0, context);
have_address = 1;
break;
case TARGET_MEM_REF:
case SSA_NAME:
case DEBUG_EXPR_DECL:
return NULL;
case COMPOUND_EXPR:
return loc_list_from_tree_1 (TREE_OPERAND (loc, 1), want_address,
context);
CASE_CONVERT:
case VIEW_CONVERT_EXPR:
case SAVE_EXPR:
case MODIFY_EXPR:
case NON_LVALUE_EXPR:
return loc_list_from_tree_1 (TREE_OPERAND (loc, 0), want_address,
context);
case COMPONENT_REF:
case BIT_FIELD_REF:
case ARRAY_REF:
case ARRAY_RANGE_REF:
case REALPART_EXPR:
case IMAGPART_EXPR:
{
tree obj, offset;
poly_int64 bitsize, bitpos, bytepos;
machine_mode mode;
int unsignedp, reversep, volatilep = 0;
obj = get_inner_reference (loc, &bitsize, &bitpos, &offset, &mode,
&unsignedp, &reversep, &volatilep);
gcc_assert (obj != loc);
list_ret = loc_list_from_tree_1 (obj,
want_address == 2
&& known_eq (bitpos, 0)
&& !offset ? 2 : 1,
context);
/* TODO: We can extract value of the small expression via shifting even
for nonzero bitpos. */
if (list_ret == 0)
return 0;
if (!multiple_p (bitpos, BITS_PER_UNIT, &bytepos)
|| !multiple_p (bitsize, BITS_PER_UNIT))
{
expansion_failed (loc, NULL_RTX,
"bitfield access");
return 0;
}
if (offset != NULL_TREE)
{
/* Variable offset. */
list_ret1 = loc_list_from_tree_1 (offset, 0, context);
if (list_ret1 == 0)
return 0;
add_loc_list (&list_ret, list_ret1);
if (!list_ret)
return 0;
add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_plus, 0, 0));
}
HOST_WIDE_INT value;
if (bytepos.is_constant (&value) && value > 0)
add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_plus_uconst,
value, 0));
else if (maybe_ne (bytepos, 0))
loc_list_plus_const (list_ret, bytepos);
have_address = 1;
break;
}
case INTEGER_CST:
if ((want_address || !tree_fits_shwi_p (loc))
&& (ret = cst_pool_loc_descr (loc)))
have_address = 1;
else if (want_address == 2
&& tree_fits_shwi_p (loc)
&& (ret = address_of_int_loc_descriptor
(int_size_in_bytes (TREE_TYPE (loc)),
tree_to_shwi (loc))))
have_address = 1;
else if (tree_fits_shwi_p (loc))
ret = int_loc_descriptor (tree_to_shwi (loc));
else if (tree_fits_uhwi_p (loc))
ret = uint_loc_descriptor (tree_to_uhwi (loc));
else
{
expansion_failed (loc, NULL_RTX,
"Integer operand is not host integer");
return 0;
}
break;
case POLY_INT_CST:
{
if (want_address)
{
expansion_failed (loc, NULL_RTX,
"constant address with a runtime component");
return 0;
}
poly_int64 value;
if (!poly_int_tree_p (loc, &value))
{
expansion_failed (loc, NULL_RTX, "constant too big");
return 0;
}
ret = int_loc_descriptor (value);
}
break;
case CONSTRUCTOR:
case REAL_CST:
case STRING_CST:
case COMPLEX_CST:
if ((ret = cst_pool_loc_descr (loc)))
have_address = 1;
else if (TREE_CODE (loc) == CONSTRUCTOR)
{
tree type = TREE_TYPE (loc);
unsigned HOST_WIDE_INT size = int_size_in_bytes (type);
unsigned HOST_WIDE_INT offset = 0;
unsigned HOST_WIDE_INT cnt;
constructor_elt *ce;
if (TREE_CODE (type) == RECORD_TYPE)
{
/* This is very limited, but it's enough to output
pointers to member functions, as long as the
referenced function is defined in the current
translation unit. */
FOR_EACH_VEC_SAFE_ELT (CONSTRUCTOR_ELTS (loc), cnt, ce)
{
tree val = ce->value;
tree field = ce->index;
if (val)
STRIP_NOPS (val);
if (!field || DECL_BIT_FIELD (field))
{
expansion_failed (loc, NULL_RTX,
"bitfield in record type constructor");
size = offset = (unsigned HOST_WIDE_INT)-1;
ret = NULL;
break;
}
HOST_WIDE_INT fieldsize = tree_to_shwi (DECL_SIZE_UNIT (field));
unsigned HOST_WIDE_INT pos = int_byte_position (field);
gcc_assert (pos + fieldsize <= size);
if (pos < offset)
{
expansion_failed (loc, NULL_RTX,
"out-of-order fields in record constructor");
size = offset = (unsigned HOST_WIDE_INT)-1;
ret = NULL;
break;
}
if (pos > offset)
{
ret1 = new_loc_descr (DW_OP_piece, pos - offset, 0);
add_loc_descr (&ret, ret1);
offset = pos;
}
if (val && fieldsize != 0)
{
ret1 = loc_descriptor_from_tree (val, want_address, context);
if (!ret1)
{
expansion_failed (loc, NULL_RTX,
"unsupported expression in field");
size = offset = (unsigned HOST_WIDE_INT)-1;
ret = NULL;
break;
}
add_loc_descr (&ret, ret1);
}
if (fieldsize)
{
ret1 = new_loc_descr (DW_OP_piece, fieldsize, 0);
add_loc_descr (&ret, ret1);
offset = pos + fieldsize;
}
}
if (offset != size)
{
ret1 = new_loc_descr (DW_OP_piece, size - offset, 0);
add_loc_descr (&ret, ret1);
offset = size;
}
have_address = !!want_address;
}
else
expansion_failed (loc, NULL_RTX,
"constructor of non-record type");
}
else
/* We can construct small constants here using int_loc_descriptor. */
expansion_failed (loc, NULL_RTX,
"constructor or constant not in constant pool");
break;
case TRUTH_AND_EXPR:
case TRUTH_ANDIF_EXPR:
case BIT_AND_EXPR:
op = DW_OP_and;
goto do_binop;
case TRUTH_XOR_EXPR:
case BIT_XOR_EXPR:
op = DW_OP_xor;
goto do_binop;
case TRUTH_OR_EXPR:
case TRUTH_ORIF_EXPR:
case BIT_IOR_EXPR:
op = DW_OP_or;
goto do_binop;
case FLOOR_DIV_EXPR:
case CEIL_DIV_EXPR:
case ROUND_DIV_EXPR:
case TRUNC_DIV_EXPR:
case EXACT_DIV_EXPR:
if (TYPE_UNSIGNED (TREE_TYPE (loc)))
return 0;
op = DW_OP_div;
goto do_binop;
case MINUS_EXPR:
op = DW_OP_minus;
goto do_binop;
case FLOOR_MOD_EXPR:
case CEIL_MOD_EXPR:
case ROUND_MOD_EXPR:
case TRUNC_MOD_EXPR:
if (TYPE_UNSIGNED (TREE_TYPE (loc)))
{
op = DW_OP_mod;
goto do_binop;
}
list_ret = loc_list_from_tree_1 (TREE_OPERAND (loc, 0), 0, context);
list_ret1 = loc_list_from_tree_1 (TREE_OPERAND (loc, 1), 0, context);
if (list_ret == 0 || list_ret1 == 0)
return 0;
add_loc_list (&list_ret, list_ret1);
if (list_ret == 0)
return 0;
add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_over, 0, 0));
add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_over, 0, 0));
add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_div, 0, 0));
add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_mul, 0, 0));
add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_minus, 0, 0));
break;
case MULT_EXPR:
op = DW_OP_mul;
goto do_binop;
case LSHIFT_EXPR:
op = DW_OP_shl;
goto do_binop;
case RSHIFT_EXPR:
op = (TYPE_UNSIGNED (TREE_TYPE (loc)) ? DW_OP_shr : DW_OP_shra);
goto do_binop;
case POINTER_PLUS_EXPR:
case PLUS_EXPR:
do_plus:
if (tree_fits_shwi_p (TREE_OPERAND (loc, 1)))
{
/* Big unsigned numbers can fit in HOST_WIDE_INT but it may be
smarter to encode their opposite. The DW_OP_plus_uconst operation
takes 1 + X bytes, X being the size of the ULEB128 addend. On the
other hand, a "<push literal>; DW_OP_minus" pattern takes 1 + Y
bytes, Y being the size of the operation that pushes the opposite
of the addend. So let's choose the smallest representation. */
const tree tree_addend = TREE_OPERAND (loc, 1);
offset_int wi_addend;
HOST_WIDE_INT shwi_addend;
dw_loc_descr_ref loc_naddend;
list_ret = loc_list_from_tree_1 (TREE_OPERAND (loc, 0), 0, context);
if (list_ret == 0)
return 0;
/* Try to get the literal to push. It is the opposite of the addend,
so as we rely on wrapping during DWARF evaluation, first decode
the literal as a "DWARF-sized" signed number. */
wi_addend = wi::to_offset (tree_addend);
wi_addend = wi::sext (wi_addend, DWARF2_ADDR_SIZE * 8);
shwi_addend = wi_addend.to_shwi ();
loc_naddend = (shwi_addend != INTTYPE_MINIMUM (HOST_WIDE_INT))
? int_loc_descriptor (-shwi_addend)
: NULL;
if (loc_naddend != NULL
&& ((unsigned) size_of_uleb128 (shwi_addend)
> size_of_loc_descr (loc_naddend)))
{
add_loc_descr_to_each (list_ret, loc_naddend);
add_loc_descr_to_each (list_ret,
new_loc_descr (DW_OP_minus, 0, 0));
}
else
{
for (dw_loc_descr_ref loc_cur = loc_naddend; loc_cur != NULL; )
{
loc_naddend = loc_cur;
loc_cur = loc_cur->dw_loc_next;
ggc_free (loc_naddend);
}
loc_list_plus_const (list_ret, wi_addend.to_shwi ());
}
break;
}
op = DW_OP_plus;
goto do_binop;
case LE_EXPR:
op = DW_OP_le;
goto do_comp_binop;
case GE_EXPR:
op = DW_OP_ge;
goto do_comp_binop;
case LT_EXPR:
op = DW_OP_lt;
goto do_comp_binop;
case GT_EXPR:
op = DW_OP_gt;
goto do_comp_binop;
do_comp_binop:
if (TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc, 0))))
{
list_ret = loc_list_from_tree (TREE_OPERAND (loc, 0), 0, context);
list_ret1 = loc_list_from_tree (TREE_OPERAND (loc, 1), 0, context);
list_ret = loc_list_from_uint_comparison (list_ret, list_ret1,
TREE_CODE (loc));
break;
}
else
goto do_binop;
case EQ_EXPR:
op = DW_OP_eq;
goto do_binop;
case NE_EXPR:
op = DW_OP_ne;
goto do_binop;
do_binop:
list_ret = loc_list_from_tree_1 (TREE_OPERAND (loc, 0), 0, context);
list_ret1 = loc_list_from_tree_1 (TREE_OPERAND (loc, 1), 0, context);
if (list_ret == 0 || list_ret1 == 0)
return 0;
add_loc_list (&list_ret, list_ret1);
if (list_ret == 0)
return 0;
add_loc_descr_to_each (list_ret, new_loc_descr (op, 0, 0));
break;
case TRUTH_NOT_EXPR:
case BIT_NOT_EXPR:
op = DW_OP_not;
goto do_unop;
case ABS_EXPR:
op = DW_OP_abs;
goto do_unop;
case NEGATE_EXPR:
op = DW_OP_neg;
goto do_unop;
do_unop:
list_ret = loc_list_from_tree_1 (TREE_OPERAND (loc, 0), 0, context);
if (list_ret == 0)
return 0;
add_loc_descr_to_each (list_ret, new_loc_descr (op, 0, 0));
break;
case MIN_EXPR:
case MAX_EXPR:
{
const enum tree_code code =
TREE_CODE (loc) == MIN_EXPR ? GT_EXPR : LT_EXPR;
loc = build3 (COND_EXPR, TREE_TYPE (loc),
build2 (code, integer_type_node,
TREE_OPERAND (loc, 0), TREE_OPERAND (loc, 1)),
TREE_OPERAND (loc, 1), TREE_OPERAND (loc, 0));
}
/* fall through */
case COND_EXPR:
{
dw_loc_descr_ref lhs
= loc_descriptor_from_tree (TREE_OPERAND (loc, 1), 0, context);
dw_loc_list_ref rhs
= loc_list_from_tree_1 (TREE_OPERAND (loc, 2), 0, context);
dw_loc_descr_ref bra_node, jump_node, tmp;
list_ret = loc_list_from_tree_1 (TREE_OPERAND (loc, 0), 0, context);
if (list_ret == 0 || lhs == 0 || rhs == 0)
return 0;
bra_node = new_loc_descr (DW_OP_bra, 0, 0);
add_loc_descr_to_each (list_ret, bra_node);
add_loc_list (&list_ret, rhs);
jump_node = new_loc_descr (DW_OP_skip, 0, 0);
add_loc_descr_to_each (list_ret, jump_node);
add_loc_descr_to_each (list_ret, lhs);
bra_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
bra_node->dw_loc_oprnd1.v.val_loc = lhs;
/* ??? Need a node to point the skip at. Use a nop. */
tmp = new_loc_descr (DW_OP_nop, 0, 0);
add_loc_descr_to_each (list_ret, tmp);
jump_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
jump_node->dw_loc_oprnd1.v.val_loc = tmp;
}
break;
case FIX_TRUNC_EXPR:
return 0;
default:
/* Leave front-end specific codes as simply unknown. This comes
up, for instance, with the C STMT_EXPR. */
if ((unsigned int) TREE_CODE (loc)
>= (unsigned int) LAST_AND_UNUSED_TREE_CODE)
{
expansion_failed (loc, NULL_RTX,
"language specific tree node");
return 0;
}
/* Otherwise this is a generic code; we should just lists all of
these explicitly. We forgot one. */
if (flag_checking)
gcc_unreachable ();
/* In a release build, we want to degrade gracefully: better to
generate incomplete debugging information than to crash. */
return NULL;
}
if (!ret && !list_ret)
return 0;
if (want_address == 2 && !have_address
&& (dwarf_version >= 4 || !dwarf_strict))
{
if (int_size_in_bytes (TREE_TYPE (loc)) > DWARF2_ADDR_SIZE)
{
expansion_failed (loc, NULL_RTX,
"DWARF address size mismatch");
return 0;
}
if (ret)
add_loc_descr (&ret, new_loc_descr (DW_OP_stack_value, 0, 0));
else
add_loc_descr_to_each (list_ret,
new_loc_descr (DW_OP_stack_value, 0, 0));
have_address = 1;
}
/* Show if we can't fill the request for an address. */
if (want_address && !have_address)
{
expansion_failed (loc, NULL_RTX,
"Want address and only have value");
return 0;
}
gcc_assert (!ret || !list_ret);
/* If we've got an address and don't want one, dereference. */
if (!want_address && have_address)
{
HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (loc));
if (size > DWARF2_ADDR_SIZE || size == -1)
{
expansion_failed (loc, NULL_RTX,
"DWARF address size mismatch");
return 0;
}
else if (size == DWARF2_ADDR_SIZE)
op = DW_OP_deref;
else
op = DW_OP_deref_size;
if (ret)
add_loc_descr (&ret, new_loc_descr (op, size, 0));
else
add_loc_descr_to_each (list_ret, new_loc_descr (op, size, 0));
}
if (ret)
list_ret = new_loc_list (ret, NULL, 0, NULL, 0, NULL);
return list_ret;
}
/* Likewise, but strip useless DW_OP_nop operations in the resulting
expressions. */
static dw_loc_list_ref
loc_list_from_tree (tree loc, int want_address,
struct loc_descr_context *context)
{
dw_loc_list_ref result = loc_list_from_tree_1 (loc, want_address, context);
for (dw_loc_list_ref loc_cur = result;
loc_cur != NULL; loc_cur = loc_cur->dw_loc_next)
loc_descr_without_nops (loc_cur->expr);
return result;
}
/* Same as above but return only single location expression. */
static dw_loc_descr_ref
loc_descriptor_from_tree (tree loc, int want_address,
struct loc_descr_context *context)
{
dw_loc_list_ref ret = loc_list_from_tree (loc, want_address, context);
if (!ret)
return NULL;
if (ret->dw_loc_next)
{
expansion_failed (loc, NULL_RTX,
"Location list where only loc descriptor needed");
return NULL;
}
return ret->expr;
}
/* Given a pointer to what is assumed to be a FIELD_DECL node, return a
pointer to the declared type for the relevant field variable, or return
`integer_type_node' if the given node turns out to be an
ERROR_MARK node. */
static inline tree
field_type (const_tree decl)
{
tree type;
if (TREE_CODE (decl) == ERROR_MARK)
return integer_type_node;
type = DECL_BIT_FIELD_TYPE (decl);
if (type == NULL_TREE)
type = TREE_TYPE (decl);
return type;
}
/* Given a pointer to a tree node, return the alignment in bits for
it, or else return BITS_PER_WORD if the node actually turns out to
be an ERROR_MARK node. */
static inline unsigned
simple_type_align_in_bits (const_tree type)
{
return (TREE_CODE (type) != ERROR_MARK) ? TYPE_ALIGN (type) : BITS_PER_WORD;
}
static inline unsigned
simple_decl_align_in_bits (const_tree decl)
{
return (TREE_CODE (decl) != ERROR_MARK) ? DECL_ALIGN (decl) : BITS_PER_WORD;
}
/* Return the result of rounding T up to ALIGN. */
static inline offset_int
round_up_to_align (const offset_int &t, unsigned int align)
{
return wi::udiv_trunc (t + align - 1, align) * align;
}
/* Compute the size of TYPE in bytes. If possible, return NULL and store the
size as an integer constant in CST_SIZE. Otherwise, if possible, return a
DWARF expression that computes the size. Return NULL and set CST_SIZE to -1
if we fail to return the size in one of these two forms. */
static dw_loc_descr_ref
type_byte_size (const_tree type, HOST_WIDE_INT *cst_size)
{
tree tree_size;
struct loc_descr_context ctx;
/* Return a constant integer in priority, if possible. */
*cst_size = int_size_in_bytes (type);
if (*cst_size != -1)
return NULL;
ctx.context_type = const_cast<tree> (type);
ctx.base_decl = NULL_TREE;
ctx.dpi = NULL;
ctx.placeholder_arg = false;
ctx.placeholder_seen = false;
type = TYPE_MAIN_VARIANT (type);
tree_size = TYPE_SIZE_UNIT (type);
return ((tree_size != NULL_TREE)
? loc_descriptor_from_tree (tree_size, 0, &ctx)
: NULL);
}
/* Helper structure for RECORD_TYPE processing. */
struct vlr_context
{
/* Root RECORD_TYPE. It is needed to generate data member location
descriptions in variable-length records (VLR), but also to cope with
variants, which are composed of nested structures multiplexed with
QUAL_UNION_TYPE nodes. Each time such a structure is passed to a
function processing a FIELD_DECL, it is required to be non null. */
tree struct_type;
/* When generating a variant part in a RECORD_TYPE (i.e. a nested
QUAL_UNION_TYPE), this holds an expression that computes the offset for
this variant part as part of the root record (in storage units). For
regular records, it must be NULL_TREE. */
tree variant_part_offset;
};
/* Given a pointer to a FIELD_DECL, compute the byte offset of the lowest
addressed byte of the "containing object" for the given FIELD_DECL. If
possible, return a native constant through CST_OFFSET (in which case NULL is
returned); otherwise return a DWARF expression that computes the offset.
Set *CST_OFFSET to 0 and return NULL if we are unable to determine what
that offset is, either because the argument turns out to be a pointer to an
ERROR_MARK node, or because the offset expression is too complex for us.
CTX is required: see the comment for VLR_CONTEXT. */
static dw_loc_descr_ref
field_byte_offset (const_tree decl, struct vlr_context *ctx,
HOST_WIDE_INT *cst_offset)
{
tree tree_result;
dw_loc_list_ref loc_result;
*cst_offset = 0;
if (TREE_CODE (decl) == ERROR_MARK)
return NULL;
else
gcc_assert (TREE_CODE (decl) == FIELD_DECL);
/* We cannot handle variable bit offsets at the moment, so abort if it's the
case. */
if (TREE_CODE (DECL_FIELD_BIT_OFFSET (decl)) != INTEGER_CST)
return NULL;
/* We used to handle only constant offsets in all cases. Now, we handle
properly dynamic byte offsets only when PCC bitfield type doesn't
matter. */
if (PCC_BITFIELD_TYPE_MATTERS
&& TREE_CODE (DECL_FIELD_OFFSET (decl)) == INTEGER_CST)
{
offset_int object_offset_in_bits;
offset_int object_offset_in_bytes;
offset_int bitpos_int;
tree type;
tree field_size_tree;
offset_int deepest_bitpos;
offset_int field_size_in_bits;
unsigned int type_align_in_bits;
unsigned int decl_align_in_bits;
offset_int type_size_in_bits;
bitpos_int = wi::to_offset (bit_position (decl));
type = field_type (decl);
type_size_in_bits = offset_int_type_size_in_bits (type);
type_align_in_bits = simple_type_align_in_bits (type);
field_size_tree = DECL_SIZE (decl);
/* The size could be unspecified if there was an error, or for
a flexible array member. */
if (!field_size_tree)
field_size_tree = bitsize_zero_node;
/* If the size of the field is not constant, use the type size. */
if (TREE_CODE (field_size_tree) == INTEGER_CST)
field_size_in_bits = wi::to_offset (field_size_tree);
else
field_size_in_bits = type_size_in_bits;
decl_align_in_bits = simple_decl_align_in_bits (decl);
/* The GCC front-end doesn't make any attempt to keep track of the
starting bit offset (relative to the start of the containing
structure type) of the hypothetical "containing object" for a
bit-field. Thus, when computing the byte offset value for the
start of the "containing object" of a bit-field, we must deduce
this information on our own. This can be rather tricky to do in
some cases. For example, handling the following structure type
definition when compiling for an i386/i486 target (which only
aligns long long's to 32-bit boundaries) can be very tricky:
struct S { int field1; long long field2:31; };
Fortunately, there is a simple rule-of-thumb which can be used
in such cases. When compiling for an i386/i486, GCC will
allocate 8 bytes for the structure shown above. It decides to
do this based upon one simple rule for bit-field allocation.
GCC allocates each "containing object" for each bit-field at
the first (i.e. lowest addressed) legitimate alignment boundary
(based upon the required minimum alignment for the declared
type of the field) which it can possibly use, subject to the
condition that there is still enough available space remaining
in the containing object (when allocated at the selected point)
to fully accommodate all of the bits of the bit-field itself.
This simple rule makes it obvious why GCC allocates 8 bytes for
each object of the structure type shown above. When looking
for a place to allocate the "containing object" for `field2',
the compiler simply tries to allocate a 64-bit "containing
object" at each successive 32-bit boundary (starting at zero)
until it finds a place to allocate that 64- bit field such that
at least 31 contiguous (and previously unallocated) bits remain
within that selected 64 bit field. (As it turns out, for the
example above, the compiler finds it is OK to allocate the
"containing object" 64-bit field at bit-offset zero within the
structure type.)
Here we attempt to work backwards from the limited set of facts
we're given, and we try to deduce from those facts, where GCC
must have believed that the containing object started (within
the structure type). The value we deduce is then used (by the
callers of this routine) to generate DW_AT_location and
DW_AT_bit_offset attributes for fields (both bit-fields and, in
the case of DW_AT_location, regular fields as well). */
/* Figure out the bit-distance from the start of the structure to
the "deepest" bit of the bit-field. */
deepest_bitpos = bitpos_int + field_size_in_bits;
/* This is the tricky part. Use some fancy footwork to deduce
where the lowest addressed bit of the containing object must
be. */
object_offset_in_bits = deepest_bitpos - type_size_in_bits;
/* Round up to type_align by default. This works best for
bitfields. */
object_offset_in_bits
= round_up_to_align (object_offset_in_bits, type_align_in_bits);
if (wi::gtu_p (object_offset_in_bits, bitpos_int))
{
object_offset_in_bits = deepest_bitpos - type_size_in_bits;
/* Round up to decl_align instead. */
object_offset_in_bits
= round_up_to_align (object_offset_in_bits, decl_align_in_bits);
}
object_offset_in_bytes
= wi::lrshift (object_offset_in_bits, LOG2_BITS_PER_UNIT);
if (ctx->variant_part_offset == NULL_TREE)
{
*cst_offset = object_offset_in_bytes.to_shwi ();
return NULL;
}
tree_result = wide_int_to_tree (sizetype, object_offset_in_bytes);
}
else
tree_result = byte_position (decl);
if (ctx->variant_part_offset != NULL_TREE)
tree_result = fold_build2 (PLUS_EXPR, TREE_TYPE (tree_result),
ctx->variant_part_offset, tree_result);
/* If the byte offset is a constant, it's simplier to handle a native
constant rather than a DWARF expression. */
if (TREE_CODE (tree_result) == INTEGER_CST)
{
*cst_offset = wi::to_offset (tree_result).to_shwi ();
return NULL;
}
struct loc_descr_context loc_ctx = {
ctx->struct_type, /* context_type */
NULL_TREE, /* base_decl */
NULL, /* dpi */
false, /* placeholder_arg */
false /* placeholder_seen */
};
loc_result = loc_list_from_tree (tree_result, 0, &loc_ctx);
/* We want a DWARF expression: abort if we only have a location list with
multiple elements. */
if (!loc_result || !single_element_loc_list_p (loc_result))
return NULL;
else
return loc_result->expr;
}
/* The following routines define various Dwarf attributes and any data
associated with them. */
/* Add a location description attribute value to a DIE.
This emits location attributes suitable for whole variables and
whole parameters. Note that the location attributes for struct fields are
generated by the routine `data_member_location_attribute' below. */
static inline void
add_AT_location_description (dw_die_ref die, enum dwarf_attribute attr_kind,
dw_loc_list_ref descr)
{
bool check_no_locviews = true;
if (descr == 0)
return;
if (single_element_loc_list_p (descr))
add_AT_loc (die, attr_kind, descr->expr);
else
{
add_AT_loc_list (die, attr_kind, descr);
gcc_assert (descr->ll_symbol);
if (attr_kind == DW_AT_location && descr->vl_symbol
&& dwarf2out_locviews_in_attribute ())
{
add_AT_view_list (die, DW_AT_GNU_locviews);
check_no_locviews = false;
}
}
if (check_no_locviews)
gcc_assert (!get_AT (die, DW_AT_GNU_locviews));
}
/* Add DW_AT_accessibility attribute to DIE if needed. */
static void
add_accessibility_attribute (dw_die_ref die, tree decl)
{
/* In DWARF3+ the default is DW_ACCESS_private only in DW_TAG_class_type
children, otherwise the default is DW_ACCESS_public. In DWARF2
the default has always been DW_ACCESS_public. */
if (TREE_PROTECTED (decl))
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_protected);
else if (TREE_PRIVATE (decl))
{
if (dwarf_version == 2
|| die->die_parent == NULL
|| die->die_parent->die_tag != DW_TAG_class_type)
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_private);
}
else if (dwarf_version > 2
&& die->die_parent
&& die->die_parent->die_tag == DW_TAG_class_type)
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public);
}
/* Attach the specialized form of location attribute used for data members of
struct and union types. In the special case of a FIELD_DECL node which
represents a bit-field, the "offset" part of this special location
descriptor must indicate the distance in bytes from the lowest-addressed
byte of the containing struct or union type to the lowest-addressed byte of
the "containing object" for the bit-field. (See the `field_byte_offset'
function above).
For any given bit-field, the "containing object" is a hypothetical object
(of some integral or enum type) within which the given bit-field lives. The
type of this hypothetical "containing object" is always the same as the
declared type of the individual bit-field itself (for GCC anyway... the
DWARF spec doesn't actually mandate this). Note that it is the size (in
bytes) of the hypothetical "containing object" which will be given in the
DW_AT_byte_size attribute for this bit-field. (See the
`byte_size_attribute' function below.) It is also used when calculating the
value of the DW_AT_bit_offset attribute. (See the `bit_offset_attribute'
function below.)
CTX is required: see the comment for VLR_CONTEXT. */
static void
add_data_member_location_attribute (dw_die_ref die,
tree decl,
struct vlr_context *ctx)
{
HOST_WIDE_INT offset;
dw_loc_descr_ref loc_descr = 0;
if (TREE_CODE (decl) == TREE_BINFO)
{
/* We're working on the TAG_inheritance for a base class. */
if (BINFO_VIRTUAL_P (decl) && is_cxx ())
{
/* For C++ virtual bases we can't just use BINFO_OFFSET, as they
aren't at a fixed offset from all (sub)objects of the same
type. We need to extract the appropriate offset from our
vtable. The following dwarf expression means
BaseAddr = ObAddr + *((*ObAddr) - Offset)
This is specific to the V3 ABI, of course. */
dw_loc_descr_ref tmp;
/* Make a copy of the object address. */
tmp = new_loc_descr (DW_OP_dup, 0, 0);
add_loc_descr (&loc_descr, tmp);
/* Extract the vtable address. */
tmp = new_loc_descr (DW_OP_deref, 0, 0);
add_loc_descr (&loc_descr, tmp);
/* Calculate the address of the offset. */
offset = tree_to_shwi (BINFO_VPTR_FIELD (decl));
gcc_assert (offset < 0);
tmp = int_loc_descriptor (-offset);
add_loc_descr (&loc_descr, tmp);
tmp = new_loc_descr (DW_OP_minus, 0, 0);
add_loc_descr (&loc_descr, tmp);
/* Extract the offset. */
tmp = new_loc_descr (DW_OP_deref, 0, 0);
add_loc_descr (&loc_descr, tmp);
/* Add it to the object address. */
tmp = new_loc_descr (DW_OP_plus, 0, 0);
add_loc_descr (&loc_descr, tmp);
}
else
offset = tree_to_shwi (BINFO_OFFSET (decl));
}
else
{
loc_descr = field_byte_offset (decl, ctx, &offset);
/* If loc_descr is available then we know the field offset is dynamic.
However, GDB does not handle dynamic field offsets very well at the
moment. */
if (loc_descr != NULL && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
{
loc_descr = NULL;
offset = 0;
}
/* Data member location evalutation starts with the base address on the
stack. Compute the field offset and add it to this base address. */
else if (loc_descr != NULL)
add_loc_descr (&loc_descr, new_loc_descr (DW_OP_plus, 0, 0));
}
if (! loc_descr)
{
/* While DW_AT_data_bit_offset has been added already in DWARF4,
e.g. GDB only added support to it in November 2016. For DWARF5
we need newer debug info consumers anyway. We might change this
to dwarf_version >= 4 once most consumers catched up. */
if (dwarf_version >= 5
&& TREE_CODE (decl) == FIELD_DECL
&& DECL_BIT_FIELD_TYPE (decl)
&& (ctx->variant_part_offset == NULL_TREE
|| TREE_CODE (ctx->variant_part_offset) == INTEGER_CST))
{
tree off = bit_position (decl);
if (ctx->variant_part_offset)
off = bit_from_pos (ctx->variant_part_offset, off);
if (tree_fits_uhwi_p (off) && get_AT (die, DW_AT_bit_size))
{
remove_AT (die, DW_AT_byte_size);
remove_AT (die, DW_AT_bit_offset);
add_AT_unsigned (die, DW_AT_data_bit_offset, tree_to_uhwi (off));
return;
}
}
if (dwarf_version > 2)
{
/* Don't need to output a location expression, just the constant. */
if (offset < 0)
add_AT_int (die, DW_AT_data_member_location, offset);
else
add_AT_unsigned (die, DW_AT_data_member_location, offset);
return;
}
else
{
enum dwarf_location_atom op;
/* The DWARF2 standard says that we should assume that the structure
address is already on the stack, so we can specify a structure
field address by using DW_OP_plus_uconst. */
op = DW_OP_plus_uconst;
loc_descr = new_loc_descr (op, offset, 0);
}
}
add_AT_loc (die, DW_AT_data_member_location, loc_descr);
}
/* Writes integer values to dw_vec_const array. */
static void
insert_int (HOST_WIDE_INT val, unsigned int size, unsigned char *dest)
{
while (size != 0)
{
*dest++ = val & 0xff;
val >>= 8;
--size;
}
}
/* Reads integers from dw_vec_const array. Inverse of insert_int. */
static HOST_WIDE_INT
extract_int (const unsigned char *src, unsigned int size)
{
HOST_WIDE_INT val = 0;
src += size;
while (size != 0)
{
val <<= 8;
val |= *--src & 0xff;
--size;
}
return val;
}
/* Writes wide_int values to dw_vec_const array. */
static void
insert_wide_int (const wide_int &val, unsigned char *dest, int elt_size)
{
int i;
if (elt_size <= HOST_BITS_PER_WIDE_INT/BITS_PER_UNIT)
{
insert_int ((HOST_WIDE_INT) val.elt (0), elt_size, dest);
return;
}
/* We'd have to extend this code to support odd sizes. */
gcc_assert (elt_size % (HOST_BITS_PER_WIDE_INT / BITS_PER_UNIT) == 0);
int n = elt_size / (HOST_BITS_PER_WIDE_INT / BITS_PER_UNIT);
if (WORDS_BIG_ENDIAN)
for (i = n - 1; i >= 0; i--)
{
insert_int ((HOST_WIDE_INT) val.elt (i), sizeof (HOST_WIDE_INT), dest);
dest += sizeof (HOST_WIDE_INT);
}
else
for (i = 0; i < n; i++)
{
insert_int ((HOST_WIDE_INT) val.elt (i), sizeof (HOST_WIDE_INT), dest);
dest += sizeof (HOST_WIDE_INT);
}
}
/* Writes floating point values to dw_vec_const array. */
static void
insert_float (const_rtx rtl, unsigned char *array)
{
long val[4];
int i;
scalar_float_mode mode = as_a <scalar_float_mode> (GET_MODE (rtl));
real_to_target (val, CONST_DOUBLE_REAL_VALUE (rtl), mode);
/* real_to_target puts 32-bit pieces in each long. Pack them. */
for (i = 0; i < GET_MODE_SIZE (mode) / 4; i++)
{
insert_int (val[i], 4, array);
array += 4;
}
}
/* Attach a DW_AT_const_value attribute for a variable or a parameter which
does not have a "location" either in memory or in a register. These
things can arise in GNU C when a constant is passed as an actual parameter
to an inlined function. They can also arise in C++ where declared
constants do not necessarily get memory "homes". */
static bool
add_const_value_attribute (dw_die_ref die, rtx rtl)
{
switch (GET_CODE (rtl))
{
case CONST_INT:
{
HOST_WIDE_INT val = INTVAL (rtl);
if (val < 0)
add_AT_int (die, DW_AT_const_value, val);
else
add_AT_unsigned (die, DW_AT_const_value, (unsigned HOST_WIDE_INT) val);
}
return true;
case CONST_WIDE_INT:
{
wide_int w1 = rtx_mode_t (rtl, MAX_MODE_INT);
unsigned int prec = MIN (wi::min_precision (w1, UNSIGNED),
(unsigned int)CONST_WIDE_INT_NUNITS (rtl) * HOST_BITS_PER_WIDE_INT);
wide_int w = wi::zext (w1, prec);
add_AT_wide (die, DW_AT_const_value, w);
}
return true;
case CONST_DOUBLE:
/* Note that a CONST_DOUBLE rtx could represent either an integer or a
floating-point constant. A CONST_DOUBLE is used whenever the
constant requires more than one word in order to be adequately
represented. */
if (TARGET_SUPPORTS_WIDE_INT == 0
&& !SCALAR_FLOAT_MODE_P (GET_MODE (rtl)))
add_AT_double (die, DW_AT_const_value,
CONST_DOUBLE_HIGH (rtl), CONST_DOUBLE_LOW (rtl));
else
{
scalar_float_mode mode = as_a <scalar_float_mode> (GET_MODE (rtl));
unsigned int length = GET_MODE_SIZE (mode);
unsigned char *array = ggc_vec_alloc<unsigned char> (length);
insert_float (rtl, array);
add_AT_vec (die, DW_AT_const_value, length / 4, 4, array);
}
return true;
case CONST_VECTOR:
{
unsigned int length;
if (!CONST_VECTOR_NUNITS (rtl).is_constant (&length))
return false;
machine_mode mode = GET_MODE (rtl);
/* The combination of a length and byte elt_size doesn't extend
naturally to boolean vectors, where several elements are packed
into the same byte. */
if (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL)
return false;
unsigned int elt_size = GET_MODE_UNIT_SIZE (mode);
unsigned char *array
= ggc_vec_alloc<unsigned char> (length * elt_size);
unsigned int i;
unsigned char *p;
machine_mode imode = GET_MODE_INNER (mode);
switch (GET_MODE_CLASS (mode))
{
case MODE_VECTOR_INT:
for (i = 0, p = array; i < length; i++, p += elt_size)
{
rtx elt = CONST_VECTOR_ELT (rtl, i);
insert_wide_int (rtx_mode_t (elt, imode), p, elt_size);
}
break;
case MODE_VECTOR_FLOAT:
for (i = 0, p = array; i < length; i++, p += elt_size)
{
rtx elt = CONST_VECTOR_ELT (rtl, i);
insert_float (elt, p);
}
break;
default:
gcc_unreachable ();
}
add_AT_vec (die, DW_AT_const_value, length, elt_size, array);
}
return true;
case CONST_STRING:
if (dwarf_version >= 4 || !dwarf_strict)
{
dw_loc_descr_ref loc_result;
resolve_one_addr (&rtl);
rtl_addr:
loc_result = new_addr_loc_descr (rtl, dtprel_false);
add_loc_descr (&loc_result, new_loc_descr (DW_OP_stack_value, 0, 0));
add_AT_loc (die, DW_AT_location, loc_result);
vec_safe_push (used_rtx_array, rtl);
return true;
}
return false;
case CONST:
if (CONSTANT_P (XEXP (rtl, 0)))
return add_const_value_attribute (die, XEXP (rtl, 0));
/* FALLTHROUGH */
case SYMBOL_REF:
if (!const_ok_for_output (rtl))
return false;
/* FALLTHROUGH */
case LABEL_REF:
if (dwarf_version >= 4 || !dwarf_strict)
goto rtl_addr;
return false;
case PLUS:
/* In cases where an inlined instance of an inline function is passed
the address of an `auto' variable (which is local to the caller) we
can get a situation where the DECL_RTL of the artificial local
variable (for the inlining) which acts as a stand-in for the
corresponding formal parameter (of the inline function) will look
like (plus:SI (reg:SI FRAME_PTR) (const_int ...)). This is not
exactly a compile-time constant expression, but it isn't the address
of the (artificial) local variable either. Rather, it represents the
*value* which the artificial local variable always has during its
lifetime. We currently have no way to represent such quasi-constant
values in Dwarf, so for now we just punt and generate nothing. */
return false;
case HIGH:
case CONST_FIXED:
case MINUS:
case SIGN_EXTEND:
case ZERO_EXTEND:
case CONST_POLY_INT:
return false;
case MEM:
if (GET_CODE (XEXP (rtl, 0)) == CONST_STRING
&& MEM_READONLY_P (rtl)
&& GET_MODE (rtl) == BLKmode)
{
add_AT_string (die, DW_AT_const_value, XSTR (XEXP (rtl, 0), 0));
return true;
}
return false;
default:
/* No other kinds of rtx should be possible here. */
gcc_unreachable ();
}
return false;
}
/* Determine whether the evaluation of EXPR references any variables
or functions which aren't otherwise used (and therefore may not be
output). */
static tree
reference_to_unused (tree * tp, int * walk_subtrees,
void * data ATTRIBUTE_UNUSED)
{
if (! EXPR_P (*tp) && ! CONSTANT_CLASS_P (*tp))
*walk_subtrees = 0;
if (DECL_P (*tp) && ! TREE_PUBLIC (*tp) && ! TREE_USED (*tp)
&& ! TREE_ASM_WRITTEN (*tp))
return *tp;
/* ??? The C++ FE emits debug information for using decls, so
putting gcc_unreachable here falls over. See PR31899. For now
be conservative. */
else if (!symtab->global_info_ready && VAR_P (*tp))
return *tp;
else if (VAR_P (*tp))
{
varpool_node *node = varpool_node::get (*tp);
if (!node || !node->definition)
return *tp;
}
else if (TREE_CODE (*tp) == FUNCTION_DECL
&& (!DECL_EXTERNAL (*tp) || DECL_DECLARED_INLINE_P (*tp)))
{
/* The call graph machinery must have finished analyzing,
optimizing and gimplifying the CU by now.
So if *TP has no call graph node associated
to it, it means *TP will not be emitted. */
if (!symtab->global_info_ready || !cgraph_node::get (*tp))
return *tp;
}
else if (TREE_CODE (*tp) == STRING_CST && !TREE_ASM_WRITTEN (*tp))
return *tp;
return NULL_TREE;
}
/* Generate an RTL constant from a decl initializer INIT with decl type TYPE,
for use in a later add_const_value_attribute call. */
static rtx
rtl_for_decl_init (tree init, tree type)
{
rtx rtl = NULL_RTX;
STRIP_NOPS (init);
/* If a variable is initialized with a string constant without embedded
zeros, build CONST_STRING. */
if (TREE_CODE (init) == STRING_CST && TREE_CODE (type) == ARRAY_TYPE)
{
tree enttype = TREE_TYPE (type);
tree domain = TYPE_DOMAIN (type);
scalar_int_mode mode;
if (is_int_mode (TYPE_MODE (enttype), &mode)
&& GET_MODE_SIZE (mode) == 1
&& domain
&& TYPE_MAX_VALUE (domain)
&& TREE_CODE (TYPE_MAX_VALUE (domain)) == INTEGER_CST
&& integer_zerop (TYPE_MIN_VALUE (domain))
&& compare_tree_int (TYPE_MAX_VALUE (domain),
TREE_STRING_LENGTH (init) - 1) == 0
&& ((size_t) TREE_STRING_LENGTH (init)
== strlen (TREE_STRING_POINTER (init)) + 1))
{
rtl = gen_rtx_CONST_STRING (VOIDmode,
ggc_strdup (TREE_STRING_POINTER (init)));
rtl = gen_rtx_MEM (BLKmode, rtl);
MEM_READONLY_P (rtl) = 1;
}
}
/* Other aggregates, and complex values, could be represented using
CONCAT: FIXME! */
else if (AGGREGATE_TYPE_P (type)
|| (TREE_CODE (init) == VIEW_CONVERT_EXPR
&& AGGREGATE_TYPE_P (TREE_TYPE (TREE_OPERAND (init, 0))))
|| TREE_CODE (type) == COMPLEX_TYPE)
;
/* Vectors only work if their mode is supported by the target.
FIXME: generic vectors ought to work too. */
else if (TREE_CODE (type) == VECTOR_TYPE
&& !VECTOR_MODE_P (TYPE_MODE (type)))
;
/* If the initializer is something that we know will expand into an
immediate RTL constant, expand it now. We must be careful not to
reference variables which won't be output. */
else if (initializer_constant_valid_p (init, type)
&& ! walk_tree (&init, reference_to_unused, NULL, NULL))
{
/* Convert vector CONSTRUCTOR initializers to VECTOR_CST if
possible. */
if (TREE_CODE (type) == VECTOR_TYPE)
switch (TREE_CODE (init))
{
case VECTOR_CST:
break;
case CONSTRUCTOR:
if (TREE_CONSTANT (init))
{
vec<constructor_elt, va_gc> *elts = CONSTRUCTOR_ELTS (init);
bool constant_p = true;
tree value;
unsigned HOST_WIDE_INT ix;
/* Even when ctor is constant, it might contain non-*_CST
elements (e.g. { 1.0/0.0 - 1.0/0.0, 0.0 }) and those don't
belong into VECTOR_CST nodes. */
FOR_EACH_CONSTRUCTOR_VALUE (elts, ix, value)
if (!CONSTANT_CLASS_P (value))
{
constant_p = false;
break;
}
if (constant_p)
{
init = build_vector_from_ctor (type, elts);
break;
}
}
/* FALLTHRU */
default:
return NULL;
}
rtl = expand_expr (init, NULL_RTX, VOIDmode, EXPAND_INITIALIZER);
/* If expand_expr returns a MEM, it wasn't immediate. */
gcc_assert (!rtl || !MEM_P (rtl));
}
return rtl;
}
/* Generate RTL for the variable DECL to represent its location. */
static rtx
rtl_for_decl_location (tree decl)
{
rtx rtl;
/* Here we have to decide where we are going to say the parameter "lives"
(as far as the debugger is concerned). We only have a couple of
choices. GCC provides us with DECL_RTL and with DECL_INCOMING_RTL.
DECL_RTL normally indicates where the parameter lives during most of the
activation of the function. If optimization is enabled however, this
could be either NULL or else a pseudo-reg. Both of those cases indicate
that the parameter doesn't really live anywhere (as far as the code
generation parts of GCC are concerned) during most of the function's
activation. That will happen (for example) if the parameter is never
referenced within the function.
We could just generate a location descriptor here for all non-NULL
non-pseudo values of DECL_RTL and ignore all of the rest, but we can be
a little nicer than that if we also consider DECL_INCOMING_RTL in cases
where DECL_RTL is NULL or is a pseudo-reg.
Note however that we can only get away with using DECL_INCOMING_RTL as
a backup substitute for DECL_RTL in certain limited cases. In cases
where DECL_ARG_TYPE (decl) indicates the same type as TREE_TYPE (decl),
we can be sure that the parameter was passed using the same type as it is
declared to have within the function, and that its DECL_INCOMING_RTL
points us to a place where a value of that type is passed.
In cases where DECL_ARG_TYPE (decl) and TREE_TYPE (decl) are different,
we cannot (in general) use DECL_INCOMING_RTL as a substitute for DECL_RTL
because in these cases DECL_INCOMING_RTL points us to a value of some
type which is *different* from the type of the parameter itself. Thus,
if we tried to use DECL_INCOMING_RTL to generate a location attribute in
such cases, the debugger would end up (for example) trying to fetch a
`float' from a place which actually contains the first part of a
`double'. That would lead to really incorrect and confusing
output at debug-time.
So, in general, we *do not* use DECL_INCOMING_RTL as a backup for DECL_RTL
in cases where DECL_ARG_TYPE (decl) != TREE_TYPE (decl). There
are a couple of exceptions however. On little-endian machines we can
get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE (decl) is
not the same as TREE_TYPE (decl), but only when DECL_ARG_TYPE (decl) is
an integral type that is smaller than TREE_TYPE (decl). These cases arise
when (on a little-endian machine) a non-prototyped function has a
parameter declared to be of type `short' or `char'. In such cases,
TREE_TYPE (decl) will be `short' or `char', DECL_ARG_TYPE (decl) will
be `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
passed `int' value. If the debugger then uses that address to fetch
a `short' or a `char' (on a little-endian machine) the result will be
the correct data, so we allow for such exceptional cases below.
Note that our goal here is to describe the place where the given formal
parameter lives during most of the function's activation (i.e. between the
end of the prologue and the start of the epilogue). We'll do that as best
as we can. Note however that if the given formal parameter is modified
sometime during the execution of the function, then a stack backtrace (at
debug-time) will show the function as having been called with the *new*
value rather than the value which was originally passed in. This happens
rarely enough that it is not a major problem, but it *is* a problem, and
I'd like to fix it.
A future version of dwarf2out.c may generate two additional attributes for
any given DW_TAG_formal_parameter DIE which will describe the "passed
type" and the "passed location" for the given formal parameter in addition
to the attributes we now generate to indicate the "declared type" and the
"active location" for each parameter. This additional set of attributes
could be used by debuggers for stack backtraces. Separately, note that
sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL can be NULL also.
This happens (for example) for inlined-instances of inline function formal
parameters which are never referenced. This really shouldn't be
happening. All PARM_DECL nodes should get valid non-NULL
DECL_INCOMING_RTL values. FIXME. */
/* Use DECL_RTL as the "location" unless we find something better. */
rtl = DECL_RTL_IF_SET (decl);
/* When generating abstract instances, ignore everything except
constants, symbols living in memory, and symbols living in
fixed registers. */
if (! reload_completed)
{
if (rtl
&& (CONSTANT_P (rtl)
|| (MEM_P (rtl)
&& CONSTANT_P (XEXP (rtl, 0)))
|| (REG_P (rtl)
&& VAR_P (decl)
&& TREE_STATIC (decl))))
{
rtl = targetm.delegitimize_address (rtl);
return rtl;
}
rtl = NULL_RTX;
}
else if (TREE_CODE (decl) == PARM_DECL)
{
if (rtl == NULL_RTX
|| is_pseudo_reg (rtl)
|| (MEM_P (rtl)
&& is_pseudo_reg (XEXP (rtl, 0))
&& DECL_INCOMING_RTL (decl)
&& MEM_P (DECL_INCOMING_RTL (decl))
&& GET_MODE (rtl) == GET_MODE (DECL_INCOMING_RTL (decl))))
{
tree declared_type = TREE_TYPE (decl);
tree passed_type = DECL_ARG_TYPE (decl);
machine_mode dmode = TYPE_MODE (declared_type);
machine_mode pmode = TYPE_MODE (passed_type);
/* This decl represents a formal parameter which was optimized out.
Note that DECL_INCOMING_RTL may be NULL in here, but we handle
all cases where (rtl == NULL_RTX) just below. */
if (dmode == pmode)
rtl = DECL_INCOMING_RTL (decl);
else if ((rtl == NULL_RTX || is_pseudo_reg (rtl))
&& SCALAR_INT_MODE_P (dmode)
&& known_le (GET_MODE_SIZE (dmode), GET_MODE_SIZE (pmode))
&& DECL_INCOMING_RTL (decl))
{
rtx inc = DECL_INCOMING_RTL (decl);
if (REG_P (inc))
rtl = inc;
else if (MEM_P (inc))
{
if (BYTES_BIG_ENDIAN)
rtl = adjust_address_nv (inc, dmode,
GET_MODE_SIZE (pmode)
- GET_MODE_SIZE (dmode));
else
rtl = inc;
}
}
}
/* If the parm was passed in registers, but lives on the stack, then
make a big endian correction if the mode of the type of the
parameter is not the same as the mode of the rtl. */
/* ??? This is the same series of checks that are made in dbxout.c before
we reach the big endian correction code there. It isn't clear if all
of these checks are necessary here, but keeping them all is the safe
thing to do. */
else if (MEM_P (rtl)
&& XEXP (rtl, 0) != const0_rtx
&& ! CONSTANT_P (XEXP (rtl, 0))
/* Not passed in memory. */
&& !MEM_P (DECL_INCOMING_RTL (decl))
/* Not passed by invisible reference. */
&& (!REG_P (XEXP (rtl, 0))
|| REGNO (XEXP (rtl, 0)) == HARD_FRAME_POINTER_REGNUM
|| REGNO (XEXP (rtl, 0)) == STACK_POINTER_REGNUM
#if !HARD_FRAME_POINTER_IS_ARG_POINTER
|| REGNO (XEXP (rtl, 0)) == ARG_POINTER_REGNUM
#endif
)
/* Big endian correction check. */
&& BYTES_BIG_ENDIAN
&& TYPE_MODE (TREE_TYPE (decl)) != GET_MODE (rtl)
&& known_lt (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (decl))),
UNITS_PER_WORD))
{
machine_mode addr_mode = get_address_mode (rtl);
poly_int64 offset = (UNITS_PER_WORD
- GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (decl))));
rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (decl)),
plus_constant (addr_mode, XEXP (rtl, 0), offset));
}
}
else if (VAR_P (decl)
&& rtl
&& MEM_P (rtl)
&& GET_MODE (rtl) != TYPE_MODE (TREE_TYPE (decl)))
{
machine_mode addr_mode = get_address_mode (rtl);
poly_int64 offset = byte_lowpart_offset (TYPE_MODE (TREE_TYPE (decl)),
GET_MODE (rtl));
/* If a variable is declared "register" yet is smaller than
a register, then if we store the variable to memory, it
looks like we're storing a register-sized value, when in
fact we are not. We need to adjust the offset of the
storage location to reflect the actual value's bytes,
else gdb will not be able to display it. */
if (maybe_ne (offset, 0))
rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (decl)),
plus_constant (addr_mode, XEXP (rtl, 0), offset));
}
/* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time constant,
and will have been substituted directly into all expressions that use it.
C does not have such a concept, but C++ and other languages do. */
if (!rtl && VAR_P (decl) && DECL_INITIAL (decl))
rtl = rtl_for_decl_init (DECL_INITIAL (decl), TREE_TYPE (decl));
if (rtl)
rtl = targetm.delegitimize_address (rtl);
/* If we don't look past the constant pool, we risk emitting a
reference to a constant pool entry that isn't referenced from
code, and thus is not emitted. */
if (rtl)
rtl = avoid_constant_pool_reference (rtl);
/* Try harder to get a rtl. If this symbol ends up not being emitted
in the current CU, resolve_addr will remove the expression referencing
it. */
if (rtl == NULL_RTX
&& !(early_dwarf && (flag_generate_lto || flag_generate_offload))
&& VAR_P (decl)
&& !DECL_EXTERNAL (decl)
&& TREE_STATIC (decl)
&& DECL_NAME (decl)
&& !DECL_HARD_REGISTER (decl)
&& DECL_MODE (decl) != VOIDmode)
{
rtl = make_decl_rtl_for_debug (decl);
if (!MEM_P (rtl)
|| GET_CODE (XEXP (rtl, 0)) != SYMBOL_REF
|| SYMBOL_REF_DECL (XEXP (rtl, 0)) != decl)
rtl = NULL_RTX;
}
return rtl;
}
/* Check whether decl is a Fortran COMMON symbol. If not, NULL_TREE is
returned. If so, the decl for the COMMON block is returned, and the
value is the offset into the common block for the symbol. */
static tree
fortran_common (tree decl, HOST_WIDE_INT *value)
{
tree val_expr, cvar;
machine_mode mode;
poly_int64 bitsize, bitpos;
tree offset;
HOST_WIDE_INT cbitpos;
int unsignedp, reversep, volatilep = 0;
/* If the decl isn't a VAR_DECL, or if it isn't static, or if
it does not have a value (the offset into the common area), or if it
is thread local (as opposed to global) then it isn't common, and shouldn't
be handled as such. */
if (!VAR_P (decl)
|| !TREE_STATIC (decl)
|| !DECL_HAS_VALUE_EXPR_P (decl)
|| !is_fortran ())
return NULL_TREE;
val_expr = DECL_VALUE_EXPR (decl);
if (TREE_CODE (val_expr) != COMPONENT_REF)
return NULL_TREE;
cvar = get_inner_reference (val_expr, &bitsize, &bitpos, &offset, &mode,
&unsignedp, &reversep, &volatilep);
if (cvar == NULL_TREE
|| !VAR_P (cvar)
|| DECL_ARTIFICIAL (cvar)
|| !TREE_PUBLIC (cvar)
/* We don't expect to have to cope with variable offsets,
since at present all static data must have a constant size. */
|| !bitpos.is_constant (&cbitpos))
return NULL_TREE;
*value = 0;
if (offset != NULL)
{
if (!tree_fits_shwi_p (offset))
return NULL_TREE;
*value = tree_to_shwi (offset);
}
if (cbitpos != 0)
*value += cbitpos / BITS_PER_UNIT;
return cvar;
}
/* Generate *either* a DW_AT_location attribute or else a DW_AT_const_value
data attribute for a variable or a parameter. We generate the
DW_AT_const_value attribute only in those cases where the given variable
or parameter does not have a true "location" either in memory or in a
register. This can happen (for example) when a constant is passed as an
actual argument in a call to an inline function. (It's possible that
these things can crop up in other ways also.) Note that one type of
constant value which can be passed into an inlined function is a constant
pointer. This can happen for example if an actual argument in an inlined
function call evaluates to a compile-time constant address.
CACHE_P is true if it is worth caching the location list for DECL,
so that future calls can reuse it rather than regenerate it from scratch.
This is true for BLOCK_NONLOCALIZED_VARS in inlined subroutines,
since we will need to refer to them each time the function is inlined. */
static bool
add_location_or_const_value_attribute (dw_die_ref die, tree decl, bool cache_p)
{
rtx rtl;
dw_loc_list_ref list;
var_loc_list *loc_list;
cached_dw_loc_list *cache;
if (early_dwarf)
return false;
if (TREE_CODE (decl) == ERROR_MARK)
return false;
if (get_AT (die, DW_AT_location)
|| get_AT (die, DW_AT_const_value))
return true;
gcc_assert (VAR_P (decl) || TREE_CODE (decl) == PARM_DECL
|| TREE_CODE (decl) == RESULT_DECL);
/* Try to get some constant RTL for this decl, and use that as the value of
the location. */
rtl = rtl_for_decl_location (decl);
if (rtl && (CONSTANT_P (rtl) || GET_CODE (rtl) == CONST_STRING)
&& add_const_value_attribute (die, rtl))
return true;
/* See if we have single element location list that is equivalent to
a constant value. That way we are better to use add_const_value_attribute
rather than expanding constant value equivalent. */
loc_list = lookup_decl_loc (decl);
if (loc_list
&& loc_list->first
&& loc_list->first->next == NULL
&& NOTE_P (loc_list->first->loc)
&& NOTE_VAR_LOCATION (loc_list->first->loc)
&& NOTE_VAR_LOCATION_LOC (loc_list->first->loc))
{
struct var_loc_node *node;
node = loc_list->first;
rtl = NOTE_VAR_LOCATION_LOC (node->loc);
if (GET_CODE (rtl) == EXPR_LIST)
rtl = XEXP (rtl, 0);
if ((CONSTANT_P (rtl) || GET_CODE (rtl) == CONST_STRING)
&& add_const_value_attribute (die, rtl))
return true;
}
/* If this decl is from BLOCK_NONLOCALIZED_VARS, we might need its
list several times. See if we've already cached the contents. */
list = NULL;
if (loc_list == NULL || cached_dw_loc_list_table == NULL)
cache_p = false;
if (cache_p)
{
cache = cached_dw_loc_list_table->find_with_hash (decl, DECL_UID (decl));
if (cache)
list = cache->loc_list;
}
if (list == NULL)
{
list = loc_list_from_tree (decl, decl_by_reference_p (decl) ? 0 : 2,
NULL);
/* It is usually worth caching this result if the decl is from
BLOCK_NONLOCALIZED_VARS and if the list has at least two elements. */
if (cache_p && list && list->dw_loc_next)
{
cached_dw_loc_list **slot
= cached_dw_loc_list_table->find_slot_with_hash (decl,
DECL_UID (decl),
INSERT);
cache = ggc_cleared_alloc<cached_dw_loc_list> ();
cache->decl_id = DECL_UID (decl);
cache->loc_list = list;
*slot = cache;
}
}
if (list)
{
add_AT_location_description (die, DW_AT_location, list);
return true;
}
/* None of that worked, so it must not really have a location;
try adding a constant value attribute from the DECL_INITIAL. */
return tree_add_const_value_attribute_for_decl (die, decl);
}
/* Attach a DW_AT_const_value attribute to DIE. The value of the
attribute is the const value T. */
static bool
tree_add_const_value_attribute (dw_die_ref die, tree t)
{
tree init;
tree type = TREE_TYPE (t);
rtx rtl;
if (!t || !TREE_TYPE (t) || TREE_TYPE (t) == error_mark_node)
return false;
init = t;
gcc_assert (!DECL_P (init));
if (TREE_CODE (init) == INTEGER_CST)
{
if (tree_fits_uhwi_p (init))
{
add_AT_unsigned (die, DW_AT_const_value, tree_to_uhwi (init));
return true;
}
if (tree_fits_shwi_p (init))
{
add_AT_int (die, DW_AT_const_value, tree_to_shwi (init));
return true;
}
}
/* Generate the RTL even if early_dwarf to force mangling of all refered to
symbols. */
rtl = rtl_for_decl_init (init, type);
if (rtl && !early_dwarf)
return add_const_value_attribute (die, rtl);
/* If the host and target are sane, try harder. */
if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
&& initializer_constant_valid_p (init, type))
{
HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (init));
if (size > 0 && (int) size == size)
{
unsigned char *array = ggc_cleared_vec_alloc<unsigned char> (size);
if (native_encode_initializer (init, array, size) == size)
{
add_AT_vec (die, DW_AT_const_value, size, 1, array);
return true;
}
ggc_free (array);
}
}
return false;
}
/* Attach a DW_AT_const_value attribute to VAR_DIE. The value of the
attribute is the const value of T, where T is an integral constant
variable with static storage duration
(so it can't be a PARM_DECL or a RESULT_DECL). */
static bool
tree_add_const_value_attribute_for_decl (dw_die_ref var_die, tree decl)
{
if (!decl
|| (!VAR_P (decl) && TREE_CODE (decl) != CONST_DECL)
|| (VAR_P (decl) && !TREE_STATIC (decl)))
return false;
if (TREE_READONLY (decl)
&& ! TREE_THIS_VOLATILE (decl)
&& DECL_INITIAL (decl))
/* OK */;
else
return false;
/* Don't add DW_AT_const_value if abstract origin already has one. */
if (get_AT (var_die, DW_AT_const_value))
return false;
return tree_add_const_value_attribute (var_die, DECL_INITIAL (decl));
}
/* Convert the CFI instructions for the current function into a
location list. This is used for DW_AT_frame_base when we targeting
a dwarf2 consumer that does not support the dwarf3
DW_OP_call_frame_cfa. OFFSET is a constant to be added to all CFA
expressions. */
static dw_loc_list_ref
convert_cfa_to_fb_loc_list (HOST_WIDE_INT offset)
{
int ix;
dw_fde_ref fde;
dw_loc_list_ref list, *list_tail;
dw_cfi_ref cfi;
dw_cfa_location last_cfa, next_cfa;
const char *start_label, *last_label, *section;
dw_cfa_location remember;
fde = cfun->fde;
gcc_assert (fde != NULL);
section = secname_for_decl (current_function_decl);
list_tail = &list;
list = NULL;
memset (&next_cfa, 0, sizeof (next_cfa));
next_cfa.reg = INVALID_REGNUM;
remember = next_cfa;
start_label = fde->dw_fde_begin;
/* ??? Bald assumption that the CIE opcode list does not contain
advance opcodes. */
FOR_EACH_VEC_ELT (*cie_cfi_vec, ix, cfi)
lookup_cfa_1 (cfi, &next_cfa, &remember);
last_cfa = next_cfa;
last_label = start_label;
if (fde->dw_fde_second_begin && fde->dw_fde_switch_cfi_index == 0)
{
/* If the first partition contained no CFI adjustments, the
CIE opcodes apply to the whole first partition. */
*list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset),
fde->dw_fde_begin, 0, fde->dw_fde_end, 0, section);
list_tail =&(*list_tail)->dw_loc_next;
start_label = last_label = fde->dw_fde_second_begin;
}
FOR_EACH_VEC_SAFE_ELT (fde->dw_fde_cfi, ix, cfi)
{
switch (cfi->dw_cfi_opc)
{
case DW_CFA_set_loc:
case DW_CFA_advance_loc1:
case DW_CFA_advance_loc2:
case DW_CFA_advance_loc4:
if (!cfa_equal_p (&last_cfa, &next_cfa))
{
*list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset),
start_label, 0, last_label, 0, section);
list_tail = &(*list_tail)->dw_loc_next;
last_cfa = next_cfa;
start_label = last_label;
}
last_label = cfi->dw_cfi_oprnd1.dw_cfi_addr;
break;
case DW_CFA_advance_loc:
/* The encoding is complex enough that we should never emit this. */
gcc_unreachable ();
default:
lookup_cfa_1 (cfi, &next_cfa, &remember);
break;
}
if (ix + 1 == fde->dw_fde_switch_cfi_index)
{
if (!cfa_equal_p (&last_cfa, &next_cfa))
{
*list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset),
start_label, 0, last_label, 0, section);
list_tail = &(*list_tail)->dw_loc_next;
last_cfa = next_cfa;
start_label = last_label;
}
*list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset),
start_label, 0, fde->dw_fde_end, 0, section);
list_tail = &(*list_tail)->dw_loc_next;
start_label = last_label = fde->dw_fde_second_begin;
}
}
if (!cfa_equal_p (&last_cfa, &next_cfa))
{
*list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset),
start_label, 0, last_label, 0, section);
list_tail = &(*list_tail)->dw_loc_next;
start_label = last_label;
}
*list_tail = new_loc_list (build_cfa_loc (&next_cfa, offset),
start_label, 0,
fde->dw_fde_second_begin
? fde->dw_fde_second_end : fde->dw_fde_end, 0,
section);
maybe_gen_llsym (list);
return list;
}
/* Compute a displacement from the "steady-state frame pointer" to the
frame base (often the same as the CFA), and store it in
frame_pointer_fb_offset. OFFSET is added to the displacement
before the latter is negated. */
static void
compute_frame_pointer_to_fb_displacement (poly_int64 offset)
{
rtx reg, elim;
#ifdef FRAME_POINTER_CFA_OFFSET
reg = frame_pointer_rtx;
offset += FRAME_POINTER_CFA_OFFSET (current_function_decl);
#else
reg = arg_pointer_rtx;
offset += ARG_POINTER_CFA_OFFSET (current_function_decl);
#endif
elim = (ira_use_lra_p
? lra_eliminate_regs (reg, VOIDmode, NULL_RTX)
: eliminate_regs (reg, VOIDmode, NULL_RTX));
elim = strip_offset_and_add (elim, &offset);
frame_pointer_fb_offset = -offset;
/* ??? AVR doesn't set up valid eliminations when there is no stack frame
in which to eliminate. This is because it's stack pointer isn't
directly accessible as a register within the ISA. To work around
this, assume that while we cannot provide a proper value for
frame_pointer_fb_offset, we won't need one either. We can use
hard frame pointer in debug info even if frame pointer isn't used
since hard frame pointer in debug info is encoded with DW_OP_fbreg
which uses the DW_AT_frame_base attribute, not hard frame pointer
directly. */
frame_pointer_fb_offset_valid
= (elim == hard_frame_pointer_rtx || elim == stack_pointer_rtx);
}
/* Generate a DW_AT_name attribute given some string value to be included as
the value of the attribute. */
static void
add_name_attribute (dw_die_ref die, const char *name_string)
{
if (name_string != NULL && *name_string != 0)
{
if (demangle_name_func)
name_string = (*demangle_name_func) (name_string);
add_AT_string (die, DW_AT_name, name_string);
}
}
/* Generate a DW_AT_name attribute given some string value representing a
file or filepath to be included as value of the attribute. */
static void
add_filename_attribute (dw_die_ref die, const char *name_string)
{
if (name_string != NULL && *name_string != 0)
add_filepath_AT_string (die, DW_AT_name, name_string);
}
/* Generate a DW_AT_description attribute given some string value to be included
as the value of the attribute. */
static void
add_desc_attribute (dw_die_ref die, const char *name_string)
{
if (!flag_describe_dies || (dwarf_version < 3 && dwarf_strict))
return;
if (name_string == NULL || *name_string == 0)
return;
if (demangle_name_func)
name_string = (*demangle_name_func) (name_string);
add_AT_string (die, DW_AT_description, name_string);
}
/* Generate a DW_AT_description attribute given some decl to be included
as the value of the attribute. */
static void
add_desc_attribute (dw_die_ref die, tree decl)
{
tree decl_name;
if (!flag_describe_dies || (dwarf_version < 3 && dwarf_strict))
return;
if (decl == NULL_TREE || !DECL_P (decl))
return;
decl_name = DECL_NAME (decl);
if (decl_name != NULL && IDENTIFIER_POINTER (decl_name) != NULL)
{
const char *name = dwarf2_name (decl, 0);
add_desc_attribute (die, name ? name : IDENTIFIER_POINTER (decl_name));
}
else
{
char *desc = print_generic_expr_to_str (decl);
add_desc_attribute (die, desc);
free (desc);
}
}
/* Retrieve the descriptive type of TYPE, if any, make sure it has a
DIE and attach a DW_AT_GNAT_descriptive_type attribute to the DIE
of TYPE accordingly.
??? This is a temporary measure until after we're able to generate
regular DWARF for the complex Ada type system. */
static void
add_gnat_descriptive_type_attribute (dw_die_ref die, tree type,
dw_die_ref context_die)
{
tree dtype;
dw_die_ref dtype_die;
if (!lang_hooks.types.descriptive_type)
return;
dtype = lang_hooks.types.descriptive_type (type);
if (!dtype)
return;
dtype_die = lookup_type_die (dtype);
if (!dtype_die)
{
gen_type_die (dtype, context_die);
dtype_die = lookup_type_die (dtype);
gcc_assert (dtype_die);
}
add_AT_die_ref (die, DW_AT_GNAT_descriptive_type, dtype_die);
}
/* Retrieve the comp_dir string suitable for use with DW_AT_comp_dir. */
static const char *
comp_dir_string (void)
{
const char *wd;
char *wd_plus_sep = NULL;
static const char *cached_wd = NULL;
if (cached_wd != NULL)
return cached_wd;
wd = get_src_pwd ();
if (wd == NULL)
return NULL;
if (DWARF2_DIR_SHOULD_END_WITH_SEPARATOR)
{
size_t wdlen = strlen (wd);
wd_plus_sep = XNEWVEC (char, wdlen + 2);
strcpy (wd_plus_sep, wd);
wd_plus_sep [wdlen] = DIR_SEPARATOR;
wd_plus_sep [wdlen + 1] = 0;
wd = wd_plus_sep;
}
cached_wd = remap_debug_filename (wd);
/* remap_debug_filename can just pass through wd or return a new gc string.
These two types can't be both stored in a GTY(())-tagged string, but since
the cached value lives forever just copy it if needed. */
if (cached_wd != wd)
{
cached_wd = xstrdup (cached_wd);
if (DWARF2_DIR_SHOULD_END_WITH_SEPARATOR && wd_plus_sep != NULL)
free (wd_plus_sep);
}
return cached_wd;
}
/* Generate a DW_AT_comp_dir attribute for DIE. */
static void
add_comp_dir_attribute (dw_die_ref die)
{
const char * wd = comp_dir_string ();
if (wd != NULL)
add_filepath_AT_string (die, DW_AT_comp_dir, wd);
}
/* Given a tree node VALUE describing a scalar attribute ATTR (i.e. a bound, a
pointer computation, ...), output a representation for that bound according
to the accepted FORMS (see enum dw_scalar_form) and add it to DIE. See
loc_list_from_tree for the meaning of CONTEXT. */
static void
add_scalar_info (dw_die_ref die, enum dwarf_attribute attr, tree value,
int forms, struct loc_descr_context *context)
{
dw_die_ref context_die, decl_die = NULL;
dw_loc_list_ref list;
bool strip_conversions = true;
bool placeholder_seen = false;
while (strip_conversions)
switch (TREE_CODE (value))
{
case ERROR_MARK:
case SAVE_EXPR:
return;
CASE_CONVERT:
case VIEW_CONVERT_EXPR:
value = TREE_OPERAND (value, 0);
break;
default:
strip_conversions = false;
break;
}
/* If possible and permitted, output the attribute as a constant. */
if ((forms & dw_scalar_form_constant) != 0
&& TREE_CODE (value) == INTEGER_CST)
{
unsigned int prec = simple_type_size_in_bits (TREE_TYPE (value));
/* If HOST_WIDE_INT is big enough then represent the bound as
a constant value. We need to choose a form based on
whether the type is signed or unsigned. We cannot just
call add_AT_unsigned if the value itself is positive
(add_AT_unsigned might add the unsigned value encoded as
DW_FORM_data[1248]). Some DWARF consumers will lookup the
bounds type and then sign extend any unsigned values found
for signed types. This is needed only for
DW_AT_{lower,upper}_bound, since for most other attributes,
consumers will treat DW_FORM_data[1248] as unsigned values,
regardless of the underlying type. */
if (prec <= HOST_BITS_PER_WIDE_INT
|| tree_fits_uhwi_p (value))
{
if (TYPE_UNSIGNED (TREE_TYPE (value)))
add_AT_unsigned (die, attr, TREE_INT_CST_LOW (value));
else
add_AT_int (die, attr, TREE_INT_CST_LOW (value));
}
else if (dwarf_version >= 5
&& TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (value))) == 128)
/* Otherwise represent the bound as an unsigned value with
the precision of its type. The precision and signedness
of the type will be necessary to re-interpret it
unambiguously. */
add_AT_wide (die, attr, wi::to_wide (value));
else
{
rtx v = immed_wide_int_const (wi::to_wide (value),
TYPE_MODE (TREE_TYPE (value)));
dw_loc_descr_ref loc
= loc_descriptor (v, TYPE_MODE (TREE_TYPE (value)),
VAR_INIT_STATUS_INITIALIZED);
if (loc)
add_AT_loc (die, attr, loc);
}
return;
}
/* Otherwise, if it's possible and permitted too, output a reference to
another DIE. */
if ((forms & dw_scalar_form_reference) != 0)
{
tree decl = NULL_TREE;
/* Some type attributes reference an outer type. For instance, the upper
bound of an array may reference an embedding record (this happens in
Ada). */
if (TREE_CODE (value) == COMPONENT_REF
&& TREE_CODE (TREE_OPERAND (value, 0)) == PLACEHOLDER_EXPR
&& TREE_CODE (TREE_OPERAND (value, 1)) == FIELD_DECL)
decl = TREE_OPERAND (value, 1);
else if (VAR_P (value)
|| TREE_CODE (value) == PARM_DECL
|| TREE_CODE (value) == RESULT_DECL)
decl = value;
if (decl != NULL_TREE)
{
decl_die = lookup_decl_die (decl);
/* ??? Can this happen, or should the variable have been bound
first? Probably it can, since I imagine that we try to create
the types of parameters in the order in which they exist in
the list, and won't have created a forward reference to a
later parameter. */
if (decl_die != NULL)
{
if (get_AT (decl_die, DW_AT_location)
|| get_AT (decl_die, DW_AT_data_member_location)
|| get_AT (decl_die, DW_AT_const_value))
{
add_AT_die_ref (die, attr, decl_die);
return;
}
}
}
}
/* Last chance: try to create a stack operation procedure to evaluate the
value. Do nothing if even that is not possible or permitted. */
if ((forms & dw_scalar_form_exprloc) == 0)
return;
list = loc_list_from_tree (value, 2, context);
if (context && context->placeholder_arg)
{
placeholder_seen = context->placeholder_seen;
context->placeholder_seen = false;
}
if (list == NULL || single_element_loc_list_p (list))
{
/* If this attribute is not a reference nor constant, it is
a DWARF expression rather than location description. For that
loc_list_from_tree (value, 0, &context) is needed. */
dw_loc_list_ref list2 = loc_list_from_tree (value, 0, context);
if (list2 && single_element_loc_list_p (list2))
{
if (placeholder_seen)
{
struct dwarf_procedure_info dpi;
dpi.fndecl = NULL_TREE;
dpi.args_count = 1;
if (!resolve_args_picking (list2->expr, 1, &dpi))
return;
}
add_AT_loc (die, attr, list2->expr);
return;
}
}
/* If that failed to give a single element location list, fall back to
outputting this as a reference... still if permitted. */
if (list == NULL
|| (forms & dw_scalar_form_reference) == 0
|| placeholder_seen)
return;
if (!decl_die)
{
if (current_function_decl == 0)
context_die = comp_unit_die ();
else
context_die = lookup_decl_die (current_function_decl);
decl_die = new_die (DW_TAG_variable, context_die, value);
add_AT_flag (decl_die, DW_AT_artificial, 1);
add_type_attribute (decl_die, TREE_TYPE (value), TYPE_QUAL_CONST, false,
context_die);
}
add_AT_location_description (decl_die, DW_AT_location, list);
add_AT_die_ref (die, attr, decl_die);
}
/* Return the default for DW_AT_lower_bound, or -1 if there is not any
default. */
static int
lower_bound_default (void)
{
switch (get_AT_unsigned (comp_unit_die (), DW_AT_language))
{
case DW_LANG_C:
case DW_LANG_C89:
case DW_LANG_C99:
case DW_LANG_C11:
case DW_LANG_C_plus_plus:
case DW_LANG_C_plus_plus_11:
case DW_LANG_C_plus_plus_14:
case DW_LANG_ObjC:
case DW_LANG_ObjC_plus_plus:
return 0;
case DW_LANG_Fortran77:
case DW_LANG_Fortran90:
case DW_LANG_Fortran95:
case DW_LANG_Fortran03:
case DW_LANG_Fortran08:
return 1;
case DW_LANG_UPC:
case DW_LANG_D:
case DW_LANG_Python:
return dwarf_version >= 4 ? 0 : -1;
case DW_LANG_Ada95:
case DW_LANG_Ada83:
case DW_LANG_Cobol74:
case DW_LANG_Cobol85:
case DW_LANG_Modula2:
case DW_LANG_PLI:
return dwarf_version >= 4 ? 1 : -1;
default:
return -1;
}
}
/* Given a tree node describing an array bound (either lower or upper) output
a representation for that bound. */
static void
add_bound_info (dw_die_ref subrange_die, enum dwarf_attribute bound_attr,
tree bound, struct loc_descr_context *context)
{
int dflt;
while (1)
switch (TREE_CODE (bound))
{
/* Strip all conversions. */
CASE_CONVERT:
case VIEW_CONVERT_EXPR:
bound = TREE_OPERAND (bound, 0);
break;
/* All fixed-bounds are represented by INTEGER_CST nodes. Lower bounds
are even omitted when they are the default. */
case INTEGER_CST:
/* If the value for this bound is the default one, we can even omit the
attribute. */
if (bound_attr == DW_AT_lower_bound
&& tree_fits_shwi_p (bound)
&& (dflt = lower_bound_default ()) != -1
&& tree_to_shwi (bound) == dflt)
return;
/* FALLTHRU */
default:
/* Because of the complex interaction there can be with other GNAT
encodings, GDB isn't ready yet to handle proper DWARF description
for self-referencial subrange bounds: let GNAT encodings do the
magic in such a case. */
if (is_ada ()
&& gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL
&& contains_placeholder_p (bound))
return;
add_scalar_info (subrange_die, bound_attr, bound,
dw_scalar_form_constant
| dw_scalar_form_exprloc
| dw_scalar_form_reference,
context);
return;
}
}
/* Add subscript info to TYPE_DIE, describing an array TYPE, collapsing
possibly nested array subscripts in a flat sequence if COLLAPSE_P is true.
Note that the block of subscript information for an array type also
includes information about the element type of the given array type.
This function reuses previously set type and bound information if
available. */
static void
add_subscript_info (dw_die_ref type_die, tree type, bool collapse_p)
{
unsigned dimension_number;
tree lower, upper;
dw_die_ref child = type_die->die_child;
for (dimension_number = 0;
TREE_CODE (type) == ARRAY_TYPE && (dimension_number == 0 || collapse_p);
type = TREE_TYPE (type), dimension_number++)
{
tree domain = TYPE_DOMAIN (type);
if (TYPE_STRING_FLAG (type) && is_fortran () && dimension_number > 0)
break;
/* Arrays come in three flavors: Unspecified bounds, fixed bounds,
and (in GNU C only) variable bounds. Handle all three forms
here. */
/* Find and reuse a previously generated DW_TAG_subrange_type if
available.
For multi-dimensional arrays, as we iterate through the
various dimensions in the enclosing for loop above, we also
iterate through the DIE children and pick at each
DW_TAG_subrange_type previously generated (if available).
Each child DW_TAG_subrange_type DIE describes the range of
the current dimension. At this point we should have as many
DW_TAG_subrange_type's as we have dimensions in the
array. */
dw_die_ref subrange_die = NULL;
if (child)
while (1)
{
child = child->die_sib;
if (child->die_tag == DW_TAG_subrange_type)
subrange_die = child;
if (child == type_die->die_child)
{
/* If we wrapped around, stop looking next time. */
child = NULL;
break;
}
if (child->die_tag == DW_TAG_subrange_type)
break;
}
if (!subrange_die)
subrange_die = new_die (DW_TAG_subrange_type, type_die, NULL);
if (domain)
{
/* We have an array type with specified bounds. */
lower = TYPE_MIN_VALUE (domain);
upper = TYPE_MAX_VALUE (domain);
/* Define the index type. */
if (TREE_TYPE (domain)
&& !get_AT (subrange_die, DW_AT_type))
{
/* ??? This is probably an Ada unnamed subrange type. Ignore the
TREE_TYPE field. We can't emit debug info for this
because it is an unnamed integral type. */
if (TREE_CODE (domain) == INTEGER_TYPE
&& TYPE_NAME (domain) == NULL_TREE
&& TREE_CODE (TREE_TYPE (domain)) == INTEGER_TYPE
&& TYPE_NAME (TREE_TYPE (domain)) == NULL_TREE)
;
else
add_type_attribute (subrange_die, TREE_TYPE (domain),
TYPE_UNQUALIFIED, false, type_die);
}
/* ??? If upper is NULL, the array has unspecified length,
but it does have a lower bound. This happens with Fortran
dimension arr(N:*)
Since the debugger is definitely going to need to know N
to produce useful results, go ahead and output the lower
bound solo, and hope the debugger can cope. */
if (!get_AT (subrange_die, DW_AT_lower_bound))
add_bound_info (subrange_die, DW_AT_lower_bound, lower, NULL);
if (!get_AT (subrange_die, DW_AT_upper_bound)
&& !get_AT (subrange_die, DW_AT_count))
{
if (upper)
add_bound_info (subrange_die, DW_AT_upper_bound, upper, NULL);
else if ((is_c () || is_cxx ()) && COMPLETE_TYPE_P (type))
/* Zero-length array. */
add_bound_info (subrange_die, DW_AT_count,
build_int_cst (TREE_TYPE (lower), 0), NULL);
}
}
/* Otherwise we have an array type with an unspecified length. The
DWARF-2 spec does not say how to handle this; let's just leave out the
bounds. */
}
}
/* Add a DW_AT_byte_size attribute to DIE with TREE_NODE's size. */
static void
add_byte_size_attribute (dw_die_ref die, tree tree_node)
{
dw_die_ref decl_die;
HOST_WIDE_INT size;
dw_loc_descr_ref size_expr = NULL;
switch (TREE_CODE (tree_node))
{
case ERROR_MARK:
size = 0;
break;
case ENUMERAL_TYPE:
case RECORD_TYPE:
case UNION_TYPE:
case QUAL_UNION_TYPE:
if (TREE_CODE (TYPE_SIZE_UNIT (tree_node)) == VAR_DECL
&& (decl_die = lookup_decl_die (TYPE_SIZE_UNIT (tree_node))))
{
add_AT_die_ref (die, DW_AT_byte_size, decl_die);
return;
}
size_expr = type_byte_size (tree_node, &size);
break;
case FIELD_DECL:
/* For a data member of a struct or union, the DW_AT_byte_size is
generally given as the number of bytes normally allocated for an
object of the *declared* type of the member itself. This is true
even for bit-fields. */
size = int_size_in_bytes (field_type (tree_node));
break;
default:
gcc_unreachable ();
}
/* Support for dynamically-sized objects was introduced by DWARFv3.
At the moment, GDB does not handle variable byte sizes very well,
though. */
if ((dwarf_version >= 3 || !dwarf_strict)
&& gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL
&& size_expr != NULL)
add_AT_loc (die, DW_AT_byte_size, size_expr);
/* Note that `size' might be -1 when we get to this point. If it is, that
indicates that the byte size of the entity in question is variable and
that we could not generate a DWARF expression that computes it. */
if (size >= 0)
add_AT_unsigned (die, DW_AT_byte_size, size);
}
/* Add a DW_AT_alignment attribute to DIE with TREE_NODE's non-default
alignment. */
static void
add_alignment_attribute (dw_die_ref die, tree tree_node)
{
if (dwarf_version < 5 && dwarf_strict)
return;
unsigned align;
if (DECL_P (tree_node))
{
if (!DECL_USER_ALIGN (tree_node))
return;
align = DECL_ALIGN_UNIT (tree_node);
}
else if (TYPE_P (tree_node))
{
if (!TYPE_USER_ALIGN (tree_node))
return;
align = TYPE_ALIGN_UNIT (tree_node);
}
else
gcc_unreachable ();
add_AT_unsigned (die, DW_AT_alignment, align);
}
/* For a FIELD_DECL node which represents a bit-field, output an attribute
which specifies the distance in bits from the highest order bit of the
"containing object" for the bit-field to the highest order bit of the
bit-field itself.
For any given bit-field, the "containing object" is a hypothetical object
(of some integral or enum type) within which the given bit-field lives. The
type of this hypothetical "containing object" is always the same as the
declared type of the individual bit-field itself. The determination of the
exact location of the "containing object" for a bit-field is rather
complicated. It's handled by the `field_byte_offset' function (above).
Note that it is the size (in bytes) of the hypothetical "containing object"
which will be given in the DW_AT_byte_size attribute for this bit-field.
(See `byte_size_attribute' above). */
static inline void
add_bit_offset_attribute (dw_die_ref die, tree decl)
{
HOST_WIDE_INT object_offset_in_bytes;
tree original_type = DECL_BIT_FIELD_TYPE (decl);
HOST_WIDE_INT bitpos_int;
HOST_WIDE_INT highest_order_object_bit_offset;
HOST_WIDE_INT highest_order_field_bit_offset;
HOST_WIDE_INT bit_offset;
/* The containing object is within the DECL_CONTEXT. */
struct vlr_context ctx = { DECL_CONTEXT (decl), NULL_TREE };
field_byte_offset (decl, &ctx, &object_offset_in_bytes);
/* Must be a field and a bit field. */
gcc_assert (original_type && TREE_CODE (decl) == FIELD_DECL);
/* We can't yet handle bit-fields whose offsets are variable, so if we
encounter such things, just return without generating any attribute
whatsoever. Likewise for variable or too large size. */
if (! tree_fits_shwi_p (bit_position (decl))
|| ! tree_fits_uhwi_p (DECL_SIZE (decl)))
return;
bitpos_int = int_bit_position (decl);
/* Note that the bit offset is always the distance (in bits) from the
highest-order bit of the "containing object" to the highest-order bit of
the bit-field itself. Since the "high-order end" of any object or field
is different on big-endian and little-endian machines, the computation
below must take account of these differences. */
highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT;
highest_order_field_bit_offset = bitpos_int;
if (! BYTES_BIG_ENDIAN)
{
highest_order_field_bit_offset += tree_to_shwi (DECL_SIZE (decl));
highest_order_object_bit_offset +=
simple_type_size_in_bits (original_type);
}
bit_offset
= (! BYTES_BIG_ENDIAN
? highest_order_object_bit_offset - highest_order_field_bit_offset
: highest_order_field_bit_offset - highest_order_object_bit_offset);
if (bit_offset < 0)
add_AT_int (die, DW_AT_bit_offset, bit_offset);
else
add_AT_unsigned (die, DW_AT_bit_offset, (unsigned HOST_WIDE_INT) bit_offset);
}
/* For a FIELD_DECL node which represents a bit field, output an attribute
which specifies the length in bits of the given field. */
static inline void
add_bit_size_attribute (dw_die_ref die, tree decl)
{
/* Must be a field and a bit field. */
gcc_assert (TREE_CODE (decl) == FIELD_DECL
&& DECL_BIT_FIELD_TYPE (decl));
if (tree_fits_uhwi_p (DECL_SIZE (decl)))
add_AT_unsigned (die, DW_AT_bit_size, tree_to_uhwi (DECL_SIZE (decl)));
}
/* If the compiled language is ANSI C, then add a 'prototyped'
attribute, if arg types are given for the parameters of a function. */
static inline void
add_prototyped_attribute (dw_die_ref die, tree func_type)
{
switch (get_AT_unsigned (comp_unit_die (), DW_AT_language))
{
case DW_LANG_C:
case DW_LANG_C89:
case DW_LANG_C99:
case DW_LANG_C11:
case DW_LANG_ObjC:
if (prototype_p (func_type))
add_AT_flag (die, DW_AT_prototyped, 1);
break;
default:
break;
}
}
/* Add an 'abstract_origin' attribute below a given DIE. The DIE is found
by looking in the type declaration, the object declaration equate table or
the block mapping. */
static inline void
add_abstract_origin_attribute (dw_die_ref die, tree origin)
{
dw_die_ref origin_die = NULL;
/* For late LTO debug output we want to refer directly to the abstract
DIE in the early debug rather to the possibly existing concrete
instance and avoid creating that just for this purpose. */
sym_off_pair *desc;
if (in_lto_p
&& external_die_map
&& (desc = external_die_map->get (origin)))
{
add_AT_external_die_ref (die, DW_AT_abstract_origin,
desc->sym, desc->off);
return;
}
if (DECL_P (origin))
origin_die = lookup_decl_die (origin);
else if (TYPE_P (origin))
origin_die = lookup_type_die (origin);
else if (TREE_CODE (origin) == BLOCK)
origin_die = lookup_block_die (origin);
/* XXX: Functions that are never lowered don't always have correct block
trees (in the case of java, they simply have no block tree, in some other
languages). For these functions, there is nothing we can really do to
output correct debug info for inlined functions in all cases. Rather
than die, we'll just produce deficient debug info now, in that we will
have variables without a proper abstract origin. In the future, when all
functions are lowered, we should re-add a gcc_assert (origin_die)
here. */
if (origin_die)
{
dw_attr_node *a;
/* Like above, if we already created a concrete instance DIE
do not use that for the abstract origin but the early DIE
if present. */
if (in_lto_p
&& (a = get_AT (origin_die, DW_AT_abstract_origin)))
origin_die = AT_ref (a);
add_AT_die_ref (die, DW_AT_abstract_origin, origin_die);
}
}
/* We do not currently support the pure_virtual attribute. */
static inline void
add_pure_or_virtual_attribute (dw_die_ref die, tree func_decl)
{
if (DECL_VINDEX (func_decl))
{
add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual);
if (tree_fits_shwi_p (DECL_VINDEX (func_decl)))
add_AT_loc (die, DW_AT_vtable_elem_location,
new_loc_descr (DW_OP_constu,
tree_to_shwi (DECL_VINDEX (func_decl)),
0));
/* GNU extension: Record what type this method came from originally. */
if (debug_info_level > DINFO_LEVEL_TERSE
&& DECL_CONTEXT (func_decl))
add_AT_die_ref (die, DW_AT_containing_type,
lookup_type_die (DECL_CONTEXT (func_decl)));
}
}
/* Add a DW_AT_linkage_name or DW_AT_MIPS_linkage_name attribute for the
given decl. This used to be a vendor extension until after DWARF 4
standardized it. */
static void
add_linkage_attr (dw_die_ref die, tree decl)
{
const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
/* Mimic what assemble_name_raw does with a leading '*'. */
if (name[0] == '*')
name = &name[1];
if (dwarf_version >= 4)
add_AT_string (die, DW_AT_linkage_name, name);
else
add_AT_string (die, DW_AT_MIPS_linkage_name, name);
}
/* Add source coordinate attributes for the given decl. */
static void
add_src_coords_attributes (dw_die_ref die, tree decl)
{
expanded_location s;
if (LOCATION_LOCUS (DECL_SOURCE_LOCATION (decl)) == UNKNOWN_LOCATION)
return;
s = expand_location (DECL_SOURCE_LOCATION (decl));
add_AT_file (die, DW_AT_decl_file, lookup_filename (s.file));
add_AT_unsigned (die, DW_AT_decl_line, s.line);
if (debug_column_info && s.column)
add_AT_unsigned (die, DW_AT_decl_column, s.column);
}
/* Add DW_AT_{,MIPS_}linkage_name attribute for the given decl. */
static void
add_linkage_name_raw (dw_die_ref die, tree decl)
{
/* Defer until we have an assembler name set. */
if (!DECL_ASSEMBLER_NAME_SET_P (decl))
{
limbo_die_node *asm_name;
asm_name = ggc_cleared_alloc<limbo_die_node> ();
asm_name->die = die;
asm_name->created_for = decl;
asm_name->next = deferred_asm_name;
deferred_asm_name = asm_name;
}
else if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl))
add_linkage_attr (die, decl);
}
/* Add DW_AT_{,MIPS_}linkage_name attribute for the given decl if desired. */
static void
add_linkage_name (dw_die_ref die, tree decl)
{
if (debug_info_level > DINFO_LEVEL_NONE
&& VAR_OR_FUNCTION_DECL_P (decl)
&& TREE_PUBLIC (decl)
&& !(VAR_P (decl) && DECL_REGISTER (decl))
&& die->die_tag != DW_TAG_member)
add_linkage_name_raw (die, decl);
}
/* Add a DW_AT_name attribute and source coordinate attribute for the
given decl, but only if it actually has a name. */
static void
add_name_and_src_coords_attributes (dw_die_ref die, tree decl,
bool no_linkage_name)
{
tree decl_name;
decl_name = DECL_NAME (decl);
if (decl_name != NULL && IDENTIFIER_POINTER (decl_name) != NULL)
{
const char *name = dwarf2_name (decl, 0);
if (name)
add_name_attribute (die, name);
else
add_desc_attribute (die, decl);
if (! DECL_ARTIFICIAL (decl))
add_src_coords_attributes (die, decl);
if (!no_linkage_name)
add_linkage_name (die, decl);
}
else
add_desc_attribute (die, decl);
#ifdef VMS_DEBUGGING_INFO
/* Get the function's name, as described by its RTL. This may be different
from the DECL_NAME name used in the source file. */
if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl))
{
add_AT_addr (die, DW_AT_VMS_rtnbeg_pd_address,
XEXP (DECL_RTL (decl), 0), false);
vec_safe_push (used_rtx_array, XEXP (DECL_RTL (decl), 0));
}
#endif /* VMS_DEBUGGING_INFO */
}
/* Add VALUE as a DW_AT_discr_value attribute to DIE. */
static void
add_discr_value (dw_die_ref die, dw_discr_value *value)
{
dw_attr_node attr;
attr.dw_attr = DW_AT_discr_value;
attr.dw_attr_val.val_class = dw_val_class_discr_value;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_discr_value.pos = value->pos;
if (value->pos)
attr.dw_attr_val.v.val_discr_value.v.uval = value->v.uval;
else
attr.dw_attr_val.v.val_discr_value.v.sval = value->v.sval;
add_dwarf_attr (die, &attr);
}
/* Add DISCR_LIST as a DW_AT_discr_list to DIE. */
static void
add_discr_list (dw_die_ref die, dw_discr_list_ref discr_list)
{
dw_attr_node attr;
attr.dw_attr = DW_AT_discr_list;
attr.dw_attr_val.val_class = dw_val_class_discr_list;
attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_discr_list = discr_list;
add_dwarf_attr (die, &attr);
}
static inline dw_discr_list_ref
AT_discr_list (dw_attr_node *attr)
{
return attr->dw_attr_val.v.val_discr_list;
}
#ifdef VMS_DEBUGGING_INFO
/* Output the debug main pointer die for VMS */
void
dwarf2out_vms_debug_main_pointer (void)
{
char label[MAX_ARTIFICIAL_LABEL_BYTES];
dw_die_ref die;
/* Allocate the VMS debug main subprogram die. */
die = new_die_raw (DW_TAG_subprogram);
add_name_attribute (die, VMS_DEBUG_MAIN_POINTER);
ASM_GENERATE_INTERNAL_LABEL (label, PROLOGUE_END_LABEL,
current_function_funcdef_no);
add_AT_lbl_id (die, DW_AT_entry_pc, label);
/* Make it the first child of comp_unit_die (). */
die->die_parent = comp_unit_die ();
if (comp_unit_die ()->die_child)
{
die->die_sib = comp_unit_die ()->die_child->die_sib;
comp_unit_die ()->die_child->die_sib = die;
}
else
{
die->die_sib = die;
comp_unit_die ()->die_child = die;
}
}
#endif /* VMS_DEBUGGING_INFO */
/* walk_tree helper function for uses_local_type, below. */
static tree
uses_local_type_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
{
if (!TYPE_P (*tp))
*walk_subtrees = 0;
else
{
tree name = TYPE_NAME (*tp);
if (name && DECL_P (name) && decl_function_context (name))
return *tp;
}
return NULL_TREE;
}
/* If TYPE involves a function-local type (including a local typedef to a
non-local type), returns that type; otherwise returns NULL_TREE. */
static tree
uses_local_type (tree type)
{
tree used = walk_tree_without_duplicates (&type, uses_local_type_r, NULL);
return used;
}
/* Return the DIE for the scope that immediately contains this type.
Non-named types that do not involve a function-local type get global
scope. Named types nested in namespaces or other types get their
containing scope. All other types (i.e. function-local named types) get
the current active scope. */
static dw_die_ref
scope_die_for (tree t, dw_die_ref context_die)
{
dw_die_ref scope_die = NULL;
tree containing_scope;
/* Non-types always go in the current scope. */
gcc_assert (TYPE_P (t));
/* Use the scope of the typedef, rather than the scope of the type
it refers to. */
if (TYPE_NAME (t) && DECL_P (TYPE_NAME (t)))
containing_scope = DECL_CONTEXT (TYPE_NAME (t));
else
containing_scope = TYPE_CONTEXT (t);
/* Use the containing namespace if there is one. */
if (containing_scope && TREE_CODE (containing_scope) == NAMESPACE_DECL)
{
if (context_die == lookup_decl_die (containing_scope))
/* OK */;
else if (debug_info_level > DINFO_LEVEL_TERSE)
context_die = get_context_die (containing_scope);
else
containing_scope = NULL_TREE;
}
/* Ignore function type "scopes" from the C frontend. They mean that
a tagged type is local to a parmlist of a function declarator, but
that isn't useful to DWARF. */
if (containing_scope && TREE_CODE (containing_scope) == FUNCTION_TYPE)
containing_scope = NULL_TREE;
if (SCOPE_FILE_SCOPE_P (containing_scope))
{
/* If T uses a local type keep it local as well, to avoid references
to function-local DIEs from outside the function. */
if (current_function_decl && uses_local_type (t))
scope_die = context_die;
else
scope_die = comp_unit_die ();
}
else if (TYPE_P (containing_scope))
{
/* For types, we can just look up the appropriate DIE. */
if (debug_info_level > DINFO_LEVEL_TERSE)
scope_die = get_context_die (containing_scope);
else
{
scope_die = lookup_type_die_strip_naming_typedef (containing_scope);
if (scope_die == NULL)
scope_die = comp_unit_die ();
}
}
else
scope_die = context_die;
return scope_die;
}
/* Returns nonzero if CONTEXT_DIE is internal to a function. */
static inline int
local_scope_p (dw_die_ref context_die)
{
for (; context_die; context_die = context_die->die_parent)
if (context_die->die_tag == DW_TAG_inlined_subroutine
|| context_die->die_tag == DW_TAG_subprogram)
return 1;
return 0;
}
/* Returns nonzero if CONTEXT_DIE is a class. */
static inline int
class_scope_p (dw_die_ref context_die)
{
return (context_die
&& (context_die->die_tag == DW_TAG_structure_type
|| context_die->die_tag == DW_TAG_class_type
|| context_die->die_tag == DW_TAG_interface_type
|| context_die->die_tag == DW_TAG_union_type));
}
/* Returns nonzero if CONTEXT_DIE is a class or namespace, for deciding
whether or not to treat a DIE in this context as a declaration. */
static inline int
class_or_namespace_scope_p (dw_die_ref context_die)
{
return (class_scope_p (context_die)
|| (context_die && context_die->die_tag == DW_TAG_namespace));
}
/* Many forms of DIEs require a "type description" attribute. This
routine locates the proper "type descriptor" die for the type given
by 'type' plus any additional qualifiers given by 'cv_quals', and
adds a DW_AT_type attribute below the given die. */
static void
add_type_attribute (dw_die_ref object_die, tree type, int cv_quals,
bool reverse, dw_die_ref context_die)
{
enum tree_code code = TREE_CODE (type);
dw_die_ref type_die = NULL;
if (debug_info_level <= DINFO_LEVEL_TERSE)
return;
/* ??? If this type is an unnamed subrange type of an integral, floating-point
or fixed-point type, use the inner type. This is because we have no
support for unnamed types in base_type_die. This can happen if this is
an Ada subrange type. Correct solution is emit a subrange type die. */
if ((code == INTEGER_TYPE || code == REAL_TYPE || code == FIXED_POINT_TYPE)
&& TREE_TYPE (type) != 0 && TYPE_NAME (type) == 0)
type = TREE_TYPE (type), code = TREE_CODE (type);
if (code == ERROR_MARK
/* Handle a special case. For functions whose return type is void, we
generate *no* type attribute. (Note that no object may have type
`void', so this only applies to function return types). */
|| code == VOID_TYPE)
return;
type_die = modified_type_die (type,
cv_quals | TYPE_QUALS (type),
reverse,
context_die);
if (type_die != NULL)
add_AT_die_ref (object_die, DW_AT_type, type_die);
}
/* Given an object die, add the calling convention attribute for the
function call type. */
static void
add_calling_convention_attribute (dw_die_ref subr_die, tree decl)
{
enum dwarf_calling_convention value = DW_CC_normal;
value = ((enum dwarf_calling_convention)
targetm.dwarf_calling_convention (TREE_TYPE (decl)));
if (is_fortran ()
&& id_equal (DECL_ASSEMBLER_NAME (decl), "MAIN__"))
{
/* DWARF 2 doesn't provide a way to identify a program's source-level
entry point. DW_AT_calling_convention attributes are only meant
to describe functions' calling conventions. However, lacking a
better way to signal the Fortran main program, we used this for
a long time, following existing custom. Now, DWARF 4 has
DW_AT_main_subprogram, which we add below, but some tools still
rely on the old way, which we thus keep. */
value = DW_CC_program;
if (dwarf_version >= 4 || !dwarf_strict)
add_AT_flag (subr_die, DW_AT_main_subprogram, 1);
}
/* Only add the attribute if the backend requests it, and
is not DW_CC_normal. */
if (value && (value != DW_CC_normal))
add_AT_unsigned (subr_die, DW_AT_calling_convention, value);
}
/* Given a tree pointer to a struct, class, union, or enum type node, return
a pointer to the (string) tag name for the given type, or zero if the type
was declared without a tag. */
static const char *
type_tag (const_tree type)
{
const char *name = 0;
if (TYPE_NAME (type) != 0)
{
tree t = 0;
/* Find the IDENTIFIER_NODE for the type name. */
if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
&& !TYPE_NAMELESS (type))
t = TYPE_NAME (type);
/* The g++ front end makes the TYPE_NAME of *each* tagged type point to
a TYPE_DECL node, regardless of whether or not a `typedef' was
involved. */
else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& ! DECL_IGNORED_P (TYPE_NAME (type)))
{
/* We want to be extra verbose. Don't call dwarf_name if
DECL_NAME isn't set. The default hook for decl_printable_name
doesn't like that, and in this context it's correct to return
0, instead of "<anonymous>" or the like. */
if (DECL_NAME (TYPE_NAME (type))
&& !DECL_NAMELESS (TYPE_NAME (type)))
name = lang_hooks.dwarf_name (TYPE_NAME (type), 2);
}
/* Now get the name as a string, or invent one. */
if (!name && t != 0)
name = IDENTIFIER_POINTER (t);
}
return (name == 0 || *name == '\0') ? 0 : name;
}
/* Return the type associated with a data member, make a special check
for bit field types. */
static inline tree
member_declared_type (const_tree member)
{
return (DECL_BIT_FIELD_TYPE (member)
? DECL_BIT_FIELD_TYPE (member) : TREE_TYPE (member));
}
/* Get the decl's label, as described by its RTL. This may be different
from the DECL_NAME name used in the source file. */
#if 0
static const char *
decl_start_label (tree decl)
{
rtx x;
const char *fnname;
x = DECL_RTL (decl);
gcc_assert (MEM_P (x));
x = XEXP (x, 0);
gcc_assert (GET_CODE (x) == SYMBOL_REF);
fnname = XSTR (x, 0);
return fnname;
}
#endif
/* For variable-length arrays that have been previously generated, but
may be incomplete due to missing subscript info, fill the subscript
info. Return TRUE if this is one of those cases. */
static bool
fill_variable_array_bounds (tree type)
{
if (TREE_ASM_WRITTEN (type)
&& TREE_CODE (type) == ARRAY_TYPE
&& variably_modified_type_p (type, NULL))
{
dw_die_ref array_die = lookup_type_die (type);
if (!array_die)
return false;
add_subscript_info (array_die, type, !is_ada ());
return true;
}
return false;
}
/* These routines generate the internal representation of the DIE's for
the compilation unit. Debugging information is collected by walking
the declaration trees passed in from dwarf2out_decl(). */
static void
gen_array_type_die (tree type, dw_die_ref context_die)
{
dw_die_ref array_die;
/* GNU compilers represent multidimensional array types as sequences of one
dimensional array types whose element types are themselves array types.
We sometimes squish that down to a single array_type DIE with multiple
subscripts in the Dwarf debugging info. The draft Dwarf specification
say that we are allowed to do this kind of compression in C, because
there is no difference between an array of arrays and a multidimensional
array. We don't do this for Ada to remain as close as possible to the
actual representation, which is especially important against the language
flexibilty wrt arrays of variable size. */
bool collapse_nested_arrays = !is_ada ();
if (fill_variable_array_bounds (type))
return;
dw_die_ref scope_die = scope_die_for (type, context_die);
tree element_type;
/* Emit DW_TAG_string_type for Fortran character types (with kind 1 only, as
DW_TAG_string_type doesn't have DW_AT_type attribute). */
if (TREE_CODE (type) == ARRAY_TYPE
&& TYPE_STRING_FLAG (type)
&& is_fortran ()
&& TYPE_MODE (TREE_TYPE (type)) == TYPE_MODE (char_type_node))
{
HOST_WIDE_INT size;
array_die = new_die (DW_TAG_string_type, scope_die, type);
add_name_attribute (array_die, type_tag (type));
equate_type_number_to_die (type, array_die);
size = int_size_in_bytes (type);
if (size >= 0)
add_AT_unsigned (array_die, DW_AT_byte_size, size);
/* ??? We can't annotate types late, but for LTO we may not
generate a location early either (gfortran.dg/save_6.f90). */
else if (! (early_dwarf && (flag_generate_lto || flag_generate_offload))
&& TYPE_DOMAIN (type) != NULL_TREE
&& TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != NULL_TREE)
{
tree szdecl = TYPE_MAX_VALUE (TYPE_DOMAIN (type));
tree rszdecl = szdecl;
size = int_size_in_bytes (TREE_TYPE (szdecl));
if (!DECL_P (szdecl))
{
if (TREE_CODE (szdecl) == INDIRECT_REF
&& DECL_P (TREE_OPERAND (szdecl, 0)))
{
rszdecl = TREE_OPERAND (szdecl, 0);
if (int_size_in_bytes (TREE_TYPE (rszdecl))
!= DWARF2_ADDR_SIZE)
size = 0;
}
else
size = 0;
}
if (size > 0)
{
dw_loc_list_ref loc
= loc_list_from_tree (rszdecl, szdecl == rszdecl ? 2 : 0,
NULL);
if (loc)
{
add_AT_location_description (array_die, DW_AT_string_length,
loc);
if (size != DWARF2_ADDR_SIZE)
add_AT_unsigned (array_die, dwarf_version >= 5
? DW_AT_string_length_byte_size
: DW_AT_byte_size, size);
}
}
}
return;
}
array_die = new_die (DW_TAG_array_type, scope_die, type);
add_name_attribute (array_die, type_tag (type));
equate_type_number_to_die (type, array_die);
if (TREE_CODE (type) == VECTOR_TYPE)
add_AT_flag (array_die, DW_AT_GNU_vector, 1);
/* For Fortran multidimensional arrays use DW_ORD_col_major ordering. */
if (is_fortran ()
&& TREE_CODE (type) == ARRAY_TYPE
&& TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE
&& !TYPE_STRING_FLAG (TREE_TYPE (type)))
add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_col_major);
#if 0
/* We default the array ordering. Debuggers will probably do the right
things even if DW_AT_ordering is not present. It's not even an issue
until we start to get into multidimensional arrays anyway. If a debugger
is ever caught doing the Wrong Thing for multi-dimensional arrays,
then we'll have to put the DW_AT_ordering attribute back in. (But if
and when we find out that we need to put these in, we will only do so
for multidimensional arrays. */
add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_row_major);
#endif
if (TREE_CODE (type) == VECTOR_TYPE)
{
/* For VECTOR_TYPEs we use an array die with appropriate bounds. */
dw_die_ref subrange_die = new_die (DW_TAG_subrange_type, array_die, NULL);
add_bound_info (subrange_die, DW_AT_lower_bound, size_zero_node, NULL);
add_bound_info (subrange_die, DW_AT_upper_bound,
size_int (TYPE_VECTOR_SUBPARTS (type) - 1), NULL);
}
else
add_subscript_info (array_die, type, collapse_nested_arrays);
/* Add representation of the type of the elements of this array type and
emit the corresponding DIE if we haven't done it already. */
element_type = TREE_TYPE (type);
if (collapse_nested_arrays)
while (TREE_CODE (element_type) == ARRAY_TYPE)
{
if (TYPE_STRING_FLAG (element_type) && is_fortran ())
break;
element_type = TREE_TYPE (element_type);
}
add_type_attribute (array_die, element_type, TYPE_UNQUALIFIED,
TREE_CODE (type) == ARRAY_TYPE
&& TYPE_REVERSE_STORAGE_ORDER (type),
context_die);
add_gnat_descriptive_type_attribute (array_die, type, context_die);
if (TYPE_ARTIFICIAL (type))
add_AT_flag (array_die, DW_AT_artificial, 1);
if (get_AT (array_die, DW_AT_name))
add_pubtype (type, array_die);
add_alignment_attribute (array_die, type);
}
/* This routine generates DIE for array with hidden descriptor, details
are filled into *info by a langhook. */
static void
gen_descr_array_type_die (tree type, struct array_descr_info *info,
dw_die_ref context_die)
{
const dw_die_ref scope_die = scope_die_for (type, context_die);
const dw_die_ref array_die = new_die (DW_TAG_array_type, scope_die, type);
struct loc_descr_context context = { type, info->base_decl, NULL,
false, false };
enum dwarf_tag subrange_tag = DW_TAG_subrange_type;
int dim;
add_name_attribute (array_die, type_tag (type));
equate_type_number_to_die (type, array_die);
if (info->ndimensions > 1)
switch (info->ordering)
{
case array_descr_ordering_row_major:
add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_row_major);
break;
case array_descr_ordering_column_major:
add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_col_major);
break;
default:
break;
}
if (dwarf_version >= 3 || !dwarf_strict)
{
if (info->data_location)
add_scalar_info (array_die, DW_AT_data_location, info->data_location,
dw_scalar_form_exprloc, &context);
if (info->associated)
add_scalar_info (array_die, DW_AT_associated, info->associated,
dw_scalar_form_constant
| dw_scalar_form_exprloc
| dw_scalar_form_reference, &context);
if (info->allocated)
add_scalar_info (array_die, DW_AT_allocated, info->allocated,
dw_scalar_form_constant
| dw_scalar_form_exprloc
| dw_scalar_form_reference, &context);
if (info->stride)
{
const enum dwarf_attribute attr
= (info->stride_in_bits) ? DW_AT_bit_stride : DW_AT_byte_stride;
const int forms
= (info->stride_in_bits)
? dw_scalar_form_constant
: (dw_scalar_form_constant
| dw_scalar_form_exprloc
| dw_scalar_form_reference);
add_scalar_info (array_die, attr, info->stride, forms, &context);
}
}
if (dwarf_version >= 5)
{
if (info->rank)
{
add_scalar_info (array_die, DW_AT_rank, info->rank,
dw_scalar_form_constant
| dw_scalar_form_exprloc, &context);
subrange_tag = DW_TAG_generic_subrange;
context.placeholder_arg = true;
}
}
add_gnat_descriptive_type_attribute (array_die, type, context_die);
for (dim = 0; dim < info->ndimensions; dim++)
{
dw_die_ref subrange_die = new_die (subrange_tag, array_die, NULL);
if (info->dimen[dim].bounds_type)
add_type_attribute (subrange_die,
info->dimen[dim].bounds_type, TYPE_UNQUALIFIED,
false, context_die);
if (info->dimen[dim].lower_bound)
add_bound_info (subrange_die, DW_AT_lower_bound,
info->dimen[dim].lower_bound, &context);
if (info->dimen[dim].upper_bound)
add_bound_info (subrange_die, DW_AT_upper_bound,
info->dimen[dim].upper_bound, &context);
if ((dwarf_version >= 3 || !dwarf_strict) && info->dimen[dim].stride)
add_scalar_info (subrange_die, DW_AT_byte_stride,
info->dimen[dim].stride,
dw_scalar_form_constant
| dw_scalar_form_exprloc
| dw_scalar_form_reference,
&context);
}
gen_type_die (info->element_type, context_die);
add_type_attribute (array_die, info->element_type, TYPE_UNQUALIFIED,
TREE_CODE (type) == ARRAY_TYPE
&& TYPE_REVERSE_STORAGE_ORDER (type),
context_die);
if (get_AT (array_die, DW_AT_name))
add_pubtype (type, array_die);
add_alignment_attribute (array_die, type);
}
#if 0
static void
gen_entry_point_die (tree decl, dw_die_ref context_die)
{
tree origin = decl_ultimate_origin (decl);
dw_die_ref decl_die = new_die (DW_TAG_entry_point, context_die, decl);
if (origin != NULL)
add_abstract_origin_attribute (decl_die, origin);
else
{
add_name_and_src_coords_attributes (decl_die, decl);
add_type_attribute (decl_die, TREE_TYPE (TREE_TYPE (decl)),
TYPE_UNQUALIFIED, false, context_die);
}
if (DECL_ABSTRACT_P (decl))
equate_decl_number_to_die (decl, decl_die);
else
add_AT_lbl_id (decl_die, DW_AT_low_pc, decl_start_label (decl));
}
#endif
/* Walk through the list of incomplete types again, trying once more to
emit full debugging info for them. */
static void
retry_incomplete_types (void)
{
set_early_dwarf s;
int i;
for (i = vec_safe_length (incomplete_types) - 1; i >= 0; i--)
if (should_emit_struct_debug ((*incomplete_types)[i], DINFO_USAGE_DIR_USE))
gen_type_die ((*incomplete_types)[i], comp_unit_die ());
vec_safe_truncate (incomplete_types, 0);
}
/* Determine what tag to use for a record type. */
static enum dwarf_tag
record_type_tag (tree type)
{
if (! lang_hooks.types.classify_record)
return DW_TAG_structure_type;
switch (lang_hooks.types.classify_record (type))
{
case RECORD_IS_STRUCT:
return DW_TAG_structure_type;
case RECORD_IS_CLASS:
return DW_TAG_class_type;
case RECORD_IS_INTERFACE:
if (dwarf_version >= 3 || !dwarf_strict)
return DW_TAG_interface_type;
return DW_TAG_structure_type;
default:
gcc_unreachable ();
}
}
/* Generate a DIE to represent an enumeration type. Note that these DIEs
include all of the information about the enumeration values also. Each
enumerated type name/value is listed as a child of the enumerated type
DIE. */
static dw_die_ref
gen_enumeration_type_die (tree type, dw_die_ref context_die)
{
dw_die_ref type_die = lookup_type_die (type);
dw_die_ref orig_type_die = type_die;
if (type_die == NULL)
{
type_die = new_die (DW_TAG_enumeration_type,
scope_die_for (type, context_die), type);
equate_type_number_to_die (type, type_die);
add_name_attribute (type_die, type_tag (type));
if ((dwarf_version >= 4 || !dwarf_strict)
&& ENUM_IS_SCOPED (type))
add_AT_flag (type_die, DW_AT_enum_class, 1);
if (ENUM_IS_OPAQUE (type) && TYPE_SIZE (type))
add_AT_flag (type_die, DW_AT_declaration, 1);
if (!dwarf_strict)
add_AT_unsigned (type_die, DW_AT_encoding,
TYPE_UNSIGNED (type)
? DW_ATE_unsigned
: DW_ATE_signed);
}
else if (! TYPE_SIZE (type) || ENUM_IS_OPAQUE (type))
return type_die;
else
remove_AT (type_die, DW_AT_declaration);
/* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
given enum type is incomplete, do not generate the DW_AT_byte_size
attribute or the DW_AT_element_list attribute. */
if (TYPE_SIZE (type))
{
tree link;
if (!ENUM_IS_OPAQUE (type))
TREE_ASM_WRITTEN (type) = 1;
if (!orig_type_die || !get_AT (type_die, DW_AT_byte_size))
add_byte_size_attribute (type_die, type);
if (!orig_type_die || !get_AT (type_die, DW_AT_alignment))
add_alignment_attribute (type_die, type);
if ((dwarf_version >= 3 || !dwarf_strict)
&& (!orig_type_die || !get_AT (type_die, DW_AT_type)))
{
tree underlying = lang_hooks.types.enum_underlying_base_type (type);
add_type_attribute (type_die, underlying, TYPE_UNQUALIFIED, false,
context_die);
}
if (TYPE_STUB_DECL (type) != NULL_TREE)
{
if (!orig_type_die || !get_AT (type_die, DW_AT_decl_file))
add_src_coords_attributes (type_die, TYPE_STUB_DECL (type));
if (!orig_type_die || !get_AT (type_die, DW_AT_accessibility))
add_accessibility_attribute (type_die, TYPE_STUB_DECL (type));
}
/* If the first reference to this type was as the return type of an
inline function, then it may not have a parent. Fix this now. */
if (type_die->die_parent == NULL)
add_child_die (scope_die_for (type, context_die), type_die);
for (link = TYPE_VALUES (type);
link != NULL; link = TREE_CHAIN (link))
{
dw_die_ref enum_die = new_die (DW_TAG_enumerator, type_die, link);
tree value = TREE_VALUE (link);
if (DECL_P (value))
equate_decl_number_to_die (value, enum_die);
gcc_assert (!ENUM_IS_OPAQUE (type));
add_name_attribute (enum_die,
IDENTIFIER_POINTER (TREE_PURPOSE (link)));
if (TREE_CODE (value) == CONST_DECL)
value = DECL_INITIAL (value);
if (simple_type_size_in_bits (TREE_TYPE (value))
<= HOST_BITS_PER_WIDE_INT || tree_fits_shwi_p (value))
{
/* For constant forms created by add_AT_unsigned DWARF
consumers (GDB, elfutils, etc.) always zero extend
the value. Only when the actual value is negative
do we need to use add_AT_int to generate a constant
form that can represent negative values. */
HOST_WIDE_INT val = TREE_INT_CST_LOW (value);
if (TYPE_UNSIGNED (TREE_TYPE (value)) || val >= 0)
add_AT_unsigned (enum_die, DW_AT_const_value,
(unsigned HOST_WIDE_INT) val);
else
add_AT_int (enum_die, DW_AT_const_value, val);
}
else
/* Enumeration constants may be wider than HOST_WIDE_INT. Handle
that here. TODO: This should be re-worked to use correct
signed/unsigned double tags for all cases. */
add_AT_wide (enum_die, DW_AT_const_value, wi::to_wide (value));
}
add_gnat_descriptive_type_attribute (type_die, type, context_die);
if (TYPE_ARTIFICIAL (type)
&& (!orig_type_die || !get_AT (type_die, DW_AT_artificial)))
add_AT_flag (type_die, DW_AT_artificial, 1);
}
else
add_AT_flag (type_die, DW_AT_declaration, 1);
add_pubtype (type, type_die);
return type_die;
}
/* Generate a DIE to represent either a real live formal parameter decl or to
represent just the type of some formal parameter position in some function
type.
Note that this routine is a bit unusual because its argument may be a
..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
represents an inlining of some PARM_DECL) or else some sort of a ..._TYPE
node. If it's the former then this function is being called to output a
DIE to represent a formal parameter object (or some inlining thereof). If
it's the latter, then this function is only being called to output a
DW_TAG_formal_parameter DIE to stand as a placeholder for some formal
argument type of some subprogram type.
If EMIT_NAME_P is true, name and source coordinate attributes
are emitted. */
static dw_die_ref
gen_formal_parameter_die (tree node, tree origin, bool emit_name_p,
dw_die_ref context_die)
{
tree node_or_origin = node ? node : origin;
tree ultimate_origin;
dw_die_ref parm_die = NULL;
if (DECL_P (node_or_origin))
{
parm_die = lookup_decl_die (node);
/* If the contexts differ, we may not be talking about the same
thing.
??? When in LTO the DIE parent is the "abstract" copy and the
context_die is the specification "copy". */
if (parm_die
&& parm_die->die_parent != context_die
&& (parm_die->die_parent->die_tag != DW_TAG_GNU_formal_parameter_pack
|| parm_die->die_parent->die_parent != context_die)
&& !in_lto_p)
{
gcc_assert (!DECL_ABSTRACT_P (node));
/* This can happen when creating a concrete instance, in
which case we need to create a new DIE that will get
annotated with DW_AT_abstract_origin. */
parm_die = NULL;
}
if (parm_die && parm_die->die_parent == NULL)
{
/* Check that parm_die already has the right attributes that
we would have added below. If any attributes are
missing, fall through to add them. */
if (! DECL_ABSTRACT_P (node_or_origin)
&& !get_AT (parm_die, DW_AT_location)
&& !get_AT (parm_die, DW_AT_const_value))
/* We are missing location info, and are about to add it. */
;
else
{
add_child_die (context_die, parm_die);
return parm_die;
}
}
}
/* If we have a previously generated DIE, use it, unless this is an
concrete instance (origin != NULL), in which case we need a new
DIE with a corresponding DW_AT_abstract_origin. */
bool reusing_die;
if (parm_die && origin == NULL)
reusing_die = true;
else
{
parm_die = new_die (DW_TAG_formal_parameter, context_die, node);
reusing_die = false;
}
switch (TREE_CODE_CLASS (TREE_CODE (node_or_origin)))
{
case tcc_declaration:
ultimate_origin = decl_ultimate_origin (node_or_origin);
if (node || ultimate_origin)
origin = ultimate_origin;
if (reusing_die)
goto add_location;
if (origin != NULL)
add_abstract_origin_attribute (parm_die, origin);
else if (emit_name_p)
add_name_and_src_coords_attributes (parm_die, node);
if (origin == NULL
|| (! DECL_ABSTRACT_P (node_or_origin)
&& variably_modified_type_p (TREE_TYPE (node_or_origin),
decl_function_context
(node_or_origin))))
{
tree type = TREE_TYPE (node_or_origin);
if (decl_by_reference_p (node_or_origin))
add_type_attribute (parm_die, TREE_TYPE (type),
TYPE_UNQUALIFIED,
false, context_die);
else
add_type_attribute (parm_die, type,
decl_quals (node_or_origin),
false, context_die);
}
if (origin == NULL && DECL_ARTIFICIAL (node))
add_AT_flag (parm_die, DW_AT_artificial, 1);
add_location:
if (node && node != origin)
equate_decl_number_to_die (node, parm_die);
if (! DECL_ABSTRACT_P (node_or_origin))
add_location_or_const_value_attribute (parm_die, node_or_origin,
node == NULL);
break;
case tcc_type:
/* We were called with some kind of a ..._TYPE node. */
add_type_attribute (parm_die, node_or_origin, TYPE_UNQUALIFIED, false,
context_die);
break;
default:
gcc_unreachable ();
}
return parm_die;
}
/* Generate and return a DW_TAG_GNU_formal_parameter_pack. Also generate
children DW_TAG_formal_parameter DIEs representing the arguments of the
parameter pack.
PARM_PACK must be a function parameter pack.
PACK_ARG is the first argument of the parameter pack. Its TREE_CHAIN
must point to the subsequent arguments of the function PACK_ARG belongs to.
SUBR_DIE is the DIE of the function PACK_ARG belongs to.
If NEXT_ARG is non NULL, *NEXT_ARG is set to the function argument
following the last one for which a DIE was generated. */
static dw_die_ref
gen_formal_parameter_pack_die (tree parm_pack,
tree pack_arg,
dw_die_ref subr_die,
tree *next_arg)
{
tree arg;
dw_die_ref parm_pack_die;
gcc_assert (parm_pack
&& lang_hooks.function_parameter_pack_p (parm_pack)
&& subr_die);
parm_pack_die = new_die (DW_TAG_GNU_formal_parameter_pack, subr_die, parm_pack);
add_src_coords_attributes (parm_pack_die, parm_pack);
for (arg = pack_arg; arg; arg = DECL_CHAIN (arg))
{
if (! lang_hooks.decls.function_parm_expanded_from_pack_p (arg,
parm_pack))
break;
gen_formal_parameter_die (arg, NULL,
false /* Don't emit name attribute. */,
parm_pack_die);
}
if (next_arg)
*next_arg = arg;
return parm_pack_die;
}
/* Generate a special type of DIE used as a stand-in for a trailing ellipsis
at the end of an (ANSI prototyped) formal parameters list. */
static void
gen_unspecified_parameters_die (tree decl_or_type, dw_die_ref context_die)
{
new_die (DW_TAG_unspecified_parameters, context_die, decl_or_type);
}
/* Generate a list of nameless DW_TAG_formal_parameter DIEs (and perhaps a
DW_TAG_unspecified_parameters DIE) to represent the types of the formal
parameters as specified in some function type specification (except for
those which appear as part of a function *definition*). */
static void
gen_formal_types_die (tree function_or_method_type, dw_die_ref context_die)
{
tree link;
tree formal_type = NULL;
tree first_parm_type;
tree arg;
if (TREE_CODE (function_or_method_type) == FUNCTION_DECL)
{
arg = DECL_ARGUMENTS (function_or_method_type);
function_or_method_type = TREE_TYPE (function_or_method_type);
}
else
arg = NULL_TREE;
first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
/* Make our first pass over the list of formal parameter types and output a
DW_TAG_formal_parameter DIE for each one. */
for (link = first_parm_type; link; )
{
dw_die_ref parm_die;
formal_type = TREE_VALUE (link);
if (formal_type == void_type_node)
break;
/* Output a (nameless) DIE to represent the formal parameter itself. */
parm_die = gen_formal_parameter_die (formal_type, NULL,
true /* Emit name attribute. */,
context_die);
if (TREE_CODE (function_or_method_type) == METHOD_TYPE
&& link == first_parm_type)
{
add_AT_flag (parm_die, DW_AT_artificial, 1);
if (dwarf_version >= 3 || !dwarf_strict)
add_AT_die_ref (context_die, DW_AT_object_pointer, parm_die);
}
else if (arg && DECL_ARTIFICIAL (arg))
add_AT_flag (parm_die, DW_AT_artificial, 1);
link = TREE_CHAIN (link);
if (arg)
arg = DECL_CHAIN (arg);
}
/* If this function type has an ellipsis, add a
DW_TAG_unspecified_parameters DIE to the end of the parameter list. */
if (formal_type != void_type_node)
gen_unspecified_parameters_die (function_or_method_type, context_die);
/* Make our second (and final) pass over the list of formal parameter types
and output DIEs to represent those types (as necessary). */
for (link = TYPE_ARG_TYPES (function_or_method_type);
link && TREE_VALUE (link);
link = TREE_CHAIN (link))
gen_type_die (TREE_VALUE (link), context_die);
}
/* We want to generate the DIE for TYPE so that we can generate the
die for MEMBER, which has been defined; we will need to refer back
to the member declaration nested within TYPE. If we're trying to
generate minimal debug info for TYPE, processing TYPE won't do the
trick; we need to attach the member declaration by hand. */
static void
gen_type_die_for_member (tree type, tree member, dw_die_ref context_die)
{
gen_type_die (type, context_die);
/* If we're trying to avoid duplicate debug info, we may not have
emitted the member decl for this function. Emit it now. */
if (TYPE_STUB_DECL (type)
&& TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type))
&& ! lookup_decl_die (member))
{
dw_die_ref type_die;
gcc_assert (!decl_ultimate_origin (member));
type_die = lookup_type_die_strip_naming_typedef (type);
if (TREE_CODE (member) == FUNCTION_DECL)
gen_subprogram_die (member, type_die);
else if (TREE_CODE (member) == FIELD_DECL)
{
/* Ignore the nameless fields that are used to skip bits but handle
C++ anonymous unions and structs. */
if (DECL_NAME (member) != NULL_TREE
|| TREE_CODE (TREE_TYPE (member)) == UNION_TYPE
|| TREE_CODE (TREE_TYPE (member)) == RECORD_TYPE)
{
struct vlr_context vlr_ctx = {
DECL_CONTEXT (member), /* struct_type */
NULL_TREE /* variant_part_offset */
};
gen_type_die (member_declared_type (member), type_die);
gen_field_die (member, &vlr_ctx, type_die);
}
}
else
gen_variable_die (member, NULL_TREE, type_die);
}
}
/* Forward declare these functions, because they are mutually recursive
with their set_block_* pairing functions. */
static void set_decl_origin_self (tree);
/* Given a pointer to some BLOCK node, if the BLOCK_ABSTRACT_ORIGIN for the
given BLOCK node is NULL, set the BLOCK_ABSTRACT_ORIGIN for the node so
that it points to the node itself, thus indicating that the node is its
own (abstract) origin. Additionally, if the BLOCK_ABSTRACT_ORIGIN for
the given node is NULL, recursively descend the decl/block tree which
it is the root of, and for each other ..._DECL or BLOCK node contained
therein whose DECL_ABSTRACT_ORIGINs or BLOCK_ABSTRACT_ORIGINs are also
still NULL, set *their* DECL_ABSTRACT_ORIGIN or BLOCK_ABSTRACT_ORIGIN
values to point to themselves. */
static void
set_block_origin_self (tree stmt)
{
if (BLOCK_ABSTRACT_ORIGIN (stmt) == NULL_TREE)
{
BLOCK_ABSTRACT_ORIGIN (stmt) = stmt;
{
tree local_decl;
for (local_decl = BLOCK_VARS (stmt);
local_decl != NULL_TREE;
local_decl = DECL_CHAIN (local_decl))
/* Do not recurse on nested functions since the inlining status
of parent and child can be different as per the DWARF spec. */
if (TREE_CODE (local_decl) != FUNCTION_DECL
&& !DECL_EXTERNAL (local_decl))
set_decl_origin_self (local_decl);
}
{
tree subblock;
for (subblock = BLOCK_SUBBLOCKS (stmt);
subblock != NULL_TREE;
subblock = BLOCK_CHAIN (subblock))
set_block_origin_self (subblock); /* Recurse. */
}
}
}
/* Given a pointer to some ..._DECL node, if the DECL_ABSTRACT_ORIGIN for
the given ..._DECL node is NULL, set the DECL_ABSTRACT_ORIGIN for the
node to so that it points to the node itself, thus indicating that the
node represents its own (abstract) origin. Additionally, if the
DECL_ABSTRACT_ORIGIN for the given node is NULL, recursively descend
the decl/block tree of which the given node is the root of, and for
each other ..._DECL or BLOCK node contained therein whose
DECL_ABSTRACT_ORIGINs or BLOCK_ABSTRACT_ORIGINs are also still NULL,
set *their* DECL_ABSTRACT_ORIGIN or BLOCK_ABSTRACT_ORIGIN values to
point to themselves. */
static void
set_decl_origin_self (tree decl)
{
if (DECL_ABSTRACT_ORIGIN (decl) == NULL_TREE)
{
DECL_ABSTRACT_ORIGIN (decl) = decl;
if (TREE_CODE (decl) == FUNCTION_DECL)
{
tree arg;
for (arg = DECL_ARGUMENTS (decl); arg; arg = DECL_CHAIN (arg))
DECL_ABSTRACT_ORIGIN (arg) = arg;
if (DECL_INITIAL (decl) != NULL_TREE
&& DECL_INITIAL (decl) != error_mark_node)
set_block_origin_self (DECL_INITIAL (decl));
}
}
}
/* Mark the early DIE for DECL as the abstract instance. */
static void
dwarf2out_abstract_function (tree decl)
{
dw_die_ref old_die;
/* Make sure we have the actual abstract inline, not a clone. */
decl = DECL_ORIGIN (decl);
if (DECL_IGNORED_P (decl))
return;
/* In LTO we're all set. We already created abstract instances
early and we want to avoid creating a concrete instance of that
if we don't output it. */
if (in_lto_p)
return;
old_die = lookup_decl_die (decl);
gcc_assert (old_die != NULL);
if (get_AT (old_die, DW_AT_inline))
/* We've already generated the abstract instance. */
return;
/* Go ahead and put DW_AT_inline on the DIE. */
if (DECL_DECLARED_INLINE_P (decl))
{
if (cgraph_function_possibly_inlined_p (decl))
add_AT_unsigned (old_die, DW_AT_inline, DW_INL_declared_inlined);
else
add_AT_unsigned (old_die, DW_AT_inline, DW_INL_declared_not_inlined);
}
else
{
if (cgraph_function_possibly_inlined_p (decl))
add_AT_unsigned (old_die, DW_AT_inline, DW_INL_inlined);
else
add_AT_unsigned (old_die, DW_AT_inline, DW_INL_not_inlined);
}
if (DECL_DECLARED_INLINE_P (decl)
&& lookup_attribute ("artificial", DECL_ATTRIBUTES (decl)))
add_AT_flag (old_die, DW_AT_artificial, 1);
set_decl_origin_self (decl);
}
/* Helper function of premark_used_types() which gets called through
htab_traverse.
Marks the DIE of a given type in *SLOT as perennial, so it never gets
marked as unused by prune_unused_types. */
bool
premark_used_types_helper (tree const &type, void *)
{
dw_die_ref die;
die = lookup_type_die (type);
if (die != NULL)
die->die_perennial_p = 1;
return true;
}
/* Helper function of premark_types_used_by_global_vars which gets called
through htab_traverse.
Marks the DIE of a given type in *SLOT as perennial, so it never gets
marked as unused by prune_unused_types. The DIE of the type is marked
only if the global variable using the type will actually be emitted. */
int
premark_types_used_by_global_vars_helper (types_used_by_vars_entry **slot,
void *)
{
struct types_used_by_vars_entry *entry;
dw_die_ref die;
entry = (struct types_used_by_vars_entry *) *slot;
gcc_assert (entry->type != NULL
&& entry->var_decl != NULL);
die = lookup_type_die (entry->type);
if (die)
{
/* Ask cgraph if the global variable really is to be emitted.
If yes, then we'll keep the DIE of ENTRY->TYPE. */
varpool_node *node = varpool_node::get (entry->var_decl);
if (node && node->definition)
{
die->die_perennial_p = 1;
/* Keep the parent DIEs as well. */
while ((die = die->die_parent) && die->die_perennial_p == 0)
die->die_perennial_p = 1;
}
}
return 1;
}
/* Mark all members of used_types_hash as perennial. */
static void
premark_used_types (struct function *fun)
{
if (fun && fun->used_types_hash)
fun->used_types_hash->traverse<void *, premark_used_types_helper> (NULL);
}
/* Mark all members of types_used_by_vars_entry as perennial. */
static void
premark_types_used_by_global_vars (void)
{
if (types_used_by_vars_hash)
types_used_by_vars_hash
->traverse<void *, premark_types_used_by_global_vars_helper> (NULL);
}
/* Mark all variables used by the symtab as perennial. */
static void
premark_used_variables (void)
{
/* Mark DIEs in the symtab as used. */
varpool_node *var;
FOR_EACH_VARIABLE (var)
{
dw_die_ref die = lookup_decl_die (var->decl);
if (die)
die->die_perennial_p = 1;
}
}
/* Generate a DW_TAG_call_site DIE in function DECL under SUBR_DIE
for CA_LOC call arg loc node. */
static dw_die_ref
gen_call_site_die (tree decl, dw_die_ref subr_die,
struct call_arg_loc_node *ca_loc)
{
dw_die_ref stmt_die = NULL, die;
tree block = ca_loc->block;
while (block
&& block != DECL_INITIAL (decl)
&& TREE_CODE (block) == BLOCK)
{
stmt_die = lookup_block_die (block);
if (stmt_die)
break;
block = BLOCK_SUPERCONTEXT (block);
}
if (stmt_die == NULL)
stmt_die = subr_die;
die = new_die (dwarf_TAG (DW_TAG_call_site), stmt_die, NULL_TREE);
add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc), ca_loc->label);
if (ca_loc->tail_call_p)
add_AT_flag (die, dwarf_AT (DW_AT_call_tail_call), 1);
if (ca_loc->symbol_ref)
{
dw_die_ref tdie = lookup_decl_die (SYMBOL_REF_DECL (ca_loc->symbol_ref));
if (tdie)
add_AT_die_ref (die, dwarf_AT (DW_AT_call_origin), tdie);
else
add_AT_addr (die, dwarf_AT (DW_AT_call_origin), ca_loc->symbol_ref,
false);
}
return die;
}
/* Generate a DIE to represent a declared function (either file-scope or
block-local). */
static void
gen_subprogram_die (tree decl, dw_die_ref context_die)
{
tree origin = decl_ultimate_origin (decl);
dw_die_ref subr_die;
dw_die_ref old_die = lookup_decl_die (decl);
bool old_die_had_no_children = false;
/* This function gets called multiple times for different stages of
the debug process. For example, for func() in this code:
namespace S
{
void func() { ... }
}
...we get called 4 times. Twice in early debug and twice in
late debug:
Early debug
-----------
1. Once while generating func() within the namespace. This is
the declaration. The declaration bit below is set, as the
context is the namespace.
A new DIE will be generated with DW_AT_declaration set.
2. Once for func() itself. This is the specification. The
declaration bit below is clear as the context is the CU.
We will use the cached DIE from (1) to create a new DIE with
DW_AT_specification pointing to the declaration in (1).
Late debug via rest_of_handle_final()
-------------------------------------
3. Once generating func() within the namespace. This is also the
declaration, as in (1), but this time we will early exit below
as we have a cached DIE and a declaration needs no additional
annotations (no locations), as the source declaration line
info is enough.
4. Once for func() itself. As in (2), this is the specification,
but this time we will re-use the cached DIE, and just annotate
it with the location information that should now be available.
For something without namespaces, but with abstract instances, we
are also called a multiple times:
class Base
{
public:
Base (); // constructor declaration (1)
};
Base::Base () { } // constructor specification (2)
Early debug
-----------
1. Once for the Base() constructor by virtue of it being a
member of the Base class. This is done via
rest_of_type_compilation.
This is a declaration, so a new DIE will be created with
DW_AT_declaration.
2. Once for the Base() constructor definition, but this time
while generating the abstract instance of the base
constructor (__base_ctor) which is being generated via early
debug of reachable functions.
Even though we have a cached version of the declaration (1),
we will create a DW_AT_specification of the declaration DIE
in (1).
3. Once for the __base_ctor itself, but this time, we generate
an DW_AT_abstract_origin version of the DW_AT_specification in
(2).
Late debug via rest_of_handle_final
-----------------------------------
4. One final time for the __base_ctor (which will have a cached
DIE with DW_AT_abstract_origin created in (3). This time,
we will just annotate the location information now
available.
*/
int declaration = (current_function_decl != decl
|| (!DECL_INITIAL (decl) && !origin)
|| class_or_namespace_scope_p (context_die));
/* A declaration that has been previously dumped needs no
additional information. */
if (old_die && declaration)
return;
if (in_lto_p && old_die && old_die->die_child == NULL)
old_die_had_no_children = true;
/* Now that the C++ front end lazily declares artificial member fns, we
might need to retrofit the declaration into its class. */
if (!declaration && !origin && !old_die
&& DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl))
&& !class_or_namespace_scope_p (context_die)
&& debug_info_level > DINFO_LEVEL_TERSE)
old_die = force_decl_die (decl);
/* A concrete instance, tag a new DIE with DW_AT_abstract_origin. */
if (origin != NULL)
{
gcc_assert (!declaration || local_scope_p (context_die));
/* Fixup die_parent for the abstract instance of a nested
inline function. */
if (old_die && old_die->die_parent == NULL)
add_child_die (context_die, old_die);
if (old_die && get_AT_ref (old_die, DW_AT_abstract_origin))
{
/* If we have a DW_AT_abstract_origin we have a working
cached version. */
subr_die = old_die;
}
else
{
subr_die = new_die (DW_TAG_subprogram, context_die, decl);
add_abstract_origin_attribute (subr_die, origin);
/* This is where the actual code for a cloned function is.
Let's emit linkage name attribute for it. This helps
debuggers to e.g, set breakpoints into
constructors/destructors when the user asks "break
K::K". */
add_linkage_name (subr_die, decl);
}
}
/* A cached copy, possibly from early dwarf generation. Reuse as
much as possible. */
else if (old_die)
{
if (!get_AT_flag (old_die, DW_AT_declaration)
/* We can have a normal definition following an inline one in the
case of redefinition of GNU C extern inlines.
It seems reasonable to use AT_specification in this case. */
&& !get_AT (old_die, DW_AT_inline))
{
/* Detect and ignore this case, where we are trying to output
something we have already output. */
if (get_AT (old_die, DW_AT_low_pc)
|| get_AT (old_die, DW_AT_ranges))
return;
/* If we have no location information, this must be a
partially generated DIE from early dwarf generation.
Fall through and generate it. */
}
/* If the definition comes from the same place as the declaration,
maybe use the old DIE. We always want the DIE for this function
that has the *_pc attributes to be under comp_unit_die so the
debugger can find it. We also need to do this for abstract
instances of inlines, since the spec requires the out-of-line copy
to have the same parent. For local class methods, this doesn't
apply; we just use the old DIE. */
expanded_location s = expand_location (DECL_SOURCE_LOCATION (decl));
struct dwarf_file_data * file_index = lookup_filename (s.file);
if (((is_unit_die (old_die->die_parent)
/* This condition fixes the inconsistency/ICE with the
following Fortran test (or some derivative thereof) while
building libgfortran:
module some_m
contains
logical function funky (FLAG)
funky = .true.
end function
end module
*/
|| (old_die->die_parent
&& old_die->die_parent->die_tag == DW_TAG_module)
|| local_scope_p (old_die->die_parent)
|| context_die == NULL)
&& (DECL_ARTIFICIAL (decl)
|| (get_AT_file (old_die, DW_AT_decl_file) == file_index
&& (get_AT_unsigned (old_die, DW_AT_decl_line)
== (unsigned) s.line)
&& (!debug_column_info
|| s.column == 0
|| (get_AT_unsigned (old_die, DW_AT_decl_column)
== (unsigned) s.column)))))
/* With LTO if there's an abstract instance for
the old DIE, this is a concrete instance and
thus re-use the DIE. */
|| get_AT (old_die, DW_AT_abstract_origin))
{
subr_die = old_die;
/* Clear out the declaration attribute, but leave the
parameters so they can be augmented with location
information later. Unless this was a declaration, in
which case, wipe out the nameless parameters and recreate
them further down. */
if (remove_AT (subr_die, DW_AT_declaration))
{
remove_AT (subr_die, DW_AT_object_pointer);
remove_child_TAG (subr_die, DW_TAG_formal_parameter);
}
}
/* Make a specification pointing to the previously built
declaration. */
else
{
subr_die = new_die (DW_TAG_subprogram, context_die, decl);
add_AT_specification (subr_die, old_die);
add_pubname (decl, subr_die);
if (get_AT_file (old_die, DW_AT_decl_file) != file_index)
add_AT_file (subr_die, DW_AT_decl_file, file_index);
if (get_AT_unsigned (old_die, DW_AT_decl_line) != (unsigned) s.line)
add_AT_unsigned (subr_die, DW_AT_decl_line, s.line);
if (debug_column_info
&& s.column
&& (get_AT_unsigned (old_die, DW_AT_decl_column)
!= (unsigned) s.column))
add_AT_unsigned (subr_die, DW_AT_decl_column, s.column);
/* If the prototype had an 'auto' or 'decltype(auto)' in
the return type, emit the real type on the definition die. */
if (is_cxx () && debug_info_level > DINFO_LEVEL_TERSE)
{
dw_die_ref die = get_AT_ref (old_die, DW_AT_type);
while (die
&& (die->die_tag == DW_TAG_reference_type
|| die->die_tag == DW_TAG_rvalue_reference_type
|| die->die_tag == DW_TAG_pointer_type
|| die->die_tag == DW_TAG_const_type
|| die->die_tag == DW_TAG_volatile_type
|| die->die_tag == DW_TAG_restrict_type
|| die->die_tag == DW_TAG_array_type
|| die->die_tag == DW_TAG_ptr_to_member_type
|| die->die_tag == DW_TAG_subroutine_type))
die = get_AT_ref (die, DW_AT_type);
if (die == auto_die || die == decltype_auto_die)
add_type_attribute (subr_die, TREE_TYPE (TREE_TYPE (decl)),
TYPE_UNQUALIFIED, false, context_die);
}
/* When we process the method declaration, we haven't seen
the out-of-class defaulted definition yet, so we have to
recheck now. */
if ((dwarf_version >= 5 || ! dwarf_strict)
&& !get_AT (subr_die, DW_AT_defaulted))
{
int defaulted
= lang_hooks.decls.decl_dwarf_attribute (decl,
DW_AT_defaulted);
if (defaulted != -1)
{
/* Other values must have been handled before. */
gcc_assert (defaulted == DW_DEFAULTED_out_of_class);
add_AT_unsigned (subr_die, DW_AT_defaulted, defaulted);
}
}
}
}
/* Create a fresh DIE for anything else. */
else
{
subr_die = new_die (DW_TAG_subprogram, context_die, decl);
if (TREE_PUBLIC (decl))
add_AT_flag (subr_die, DW_AT_external, 1);
add_name_and_src_coords_attributes (subr_die, decl);
add_pubname (decl, subr_die);
if (debug_info_level > DINFO_LEVEL_TERSE)
{
add_prototyped_attribute (subr_die, TREE_TYPE (decl));
add_type_attribute (subr_die, TREE_TYPE (TREE_TYPE (decl)),
TYPE_UNQUALIFIED, false, context_die);
}
add_pure_or_virtual_attribute (subr_die, decl);
if (DECL_ARTIFICIAL (decl))
add_AT_flag (subr_die, DW_AT_artificial, 1);
if (TREE_THIS_VOLATILE (decl) && (dwarf_version >= 5 || !dwarf_strict))
add_AT_flag (subr_die, DW_AT_noreturn, 1);
add_alignment_attribute (subr_die, decl);
add_accessibility_attribute (subr_die, decl);
}
/* Unless we have an existing non-declaration DIE, equate the new
DIE. */
if (!old_die || is_declaration_die (old_die))
equate_decl_number_to_die (decl, subr_die);
if (declaration)
{
if (!old_die || !get_AT (old_die, DW_AT_inline))
{
add_AT_flag (subr_die, DW_AT_declaration, 1);
/* If this is an explicit function declaration then generate
a DW_AT_explicit attribute. */
if ((dwarf_version >= 3 || !dwarf_strict)
&& lang_hooks.decls.decl_dwarf_attribute (decl,
DW_AT_explicit) == 1)
add_AT_flag (subr_die, DW_AT_explicit, 1);
/* If this is a C++11 deleted special function member then generate
a DW_AT_deleted attribute. */
if ((dwarf_version >= 5 || !dwarf_strict)
&& lang_hooks.decls.decl_dwarf_attribute (decl,
DW_AT_deleted) == 1)
add_AT_flag (subr_die, DW_AT_deleted, 1);
/* If this is a C++11 defaulted special function member then
generate a DW_AT_defaulted attribute. */
if (dwarf_version >= 5 || !dwarf_strict)
{
int defaulted
= lang_hooks.decls.decl_dwarf_attribute (decl,
DW_AT_defaulted);
if (defaulted != -1)
add_AT_unsigned (subr_die, DW_AT_defaulted, defaulted);
}
/* If this is a C++11 non-static member function with & ref-qualifier
then generate a DW_AT_reference attribute. */
if ((dwarf_version >= 5 || !dwarf_strict)
&& lang_hooks.decls.decl_dwarf_attribute (decl,
DW_AT_reference) == 1)
add_AT_flag (subr_die, DW_AT_reference, 1);
/* If this is a C++11 non-static member function with &&
ref-qualifier then generate a DW_AT_reference attribute. */
if ((dwarf_version >= 5 || !dwarf_strict)
&& lang_hooks.decls.decl_dwarf_attribute (decl,
DW_AT_rvalue_reference)
== 1)
add_AT_flag (subr_die, DW_AT_rvalue_reference, 1);
}
}
/* For non DECL_EXTERNALs, if range information is available, fill
the DIE with it. */
else if (!DECL_EXTERNAL (decl) && !early_dwarf)
{
HOST_WIDE_INT cfa_fb_offset;
struct function *fun = DECL_STRUCT_FUNCTION (decl);
if (!crtl->has_bb_partition)
{
dw_fde_ref fde = fun->fde;
if (fde->dw_fde_begin)
{
/* We have already generated the labels. */
add_AT_low_high_pc (subr_die, fde->dw_fde_begin,
fde->dw_fde_end, false);
}
else
{
/* Create start/end labels and add the range. */
char label_id_low[MAX_ARTIFICIAL_LABEL_BYTES];
char label_id_high[MAX_ARTIFICIAL_LABEL_BYTES];
ASM_GENERATE_INTERNAL_LABEL (label_id_low, FUNC_BEGIN_LABEL,
current_function_funcdef_no);
ASM_GENERATE_INTERNAL_LABEL (label_id_high, FUNC_END_LABEL,
current_function_funcdef_no);
add_AT_low_high_pc (subr_die, label_id_low, label_id_high,
false);
}
#if VMS_DEBUGGING_INFO
/* HP OpenVMS Industry Standard 64: DWARF Extensions
Section 2.3 Prologue and Epilogue Attributes:
When a breakpoint is set on entry to a function, it is generally
desirable for execution to be suspended, not on the very first
instruction of the function, but rather at a point after the
function's frame has been set up, after any language defined local
declaration processing has been completed, and before execution of
the first statement of the function begins. Debuggers generally
cannot properly determine where this point is. Similarly for a
breakpoint set on exit from a function. The prologue and epilogue
attributes allow a compiler to communicate the location(s) to use. */
{
if (fde->dw_fde_vms_end_prologue)
add_AT_vms_delta (subr_die, DW_AT_HP_prologue,
fde->dw_fde_begin, fde->dw_fde_vms_end_prologue);
if (fde->dw_fde_vms_begin_epilogue)
add_AT_vms_delta (subr_die, DW_AT_HP_epilogue,
fde->dw_fde_begin, fde->dw_fde_vms_begin_epilogue);
}
#endif
}
else
{
/* Generate pubnames entries for the split function code ranges. */
dw_fde_ref fde = fun->fde;
if (fde->dw_fde_second_begin)
{
if (dwarf_version >= 3 || !dwarf_strict)
{
/* We should use ranges for non-contiguous code section
addresses. Use the actual code range for the initial
section, since the HOT/COLD labels might precede an
alignment offset. */
bool range_list_added = false;
add_ranges_by_labels (subr_die, fde->dw_fde_begin,
fde->dw_fde_end, &range_list_added,
false);
add_ranges_by_labels (subr_die, fde->dw_fde_second_begin,
fde->dw_fde_second_end,
&range_list_added, false);
if (range_list_added)
add_ranges (NULL);
}
else
{
/* There is no real support in DW2 for this .. so we make
a work-around. First, emit the pub name for the segment
containing the function label. Then make and emit a
simplified subprogram DIE for the second segment with the
name pre-fixed by __hot/cold_sect_of_. We use the same
linkage name for the second die so that gdb will find both
sections when given "b foo". */
const char *name = NULL;
tree decl_name = DECL_NAME (decl);
dw_die_ref seg_die;
/* Do the 'primary' section. */
add_AT_low_high_pc (subr_die, fde->dw_fde_begin,
fde->dw_fde_end, false);
/* Build a minimal DIE for the secondary section. */
seg_die = new_die (DW_TAG_subprogram,
subr_die->die_parent, decl);
if (TREE_PUBLIC (decl))
add_AT_flag (seg_die, DW_AT_external, 1);
if (decl_name != NULL
&& IDENTIFIER_POINTER (decl_name) != NULL)
{
name = dwarf2_name (decl, 1);
if (! DECL_ARTIFICIAL (decl))
add_src_coords_attributes (seg_die, decl);
add_linkage_name (seg_die, decl);
}
gcc_assert (name != NULL);
add_pure_or_virtual_attribute (seg_die, decl);
if (DECL_ARTIFICIAL (decl))
add_AT_flag (seg_die, DW_AT_artificial, 1);
name = concat ("__second_sect_of_", name, NULL);
add_AT_low_high_pc (seg_die, fde->dw_fde_second_begin,
fde->dw_fde_second_end, false);
add_name_attribute (seg_die, name);
if (want_pubnames ())
add_pubname_string (name, seg_die);
}
}
else
add_AT_low_high_pc (subr_die, fde->dw_fde_begin, fde->dw_fde_end,
false);
}
cfa_fb_offset = CFA_FRAME_BASE_OFFSET (decl);
/* We define the "frame base" as the function's CFA. This is more
convenient for several reasons: (1) It's stable across the prologue
and epilogue, which makes it better than just a frame pointer,
(2) With dwarf3, there exists a one-byte encoding that allows us
to reference the .debug_frame data by proxy, but failing that,
(3) We can at least reuse the code inspection and interpretation
code that determines the CFA position at various points in the
function. */
if (dwarf_version >= 3 && targetm.debug_unwind_info () == UI_DWARF2)
{
dw_loc_descr_ref op = new_loc_descr (DW_OP_call_frame_cfa, 0, 0);
add_AT_loc (subr_die, DW_AT_frame_base, op);
}
else
{
dw_loc_list_ref list = convert_cfa_to_fb_loc_list (cfa_fb_offset);
if (list->dw_loc_next)
add_AT_loc_list (subr_die, DW_AT_frame_base, list);
else
add_AT_loc (subr_die, DW_AT_frame_base, list->expr);
}
/* Compute a displacement from the "steady-state frame pointer" to
the CFA. The former is what all stack slots and argument slots
will reference in the rtl; the latter is what we've told the
debugger about. We'll need to adjust all frame_base references
by this displacement. */
compute_frame_pointer_to_fb_displacement (cfa_fb_offset);
if (fun->static_chain_decl)
{
/* DWARF requires here a location expression that computes the
address of the enclosing subprogram's frame base. The machinery
in tree-nested.c is supposed to store this specific address in the
last field of the FRAME record. */
const tree frame_type
= TREE_TYPE (TREE_TYPE (fun->static_chain_decl));
const tree fb_decl = tree_last (TYPE_FIELDS (frame_type));
tree fb_expr
= build1 (INDIRECT_REF, frame_type, fun->static_chain_decl);
fb_expr = build3 (COMPONENT_REF, TREE_TYPE (fb_decl),
fb_expr, fb_decl, NULL_TREE);
add_AT_location_description (subr_die, DW_AT_static_link,
loc_list_from_tree (fb_expr, 0, NULL));
}
resolve_variable_values ();
}
/* Generate child dies for template paramaters. */
if (early_dwarf && debug_info_level > DINFO_LEVEL_TERSE)
gen_generic_params_dies (decl);
/* Now output descriptions of the arguments for this function. This gets
(unnecessarily?) complex because of the fact that the DECL_ARGUMENT list
for a FUNCTION_DECL doesn't indicate cases where there was a trailing
`...' at the end of the formal parameter list. In order to find out if
there was a trailing ellipsis or not, we must instead look at the type
associated with the FUNCTION_DECL. This will be a node of type
FUNCTION_TYPE. If the chain of type nodes hanging off of this
FUNCTION_TYPE node ends with a void_type_node then there should *not* be
an ellipsis at the end. */
/* In the case where we are describing a mere function declaration, all we
need to do here (and all we *can* do here) is to describe the *types* of
its formal parameters. */
if (debug_info_level <= DINFO_LEVEL_TERSE)
;
else if (declaration)
gen_formal_types_die (decl, subr_die);
else
{
/* Generate DIEs to represent all known formal parameters. */
tree parm = DECL_ARGUMENTS (decl);
tree generic_decl = early_dwarf
? lang_hooks.decls.get_generic_function_decl (decl) : NULL;
tree generic_decl_parm = generic_decl
? DECL_ARGUMENTS (generic_decl)
: NULL;
/* Now we want to walk the list of parameters of the function and
emit their relevant DIEs.
We consider the case of DECL being an instance of a generic function
as well as it being a normal function.
If DECL is an instance of a generic function we walk the
parameters of the generic function declaration _and_ the parameters of
DECL itself. This is useful because we want to emit specific DIEs for
function parameter packs and those are declared as part of the
generic function declaration. In that particular case,
the parameter pack yields a DW_TAG_GNU_formal_parameter_pack DIE.
That DIE has children DIEs representing the set of arguments
of the pack. Note that the set of pack arguments can be empty.
In that case, the DW_TAG_GNU_formal_parameter_pack DIE will not have any
children DIE.
Otherwise, we just consider the parameters of DECL. */
while (generic_decl_parm || parm)
{
if (generic_decl_parm
&& lang_hooks.function_parameter_pack_p (generic_decl_parm))
gen_formal_parameter_pack_die (generic_decl_parm,
parm, subr_die,
&parm);
else if (parm)
{
dw_die_ref parm_die = gen_decl_die (parm, NULL, NULL, subr_die);
if (early_dwarf
&& parm == DECL_ARGUMENTS (decl)
&& TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE
&& parm_die
&& (dwarf_version >= 3 || !dwarf_strict))
add_AT_die_ref (subr_die, DW_AT_object_pointer, parm_die);
parm = DECL_CHAIN (parm);
}
if (generic_decl_parm)
generic_decl_parm = DECL_CHAIN (generic_decl_parm);
}
/* Decide whether we need an unspecified_parameters DIE at the end.
There are 2 more cases to do this for: 1) the ansi ... declaration -
this is detectable when the end of the arg list is not a
void_type_node 2) an unprototyped function declaration (not a
definition). This just means that we have no info about the
parameters at all. */
if (early_dwarf)
{
if (prototype_p (TREE_TYPE (decl)))
{
/* This is the prototyped case, check for.... */
if (stdarg_p (TREE_TYPE (decl)))
gen_unspecified_parameters_die (decl, subr_die);
}
else if (DECL_INITIAL (decl) == NULL_TREE)
gen_unspecified_parameters_die (decl, subr_die);
}
else if ((subr_die != old_die || old_die_had_no_children)
&& prototype_p (TREE_TYPE (decl))
&& stdarg_p (TREE_TYPE (decl)))
gen_unspecified_parameters_die (decl, subr_die);
}
if (subr_die != old_die)
/* Add the calling convention attribute if requested. */
add_calling_convention_attribute (subr_die, decl);
/* Output Dwarf info for all of the stuff within the body of the function
(if it has one - it may be just a declaration).
OUTER_SCOPE is a pointer to the outermost BLOCK node created to represent
a function. This BLOCK actually represents the outermost binding contour
for the function, i.e. the contour in which the function's formal
parameters and labels get declared. Curiously, it appears that the front
end doesn't actually put the PARM_DECL nodes for the current function onto
the BLOCK_VARS list for this outer scope, but are strung off of the
DECL_ARGUMENTS list for the function instead.
The BLOCK_VARS list for the `outer_scope' does provide us with a list of
the LABEL_DECL nodes for the function however, and we output DWARF info
for those in decls_for_scope. Just within the `outer_scope' there will be
a BLOCK node representing the function's outermost pair of curly braces,
and any blocks used for the base and member initializers of a C++
constructor function. */
tree outer_scope = DECL_INITIAL (decl);
if (! declaration && outer_scope && TREE_CODE (outer_scope) != ERROR_MARK)
{
int call_site_note_count = 0;
int tail_call_site_note_count = 0;
/* Emit a DW_TAG_variable DIE for a named return value. */
if (DECL_NAME (DECL_RESULT (decl)))
gen_decl_die (DECL_RESULT (decl), NULL, NULL, subr_die);
/* The first time through decls_for_scope we will generate the
DIEs for the locals. The second time, we fill in the
location info. */
decls_for_scope (outer_scope, subr_die);
if (call_arg_locations && (!dwarf_strict || dwarf_version >= 5))
{
struct call_arg_loc_node *ca_loc;
for (ca_loc = call_arg_locations; ca_loc; ca_loc = ca_loc->next)
{
dw_die_ref die = NULL;
rtx tloc = NULL_RTX, tlocc = NULL_RTX;
rtx arg, next_arg;
tree arg_decl = NULL_TREE;
for (arg = (ca_loc->call_arg_loc_note != NULL_RTX
? XEXP (ca_loc->call_arg_loc_note, 0)
: NULL_RTX);
arg; arg = next_arg)
{
dw_loc_descr_ref reg, val;
machine_mode mode = GET_MODE (XEXP (XEXP (arg, 0), 1));
dw_die_ref cdie, tdie = NULL;
next_arg = XEXP (arg, 1);
if (REG_P (XEXP (XEXP (arg, 0), 0))
&& next_arg
&& MEM_P (XEXP (XEXP (next_arg, 0), 0))
&& REG_P (XEXP (XEXP (XEXP (next_arg, 0), 0), 0))
&& REGNO (XEXP (XEXP (arg, 0), 0))
== REGNO (XEXP (XEXP (XEXP (next_arg, 0), 0), 0)))
next_arg = XEXP (next_arg, 1);
if (mode == VOIDmode)
{
mode = GET_MODE (XEXP (XEXP (arg, 0), 0));
if (mode == VOIDmode)
mode = GET_MODE (XEXP (arg, 0));
}
if (mode == VOIDmode || mode == BLKmode)
continue;
/* Get dynamic information about call target only if we
have no static information: we cannot generate both
DW_AT_call_origin and DW_AT_call_target
attributes. */
if (ca_loc->symbol_ref == NULL_RTX)
{
if (XEXP (XEXP (arg, 0), 0) == pc_rtx)
{
tloc = XEXP (XEXP (arg, 0), 1);
continue;
}
else if (GET_CODE (XEXP (XEXP (arg, 0), 0)) == CLOBBER
&& XEXP (XEXP (XEXP (arg, 0), 0), 0) == pc_rtx)
{
tlocc = XEXP (XEXP (arg, 0), 1);
continue;
}
}
reg = NULL;
if (REG_P (XEXP (XEXP (arg, 0), 0)))
reg = reg_loc_descriptor (XEXP (XEXP (arg, 0), 0),
VAR_INIT_STATUS_INITIALIZED);
else if (MEM_P (XEXP (XEXP (arg, 0), 0)))
{
rtx mem = XEXP (XEXP (arg, 0), 0);
reg = mem_loc_descriptor (XEXP (mem, 0),
get_address_mode (mem),
GET_MODE (mem),
VAR_INIT_STATUS_INITIALIZED);
}
else if (GET_CODE (XEXP (XEXP (arg, 0), 0))
== DEBUG_PARAMETER_REF)
{
tree tdecl
= DEBUG_PARAMETER_REF_DECL (XEXP (XEXP (arg, 0), 0));
tdie = lookup_decl_die (tdecl);
if (tdie == NULL)
continue;
arg_decl = tdecl;
}
else
continue;
if (reg == NULL
&& GET_CODE (XEXP (XEXP (arg, 0), 0))
!= DEBUG_PARAMETER_REF)
continue;
val = mem_loc_descriptor (XEXP (XEXP (arg, 0), 1), mode,
VOIDmode,
VAR_INIT_STATUS_INITIALIZED);
if (val == NULL)
continue;
if (die == NULL)
die = gen_call_site_die (decl, subr_die, ca_loc);
cdie = new_die (dwarf_TAG (DW_TAG_call_site_parameter), die,
NULL_TREE);
add_desc_attribute (cdie, arg_decl);
if (reg != NULL)
add_AT_loc (cdie, DW_AT_location, reg);
else if (tdie != NULL)
add_AT_die_ref (cdie, dwarf_AT (DW_AT_call_parameter),
tdie);
add_AT_loc (cdie, dwarf_AT (DW_AT_call_value), val);
if (next_arg != XEXP (arg, 1))
{
mode = GET_MODE (XEXP (XEXP (XEXP (arg, 1), 0), 1));
if (mode == VOIDmode)
mode = GET_MODE (XEXP (XEXP (XEXP (arg, 1), 0), 0));
val = mem_loc_descriptor (XEXP (XEXP (XEXP (arg, 1),
0), 1),
mode, VOIDmode,
VAR_INIT_STATUS_INITIALIZED);
if (val != NULL)
add_AT_loc (cdie, dwarf_AT (DW_AT_call_data_value),
val);
}
}
if (die == NULL
&& (ca_loc->symbol_ref || tloc))
die = gen_call_site_die (decl, subr_die, ca_loc);
if (die != NULL && (tloc != NULL_RTX || tlocc != NULL_RTX))
{
dw_loc_descr_ref tval = NULL;
if (tloc != NULL_RTX)
tval = mem_loc_descriptor (tloc,
GET_MODE (tloc) == VOIDmode
? Pmode : GET_MODE (tloc),
VOIDmode,
VAR_INIT_STATUS_INITIALIZED);
if (tval)
add_AT_loc (die, dwarf_AT (DW_AT_call_target), tval);
else if (tlocc != NULL_RTX)
{
tval = mem_loc_descriptor (tlocc,
GET_MODE (tlocc) == VOIDmode
? Pmode : GET_MODE (tlocc),
VOIDmode,
VAR_INIT_STATUS_INITIALIZED);
if (tval)
add_AT_loc (die,
dwarf_AT (DW_AT_call_target_clobbered),
tval);
}
}
if (die != NULL)
{
call_site_note_count++;
if (ca_loc->tail_call_p)
tail_call_site_note_count++;
}
}
}
call_arg_locations = NULL;
call_arg_loc_last = NULL;
if (tail_call_site_count >= 0
&& tail_call_site_count == tail_call_site_note_count
&& (!dwarf_strict || dwarf_version >= 5))
{
if (call_site_count >= 0
&& call_site_count == call_site_note_count)
add_AT_flag (subr_die, dwarf_AT (DW_AT_call_all_calls), 1);
else
add_AT_flag (subr_die, dwarf_AT (DW_AT_call_all_tail_calls), 1);
}
call_site_count = -1;
tail_call_site_count = -1;
}
/* Mark used types after we have created DIEs for the functions scopes. */
premark_used_types (DECL_STRUCT_FUNCTION (decl));
}
/* Returns a hash value for X (which really is a die_struct). */
hashval_t
block_die_hasher::hash (die_struct *d)
{
return (hashval_t) d->decl_id ^ htab_hash_pointer (d->die_parent);
}
/* Return nonzero if decl_id and die_parent of die_struct X is the same
as decl_id and die_parent of die_struct Y. */
bool
block_die_hasher::equal (die_struct *x, die_struct *y)
{
return x->decl_id == y->decl_id && x->die_parent == y->die_parent;
}
/* Hold information about markers for inlined entry points. */
struct GTY ((for_user)) inline_entry_data
{
/* The block that's the inlined_function_outer_scope for an inlined
function. */
tree block;
/* The label at the inlined entry point. */
const char *label_pfx;
unsigned int label_num;
/* The view number to be used as the inlined entry point. */
var_loc_view view;
};
struct inline_entry_data_hasher : ggc_ptr_hash <inline_entry_data>
{
typedef tree compare_type;
static inline hashval_t hash (const inline_entry_data *);
static inline bool equal (const inline_entry_data *, const_tree);
};
/* Hash table routines for inline_entry_data. */
inline hashval_t
inline_entry_data_hasher::hash (const inline_entry_data *data)
{
return htab_hash_pointer (data->block);
}
inline bool
inline_entry_data_hasher::equal (const inline_entry_data *data,
const_tree block)
{
return data->block == block;
}
/* Inlined entry points pending DIE creation in this compilation unit. */
static GTY(()) hash_table<inline_entry_data_hasher> *inline_entry_data_table;
/* Return TRUE if DECL, which may have been previously generated as
OLD_DIE, is a candidate for a DW_AT_specification. DECLARATION is
true if decl (or its origin) is either an extern declaration or a
class/namespace scoped declaration.
The declare_in_namespace support causes us to get two DIEs for one
variable, both of which are declarations. We want to avoid
considering one to be a specification, so we must test for
DECLARATION and DW_AT_declaration. */
static inline bool
decl_will_get_specification_p (dw_die_ref old_die, tree decl, bool declaration)
{
return (old_die && TREE_STATIC (decl) && !declaration
&& get_AT_flag (old_die, DW_AT_declaration) == 1);
}
/* Return true if DECL is a local static. */
static inline bool
local_function_static (tree decl)
{
gcc_assert (VAR_P (decl));
return TREE_STATIC (decl)
&& DECL_CONTEXT (decl)
&& TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL;
}
/* Return true iff DECL overrides (presumably completes) the type of
OLD_DIE within CONTEXT_DIE. */
static bool
override_type_for_decl_p (tree decl, dw_die_ref old_die,
dw_die_ref context_die)
{
tree type = TREE_TYPE (decl);
int cv_quals;
if (decl_by_reference_p (decl))
{
type = TREE_TYPE (type);
cv_quals = TYPE_UNQUALIFIED;
}
else
cv_quals = decl_quals (decl);
dw_die_ref type_die = modified_type_die (type,
cv_quals | TYPE_QUALS (type),
false,
context_die);
dw_die_ref old_type_die = get_AT_ref (old_die, DW_AT_type);
return type_die != old_type_die;
}
/* Generate a DIE to represent a declared data object.
Either DECL or ORIGIN must be non-null. */
static void
gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
{
HOST_WIDE_INT off = 0;
tree com_decl;
tree decl_or_origin = decl ? decl : origin;
tree ultimate_origin;
dw_die_ref var_die;
dw_die_ref old_die = decl ? lookup_decl_die (decl) : NULL;
bool declaration = (DECL_EXTERNAL (decl_or_origin)
|| class_or_namespace_scope_p (context_die));
bool specialization_p = false;
bool no_linkage_name = false;
/* While C++ inline static data members have definitions inside of the
class, force the first DIE to be a declaration, then let gen_member_die
reparent it to the class context and call gen_variable_die again
to create the outside of the class DIE for the definition. */
if (!declaration
&& old_die == NULL
&& decl
&& DECL_CONTEXT (decl)
&& TYPE_P (DECL_CONTEXT (decl))
&& lang_hooks.decls.decl_dwarf_attribute (decl, DW_AT_inline) != -1)
{
declaration = true;
if (dwarf_version < 5)
no_linkage_name = true;
}
ultimate_origin = decl_ultimate_origin (decl_or_origin);
if (decl || ultimate_origin)
origin = ultimate_origin;
com_decl = fortran_common (decl_or_origin, &off);
/* Symbol in common gets emitted as a child of the common block, in the form
of a data member. */
if (com_decl)
{
dw_die_ref com_die;
dw_loc_list_ref loc = NULL;
die_node com_die_arg;
var_die = lookup_decl_die (decl_or_origin);
if (var_die)
{
if (! early_dwarf && get_AT (var_die, DW_AT_location) == NULL)
{
loc = loc_list_from_tree (com_decl, off ? 1 : 2, NULL);
if (loc)
{
if (off)
{
/* Optimize the common case. */
if (single_element_loc_list_p (loc)
&& loc->expr->dw_loc_opc == DW_OP_addr
&& loc->expr->dw_loc_next == NULL
&& GET_CODE (loc->expr->dw_loc_oprnd1.v.val_addr)
== SYMBOL_REF)
{
rtx x = loc->expr->dw_loc_oprnd1.v.val_addr;
loc->expr->dw_loc_oprnd1.v.val_addr
= plus_constant (GET_MODE (x), x , off);
}
else
loc_list_plus_const (loc, off);
}
add_AT_location_description (var_die, DW_AT_location, loc);
remove_AT (var_die, DW_AT_declaration);
}
}
return;
}
if (common_block_die_table == NULL)
common_block_die_table = hash_table<block_die_hasher>::create_ggc (10);
com_die_arg.decl_id = DECL_UID (com_decl);
com_die_arg.die_parent = context_die;
com_die = common_block_die_table->find (&com_die_arg);
if (! early_dwarf)
loc = loc_list_from_tree (com_decl, 2, NULL);
if (com_die == NULL)
{
const char *cnam
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (com_decl));
die_node **slot;
com_die = new_die (DW_TAG_common_block, context_die, decl);
add_name_and_src_coords_attributes (com_die, com_decl);
if (loc)
{
add_AT_location_description (com_die, DW_AT_location, loc);
/* Avoid sharing the same loc descriptor between
DW_TAG_common_block and DW_TAG_variable. */
loc = loc_list_from_tree (com_decl, 2, NULL);
}
else if (DECL_EXTERNAL (decl_or_origin))
add_AT_flag (com_die, DW_AT_declaration, 1);
if (want_pubnames ())
add_pubname_string (cnam, com_die); /* ??? needed? */
com_die->decl_id = DECL_UID (com_decl);
slot = common_block_die_table->find_slot (com_die, INSERT);
*slot = com_die;
}
else if (get_AT (com_die, DW_AT_location) == NULL && loc)
{
add_AT_location_description (com_die, DW_AT_location, loc);
loc = loc_list_from_tree (com_decl, 2, NULL);
remove_AT (com_die, DW_AT_declaration);
}
var_die = new_die (DW_TAG_variable, com_die, decl);
add_name_and_src_coords_attributes (var_die, decl_or_origin);
add_type_attribute (var_die, TREE_TYPE (decl_or_origin),
decl_quals (decl_or_origin), false,
context_die);
add_alignment_attribute (var_die, decl);
add_AT_flag (var_die, DW_AT_external, 1);
if (loc)
{
if (off)
{
/* Optimize the common case. */
if (single_element_loc_list_p (loc)
&& loc->expr->dw_loc_opc == DW_OP_addr
&& loc->expr->dw_loc_next == NULL
&& GET_CODE (loc->expr->dw_loc_oprnd1.v.val_addr) == SYMBOL_REF)
{
rtx x = loc->expr->dw_loc_oprnd1.v.val_addr;
loc->expr->dw_loc_oprnd1.v.val_addr
= plus_constant (GET_MODE (x), x, off);
}
else
loc_list_plus_const (loc, off);
}
add_AT_location_description (var_die, DW_AT_location, loc);
}
else if (DECL_EXTERNAL (decl_or_origin))
add_AT_flag (var_die, DW_AT_declaration, 1);
if (decl)
equate_decl_number_to_die (decl, var_die);
return;
}
if (old_die)
{
if (declaration)
{
/* A declaration that has been previously dumped, needs no
further annotations, since it doesn't need location on
the second pass. */
return;
}
else if (decl_will_get_specification_p (old_die, decl, declaration)
&& !get_AT (old_die, DW_AT_specification))
{
/* Fall-thru so we can make a new variable die along with a
DW_AT_specification. */
}
else if (origin && old_die->die_parent != context_die)
{
/* If we will be creating an inlined instance, we need a
new DIE that will get annotated with
DW_AT_abstract_origin. */
gcc_assert (!DECL_ABSTRACT_P (decl));
}
else
{
/* If a DIE was dumped early, it still needs location info.
Skip to where we fill the location bits. */
var_die = old_die;
/* ??? In LTRANS we cannot annotate early created variably
modified type DIEs without copying them and adjusting all
references to them. Thus we dumped them again. Also add a
reference to them but beware of -g0 compile and -g link
in which case the reference will be already present. */
tree type = TREE_TYPE (decl_or_origin);
if (in_lto_p
&& ! get_AT (var_die, DW_AT_type)
&& variably_modified_type_p
(type, decl_function_context (decl_or_origin)))
{
if (decl_by_reference_p (decl_or_origin))
add_type_attribute (var_die, TREE_TYPE (type),
TYPE_UNQUALIFIED, false, context_die);
else
add_type_attribute (var_die, type, decl_quals (decl_or_origin),
false, context_die);
}
goto gen_variable_die_location;
}
}
/* For static data members, the declaration in the class is supposed
to have DW_TAG_member tag in DWARF{3,4} and we emit it for compatibility
also in DWARF2; the specification should still be DW_TAG_variable
referencing the DW_TAG_member DIE. */
if (declaration && class_scope_p (context_die) && dwarf_version < 5)
var_die = new_die (DW_TAG_member, context_die, decl);
else
var_die = new_die (DW_TAG_variable, context_die, decl);
if (origin != NULL)
add_abstract_origin_attribute (var_die, origin);
/* Loop unrolling can create multiple blocks that refer to the same
static variable, so we must test for the DW_AT_declaration flag.
??? Loop unrolling/reorder_blocks should perhaps be rewritten to
copy decls and set the DECL_ABSTRACT_P flag on them instead of
sharing them.
??? Duplicated blocks have been rewritten to use .debug_ranges. */
else if (decl_will_get_specification_p (old_die, decl, declaration))
{
/* This is a definition of a C++ class level static. */
add_AT_specification (var_die, old_die);
specialization_p = true;
if (DECL_NAME (decl))
{
expanded_location s = expand_location (DECL_SOURCE_LOCATION (decl));
struct dwarf_file_data * file_index = lookup_filename (s.file);
if (get_AT_file (old_die, DW_AT_decl_file) != file_index)
add_AT_file (var_die, DW_AT_decl_file, file_index);
if (get_AT_unsigned (old_die, DW_AT_decl_line) != (unsigned) s.line)
add_AT_unsigned (var_die, DW_AT_decl_line, s.line);
if (debug_column_info
&& s.column
&& (get_AT_unsigned (old_die, DW_AT_decl_column)
!= (unsigned) s.column))
add_AT_unsigned (var_die, DW_AT_decl_column, s.column);
if (old_die->die_tag == DW_TAG_member)
add_linkage_name (var_die, decl);
}
}
else
add_name_and_src_coords_attributes (var_die, decl, no_linkage_name);
if ((origin == NULL && !specialization_p)
|| (origin != NULL
&& !DECL_ABSTRACT_P (decl_or_origin)
&& variably_modified_type_p (TREE_TYPE (decl_or_origin),
decl_function_context
(decl_or_origin)))
|| (old_die && specialization_p
&& override_type_for_decl_p (decl_or_origin, old_die, context_die)))
{
tree type = TREE_TYPE (decl_or_origin);
if (decl_by_reference_p (decl_or_origin))
add_type_attribute (var_die, TREE_TYPE (type), TYPE_UNQUALIFIED, false,
context_die);
else
add_type_attribute (var_die, type, decl_quals (decl_or_origin), false,
context_die);
}
if (origin == NULL && !specialization_p)
{
if (TREE_PUBLIC (decl))
add_AT_flag (var_die, DW_AT_external, 1);
if (DECL_ARTIFICIAL (decl))
add_AT_flag (var_die, DW_AT_artificial, 1);
add_alignment_attribute (var_die, decl);
add_accessibility_attribute (var_die, decl);
}
if (declaration)
add_AT_flag (var_die, DW_AT_declaration, 1);
if (decl && (DECL_ABSTRACT_P (decl)
|| !old_die || is_declaration_die (old_die)))
equate_decl_number_to_die (decl, var_die);
gen_variable_die_location:
if (! declaration
&& (! DECL_ABSTRACT_P (decl_or_origin)
/* Local static vars are shared between all clones/inlines,
so emit DW_AT_location on the abstract DIE if DECL_RTL is
already set. */
|| (VAR_P (decl_or_origin)
&& TREE_STATIC (decl_or_origin)
&& DECL_RTL_SET_P (decl_or_origin))))
{
if (early_dwarf)
add_pubname (decl_or_origin, var_die);
else
add_location_or_const_value_attribute (var_die, decl_or_origin,
decl == NULL);
}
else
tree_add_const_value_attribute_for_decl (var_die, decl_or_origin);
if ((dwarf_version >= 4 || !dwarf_strict)
&& lang_hooks.decls.decl_dwarf_attribute (decl_or_origin,
DW_AT_const_expr) == 1
&& !get_AT (var_die, DW_AT_const_expr)
&& !specialization_p)
add_AT_flag (var_die, DW_AT_const_expr, 1);
if (!dwarf_strict)
{
int inl = lang_hooks.decls.decl_dwarf_attribute (decl_or_origin,
DW_AT_inline);
if (inl != -1
&& !get_AT (var_die, DW_AT_inline)
&& !specialization_p)
add_AT_unsigned (var_die, DW_AT_inline, inl);
}
}
/* Generate a DIE to represent a named constant. */
static void
gen_const_die (tree decl, dw_die_ref context_die)
{
dw_die_ref const_die;
tree type = TREE_TYPE (decl);
const_die = lookup_decl_die (decl);
if (const_die)
return;
const_die = new_die (DW_TAG_constant, context_die, decl);
equate_decl_number_to_die (decl, const_die);
add_name_and_src_coords_attributes (const_die, decl);
add_type_attribute (const_die, type, TYPE_QUAL_CONST, false, context_die);
if (TREE_PUBLIC (decl))
add_AT_flag (const_die, DW_AT_external, 1);
if (DECL_ARTIFICIAL (decl))
add_AT_flag (const_die, DW_AT_artificial, 1);
tree_add_const_value_attribute_for_decl (const_die, decl);
}
/* Generate a DIE to represent a label identifier. */
static void
gen_label_die (tree decl, dw_die_ref context_die)
{
tree origin = decl_ultimate_origin (decl);
dw_die_ref lbl_die = lookup_decl_die (decl);
rtx insn;
char label[MAX_ARTIFICIAL_LABEL_BYTES];
if (!lbl_die)
{
lbl_die = new_die (DW_TAG_label, context_die, decl);
equate_decl_number_to_die (decl, lbl_die);
if (origin != NULL)
add_abstract_origin_attribute (lbl_die, origin);
else
add_name_and_src_coords_attributes (lbl_die, decl);
}
if (DECL_ABSTRACT_P (decl))
equate_decl_number_to_die (decl, lbl_die);
else if (! early_dwarf)
{
insn = DECL_RTL_IF_SET (decl);
/* Deleted labels are programmer specified labels which have been
eliminated because of various optimizations. We still emit them
here so that it is possible to put breakpoints on them. */
if (insn
&& (LABEL_P (insn)
|| ((NOTE_P (insn)
&& NOTE_KIND (insn) == NOTE_INSN_DELETED_LABEL))))
{
/* When optimization is enabled (via -O) some parts of the compiler
(e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
represent source-level labels which were explicitly declared by
the user. This really shouldn't be happening though, so catch
it if it ever does happen. */
gcc_assert (!as_a<rtx_insn *> (insn)->deleted ());
ASM_GENERATE_INTERNAL_LABEL (label, "L", CODE_LABEL_NUMBER (insn));
add_AT_lbl_id (lbl_die, DW_AT_low_pc, label);
}
else if (insn
&& NOTE_P (insn)
&& NOTE_KIND (insn) == NOTE_INSN_DELETED_DEBUG_LABEL
&& CODE_LABEL_NUMBER (insn) != -1)
{
ASM_GENERATE_INTERNAL_LABEL (label, "LDL", CODE_LABEL_NUMBER (insn));
add_AT_lbl_id (lbl_die, DW_AT_low_pc, label);
}
}
}
/* A helper function for gen_inlined_subroutine_die. Add source coordinate
attributes to the DIE for a block STMT, to describe where the inlined
function was called from. This is similar to add_src_coords_attributes. */
static inline void
add_call_src_coords_attributes (tree stmt, dw_die_ref die)
{
/* We can end up with BUILTINS_LOCATION here. */
if (RESERVED_LOCATION_P (BLOCK_SOURCE_LOCATION (stmt)))
return;
expanded_location s = expand_location (BLOCK_SOURCE_LOCATION (stmt));
if (dwarf_version >= 3 || !dwarf_strict)
{
add_AT_file (die, DW_AT_call_file, lookup_filename (s.file));
add_AT_unsigned (die, DW_AT_call_line, s.line);
if (debug_column_info && s.column)
add_AT_unsigned (die, DW_AT_call_column, s.column);
}
}
/* A helper function for gen_lexical_block_die and gen_inlined_subroutine_die.
Add low_pc and high_pc attributes to the DIE for a block STMT. */
static inline void
add_high_low_attributes (tree stmt, dw_die_ref die)
{
char label[MAX_ARTIFICIAL_LABEL_BYTES];
if (inline_entry_data **iedp
= !inline_entry_data_table ? NULL
: inline_entry_data_table->find_slot_with_hash (stmt,
htab_hash_pointer (stmt),
NO_INSERT))
{
inline_entry_data *ied = *iedp;
gcc_assert (MAY_HAVE_DEBUG_MARKER_INSNS);
gcc_assert (debug_inline_points);
gcc_assert (inlined_function_outer_scope_p (stmt));
ASM_GENERATE_INTERNAL_LABEL (label, ied->label_pfx, ied->label_num);
add_AT_lbl_id (die, DW_AT_entry_pc, label);
if (debug_variable_location_views && !ZERO_VIEW_P (ied->view)
&& !dwarf_strict)
{
if (!output_asm_line_debug_info ())
add_AT_unsigned (die, DW_AT_GNU_entry_view, ied->view);
else
{
ASM_GENERATE_INTERNAL_LABEL (label, "LVU", ied->view);
/* FIXME: this will resolve to a small number. Could we
possibly emit smaller data? Ideally we'd emit a
uleb128, but that would make the size of DIEs
impossible for the compiler to compute, since it's
the assembler that computes the value of the view
label in this case. Ideally, we'd have a single form
encompassing both the address and the view, and
indirecting them through a table might make things
easier, but even that would be more wasteful,
space-wise, than what we have now. */
add_AT_symview (die, DW_AT_GNU_entry_view, label);
}
}
inline_entry_data_table->clear_slot (iedp);
}
if (BLOCK_FRAGMENT_CHAIN (stmt)
&& (dwarf_version >= 3 || !dwarf_strict))
{
tree chain, superblock = NULL_TREE;
dw_die_ref pdie;
dw_attr_node *attr = NULL;
if (!debug_inline_points && inlined_function_outer_scope_p (stmt))
{
ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_BEGIN_LABEL,
BLOCK_NUMBER (stmt));
add_AT_lbl_id (die, DW_AT_entry_pc, label);
}
/* Optimize duplicate .debug_ranges lists or even tails of
lists. If this BLOCK has same ranges as its supercontext,
lookup DW_AT_ranges attribute in the supercontext (and
recursively so), verify that the ranges_table contains the
right values and use it instead of adding a new .debug_range. */
for (chain = stmt, pdie = die;
BLOCK_SAME_RANGE (chain);
chain = BLOCK_SUPERCONTEXT (chain))
{
dw_attr_node *new_attr;
pdie = pdie->die_parent;
if (pdie == NULL)
break;
if (BLOCK_SUPERCONTEXT (chain) == NULL_TREE)
break;
new_attr = get_AT (pdie, DW_AT_ranges);
if (new_attr == NULL
|| new_attr->dw_attr_val.val_class != dw_val_class_range_list)
break;
attr = new_attr;
superblock = BLOCK_SUPERCONTEXT (chain);
}
if (attr != NULL
&& ((*ranges_table)[attr->dw_attr_val.v.val_offset].num
== (int)BLOCK_NUMBER (superblock))
&& BLOCK_FRAGMENT_CHAIN (superblock))
{
unsigned long off = attr->dw_attr_val.v.val_offset;
unsigned long supercnt = 0, thiscnt = 0;
for (chain = BLOCK_FRAGMENT_CHAIN (superblock);
chain; chain = BLOCK_FRAGMENT_CHAIN (chain))
{
++supercnt;
gcc_checking_assert ((*ranges_table)[off + supercnt].num
== (int)BLOCK_NUMBER (chain));
}
gcc_checking_assert ((*ranges_table)[off + supercnt + 1].num == 0);
for (chain = BLOCK_FRAGMENT_CHAIN (stmt);
chain; chain = BLOCK_FRAGMENT_CHAIN (chain))
++thiscnt;
gcc_assert (supercnt >= thiscnt);
add_AT_range_list (die, DW_AT_ranges, off + supercnt - thiscnt,
false);
note_rnglist_head (off + supercnt - thiscnt);
return;
}
unsigned int offset = add_ranges (stmt, true);
add_AT_range_list (die, DW_AT_ranges, offset, false);
note_rnglist_head (offset);
bool prev_in_cold = BLOCK_IN_COLD_SECTION_P (stmt);
chain = BLOCK_FRAGMENT_CHAIN (stmt);
do
{
add_ranges (chain, prev_in_cold != BLOCK_IN_COLD_SECTION_P (chain));
prev_in_cold = BLOCK_IN_COLD_SECTION_P (chain);
chain = BLOCK_FRAGMENT_CHAIN (chain);
}
while (chain);
add_ranges (NULL);
}
else
{
char label_high[MAX_ARTIFICIAL_LABEL_BYTES];
ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_BEGIN_LABEL,
BLOCK_NUMBER (stmt));
ASM_GENERATE_INTERNAL_LABEL (label_high, BLOCK_END_LABEL,
BLOCK_NUMBER (stmt));
add_AT_low_high_pc (die, label, label_high, false);
}
}
/* Generate a DIE for a lexical block. */
static void
gen_lexical_block_die (tree stmt, dw_die_ref context_die)
{
dw_die_ref old_die = lookup_block_die (stmt);
dw_die_ref stmt_die = NULL;
if (!old_die)
{
stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt);
equate_block_to_die (stmt, stmt_die);
}
if (BLOCK_ABSTRACT_ORIGIN (stmt))
{
/* If this is an inlined or conrecte instance, create a new lexical
die for anything below to attach DW_AT_abstract_origin to. */
if (old_die)
stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt);
tree origin = block_ultimate_origin (stmt);
if (origin != NULL_TREE && (origin != stmt || old_die))
add_abstract_origin_attribute (stmt_die, origin);
old_die = NULL;
}
if (old_die)
stmt_die = old_die;
/* A non abstract block whose blocks have already been reordered
should have the instruction range for this block. If so, set the
high/low attributes. */
if (!early_dwarf && TREE_ASM_WRITTEN (stmt))
{
gcc_assert (stmt_die);
add_high_low_attributes (stmt, stmt_die);
}
decls_for_scope (stmt, stmt_die);
}
/* Generate a DIE for an inlined subprogram. */
static void
gen_inlined_subroutine_die (tree stmt, dw_die_ref context_die)
{
tree decl = block_ultimate_origin (stmt);
/* Make sure any inlined functions are known to be inlineable. */
gcc_checking_assert (DECL_ABSTRACT_P (decl)
|| cgraph_function_possibly_inlined_p (decl));
dw_die_ref subr_die = new_die (DW_TAG_inlined_subroutine, context_die, stmt);
if (call_arg_locations || debug_inline_points)
equate_block_to_die (stmt, subr_die);
add_abstract_origin_attribute (subr_die, decl);
if (TREE_ASM_WRITTEN (stmt))
add_high_low_attributes (stmt, subr_die);
add_call_src_coords_attributes (stmt, subr_die);
/* The inliner creates an extra BLOCK for the parameter setup,
we want to merge that with the actual outermost BLOCK of the
inlined function to avoid duplicate locals in consumers.
Do that by doing the recursion to subblocks on the single subblock
of STMT. */
bool unwrap_one = false;
if (BLOCK_SUBBLOCKS (stmt) && !BLOCK_CHAIN (BLOCK_SUBBLOCKS (stmt)))
{
tree origin = block_ultimate_origin (BLOCK_SUBBLOCKS (stmt));
if (origin
&& TREE_CODE (origin) == BLOCK
&& BLOCK_SUPERCONTEXT (origin) == decl)
unwrap_one = true;
}
decls_for_scope (stmt, subr_die, !unwrap_one);
if (unwrap_one)
decls_for_scope (BLOCK_SUBBLOCKS (stmt), subr_die);
}
/* Generate a DIE for a field in a record, or structure. CTX is required: see
the comment for VLR_CONTEXT. */
static void
gen_field_die (tree decl, struct vlr_context *ctx, dw_die_ref context_die)
{
dw_die_ref decl_die;
if (TREE_TYPE (decl) == error_mark_node)
return;
decl_die = new_die (DW_TAG_member, context_die, decl);
add_name_and_src_coords_attributes (decl_die, decl);
add_type_attribute (decl_die, member_declared_type (decl), decl_quals (decl),
TYPE_REVERSE_STORAGE_ORDER (DECL_FIELD_CONTEXT (decl)),
context_die);
if (DECL_BIT_FIELD_TYPE (decl))
{
add_byte_size_attribute (decl_die, decl);
add_bit_size_attribute (decl_die, decl);
add_bit_offset_attribute (decl_die, decl);
}
add_alignment_attribute (decl_die, decl);
if (TREE_CODE (DECL_FIELD_CONTEXT (decl)) != UNION_TYPE)
add_data_member_location_attribute (decl_die, decl, ctx);
if (DECL_ARTIFICIAL (decl))
add_AT_flag (decl_die, DW_AT_artificial, 1);
add_accessibility_attribute (decl_die, decl);
/* Equate decl number to die, so that we can look up this decl later on. */
equate_decl_number_to_die (decl, decl_die);
}
/* Generate a DIE for a pointer to a member type. TYPE can be an
OFFSET_TYPE, for a pointer to data member, or a RECORD_TYPE, for a
pointer to member function. */
static void
gen_ptr_to_mbr_type_die (tree type, dw_die_ref context_die)
{
if (lookup_type_die (type))
return;
dw_die_ref ptr_die = new_die (DW_TAG_ptr_to_member_type,
scope_die_for (type, context_die), type);
equate_type_number_to_die (type, ptr_die);
add_AT_die_ref (ptr_die, DW_AT_containing_type,
lookup_type_die (TYPE_OFFSET_BASETYPE (type)));
add_type_attribute (ptr_die, TREE_TYPE (type), TYPE_UNQUALIFIED, false,
context_die);
add_alignment_attribute (ptr_die, type);
if (TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE
&& TREE_CODE (TREE_TYPE (type)) != METHOD_TYPE)
{
dw_loc_descr_ref op = new_loc_descr (DW_OP_plus, 0, 0);
add_AT_loc (ptr_die, DW_AT_use_location, op);
}
}
static char *producer_string;
/* Return a heap allocated producer string including command line options
if -grecord-gcc-switches. */
static char *
gen_producer_string (void)
{
size_t j;
auto_vec<const char *> switches;
const char *language_string = lang_hooks.name;
char *producer, *tail;
const char *p;
size_t len = dwarf_record_gcc_switches ? 0 : 3;
size_t plen = strlen (language_string) + 1 + strlen (version_string);
for (j = 1; dwarf_record_gcc_switches && j < save_decoded_options_count; j++)
switch (save_decoded_options[j].opt_index)
{
case OPT_o:
case OPT_d:
case OPT_dumpbase:
case OPT_dumpbase_ext:
case OPT_dumpdir:
case OPT_quiet:
case OPT_version:
case OPT_v:
case OPT_w:
case OPT_L:
case OPT_D:
case OPT_I:
case OPT_U:
case OPT_SPECIAL_unknown:
case OPT_SPECIAL_ignore:
case OPT_SPECIAL_warn_removed:
case OPT_SPECIAL_program_name:
case OPT_SPECIAL_input_file:
case OPT_grecord_gcc_switches:
case OPT__output_pch_:
case OPT_fdiagnostics_show_location_:
case OPT_fdiagnostics_show_option:
case OPT_fdiagnostics_show_caret:
case OPT_fdiagnostics_show_labels:
case OPT_fdiagnostics_show_line_numbers:
case OPT_fdiagnostics_color_:
case OPT_fdiagnostics_format_:
case OPT_fverbose_asm:
case OPT____:
case OPT__sysroot_:
case OPT_nostdinc:
case OPT_nostdinc__:
case OPT_fpreprocessed:
case OPT_fltrans_output_list_:
case OPT_fresolution_:
case OPT_fdebug_prefix_map_:
case OPT_fmacro_prefix_map_:
case OPT_ffile_prefix_map_:
case OPT_fcompare_debug:
case OPT_fchecking:
case OPT_fchecking_:
/* Ignore these. */
continue;
case OPT_flto_:
{
const char *lto_canonical = "-flto";
switches.safe_push (lto_canonical);
len += strlen (lto_canonical) + 1;
break;
}
default:
if (cl_options[save_decoded_options[j].opt_index].flags
& CL_NO_DWARF_RECORD)
continue;
gcc_checking_assert (save_decoded_options[j].canonical_option[0][0]
== '-');
switch (save_decoded_options[j].canonical_option[0][1])
{
case 'M':
case 'i':
case 'W':
continue;
case 'f':
if (strncmp (save_decoded_options[j].canonical_option[0] + 2,
"dump", 4) == 0)
continue;
break;
default:
break;
}
switches.safe_push (save_decoded_options[j].orig_option_with_args_text);
len += strlen (save_decoded_options[j].orig_option_with_args_text) + 1;
break;
}
producer = XNEWVEC (char, plen + 1 + len + 1);
tail = producer;
sprintf (tail, "%s %s", language_string, version_string);
tail += plen;
FOR_EACH_VEC_ELT (switches, j, p)
{
len = strlen (p);
*tail = ' ';
memcpy (tail + 1, p, len);
tail += len + 1;
}
*tail = '\0';
return producer;
}
/* Given a C and/or C++ language/version string return the "highest".
C++ is assumed to be "higher" than C in this case. Used for merging
LTO translation unit languages. */
static const char *
highest_c_language (const char *lang1, const char *lang2)
{
if (strcmp ("GNU C++17", lang1) == 0 || strcmp ("GNU C++17", lang2) == 0)
return "GNU C++17";
if (strcmp ("GNU C++14", lang1) == 0 || strcmp ("GNU C++14", lang2) == 0)
return "GNU C++14";
if (strcmp ("GNU C++11", lang1) == 0 || strcmp ("GNU C++11", lang2) == 0)
return "GNU C++11";
if (strcmp ("GNU C++98", lang1) == 0 || strcmp ("GNU C++98", lang2) == 0)
return "GNU C++98";
if (strcmp ("GNU C2X", lang1) == 0 || strcmp ("GNU C2X", lang2) == 0)
return "GNU C2X";
if (strcmp ("GNU C17", lang1) == 0 || strcmp ("GNU C17", lang2) == 0)
return "GNU C17";
if (strcmp ("GNU C11", lang1) == 0 || strcmp ("GNU C11", lang2) == 0)
return "GNU C11";
if (strcmp ("GNU C99", lang1) == 0 || strcmp ("GNU C99", lang2) == 0)
return "GNU C99";
if (strcmp ("GNU C89", lang1) == 0 || strcmp ("GNU C89", lang2) == 0)
return "GNU C89";
gcc_unreachable ();
}
/* Generate the DIE for the compilation unit. */
static dw_die_ref
gen_compile_unit_die (const char *filename)
{
dw_die_ref die;
const char *language_string = lang_hooks.name;
int language;
die = new_die (DW_TAG_compile_unit, NULL, NULL);
if (filename)
{
add_filename_attribute (die, filename);
/* Don't add cwd for <built-in>. */
if (filename[0] != '<')
add_comp_dir_attribute (die);
}
add_AT_string (die, DW_AT_producer, producer_string ? producer_string : "");
/* If our producer is LTO try to figure out a common language to use
from the global list of translation units. */
if (strcmp (language_string, "GNU GIMPLE") == 0)
{
unsigned i;
tree t;
const char *common_lang = NULL;
FOR_EACH_VEC_SAFE_ELT (all_translation_units, i, t)
{
if (!TRANSLATION_UNIT_LANGUAGE (t))
continue;
if (!common_lang)
common_lang = TRANSLATION_UNIT_LANGUAGE (t);
else if (strcmp (common_lang, TRANSLATION_UNIT_LANGUAGE (t)) == 0)
;
else if (strncmp (common_lang, "GNU C", 5) == 0
&& strncmp (TRANSLATION_UNIT_LANGUAGE (t), "GNU C", 5) == 0)
/* Mixing C and C++ is ok, use C++ in that case. */
common_lang = highest_c_language (common_lang,
TRANSLATION_UNIT_LANGUAGE (t));
else
{
/* Fall back to C. */
common_lang = NULL;
break;
}
}
if (common_lang)
language_string = common_lang;
}
language = DW_LANG_C;
if (strncmp (language_string, "GNU C", 5) == 0
&& ISDIGIT (language_string[5]))
{
language = DW_LANG_C89;
if (dwarf_version >= 3 || !dwarf_strict)
{
if (strcmp (language_string, "GNU C89") != 0)
language = DW_LANG_C99;
if (dwarf_version >= 5 /* || !dwarf_strict */)
if (strcmp (language_string, "GNU C11") == 0
|| strcmp (language_string, "GNU C17") == 0
|| strcmp (language_string, "GNU C2X") == 0)
language = DW_LANG_C11;
}
}
else if (strncmp (language_string, "GNU C++", 7) == 0)
{
language = DW_LANG_C_plus_plus;
if (dwarf_version >= 5 /* || !dwarf_strict */)
{
if (strcmp (language_string, "GNU C++11") == 0)
language = DW_LANG_C_plus_plus_11;
else if (strcmp (language_string, "GNU C++14") == 0)
language = DW_LANG_C_plus_plus_14;
else if (strcmp (language_string, "GNU C++17") == 0
|| strcmp (language_string, "GNU C++20") == 0)
/* For now. */
language = DW_LANG_C_plus_plus_14;
}
}
else if (strcmp (language_string, "GNU F77") == 0)
language = DW_LANG_Fortran77;
else if (dwarf_version >= 3 || !dwarf_strict)
{
if (strcmp (language_string, "GNU Ada") == 0)
language = DW_LANG_Ada95;
else if (strncmp (language_string, "GNU Fortran", 11) == 0)
{
language = DW_LANG_Fortran95;
if (dwarf_version >= 5 /* || !dwarf_strict */)
{
if (strcmp (language_string, "GNU Fortran2003") == 0)
language = DW_LANG_Fortran03;
else if (strcmp (language_string, "GNU Fortran2008") == 0)
language = DW_LANG_Fortran08;
}
}
else if (strcmp (language_string, "GNU Objective-C") == 0)
language = DW_LANG_ObjC;
else if (strcmp (language_string, "GNU Objective-C++") == 0)
language = DW_LANG_ObjC_plus_plus;
else if (strcmp (language_string, "GNU D") == 0)
language = DW_LANG_D;
else if (dwarf_version >= 5 || !dwarf_strict)
{
if (strcmp (language_string, "GNU Go") == 0)
language = DW_LANG_Go;
}
}
/* Use a degraded Fortran setting in strict DWARF2 so is_fortran works. */
else if (strncmp (language_string, "GNU Fortran", 11) == 0)
language = DW_LANG_Fortran90;
/* Likewise for Ada. */
else if (strcmp (language_string, "GNU Ada") == 0)
language = DW_LANG_Ada83;
add_AT_unsigned (die, DW_AT_language, language);
switch (language)
{
case DW_LANG_Fortran77:
case DW_LANG_Fortran90:
case DW_LANG_Fortran95:
case DW_LANG_Fortran03:
case DW_LANG_Fortran08:
/* Fortran has case insensitive identifiers and the front-end
lowercases everything. */
add_AT_unsigned (die, DW_AT_identifier_case, DW_ID_down_case);
break;
default:
/* The default DW_ID_case_sensitive doesn't need to be specified. */
break;
}
return die;
}
/* Generate the DIE for a base class. */
static void
gen_inheritance_die (tree binfo, tree access, tree type,
dw_die_ref context_die)
{
dw_die_ref die = new_die (DW_TAG_inheritance, context_die, binfo);
struct vlr_context ctx = { type, NULL };
add_type_attribute (die, BINFO_TYPE (binfo), TYPE_UNQUALIFIED, false,
context_die);
add_data_member_location_attribute (die, binfo, &ctx);
if (BINFO_VIRTUAL_P (binfo))
add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual);
/* In DWARF3+ the default is DW_ACCESS_private only in DW_TAG_class_type
children, otherwise the default is DW_ACCESS_public. In DWARF2
the default has always been DW_ACCESS_private. */
if (access == access_public_node)
{
if (dwarf_version == 2
|| context_die->die_tag == DW_TAG_class_type)
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public);
}
else if (access == access_protected_node)
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_protected);
else if (dwarf_version > 2
&& context_die->die_tag != DW_TAG_class_type)
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_private);
}
/* Return whether DECL is a FIELD_DECL that represents the variant part of a
structure. */
static bool
is_variant_part (tree decl)
{
return (TREE_CODE (decl) == FIELD_DECL
&& TREE_CODE (TREE_TYPE (decl)) == QUAL_UNION_TYPE);
}
/* Check that OPERAND is a reference to a field in STRUCT_TYPE. If it is,
return the FIELD_DECL. Return NULL_TREE otherwise. */
static tree
analyze_discr_in_predicate (tree operand, tree struct_type)
{
while (CONVERT_EXPR_P (operand))
operand = TREE_OPERAND (operand, 0);
/* Match field access to members of struct_type only. */
if (TREE_CODE (operand) == COMPONENT_REF
&& TREE_CODE (TREE_OPERAND (operand, 0)) == PLACEHOLDER_EXPR
&& TREE_TYPE (TREE_OPERAND (operand, 0)) == struct_type
&& TREE_CODE (TREE_OPERAND (operand, 1)) == FIELD_DECL)
return TREE_OPERAND (operand, 1);
else
return NULL_TREE;
}
/* Check that SRC is a constant integer that can be represented as a native
integer constant (either signed or unsigned). If so, store it into DEST and
return true. Return false otherwise. */
static bool
get_discr_value (tree src, dw_discr_value *dest)
{
tree discr_type = TREE_TYPE (src);
if (lang_hooks.types.get_debug_type)
{
tree debug_type = lang_hooks.types.get_debug_type (discr_type);
if (debug_type != NULL)
discr_type = debug_type;
}
if (TREE_CODE (src) != INTEGER_CST || !INTEGRAL_TYPE_P (discr_type))
return false;
/* Signedness can vary between the original type and the debug type. This
can happen for character types in Ada for instance: the character type
used for code generation can be signed, to be compatible with the C one,
but from a debugger point of view, it must be unsigned. */
bool is_orig_unsigned = TYPE_UNSIGNED (TREE_TYPE (src));
bool is_debug_unsigned = TYPE_UNSIGNED (discr_type);
if (is_orig_unsigned != is_debug_unsigned)
src = fold_convert (discr_type, src);
if (!(is_debug_unsigned ? tree_fits_uhwi_p (src) : tree_fits_shwi_p (src)))
return false;
dest->pos = is_debug_unsigned;
if (is_debug_unsigned)
dest->v.uval = tree_to_uhwi (src);
else
dest->v.sval = tree_to_shwi (src);
return true;
}
/* Try to extract synthetic properties out of VARIANT_PART_DECL, which is a
FIELD_DECL in STRUCT_TYPE that represents a variant part. If unsuccessful,
store NULL_TREE in DISCR_DECL. Otherwise:
- store the discriminant field in STRUCT_TYPE that controls the variant
part to *DISCR_DECL
- put in *DISCR_LISTS_P an array where for each variant, the item
represents the corresponding matching list of discriminant values.
- put in *DISCR_LISTS_LENGTH the number of variants, which is the size of
the above array.
Note that when the array is allocated (i.e. when the analysis is
successful), it is up to the caller to free the array. */
static void
analyze_variants_discr (tree variant_part_decl,
tree struct_type,
tree *discr_decl,
dw_discr_list_ref **discr_lists_p,
unsigned *discr_lists_length)
{
tree variant_part_type = TREE_TYPE (variant_part_decl);
tree variant;
dw_discr_list_ref *discr_lists;
unsigned i;
/* Compute how many variants there are in this variant part. */
*discr_lists_length = 0;
for (variant = TYPE_FIELDS (variant_part_type);
variant != NULL_TREE;
variant = DECL_CHAIN (variant))
++*discr_lists_length;
*discr_decl = NULL_TREE;
*discr_lists_p
= (dw_discr_list_ref *) xcalloc (*discr_lists_length,
sizeof (**discr_lists_p));
discr_lists = *discr_lists_p;
/* And then analyze all variants to extract discriminant information for all
of them. This analysis is conservative: as soon as we detect something we
do not support, abort everything and pretend we found nothing. */
for (variant = TYPE_FIELDS (variant_part_type), i = 0;
variant != NULL_TREE;
variant = DECL_CHAIN (variant), ++i)
{
tree match_expr = DECL_QUALIFIER (variant);
/* Now, try to analyze the predicate and deduce a discriminant for
it. */
if (match_expr == boolean_true_node)
/* Typically happens for the default variant: it matches all cases that
previous variants rejected. Don't output any matching value for
this one. */
continue;
/* The following loop tries to iterate over each discriminant
possibility: single values or ranges. */
while (match_expr != NULL_TREE)
{
tree next_round_match_expr;
tree candidate_discr = NULL_TREE;
dw_discr_list_ref new_node = NULL;
/* Possibilities are matched one after the other by nested
TRUTH_ORIF_EXPR expressions. Process the current possibility and
continue with the rest at next iteration. */
if (TREE_CODE (match_expr) == TRUTH_ORIF_EXPR)
{
next_round_match_expr = TREE_OPERAND (match_expr, 0);
match_expr = TREE_OPERAND (match_expr, 1);
}
else
next_round_match_expr = NULL_TREE;
if (match_expr == boolean_false_node)
/* This sub-expression matches nothing: just wait for the next
one. */
;
else if (TREE_CODE (match_expr) == EQ_EXPR)
{
/* We are matching: <discr_field> == <integer_cst>
This sub-expression matches a single value. */
tree integer_cst = TREE_OPERAND (match_expr, 1);
candidate_discr
= analyze_discr_in_predicate (TREE_OPERAND (match_expr, 0),
struct_type);
new_node = ggc_cleared_alloc<dw_discr_list_node> ();
if (!get_discr_value (integer_cst,
&new_node->dw_discr_lower_bound))
goto abort;
new_node->dw_discr_range = false;
}
else if (TREE_CODE (match_expr) == TRUTH_ANDIF_EXPR)
{
/* We are matching:
<discr_field> > <integer_cst>
&& <discr_field> < <integer_cst>.
This sub-expression matches the range of values between the
two matched integer constants. Note that comparisons can be
inclusive or exclusive. */
tree candidate_discr_1, candidate_discr_2;
tree lower_cst, upper_cst;
bool lower_cst_included, upper_cst_included;
tree lower_op = TREE_OPERAND (match_expr, 0);
tree upper_op = TREE_OPERAND (match_expr, 1);
/* When the comparison is exclusive, the integer constant is not
the discriminant range bound we are looking for: we will have
to increment or decrement it. */
if (TREE_CODE (lower_op) == GE_EXPR)
lower_cst_included = true;
else if (TREE_CODE (lower_op) == GT_EXPR)
lower_cst_included = false;
else
goto abort;
if (TREE_CODE (upper_op) == LE_EXPR)
upper_cst_included = true;
else if (TREE_CODE (upper_op) == LT_EXPR)
upper_cst_included = false;
else
goto abort;
/* Extract the discriminant from the first operand and check it
is consistant with the same analysis in the second
operand. */
candidate_discr_1
= analyze_discr_in_predicate (TREE_OPERAND (lower_op, 0),
struct_type);
candidate_discr_2
= analyze_discr_in_predicate (TREE_OPERAND (upper_op, 0),
struct_type);
if (candidate_discr_1 == candidate_discr_2)
candidate_discr = candidate_discr_1;
else
goto abort;
/* Extract bounds from both. */
new_node = ggc_cleared_alloc<dw_discr_list_node> ();
lower_cst = TREE_OPERAND (lower_op, 1);
upper_cst = TREE_OPERAND (upper_op, 1);
if (!lower_cst_included)
lower_cst
= fold_build2 (PLUS_EXPR, TREE_TYPE (lower_cst), lower_cst,
build_int_cst (TREE_TYPE (lower_cst), 1));
if (!upper_cst_included)
upper_cst
= fold_build2 (MINUS_EXPR, TREE_TYPE (upper_cst), upper_cst,
build_int_cst (TREE_TYPE (upper_cst), 1));
if (!get_discr_value (lower_cst,
&new_node->dw_discr_lower_bound)
|| !get_discr_value (upper_cst,
&new_node->dw_discr_upper_bound))
goto abort;
new_node->dw_discr_range = true;
}
else if ((candidate_discr
= analyze_discr_in_predicate (match_expr, struct_type))
&& (TREE_TYPE (candidate_discr) == boolean_type_node
|| TREE_TYPE (TREE_TYPE (candidate_discr))
== boolean_type_node))
{
/* We are matching: <discr_field> for a boolean discriminant.
This sub-expression matches boolean_true_node. */
new_node = ggc_cleared_alloc<dw_discr_list_node> ();
if (!get_discr_value (boolean_true_node,
&new_node->dw_discr_lower_bound))
goto abort;
new_node->dw_discr_range = false;
}
else
/* Unsupported sub-expression: we cannot determine the set of
matching discriminant values. Abort everything. */
goto abort;
/* If the discriminant info is not consistant with what we saw so
far, consider the analysis failed and abort everything. */
if (candidate_discr == NULL_TREE
|| (*discr_decl != NULL_TREE && candidate_discr != *discr_decl))
goto abort;
else
*discr_decl = candidate_discr;
if (new_node != NULL)
{
new_node->dw_discr_next = discr_lists[i];
discr_lists[i] = new_node;
}
match_expr = next_round_match_expr;
}
}
/* If we reach this point, we could match everything we were interested
in. */
return;
abort:
/* Clean all data structure and return no result. */
free (*discr_lists_p);
*discr_lists_p = NULL;
*discr_decl = NULL_TREE;
}
/* Generate a DIE to represent VARIANT_PART_DECL, a variant part that is part
of STRUCT_TYPE, a record type. This new DIE is emitted as the next child
under CONTEXT_DIE.
Variant parts are supposed to be implemented as a FIELD_DECL whose type is a
QUAL_UNION_TYPE: this is the VARIANT_PART_DECL parameter. The members for
this type, which are record types, represent the available variants and each
has a DECL_QUALIFIER attribute. The discriminant and the discriminant
values are inferred from these attributes.
In trees, the offsets for the fields inside these sub-records are relative
to the variant part itself, whereas the corresponding DIEs should have
offset attributes that are relative to the embedding record base address.
This is why the caller must provide a VARIANT_PART_OFFSET expression: it
must be an expression that computes the offset of the variant part to
describe in DWARF. */
static void
gen_variant_part (tree variant_part_decl, struct vlr_context *vlr_ctx,
dw_die_ref context_die)
{
const tree variant_part_type = TREE_TYPE (variant_part_decl);
tree variant_part_offset = vlr_ctx->variant_part_offset;
struct loc_descr_context ctx = {
vlr_ctx->struct_type, /* context_type */
NULL_TREE, /* base_decl */
NULL, /* dpi */
false, /* placeholder_arg */
false /* placeholder_seen */
};
/* The FIELD_DECL node in STRUCT_TYPE that acts as the discriminant, or
NULL_TREE if there is no such field. */
tree discr_decl = NULL_TREE;
dw_discr_list_ref *discr_lists;
unsigned discr_lists_length = 0;
unsigned i;
dw_die_ref dwarf_proc_die = NULL;
dw_die_ref variant_part_die
= new_die (DW_TAG_variant_part, context_die, variant_part_type);
equate_decl_number_to_die (variant_part_decl, variant_part_die);
analyze_variants_discr (variant_part_decl, vlr_ctx->struct_type,
&discr_decl, &discr_lists, &discr_lists_length);
if (discr_decl != NULL_TREE)
{
dw_die_ref discr_die = lookup_decl_die (discr_decl);
if (discr_die)
add_AT_die_ref (variant_part_die, DW_AT_discr, discr_die);
else
/* We have no DIE for the discriminant, so just discard all
discrimimant information in the output. */
discr_decl = NULL_TREE;
}
/* If the offset for this variant part is more complex than a constant,
create a DWARF procedure for it so that we will not have to generate DWARF
expressions for it for each member. */
if (TREE_CODE (variant_part_offset) != INTEGER_CST
&& (dwarf_version >= 3 || !dwarf_strict))
{
const tree dwarf_proc_fndecl
= build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, NULL_TREE,
build_function_type (TREE_TYPE (variant_part_offset),
NULL_TREE));
const tree dwarf_proc_call = build_call_expr (dwarf_proc_fndecl, 0);
const dw_loc_descr_ref dwarf_proc_body
= loc_descriptor_from_tree (variant_part_offset, 0, &ctx);
dwarf_proc_die = new_dwarf_proc_die (dwarf_proc_body,
dwarf_proc_fndecl, context_die);
if (dwarf_proc_die != NULL)
variant_part_offset = dwarf_proc_call;
}
/* Output DIEs for all variants. */
i = 0;
for (tree variant = TYPE_FIELDS (variant_part_type);
variant != NULL_TREE;
variant = DECL_CHAIN (variant), ++i)
{
tree variant_type = TREE_TYPE (variant);
dw_die_ref variant_die;
/* All variants (i.e. members of a variant part) are supposed to be
encoded as structures. Sub-variant parts are QUAL_UNION_TYPE fields
under these records. */
gcc_assert (TREE_CODE (variant_type) == RECORD_TYPE);
variant_die = new_die (DW_TAG_variant, variant_part_die, variant_type);
equate_decl_number_to_die (variant, variant_die);
/* Output discriminant values this variant matches, if any. */
if (discr_decl == NULL || discr_lists[i] == NULL)
/* In the case we have discriminant information at all, this is
probably the default variant: as the standard says, don't
output any discriminant value/list attribute. */
;
else if (discr_lists[i]->dw_discr_next == NULL
&& !discr_lists[i]->dw_discr_range)
/* If there is only one accepted value, don't bother outputting a
list. */
add_discr_value (variant_die, &discr_lists[i]->dw_discr_lower_bound);
else
add_discr_list (variant_die, discr_lists[i]);
for (tree member = TYPE_FIELDS (variant_type);
member != NULL_TREE;
member = DECL_CHAIN (member))
{
struct vlr_context vlr_sub_ctx = {
vlr_ctx->struct_type, /* struct_type */
NULL /* variant_part_offset */
};
if (is_variant_part (member))
{
/* All offsets for fields inside variant parts are relative to
the top-level embedding RECORD_TYPE's base address. On the
other hand, offsets in GCC's types are relative to the
nested-most variant part. So we have to sum offsets each time
we recurse. */
vlr_sub_ctx.variant_part_offset
= fold_build2 (PLUS_EXPR, TREE_TYPE (variant_part_offset),
variant_part_offset, byte_position (member));
gen_variant_part (member, &vlr_sub_ctx, variant_die);
}
else
{
vlr_sub_ctx.variant_part_offset = variant_part_offset;
gen_decl_die (member, NULL, &vlr_sub_ctx, variant_die);
}
}
}
free (discr_lists);
}
/* Generate a DIE for a class member. */
static void
gen_member_die (tree type, dw_die_ref context_die)
{
tree member;
tree binfo = TYPE_BINFO (type);
gcc_assert (TYPE_MAIN_VARIANT (type) == type);
/* If this is not an incomplete type, output descriptions of each of its
members. Note that as we output the DIEs necessary to represent the
members of this record or union type, we will also be trying to output
DIEs to represent the *types* of those members. However the `type'
function (above) will specifically avoid generating type DIEs for member
types *within* the list of member DIEs for this (containing) type except
for those types (of members) which are explicitly marked as also being
members of this (containing) type themselves. The g++ front- end can
force any given type to be treated as a member of some other (containing)
type by setting the TYPE_CONTEXT of the given (member) type to point to
the TREE node representing the appropriate (containing) type. */
/* First output info about the base classes. */
if (binfo && early_dwarf)
{
vec<tree, va_gc> *accesses = BINFO_BASE_ACCESSES (binfo);
int i;
tree base;
for (i = 0; BINFO_BASE_ITERATE (binfo, i, base); i++)
gen_inheritance_die (base,
(accesses ? (*accesses)[i] : access_public_node),
type,
context_die);
}
/* Now output info about the members. */
for (member = TYPE_FIELDS (type); member; member = DECL_CHAIN (member))
{
/* Ignore clones. */
if (DECL_ABSTRACT_ORIGIN (member))
continue;
struct vlr_context vlr_ctx = { type, NULL_TREE };
bool static_inline_p
= (VAR_P (member)
&& TREE_STATIC (member)
&& (lang_hooks.decls.decl_dwarf_attribute (member, DW_AT_inline)
!= -1));
/* If we thought we were generating minimal debug info for TYPE
and then changed our minds, some of the member declarations
may have already been defined. Don't define them again, but
do put them in the right order. */
if (dw_die_ref child = lookup_decl_die (member))
{
/* Handle inline static data members, which only have in-class
declarations. */
bool splice = true;
dw_die_ref ref = NULL;
if (child->die_tag == DW_TAG_variable
&& child->die_parent == comp_unit_die ())
{
ref = get_AT_ref (child, DW_AT_specification);
/* For C++17 inline static data members followed by redundant
out of class redeclaration, we might get here with
child being the DIE created for the out of class
redeclaration and with its DW_AT_specification being
the DIE created for in-class definition. We want to
reparent the latter, and don't want to create another
DIE with DW_AT_specification in that case, because
we already have one. */
if (ref
&& static_inline_p
&& ref->die_tag == DW_TAG_variable
&& ref->die_parent == comp_unit_die ()
&& get_AT (ref, DW_AT_specification) == NULL)
{
child = ref;
ref = NULL;
static_inline_p = false;
}
if (!ref)
{
reparent_child (child, context_die);
if (dwarf_version < 5)
child->die_tag = DW_TAG_member;
splice = false;
}
}
else if (child->die_tag == DW_TAG_enumerator)
/* Enumerators remain under their enumeration even if
their names are introduced in the enclosing scope. */
splice = false;
if (splice)
splice_child_die (context_die, child);
}
/* Do not generate standard DWARF for variant parts if we are generating
the corresponding GNAT encodings: DIEs generated for both would
conflict in our mappings. */
else if (is_variant_part (member)
&& gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
{
vlr_ctx.variant_part_offset = byte_position (member);
gen_variant_part (member, &vlr_ctx, context_die);
}
else
{
vlr_ctx.variant_part_offset = NULL_TREE;
gen_decl_die (member, NULL, &vlr_ctx, context_die);
}
/* For C++ inline static data members emit immediately a DW_TAG_variable
DIE that will refer to that DW_TAG_member/DW_TAG_variable through
DW_AT_specification. */
if (static_inline_p)
{
int old_extern = DECL_EXTERNAL (member);
DECL_EXTERNAL (member) = 0;
gen_decl_die (member, NULL, NULL, comp_unit_die ());
DECL_EXTERNAL (member) = old_extern;
}
}
}
/* Generate a DIE for a structure or union type. If TYPE_DECL_SUPPRESS_DEBUG
is set, we pretend that the type was never defined, so we only get the
member DIEs needed by later specification DIEs. */
static void
gen_struct_or_union_type_die (tree type, dw_die_ref context_die,
enum debug_info_usage usage)
{
if (TREE_ASM_WRITTEN (type))
{
/* Fill in the bound of variable-length fields in late dwarf if
still incomplete. */
if (!early_dwarf && variably_modified_type_p (type, NULL))
for (tree member = TYPE_FIELDS (type);
member;
member = DECL_CHAIN (member))
fill_variable_array_bounds (TREE_TYPE (member));
return;
}
dw_die_ref type_die = lookup_type_die (type);
dw_die_ref scope_die = 0;
int nested = 0;
int complete = (TYPE_SIZE (type)
&& (! TYPE_STUB_DECL (type)
|| ! TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type))));
int ns_decl = (context_die && context_die->die_tag == DW_TAG_namespace);
complete = complete && should_emit_struct_debug (type, usage);
if (type_die && ! complete)
return;
if (TYPE_CONTEXT (type) != NULL_TREE
&& (AGGREGATE_TYPE_P (TYPE_CONTEXT (type))
|| TREE_CODE (TYPE_CONTEXT (type)) == NAMESPACE_DECL))
nested = 1;
scope_die = scope_die_for (type, context_die);
/* Generate child dies for template paramaters. */
if (!type_die && debug_info_level > DINFO_LEVEL_TERSE)
schedule_generic_params_dies_gen (type);
if (! type_die || (nested && is_cu_die (scope_die)))
/* First occurrence of type or toplevel definition of nested class. */
{
dw_die_ref old_die = type_die;
type_die = new_die (TREE_CODE (type) == RECORD_TYPE
? record_type_tag (type) : DW_TAG_union_type,
scope_die, type);
equate_type_number_to_die (type, type_die);
if (old_die)
add_AT_specification (type_die, old_die);
else
add_name_attribute (type_die, type_tag (type));
}
else
remove_AT (type_die, DW_AT_declaration);
/* If this type has been completed, then give it a byte_size attribute and
then give a list of members. */
if (complete && !ns_decl)
{
/* Prevent infinite recursion in cases where the type of some member of
this type is expressed in terms of this type itself. */
TREE_ASM_WRITTEN (type) = 1;
add_byte_size_attribute (type_die, type);
add_alignment_attribute (type_die, type);
if (TYPE_STUB_DECL (type) != NULL_TREE)
{
add_src_coords_attributes (type_die, TYPE_STUB_DECL (type));
add_accessibility_attribute (type_die, TYPE_STUB_DECL (type));
}
/* If the first reference to this type was as the return type of an
inline function, then it may not have a parent. Fix this now. */
if (type_die->die_parent == NULL)
add_child_die (scope_die, type_die);
gen_member_die (type, type_die);
add_gnat_descriptive_type_attribute (type_die, type, context_die);
if (TYPE_ARTIFICIAL (type))
add_AT_flag (type_die, DW_AT_artificial, 1);
/* GNU extension: Record what type our vtable lives in. */
if (TYPE_VFIELD (type))
{
tree vtype = DECL_FCONTEXT (TYPE_VFIELD (type));
gen_type_die (vtype, context_die);
add_AT_die_ref (type_die, DW_AT_containing_type,
lookup_type_die (vtype));
}
}
else
{
add_AT_flag (type_die, DW_AT_declaration, 1);
/* We don't need to do this for function-local types. */
if (TYPE_STUB_DECL (type)
&& ! decl_function_context (TYPE_STUB_DECL (type)))
vec_safe_push (incomplete_types, type);
}
if (get_AT (type_die, DW_AT_name))
add_pubtype (type, type_die);
}
/* Generate a DIE for a subroutine _type_. */
static void
gen_subroutine_type_die (tree type, dw_die_ref context_die)
{
tree return_type = TREE_TYPE (type);
dw_die_ref subr_die
= new_die (DW_TAG_subroutine_type,
scope_die_for (type, context_die), type);
equate_type_number_to_die (type, subr_die);
add_prototyped_attribute (subr_die, type);
add_type_attribute (subr_die, return_type, TYPE_UNQUALIFIED, false,
context_die);
add_alignment_attribute (subr_die, type);
gen_formal_types_die (type, subr_die);
if (get_AT (subr_die, DW_AT_name))
add_pubtype (type, subr_die);
if ((dwarf_version >= 5 || !dwarf_strict)
&& lang_hooks.types.type_dwarf_attribute (type, DW_AT_reference) != -1)
add_AT_flag (subr_die, DW_AT_reference, 1);
if ((dwarf_version >= 5 || !dwarf_strict)
&& lang_hooks.types.type_dwarf_attribute (type,
DW_AT_rvalue_reference) != -1)
add_AT_flag (subr_die, DW_AT_rvalue_reference, 1);
}
/* Generate a DIE for a type definition. */
static void
gen_typedef_die (tree decl, dw_die_ref context_die)
{
dw_die_ref type_die;
tree type;
if (TREE_ASM_WRITTEN (decl))
{
if (DECL_ORIGINAL_TYPE (decl))
fill_variable_array_bounds (DECL_ORIGINAL_TYPE (decl));
return;
}
/* As we avoid creating DIEs for local typedefs (see decl_ultimate_origin
checks in process_scope_var and modified_type_die), this should be called
only for original types. */
gcc_assert (decl_ultimate_origin (decl) == NULL
|| decl_ultimate_origin (decl) == decl);
TREE_ASM_WRITTEN (decl) = 1;
type_die = new_die (DW_TAG_typedef, context_die, decl);
add_name_and_src_coords_attributes (type_die, decl);
if (DECL_ORIGINAL_TYPE (decl))
{
type = DECL_ORIGINAL_TYPE (decl);
if (type == error_mark_node)
return;
gcc_assert (type != TREE_TYPE (decl));
equate_type_number_to_die (TREE_TYPE (decl), type_die);
}
else
{
type = TREE_TYPE (decl);
if (type == error_mark_node)
return;
if (is_naming_typedef_decl (TYPE_NAME (type)))
{
/* Here, we are in the case of decl being a typedef naming
an anonymous type, e.g:
typedef struct {...} foo;
In that case TREE_TYPE (decl) is not a typedef variant
type and TYPE_NAME of the anonymous type is set to the
TYPE_DECL of the typedef. This construct is emitted by
the C++ FE.
TYPE is the anonymous struct named by the typedef
DECL. As we need the DW_AT_type attribute of the
DW_TAG_typedef to point to the DIE of TYPE, let's
generate that DIE right away. add_type_attribute
called below will then pick (via lookup_type_die) that
anonymous struct DIE. */
if (!TREE_ASM_WRITTEN (type))
gen_tagged_type_die (type, context_die, DINFO_USAGE_DIR_USE);
/* This is a GNU Extension. We are adding a
DW_AT_linkage_name attribute to the DIE of the
anonymous struct TYPE. The value of that attribute
is the name of the typedef decl naming the anonymous
struct. This greatly eases the work of consumers of
this debug info. */
add_linkage_name_raw (lookup_type_die (type), decl);
}
}
add_type_attribute (type_die, type, decl_quals (decl), false,
context_die);
if (is_naming_typedef_decl (decl))
/* We want that all subsequent calls to lookup_type_die with
TYPE in argument yield the DW_TAG_typedef we have just
created. */
equate_type_number_to_die (type, type_die);
add_alignment_attribute (type_die, TREE_TYPE (decl));
add_accessibility_attribute (type_die, decl);
if (DECL_ABSTRACT_P (decl))
equate_decl_number_to_die (decl, type_die);
if (get_AT (type_die, DW_AT_name))
add_pubtype (decl, type_die);
}
/* Generate a DIE for a struct, class, enum or union type. */
static void
gen_tagged_type_die (tree type,
dw_die_ref context_die,
enum debug_info_usage usage)
{
if (type == NULL_TREE
|| !is_tagged_type (type))
return;
if (TREE_ASM_WRITTEN (type))
;
/* If this is a nested type whose containing class hasn't been written
out yet, writing it out will cover this one, too. This does not apply
to instantiations of member class templates; they need to be added to
the containing class as they are generated. FIXME: This hurts the
idea of combining type decls from multiple TUs, since we can't predict
what set of template instantiations we'll get. */
else if (TYPE_CONTEXT (type)
&& AGGREGATE_TYPE_P (TYPE_CONTEXT (type))
&& ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
{
gen_type_die_with_usage (TYPE_CONTEXT (type), context_die, usage);
if (TREE_ASM_WRITTEN (type))
return;
/* If that failed, attach ourselves to the stub. */
context_die = lookup_type_die (TYPE_CONTEXT (type));
}
else if (TYPE_CONTEXT (type) != NULL_TREE
&& (TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL))
{
/* If this type is local to a function that hasn't been written
out yet, use a NULL context for now; it will be fixed up in
decls_for_scope. */
context_die = lookup_decl_die (TYPE_CONTEXT (type));
/* A declaration DIE doesn't count; nested types need to go in the
specification. */
if (context_die && is_declaration_die (context_die))
context_die = NULL;
}
else
context_die = declare_in_namespace (type, context_die);
if (TREE_CODE (type) == ENUMERAL_TYPE)
{
/* This might have been written out by the call to
declare_in_namespace. */
if (!TREE_ASM_WRITTEN (type))
gen_enumeration_type_die (type, context_die);
}
else
gen_struct_or_union_type_die (type, context_die, usage);
/* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix
it up if it is ever completed. gen_*_type_die will set it for us
when appropriate. */
}
/* Generate a type description DIE. */
static void
gen_type_die_with_usage (tree type, dw_die_ref context_die,
enum debug_info_usage usage)
{
struct array_descr_info info;
if (type == NULL_TREE || type == error_mark_node)
return;
if (flag_checking && type)
verify_type (type);
if (TYPE_NAME (type) != NULL_TREE
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& is_redundant_typedef (TYPE_NAME (type))
&& DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
/* The DECL of this type is a typedef we don't want to emit debug
info for but we want debug info for its underlying typedef.
This can happen for e.g, the injected-class-name of a C++
type. */
type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
/* If TYPE is a typedef type variant, let's generate debug info
for the parent typedef which TYPE is a type of. */
if (typedef_variant_p (type))
{
if (TREE_ASM_WRITTEN (type))
return;
tree name = TYPE_NAME (type);
tree origin = decl_ultimate_origin (name);
if (origin != NULL && origin != name)
{
gen_decl_die (origin, NULL, NULL, context_die);
return;
}
/* Prevent broken recursion; we can't hand off to the same type. */
gcc_assert (DECL_ORIGINAL_TYPE (name) != type);
/* Give typedefs the right scope. */
context_die = scope_die_for (type, context_die);
TREE_ASM_WRITTEN (type) = 1;
gen_decl_die (name, NULL, NULL, context_die);
return;
}
/* If type is an anonymous tagged type named by a typedef, let's
generate debug info for the typedef. */
if (is_naming_typedef_decl (TYPE_NAME (type)))
{
/* Give typedefs the right scope. */
context_die = scope_die_for (type, context_die);
gen_decl_die (TYPE_NAME (type), NULL, NULL, context_die);
return;
}
if (lang_hooks.types.get_debug_type)
{
tree debug_type = lang_hooks.types.get_debug_type (type);
if (debug_type != NULL_TREE && debug_type != type)
{
gen_type_die_with_usage (debug_type, context_die, usage);
return;
}
}
/* We are going to output a DIE to represent the unqualified version
of this type (i.e. without any const or volatile qualifiers) so
get the main variant (i.e. the unqualified version) of this type
now. (Vectors and arrays are special because the debugging info is in the
cloned type itself. Similarly function/method types can contain extra
ref-qualification). */
if (TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == METHOD_TYPE)
{
/* For function/method types, can't use type_main_variant here,
because that can have different ref-qualifiers for C++,
but try to canonicalize. */
tree main = TYPE_MAIN_VARIANT (type);
for (tree t = main; t; t = TYPE_NEXT_VARIANT (t))
if (TYPE_QUALS_NO_ADDR_SPACE (t) == 0
&& check_base_type (t, main)
&& check_lang_type (t, type))
{
type = t;
break;
}
}
else if (TREE_CODE (type) != VECTOR_TYPE
&& TREE_CODE (type) != ARRAY_TYPE)
type = type_main_variant (type);
/* If this is an array type with hidden descriptor, handle it first. */
if (!TREE_ASM_WRITTEN (type)
&& lang_hooks.types.get_array_descr_info)
{
memset (&info, 0, sizeof (info));
if (lang_hooks.types.get_array_descr_info (type, &info))
{
/* Fortran sometimes emits array types with no dimension. */
gcc_assert (info.ndimensions >= 0
&& (info.ndimensions
<= DWARF2OUT_ARRAY_DESCR_INFO_MAX_DIMEN));
gen_descr_array_type_die (type, &info, context_die);
TREE_ASM_WRITTEN (type) = 1;
return;
}
}
if (TREE_ASM_WRITTEN (type))
{
/* Variable-length types may be incomplete even if
TREE_ASM_WRITTEN. For such types, fall through to
gen_array_type_die() and possibly fill in
DW_AT_{upper,lower}_bound attributes. */
if ((TREE_CODE (type) != ARRAY_TYPE
&& TREE_CODE (type) != RECORD_TYPE
&& TREE_CODE (type) != UNION_TYPE
&& TREE_CODE (type) != QUAL_UNION_TYPE)
|| !variably_modified_type_p (type, NULL))
return;
}
switch (TREE_CODE (type))
{
case ERROR_MARK:
break;
case POINTER_TYPE:
case REFERENCE_TYPE:
/* We must set TREE_ASM_WRITTEN in case this is a recursive type. This
ensures that the gen_type_die recursion will terminate even if the
type is recursive. Recursive types are possible in Ada. */
/* ??? We could perhaps do this for all types before the switch
statement. */
TREE_ASM_WRITTEN (type) = 1;
/* For these types, all that is required is that we output a DIE (or a
set of DIEs) to represent the "basis" type. */
gen_type_die_with_usage (TREE_TYPE (type), context_die,
DINFO_USAGE_IND_USE);
break;
case OFFSET_TYPE:
/* This code is used for C++ pointer-to-data-member types.
Output a description of the relevant class type. */
gen_type_die_with_usage (TYPE_OFFSET_BASETYPE (type), context_die,
DINFO_USAGE_IND_USE);
/* Output a description of the type of the object pointed to. */
gen_type_die_with_usage (TREE_TYPE (type), context_die,
DINFO_USAGE_IND_USE);
/* Now output a DIE to represent this pointer-to-data-member type
itself. */
gen_ptr_to_mbr_type_die (type, context_die);
break;
case FUNCTION_TYPE:
/* Force out return type (in case it wasn't forced out already). */
gen_type_die_with_usage (TREE_TYPE (type), context_die,
DINFO_USAGE_DIR_USE);
gen_subroutine_type_die (type, context_die);
break;
case METHOD_TYPE:
/* Force out return type (in case it wasn't forced out already). */
gen_type_die_with_usage (TREE_TYPE (type), context_die,
DINFO_USAGE_DIR_USE);
gen_subroutine_type_die (type, context_die);
break;
case ARRAY_TYPE:
case VECTOR_TYPE:
gen_array_type_die (type, context_die);
break;
case ENUMERAL_TYPE:
case RECORD_TYPE:
case UNION_TYPE:
case QUAL_UNION_TYPE:
gen_tagged_type_die (type, context_die, usage);
return;
case VOID_TYPE:
case OPAQUE_TYPE:
case INTEGER_TYPE:
case REAL_TYPE:
case FIXED_POINT_TYPE:
case COMPLEX_TYPE:
case BOOLEAN_TYPE:
/* No DIEs needed for fundamental types. */
break;
case NULLPTR_TYPE:
case LANG_TYPE:
/* Just use DW_TAG_unspecified_type. */
{
dw_die_ref type_die = lookup_type_die (type);
if (type_die == NULL)
{
tree name = TYPE_IDENTIFIER (type);
type_die = new_die (DW_TAG_unspecified_type, comp_unit_die (),
type);
add_name_attribute (type_die, IDENTIFIER_POINTER (name));
equate_type_number_to_die (type, type_die);
}
}
break;
default:
if (is_cxx_auto (type))
{
tree name = TYPE_IDENTIFIER (type);
dw_die_ref *die = (name == get_identifier ("auto")
? &auto_die : &decltype_auto_die);
if (!*die)
{
*die = new_die (DW_TAG_unspecified_type,
comp_unit_die (), NULL_TREE);
add_name_attribute (*die, IDENTIFIER_POINTER (name));
}
equate_type_number_to_die (type, *die);
break;
}
gcc_unreachable ();
}
TREE_ASM_WRITTEN (type) = 1;
}
static void
gen_type_die (tree type, dw_die_ref context_die)
{
if (type != error_mark_node)
{
gen_type_die_with_usage (type, context_die, DINFO_USAGE_DIR_USE);
if (flag_checking)
{
dw_die_ref die = lookup_type_die (type);
if (die)
check_die (die);
}
}
}
/* Generate a DW_TAG_lexical_block DIE followed by DIEs to represent all of the
things which are local to the given block. */
static void
gen_block_die (tree stmt, dw_die_ref context_die)
{
int must_output_die = 0;
bool inlined_func;
/* Ignore blocks that are NULL. */
if (stmt == NULL_TREE)
return;
inlined_func = inlined_function_outer_scope_p (stmt);
/* If the block is one fragment of a non-contiguous block, do not
process the variables, since they will have been done by the
origin block. Do process subblocks. */
if (BLOCK_FRAGMENT_ORIGIN (stmt))
{
tree sub;
for (sub = BLOCK_SUBBLOCKS (stmt); sub; sub = BLOCK_CHAIN (sub))
gen_block_die (sub, context_die);
return;
}
/* Determine if we need to output any Dwarf DIEs at all to represent this
block. */
if (inlined_func)
/* The outer scopes for inlinings *must* always be represented. We
generate DW_TAG_inlined_subroutine DIEs for them. (See below.) */
must_output_die = 1;
else if (lookup_block_die (stmt))
/* If we already have a DIE then it was filled early. Meanwhile
we might have pruned all BLOCK_VARS as optimized out but we
still want to generate high/low PC attributes so output it. */
must_output_die = 1;
else if (TREE_USED (stmt)
|| TREE_ASM_WRITTEN (stmt))
{
/* Determine if this block directly contains any "significant"
local declarations which we will need to output DIEs for. */
if (debug_info_level > DINFO_LEVEL_TERSE)
{
/* We are not in terse mode so any local declaration that
is not ignored for debug purposes counts as being a
"significant" one. */
if (BLOCK_NUM_NONLOCALIZED_VARS (stmt))
must_output_die = 1;
else
for (tree var = BLOCK_VARS (stmt); var; var = DECL_CHAIN (var))
if (!DECL_IGNORED_P (var))
{
must_output_die = 1;
break;
}
}
else if (!dwarf2out_ignore_block (stmt))
must_output_die = 1;
}
/* It would be a waste of space to generate a Dwarf DW_TAG_lexical_block
DIE for any block which contains no significant local declarations at
all. Rather, in such cases we just call `decls_for_scope' so that any
needed Dwarf info for any sub-blocks will get properly generated. Note
that in terse mode, our definition of what constitutes a "significant"
local declaration gets restricted to include only inlined function
instances and local (nested) function definitions. */
if (must_output_die)
{
if (inlined_func)
gen_inlined_subroutine_die (stmt, context_die);
else
gen_lexical_block_die (stmt, context_die);
}
else
decls_for_scope (stmt, context_die);
}
/* Process variable DECL (or variable with origin ORIGIN) within
block STMT and add it to CONTEXT_DIE. */
static void
process_scope_var (tree stmt, tree decl, tree origin, dw_die_ref context_die)
{
dw_die_ref die;
tree decl_or_origin = decl ? decl : origin;
if (TREE_CODE (decl_or_origin) == FUNCTION_DECL)
die = lookup_decl_die (decl_or_origin);
else if (TREE_CODE (decl_or_origin) == TYPE_DECL)
{
if (TYPE_DECL_IS_STUB (decl_or_origin))
die = lookup_type_die (TREE_TYPE (decl_or_origin));
else
die = lookup_decl_die (decl_or_origin);
/* Avoid re-creating the DIE late if it was optimized as unused early. */
if (! die && ! early_dwarf)
return;
}
else
die = NULL;
/* Avoid creating DIEs for local typedefs and concrete static variables that
will only be pruned later. */
if ((origin || decl_ultimate_origin (decl))
&& (TREE_CODE (decl_or_origin) == TYPE_DECL
|| (VAR_P (decl_or_origin) && TREE_STATIC (decl_or_origin))))
{
origin = decl_ultimate_origin (decl_or_origin);
if (decl && VAR_P (decl) && die != NULL)
{
die = lookup_decl_die (origin);
if (die != NULL)
equate_decl_number_to_die (decl, die);
}
return;
}
if (die != NULL && die->die_parent == NULL)
add_child_die (context_die, die);
else if (TREE_CODE (decl_or_origin) == IMPORTED_DECL)
{
if (early_dwarf)
dwarf2out_imported_module_or_decl_1 (decl_or_origin, DECL_NAME (decl_or_origin),
stmt, context_die);
}
else
{
if (decl && DECL_P (decl))
{
die = lookup_decl_die (decl);
/* Early created DIEs do not have a parent as the decls refer
to the function as DECL_CONTEXT rather than the BLOCK. */
if (die && die->die_parent == NULL)
{
gcc_assert (in_lto_p);
add_child_die (context_die, die);
}
}
gen_decl_die (decl, origin, NULL, context_die);
}
}
/* Generate all of the decls declared within a given scope and (recursively)
all of its sub-blocks. */
static void
decls_for_scope (tree stmt, dw_die_ref context_die, bool recurse)
{
tree decl;
unsigned int i;
tree subblocks;
/* Ignore NULL blocks. */
if (stmt == NULL_TREE)
return;
/* Output the DIEs to represent all of the data objects and typedefs
declared directly within this block but not within any nested
sub-blocks. Also, nested function and tag DIEs have been
generated with a parent of NULL; fix that up now. We don't
have to do this if we're at -g1. */
if (debug_info_level > DINFO_LEVEL_TERSE)
{
for (decl = BLOCK_VARS (stmt); decl != NULL; decl = DECL_CHAIN (decl))
process_scope_var (stmt, decl, NULL_TREE, context_die);
/* BLOCK_NONLOCALIZED_VARs simply generate DIE stubs with abstract
origin - avoid doing this twice as we have no good way to see
if we've done it once already. */
if (! early_dwarf)
for (i = 0; i < BLOCK_NUM_NONLOCALIZED_VARS (stmt); i++)
{
decl = BLOCK_NONLOCALIZED_VAR (stmt, i);
if (decl == current_function_decl)
/* Ignore declarations of the current function, while they
are declarations, gen_subprogram_die would treat them
as definitions again, because they are equal to
current_function_decl and endlessly recurse. */;
else if (TREE_CODE (decl) == FUNCTION_DECL)
process_scope_var (stmt, decl, NULL_TREE, context_die);
else
process_scope_var (stmt, NULL_TREE, decl, context_die);
}
}
/* Even if we're at -g1, we need to process the subblocks in order to get
inlined call information. */
/* Output the DIEs to represent all sub-blocks (and the items declared
therein) of this block. */
if (recurse)
for (subblocks = BLOCK_SUBBLOCKS (stmt);
subblocks != NULL;
subblocks = BLOCK_CHAIN (subblocks))
gen_block_die (subblocks, context_die);
}
/* Is this a typedef we can avoid emitting? */
static bool
is_redundant_typedef (const_tree decl)
{
if (TYPE_DECL_IS_STUB (decl))
return true;
if (DECL_ARTIFICIAL (decl)
&& DECL_CONTEXT (decl)
&& is_tagged_type (DECL_CONTEXT (decl))
&& TREE_CODE (TYPE_NAME (DECL_CONTEXT (decl))) == TYPE_DECL
&& DECL_NAME (decl) == DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl))))
/* Also ignore the artificial member typedef for the class name. */
return true;
return false;
}
/* Return TRUE if TYPE is a typedef that names a type for linkage
purposes. This kind of typedefs is produced by the C++ FE for
constructs like:
typedef struct {...} foo;
In that case, there is no typedef variant type produced for foo.
Rather, the TREE_TYPE of the TYPE_DECL of foo is the anonymous
struct type. */
static bool
is_naming_typedef_decl (const_tree decl)
{
if (decl == NULL_TREE
|| TREE_CODE (decl) != TYPE_DECL
|| DECL_NAMELESS (decl)
|| !is_tagged_type (TREE_TYPE (decl))
|| DECL_IS_UNDECLARED_BUILTIN (decl)
|| is_redundant_typedef (decl)
/* It looks like Ada produces TYPE_DECLs that are very similar
to C++ naming typedefs but that have different
semantics. Let's be specific to c++ for now. */
|| !is_cxx (decl))
return FALSE;
return (DECL_ORIGINAL_TYPE (decl) == NULL_TREE
&& TYPE_NAME (TREE_TYPE (decl)) == decl
&& (TYPE_STUB_DECL (TREE_TYPE (decl))
!= TYPE_NAME (TREE_TYPE (decl))));
}
/* Looks up the DIE for a context. */
static inline dw_die_ref
lookup_context_die (tree context)
{
if (context)
{
/* Find die that represents this context. */
if (TYPE_P (context))
{
context = TYPE_MAIN_VARIANT (context);
dw_die_ref ctx = lookup_type_die (context);
if (!ctx)
return NULL;
return strip_naming_typedef (context, ctx);
}
else
return lookup_decl_die (context);
}
return comp_unit_die ();
}
/* Returns the DIE for a context. */
static inline dw_die_ref
get_context_die (tree context)
{
if (context)
{
/* Find die that represents this context. */
if (TYPE_P (context))
{
context = TYPE_MAIN_VARIANT (context);
return strip_naming_typedef (context, force_type_die (context));
}
else
return force_decl_die (context);
}
return comp_unit_die ();
}
/* Returns the DIE for decl. A DIE will always be returned. */
static dw_die_ref
force_decl_die (tree decl)
{
dw_die_ref decl_die;
unsigned saved_external_flag;
tree save_fn = NULL_TREE;
decl_die = lookup_decl_die (decl);
if (!decl_die)
{
dw_die_ref context_die = get_context_die (DECL_CONTEXT (decl));
decl_die = lookup_decl_die (decl);
if (decl_die)
return decl_die;
switch (TREE_CODE (decl))
{
case FUNCTION_DECL:
/* Clear current_function_decl, so that gen_subprogram_die thinks
that this is a declaration. At this point, we just want to force
declaration die. */
save_fn = current_function_decl;
current_function_decl = NULL_TREE;
gen_subprogram_die (decl, context_die);
current_function_decl = save_fn;
break;
case VAR_DECL:
/* Set external flag to force declaration die. Restore it after
gen_decl_die() call. */
saved_external_flag = DECL_EXTERNAL (decl);
DECL_EXTERNAL (decl) = 1;
gen_decl_die (decl, NULL, NULL, context_die);
DECL_EXTERNAL (decl) = saved_external_flag;
break;
case NAMESPACE_DECL:
if (dwarf_version >= 3 || !dwarf_strict)
dwarf2out_decl (decl);
else
/* DWARF2 has neither DW_TAG_module, nor DW_TAG_namespace. */
decl_die = comp_unit_die ();
break;
case CONST_DECL:
/* Enumerators shouldn't need force_decl_die. */
gcc_assert (DECL_CONTEXT (decl) == NULL_TREE
|| TREE_CODE (DECL_CONTEXT (decl)) != ENUMERAL_TYPE);
gen_decl_die (decl, NULL, NULL, context_die);
break;
case TRANSLATION_UNIT_DECL:
decl_die = comp_unit_die ();
break;
default:
gcc_unreachable ();
}
/* We should be able to find the DIE now. */
if (!decl_die)
decl_die = lookup_decl_die (decl);
gcc_assert (decl_die);
}
return decl_die;
}
/* Returns the DIE for TYPE, that must not be a base type. A DIE is
always returned. */
static dw_die_ref
force_type_die (tree type)
{
dw_die_ref type_die;
type_die = lookup_type_die (type);
if (!type_die)
{
dw_die_ref context_die = get_context_die (TYPE_CONTEXT (type));
type_die = modified_type_die (type, TYPE_QUALS_NO_ADDR_SPACE (type),
false, context_die);
gcc_assert (type_die);
}
return type_die;
}
/* Force out any required namespaces to be able to output DECL,
and return the new context_die for it, if it's changed. */
static dw_die_ref
setup_namespace_context (tree thing, dw_die_ref context_die)
{
tree context = (DECL_P (thing)
? DECL_CONTEXT (thing) : TYPE_CONTEXT (thing));
if (context && TREE_CODE (context) == NAMESPACE_DECL)
/* Force out the namespace. */
context_die = force_decl_die (context);
return context_die;
}
/* Emit a declaration DIE for THING (which is either a DECL or a tagged
type) within its namespace, if appropriate.
For compatibility with older debuggers, namespace DIEs only contain
declarations; all definitions are emitted at CU scope, with
DW_AT_specification pointing to the declaration (like with class
members). */
static dw_die_ref
declare_in_namespace (tree thing, dw_die_ref context_die)
{
dw_die_ref ns_context;
if (debug_info_level <= DINFO_LEVEL_TERSE)
return context_die;
/* External declarations in the local scope only need to be emitted
once, not once in the namespace and once in the scope.
This avoids declaring the `extern' below in the
namespace DIE as well as in the innermost scope:
namespace S
{
int i=5;
int foo()
{
int i=8;
extern int i;
return i;
}
}
*/
if (DECL_P (thing) && DECL_EXTERNAL (thing) && local_scope_p (context_die))
return context_die;
/* If this decl is from an inlined function, then don't try to emit it in its
namespace, as we will get confused. It would have already been emitted
when the abstract instance of the inline function was emitted anyways. */
if (DECL_P (thing) && DECL_ABSTRACT_ORIGIN (thing))
return context_die;
ns_context = setup_namespace_context (thing, context_die);
if (ns_context != context_die)
{
if (is_fortran () || is_dlang ())
return ns_context;
if (DECL_P (thing))
gen_decl_die (thing, NULL, NULL, ns_context);
else
gen_type_die (thing, ns_context);
}
return context_die;
}
/* Generate a DIE for a namespace or namespace alias. */
static void
gen_namespace_die (tree decl, dw_die_ref context_die)
{
dw_die_ref namespace_die;
/* Namespace aliases have a DECL_ABSTRACT_ORIGIN of the namespace
they are an alias of. */
if (DECL_ABSTRACT_ORIGIN (decl) == NULL)
{
/* Output a real namespace or module. */
context_die = setup_namespace_context (decl, comp_unit_die ());
namespace_die = new_die (is_fortran () || is_dlang ()
? DW_TAG_module : DW_TAG_namespace,
context_die, decl);
/* For Fortran modules defined in different CU don't add src coords. */
if (namespace_die->die_tag == DW_TAG_module && DECL_EXTERNAL (decl))
{
const char *name = dwarf2_name (decl, 0);
if (name)
add_name_attribute (namespace_die, name);
}
else
add_name_and_src_coords_attributes (namespace_die, decl);
if (DECL_EXTERNAL (decl))
add_AT_flag (namespace_die, DW_AT_declaration, 1);
equate_decl_number_to_die (decl, namespace_die);
}
else
{
/* Output a namespace alias. */
/* Force out the namespace we are an alias of, if necessary. */
dw_die_ref origin_die
= force_decl_die (DECL_ABSTRACT_ORIGIN (decl));
if (DECL_FILE_SCOPE_P (decl)
|| TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL)
context_die = setup_namespace_context (decl, comp_unit_die ());
/* Now create the namespace alias DIE. */
namespace_die = new_die (DW_TAG_imported_declaration, context_die, decl);
add_name_and_src_coords_attributes (namespace_die, decl);
add_AT_die_ref (namespace_die, DW_AT_import, origin_die);
equate_decl_number_to_die (decl, namespace_die);
}
if ((dwarf_version >= 5 || !dwarf_strict)
&& lang_hooks.decls.decl_dwarf_attribute (decl,
DW_AT_export_symbols) == 1)
add_AT_flag (namespace_die, DW_AT_export_symbols, 1);
/* Bypass dwarf2_name's check for DECL_NAMELESS. */
if (want_pubnames ())
add_pubname_string (lang_hooks.dwarf_name (decl, 1), namespace_die);
}
/* Generate Dwarf debug information for a decl described by DECL.
The return value is currently only meaningful for PARM_DECLs,
for all other decls it returns NULL.
If DECL is a FIELD_DECL, CTX is required: see the comment for VLR_CONTEXT.
It can be NULL otherwise. */
static dw_die_ref
gen_decl_die (tree decl, tree origin, struct vlr_context *ctx,
dw_die_ref context_die)
{
tree decl_or_origin = decl ? decl : origin;
tree class_origin = NULL, ultimate_origin;
if (DECL_P (decl_or_origin) && DECL_IGNORED_P (decl_or_origin))
return NULL;
switch (TREE_CODE (decl_or_origin))
{
case ERROR_MARK:
break;
case CONST_DECL:
if (!is_fortran () && !is_ada () && !is_dlang ())
{
/* The individual enumerators of an enum type get output when we output
the Dwarf representation of the relevant enum type itself. */
break;
}
/* Emit its type. */
gen_type_die (TREE_TYPE (decl), context_die);
/* And its containing namespace. */
context_die = declare_in_namespace (decl, context_die);
gen_const_die (decl, context_die);
break;
case FUNCTION_DECL:
#if 0
/* FIXME */
/* This doesn't work because the C frontend sets DECL_ABSTRACT_ORIGIN
on local redeclarations of global functions. That seems broken. */
if (current_function_decl != decl)
/* This is only a declaration. */;
#endif
/* We should have abstract copies already and should not generate
stray type DIEs in late LTO dumping. */
if (! early_dwarf)
;
/* If we're emitting a clone, emit info for the abstract instance. */
else if (origin || DECL_ORIGIN (decl) != decl)
dwarf2out_abstract_function (origin
? DECL_ORIGIN (origin)
: DECL_ABSTRACT_ORIGIN (decl));
/* If we're emitting a possibly inlined function emit it as
abstract instance. */
else if (cgraph_function_possibly_inlined_p (decl)
&& ! DECL_ABSTRACT_P (decl)
&& ! class_or_namespace_scope_p (context_die)
/* dwarf2out_abstract_function won't emit a die if this is just
a declaration. We must avoid setting DECL_ABSTRACT_ORIGIN in
that case, because that works only if we have a die. */
&& DECL_INITIAL (decl) != NULL_TREE)
dwarf2out_abstract_function (decl);
/* Otherwise we're emitting the primary DIE for this decl. */
else if (debug_info_level > DINFO_LEVEL_TERSE)
{
/* Before we describe the FUNCTION_DECL itself, make sure that we
have its containing type. */
if (!origin)
origin = decl_class_context (decl);
if (origin != NULL_TREE)
gen_type_die (origin, context_die);
/* And its return type. */
gen_type_die (TREE_TYPE (TREE_TYPE (decl)), context_die);
/* And its virtual context. */
if (DECL_VINDEX (decl) != NULL_TREE)
gen_type_die (DECL_CONTEXT (decl), context_die);
/* Make sure we have a member DIE for decl. */
if (origin != NULL_TREE)
gen_type_die_for_member (origin, decl, context_die);
/* And its containing namespace. */
context_die = declare_in_namespace (decl, context_die);
}
/* Now output a DIE to represent the function itself. */
if (decl)
gen_subprogram_die (decl, context_die);
break;
case TYPE_DECL:
/* If we are in terse mode, don't generate any DIEs to represent any
actual typedefs. */
if (debug_info_level <= DINFO_LEVEL_TERSE)
break;
/* In the special case of a TYPE_DECL node representing the declaration
of some type tag, if the given TYPE_DECL is marked as having been
instantiated from some other (original) TYPE_DECL node (e.g. one which
was generated within the original definition of an inline function) we
used to generate a special (abbreviated) DW_TAG_structure_type,
DW_TAG_union_type, or DW_TAG_enumeration_type DIE here. But nothing
should be actually referencing those DIEs, as variable DIEs with that
type would be emitted already in the abstract origin, so it was always
removed during unused type prunning. Don't add anything in this
case. */
if (TYPE_DECL_IS_STUB (decl) && decl_ultimate_origin (decl) != NULL_TREE)
break;
if (is_redundant_typedef (decl))
gen_type_die (TREE_TYPE (decl), context_die);
else
/* Output a DIE to represent the typedef itself. */
gen_typedef_die (decl, context_die);
break;
case LABEL_DECL:
if (debug_info_level >= DINFO_LEVEL_NORMAL)
gen_label_die (decl, context_die);
break;
case VAR_DECL:
case RESULT_DECL:
/* If we are in terse mode, don't generate any DIEs to represent any
variable declarations or definitions unless it is external. */
if (debug_info_level < DINFO_LEVEL_TERSE
|| (debug_info_level == DINFO_LEVEL_TERSE
&& !TREE_PUBLIC (decl_or_origin)))
break;
if (debug_info_level > DINFO_LEVEL_TERSE)
{
/* Avoid generating stray type DIEs during late dwarf dumping.
All types have been dumped early. */
if (early_dwarf
/* ??? But in LTRANS we cannot annotate early created variably
modified type DIEs without copying them and adjusting all
references to them. Dump them again as happens for inlining
which copies both the decl and the types. */
/* ??? And even non-LTO needs to re-visit type DIEs to fill
in VLA bound information for example. */
|| (decl && variably_modified_type_p (TREE_TYPE (decl),
current_function_decl)))
{
/* Output any DIEs that are needed to specify the type of this data
object. */
if (decl_by_reference_p (decl_or_origin))
gen_type_die (TREE_TYPE (TREE_TYPE (decl_or_origin)), context_die);
else
gen_type_die (TREE_TYPE (decl_or_origin), context_die);
}
if (early_dwarf)
{
/* And its containing type. */
class_origin = decl_class_context (decl_or_origin);
if (class_origin != NULL_TREE)
gen_type_die_for_member (class_origin, decl_or_origin, context_die);
/* And its containing namespace. */
context_die = declare_in_namespace (decl_or_origin, context_die);
}
}
/* Now output the DIE to represent the data object itself. This gets
complicated because of the possibility that the VAR_DECL really
represents an inlined instance of a formal parameter for an inline
function. */
ultimate_origin = decl_ultimate_origin (decl_or_origin);
if (ultimate_origin != NULL_TREE
&& TREE_CODE (ultimate_origin) == PARM_DECL)
gen_formal_parameter_die (decl, origin,
true /* Emit name attribute. */,
context_die);
else
gen_variable_die (decl, origin, context_die);
break;
case FIELD_DECL:
gcc_assert (ctx != NULL && ctx->struct_type != NULL);
/* Ignore the nameless fields that are used to skip bits but handle C++
anonymous unions and structs. */
if (DECL_NAME (decl) != NULL_TREE
|| TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE
|| TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE)
{
gen_type_die (member_declared_type (decl), context_die);
gen_field_die (decl, ctx, context_die);
}
break;
case PARM_DECL:
/* Avoid generating stray type DIEs during late dwarf dumping.
All types have been dumped early. */
if (early_dwarf
/* ??? But in LTRANS we cannot annotate early created variably
modified type DIEs without copying them and adjusting all
references to them. Dump them again as happens for inlining
which copies both the decl and the types. */
/* ??? And even non-LTO needs to re-visit type DIEs to fill
in VLA bound information for example. */
|| (decl && variably_modified_type_p (TREE_TYPE (decl),
current_function_decl)))
{
if (DECL_BY_REFERENCE (decl_or_origin))
gen_type_die (TREE_TYPE (TREE_TYPE (decl_or_origin)), context_die);
else
gen_type_die (TREE_TYPE (decl_or_origin), context_die);
}
return gen_formal_parameter_die (decl, origin,
true /* Emit name attribute. */,
context_die);
case NAMESPACE_DECL:
if (dwarf_version >= 3 || !dwarf_strict)
gen_namespace_die (decl, context_die);
break;
case IMPORTED_DECL:
dwarf2out_imported_module_or_decl_1 (decl, DECL_NAME (decl),
DECL_CONTEXT (decl), context_die);
break;
case NAMELIST_DECL:
gen_namelist_decl (DECL_NAME (decl), context_die,
NAMELIST_DECL_ASSOCIATED_DECL (decl));
break;
default:
/* Probably some frontend-internal decl. Assume we don't care. */
gcc_assert ((int)TREE_CODE (decl) > NUM_TREE_CODES);
break;
}
return NULL;
}
/* Output initial debug information for global DECL. Called at the
end of the parsing process.
This is the initial debug generation process. As such, the DIEs
generated may be incomplete. A later debug generation pass
(dwarf2out_late_global_decl) will augment the information generated
in this pass (e.g., with complete location info). */
static void
dwarf2out_early_global_decl (tree decl)
{
set_early_dwarf s;
/* gen_decl_die() will set DECL_ABSTRACT because
cgraph_function_possibly_inlined_p() returns true. This is in
turn will cause DW_AT_inline attributes to be set.
This happens because at early dwarf generation, there is no
cgraph information, causing cgraph_function_possibly_inlined_p()
to return true. Trick cgraph_function_possibly_inlined_p()
while we generate dwarf early. */
bool save = symtab->global_info_ready;
symtab->global_info_ready = true;
/* We don't handle TYPE_DECLs. If required, they'll be reached via
other DECLs and they can point to template types or other things
that dwarf2out can't handle when done via dwarf2out_decl. */
if (TREE_CODE (decl) != TYPE_DECL
&& TREE_CODE (decl) != PARM_DECL)
{
if (TREE_CODE (decl) == FUNCTION_DECL)
{
tree save_fndecl = current_function_decl;
/* For nested functions, make sure we have DIEs for the parents first
so that all nested DIEs are generated at the proper scope in the
first shot. */
tree context = decl_function_context (decl);
if (context != NULL)
{
dw_die_ref context_die = lookup_decl_die (context);
current_function_decl = context;
/* Avoid emitting DIEs multiple times, but still process CONTEXT
enough so that it lands in its own context. This avoids type
pruning issues later on. */
if (context_die == NULL || is_declaration_die (context_die))
dwarf2out_early_global_decl (context);
}
/* Emit an abstract origin of a function first. This happens
with C++ constructor clones for example and makes
dwarf2out_abstract_function happy which requires the early
DIE of the abstract instance to be present. */
tree origin = DECL_ABSTRACT_ORIGIN (decl);
dw_die_ref origin_die;
if (origin != NULL
/* Do not emit the DIE multiple times but make sure to
process it fully here in case we just saw a declaration. */
&& ((origin_die = lookup_decl_die (origin)) == NULL
|| is_declaration_die (origin_die)))
{
current_function_decl = origin;
dwarf2out_decl (origin);
}
/* Emit the DIE for decl but avoid doing that multiple times. */
dw_die_ref old_die;
if ((old_die = lookup_decl_die (decl)) == NULL
|| is_declaration_die (old_die))
{
current_function_decl = decl;
dwarf2out_decl (decl);
}
current_function_decl = save_fndecl;
}
else
dwarf2out_decl (decl);
}
symtab->global_info_ready = save;
}
/* Return whether EXPR is an expression with the following pattern:
INDIRECT_REF (NOP_EXPR (INTEGER_CST)). */
static bool
is_trivial_indirect_ref (tree expr)
{
if (expr == NULL_TREE || TREE_CODE (expr) != INDIRECT_REF)
return false;
tree nop = TREE_OPERAND (expr, 0);
if (nop == NULL_TREE || TREE_CODE (nop) != NOP_EXPR)
return false;
tree int_cst = TREE_OPERAND (nop, 0);
return int_cst != NULL_TREE && TREE_CODE (int_cst) == INTEGER_CST;
}
/* Output debug information for global decl DECL. Called from
toplev.c after compilation proper has finished. */
static void
dwarf2out_late_global_decl (tree decl)
{
/* Fill-in any location information we were unable to determine
on the first pass. */
if (VAR_P (decl))
{
dw_die_ref die = lookup_decl_die (decl);
/* We may have to generate full debug late for LTO in case debug
was not enabled at compile-time or the target doesn't support
the LTO early debug scheme. */
if (! die && in_lto_p)
dwarf2out_decl (decl);
else if (die)
{
/* We get called via the symtab code invoking late_global_decl
for symbols that are optimized out.
Do not add locations for those, except if they have a
DECL_VALUE_EXPR, in which case they are relevant for debuggers.
Still don't add a location if the DECL_VALUE_EXPR is not a trivial
INDIRECT_REF expression, as this could generate relocations to
text symbols in LTO object files, which is invalid. */
varpool_node *node = varpool_node::get (decl);
if ((! node || ! node->definition)
&& ! (DECL_HAS_VALUE_EXPR_P (decl)
&& is_trivial_indirect_ref (DECL_VALUE_EXPR (decl))))
tree_add_const_value_attribute_for_decl (die, decl);
else
add_location_or_const_value_attribute (die, decl, false);
}
}
}
/* Output debug information for type decl DECL. Called from toplev.c
and from language front ends (to record built-in types). */
static void
dwarf2out_type_decl (tree decl, int local)
{
if (!local)
{
set_early_dwarf s;
dwarf2out_decl (decl);
}
}
/* Output debug information for imported module or decl DECL.
NAME is non-NULL name in the lexical block if the decl has been renamed.
LEXICAL_BLOCK is the lexical block (which TREE_CODE is a BLOCK)
that DECL belongs to.
LEXICAL_BLOCK_DIE is the DIE of LEXICAL_BLOCK. */
static void
dwarf2out_imported_module_or_decl_1 (tree decl,
tree name,
tree lexical_block,
dw_die_ref lexical_block_die)
{
expanded_location xloc;
dw_die_ref imported_die = NULL;
dw_die_ref at_import_die;
if (TREE_CODE (decl) == IMPORTED_DECL)
{
xloc = expand_location (DECL_SOURCE_LOCATION (decl));
decl = IMPORTED_DECL_ASSOCIATED_DECL (decl);
gcc_assert (decl);
}
else
xloc = expand_location (input_location);
if (TREE_CODE (decl) == TYPE_DECL)
{
at_import_die = force_type_die (TREE_TYPE (decl));
/* For namespace N { typedef void T; } using N::T; base_type_die
returns NULL, but DW_TAG_imported_declaration requires
the DW_AT_import tag. Force creation of DW_TAG_typedef. */
if (!at_import_die)
{
gcc_assert (TREE_CODE (decl) == TYPE_DECL);
gen_typedef_die (decl, get_context_die (DECL_CONTEXT (decl)));
at_import_die = lookup_type_die (TREE_TYPE (decl));
gcc_assert (at_import_die);
}
}
else
{
at_import_die = lookup_decl_die (decl);
if (!at_import_die)
{
/* If we're trying to avoid duplicate debug info, we may not have
emitted the member decl for this field. Emit it now. */
if (TREE_CODE (decl) == FIELD_DECL)
{
tree type = DECL_CONTEXT (decl);
if (TYPE_CONTEXT (type)
&& TYPE_P (TYPE_CONTEXT (type))
&& !should_emit_struct_debug (TYPE_CONTEXT (type),
DINFO_USAGE_DIR_USE))
return;
gen_type_die_for_member (type, decl,
get_context_die (TYPE_CONTEXT (type)));
}
if (TREE_CODE (decl) == NAMELIST_DECL)
at_import_die = gen_namelist_decl (DECL_NAME (decl),
get_context_die (DECL_CONTEXT (decl)),
NULL_TREE);
else
at_import_die = force_decl_die (decl);
}
}
if (TREE_CODE (decl) == NAMESPACE_DECL)
{
if (dwarf_version >= 3 || !dwarf_strict)
imported_die = new_die (DW_TAG_imported_module,
lexical_block_die,
lexical_block);
else
return;
}
else
imported_die = new_die (DW_TAG_imported_declaration,
lexical_block_die,
lexical_block);
add_AT_file (imported_die, DW_AT_decl_file, lookup_filename (xloc.file));
add_AT_unsigned (imported_die, DW_AT_decl_line, xloc.line);
if (debug_column_info && xloc.column)
add_AT_unsigned (imported_die, DW_AT_decl_column, xloc.column);
if (name)
add_AT_string (imported_die, DW_AT_name,
IDENTIFIER_POINTER (name));
add_AT_die_ref (imported_die, DW_AT_import, at_import_die);
}
/* Output debug information for imported module or decl DECL.
NAME is non-NULL name in context if the decl has been renamed.
CHILD is true if decl is one of the renamed decls as part of
importing whole module.
IMPLICIT is set if this hook is called for an implicit import
such as inline namespace. */
static void
dwarf2out_imported_module_or_decl (tree decl, tree name, tree context,
bool child, bool implicit)
{
/* dw_die_ref at_import_die; */
dw_die_ref scope_die;
if (debug_info_level <= DINFO_LEVEL_TERSE)
return;
gcc_assert (decl);
/* For DWARF5, just DW_AT_export_symbols on the DW_TAG_namespace
should be enough, for DWARF4 and older even if we emit as extension
DW_AT_export_symbols add the implicit DW_TAG_imported_module anyway
for the benefit of consumers unaware of DW_AT_export_symbols. */
if (implicit
&& dwarf_version >= 5
&& lang_hooks.decls.decl_dwarf_attribute (decl,
DW_AT_export_symbols) == 1)
return;
set_early_dwarf s;
/* To emit DW_TAG_imported_module or DW_TAG_imported_decl, we need two DIEs.
We need decl DIE for reference and scope die. First, get DIE for the decl
itself. */
/* Get the scope die for decl context. Use comp_unit_die for global module
or decl. If die is not found for non globals, force new die. */
if (context
&& TYPE_P (context)
&& !should_emit_struct_debug (context, DINFO_USAGE_DIR_USE))
return;
scope_die = get_context_die (context);
if (child)
{
/* DW_TAG_imported_module was introduced in the DWARFv3 specification, so
there is nothing we can do, here. */
if (dwarf_version < 3 && dwarf_strict)
return;
gcc_assert (scope_die->die_child);
gcc_assert (scope_die->die_child->die_tag == DW_TAG_imported_module);
gcc_assert (TREE_CODE (decl) != NAMESPACE_DECL);
scope_die = scope_die->die_child;
}
/* OK, now we have DIEs for decl as well as scope. Emit imported die. */
dwarf2out_imported_module_or_decl_1 (decl, name, context, scope_die);
}
/* Output debug information for namelists. */
static dw_die_ref
gen_namelist_decl (tree name, dw_die_ref scope_die, tree item_decls)
{
dw_die_ref nml_die, nml_item_die, nml_item_ref_die;
tree value;
unsigned i;
if (debug_info_level <= DINFO_LEVEL_TERSE)
return NULL;
gcc_assert (scope_die != NULL);
nml_die = new_die (DW_TAG_namelist, scope_die, NULL);
add_AT_string (nml_die, DW_AT_name, IDENTIFIER_POINTER (name));
/* If there are no item_decls, we have a nondefining namelist, e.g.
with USE association; hence, set DW_AT_declaration. */
if (item_decls == NULL_TREE)
{
add_AT_flag (nml_die, DW_AT_declaration, 1);
return nml_die;
}
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (item_decls), i, value)
{
nml_item_ref_die = lookup_decl_die (value);
if (!nml_item_ref_die)
nml_item_ref_die = force_decl_die (value);
nml_item_die = new_die (DW_TAG_namelist_item, nml_die, NULL);
add_AT_die_ref (nml_item_die, DW_AT_namelist_items, nml_item_ref_die);
}
return nml_die;
}
/* Write the debugging output for DECL and return the DIE. */
static void
dwarf2out_decl (tree decl)
{
dw_die_ref context_die = comp_unit_die ();
switch (TREE_CODE (decl))
{
case ERROR_MARK:
return;
case FUNCTION_DECL:
/* If we're a nested function, initially use a parent of NULL; if we're
a plain function, this will be fixed up in decls_for_scope. If
we're a method, it will be ignored, since we already have a DIE.
Avoid doing this late though since clones of class methods may
otherwise end up in limbo and create type DIEs late. */
if (early_dwarf
&& decl_function_context (decl)
/* But if we're in terse mode, we don't care about scope. */
&& debug_info_level > DINFO_LEVEL_TERSE)
context_die = NULL;
break;
case VAR_DECL:
/* For local statics lookup proper context die. */
if (local_function_static (decl))
context_die = lookup_decl_die (DECL_CONTEXT (decl));
/* If we are in terse mode, don't generate any DIEs to represent any
variable declarations or definitions unless it is external. */
if (debug_info_level < DINFO_LEVEL_TERSE
|| (debug_info_level == DINFO_LEVEL_TERSE
&& !TREE_PUBLIC (decl)))
return;
break;
case CONST_DECL:
if (debug_info_level <= DINFO_LEVEL_TERSE)
return;
if (!is_fortran () && !is_ada () && !is_dlang ())
return;
if (TREE_STATIC (decl) && decl_function_context (decl))
context_die = lookup_decl_die (DECL_CONTEXT (decl));
break;
case NAMESPACE_DECL:
case IMPORTED_DECL:
if (debug_info_level <= DINFO_LEVEL_TERSE)
return;
if (lookup_decl_die (decl) != NULL)
return;
break;
case TYPE_DECL:
/* Don't emit stubs for types unless they are needed by other DIEs. */
if (TYPE_DECL_SUPPRESS_DEBUG (decl))
return;
/* Don't bother trying to generate any DIEs to represent any of the
normal built-in types for the language we are compiling. */
if (DECL_IS_UNDECLARED_BUILTIN (decl))
return;
/* If we are in terse mode, don't generate any DIEs for types. */
if (debug_info_level <= DINFO_LEVEL_TERSE)
return;
/* If we're a function-scope tag, initially use a parent of NULL;
this will be fixed up in decls_for_scope. */
if (decl_function_context (decl))
context_die = NULL;
break;
case NAMELIST_DECL:
break;
default:
return;
}
gen_decl_die (decl, NULL, NULL, context_die);
if (flag_checking)
{
dw_die_ref die = lookup_decl_die (decl);
if (die)
check_die (die);
}
}
/* Write the debugging output for DECL. */
static void
dwarf2out_function_decl (tree decl)
{
dwarf2out_decl (decl);
call_arg_locations = NULL;
call_arg_loc_last = NULL;
call_site_count = -1;
tail_call_site_count = -1;
decl_loc_table->empty ();
cached_dw_loc_list_table->empty ();
}
/* Output a marker (i.e. a label) for the beginning of the generated code for
a lexical block. */
static void
dwarf2out_begin_block (unsigned int line ATTRIBUTE_UNUSED,
unsigned int blocknum)
{
switch_to_section (current_function_section ());
ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_BEGIN_LABEL, blocknum);
}
/* Output a marker (i.e. a label) for the end of the generated code for a
lexical block. */
static void
dwarf2out_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int blocknum)
{
switch_to_section (current_function_section ());
ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_END_LABEL, blocknum);
}
/* Returns nonzero if it is appropriate not to emit any debugging
information for BLOCK, because it doesn't contain any instructions.
Don't allow this for blocks with nested functions or local classes
as we would end up with orphans, and in the presence of scheduling
we may end up calling them anyway. */
static bool
dwarf2out_ignore_block (const_tree block)
{
tree decl;
unsigned int i;
for (decl = BLOCK_VARS (block); decl; decl = DECL_CHAIN (decl))
if (TREE_CODE (decl) == FUNCTION_DECL
|| (TREE_CODE (decl) == TYPE_DECL && TYPE_DECL_IS_STUB (decl)))
return 0;
for (i = 0; i < BLOCK_NUM_NONLOCALIZED_VARS (block); i++)
{
decl = BLOCK_NONLOCALIZED_VAR (block, i);
if (TREE_CODE (decl) == FUNCTION_DECL
|| (TREE_CODE (decl) == TYPE_DECL && TYPE_DECL_IS_STUB (decl)))
return 0;
}
return 1;
}
/* Hash table routines for file_hash. */
bool
dwarf_file_hasher::equal (dwarf_file_data *p1, const char *p2)
{
return filename_cmp (p1->filename, p2) == 0;
}
hashval_t
dwarf_file_hasher::hash (dwarf_file_data *p)
{
return htab_hash_string (p->filename);
}
/* Lookup FILE_NAME (in the list of filenames that we know about here in
dwarf2out.c) and return its "index". The index of each (known) filename is
just a unique number which is associated with only that one filename. We
need such numbers for the sake of generating labels (in the .debug_sfnames
section) and references to those files numbers (in the .debug_srcinfo
and .debug_macinfo sections). If the filename given as an argument is not
found in our current list, add it to the list and assign it the next
available unique index number. */
static struct dwarf_file_data *
lookup_filename (const char *file_name)
{
struct dwarf_file_data * created;
if (!file_name)
return NULL;
if (!file_name[0])
file_name = "<stdin>";
dwarf_file_data **slot
= file_table->find_slot_with_hash (file_name, htab_hash_string (file_name),
INSERT);
if (*slot)
return *slot;
created = ggc_alloc<dwarf_file_data> ();
created->filename = file_name;
created->emitted_number = 0;
*slot = created;
return created;
}
/* If the assembler will construct the file table, then translate the compiler
internal file table number into the assembler file table number, and emit
a .file directive if we haven't already emitted one yet. The file table
numbers are different because we prune debug info for unused variables and
types, which may include filenames. */
static int
maybe_emit_file (struct dwarf_file_data * fd)
{
if (! fd->emitted_number)
{
if (last_emitted_file)
fd->emitted_number = last_emitted_file->emitted_number + 1;
else
fd->emitted_number = 1;
last_emitted_file = fd;
if (output_asm_line_debug_info ())
{
fprintf (asm_out_file, "\t.file %u ", fd->emitted_number);
output_quoted_string (asm_out_file,
remap_debug_filename (fd->filename));
fputc ('\n', asm_out_file);
}
}
return fd->emitted_number;
}
/* Schedule generation of a DW_AT_const_value attribute to DIE.
That generation should happen after function debug info has been
generated. The value of the attribute is the constant value of ARG. */
static void
append_entry_to_tmpl_value_parm_die_table (dw_die_ref die, tree arg)
{
die_arg_entry entry;
if (!die || !arg)
return;
gcc_assert (early_dwarf);
if (!tmpl_value_parm_die_table)
vec_alloc (tmpl_value_parm_die_table, 32);
entry.die = die;
entry.arg = arg;
vec_safe_push (tmpl_value_parm_die_table, entry);
}
/* Return TRUE if T is an instance of generic type, FALSE
otherwise. */
static bool
generic_type_p (tree t)
{
if (t == NULL_TREE || !TYPE_P (t))
return false;
return lang_hooks.get_innermost_generic_parms (t) != NULL_TREE;
}
/* Schedule the generation of the generic parameter dies for the
instance of generic type T. The proper generation itself is later
done by gen_scheduled_generic_parms_dies. */
static void
schedule_generic_params_dies_gen (tree t)
{
if (!generic_type_p (t))
return;
gcc_assert (early_dwarf);
if (!generic_type_instances)
vec_alloc (generic_type_instances, 256);
vec_safe_push (generic_type_instances, t);
}
/* Add a DW_AT_const_value attribute to DIEs that were scheduled
by append_entry_to_tmpl_value_parm_die_table. This function must
be called after function DIEs have been generated. */
static void
gen_remaining_tmpl_value_param_die_attribute (void)
{
if (tmpl_value_parm_die_table)
{
unsigned i, j;
die_arg_entry *e;
/* We do this in two phases - first get the cases we can
handle during early-finish, preserving those we cannot
(containing symbolic constants where we don't yet know
whether we are going to output the referenced symbols).
For those we try again at late-finish. */
j = 0;
FOR_EACH_VEC_ELT (*tmpl_value_parm_die_table, i, e)
{
if (!e->die->removed
&& !tree_add_const_value_attribute (e->die, e->arg))
{
dw_loc_descr_ref loc = NULL;
if (! early_dwarf
&& (dwarf_version >= 5 || !dwarf_strict))
loc = loc_descriptor_from_tree (e->arg, 2, NULL);
if (loc)
add_AT_loc (e->die, DW_AT_location, loc);
else
(*tmpl_value_parm_die_table)[j++] = *e;
}
}
tmpl_value_parm_die_table->truncate (j);
}
}
/* Generate generic parameters DIEs for instances of generic types
that have been previously scheduled by
schedule_generic_params_dies_gen. This function must be called
after all the types of the CU have been laid out. */
static void
gen_scheduled_generic_parms_dies (void)
{
unsigned i;
tree t;
if (!generic_type_instances)
return;
FOR_EACH_VEC_ELT (*generic_type_instances, i, t)
if (COMPLETE_TYPE_P (t))
gen_generic_params_dies (t);
generic_type_instances = NULL;
}
/* Replace DW_AT_name for the decl with name. */
static void
dwarf2out_set_name (tree decl, tree name)
{
dw_die_ref die;
dw_attr_node *attr;
const char *dname;
die = TYPE_SYMTAB_DIE (decl);
if (!die)
return;
dname = dwarf2_name (name, 0);
if (!dname)
return;
attr = get_AT (die, DW_AT_name);
if (attr)
{
struct indirect_string_node *node;
node = find_AT_string (dname);
/* replace the string. */
attr->dw_attr_val.v.val_str = node;
}
else
add_name_attribute (die, dname);
}
/* True if before or during processing of the first function being emitted. */
static bool in_first_function_p = true;
/* True if loc_note during dwarf2out_var_location call might still be
before first real instruction at address equal to .Ltext0. */
static bool maybe_at_text_label_p = true;
/* One above highest N where .LVLN label might be equal to .Ltext0 label. */
static unsigned int first_loclabel_num_not_at_text_label;
/* Look ahead for a real insn. */
static rtx_insn *
dwarf2out_next_real_insn (rtx_insn *loc_note)
{
rtx_insn *next_real = NEXT_INSN (loc_note);
while (next_real)
if (INSN_P (next_real))
break;
else
next_real = NEXT_INSN (next_real);
return next_real;
}
/* Called by the final INSN scan whenever we see a var location. We
use it to drop labels in the right places, and throw the location in
our lookup table. */
static void
dwarf2out_var_location (rtx_insn *loc_note)
{
char loclabel[MAX_ARTIFICIAL_LABEL_BYTES + 2];
struct var_loc_node *newloc;
rtx_insn *next_real;
rtx_insn *call_insn = NULL;
static const char *last_label;
static const char *last_postcall_label;
static bool last_in_cold_section_p;
static rtx_insn *expected_next_loc_note;
tree decl;
bool var_loc_p;
var_loc_view view = 0;
if (!NOTE_P (loc_note))
{
if (CALL_P (loc_note))
{
maybe_reset_location_view (loc_note, cur_line_info_table);
call_site_count++;
if (SIBLING_CALL_P (loc_note))
tail_call_site_count++;
if (find_reg_note (loc_note, REG_CALL_ARG_LOCATION, NULL_RTX))
{
call_insn = loc_note;
loc_note = NULL;
var_loc_p = false;
next_real = dwarf2out_next_real_insn (call_insn);
cached_next_real_insn = NULL;
goto create_label;
}
if (optimize == 0 && !flag_var_tracking)
{
/* When the var-tracking pass is not running, there is no note
for indirect calls whose target is compile-time known. In this
case, process such calls specifically so that we generate call
sites for them anyway. */
rtx x = PATTERN (loc_note);
if (GET_CODE (x) == PARALLEL)
x = XVECEXP (x, 0, 0);
if (GET_CODE (x) == SET)
x = SET_SRC (x);
if (GET_CODE (x) == CALL)
x = XEXP (x, 0);
if (!MEM_P (x)
|| GET_CODE (XEXP (x, 0)) != SYMBOL_REF
|| !SYMBOL_REF_DECL (XEXP (x, 0))
|| (TREE_CODE (SYMBOL_REF_DECL (XEXP (x, 0)))
!= FUNCTION_DECL))
{
call_insn = loc_note;
loc_note = NULL;
var_loc_p = false;
next_real = dwarf2out_next_real_insn (call_insn);
cached_next_real_insn = NULL;
goto create_label;
}
}
}
else if (!debug_variable_location_views)
gcc_unreachable ();
else
maybe_reset_location_view (loc_note, cur_line_info_table);
return;
}
var_loc_p = NOTE_KIND (loc_note) == NOTE_INSN_VAR_LOCATION;
if (var_loc_p && !DECL_P (NOTE_VAR_LOCATION_DECL (loc_note)))
return;
/* Optimize processing a large consecutive sequence of location
notes so we don't spend too much time in next_real_insn. If the
next insn is another location note, remember the next_real_insn
calculation for next time. */
next_real = cached_next_real_insn;
if (next_real)
{
if (expected_next_loc_note != loc_note)
next_real = NULL;
}
if (! next_real)
next_real = dwarf2out_next_real_insn (loc_note);
if (next_real)
{
rtx_insn *next_note = NEXT_INSN (loc_note);
while (next_note != next_real)
{
if (! next_note->deleted ()
&& NOTE_P (next_note)
&& NOTE_KIND (next_note) == NOTE_INSN_VAR_LOCATION)
break;
next_note = NEXT_INSN (next_note);
}
if (next_note == next_real)
cached_next_real_insn = NULL;
else
{
expected_next_loc_note = next_note;
cached_next_real_insn = next_real;
}
}
else
cached_next_real_insn = NULL;
/* If there are no instructions which would be affected by this note,
don't do anything. */
if (var_loc_p
&& next_real == NULL_RTX
&& !NOTE_DURING_CALL_P (loc_note))
return;
create_label:
if (next_real == NULL_RTX)
next_real = get_last_insn ();
/* If there were any real insns between note we processed last time
and this note (or if it is the first note), clear
last_{,postcall_}label so that they are not reused this time. */
if (last_var_location_insn == NULL_RTX
|| last_var_location_insn != next_real
|| last_in_cold_section_p != in_cold_section_p)
{
last_label = NULL;
last_postcall_label = NULL;
}
if (var_loc_p)
{
const char *label
= NOTE_DURING_CALL_P (loc_note) ? last_postcall_label : last_label;
view = cur_line_info_table->view;
decl = NOTE_VAR_LOCATION_DECL (loc_note);
newloc = add_var_loc_to_decl (decl, loc_note, label, view);
if (newloc == NULL)
return;
}
else
{
decl = NULL_TREE;
newloc = NULL;
}
/* If there were no real insns between note we processed last time
and this note, use the label we emitted last time. Otherwise
create a new label and emit it. */
if (last_label == NULL)
{
ASM_GENERATE_INTERNAL_LABEL (loclabel, "LVL", loclabel_num);
ASM_OUTPUT_DEBUG_LABEL (asm_out_file, "LVL", loclabel_num);
loclabel_num++;
last_label = ggc_strdup (loclabel);
/* See if loclabel might be equal to .Ltext0. If yes,
bump first_loclabel_num_not_at_text_label. */
if (!have_multiple_function_sections
&& in_first_function_p
&& maybe_at_text_label_p)
{
static rtx_insn *last_start;
rtx_insn *insn;
for (insn = loc_note; insn; insn = previous_insn (insn))
if (insn == last_start)
break;
else if (!NONDEBUG_INSN_P (insn))
continue;
else
{
rtx body = PATTERN (insn);
if (GET_CODE (body) == USE || GET_CODE (body) == CLOBBER)
continue;
/* Inline asm could occupy zero bytes. */
else if (GET_CODE (body) == ASM_INPUT
|| asm_noperands (body) >= 0)
continue;
#ifdef HAVE_ATTR_length /* ??? We don't include insn-attr.h. */
else if (HAVE_ATTR_length && get_attr_min_length (insn) == 0)
continue;
#endif
else
{
/* Assume insn has non-zero length. */
maybe_at_text_label_p = false;
break;
}
}
if (maybe_at_text_label_p)
{
last_start = loc_note;
first_loclabel_num_not_at_text_label = loclabel_num;
}
}
}
gcc_assert ((loc_note == NULL_RTX && call_insn != NULL_RTX)
|| (loc_note != NULL_RTX && call_insn == NULL_RTX));
if (!var_loc_p)
{
struct call_arg_loc_node *ca_loc
= ggc_cleared_alloc<call_arg_loc_node> ();
rtx_insn *prev = call_insn;
ca_loc->call_arg_loc_note
= find_reg_note (call_insn, REG_CALL_ARG_LOCATION, NULL_RTX);
ca_loc->next = NULL;
ca_loc->label = last_label;
gcc_assert (prev
&& (CALL_P (prev)
|| (NONJUMP_INSN_P (prev)
&& GET_CODE (PATTERN (prev)) == SEQUENCE
&& CALL_P (XVECEXP (PATTERN (prev), 0, 0)))));
if (!CALL_P (prev))
prev = as_a <rtx_sequence *> (PATTERN (prev))->insn (0);
ca_loc->tail_call_p = SIBLING_CALL_P (prev);
/* Look for a SYMBOL_REF in the "prev" instruction. */
rtx x = get_call_rtx_from (prev);
if (x)
{
/* Try to get the call symbol, if any. */
if (MEM_P (XEXP (x, 0)))
x = XEXP (x, 0);
/* First, look for a memory access to a symbol_ref. */
if (GET_CODE (XEXP (x, 0)) == SYMBOL_REF
&& SYMBOL_REF_DECL (XEXP (x, 0))
&& TREE_CODE (SYMBOL_REF_DECL (XEXP (x, 0))) == FUNCTION_DECL)
ca_loc->symbol_ref = XEXP (x, 0);
/* Otherwise, look at a compile-time known user-level function
declaration. */
else if (MEM_P (x)
&& MEM_EXPR (x)
&& TREE_CODE (MEM_EXPR (x)) == FUNCTION_DECL)
ca_loc->symbol_ref = XEXP (DECL_RTL (MEM_EXPR (x)), 0);
}
ca_loc->block = insn_scope (prev);
if (call_arg_locations)
call_arg_loc_last->next = ca_loc;
else
call_arg_locations = ca_loc;
call_arg_loc_last = ca_loc;
}
else if (loc_note != NULL_RTX && !NOTE_DURING_CALL_P (loc_note))
{
newloc->label = last_label;
newloc->view = view;
}
else
{
if (!last_postcall_label)
{
sprintf (loclabel, "%s-1", last_label);
last_postcall_label = ggc_strdup (loclabel);
}
newloc->label = last_postcall_label;
/* ??? This view is at last_label, not last_label-1, but we
could only assume view at last_label-1 is zero if we could
assume calls always have length greater than one. This is
probably true in general, though there might be a rare
exception to this rule, e.g. if a call insn is optimized out
by target magic. Then, even the -1 in the label will be
wrong, which might invalidate the range. Anyway, using view,
though technically possibly incorrect, will work as far as
ranges go: since L-1 is in the middle of the call insn,
(L-1).0 and (L-1).V shouldn't make any difference, and having
the loclist entry refer to the .loc entry might be useful, so
leave it like this. */
newloc->view = view;
}
if (var_loc_p && flag_debug_asm)
{
const char *name, *sep, *patstr;
if (decl && DECL_NAME (decl))
name = IDENTIFIER_POINTER (DECL_NAME (decl));
else
name = "";
if (NOTE_VAR_LOCATION_LOC (loc_note))
{
sep = " => ";
patstr = str_pattern_slim (NOTE_VAR_LOCATION_LOC (loc_note));
}
else
{
sep = " ";
patstr = "RESET";
}
fprintf (asm_out_file, "\t%s DEBUG %s%s%s\n", ASM_COMMENT_START,
name, sep, patstr);
}
last_var_location_insn = next_real;
last_in_cold_section_p = in_cold_section_p;
}
/* Check whether BLOCK, a lexical block, is nested within OUTER, or is
OUTER itself. If BOTHWAYS, check not only that BLOCK can reach
OUTER through BLOCK_SUPERCONTEXT links, but also that there is a
path from OUTER to BLOCK through BLOCK_SUBBLOCKs and
BLOCK_FRAGMENT_ORIGIN links. */
static bool
block_within_block_p (tree block, tree outer, bool bothways)
{
if (block == outer)
return true;
/* Quickly check that OUTER is up BLOCK's supercontext chain. */
for (tree context = BLOCK_SUPERCONTEXT (block);
context != outer;
context = BLOCK_SUPERCONTEXT (context))
if (!context || TREE_CODE (context) != BLOCK)
return false;
if (!bothways)
return true;
/* Now check that each block is actually referenced by its
parent. */
for (tree context = BLOCK_SUPERCONTEXT (block); ;
context = BLOCK_SUPERCONTEXT (context))
{
if (BLOCK_FRAGMENT_ORIGIN (context))
{
gcc_assert (!BLOCK_SUBBLOCKS (context));
context = BLOCK_FRAGMENT_ORIGIN (context);
}
for (tree sub = BLOCK_SUBBLOCKS (context);
sub != block;
sub = BLOCK_CHAIN (sub))
if (!sub)
return false;
if (context == outer)
return true;
else
block = context;
}
}
/* Called during final while assembling the marker of the entry point
for an inlined function. */
static void
dwarf2out_inline_entry (tree block)
{
gcc_assert (debug_inline_points);
/* If we can't represent it, don't bother. */
if (!(dwarf_version >= 3 || !dwarf_strict))
return;
gcc_assert (DECL_P (block_ultimate_origin (block)));
/* Sanity check the block tree. This would catch a case in which
BLOCK got removed from the tree reachable from the outermost
lexical block, but got retained in markers. It would still link
back to its parents, but some ancestor would be missing a link
down the path to the sub BLOCK. If the block got removed, its
BLOCK_NUMBER will not be a usable value. */
if (flag_checking)
gcc_assert (block_within_block_p (block,
DECL_INITIAL (current_function_decl),
true));
gcc_assert (inlined_function_outer_scope_p (block));
gcc_assert (!lookup_block_die (block));
if (BLOCK_FRAGMENT_ORIGIN (block))
block = BLOCK_FRAGMENT_ORIGIN (block);
/* Can the entry point ever not be at the beginning of an
unfragmented lexical block? */
else if (!(BLOCK_FRAGMENT_CHAIN (block)
|| (cur_line_info_table
&& !ZERO_VIEW_P (cur_line_info_table->view))))
return;
if (!inline_entry_data_table)
inline_entry_data_table
= hash_table<inline_entry_data_hasher>::create_ggc (10);
inline_entry_data **iedp
= inline_entry_data_table->find_slot_with_hash (block,
htab_hash_pointer (block),
INSERT);
if (*iedp)
/* ??? Ideally, we'd record all entry points for the same inlined
function (some may have been duplicated by e.g. unrolling), but
we have no way to represent that ATM. */
return;
inline_entry_data *ied = *iedp = ggc_cleared_alloc<inline_entry_data> ();
ied->block = block;
ied->label_pfx = BLOCK_INLINE_ENTRY_LABEL;
ied->label_num = BLOCK_NUMBER (block);
if (cur_line_info_table)
ied->view = cur_line_info_table->view;
ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_INLINE_ENTRY_LABEL,
BLOCK_NUMBER (block));
}
/* Called from finalize_size_functions for size functions so that their body
can be encoded in the debug info to describe the layout of variable-length
structures. */
static void
dwarf2out_size_function (tree decl)
{
set_early_dwarf s;
function_to_dwarf_procedure (decl);
}
/* Note in one location list that text section has changed. */
int
var_location_switch_text_section_1 (var_loc_list **slot, void *)
{
var_loc_list *list = *slot;
if (list->first)
list->last_before_switch
= list->last->next ? list->last->next : list->last;
return 1;
}
/* Note in all location lists that text section has changed. */
static void
var_location_switch_text_section (void)
{
if (decl_loc_table == NULL)
return;
decl_loc_table->traverse<void *, var_location_switch_text_section_1> (NULL);
}
/* Create a new line number table. */
static dw_line_info_table *
new_line_info_table (void)
{
dw_line_info_table *table;
table = ggc_cleared_alloc<dw_line_info_table> ();
table->file_num = 1;
table->line_num = 1;
table->is_stmt = DWARF_LINE_DEFAULT_IS_STMT_START;
FORCE_RESET_NEXT_VIEW (table->view);
table->symviews_since_reset = 0;
return table;
}
/* Lookup the "current" table into which we emit line info, so
that we don't have to do it for every source line. */
static void
set_cur_line_info_table (section *sec)
{
dw_line_info_table *table;
if (sec == text_section)
table = text_section_line_info;
else if (sec == cold_text_section)
{
table = cold_text_section_line_info;
if (!table)
{
cold_text_section_line_info = table = new_line_info_table ();
table->end_label = cold_end_label;
}
}
else
{
const char *end_label;
if (crtl->has_bb_partition)
{
if (in_cold_section_p)
end_label = crtl->subsections.cold_section_end_label;
else
end_label = crtl->subsections.hot_section_end_label;
}
else
{
char label[MAX_ARTIFICIAL_LABEL_BYTES];
ASM_GENERATE_INTERNAL_LABEL (label, FUNC_END_LABEL,
current_function_funcdef_no);
end_label = ggc_strdup (label);
}
table = new_line_info_table ();
table->end_label = end_label;
vec_safe_push (separate_line_info, table);
}
if (output_asm_line_debug_info ())
table->is_stmt = (cur_line_info_table
? cur_line_info_table->is_stmt
: DWARF_LINE_DEFAULT_IS_STMT_START);
cur_line_info_table = table;
}
/* We need to reset the locations at the beginning of each
function. We can't do this in the end_function hook, because the
declarations that use the locations won't have been output when
that hook is called. Also compute have_multiple_function_sections here. */
static void
dwarf2out_begin_function (tree fun)
{
section *sec = function_section (fun);
if (sec != text_section)
have_multiple_function_sections = true;
if (crtl->has_bb_partition && !cold_text_section)
{
gcc_assert (current_function_decl == fun);
cold_text_section = unlikely_text_section ();
switch_to_section (cold_text_section);
ASM_OUTPUT_LABEL (asm_out_file, cold_text_section_label);
switch_to_section (sec);
}
dwarf2out_note_section_used ();
call_site_count = 0;
tail_call_site_count = 0;
set_cur_line_info_table (sec);
FORCE_RESET_NEXT_VIEW (cur_line_info_table->view);
}
/* Helper function of dwarf2out_end_function, called only after emitting
the very first function into assembly. Check if some .debug_loc range
might end with a .LVL* label that could be equal to .Ltext0.
In that case we must force using absolute addresses in .debug_loc ranges,
because this range could be .LVLN-.Ltext0 .. .LVLM-.Ltext0 for
.LVLN == .LVLM == .Ltext0, thus 0 .. 0, which is a .debug_loc
list terminator.
Set have_multiple_function_sections to true in that case and
terminate htab traversal. */
int
find_empty_loc_ranges_at_text_label (var_loc_list **slot, int)
{
var_loc_list *entry = *slot;
struct var_loc_node *node;
node = entry->first;
if (node && node->next && node->next->label)
{
unsigned int i;
const char *label = node->next->label;
char loclabel[MAX_ARTIFICIAL_LABEL_BYTES];
for (i = 0; i < first_loclabel_num_not_at_text_label; i++)
{
ASM_GENERATE_INTERNAL_LABEL (loclabel, "LVL", i);
if (strcmp (label, loclabel) == 0)
{
have_multiple_function_sections = true;
return 0;
}
}
}
return 1;
}
/* Hook called after emitting a function into assembly.
This does something only for the very first function emitted. */
static void
dwarf2out_end_function (unsigned int)
{
if (in_first_function_p
&& !have_multiple_function_sections
&& first_loclabel_num_not_at_text_label
&& decl_loc_table)
decl_loc_table->traverse<int, find_empty_loc_ranges_at_text_label> (0);
in_first_function_p = false;
maybe_at_text_label_p = false;
}
/* Temporary holder for dwarf2out_register_main_translation_unit. Used to let
front-ends register a translation unit even before dwarf2out_init is
called. */
static tree main_translation_unit = NULL_TREE;
/* Hook called by front-ends after they built their main translation unit.
Associate comp_unit_die to UNIT. */
static void
dwarf2out_register_main_translation_unit (tree unit)
{
gcc_assert (TREE_CODE (unit) == TRANSLATION_UNIT_DECL
&& main_translation_unit == NULL_TREE);
main_translation_unit = unit;
/* If dwarf2out_init has not been called yet, it will perform the association
itself looking at main_translation_unit. */
if (decl_die_table != NULL)
equate_decl_number_to_die (unit, comp_unit_die ());
}
/* Add OPCODE+VAL as an entry at the end of the opcode array in TABLE. */
static void
push_dw_line_info_entry (dw_line_info_table *table,
enum dw_line_info_opcode opcode, unsigned int val)
{
dw_line_info_entry e;
e.opcode = opcode;
e.val = val;
vec_safe_push (table->entries, e);
}
/* Output a label to mark the beginning of a source code line entry
and record information relating to this source line, in
'line_info_table' for later output of the .debug_line section. */
/* ??? The discriminator parameter ought to be unsigned. */
static void
dwarf2out_source_line (unsigned int line, unsigned int column,
const char *filename,
int discriminator, bool is_stmt)
{
unsigned int file_num;
dw_line_info_table *table;
static var_loc_view lvugid;
if (debug_info_level < DINFO_LEVEL_TERSE)
return;
table = cur_line_info_table;
if (line == 0)
{
if (debug_variable_location_views
&& output_asm_line_debug_info ()
&& table && !RESETTING_VIEW_P (table->view))
{
/* If we're using the assembler to compute view numbers, we
can't issue a .loc directive for line zero, so we can't
get a view number at this point. We might attempt to
compute it from the previous view, or equate it to a
subsequent view (though it might not be there!), but
since we're omitting the line number entry, we might as
well omit the view number as well. That means pretending
it's a view number zero, which might very well turn out
to be correct. ??? Extend the assembler so that the
compiler could emit e.g. ".locview .LVU#", to output a
view without changing line number information. We'd then
have to count it in symviews_since_reset; when it's omitted,
it doesn't count. */
if (!zero_view_p)
zero_view_p = BITMAP_GGC_ALLOC ();
bitmap_set_bit (zero_view_p, table->view);
if (flag_debug_asm)
{
char label[MAX_ARTIFICIAL_LABEL_BYTES];
ASM_GENERATE_INTERNAL_LABEL (label, "LVU", table->view);
fprintf (asm_out_file, "\t%s line 0, omitted view ",
ASM_COMMENT_START);
assemble_name (asm_out_file, label);
putc ('\n', asm_out_file);
}
table->view = ++lvugid;
}
return;
}
/* The discriminator column was added in dwarf4. Simplify the below
by simply removing it if we're not supposed to output it. */
if (dwarf_version < 4 && dwarf_strict)
discriminator = 0;
if (!debug_column_info)
column = 0;
file_num = maybe_emit_file (lookup_filename (filename));
/* ??? TODO: Elide duplicate line number entries. Traditionally,
the debugger has used the second (possibly duplicate) line number
at the beginning of the function to mark the end of the prologue.
We could eliminate any other duplicates within the function. For
Dwarf3, we ought to include the DW_LNS_set_prologue_end mark in
that second line number entry. */
/* Recall that this end-of-prologue indication is *not* the same thing
as the end_prologue debug hook. The NOTE_INSN_PROLOGUE_END note,
to which the hook corresponds, follows the last insn that was
emitted by gen_prologue. What we need is to precede the first insn
that had been emitted after NOTE_INSN_FUNCTION_BEG, i.e. the first
insn that corresponds to something the user wrote. These may be
very different locations once scheduling is enabled. */
if (0 && file_num == table->file_num
&& line == table->line_num
&& column == table->column_num
&& discriminator == table->discrim_num
&& is_stmt == table->is_stmt)
return;
switch_to_section (current_function_section ());
/* If requested, emit something human-readable. */
if (flag_debug_asm)
{
if (debug_column_info)
fprintf (asm_out_file, "\t%s %s:%d:%d\n", ASM_COMMENT_START,
filename, line, column);
else
fprintf (asm_out_file, "\t%s %s:%d\n", ASM_COMMENT_START,
filename, line);
}
if (output_asm_line_debug_info ())
{
/* Emit the .loc directive understood by GNU as. */
/* "\t.loc %u %u 0 is_stmt %u discriminator %u",
file_num, line, is_stmt, discriminator */
fputs ("\t.loc ", asm_out_file);
fprint_ul (asm_out_file, file_num);
putc (' ', asm_out_file);
fprint_ul (asm_out_file, line);
putc (' ', asm_out_file);
fprint_ul (asm_out_file, column);
if (is_stmt != table->is_stmt)
{
#if HAVE_GAS_LOC_STMT
fputs (" is_stmt ", asm_out_file);
putc (is_stmt ? '1' : '0', asm_out_file);
#endif
}
if (SUPPORTS_DISCRIMINATOR && discriminator != 0)
{
gcc_assert (discriminator > 0);
fputs (" discriminator ", asm_out_file);
fprint_ul (asm_out_file, (unsigned long) discriminator);
}
if (debug_variable_location_views)
{
if (!RESETTING_VIEW_P (table->view))
{
table->symviews_since_reset++;
if (table->symviews_since_reset > symview_upper_bound)
symview_upper_bound = table->symviews_since_reset;
/* When we're using the assembler to compute view
numbers, we output symbolic labels after "view" in
.loc directives, and the assembler will set them for
us, so that we can refer to the view numbers in
location lists. The only exceptions are when we know
a view will be zero: "-0" is a forced reset, used
e.g. in the beginning of functions, whereas "0" tells
the assembler to check that there was a PC change
since the previous view, in a way that implicitly
resets the next view. */
fputs (" view ", asm_out_file);
char label[MAX_ARTIFICIAL_LABEL_BYTES];
ASM_GENERATE_INTERNAL_LABEL (label, "LVU", table->view);
assemble_name (asm_out_file, label);
table->view = ++lvugid;
}
else
{
table->symviews_since_reset = 0;
if (FORCE_RESETTING_VIEW_P (table->view))
fputs (" view -0", asm_out_file);
else
fputs (" view 0", asm_out_file);
/* Mark the present view as a zero view. Earlier debug
binds may have already added its id to loclists to be
emitted later, so we can't reuse the id for something
else. However, it's good to know whether a view is
known to be zero, because then we may be able to
optimize out locviews that are all zeros, so take
note of it in zero_view_p. */
if (!zero_view_p)
zero_view_p = BITMAP_GGC_ALLOC ();
bitmap_set_bit (zero_view_p, lvugid);
table->view = ++lvugid;
}
}
putc ('\n', asm_out_file);
}
else
{
unsigned int label_num = ++line_info_label_num;
targetm.asm_out.internal_label (asm_out_file, LINE_CODE_LABEL, label_num);
if (debug_variable_location_views && !RESETTING_VIEW_P (table->view))
push_dw_line_info_entry (table, LI_adv_address, label_num);
else
push_dw_line_info_entry (table, LI_set_address, label_num);
if (debug_variable_location_views)
{
bool resetting = FORCE_RESETTING_VIEW_P (table->view);
if (resetting)
table->view = 0;
if (flag_debug_asm)
fprintf (asm_out_file, "\t%s view %s%d\n",
ASM_COMMENT_START,
resetting ? "-" : "",
table->view);
table->view++;
}
if (file_num != table->file_num)
push_dw_line_info_entry (table, LI_set_file, file_num);
if (discriminator != table->discrim_num)
push_dw_line_info_entry (table, LI_set_discriminator, discriminator);
if (is_stmt != table->is_stmt)
push_dw_line_info_entry (table, LI_negate_stmt, 0);
push_dw_line_info_entry (table, LI_set_line, line);
if (debug_column_info)
push_dw_line_info_entry (table, LI_set_column, column);
}
table->file_num = file_num;
table->line_num = line;
table->column_num = column;
table->discrim_num = discriminator;
table->is_stmt = is_stmt;
table->in_use = true;
}
/* Record the beginning of a new source file. */
static void
dwarf2out_start_source_file (unsigned int lineno, const char *filename)
{
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
macinfo_entry e;
e.code = DW_MACINFO_start_file;
e.lineno = lineno;
e.info = ggc_strdup (filename);
vec_safe_push (macinfo_table, e);
}
}
/* Record the end of a source file. */
static void
dwarf2out_end_source_file (unsigned int lineno ATTRIBUTE_UNUSED)
{
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
macinfo_entry e;
e.code = DW_MACINFO_end_file;
e.lineno = lineno;
e.info = NULL;
vec_safe_push (macinfo_table, e);
}
}
/* Called from debug_define in toplev.c. The `buffer' parameter contains
the tail part of the directive line, i.e. the part which is past the
initial whitespace, #, whitespace, directive-name, whitespace part. */
static void
dwarf2out_define (unsigned int lineno ATTRIBUTE_UNUSED,
const char *buffer ATTRIBUTE_UNUSED)
{
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
macinfo_entry e;
/* Insert a dummy first entry to be able to optimize the whole
predefined macro block using DW_MACRO_import. */
if (macinfo_table->is_empty () && lineno <= 1)
{
e.code = 0;
e.lineno = 0;
e.info = NULL;
vec_safe_push (macinfo_table, e);
}
e.code = DW_MACINFO_define;
e.lineno = lineno;
e.info = ggc_strdup (buffer);
vec_safe_push (macinfo_table, e);
}
}
/* Called from debug_undef in toplev.c. The `buffer' parameter contains
the tail part of the directive line, i.e. the part which is past the
initial whitespace, #, whitespace, directive-name, whitespace part. */
static void
dwarf2out_undef (unsigned int lineno ATTRIBUTE_UNUSED,
const char *buffer ATTRIBUTE_UNUSED)
{
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
macinfo_entry e;
/* Insert a dummy first entry to be able to optimize the whole
predefined macro block using DW_MACRO_import. */
if (macinfo_table->is_empty () && lineno <= 1)
{
e.code = 0;
e.lineno = 0;
e.info = NULL;
vec_safe_push (macinfo_table, e);
}
e.code = DW_MACINFO_undef;
e.lineno = lineno;
e.info = ggc_strdup (buffer);
vec_safe_push (macinfo_table, e);
}
}
/* Helpers to manipulate hash table of CUs. */
struct macinfo_entry_hasher : nofree_ptr_hash <macinfo_entry>
{
static inline hashval_t hash (const macinfo_entry *);
static inline bool equal (const macinfo_entry *, const macinfo_entry *);
};
inline hashval_t
macinfo_entry_hasher::hash (const macinfo_entry *entry)
{
return htab_hash_string (entry->info);
}
inline bool
macinfo_entry_hasher::equal (const macinfo_entry *entry1,
const macinfo_entry *entry2)
{
return !strcmp (entry1->info, entry2->info);
}
typedef hash_table<macinfo_entry_hasher> macinfo_hash_type;
/* Output a single .debug_macinfo entry. */
static void
output_macinfo_op (macinfo_entry *ref)
{
int file_num;
size_t len;
struct indirect_string_node *node;
char label[MAX_ARTIFICIAL_LABEL_BYTES];
struct dwarf_file_data *fd;
switch (ref->code)
{
case DW_MACINFO_start_file:
fd = lookup_filename (ref->info);
file_num = maybe_emit_file (fd);
dw2_asm_output_data (1, DW_MACINFO_start_file, "Start new file");
dw2_asm_output_data_uleb128 (ref->lineno,
"Included from line number %lu",
(unsigned long) ref->lineno);
dw2_asm_output_data_uleb128 (file_num, "file %s", ref->info);
break;
case DW_MACINFO_end_file:
dw2_asm_output_data (1, DW_MACINFO_end_file, "End file");
break;
case DW_MACINFO_define:
case DW_MACINFO_undef:
len = strlen (ref->info) + 1;
if (!dwarf_strict
&& len > DWARF_OFFSET_SIZE
&& !DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET
&& (debug_str_section->common.flags & SECTION_MERGE) != 0)
{
ref->code = ref->code == DW_MACINFO_define
? DW_MACRO_define_strp : DW_MACRO_undef_strp;
output_macinfo_op (ref);
return;
}
dw2_asm_output_data (1, ref->code,
ref->code == DW_MACINFO_define
? "Define macro" : "Undefine macro");
dw2_asm_output_data_uleb128 (ref->lineno, "At line number %lu",
(unsigned long) ref->lineno);
dw2_asm_output_nstring (ref->info, -1, "The macro");
break;
case DW_MACRO_define_strp:
case DW_MACRO_undef_strp:
/* NB: dwarf2out_finish performs:
1. save_macinfo_strings
2. hash table traverse of index_string
3. output_macinfo -> output_macinfo_op
4. output_indirect_strings
-> hash table traverse of output_index_string
When output_macinfo_op is called, all index strings have been
added to hash table by save_macinfo_strings and we can't pass
INSERT to find_slot_with_hash which may expand hash table, even
if no insertion is needed, and change hash table traverse order
between index_string and output_index_string. */
node = find_AT_string (ref->info, NO_INSERT);
gcc_assert (node
&& (node->form == DW_FORM_strp
|| node->form == dwarf_FORM (DW_FORM_strx)));
dw2_asm_output_data (1, ref->code,
ref->code == DW_MACRO_define_strp
? "Define macro strp"
: "Undefine macro strp");
dw2_asm_output_data_uleb128 (ref->lineno, "At line number %lu",
(unsigned long) ref->lineno);
if (node->form == DW_FORM_strp)
dw2_asm_output_offset (DWARF_OFFSET_SIZE, node->label,
debug_str_section, "The macro: \"%s\"",
ref->info);
else
dw2_asm_output_data_uleb128 (node->index, "The macro: \"%s\"",
ref->info);
break;
case DW_MACRO_import:
dw2_asm_output_data (1, ref->code, "Import");
ASM_GENERATE_INTERNAL_LABEL (label,
DEBUG_MACRO_SECTION_LABEL,
ref->lineno + macinfo_label_base);
dw2_asm_output_offset (DWARF_OFFSET_SIZE, label, NULL, NULL);
break;
default:
fprintf (asm_out_file, "%s unrecognized macinfo code %lu\n",
ASM_COMMENT_START, (unsigned long) ref->code);
break;
}
}
/* Attempt to make a sequence of define/undef macinfo ops shareable with
other compilation unit .debug_macinfo sections. IDX is the first
index of a define/undef, return the number of ops that should be
emitted in a comdat .debug_macinfo section and emit
a DW_MACRO_import entry referencing it.
If the define/undef entry should be emitted normally, return 0. */
static unsigned
optimize_macinfo_range (unsigned int idx, vec<macinfo_entry, va_gc> *files,
macinfo_hash_type **macinfo_htab)
{
macinfo_entry *first, *second, *cur, *inc;
char linebuf[sizeof (HOST_WIDE_INT) * 3 + 1];
unsigned char checksum[16];
struct md5_ctx ctx;
char *grp_name, *tail;
const char *base;
unsigned int i, count, encoded_filename_len, linebuf_len;
macinfo_entry **slot;
first = &(*macinfo_table)[idx];
second = &(*macinfo_table)[idx + 1];
/* Optimize only if there are at least two consecutive define/undef ops,
and either all of them are before first DW_MACINFO_start_file
with lineno {0,1} (i.e. predefined macro block), or all of them are
in some included header file. */
if (second->code != DW_MACINFO_define && second->code != DW_MACINFO_undef)
return 0;
if (vec_safe_is_empty (files))
{
if (first->lineno > 1 || second->lineno > 1)
return 0;
}
else if (first->lineno == 0)
return 0;
/* Find the last define/undef entry that can be grouped together
with first and at the same time compute md5 checksum of their
codes, linenumbers and strings. */
md5_init_ctx (&ctx);
for (i = idx; macinfo_table->iterate (i, &cur); i++)
if (cur->code != DW_MACINFO_define && cur->code != DW_MACINFO_undef)
break;
else if (vec_safe_is_empty (files) && cur->lineno > 1)
break;
else
{
unsigned char code = cur->code;
md5_process_bytes (&code, 1, &ctx);
checksum_uleb128 (cur->lineno, &ctx);
md5_process_bytes (cur->info, strlen (cur->info) + 1, &ctx);
}
md5_finish_ctx (&ctx, checksum);
count = i - idx;
/* From the containing include filename (if any) pick up just
usable characters from its basename. */
if (vec_safe_is_empty (files))
base = "";
else
base = lbasename (files->last ().info);
for (encoded_filename_len = 0, i = 0; base[i]; i++)
if (ISIDNUM (base[i]) || base[i] == '.')
encoded_filename_len++;
/* Count . at the end. */
if (encoded_filename_len)
encoded_filename_len++;
sprintf (linebuf, HOST_WIDE_INT_PRINT_UNSIGNED, first->lineno);
linebuf_len = strlen (linebuf);
/* The group name format is: wmN.[<encoded filename>.]<lineno>.<md5sum> */
grp_name = XALLOCAVEC (char, 4 + encoded_filename_len + linebuf_len + 1
+ 16 * 2 + 1);
memcpy (grp_name, DWARF_OFFSET_SIZE == 4 ? "wm4." : "wm8.", 4);
tail = grp_name + 4;
if (encoded_filename_len)
{
for (i = 0; base[i]; i++)
if (ISIDNUM (base[i]) || base[i] == '.')
*tail++ = base[i];
*tail++ = '.';
}
memcpy (tail, linebuf, linebuf_len);
tail += linebuf_len;
*tail++ = '.';
for (i = 0; i < 16; i++)
sprintf (tail + i * 2, "%02x", checksum[i] & 0xff);
/* Construct a macinfo_entry for DW_MACRO_import
in the empty vector entry before the first define/undef. */
inc = &(*macinfo_table)[idx - 1];
inc->code = DW_MACRO_import;
inc->lineno = 0;
inc->info = ggc_strdup (grp_name);
if (!*macinfo_htab)
*macinfo_htab = new macinfo_hash_type (10);
/* Avoid emitting duplicates. */
slot = (*macinfo_htab)->find_slot (inc, INSERT);
if (*slot != NULL)
{
inc->code = 0;
inc->info = NULL;
/* If such an entry has been used before, just emit
a DW_MACRO_import op. */
inc = *slot;
output_macinfo_op (inc);
/* And clear all macinfo_entry in the range to avoid emitting them
in the second pass. */
for (i = idx; macinfo_table->iterate (i, &cur) && i < idx + count; i++)
{
cur->code = 0;
cur->info = NULL;
}
}
else
{
*slot = inc;
inc->lineno = (*macinfo_htab)->elements ();
output_macinfo_op (inc);
}
return count;
}
/* Save any strings needed by the macinfo table in the debug str
table. All strings must be collected into the table by the time
index_string is called. */
static void
save_macinfo_strings (void)
{
unsigned len;
unsigned i;
macinfo_entry *ref;
for (i = 0; macinfo_table && macinfo_table->iterate (i, &ref); i++)
{
switch (ref->code)
{
/* Match the logic in output_macinfo_op to decide on
indirect strings. */
case DW_MACINFO_define:
case DW_MACINFO_undef:
len = strlen (ref->info) + 1;
if (!dwarf_strict
&& len > DWARF_OFFSET_SIZE
&& !DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET
&& (debug_str_section->common.flags & SECTION_MERGE) != 0)
set_indirect_string (find_AT_string (ref->info));
break;
case DW_MACINFO_start_file:
/* -gsplit-dwarf -g3 will also output filename as indirect
string. */
if (!dwarf_split_debug_info)
break;
/* Fall through. */
case DW_MACRO_define_strp:
case DW_MACRO_undef_strp:
set_indirect_string (find_AT_string (ref->info));
break;
default:
break;
}
}
}
/* Output macinfo section(s). */
static void
output_macinfo (const char *debug_line_label, bool early_lto_debug)
{
unsigned i;
unsigned long length = vec_safe_length (macinfo_table);
macinfo_entry *ref;
vec<macinfo_entry, va_gc> *files = NULL;
macinfo_hash_type *macinfo_htab = NULL;
char dl_section_ref[MAX_ARTIFICIAL_LABEL_BYTES];
if (! length)
return;
/* output_macinfo* uses these interchangeably. */
gcc_assert ((int) DW_MACINFO_define == (int) DW_MACRO_define
&& (int) DW_MACINFO_undef == (int) DW_MACRO_undef
&& (int) DW_MACINFO_start_file == (int) DW_MACRO_start_file
&& (int) DW_MACINFO_end_file == (int) DW_MACRO_end_file);
/* AIX Assembler inserts the length, so adjust the reference to match the
offset expected by debuggers. */
strcpy (dl_section_ref, debug_line_label);
if (XCOFF_DEBUGGING_INFO)
strcat (dl_section_ref, DWARF_INITIAL_LENGTH_SIZE_STR);
/* For .debug_macro emit the section header. */
if (!dwarf_strict || dwarf_version >= 5)
{
dw2_asm_output_data (2, dwarf_version >= 5 ? 5 : 4,
"DWARF macro version number");
if (DWARF_OFFSET_SIZE == 8)
dw2_asm_output_data (1, 3, "Flags: 64-bit, lineptr present");
else
dw2_asm_output_data (1, 2, "Flags: 32-bit, lineptr present");
dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_line_label,
debug_line_section, NULL);
}
/* In the first loop, it emits the primary .debug_macinfo section
and after each emitted op the macinfo_entry is cleared.
If a longer range of define/undef ops can be optimized using
DW_MACRO_import, the DW_MACRO_import op is emitted and kept in
the vector before the first define/undef in the range and the
whole range of define/undef ops is not emitted and kept. */
for (i = 0; macinfo_table->iterate (i, &ref); i++)
{
switch (ref->code)
{
case DW_MACINFO_start_file:
vec_safe_push (files, *ref);
break;
case DW_MACINFO_end_file:
if (!vec_safe_is_empty (files))
files->pop ();
break;
case DW_MACINFO_define:
case DW_MACINFO_undef:
if ((!dwarf_strict || dwarf_version >= 5)
&& HAVE_COMDAT_GROUP
&& vec_safe_length (files) != 1
&& i > 0
&& i + 1 < length
&& (*macinfo_table)[i - 1].code == 0)
{
unsigned count = optimize_macinfo_range (i, files, &macinfo_htab);
if (count)
{
i += count - 1;
continue;
}
}
break;
case 0:
/* A dummy entry may be inserted at the beginning to be able
to optimize the whole block of predefined macros. */
if (i == 0)
continue;
default:
break;
}
output_macinfo_op (ref);
ref->info = NULL;
ref->code = 0;
}
if (!macinfo_htab)
return;
/* Save the number of transparent includes so we can adjust the
label number for the fat LTO object DWARF. */
unsigned macinfo_label_base_adj = macinfo_htab->elements ();
delete macinfo_htab;
macinfo_htab = NULL;
/* If any DW_MACRO_import were used, on those DW_MACRO_import entries
terminate the current chain and switch to a new comdat .debug_macinfo
section and emit the define/undef entries within it. */
for (i = 0; macinfo_table->iterate (i, &ref); i++)
switch (ref->code)
{
case 0:
continue;
case DW_MACRO_import:
{
char label[MAX_ARTIFICIAL_LABEL_BYTES];
tree comdat_key = get_identifier (ref->info);
/* Terminate the previous .debug_macinfo section. */
dw2_asm_output_data (1, 0, "End compilation unit");
targetm.asm_out.named_section (debug_macinfo_section_name,
SECTION_DEBUG
| SECTION_LINKONCE
| (early_lto_debug
? SECTION_EXCLUDE : 0),
comdat_key);
ASM_GENERATE_INTERNAL_LABEL (label,
DEBUG_MACRO_SECTION_LABEL,
ref->lineno + macinfo_label_base);
ASM_OUTPUT_LABEL (asm_out_file, label);
ref->code = 0;
ref->info = NULL;
dw2_asm_output_data (2, dwarf_version >= 5 ? 5 : 4,
"DWARF macro version number");
if (DWARF_OFFSET_SIZE == 8)
dw2_asm_output_data (1, 1, "Flags: 64-bit");
else
dw2_asm_output_data (1, 0, "Flags: 32-bit");
}
break;
case DW_MACINFO_define:
case DW_MACINFO_undef:
output_macinfo_op (ref);
ref->code = 0;
ref->info = NULL;
break;
default:
gcc_unreachable ();
}
macinfo_label_base += macinfo_label_base_adj;
}
/* Initialize the various sections and labels for dwarf output and prefix
them with PREFIX if non-NULL. Returns the generation (zero based
number of times function was called). */
static unsigned
init_sections_and_labels (bool early_lto_debug)
{
/* As we may get called multiple times have a generation count for
labels. */
static unsigned generation = 0;
if (early_lto_debug)
{
if (!dwarf_split_debug_info)
{
debug_info_section = get_section (DEBUG_LTO_INFO_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE,
NULL);
debug_abbrev_section = get_section (DEBUG_LTO_ABBREV_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE,
NULL);
debug_macinfo_section_name
= ((dwarf_strict && dwarf_version < 5)
? DEBUG_LTO_MACINFO_SECTION : DEBUG_LTO_MACRO_SECTION);
debug_macinfo_section = get_section (debug_macinfo_section_name,
SECTION_DEBUG
| SECTION_EXCLUDE, NULL);
}
else
{
/* ??? Which of the following do we need early? */
debug_info_section = get_section (DEBUG_LTO_DWO_INFO_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE,
NULL);
debug_abbrev_section = get_section (DEBUG_LTO_DWO_ABBREV_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE,
NULL);
debug_skeleton_info_section = get_section (DEBUG_LTO_INFO_SECTION,
SECTION_DEBUG
| SECTION_EXCLUDE, NULL);
debug_skeleton_abbrev_section
= get_section (DEBUG_LTO_ABBREV_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE, NULL);
ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_abbrev_section_label,
DEBUG_SKELETON_ABBREV_SECTION_LABEL,
generation);
/* Somewhat confusing detail: The skeleton_[abbrev|info] sections
stay in the main .o, but the skeleton_line goes into the split
off dwo. */
debug_skeleton_line_section
= get_section (DEBUG_LTO_LINE_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE, NULL);
ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_line_section_label,
DEBUG_SKELETON_LINE_SECTION_LABEL,
generation);
debug_str_offsets_section
= get_section (DEBUG_LTO_DWO_STR_OFFSETS_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE,
NULL);
ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_info_section_label,
DEBUG_SKELETON_INFO_SECTION_LABEL,
generation);
debug_str_dwo_section = get_section (DEBUG_LTO_STR_DWO_SECTION,
DEBUG_STR_DWO_SECTION_FLAGS,
NULL);
debug_macinfo_section_name
= ((dwarf_strict && dwarf_version < 5)
? DEBUG_LTO_DWO_MACINFO_SECTION : DEBUG_LTO_DWO_MACRO_SECTION);
debug_macinfo_section = get_section (debug_macinfo_section_name,
SECTION_DEBUG | SECTION_EXCLUDE,
NULL);
}
/* For macro info and the file table we have to refer to a
debug_line section. */
debug_line_section = get_section (DEBUG_LTO_LINE_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE, NULL);
ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label,
DEBUG_LINE_SECTION_LABEL, generation);
debug_str_section = get_section (DEBUG_LTO_STR_SECTION,
DEBUG_STR_SECTION_FLAGS
| SECTION_EXCLUDE, NULL);
if (!dwarf_split_debug_info)
debug_line_str_section
= get_section (DEBUG_LTO_LINE_STR_SECTION,
DEBUG_STR_SECTION_FLAGS | SECTION_EXCLUDE, NULL);
}
else
{
if (!dwarf_split_debug_info)
{
debug_info_section = get_section (DEBUG_INFO_SECTION,
SECTION_DEBUG, NULL);
debug_abbrev_section = get_section (DEBUG_ABBREV_SECTION,
SECTION_DEBUG, NULL);
debug_loc_section = get_section (dwarf_version >= 5
? DEBUG_LOCLISTS_SECTION
: DEBUG_LOC_SECTION,
SECTION_DEBUG, NULL);
debug_macinfo_section_name
= ((dwarf_strict && dwarf_version < 5)
? DEBUG_MACINFO_SECTION : DEBUG_MACRO_SECTION);
debug_macinfo_section = get_section (debug_macinfo_section_name,
SECTION_DEBUG, NULL);
}
else
{
debug_info_section = get_section (DEBUG_DWO_INFO_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE,
NULL);
debug_abbrev_section = get_section (DEBUG_DWO_ABBREV_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE,
NULL);
debug_addr_section = get_section (DEBUG_ADDR_SECTION,
SECTION_DEBUG, NULL);
debug_skeleton_info_section = get_section (DEBUG_INFO_SECTION,
SECTION_DEBUG, NULL);
debug_skeleton_abbrev_section = get_section (DEBUG_ABBREV_SECTION,
SECTION_DEBUG, NULL);
ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_abbrev_section_label,
DEBUG_SKELETON_ABBREV_SECTION_LABEL,
generation);
/* Somewhat confusing detail: The skeleton_[abbrev|info] sections
stay in the main .o, but the skeleton_line goes into the
split off dwo. */
debug_skeleton_line_section
= get_section (DEBUG_DWO_LINE_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE, NULL);
ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_line_section_label,
DEBUG_SKELETON_LINE_SECTION_LABEL,
generation);
debug_str_offsets_section
= get_section (DEBUG_DWO_STR_OFFSETS_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE, NULL);
ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_info_section_label,
DEBUG_SKELETON_INFO_SECTION_LABEL,
generation);
debug_loc_section = get_section (dwarf_version >= 5
? DEBUG_DWO_LOCLISTS_SECTION
: DEBUG_DWO_LOC_SECTION,
SECTION_DEBUG | SECTION_EXCLUDE,
NULL);
debug_str_dwo_section = get_section (DEBUG_STR_DWO_SECTION,
DEBUG_STR_DWO_SECTION_FLAGS,
NULL);
debug_macinfo_section_name
= ((dwarf_strict && dwarf_version < 5)
? DEBUG_DWO_MACINFO_SECTION : DEBUG_DWO_MACRO_SECTION);
debug_macinfo_section = get_section (debug_macinfo_section_name,
SECTION_DEBUG | SECTION_EXCLUDE,
NULL);
}
debug_aranges_section = get_section (DEBUG_ARANGES_SECTION,
SECTION_DEBUG, NULL);
debug_line_section = get_section (DEBUG_LINE_SECTION,
SECTION_DEBUG, NULL);
debug_pubnames_section = get_section (DEBUG_PUBNAMES_SECTION,
SECTION_DEBUG, NULL);
debug_pubtypes_section = get_section (DEBUG_PUBTYPES_SECTION,
SECTION_DEBUG, NULL);
debug_str_section = get_section (DEBUG_STR_SECTION,
DEBUG_STR_SECTION_FLAGS, NULL);
if ((!dwarf_split_debug_info && !output_asm_line_debug_info ())
|| asm_outputs_debug_line_str ())
debug_line_str_section = get_section (DEBUG_LINE_STR_SECTION,
DEBUG_STR_SECTION_FLAGS, NULL);
debug_ranges_section = get_section (dwarf_version >= 5
? DEBUG_RNGLISTS_SECTION
: DEBUG_RANGES_SECTION,
SECTION_DEBUG, NULL);
debug_frame_section = get_section (DEBUG_FRAME_SECTION,
SECTION_DEBUG, NULL);
}
ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label,
DEBUG_ABBREV_SECTION_LABEL, generation);
ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label,
DEBUG_INFO_SECTION_LABEL, generation);
info_section_emitted = false;
ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label,
DEBUG_LINE_SECTION_LABEL, generation);
/* There are up to 4 unique ranges labels per generation.
See also output_rnglists. */
ASM_GENERATE_INTERNAL_LABEL (ranges_section_label,
DEBUG_RANGES_SECTION_LABEL, generation * 4);
if (dwarf_version >= 5 && dwarf_split_debug_info)
ASM_GENERATE_INTERNAL_LABEL (ranges_base_label,
DEBUG_RANGES_SECTION_LABEL,
1 + generation * 4);
ASM_GENERATE_INTERNAL_LABEL (debug_addr_section_label,
DEBUG_ADDR_SECTION_LABEL, generation);
ASM_GENERATE_INTERNAL_LABEL (macinfo_section_label,
(dwarf_strict && dwarf_version < 5)
? DEBUG_MACINFO_SECTION_LABEL
: DEBUG_MACRO_SECTION_LABEL, generation);
ASM_GENERATE_INTERNAL_LABEL (loc_section_label, DEBUG_LOC_SECTION_LABEL,
generation);
++generation;
return generation - 1;
}
/* Set up for Dwarf output at the start of compilation. */
static void
dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
{
/* Allocate the file_table. */
file_table = hash_table<dwarf_file_hasher>::create_ggc (50);
#ifndef DWARF2_LINENO_DEBUGGING_INFO
/* Allocate the decl_die_table. */
decl_die_table = hash_table<decl_die_hasher>::create_ggc (10);
/* Allocate the decl_loc_table. */
decl_loc_table = hash_table<decl_loc_hasher>::create_ggc (10);
/* Allocate the cached_dw_loc_list_table. */
cached_dw_loc_list_table = hash_table<dw_loc_list_hasher>::create_ggc (10);
/* Allocate the initial hunk of the abbrev_die_table. */
vec_alloc (abbrev_die_table, 256);
/* Zero-th entry is allocated, but unused. */
abbrev_die_table->quick_push (NULL);
/* Allocate the dwarf_proc_stack_usage_map. */
dwarf_proc_stack_usage_map = new hash_map<dw_die_ref, int>;
/* Allocate the pubtypes and pubnames vectors. */
vec_alloc (pubname_table, 32);
vec_alloc (pubtype_table, 32);
vec_alloc (incomplete_types, 64);
vec_alloc (used_rtx_array, 32);
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
vec_alloc (macinfo_table, 64);
#endif
/* If front-ends already registered a main translation unit but we were not
ready to perform the association, do this now. */
if (main_translation_unit != NULL_TREE)
equate_decl_number_to_die (main_translation_unit, comp_unit_die ());
}
/* Called before compile () starts outputtting functions, variables
and toplevel asms into assembly. */
static void
dwarf2out_assembly_start (void)
{
if (text_section_line_info)
return;
#ifndef DWARF2_LINENO_DEBUGGING_INFO
ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0);
ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0);
ASM_GENERATE_INTERNAL_LABEL (cold_text_section_label,
COLD_TEXT_SECTION_LABEL, 0);
ASM_GENERATE_INTERNAL_LABEL (cold_end_label, COLD_END_LABEL, 0);
switch_to_section (text_section);
ASM_OUTPUT_LABEL (asm_out_file, text_section_label);
#endif
/* Make sure the line number table for .text always exists. */
text_section_line_info = new_line_info_table ();
text_section_line_info->end_label = text_end_label;
#ifdef DWARF2_LINENO_DEBUGGING_INFO
cur_line_info_table = text_section_line_info;
#endif
if (HAVE_GAS_CFI_SECTIONS_DIRECTIVE
&& dwarf2out_do_cfi_asm ()
&& !dwarf2out_do_eh_frame ())
fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n");
}
/* A helper function for dwarf2out_finish called through
htab_traverse. Assign a string its index. All strings must be
collected into the table by the time index_string is called,
because the indexing code relies on htab_traverse to traverse nodes
in the same order for each run. */
int
index_string (indirect_string_node **h, unsigned int *index)
{
indirect_string_node *node = *h;
find_string_form (node);
if (node->form == dwarf_FORM (DW_FORM_strx) && node->refcount > 0)
{
gcc_assert (node->index == NO_INDEX_ASSIGNED);
node->index = *index;
*index += 1;
}
return 1;
}
/* A helper function for output_indirect_strings called through
htab_traverse. Output the offset to a string and update the
current offset. */
int
output_index_string_offset (indirect_string_node **h, unsigned int *offset)
{
indirect_string_node *node = *h;
if (node->form == dwarf_FORM (DW_FORM_strx) && node->refcount > 0)
{
/* Assert that this node has been assigned an index. */
gcc_assert (node->index != NO_INDEX_ASSIGNED
&& node->index != NOT_INDEXED);
dw2_asm_output_data (DWARF_OFFSET_SIZE, *offset,
"indexed string 0x%x: %s", node->index, node->str);
*offset += strlen (node->str) + 1;
}
return 1;
}
/* A helper function for dwarf2out_finish called through
htab_traverse. Output the indexed string. */
int
output_index_string (indirect_string_node **h, unsigned int *cur_idx)
{
struct indirect_string_node *node = *h;
if (node->form == dwarf_FORM (DW_FORM_strx) && node->refcount > 0)
{
/* Assert that the strings are output in the same order as their
indexes were assigned. */
gcc_assert (*cur_idx == node->index);
assemble_string (node->str, strlen (node->str) + 1);
*cur_idx += 1;
}
return 1;
}
/* A helper function for output_indirect_strings. Counts the number
of index strings offsets. Must match the logic of the functions
output_index_string[_offsets] above. */
int
count_index_strings (indirect_string_node **h, unsigned int *last_idx)
{
struct indirect_string_node *node = *h;
if (node->form == dwarf_FORM (DW_FORM_strx) && node->refcount > 0)
*last_idx += 1;
return 1;
}
/* A helper function for dwarf2out_finish called through
htab_traverse. Emit one queued .debug_str string. */
int
output_indirect_string (indirect_string_node **h, enum dwarf_form form)
{
struct indirect_string_node *node = *h;
node->form = find_string_form (node);
if (node->form == form && node->refcount > 0)
{
ASM_OUTPUT_LABEL (asm_out_file, node->label);
assemble_string (node->str, strlen (node->str) + 1);
}
return 1;
}
/* Output the indexed string table. */
static void
output_indirect_strings (void)
{
switch_to_section (debug_str_section);
if (!dwarf_split_debug_info)
debug_str_hash->traverse<enum dwarf_form,
output_indirect_string> (DW_FORM_strp);
else
{
unsigned int offset = 0;
unsigned int cur_idx = 0;
if (skeleton_debug_str_hash)
skeleton_debug_str_hash->traverse<enum dwarf_form,
output_indirect_string> (DW_FORM_strp);
switch_to_section (debug_str_offsets_section);
/* For DWARF5 the .debug_str_offsets[.dwo] section needs a unit
header. Note that we don't need to generate a label to the
actual index table following the header here, because this is
for the split dwarf case only. In an .dwo file there is only
one string offsets table (and one debug info section). But
if we would start using string offset tables for the main (or
skeleton) unit, then we have to add a DW_AT_str_offsets_base
pointing to the actual index after the header. Split dwarf
units will never have a string offsets base attribute. When
a split unit is moved into a .dwp file the string offsets can
be found through the .debug_cu_index section table. */
if (dwarf_version >= 5)
{
unsigned int last_idx = 0;
unsigned long str_offsets_length;
debug_str_hash->traverse_noresize
<unsigned int *, count_index_strings> (&last_idx);
str_offsets_length = last_idx * DWARF_OFFSET_SIZE + 4;
if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
dw2_asm_output_data (4, 0xffffffff,
"Escape value for 64-bit DWARF extension");
dw2_asm_output_data (DWARF_OFFSET_SIZE, str_offsets_length,
"Length of string offsets unit");
dw2_asm_output_data (2, 5, "DWARF string offsets version");
dw2_asm_output_data (2, 0, "Header zero padding");
}
debug_str_hash->traverse_noresize
<unsigned int *, output_index_string_offset> (&offset);
switch_to_section (debug_str_dwo_section);
debug_str_hash->traverse_noresize<unsigned int *, output_index_string>
(&cur_idx);
}
}
/* Callback for htab_traverse to assign an index to an entry in the
table, and to write that entry to the .debug_addr section. */
int
output_addr_table_entry (addr_table_entry **slot, unsigned int *cur_index)
{
addr_table_entry *entry = *slot;
if (entry->refcount == 0)
{
gcc_assert (entry->index == NO_INDEX_ASSIGNED
|| entry->index == NOT_INDEXED);
return 1;
}
gcc_assert (entry->index == *cur_index);
(*cur_index)++;
switch (entry->kind)
{
case ate_kind_rtx:
dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, entry->addr.rtl,
"0x%x", entry->index);
break;
case ate_kind_rtx_dtprel:
gcc_assert (targetm.asm_out.output_dwarf_dtprel);
targetm.asm_out.output_dwarf_dtprel (asm_out_file,
DWARF2_ADDR_SIZE,
entry->addr.rtl);
fputc ('\n', asm_out_file);
break;
case ate_kind_label:
dw2_asm_output_addr (DWARF2_ADDR_SIZE, entry->addr.label,
"0x%x", entry->index);
break;
default:
gcc_unreachable ();
}
return 1;
}
/* A helper function for dwarf2out_finish. Counts the number
of indexed addresses. Must match the logic of the functions
output_addr_table_entry above. */
int
count_index_addrs (addr_table_entry **slot, unsigned int *last_idx)
{
addr_table_entry *entry = *slot;
if (entry->refcount > 0)
*last_idx += 1;
return 1;
}
/* Produce the .debug_addr section. */
static void
output_addr_table (void)
{
unsigned int index = 0;
if (addr_index_table == NULL || addr_index_table->size () == 0)
return;
switch_to_section (debug_addr_section);
/* GNU DebugFission https://gcc.gnu.org/wiki/DebugFission
which GCC uses to implement -gsplit-dwarf as DWARF GNU extension
before DWARF5, didn't have a header for .debug_addr units.
DWARF5 specifies a small header when address tables are used. */
if (dwarf_version >= 5)
{
unsigned int last_idx = 0;
unsigned long addrs_length;
addr_index_table->traverse_noresize
<unsigned int *, count_index_addrs> (&last_idx);
addrs_length = last_idx * DWARF2_ADDR_SIZE + 4;
if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
dw2_asm_output_data (4, 0xffffffff,
"Escape value for 64-bit DWARF extension");
dw2_asm_output_data (DWARF_OFFSET_SIZE, addrs_length,
"Length of Address Unit");
dw2_asm_output_data (2, 5, "DWARF addr version");
dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Size of Address");
dw2_asm_output_data (1, 0, "Size of Segment Descriptor");
}
ASM_OUTPUT_LABEL (asm_out_file, debug_addr_section_label);
addr_index_table
->traverse_noresize<unsigned int *, output_addr_table_entry> (&index);
}
#if ENABLE_ASSERT_CHECKING
/* Verify that all marks are clear. */
static void
verify_marks_clear (dw_die_ref die)
{
dw_die_ref c;
gcc_assert (! die->die_mark);
FOR_EACH_CHILD (die, c, verify_marks_clear (c));
}
#endif /* ENABLE_ASSERT_CHECKING */
/* Clear the marks for a die and its children.
Be cool if the mark isn't set. */
static void
prune_unmark_dies (dw_die_ref die)
{
dw_die_ref c;
if (die->die_mark)
die->die_mark = 0;
FOR_EACH_CHILD (die, c, prune_unmark_dies (c));
}
/* Given LOC that is referenced by a DIE we're marking as used, find all
referenced DWARF procedures it references and mark them as used. */
static void
prune_unused_types_walk_loc_descr (dw_loc_descr_ref loc)
{
for (; loc != NULL; loc = loc->dw_loc_next)
switch (loc->dw_loc_opc)
{
case DW_OP_implicit_pointer:
case DW_OP_convert:
case DW_OP_reinterpret:
case DW_OP_GNU_implicit_pointer:
case DW_OP_GNU_convert:
case DW_OP_GNU_reinterpret:
if (loc->dw_loc_oprnd1.val_class == dw_val_class_die_ref)
prune_unused_types_mark (loc->dw_loc_oprnd1.v.val_die_ref.die, 1);
break;
case DW_OP_GNU_variable_value:
if (loc->dw_loc_oprnd1.val_class == dw_val_class_decl_ref)
{
dw_die_ref ref
= lookup_decl_die (loc->dw_loc_oprnd1.v.val_decl_ref);
if (ref == NULL)
break;
loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
loc->dw_loc_oprnd1.v.val_die_ref.die = ref;
loc->dw_loc_oprnd1.v.val_die_ref.external = 0;
}
/* FALLTHRU */
case DW_OP_call2:
case DW_OP_call4:
case DW_OP_call_ref:
case DW_OP_const_type:
case DW_OP_GNU_const_type:
case DW_OP_GNU_parameter_ref:
gcc_assert (loc->dw_loc_oprnd1.val_class == dw_val_class_die_ref);
prune_unused_types_mark (loc->dw_loc_oprnd1.v.val_die_ref.die, 1);
break;
case DW_OP_regval_type:
case DW_OP_deref_type:
case DW_OP_GNU_regval_type:
case DW_OP_GNU_deref_type:
gcc_assert (loc->dw_loc_oprnd2.val_class == dw_val_class_die_ref);
prune_unused_types_mark (loc->dw_loc_oprnd2.v.val_die_ref.die, 1);
break;
case DW_OP_entry_value:
case DW_OP_GNU_entry_value:
gcc_assert (loc->dw_loc_oprnd1.val_class == dw_val_class_loc);
prune_unused_types_walk_loc_descr (loc->dw_loc_oprnd1.v.val_loc);
break;
default:
break;
}
}
/* Given DIE that we're marking as used, find any other dies
it references as attributes and mark them as used. */
static void
prune_unused_types_walk_attribs (dw_die_ref die)
{
dw_attr_node *a;
unsigned ix;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
{
switch (AT_class (a))
{
/* Make sure DWARF procedures referenced by location descriptions will
get emitted. */
case dw_val_class_loc:
prune_unused_types_walk_loc_descr (AT_loc (a));
break;
case dw_val_class_loc_list:
for (dw_loc_list_ref list = AT_loc_list (a);
list != NULL;
list = list->dw_loc_next)
prune_unused_types_walk_loc_descr (list->expr);
break;
case dw_val_class_view_list:
/* This points to a loc_list in another attribute, so it's
already covered. */
break;
case dw_val_class_die_ref:
/* A reference to another DIE.
Make sure that it will get emitted.
If it was broken out into a comdat group, don't follow it. */
if (! AT_ref (a)->comdat_type_p
|| a->dw_attr == DW_AT_specification)
prune_unused_types_mark (a->dw_attr_val.v.val_die_ref.die, 1);
break;
case dw_val_class_str:
/* Set the string's refcount to 0 so that prune_unused_types_mark
accounts properly for it. */
a->dw_attr_val.v.val_str->refcount = 0;
break;
default:
break;
}
}
}
/* Mark the generic parameters and arguments children DIEs of DIE. */
static void
prune_unused_types_mark_generic_parms_dies (dw_die_ref die)
{
dw_die_ref c;
if (die == NULL || die->die_child == NULL)
return;
c = die->die_child;
do
{
if (is_template_parameter (c))
prune_unused_types_mark (c, 1);
c = c->die_sib;
} while (c && c != die->die_child);
}
/* Mark DIE as being used. If DOKIDS is true, then walk down
to DIE's children. */
static void
prune_unused_types_mark (dw_die_ref die, int dokids)
{
dw_die_ref c;
if (die->die_mark == 0)
{
/* We haven't done this node yet. Mark it as used. */
die->die_mark = 1;
/* If this is the DIE of a generic type instantiation,
mark the children DIEs that describe its generic parms and
args. */
prune_unused_types_mark_generic_parms_dies (die);
/* We also have to mark its parents as used.
(But we don't want to mark our parent's kids due to this,
unless it is a class.) */
if (die->die_parent)
prune_unused_types_mark (die->die_parent,
class_scope_p (die->die_parent));
/* Mark any referenced nodes. */
prune_unused_types_walk_attribs (die);
/* If this node is a specification,
also mark the definition, if it exists. */
if (get_AT_flag (die, DW_AT_declaration) && die->die_definition)
prune_unused_types_mark (die->die_definition, 1);
}
if (dokids && die->die_mark != 2)
{
/* We need to walk the children, but haven't done so yet.
Remember that we've walked the kids. */
die->die_mark = 2;
/* If this is an array type, we need to make sure our
kids get marked, even if they're types. If we're
breaking out types into comdat sections, do this
for all type definitions. */
if (die->die_tag == DW_TAG_array_type
|| (use_debug_types
&& is_type_die (die) && ! is_declaration_die (die)))
FOR_EACH_CHILD (die, c, prune_unused_types_mark (c, 1));
else
FOR_EACH_CHILD (die, c, prune_unused_types_walk (c));
}
}
/* For local classes, look if any static member functions were emitted
and if so, mark them. */
static void
prune_unused_types_walk_local_classes (dw_die_ref die)
{
dw_die_ref c;
if (die->die_mark == 2)
return;
switch (die->die_tag)
{
case DW_TAG_structure_type:
case DW_TAG_union_type:
case DW_TAG_class_type:
case DW_TAG_interface_type:
break;
case DW_TAG_subprogram:
if (!get_AT_flag (die, DW_AT_declaration)
|| die->die_definition != NULL)
prune_unused_types_mark (die, 1);
return;
default:
return;
}
/* Mark children. */
FOR_EACH_CHILD (die, c, prune_unused_types_walk_local_classes (c));
}
/* Walk the tree DIE and mark types that we actually use. */
static void
prune_unused_types_walk (dw_die_ref die)
{
dw_die_ref c;
/* Don't do anything if this node is already marked and
children have been marked as well. */
if (die->die_mark == 2)
return;
switch (die->die_tag)
{
case DW_TAG_structure_type:
case DW_TAG_union_type:
case DW_TAG_class_type:
case DW_TAG_interface_type:
if (die->die_perennial_p)
break;
for (c = die->die_parent; c; c = c->die_parent)
if (c->die_tag == DW_TAG_subprogram)
break;
/* Finding used static member functions inside of classes
is needed just for local classes, because for other classes
static member function DIEs with DW_AT_specification
are emitted outside of the DW_TAG_*_type. If we ever change
it, we'd need to call this even for non-local classes. */
if (c)
prune_unused_types_walk_local_classes (die);
/* It's a type node --- don't mark it. */
return;
case DW_TAG_const_type:
case DW_TAG_packed_type:
case DW_TAG_pointer_type:
case DW_TAG_reference_type:
case DW_TAG_rvalue_reference_type:
case DW_TAG_volatile_type:
case DW_TAG_typedef:
case DW_TAG_array_type:
case DW_TAG_friend:
case DW_TAG_enumeration_type:
case DW_TAG_subroutine_type:
case DW_TAG_string_type:
case DW_TAG_set_type:
case DW_TAG_subrange_type:
case DW_TAG_ptr_to_member_type:
case DW_TAG_file_type:
/* Type nodes are useful only when other DIEs reference them --- don't
mark them. */
/* FALLTHROUGH */
case DW_TAG_dwarf_procedure:
/* Likewise for DWARF procedures. */
if (die->die_perennial_p)
break;
return;
case DW_TAG_variable:
if (flag_debug_only_used_symbols)
{
if (die->die_perennial_p)
break;
/* premark_used_variables marks external variables --- don't mark
them here. But function-local externals are always considered
used. */
if (get_AT (die, DW_AT_external))
{
for (c = die->die_parent; c; c = c->die_parent)
if (c->die_tag == DW_TAG_subprogram)
break;
if (!c)
return;
}
}
/* FALLTHROUGH */
default:
/* Mark everything else. */
break;
}
if (die->die_mark == 0)
{
die->die_mark = 1;
/* Now, mark any dies referenced from here. */
prune_unused_types_walk_attribs (die);
}
die->die_mark = 2;
/* Mark children. */
FOR_EACH_CHILD (die, c, prune_unused_types_walk (c));
}
/* Increment the string counts on strings referred to from DIE's
attributes. */
static void
prune_unused_types_update_strings (dw_die_ref die)
{
dw_attr_node *a;
unsigned ix;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (AT_class (a) == dw_val_class_str)
{
struct indirect_string_node *s = a->dw_attr_val.v.val_str;
s->refcount++;
/* Avoid unnecessarily putting strings that are used less than
twice in the hash table. */
if (s->refcount
== ((DEBUG_STR_SECTION_FLAGS & SECTION_MERGE) ? 1 : 2))
{
indirect_string_node **slot
= debug_str_hash->find_slot_with_hash (s->str,
htab_hash_string (s->str),
INSERT);
gcc_assert (*slot == NULL);
*slot = s;
}
}
}
/* Mark DIE and its children as removed. */
static void
mark_removed (dw_die_ref die)
{
dw_die_ref c;
die->removed = true;
FOR_EACH_CHILD (die, c, mark_removed (c));
}
/* Remove from the tree DIE any dies that aren't marked. */
static void
prune_unused_types_prune (dw_die_ref die)
{
dw_die_ref c;
gcc_assert (die->die_mark);
prune_unused_types_update_strings (die);
if (! die->die_child)
return;
c = die->die_child;
do {
dw_die_ref prev = c, next;
for (c = c->die_sib; ! c->die_mark; c = next)
if (c == die->die_child)
{
/* No marked children between 'prev' and the end of the list. */
if (prev == c)
/* No marked children at all. */
die->die_child = NULL;
else
{
prev->die_sib = c->die_sib;
die->die_child = prev;
}
c->die_sib = NULL;
mark_removed (c);
return;
}
else
{
next = c->die_sib;
c->die_sib = NULL;
mark_removed (c);
}
if (c != prev->die_sib)
prev->die_sib = c;
prune_unused_types_prune (c);
} while (c != die->die_child);
}
/* Remove dies representing declarations that we never use. */
static void
prune_unused_types (void)
{
unsigned int i;
limbo_die_node *node;
comdat_type_node *ctnode;
pubname_entry *pub;
dw_die_ref base_type;
#if ENABLE_ASSERT_CHECKING
/* All the marks should already be clear. */
verify_marks_clear (comp_unit_die ());
for (node = limbo_die_list; node; node = node->next)
verify_marks_clear (node->die);
for (ctnode = comdat_type_list; ctnode; ctnode = ctnode->next)
verify_marks_clear (ctnode->root_die);
#endif /* ENABLE_ASSERT_CHECKING */
/* Mark types that are used in global variables. */
premark_types_used_by_global_vars ();
/* Mark variables used in the symtab. */
if (flag_debug_only_used_symbols)
premark_used_variables ();
/* Set the mark on nodes that are actually used. */
prune_unused_types_walk (comp_unit_die ());
for (node = limbo_die_list; node; node = node->next)
prune_unused_types_walk (node->die);
for (ctnode = comdat_type_list; ctnode; ctnode = ctnode->next)
{
prune_unused_types_walk (ctnode->root_die);
prune_unused_types_mark (ctnode->type_die, 1);
}
/* Also set the mark on nodes referenced from the pubname_table. Enumerators
are unusual in that they are pubnames that are the children of pubtypes.
They should only be marked via their parent DW_TAG_enumeration_type die,
not as roots in themselves. */
FOR_EACH_VEC_ELT (*pubname_table, i, pub)
if (pub->die->die_tag != DW_TAG_enumerator)
prune_unused_types_mark (pub->die, 1);
for (i = 0; base_types.iterate (i, &base_type); i++)
prune_unused_types_mark (base_type, 1);
/* Also set the mark on nodes that could be referenced by
DW_TAG_call_site DW_AT_call_origin (i.e. direct call callees) or
by DW_TAG_inlined_subroutine origins. */
cgraph_node *cnode;
FOR_EACH_FUNCTION (cnode)
if (cnode->referred_to_p (false))
{
dw_die_ref die = lookup_decl_die (cnode->decl);
if (die == NULL || die->die_mark)
continue;
for (cgraph_edge *e = cnode->callers; e; e = e->next_caller)
if (e->caller != cnode)
{
prune_unused_types_mark (die, 1);
break;
}
}
if (debug_str_hash)
debug_str_hash->empty ();
if (skeleton_debug_str_hash)
skeleton_debug_str_hash->empty ();
prune_unused_types_prune (comp_unit_die ());
for (limbo_die_node **pnode = &limbo_die_list; *pnode; )
{
node = *pnode;
if (!node->die->die_mark)
*pnode = node->next;
else
{
prune_unused_types_prune (node->die);
pnode = &node->next;
}
}
for (ctnode = comdat_type_list; ctnode; ctnode = ctnode->next)
prune_unused_types_prune (ctnode->root_die);
/* Leave the marks clear. */
prune_unmark_dies (comp_unit_die ());
for (node = limbo_die_list; node; node = node->next)
prune_unmark_dies (node->die);
for (ctnode = comdat_type_list; ctnode; ctnode = ctnode->next)
prune_unmark_dies (ctnode->root_die);
}
/* Helpers to manipulate hash table of comdat type units. */
struct comdat_type_hasher : nofree_ptr_hash <comdat_type_node>
{
static inline hashval_t hash (const comdat_type_node *);
static inline bool equal (const comdat_type_node *, const comdat_type_node *);
};
inline hashval_t
comdat_type_hasher::hash (const comdat_type_node *type_node)
{
hashval_t h;
memcpy (&h, type_node->signature, sizeof (h));
return h;
}
inline bool
comdat_type_hasher::equal (const comdat_type_node *type_node_1,
const comdat_type_node *type_node_2)
{
return (! memcmp (type_node_1->signature, type_node_2->signature,
DWARF_TYPE_SIGNATURE_SIZE));
}
/* Move a DW_AT_{,MIPS_}linkage_name attribute just added to dw_die_ref
to the location it would have been added, should we know its
DECL_ASSEMBLER_NAME when we added other attributes. This will
probably improve compactness of debug info, removing equivalent
abbrevs, and hide any differences caused by deferring the
computation of the assembler name, triggered by e.g. PCH. */
static inline void
move_linkage_attr (dw_die_ref die)
{
unsigned ix = vec_safe_length (die->die_attr);
dw_attr_node linkage = (*die->die_attr)[ix - 1];
gcc_assert (linkage.dw_attr == DW_AT_linkage_name
|| linkage.dw_attr == DW_AT_MIPS_linkage_name);
while (--ix > 0)
{
dw_attr_node *prev = &(*die->die_attr)[ix - 1];
if (prev->dw_attr == DW_AT_decl_line
|| prev->dw_attr == DW_AT_decl_column
|| prev->dw_attr == DW_AT_name)
break;
}
if (ix != vec_safe_length (die->die_attr) - 1)
{
die->die_attr->pop ();
die->die_attr->quick_insert (ix, linkage);
}
}
/* Helper function for resolve_addr, mark DW_TAG_base_type nodes
referenced from typed stack ops and count how often they are used. */
static void
mark_base_types (dw_loc_descr_ref loc)
{
dw_die_ref base_type = NULL;
for (; loc; loc = loc->dw_loc_next)
{
switch (loc->dw_loc_opc)
{
case DW_OP_regval_type:
case DW_OP_deref_type:
case DW_OP_GNU_regval_type:
case DW_OP_GNU_deref_type:
base_type = loc->dw_loc_oprnd2.v.val_die_ref.die;
break;
case DW_OP_convert:
case DW_OP_reinterpret:
case DW_OP_GNU_convert:
case DW_OP_GNU_reinterpret:
if (loc->dw_loc_oprnd1.val_class == dw_val_class_unsigned_const)
continue;
/* FALLTHRU */
case DW_OP_const_type:
case DW_OP_GNU_const_type:
base_type = loc->dw_loc_oprnd1.v.val_die_ref.die;
break;
case DW_OP_entry_value:
case DW_OP_GNU_entry_value:
mark_base_types (loc->dw_loc_oprnd1.v.val_loc);
continue;
default:
continue;
}
gcc_assert (base_type->die_parent == comp_unit_die ());
if (base_type->die_mark)
base_type->die_mark++;
else
{
base_types.safe_push (base_type);
base_type->die_mark = 1;
}
}
}
/* Comparison function for sorting marked base types. */
static int
base_type_cmp (const void *x, const void *y)
{
dw_die_ref dx = *(const dw_die_ref *) x;
dw_die_ref dy = *(const dw_die_ref *) y;
unsigned int byte_size1, byte_size2;
unsigned int encoding1, encoding2;
unsigned int align1, align2;
if (dx->die_mark > dy->die_mark)
return -1;
if (dx->die_mark < dy->die_mark)
return 1;
byte_size1 = get_AT_unsigned (dx, DW_AT_byte_size);
byte_size2 = get_AT_unsigned (dy, DW_AT_byte_size);
if (byte_size1 < byte_size2)
return 1;
if (byte_size1 > byte_size2)
return -1;
encoding1 = get_AT_unsigned (dx, DW_AT_encoding);
encoding2 = get_AT_unsigned (dy, DW_AT_encoding);
if (encoding1 < encoding2)
return 1;
if (encoding1 > encoding2)
return -1;
align1 = get_AT_unsigned (dx, DW_AT_alignment);
align2 = get_AT_unsigned (dy, DW_AT_alignment);
if (align1 < align2)
return 1;
if (align1 > align2)
return -1;
return 0;
}
/* Move base types marked by mark_base_types as early as possible
in the CU, sorted by decreasing usage count both to make the
uleb128 references as small as possible and to make sure they
will have die_offset already computed by calc_die_sizes when
sizes of typed stack loc ops is computed. */
static void
move_marked_base_types (void)
{
unsigned int i;
dw_die_ref base_type, die, c;
if (base_types.is_empty ())
return;
/* Sort by decreasing usage count, they will be added again in that
order later on. */
base_types.qsort (base_type_cmp);
die = comp_unit_die ();
c = die->die_child;
do
{
dw_die_ref prev = c;
c = c->die_sib;
while (c->die_mark)
{
remove_child_with_prev (c, prev);
/* As base types got marked, there must be at least
one node other than DW_TAG_base_type. */
gcc_assert (die->die_child != NULL);
c = prev->die_sib;
}
}
while (c != die->die_child);
gcc_assert (die->die_child);
c = die->die_child;
for (i = 0; base_types.iterate (i, &base_type); i++)
{
base_type->die_mark = 0;
base_type->die_sib = c->die_sib;
c->die_sib = base_type;
c = base_type;
}
}
/* Helper function for resolve_addr, attempt to resolve
one CONST_STRING, return true if successful. Similarly verify that
SYMBOL_REFs refer to variables emitted in the current CU. */
static bool
resolve_one_addr (rtx *addr)
{
rtx rtl = *addr;
if (GET_CODE (rtl) == CONST_STRING)
{
size_t len = strlen (XSTR (rtl, 0)) + 1;
tree t = build_string (len, XSTR (rtl, 0));
tree tlen = size_int (len - 1);
TREE_TYPE (t)
= build_array_type (char_type_node, build_index_type (tlen));
rtl = lookup_constant_def (t);
if (!rtl || !MEM_P (rtl))
return false;
rtl = XEXP (rtl, 0);
if (GET_CODE (rtl) == SYMBOL_REF
&& SYMBOL_REF_DECL (rtl)
&& !TREE_ASM_WRITTEN (SYMBOL_REF_DECL (rtl)))
return false;
vec_safe_push (used_rtx_array, rtl);
*addr = rtl;
return true;
}
if (GET_CODE (rtl) == SYMBOL_REF
&& SYMBOL_REF_DECL (rtl))
{
if (TREE_CONSTANT_POOL_ADDRESS_P (rtl))
{
if (!TREE_ASM_WRITTEN (DECL_INITIAL (SYMBOL_REF_DECL (rtl))))
return false;
}
else if (!TREE_ASM_WRITTEN (SYMBOL_REF_DECL (rtl)))
return false;
}
if (GET_CODE (rtl) == CONST)
{
subrtx_ptr_iterator::array_type array;
FOR_EACH_SUBRTX_PTR (iter, array, &XEXP (rtl, 0), ALL)
if (!resolve_one_addr (*iter))
return false;
}
return true;
}
/* For STRING_CST, return SYMBOL_REF of its constant pool entry,
if possible, and create DW_TAG_dwarf_procedure that can be referenced
from DW_OP_implicit_pointer if the string hasn't been seen yet. */
static rtx
string_cst_pool_decl (tree t)
{
rtx rtl = output_constant_def (t, 1);
unsigned char *array;
dw_loc_descr_ref l;
tree decl;
size_t len;
dw_die_ref ref;
if (!rtl || !MEM_P (rtl))
return NULL_RTX;
rtl = XEXP (rtl, 0);
if (GET_CODE (rtl) != SYMBOL_REF
|| SYMBOL_REF_DECL (rtl) == NULL_TREE)
return NULL_RTX;
decl = SYMBOL_REF_DECL (rtl);
if (!lookup_decl_die (decl))
{
len = TREE_STRING_LENGTH (t);
vec_safe_push (used_rtx_array, rtl);
ref = new_die (DW_TAG_dwarf_procedure, comp_unit_die (), decl);
array = ggc_vec_alloc<unsigned char> (len);
memcpy (array, TREE_STRING_POINTER (t), len);
l = new_loc_descr (DW_OP_implicit_value, len, 0);
l->dw_loc_oprnd2.val_class = dw_val_class_vec;
l->dw_loc_oprnd2.v.val_vec.length = len;
l->dw_loc_oprnd2.v.val_vec.elt_size = 1;
l->dw_loc_oprnd2.v.val_vec.array = array;
add_AT_loc (ref, DW_AT_location, l);
equate_decl_number_to_die (decl, ref);
}
return rtl;
}
/* Helper function of resolve_addr_in_expr. LOC is
a DW_OP_addr followed by DW_OP_stack_value, either at the start
of exprloc or after DW_OP_{,bit_}piece, and val_addr can't be
resolved. Replace it (both DW_OP_addr and DW_OP_stack_value)
with DW_OP_implicit_pointer if possible
and return true, if unsuccessful, return false. */
static bool
optimize_one_addr_into_implicit_ptr (dw_loc_descr_ref loc)
{
rtx rtl = loc->dw_loc_oprnd1.v.val_addr;
HOST_WIDE_INT offset = 0;
dw_die_ref ref = NULL;
tree decl;
if (GET_CODE (rtl) == CONST
&& GET_CODE (XEXP (rtl, 0)) == PLUS
&& CONST_INT_P (XEXP (XEXP (rtl, 0), 1)))
{
offset = INTVAL (XEXP (XEXP (rtl, 0), 1));
rtl = XEXP (XEXP (rtl, 0), 0);
}
if (GET_CODE (rtl) == CONST_STRING)
{
size_t len = strlen (XSTR (rtl, 0)) + 1;
tree t = build_string (len, XSTR (rtl, 0));
tree tlen = size_int (len - 1);
TREE_TYPE (t)
= build_array_type (char_type_node, build_index_type (tlen));
rtl = string_cst_pool_decl (t);
if (!rtl)
return false;
}
if (GET_CODE (rtl) == SYMBOL_REF && SYMBOL_REF_DECL (rtl))
{
decl = SYMBOL_REF_DECL (rtl);
if (VAR_P (decl) && !DECL_EXTERNAL (decl))
{
ref = lookup_decl_die (decl);
if (ref && (get_AT (ref, DW_AT_location)
|| get_AT (ref, DW_AT_const_value)))
{
loc->dw_loc_opc = dwarf_OP (DW_OP_implicit_pointer);
loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
loc->dw_loc_oprnd1.val_entry = NULL;
loc->dw_loc_oprnd1.v.val_die_ref.die = ref;
loc->dw_loc_oprnd1.v.val_die_ref.external = 0;
loc->dw_loc_next = loc->dw_loc_next->dw_loc_next;
loc->dw_loc_oprnd2.v.val_int = offset;
return true;
}
}
}
return false;
}
/* Helper function for resolve_addr, handle one location
expression, return false if at least one CONST_STRING or SYMBOL_REF in
the location list couldn't be resolved. */
static bool
resolve_addr_in_expr (dw_attr_node *a, dw_loc_descr_ref loc)
{
dw_loc_descr_ref keep = NULL;
for (dw_loc_descr_ref prev = NULL; loc; prev = loc, loc = loc->dw_loc_next)
switch (loc->dw_loc_opc)
{
case DW_OP_addr:
if (!resolve_one_addr (&loc->dw_loc_oprnd1.v.val_addr))
{
if ((prev == NULL
|| prev->dw_loc_opc == DW_OP_piece
|| prev->dw_loc_opc == DW_OP_bit_piece)
&& loc->dw_loc_next
&& loc->dw_loc_next->dw_loc_opc == DW_OP_stack_value
&& (!dwarf_strict || dwarf_version >= 5)
&& optimize_one_addr_into_implicit_ptr (loc))
break;
return false;
}
break;
case DW_OP_GNU_addr_index:
case DW_OP_addrx:
case DW_OP_GNU_const_index:
case DW_OP_constx:
if ((loc->dw_loc_opc == DW_OP_GNU_addr_index
|| loc->dw_loc_opc == DW_OP_addrx)
|| ((loc->dw_loc_opc == DW_OP_GNU_const_index
|| loc->dw_loc_opc == DW_OP_constx)
&& loc->dtprel))
{
rtx rtl = loc->dw_loc_oprnd1.val_entry->addr.rtl;
if (!resolve_one_addr (&rtl))
return false;
remove_addr_table_entry (loc->dw_loc_oprnd1.val_entry);
loc->dw_loc_oprnd1.val_entry
= add_addr_table_entry (rtl, ate_kind_rtx);
}
break;
case DW_OP_const4u:
case DW_OP_const8u:
if (loc->dtprel
&& !resolve_one_addr (&loc->dw_loc_oprnd1.v.val_addr))
return false;
break;
case DW_OP_plus_uconst:
if (size_of_loc_descr (loc)
> size_of_int_loc_descriptor (loc->dw_loc_oprnd1.v.val_unsigned)
+ 1
&& loc->dw_loc_oprnd1.v.val_unsigned > 0)
{
dw_loc_descr_ref repl
= int_loc_descriptor (loc->dw_loc_oprnd1.v.val_unsigned);
add_loc_descr (&repl, new_loc_descr (DW_OP_plus, 0, 0));
add_loc_descr (&repl, loc->dw_loc_next);
*loc = *repl;
}
break;
case DW_OP_implicit_value:
if (loc->dw_loc_oprnd2.val_class == dw_val_class_addr
&& !resolve_one_addr (&loc->dw_loc_oprnd2.v.val_addr))
return false;
break;
case DW_OP_implicit_pointer:
case DW_OP_GNU_implicit_pointer:
case DW_OP_GNU_parameter_ref:
case DW_OP_GNU_variable_value:
if (loc->dw_loc_oprnd1.val_class == dw_val_class_decl_ref)
{
dw_die_ref ref
= lookup_decl_die (loc->dw_loc_oprnd1.v.val_decl_ref);
if (ref == NULL)
return false;
loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
loc->dw_loc_oprnd1.v.val_die_ref.die = ref;
loc->dw_loc_oprnd1.v.val_die_ref.external = 0;
}
if (loc->dw_loc_opc == DW_OP_GNU_variable_value)
{
if (prev == NULL
&& loc->dw_loc_next == NULL
&& AT_class (a) == dw_val_class_loc)
switch (a->dw_attr)
{
/* Following attributes allow both exprloc and reference,
so if the whole expression is DW_OP_GNU_variable_value
alone we could transform it into reference. */
case DW_AT_byte_size:
case DW_AT_bit_size:
case DW_AT_lower_bound:
case DW_AT_upper_bound:
case DW_AT_bit_stride:
case DW_AT_count:
case DW_AT_allocated:
case DW_AT_associated:
case DW_AT_byte_stride:
a->dw_attr_val.val_class = dw_val_class_die_ref;
a->dw_attr_val.val_entry = NULL;
a->dw_attr_val.v.val_die_ref.die
= loc->dw_loc_oprnd1.v.val_die_ref.die;
a->dw_attr_val.v.val_die_ref.external = 0;
return true;
default:
break;
}
if (dwarf_strict)
return false;
}
break;
case DW_OP_const_type:
case DW_OP_regval_type:
case DW_OP_deref_type:
case DW_OP_convert:
case DW_OP_reinterpret:
case DW_OP_GNU_const_type:
case DW_OP_GNU_regval_type:
case DW_OP_GNU_deref_type:
case DW_OP_GNU_convert:
case DW_OP_GNU_reinterpret:
while (loc->dw_loc_next
&& (loc->dw_loc_next->dw_loc_opc == DW_OP_convert
|| loc->dw_loc_next->dw_loc_opc == DW_OP_GNU_convert))
{
dw_die_ref base1, base2;
unsigned enc1, enc2, size1, size2;
if (loc->dw_loc_opc == DW_OP_regval_type
|| loc->dw_loc_opc == DW_OP_deref_type
|| loc->dw_loc_opc == DW_OP_GNU_regval_type
|| loc->dw_loc_opc == DW_OP_GNU_deref_type)
base1 = loc->dw_loc_oprnd2.v.val_die_ref.die;
else if (loc->dw_loc_oprnd1.val_class
== dw_val_class_unsigned_const)
break;
else
base1 = loc->dw_loc_oprnd1.v.val_die_ref.die;
if (loc->dw_loc_next->dw_loc_oprnd1.val_class
== dw_val_class_unsigned_const)
break;
base2 = loc->dw_loc_next->dw_loc_oprnd1.v.val_die_ref.die;
gcc_assert (base1->die_tag == DW_TAG_base_type
&& base2->die_tag == DW_TAG_base_type);
enc1 = get_AT_unsigned (base1, DW_AT_encoding);
enc2 = get_AT_unsigned (base2, DW_AT_encoding);
size1 = get_AT_unsigned (base1, DW_AT_byte_size);
size2 = get_AT_unsigned (base2, DW_AT_byte_size);
if (size1 == size2
&& (((enc1 == DW_ATE_unsigned || enc1 == DW_ATE_signed)
&& (enc2 == DW_ATE_unsigned || enc2 == DW_ATE_signed)
&& loc != keep)
|| enc1 == enc2))
{
/* Optimize away next DW_OP_convert after
adjusting LOC's base type die reference. */
if (loc->dw_loc_opc == DW_OP_regval_type
|| loc->dw_loc_opc == DW_OP_deref_type
|| loc->dw_loc_opc == DW_OP_GNU_regval_type
|| loc->dw_loc_opc == DW_OP_GNU_deref_type)
loc->dw_loc_oprnd2.v.val_die_ref.die = base2;
else
loc->dw_loc_oprnd1.v.val_die_ref.die = base2;
loc->dw_loc_next = loc->dw_loc_next->dw_loc_next;
continue;
}
/* Don't change integer DW_OP_convert after e.g. floating
point typed stack entry. */
else if (enc1 != DW_ATE_unsigned && enc1 != DW_ATE_signed)
keep = loc->dw_loc_next;
break;
}
break;
default:
break;
}
return true;
}
/* Helper function of resolve_addr. DIE had DW_AT_location of
DW_OP_addr alone, which referred to DECL in DW_OP_addr's operand
and DW_OP_addr couldn't be resolved. resolve_addr has already
removed the DW_AT_location attribute. This function attempts to
add a new DW_AT_location attribute with DW_OP_implicit_pointer
to it or DW_AT_const_value attribute, if possible. */
static void
optimize_location_into_implicit_ptr (dw_die_ref die, tree decl)
{
if (!VAR_P (decl)
|| lookup_decl_die (decl) != die
|| DECL_EXTERNAL (decl)
|| !TREE_STATIC (decl)
|| DECL_INITIAL (decl) == NULL_TREE
|| DECL_P (DECL_INITIAL (decl))
|| get_AT (die, DW_AT_const_value))
return;
tree init = DECL_INITIAL (decl);
HOST_WIDE_INT offset = 0;
/* For variables that have been optimized away and thus
don't have a memory location, see if we can emit
DW_AT_const_value instead. */
if (tree_add_const_value_attribute (die, init))
return;
if (dwarf_strict && dwarf_version < 5)
return;
/* If init is ADDR_EXPR or POINTER_PLUS_EXPR of ADDR_EXPR,
and ADDR_EXPR refers to a decl that has DW_AT_location or
DW_AT_const_value (but isn't addressable, otherwise
resolving the original DW_OP_addr wouldn't fail), see if
we can add DW_OP_implicit_pointer. */
STRIP_NOPS (init);
if (TREE_CODE (init) == POINTER_PLUS_EXPR
&& tree_fits_shwi_p (TREE_OPERAND (init, 1)))
{
offset = tree_to_shwi (TREE_OPERAND (init, 1));
init = TREE_OPERAND (init, 0);
STRIP_NOPS (init);
}
if (TREE_CODE (init) != ADDR_EXPR)
return;
if ((TREE_CODE (TREE_OPERAND (init, 0)) == STRING_CST
&& !TREE_ASM_WRITTEN (TREE_OPERAND (init, 0)))
|| (TREE_CODE (TREE_OPERAND (init, 0)) == VAR_DECL
&& !DECL_EXTERNAL (TREE_OPERAND (init, 0))
&& TREE_OPERAND (init, 0) != decl))
{
dw_die_ref ref;
dw_loc_descr_ref l;
if (TREE_CODE (TREE_OPERAND (init, 0)) == STRING_CST)
{
rtx rtl = string_cst_pool_decl (TREE_OPERAND (init, 0));
if (!rtl)
return;
decl = SYMBOL_REF_DECL (rtl);
}
else
decl = TREE_OPERAND (init, 0);
ref = lookup_decl_die (decl);
if (ref == NULL
|| (!get_AT (ref, DW_AT_location)
&& !get_AT (ref, DW_AT_const_value)))
return;
l = new_loc_descr (dwarf_OP (DW_OP_implicit_pointer), 0, offset);
l->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
l->dw_loc_oprnd1.v.val_die_ref.die = ref;
l->dw_loc_oprnd1.v.val_die_ref.external = 0;
add_AT_loc (die, DW_AT_location, l);
}
}
/* Return NULL if l is a DWARF expression, or first op that is not
valid DWARF expression. */
static dw_loc_descr_ref
non_dwarf_expression (dw_loc_descr_ref l)
{
while (l)
{
if (l->dw_loc_opc >= DW_OP_reg0 && l->dw_loc_opc <= DW_OP_reg31)
return l;
switch (l->dw_loc_opc)
{
case DW_OP_regx:
case DW_OP_implicit_value:
case DW_OP_stack_value:
case DW_OP_implicit_pointer:
case DW_OP_GNU_implicit_pointer:
case DW_OP_GNU_parameter_ref:
case DW_OP_piece:
case DW_OP_bit_piece:
return l;
default:
break;
}
l = l->dw_loc_next;
}
return NULL;
}
/* Return adjusted copy of EXPR:
If it is empty DWARF expression, return it.
If it is valid non-empty DWARF expression,
return copy of EXPR with DW_OP_deref appended to it.
If it is DWARF expression followed by DW_OP_reg{N,x}, return
copy of the DWARF expression with DW_OP_breg{N,x} <0> appended.
If it is DWARF expression followed by DW_OP_stack_value, return
copy of the DWARF expression without anything appended.
Otherwise, return NULL. */
static dw_loc_descr_ref
copy_deref_exprloc (dw_loc_descr_ref expr)
{
dw_loc_descr_ref tail = NULL;
if (expr == NULL)
return NULL;
dw_loc_descr_ref l = non_dwarf_expression (expr);
if (l && l->dw_loc_next)
return NULL;
if (l)
{
if (l->dw_loc_opc >= DW_OP_reg0 && l->dw_loc_opc <= DW_OP_reg31)
tail = new_loc_descr ((enum dwarf_location_atom)
(DW_OP_breg0 + (l->dw_loc_opc - DW_OP_reg0)),
0, 0);
else
switch (l->dw_loc_opc)
{
case DW_OP_regx:
tail = new_loc_descr (DW_OP_bregx,
l->dw_loc_oprnd1.v.val_unsigned, 0);
break;
case DW_OP_stack_value:
break;
default:
return NULL;
}
}
else
tail = new_loc_descr (DW_OP_deref, 0, 0);
dw_loc_descr_ref ret = NULL, *p = &ret;
while (expr != l)
{
*p = new_loc_descr (expr->dw_loc_opc, 0, 0);
(*p)->dw_loc_oprnd1 = expr->dw_loc_oprnd1;
(*p)->dw_loc_oprnd2 = expr->dw_loc_oprnd2;
p = &(*p)->dw_loc_next;
expr = expr->dw_loc_next;
}
*p = tail;
return ret;
}
/* For DW_AT_string_length attribute with DW_OP_GNU_variable_value
reference to a variable or argument, adjust it if needed and return:
-1 if the DW_AT_string_length attribute and DW_AT_{string_length_,}byte_size
attribute if present should be removed
0 keep the attribute perhaps with minor modifications, no need to rescan
1 if the attribute has been successfully adjusted. */
static int
optimize_string_length (dw_attr_node *a)
{
dw_loc_descr_ref l = AT_loc (a), lv;
dw_die_ref die;
if (l->dw_loc_oprnd1.val_class == dw_val_class_decl_ref)
{
tree decl = l->dw_loc_oprnd1.v.val_decl_ref;
die = lookup_decl_die (decl);
if (die)
{
l->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
l->dw_loc_oprnd1.v.val_die_ref.die = die;
l->dw_loc_oprnd1.v.val_die_ref.external = 0;
}
else
return -1;
}
else
die = l->dw_loc_oprnd1.v.val_die_ref.die;
/* DWARF5 allows reference class, so we can then reference the DIE.
Only do this for DW_OP_GNU_variable_value DW_OP_stack_value. */
if (l->dw_loc_next != NULL && dwarf_version >= 5)
{
a->dw_attr_val.val_class = dw_val_class_die_ref;
a->dw_attr_val.val_entry = NULL;
a->dw_attr_val.v.val_die_ref.die = die;
a->dw_attr_val.v.val_die_ref.external = 0;
return 0;
}
dw_attr_node *av = get_AT (die, DW_AT_location);
dw_loc_list_ref d;
bool non_dwarf_expr = false;
if (av == NULL)
return dwarf_strict ? -1 : 0;
switch (AT_class (av))
{
case dw_val_class_loc_list:
for (d = AT_loc_list (av); d != NULL; d = d->dw_loc_next)
if (d->expr && non_dwarf_expression (d->expr))
non_dwarf_expr = true;
break;
case dw_val_class_view_list:
gcc_unreachable ();
case dw_val_class_loc:
lv = AT_loc (av);
if (lv == NULL)
return dwarf_strict ? -1 : 0;
if (non_dwarf_expression (lv))
non_dwarf_expr = true;
break;
default:
return dwarf_strict ? -1 : 0;
}
/* If it is safe to transform DW_OP_GNU_variable_value DW_OP_stack_value
into DW_OP_call4 or DW_OP_GNU_variable_value into
DW_OP_call4 DW_OP_deref, do so. */
if (!non_dwarf_expr
&& (l->dw_loc_next != NULL || AT_class (av) == dw_val_class_loc))
{
l->dw_loc_opc = DW_OP_call4;
if (l->dw_loc_next)
l->dw_loc_next = NULL;
else
l->dw_loc_next = new_loc_descr (DW_OP_deref, 0, 0);
return 0;
}
/* For DW_OP_GNU_variable_value DW_OP_stack_value, we can just
copy over the DW_AT_location attribute from die to a. */
if (l->dw_loc_next != NULL)
{
a->dw_attr_val = av->dw_attr_val;
return 1;
}
dw_loc_list_ref list, *p;
switch (AT_class (av))
{
case dw_val_class_loc_list:
p = &list;
list = NULL;
for (d = AT_loc_list (av); d != NULL; d = d->dw_loc_next)
{
lv = copy_deref_exprloc (d->expr);
if (lv)
{
*p = new_loc_list (lv, d->begin, d->vbegin, d->end, d->vend, d->section);
p = &(*p)->dw_loc_next;
}
else if (!dwarf_strict && d->expr)
return 0;
}
if (list == NULL)
return dwarf_strict ? -1 : 0;
a->dw_attr_val.val_class = dw_val_class_loc_list;
gen_llsym (list);
*AT_loc_list_ptr (a) = list;
return 1;
case dw_val_class_loc:
lv = copy_deref_exprloc (AT_loc (av));
if (lv == NULL)
return dwarf_strict ? -1 : 0;
a->dw_attr_val.v.val_loc = lv;
return 1;
default:
gcc_unreachable ();
}
}
/* Resolve DW_OP_addr and DW_AT_const_value CONST_STRING arguments to
an address in .rodata section if the string literal is emitted there,
or remove the containing location list or replace DW_AT_const_value
with DW_AT_location and empty location expression, if it isn't found
in .rodata. Similarly for SYMBOL_REFs, keep only those that refer
to something that has been emitted in the current CU. */
static void
resolve_addr (dw_die_ref die)
{
dw_die_ref c;
dw_attr_node *a;
dw_loc_list_ref *curr, *start, loc;
unsigned ix;
bool remove_AT_byte_size = false;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
switch (AT_class (a))
{
case dw_val_class_loc_list:
start = curr = AT_loc_list_ptr (a);
loc = *curr;
gcc_assert (loc);
/* The same list can be referenced more than once. See if we have
already recorded the result from a previous pass. */
if (loc->replaced)
*curr = loc->dw_loc_next;
else if (!loc->resolved_addr)
{
/* As things stand, we do not expect or allow one die to
reference a suffix of another die's location list chain.
References must be identical or completely separate.
There is therefore no need to cache the result of this
pass on any list other than the first; doing so
would lead to unnecessary writes. */
while (*curr)
{
gcc_assert (!(*curr)->replaced && !(*curr)->resolved_addr);
if (!resolve_addr_in_expr (a, (*curr)->expr))
{
dw_loc_list_ref next = (*curr)->dw_loc_next;
dw_loc_descr_ref l = (*curr)->expr;
if (next && (*curr)->ll_symbol)
{
gcc_assert (!next->ll_symbol);
next->ll_symbol = (*curr)->ll_symbol;
next->vl_symbol = (*curr)->vl_symbol;
}
if (dwarf_split_debug_info)
remove_loc_list_addr_table_entries (l);
*curr = next;
}
else
{
mark_base_types ((*curr)->expr);
curr = &(*curr)->dw_loc_next;
}
}
if (loc == *start)
loc->resolved_addr = 1;
else
{
loc->replaced = 1;
loc->dw_loc_next = *start;
}
}
if (!*start)
{
remove_AT (die, a->dw_attr);
ix--;
}
break;
case dw_val_class_view_list:
{
gcc_checking_assert (a->dw_attr == DW_AT_GNU_locviews);
gcc_checking_assert (dwarf2out_locviews_in_attribute ());
dw_val_node *llnode
= view_list_to_loc_list_val_node (&a->dw_attr_val);
/* If we no longer have a loclist, or it no longer needs
views, drop this attribute. */
if (!llnode || !llnode->v.val_loc_list->vl_symbol)
{
remove_AT (die, a->dw_attr);
ix--;
}
break;
}
case dw_val_class_loc:
{
dw_loc_descr_ref l = AT_loc (a);
/* DW_OP_GNU_variable_value DW_OP_stack_value or
DW_OP_GNU_variable_value in DW_AT_string_length can be converted
into DW_OP_call4 or DW_OP_call4 DW_OP_deref, which is standard
DWARF4 unlike DW_OP_GNU_variable_value. Or for DWARF5
DW_OP_GNU_variable_value DW_OP_stack_value can be replaced
with DW_FORM_ref referencing the same DIE as
DW_OP_GNU_variable_value used to reference. */
if (a->dw_attr == DW_AT_string_length
&& l
&& l->dw_loc_opc == DW_OP_GNU_variable_value
&& (l->dw_loc_next == NULL
|| (l->dw_loc_next->dw_loc_next == NULL
&& l->dw_loc_next->dw_loc_opc == DW_OP_stack_value)))
{
switch (optimize_string_length (a))
{
case -1:
remove_AT (die, a->dw_attr);
ix--;
/* If we drop DW_AT_string_length, we need to drop also
DW_AT_{string_length_,}byte_size. */
remove_AT_byte_size = true;
continue;
default:
break;
case 1:
/* Even if we keep the optimized DW_AT_string_length,
it might have changed AT_class, so process it again. */
ix--;
continue;
}
}
/* For -gdwarf-2 don't attempt to optimize
DW_AT_data_member_location containing
DW_OP_plus_uconst - older consumers might
rely on it being that op instead of a more complex,
but shorter, location description. */
if ((dwarf_version > 2
|| a->dw_attr != DW_AT_data_member_location
|| l == NULL
|| l->dw_loc_opc != DW_OP_plus_uconst
|| l->dw_loc_next != NULL)
&& !resolve_addr_in_expr (a, l))
{
if (dwarf_split_debug_info)
remove_loc_list_addr_table_entries (l);
if (l != NULL
&& l->dw_loc_next == NULL
&& l->dw_loc_opc == DW_OP_addr
&& GET_CODE (l->dw_loc_oprnd1.v.val_addr) == SYMBOL_REF
&& SYMBOL_REF_DECL (l->dw_loc_oprnd1.v.val_addr)
&& a->dw_attr == DW_AT_location)
{
tree decl = SYMBOL_REF_DECL (l->dw_loc_oprnd1.v.val_addr);
remove_AT (die, a->dw_attr);
ix--;
optimize_location_into_implicit_ptr (die, decl);
break;
}
if (a->dw_attr == DW_AT_string_length)
/* If we drop DW_AT_string_length, we need to drop also
DW_AT_{string_length_,}byte_size. */
remove_AT_byte_size = true;
remove_AT (die, a->dw_attr);
ix--;
}
else
mark_base_types (l);
}
break;
case dw_val_class_addr:
if (a->dw_attr == DW_AT_const_value
&& !resolve_one_addr (&a->dw_attr_val.v.val_addr))
{
if (AT_index (a) != NOT_INDEXED)
remove_addr_table_entry (a->dw_attr_val.val_entry);
remove_AT (die, a->dw_attr);
ix--;
}
if ((die->die_tag == DW_TAG_call_site
&& a->dw_attr == DW_AT_call_origin)
|| (die->die_tag == DW_TAG_GNU_call_site
&& a->dw_attr == DW_AT_abstract_origin))
{
tree tdecl = SYMBOL_REF_DECL (a->dw_attr_val.v.val_addr);
dw_die_ref tdie = lookup_decl_die (tdecl);
dw_die_ref cdie;
if (tdie == NULL
&& DECL_EXTERNAL (tdecl)
&& DECL_ABSTRACT_ORIGIN (tdecl) == NULL_TREE
&& (cdie = lookup_context_die (DECL_CONTEXT (tdecl))))
{
dw_die_ref pdie = cdie;
/* Make sure we don't add these DIEs into type units.
We could emit skeleton DIEs for context (namespaces,
outer structs/classes) and a skeleton DIE for the
innermost context with DW_AT_signature pointing to the
type unit. See PR78835. */
while (pdie && pdie->die_tag != DW_TAG_type_unit)
pdie = pdie->die_parent;
if (pdie == NULL)
{
/* Creating a full DIE for tdecl is overly expensive and
at this point even wrong when in the LTO phase
as it can end up generating new type DIEs we didn't
output and thus optimize_external_refs will crash. */
tdie = new_die (DW_TAG_subprogram, cdie, NULL_TREE);
add_AT_flag (tdie, DW_AT_external, 1);
add_AT_flag (tdie, DW_AT_declaration, 1);
add_linkage_attr (tdie, tdecl);
add_name_and_src_coords_attributes (tdie, tdecl, true);
equate_decl_number_to_die (tdecl, tdie);
}
}
if (tdie)
{
a->dw_attr_val.val_class = dw_val_class_die_ref;
a->dw_attr_val.v.val_die_ref.die = tdie;
a->dw_attr_val.v.val_die_ref.external = 0;
}
else
{
if (AT_index (a) != NOT_INDEXED)
remove_addr_table_entry (a->dw_attr_val.val_entry);
remove_AT (die, a->dw_attr);
ix--;
}
}
break;
default:
break;
}
if (remove_AT_byte_size)
remove_AT (die, dwarf_version >= 5
? DW_AT_string_length_byte_size
: DW_AT_byte_size);
FOR_EACH_CHILD (die, c, resolve_addr (c));
}
/* Helper routines for optimize_location_lists.
This pass tries to share identical local lists in .debug_loc
section. */
/* Iteratively hash operands of LOC opcode into HSTATE. */
static void
hash_loc_operands (dw_loc_descr_ref loc, inchash::hash &hstate)
{
dw_val_ref val1 = &loc->dw_loc_oprnd1;
dw_val_ref val2 = &loc->dw_loc_oprnd2;
switch (loc->dw_loc_opc)
{
case DW_OP_const4u:
case DW_OP_const8u:
if (loc->dtprel)
goto hash_addr;
/* FALLTHRU */
case DW_OP_const1u:
case DW_OP_const1s:
case DW_OP_const2u:
case DW_OP_const2s:
case DW_OP_const4s:
case DW_OP_const8s:
case DW_OP_constu:
case DW_OP_consts:
case DW_OP_pick:
case DW_OP_plus_uconst:
case DW_OP_breg0:
case DW_OP_breg1:
case DW_OP_breg2:
case DW_OP_breg3:
case DW_OP_breg4:
case DW_OP_breg5:
case DW_OP_breg6:
case DW_OP_breg7:
case DW_OP_breg8:
case DW_OP_breg9:
case DW_OP_breg10:
case DW_OP_breg11:
case DW_OP_breg12:
case DW_OP_breg13:
case DW_OP_breg14:
case DW_OP_breg15:
case DW_OP_breg16:
case DW_OP_breg17:
case DW_OP_breg18:
case DW_OP_breg19:
case DW_OP_breg20:
case DW_OP_breg21:
case DW_OP_breg22:
case DW_OP_breg23:
case DW_OP_breg24:
case DW_OP_breg25:
case DW_OP_breg26:
case DW_OP_breg27:
case DW_OP_breg28:
case DW_OP_breg29:
case DW_OP_breg30:
case DW_OP_breg31:
case DW_OP_regx:
case DW_OP_fbreg:
case DW_OP_piece:
case DW_OP_deref_size:
case DW_OP_xderef_size:
hstate.add_object (val1->v.val_int);
break;
case DW_OP_skip:
case DW_OP_bra:
{
int offset;
gcc_assert (val1->val_class == dw_val_class_loc);
offset = val1->v.val_loc->dw_loc_addr - (loc->dw_loc_addr + 3);
hstate.add_object (offset);
}
break;
case DW_OP_implicit_value:
hstate.add_object (val1->v.val_unsigned);
switch (val2->val_class)
{
case dw_val_class_const:
hstate.add_object (val2->v.val_int);
break;
case dw_val_class_vec:
{
unsigned int elt_size = val2->v.val_vec.elt_size;
unsigned int len = val2->v.val_vec.length;
hstate.add_int (elt_size);
hstate.add_int (len);
hstate.add (val2->v.val_vec.array, len * elt_size);
}
break;
case dw_val_class_const_double:
hstate.add_object (val2->v.val_double.low);
hstate.add_object (val2->v.val_double.high);
break;
case dw_val_class_wide_int:
hstate.add (val2->v.val_wide->get_val (),
get_full_len (*val2->v.val_wide)
* HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR);
break;
case dw_val_class_addr:
inchash::add_rtx (val2->v.val_addr, hstate);
break;
default:
gcc_unreachable ();
}
break;
case DW_OP_bregx:
case DW_OP_bit_piece:
hstate.add_object (val1->v.val_int);
hstate.add_object (val2->v.val_int);
break;
case DW_OP_addr:
hash_addr:
if (loc->dtprel)
{
unsigned char dtprel = 0xd1;
hstate.add_object (dtprel);
}
inchash::add_rtx (val1->v.val_addr, hstate);
break;
case DW_OP_GNU_addr_index:
case DW_OP_addrx:
case DW_OP_GNU_const_index:
case DW_OP_constx:
{
if (loc->dtprel)
{
unsigned char dtprel = 0xd1;
hstate.add_object (dtprel);
}
inchash::add_rtx (val1->val_entry->addr.rtl, hstate);
}
break;
case DW_OP_implicit_pointer:
case DW_OP_GNU_implicit_pointer:
hstate.add_int (val2->v.val_int);
break;
case DW_OP_entry_value:
case DW_OP_GNU_entry_value:
hstate.add_object (val1->v.val_loc);
break;
case DW_OP_regval_type:
case DW_OP_deref_type:
case DW_OP_GNU_regval_type:
case DW_OP_GNU_deref_type:
{
unsigned int byte_size
= get_AT_unsigned (val2->v.val_die_ref.die, DW_AT_byte_size);
unsigned int encoding
= get_AT_unsigned (val2->v.val_die_ref.die, DW_AT_encoding);
hstate.add_object (val1->v.val_int);
hstate.add_object (byte_size);
hstate.add_object (encoding);
}
break;
case DW_OP_convert:
case DW_OP_reinterpret:
case DW_OP_GNU_convert:
case DW_OP_GNU_reinterpret:
if (val1->val_class == dw_val_class_unsigned_const)
{
hstate.add_object (val1->v.val_unsigned);
break;
}
/* FALLTHRU */
case DW_OP_const_type:
case DW_OP_GNU_const_type:
{
unsigned int byte_size
= get_AT_unsigned (val1->v.val_die_ref.die, DW_AT_byte_size);
unsigned int encoding
= get_AT_unsigned (val1->v.val_die_ref.die, DW_AT_encoding);
hstate.add_object (byte_size);
hstate.add_object (encoding);
if (loc->dw_loc_opc != DW_OP_const_type
&& loc->dw_loc_opc != DW_OP_GNU_const_type)
break;
hstate.add_object (val2->val_class);
switch (val2->val_class)
{
case dw_val_class_const:
hstate.add_object (val2->v.val_int);
break;
case dw_val_class_vec:
{
unsigned int elt_size = val2->v.val_vec.elt_size;
unsigned int len = val2->v.val_vec.length;
hstate.add_object (elt_size);
hstate.add_object (len);
hstate.add (val2->v.val_vec.array, len * elt_size);
}
break;
case dw_val_class_const_double:
hstate.add_object (val2->v.val_double.low);
hstate.add_object (val2->v.val_double.high);
break;
case dw_val_class_wide_int:
hstate.add (val2->v.val_wide->get_val (),
get_full_len (*val2->v.val_wide)
* HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR);
break;
default:
gcc_unreachable ();
}
}
break;
default:
/* Other codes have no operands. */
break;
}
}
/* Iteratively hash the whole DWARF location expression LOC into HSTATE. */
static inline void
hash_locs (dw_loc_descr_ref loc, inchash::hash &hstate)
{
dw_loc_descr_ref l;
bool sizes_computed = false;
/* Compute sizes, so that DW_OP_skip/DW_OP_bra can be checksummed. */
size_of_locs (loc);
for (l = loc; l != NULL; l = l->dw_loc_next)
{
enum dwarf_location_atom opc = l->dw_loc_opc;
hstate.add_object (opc);
if ((opc == DW_OP_skip || opc == DW_OP_bra) && !sizes_computed)
{
size_of_locs (loc);
sizes_computed = true;
}
hash_loc_operands (l, hstate);
}
}
/* Compute hash of the whole location list LIST_HEAD. */
static inline void
hash_loc_list (dw_loc_list_ref list_head)
{
dw_loc_list_ref curr = list_head;
inchash::hash hstate;
for (curr = list_head; curr != NULL; curr = curr->dw_loc_next)
{
hstate.add (curr->begin, strlen (curr->begin) + 1);
hstate.add (curr->end, strlen (curr->end) + 1);
hstate.add_object (curr->vbegin);
hstate.add_object (curr->vend);
if (curr->section)
hstate.add (curr->section, strlen (curr->section) + 1);
hash_locs (curr->expr, hstate);
}
list_head->hash = hstate.end ();
}
/* Return true if X and Y opcodes have the same operands. */
static inline bool
compare_loc_operands (dw_loc_descr_ref x, dw_loc_descr_ref y)
{
dw_val_ref valx1 = &x->dw_loc_oprnd1;
dw_val_ref valx2 = &x->dw_loc_oprnd2;
dw_val_ref valy1 = &y->dw_loc_oprnd1;
dw_val_ref valy2 = &y->dw_loc_oprnd2;
switch (x->dw_loc_opc)
{
case DW_OP_const4u:
case DW_OP_const8u:
if (x->dtprel)
goto hash_addr;
/* FALLTHRU */
case DW_OP_const1u:
case DW_OP_const1s:
case DW_OP_const2u:
case DW_OP_const2s:
case DW_OP_const4s:
case DW_OP_const8s:
case DW_OP_constu:
case DW_OP_consts:
case DW_OP_pick:
case DW_OP_plus_uconst:
case DW_OP_breg0:
case DW_OP_breg1:
case DW_OP_breg2:
case DW_OP_breg3:
case DW_OP_breg4:
case DW_OP_breg5:
case DW_OP_breg6:
case DW_OP_breg7:
case DW_OP_breg8:
case DW_OP_breg9:
case DW_OP_breg10:
case DW_OP_breg11:
case DW_OP_breg12:
case DW_OP_breg13:
case DW_OP_breg14:
case DW_OP_breg15:
case DW_OP_breg16:
case DW_OP_breg17:
case DW_OP_breg18:
case DW_OP_breg19:
case DW_OP_breg20:
case DW_OP_breg21:
case DW_OP_breg22:
case DW_OP_breg23:
case DW_OP_breg24:
case DW_OP_breg25:
case DW_OP_breg26:
case DW_OP_breg27:
case DW_OP_breg28:
case DW_OP_breg29:
case DW_OP_breg30:
case DW_OP_breg31:
case DW_OP_regx:
case DW_OP_fbreg:
case DW_OP_piece:
case DW_OP_deref_size:
case DW_OP_xderef_size:
return valx1->v.val_int == valy1->v.val_int;
case DW_OP_skip:
case DW_OP_bra:
/* If splitting debug info, the use of DW_OP_GNU_addr_index
can cause irrelevant differences in dw_loc_addr. */
gcc_assert (valx1->val_class == dw_val_class_loc
&& valy1->val_class == dw_val_class_loc
&& (dwarf_split_debug_info
|| x->dw_loc_addr == y->dw_loc_addr));
return valx1->v.val_loc->dw_loc_addr == valy1->v.val_loc->dw_loc_addr;
case DW_OP_implicit_value:
if (valx1->v.val_unsigned != valy1->v.val_unsigned
|| valx2->val_class != valy2->val_class)
return false;
switch (valx2->val_class)
{
case dw_val_class_const:
return valx2->v.val_int == valy2->v.val_int;
case dw_val_class_vec:
return valx2->v.val_vec.elt_size == valy2->v.val_vec.elt_size
&& valx2->v.val_vec.length == valy2->v.val_vec.length
&& memcmp (valx2->v.val_vec.array, valy2->v.val_vec.array,
valx2->v.val_vec.elt_size
* valx2->v.val_vec.length) == 0;
case dw_val_class_const_double:
return valx2->v.val_double.low == valy2->v.val_double.low
&& valx2->v.val_double.high == valy2->v.val_double.high;
case dw_val_class_wide_int:
return *valx2->v.val_wide == *valy2->v.val_wide;
case dw_val_class_addr:
return rtx_equal_p (valx2->v.val_addr, valy2->v.val_addr);
default:
gcc_unreachable ();
}
case DW_OP_bregx:
case DW_OP_bit_piece:
return valx1->v.val_int == valy1->v.val_int
&& valx2->v.val_int == valy2->v.val_int;
case DW_OP_addr:
hash_addr:
return rtx_equal_p (valx1->v.val_addr, valy1->v.val_addr);
case DW_OP_GNU_addr_index:
case DW_OP_addrx:
case DW_OP_GNU_const_index:
case DW_OP_constx:
{
rtx ax1 = valx1->val_entry->addr.rtl;
rtx ay1 = valy1->val_entry->addr.rtl;
return rtx_equal_p (ax1, ay1);
}
case DW_OP_implicit_pointer:
case DW_OP_GNU_implicit_pointer:
return valx1->val_class == dw_val_class_die_ref
&& valx1->val_class == valy1->val_class
&& valx1->v.val_die_ref.die == valy1->v.val_die_ref.die
&& valx2->v.val_int == valy2->v.val_int;
case DW_OP_entry_value:
case DW_OP_GNU_entry_value:
return compare_loc_operands (valx1->v.val_loc, valy1->v.val_loc);
case DW_OP_const_type:
case DW_OP_GNU_const_type:
if (valx1->v.val_die_ref.die != valy1->v.val_die_ref.die
|| valx2->val_class != valy2->val_class)
return false;
switch (valx2->val_class)
{
case dw_val_class_const:
return valx2->v.val_int == valy2->v.val_int;
case dw_val_class_vec:
return valx2->v.val_vec.elt_size == valy2->v.val_vec.elt_size
&& valx2->v.val_vec.length == valy2->v.val_vec.length
&& memcmp (valx2->v.val_vec.array, valy2->v.val_vec.array,
valx2->v.val_vec.elt_size
* valx2->v.val_vec.length) == 0;
case dw_val_class_const_double:
return valx2->v.val_double.low == valy2->v.val_double.low
&& valx2->v.val_double.high == valy2->v.val_double.high;
case dw_val_class_wide_int:
return *valx2->v.val_wide == *valy2->v.val_wide;
default:
gcc_unreachable ();
}
case DW_OP_regval_type:
case DW_OP_deref_type:
case DW_OP_GNU_regval_type:
case DW_OP_GNU_deref_type:
return valx1->v.val_int == valy1->v.val_int
&& valx2->v.val_die_ref.die == valy2->v.val_die_ref.die;
case DW_OP_convert:
case DW_OP_reinterpret:
case DW_OP_GNU_convert:
case DW_OP_GNU_reinterpret:
if (valx1->val_class != valy1->val_class)
return false;
if (valx1->val_class == dw_val_class_unsigned_const)
return valx1->v.val_unsigned == valy1->v.val_unsigned;
return valx1->v.val_die_ref.die == valy1->v.val_die_ref.die;
case DW_OP_GNU_parameter_ref:
return valx1->val_class == dw_val_class_die_ref
&& valx1->val_class == valy1->val_class
&& valx1->v.val_die_ref.die == valy1->v.val_die_ref.die;
default:
/* Other codes have no operands. */
return true;
}
}
/* Return true if DWARF location expressions X and Y are the same. */
static inline bool
compare_locs (dw_loc_descr_ref x, dw_loc_descr_ref y)
{
for (; x != NULL && y != NULL; x = x->dw_loc_next, y = y->dw_loc_next)
if (x->dw_loc_opc != y->dw_loc_opc
|| x->dtprel != y->dtprel
|| !compare_loc_operands (x, y))
break;
return x == NULL && y == NULL;
}
/* Hashtable helpers. */
struct loc_list_hasher : nofree_ptr_hash <dw_loc_list_struct>
{
static inline hashval_t hash (const dw_loc_list_struct *);
static inline bool equal (const dw_loc_list_struct *,
const dw_loc_list_struct *);
};
/* Return precomputed hash of location list X. */
inline hashval_t
loc_list_hasher::hash (const dw_loc_list_struct *x)
{
return x->hash;
}
/* Return true if location lists A and B are the same. */
inline bool
loc_list_hasher::equal (const dw_loc_list_struct *a,
const dw_loc_list_struct *b)
{
if (a == b)
return 1;
if (a->hash != b->hash)
return 0;
for (; a != NULL && b != NULL; a = a->dw_loc_next, b = b->dw_loc_next)
if (strcmp (a->begin, b->begin) != 0
|| strcmp (a->end, b->end) != 0
|| (a->section == NULL) != (b->section == NULL)
|| (a->section && strcmp (a->section, b->section) != 0)
|| a->vbegin != b->vbegin || a->vend != b->vend
|| !compare_locs (a->expr, b->expr))
break;
return a == NULL && b == NULL;
}
typedef hash_table<loc_list_hasher> loc_list_hash_type;
/* Recursively optimize location lists referenced from DIE
children and share them whenever possible. */
static void
optimize_location_lists_1 (dw_die_ref die, loc_list_hash_type *htab)
{
dw_die_ref c;
dw_attr_node *a;
unsigned ix;
dw_loc_list_struct **slot;
bool drop_locviews = false;
bool has_locviews = false;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (AT_class (a) == dw_val_class_loc_list)
{
dw_loc_list_ref list = AT_loc_list (a);
/* TODO: perform some optimizations here, before hashing
it and storing into the hash table. */
hash_loc_list (list);
slot = htab->find_slot_with_hash (list, list->hash, INSERT);
if (*slot == NULL)
{
*slot = list;
if (loc_list_has_views (list))
gcc_assert (list->vl_symbol);
else if (list->vl_symbol)
{
drop_locviews = true;
list->vl_symbol = NULL;
}
}
else
{
if (list->vl_symbol && !(*slot)->vl_symbol)
drop_locviews = true;
a->dw_attr_val.v.val_loc_list = *slot;
}
}
else if (AT_class (a) == dw_val_class_view_list)
{
gcc_checking_assert (a->dw_attr == DW_AT_GNU_locviews);
has_locviews = true;
}
if (drop_locviews && has_locviews)
remove_AT (die, DW_AT_GNU_locviews);
FOR_EACH_CHILD (die, c, optimize_location_lists_1 (c, htab));
}
/* Recursively assign each location list a unique index into the debug_addr
section. */
static void
index_location_lists (dw_die_ref die)
{
dw_die_ref c;
dw_attr_node *a;
unsigned ix;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
if (AT_class (a) == dw_val_class_loc_list)
{
dw_loc_list_ref list = AT_loc_list (a);
dw_loc_list_ref curr;
for (curr = list; curr != NULL; curr = curr->dw_loc_next)
{
/* Don't index an entry that has already been indexed
or won't be output. Make sure skip_loc_list_entry doesn't
call size_of_locs, because that might cause circular dependency,
index_location_lists requiring address table indexes to be
computed, but adding new indexes through add_addr_table_entry
and address table index computation requiring no new additions
to the hash table. In the rare case of DWARF[234] >= 64KB
location expression, we'll just waste unused address table entry
for it. */
if (curr->begin_entry != NULL
|| skip_loc_list_entry (curr))
continue;
curr->begin_entry
= add_addr_table_entry (xstrdup (curr->begin), ate_kind_label);
}
}
FOR_EACH_CHILD (die, c, index_location_lists (c));
}
/* Optimize location lists referenced from DIE
children and share them whenever possible. */
static void
optimize_location_lists (dw_die_ref die)
{
loc_list_hash_type htab (500);
optimize_location_lists_1 (die, &htab);
}
/* Traverse the limbo die list, and add parent/child links. The only
dies without parents that should be here are concrete instances of
inline functions, and the comp_unit_die. We can ignore the comp_unit_die.
For concrete instances, we can get the parent die from the abstract
instance. */
static void
flush_limbo_die_list (void)
{
limbo_die_node *node;
/* get_context_die calls force_decl_die, which can put new DIEs on the
limbo list in LTO mode when nested functions are put in a different
partition than that of their parent function. */
while ((node = limbo_die_list))
{
dw_die_ref die = node->die;
limbo_die_list = node->next;
if (die->die_parent == NULL)
{
dw_die_ref origin = get_AT_ref (die, DW_AT_abstract_origin);
if (origin && origin->die_parent)
add_child_die (origin->die_parent, die);
else if (is_cu_die (die))
;
else if (seen_error ())
/* It's OK to be confused by errors in the input. */
add_child_die (comp_unit_die (), die);
else
{
/* In certain situations, the lexical block containing a
nested function can be optimized away, which results
in the nested function die being orphaned. Likewise
with the return type of that nested function. Force
this to be a child of the containing function.
It may happen that even the containing function got fully
inlined and optimized out. In that case we are lost and
assign the empty child. This should not be big issue as
the function is likely unreachable too. */
gcc_assert (node->created_for);
if (DECL_P (node->created_for))
origin = get_context_die (DECL_CONTEXT (node->created_for));
else if (TYPE_P (node->created_for))
origin = scope_die_for (node->created_for, comp_unit_die ());
else
origin = comp_unit_die ();
add_child_die (origin, die);
}
}
}
}
/* Reset DIEs so we can output them again. */
static void
reset_dies (dw_die_ref die)
{
dw_die_ref c;
/* Remove stuff we re-generate. */
die->die_mark = 0;
die->die_offset = 0;
die->die_abbrev = 0;
remove_AT (die, DW_AT_sibling);
FOR_EACH_CHILD (die, c, reset_dies (c));
}
/* Output stuff that dwarf requires at the end of every file,
and generate the DWARF-2 debugging info. */
static void
dwarf2out_finish (const char *filename)
{
comdat_type_node *ctnode;
dw_die_ref main_comp_unit_die;
unsigned char checksum[16];
char dl_section_ref[MAX_ARTIFICIAL_LABEL_BYTES];
/* Flush out any latecomers to the limbo party. */
flush_limbo_die_list ();
if (inline_entry_data_table)
gcc_assert (inline_entry_data_table->is_empty ());
if (flag_checking)
{
verify_die (comp_unit_die ());
for (limbo_die_node *node = cu_die_list; node; node = node->next)
verify_die (node->die);
}
/* We shouldn't have any symbols with delayed asm names for
DIEs generated after early finish. */
gcc_assert (deferred_asm_name == NULL);
gen_remaining_tmpl_value_param_die_attribute ();
if (flag_generate_lto || flag_generate_offload)
{
gcc_assert (flag_fat_lto_objects || flag_generate_offload);
/* Prune stuff so that dwarf2out_finish runs successfully
for the fat part of the object. */
reset_dies (comp_unit_die ());
for (limbo_die_node *node = cu_die_list; node; node = node->next)
reset_dies (node->die);
hash_table<comdat_type_hasher> comdat_type_table (100);
for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
{
comdat_type_node **slot
= comdat_type_table.find_slot (ctnode, INSERT);
/* Don't reset types twice. */
if (*slot != HTAB_EMPTY_ENTRY)
continue;
/* Remove the pointer to the line table. */
remove_AT (ctnode->root_die, DW_AT_stmt_list);
if (debug_info_level >= DINFO_LEVEL_TERSE)
reset_dies (ctnode->root_die);
*slot = ctnode;
}
/* Reset die CU symbol so we don't output it twice. */
comp_unit_die ()->die_id.die_symbol = NULL;
/* Remove DW_AT_macro and DW_AT_stmt_list from the early output. */
remove_AT (comp_unit_die (), DW_AT_stmt_list);
if (have_macinfo)
remove_AT (comp_unit_die (), DEBUG_MACRO_ATTRIBUTE);
/* Remove indirect string decisions. */
debug_str_hash->traverse<void *, reset_indirect_string> (NULL);
if (debug_line_str_hash)
{
debug_line_str_hash->traverse<void *, reset_indirect_string> (NULL);
debug_line_str_hash = NULL;
}
}
#if ENABLE_ASSERT_CHECKING
{
dw_die_ref die = comp_unit_die (), c;
FOR_EACH_CHILD (die, c, gcc_assert (! c->die_mark));
}
#endif
for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
resolve_addr (ctnode->root_die);
resolve_addr (comp_unit_die ());
move_marked_base_types ();
if (dump_file)
{
fprintf (dump_file, "DWARF for %s\n", filename);
print_die (comp_unit_die (), dump_file);
}
/* Initialize sections and labels used for actual assembler output. */
unsigned generation = init_sections_and_labels (false);
/* Traverse the DIE's and add sibling attributes to those DIE's that
have children. */
add_sibling_attributes (comp_unit_die ());
limbo_die_node *node;
for (node = cu_die_list; node; node = node->next)
add_sibling_attributes (node->die);
for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
add_sibling_attributes (ctnode->root_die);
/* When splitting DWARF info, we put some attributes in the
skeleton compile_unit DIE that remains in the .o, while
most attributes go in the DWO compile_unit_die. */
if (dwarf_split_debug_info)
{
limbo_die_node *cu;
main_comp_unit_die = gen_compile_unit_die (NULL);
if (dwarf_version >= 5)
main_comp_unit_die->die_tag = DW_TAG_skeleton_unit;
cu = limbo_die_list;
gcc_assert (cu->die == main_comp_unit_die);
limbo_die_list = limbo_die_list->next;
cu->next = cu_die_list;
cu_die_list = cu;
}
else
main_comp_unit_die = comp_unit_die ();
/* Output a terminator label for the .text section. */
switch_to_section (text_section);
targetm.asm_out.internal_label (asm_out_file, TEXT_END_LABEL, 0);
if (cold_text_section)
{
switch_to_section (cold_text_section);
targetm.asm_out.internal_label (asm_out_file, COLD_END_LABEL, 0);
}
/* We can only use the low/high_pc attributes if all of the code was
in .text. */
if (!have_multiple_function_sections
|| (dwarf_version < 3 && dwarf_strict))
{
/* Don't add if the CU has no associated code. */
if (text_section_used)
add_AT_low_high_pc (main_comp_unit_die, text_section_label,
text_end_label, true);
}
else
{
unsigned fde_idx;
dw_fde_ref fde;
bool range_list_added = false;
if (text_section_used)
add_ranges_by_labels (main_comp_unit_die, text_section_label,
text_end_label, &range_list_added, true);
if (cold_text_section_used)
add_ranges_by_labels (main_comp_unit_die, cold_text_section_label,
cold_end_label, &range_list_added, true);
FOR_EACH_VEC_ELT (*fde_vec, fde_idx, fde)
{
if (DECL_IGNORED_P (fde->decl))
continue;
if (!fde->in_std_section)
add_ranges_by_labels (main_comp_unit_die, fde->dw_fde_begin,
fde->dw_fde_end, &range_list_added,
true);
if (fde->dw_fde_second_begin && !fde->second_in_std_section)
add_ranges_by_labels (main_comp_unit_die, fde->dw_fde_second_begin,
fde->dw_fde_second_end, &range_list_added,
true);
}
if (range_list_added)
{
/* We need to give .debug_loc and .debug_ranges an appropriate
"base address". Use zero so that these addresses become
absolute. Historically, we've emitted the unexpected
DW_AT_entry_pc instead of DW_AT_low_pc for this purpose.
Emit both to give time for other tools to adapt. */
add_AT_addr (main_comp_unit_die, DW_AT_low_pc, const0_rtx, true);
if (! dwarf_strict && dwarf_version < 4)
add_AT_addr (main_comp_unit_die, DW_AT_entry_pc, const0_rtx, true);
add_ranges (NULL);
}
}
/* AIX Assembler inserts the length, so adjust the reference to match the
offset expected by debuggers. */
strcpy (dl_section_ref, debug_line_section_label);
if (XCOFF_DEBUGGING_INFO)
strcat (dl_section_ref, DWARF_INITIAL_LENGTH_SIZE_STR);
if (debug_info_level >= DINFO_LEVEL_TERSE)
add_AT_lineptr (main_comp_unit_die, DW_AT_stmt_list,
dl_section_ref);
if (have_macinfo)
add_AT_macptr (comp_unit_die (), DEBUG_MACRO_ATTRIBUTE,
macinfo_section_label);
if (dwarf_split_debug_info)
{
if (have_location_lists)
{
/* Since we generate the loclists in the split DWARF .dwo
file itself, we don't need to generate a loclists_base
attribute for the split compile unit DIE. That attribute
(and using relocatable sec_offset FORMs) isn't allowed
for a split compile unit. Only if the .debug_loclists
section was in the main file, would we need to generate a
loclists_base attribute here (for the full or skeleton
unit DIE). */
/* optimize_location_lists calculates the size of the lists,
so index them first, and assign indices to the entries.
Although optimize_location_lists will remove entries from
the table, it only does so for duplicates, and therefore
only reduces ref_counts to 1. */
index_location_lists (comp_unit_die ());
}
if (addr_index_table != NULL)
{
unsigned int index = 0;
addr_index_table
->traverse_noresize<unsigned int *, index_addr_table_entry>
(&index);
}
}
loc_list_idx = 0;
if (have_location_lists)
{
optimize_location_lists (comp_unit_die ());
/* And finally assign indexes to the entries for -gsplit-dwarf. */
if (dwarf_version >= 5 && dwarf_split_debug_info)
assign_location_list_indexes (comp_unit_die ());
}
save_macinfo_strings ();
if (dwarf_split_debug_info)
{
unsigned int index = 0;
/* Add attributes common to skeleton compile_units and
type_units. Because these attributes include strings, it
must be done before freezing the string table. Top-level
skeleton die attrs are added when the skeleton type unit is
created, so ensure it is created by this point. */
add_top_level_skeleton_die_attrs (main_comp_unit_die);
debug_str_hash->traverse_noresize<unsigned int *, index_string> (&index);
}
/* Output all of the compilation units. We put the main one last so that
the offsets are available to output_pubnames. */
for (node = cu_die_list; node; node = node->next)
output_comp_unit (node->die, 0, NULL);
hash_table<comdat_type_hasher> comdat_type_table (100);
for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
{
comdat_type_node **slot = comdat_type_table.find_slot (ctnode, INSERT);
/* Don't output duplicate types. */
if (*slot != HTAB_EMPTY_ENTRY)
continue;
/* Add a pointer to the line table for the main compilation unit
so that the debugger can make sense of DW_AT_decl_file
attributes. */
if (debug_info_level >= DINFO_LEVEL_TERSE)
add_AT_lineptr (ctnode->root_die, DW_AT_stmt_list,
(!dwarf_split_debug_info
? dl_section_ref
: debug_skeleton_line_section_label));
output_comdat_type_unit (ctnode, false);
*slot = ctnode;
}
if (dwarf_split_debug_info)
{
int mark;
struct md5_ctx ctx;
if (dwarf_version >= 5 && !vec_safe_is_empty (ranges_table))
index_rnglists ();
/* Compute a checksum of the comp_unit to use as the dwo_id. */
md5_init_ctx (&ctx);
mark = 0;
die_checksum (comp_unit_die (), &ctx, &mark);
unmark_all_dies (comp_unit_die ());
md5_finish_ctx (&ctx, checksum);
if (dwarf_version < 5)
{
/* Use the first 8 bytes of the checksum as the dwo_id,
and add it to both comp-unit DIEs. */
add_AT_data8 (main_comp_unit_die, DW_AT_GNU_dwo_id, checksum);
add_AT_data8 (comp_unit_die (), DW_AT_GNU_dwo_id, checksum);
}
/* Add the base offset of the ranges table to the skeleton
comp-unit DIE. */
if (!vec_safe_is_empty (ranges_table))
{
if (dwarf_version >= 5)
add_AT_lineptr (main_comp_unit_die, DW_AT_rnglists_base,
ranges_base_label);
else
add_AT_lineptr (main_comp_unit_die, DW_AT_GNU_ranges_base,
ranges_section_label);
}
output_addr_table ();
}
/* Output the main compilation unit if non-empty or if .debug_macinfo
or .debug_macro will be emitted. */
output_comp_unit (comp_unit_die (), have_macinfo,
dwarf_split_debug_info ? checksum : NULL);
if (dwarf_split_debug_info && info_section_emitted)
output_skeleton_debug_sections (main_comp_unit_die, checksum);
/* Output the abbreviation table. */
if (vec_safe_length (abbrev_die_table) != 1)
{
switch_to_section (debug_abbrev_section);
ASM_OUTPUT_LABEL (asm_out_file, abbrev_section_label);
output_abbrev_section ();
}
/* Output location list section if necessary. */
if (have_location_lists)
{
char l1[MAX_ARTIFICIAL_LABEL_BYTES];
char l2[MAX_ARTIFICIAL_LABEL_BYTES];
/* Output the location lists info. */
switch_to_section (debug_loc_section);
if (dwarf_version >= 5)
{
ASM_GENERATE_INTERNAL_LABEL (l1, DEBUG_LOC_SECTION_LABEL, 2);
ASM_GENERATE_INTERNAL_LABEL (l2, DEBUG_LOC_SECTION_LABEL, 3);
if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
dw2_asm_output_data (4, 0xffffffff,
"Initial length escape value indicating "
"64-bit DWARF extension");
dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
"Length of Location Lists");
ASM_OUTPUT_LABEL (asm_out_file, l1);
output_dwarf_version ();
dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Address Size");
dw2_asm_output_data (1, 0, "Segment Size");
dw2_asm_output_data (4, dwarf_split_debug_info ? loc_list_idx : 0,
"Offset Entry Count");
}
ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
if (dwarf_version >= 5 && dwarf_split_debug_info)
{
unsigned int save_loc_list_idx = loc_list_idx;
loc_list_idx = 0;
output_loclists_offsets (comp_unit_die ());
gcc_assert (save_loc_list_idx == loc_list_idx);
}
output_location_lists (comp_unit_die ());
if (dwarf_version >= 5)
ASM_OUTPUT_LABEL (asm_out_file, l2);
}
output_pubtables ();
/* Output the address range information if a CU (.debug_info section)
was emitted. We output an empty table even if we had no functions
to put in it. This because the consumer has no way to tell the
difference between an empty table that we omitted and failure to
generate a table that would have contained data. */
if (info_section_emitted)
{
switch_to_section (debug_aranges_section);
output_aranges ();
}
/* Output ranges section if necessary. */
if (!vec_safe_is_empty (ranges_table))
{
if (dwarf_version >= 5)
output_rnglists (generation);
else
output_ranges ();
}
/* Have to end the macro section. */
if (have_macinfo)
{
switch_to_section (debug_macinfo_section);
ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label);
output_macinfo (!dwarf_split_debug_info ? debug_line_section_label
: debug_skeleton_line_section_label, false);
dw2_asm_output_data (1, 0, "End compilation unit");
}
/* Output the source line correspondence table. We must do this
even if there is no line information. Otherwise, on an empty
translation unit, we will generate a present, but empty,
.debug_info section. IRIX 6.5 `nm' will then complain when
examining the file. This is done late so that any filenames
used by the debug_info section are marked as 'used'. */
switch_to_section (debug_line_section);
ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label);
if (! output_asm_line_debug_info ())
output_line_info (false);
else if (asm_outputs_debug_line_str ())
{
/* When gas outputs DWARF5 .debug_line[_str] then we have to
tell it the comp_dir and main file name for the zero entry
line table. */
const char *comp_dir, *filename0;
comp_dir = comp_dir_string ();
if (comp_dir == NULL)
comp_dir = "";
filename0 = get_AT_string (comp_unit_die (), DW_AT_name);
if (filename0 == NULL)
filename0 = "";
fprintf (asm_out_file, "\t.file 0 ");
output_quoted_string (asm_out_file, remap_debug_filename (comp_dir));
fputc (' ', asm_out_file);
output_quoted_string (asm_out_file, remap_debug_filename (filename0));
fputc ('\n', asm_out_file);
}
if (dwarf_split_debug_info && info_section_emitted)
{
switch_to_section (debug_skeleton_line_section);
ASM_OUTPUT_LABEL (asm_out_file, debug_skeleton_line_section_label);
output_line_info (true);
}
/* If we emitted any indirect strings, output the string table too. */
if (debug_str_hash || skeleton_debug_str_hash)
output_indirect_strings ();
if (debug_line_str_hash)
{
switch_to_section (debug_line_str_section);
const enum dwarf_form form = DW_FORM_line_strp;
debug_line_str_hash->traverse<enum dwarf_form,
output_indirect_string> (form);
}
/* ??? Move lvugid out of dwarf2out_source_line and reset it too? */
symview_upper_bound = 0;
if (zero_view_p)
bitmap_clear (zero_view_p);
}
/* Returns a hash value for X (which really is a variable_value_struct). */
inline hashval_t
variable_value_hasher::hash (variable_value_struct *x)
{
return (hashval_t) x->decl_id;
}
/* Return nonzero if decl_id of variable_value_struct X is the same as
UID of decl Y. */
inline bool
variable_value_hasher::equal (variable_value_struct *x, tree y)
{
return x->decl_id == DECL_UID (y);
}
/* Helper function for resolve_variable_value, handle
DW_OP_GNU_variable_value in one location expression.
Return true if exprloc has been changed into loclist. */
static bool
resolve_variable_value_in_expr (dw_attr_node *a, dw_loc_descr_ref loc)
{
dw_loc_descr_ref next;
for (dw_loc_descr_ref prev = NULL; loc; prev = loc, loc = next)
{
next = loc->dw_loc_next;
if (loc->dw_loc_opc != DW_OP_GNU_variable_value
|| loc->dw_loc_oprnd1.val_class != dw_val_class_decl_ref)
continue;
tree decl = loc->dw_loc_oprnd1.v.val_decl_ref;
if (DECL_CONTEXT (decl) != current_function_decl)
continue;
dw_die_ref ref = lookup_decl_die (decl);
if (ref)
{
loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
loc->dw_loc_oprnd1.v.val_die_ref.die = ref;
loc->dw_loc_oprnd1.v.val_die_ref.external = 0;
continue;
}
dw_loc_list_ref l = loc_list_from_tree (decl, 0, NULL);
if (l == NULL)
continue;
if (l->dw_loc_next)
{
if (AT_class (a) != dw_val_class_loc)
continue;
switch (a->dw_attr)
{
/* Following attributes allow both exprloc and loclist
classes, so we can change them into a loclist. */
case DW_AT_location:
case DW_AT_string_length:
case DW_AT_return_addr:
case DW_AT_data_member_location:
case DW_AT_frame_base:
case DW_AT_segment:
case DW_AT_static_link:
case DW_AT_use_location:
case DW_AT_vtable_elem_location:
if (prev)
{
prev->dw_loc_next = NULL;
prepend_loc_descr_to_each (l, AT_loc (a));
}
if (next)
add_loc_descr_to_each (l, next);
a->dw_attr_val.val_class = dw_val_class_loc_list;
a->dw_attr_val.val_entry = NULL;
a->dw_attr_val.v.val_loc_list = l;
have_location_lists = true;
return true;
/* Following attributes allow both exprloc and reference,
so if the whole expression is DW_OP_GNU_variable_value alone
we could transform it into reference. */
case DW_AT_byte_size:
case DW_AT_bit_size:
case DW_AT_lower_bound:
case DW_AT_upper_bound:
case DW_AT_bit_stride:
case DW_AT_count:
case DW_AT_allocated:
case DW_AT_associated:
case DW_AT_byte_stride:
if (prev == NULL && next == NULL)
break;
/* FALLTHRU */
default:
if (dwarf_strict)
continue;
break;
}
/* Create DW_TAG_variable that we can refer to. */
gen_decl_die (decl, NULL_TREE, NULL,
lookup_decl_die (current_function_decl));
ref = lookup_decl_die (decl);
if (ref)
{
loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
loc->dw_loc_oprnd1.v.val_die_ref.die = ref;
loc->dw_loc_oprnd1.v.val_die_ref.external = 0;
}
continue;
}
if (prev)
{
prev->dw_loc_next = l->expr;
add_loc_descr (&prev->dw_loc_next, next);
free_loc_descr (loc, NULL);
next = prev->dw_loc_next;
}
else
{
memcpy (loc, l->expr, sizeof (dw_loc_descr_node));
add_loc_descr (&loc, next);
next = loc;
}
loc = prev;
}
return false;
}
/* Attempt to resolve DW_OP_GNU_variable_value using loc_list_from_tree. */
static void
resolve_variable_value (dw_die_ref die)
{
dw_attr_node *a;
dw_loc_list_ref loc;
unsigned ix;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
switch (AT_class (a))
{
case dw_val_class_loc:
if (!resolve_variable_value_in_expr (a, AT_loc (a)))
break;
/* FALLTHRU */
case dw_val_class_loc_list:
loc = AT_loc_list (a);
gcc_assert (loc);
for (; loc; loc = loc->dw_loc_next)
resolve_variable_value_in_expr (a, loc->expr);
break;
default:
break;
}
}
/* Attempt to optimize DW_OP_GNU_variable_value refering to
temporaries in the current function. */
static void
resolve_variable_values (void)
{
if (!variable_value_hash || !current_function_decl)
return;
struct variable_value_struct *node
= variable_value_hash->find_with_hash (current_function_decl,
DECL_UID (current_function_decl));
if (node == NULL)
return;
unsigned int i;
dw_die_ref die;
FOR_EACH_VEC_SAFE_ELT (node->dies, i, die)
resolve_variable_value (die);
}
/* Helper function for note_variable_value, handle one location
expression. */
static void
note_variable_value_in_expr (dw_die_ref die, dw_loc_descr_ref loc)
{
for (; loc; loc = loc->dw_loc_next)
if (loc->dw_loc_opc == DW_OP_GNU_variable_value
&& loc->dw_loc_oprnd1.val_class == dw_val_class_decl_ref)
{
tree decl = loc->dw_loc_oprnd1.v.val_decl_ref;
dw_die_ref ref = lookup_decl_die (decl);
if (! ref && (flag_generate_lto || flag_generate_offload))
{
/* ??? This is somewhat a hack because we do not create DIEs
for variables not in BLOCK trees early but when generating
early LTO output we need the dw_val_class_decl_ref to be
fully resolved. For fat LTO objects we'd also like to
undo this after LTO dwarf output. */
gcc_assert (DECL_CONTEXT (decl));
dw_die_ref ctx = lookup_decl_die (DECL_CONTEXT (decl));
gcc_assert (ctx != NULL);
gen_decl_die (decl, NULL_TREE, NULL, ctx);
ref = lookup_decl_die (decl);
gcc_assert (ref != NULL);
}
if (ref)
{
loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
loc->dw_loc_oprnd1.v.val_die_ref.die = ref;
loc->dw_loc_oprnd1.v.val_die_ref.external = 0;
continue;
}
if (VAR_P (decl)
&& DECL_CONTEXT (decl)
&& TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL
&& lookup_decl_die (DECL_CONTEXT (decl)))
{
if (!variable_value_hash)
variable_value_hash
= hash_table<variable_value_hasher>::create_ggc (10);
tree fndecl = DECL_CONTEXT (decl);
struct variable_value_struct *node;
struct variable_value_struct **slot
= variable_value_hash->find_slot_with_hash (fndecl,
DECL_UID (fndecl),
INSERT);
if (*slot == NULL)
{
node = ggc_cleared_alloc<variable_value_struct> ();
node->decl_id = DECL_UID (fndecl);
*slot = node;
}
else
node = *slot;
vec_safe_push (node->dies, die);
}
}
}
/* Walk the tree DIE and note DIEs with DW_OP_GNU_variable_value still
with dw_val_class_decl_ref operand. */
static void
note_variable_value (dw_die_ref die)
{
dw_die_ref c;
dw_attr_node *a;
dw_loc_list_ref loc;
unsigned ix;
FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
switch (AT_class (a))
{
case dw_val_class_loc_list:
loc = AT_loc_list (a);
gcc_assert (loc);
if (!loc->noted_variable_value)
{
loc->noted_variable_value = 1;
for (; loc; loc = loc->dw_loc_next)
note_variable_value_in_expr (die, loc->expr);
}
break;
case dw_val_class_loc:
note_variable_value_in_expr (die, AT_loc (a));
break;
default:
break;
}
/* Mark children. */
FOR_EACH_CHILD (die, c, note_variable_value (c));
}
/* Perform any cleanups needed after the early debug generation pass
has run. */
static void
dwarf2out_early_finish (const char *filename)
{
set_early_dwarf s;
char dl_section_ref[MAX_ARTIFICIAL_LABEL_BYTES];
/* PCH might result in DW_AT_producer string being restored from the
header compilation, so always fill it with empty string initially
and overwrite only here. */
dw_attr_node *producer = get_AT (comp_unit_die (), DW_AT_producer);
producer_string = gen_producer_string ();
producer->dw_attr_val.v.val_str->refcount--;
producer->dw_attr_val.v.val_str = find_AT_string (producer_string);
/* Add the name for the main input file now. We delayed this from
dwarf2out_init to avoid complications with PCH. */
add_filename_attribute (comp_unit_die (), remap_debug_filename (filename));
add_comp_dir_attribute (comp_unit_die ());
/* With LTO early dwarf was really finished at compile-time, so make
sure to adjust the phase after annotating the LTRANS CU DIE. */
if (in_lto_p)
{
early_dwarf_finished = true;
if (dump_file)
{
fprintf (dump_file, "LTO EARLY DWARF for %s\n", filename);
print_die (comp_unit_die (), dump_file);
}
return;
}
/* Walk through the list of incomplete types again, trying once more to
emit full debugging info for them. */
retry_incomplete_types ();
gen_scheduled_generic_parms_dies ();
gen_remaining_tmpl_value_param_die_attribute ();
/* The point here is to flush out the limbo list so that it is empty
and we don't need to stream it for LTO. */
flush_limbo_die_list ();
/* Add DW_AT_linkage_name for all deferred DIEs. */
for (limbo_die_node *node = deferred_asm_name; node; node = node->next)
{
tree decl = node->created_for;
if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl)
/* A missing DECL_ASSEMBLER_NAME can be a constant DIE that
ended up in deferred_asm_name before we knew it was
constant and never written to disk. */
&& DECL_ASSEMBLER_NAME (decl))
{
add_linkage_attr (node->die, decl);
move_linkage_attr (node->die);
}
}
deferred_asm_name = NULL;
if (flag_eliminate_unused_debug_types)
prune_unused_types ();
/* Generate separate COMDAT sections for type DIEs. */
if (use_debug_types)
{
break_out_comdat_types (comp_unit_die ());
/* Each new type_unit DIE was added to the limbo die list when created.
Since these have all been added to comdat_type_list, clear the
limbo die list. */
limbo_die_list = NULL;
/* For each new comdat type unit, copy declarations for incomplete
types to make the new unit self-contained (i.e., no direct
references to the main compile unit). */
for (comdat_type_node *ctnode = comdat_type_list;
ctnode != NULL; ctnode = ctnode->next)
copy_decls_for_unworthy_types (ctnode->root_die);
copy_decls_for_unworthy_types (comp_unit_die ());
/* In the process of copying declarations from one unit to another,
we may have left some declarations behind that are no longer
referenced. Prune them. */
prune_unused_types ();
}
/* Traverse the DIE's and note DIEs with DW_OP_GNU_variable_value still
with dw_val_class_decl_ref operand. */
note_variable_value (comp_unit_die ());
for (limbo_die_node *node = cu_die_list; node; node = node->next)
note_variable_value (node->die);
for (comdat_type_node *ctnode = comdat_type_list; ctnode != NULL;
ctnode = ctnode->next)
note_variable_value (ctnode->root_die);
for (limbo_die_node *node = limbo_die_list; node; node = node->next)
note_variable_value (node->die);
/* The AT_pubnames attribute needs to go in all skeleton dies, including
both the main_cu and all skeleton TUs. Making this call unconditional
would end up either adding a second copy of the AT_pubnames attribute, or
requiring a special case in add_top_level_skeleton_die_attrs. */
if (!dwarf_split_debug_info)
add_AT_pubnames (comp_unit_die ());
/* The early debug phase is now finished. */
early_dwarf_finished = true;
if (dump_file)
{
fprintf (dump_file, "EARLY DWARF for %s\n", filename);
print_die (comp_unit_die (), dump_file);
}
/* Do not generate DWARF assembler now when not producing LTO bytecode. */
if ((!flag_generate_lto && !flag_generate_offload)
/* FIXME: Disable debug info generation for (PE-)COFF targets since the
copy_lto_debug_sections operation of the simple object support in
libiberty is not implemented for them yet. */
|| TARGET_PECOFF || TARGET_COFF)
return;
/* Now as we are going to output for LTO initialize sections and labels
to the LTO variants. We don't need a random-seed postfix as other
LTO sections as linking the LTO debug sections into one in a partial
link is fine. */
init_sections_and_labels (true);
/* The output below is modeled after dwarf2out_finish with all
location related output removed and some LTO specific changes.
Some refactoring might make both smaller and easier to match up. */
/* Traverse the DIE's and add sibling attributes to those DIE's
that have children. */
add_sibling_attributes (comp_unit_die ());
for (limbo_die_node *node = limbo_die_list; node; node = node->next)
add_sibling_attributes (node->die);
for (comdat_type_node *ctnode = comdat_type_list;
ctnode != NULL; ctnode = ctnode->next)
add_sibling_attributes (ctnode->root_die);
/* AIX Assembler inserts the length, so adjust the reference to match the
offset expected by debuggers. */
strcpy (dl_section_ref, debug_line_section_label);
if (XCOFF_DEBUGGING_INFO)
strcat (dl_section_ref, DWARF_INITIAL_LENGTH_SIZE_STR);
if (debug_info_level >= DINFO_LEVEL_TERSE)
add_AT_lineptr (comp_unit_die (), DW_AT_stmt_list, dl_section_ref);
if (have_macinfo)
add_AT_macptr (comp_unit_die (), DEBUG_MACRO_ATTRIBUTE,
macinfo_section_label);
save_macinfo_strings ();
if (dwarf_split_debug_info)
{
unsigned int index = 0;
debug_str_hash->traverse_noresize<unsigned int *, index_string> (&index);
}
/* Output all of the compilation units. We put the main one last so that
the offsets are available to output_pubnames. */
for (limbo_die_node *node = limbo_die_list; node; node = node->next)
output_comp_unit (node->die, 0, NULL);
hash_table<comdat_type_hasher> comdat_type_table (100);
for (comdat_type_node *ctnode = comdat_type_list;
ctnode != NULL; ctnode = ctnode->next)
{
comdat_type_node **slot = comdat_type_table.find_slot (ctnode, INSERT);
/* Don't output duplicate types. */
if (*slot != HTAB_EMPTY_ENTRY)
continue;
/* Add a pointer to the line table for the main compilation unit
so that the debugger can make sense of DW_AT_decl_file
attributes. */
if (debug_info_level >= DINFO_LEVEL_TERSE)
add_AT_lineptr (ctnode->root_die, DW_AT_stmt_list,
(!dwarf_split_debug_info
? debug_line_section_label
: debug_skeleton_line_section_label));
output_comdat_type_unit (ctnode, true);
*slot = ctnode;
}
/* Stick a unique symbol to the main debuginfo section. */
compute_comp_unit_symbol (comp_unit_die ());
/* Output the main compilation unit. We always need it if only for
the CU symbol. */
output_comp_unit (comp_unit_die (), true, NULL);
/* Output the abbreviation table. */
if (vec_safe_length (abbrev_die_table) != 1)
{
switch_to_section (debug_abbrev_section);
ASM_OUTPUT_LABEL (asm_out_file, abbrev_section_label);
output_abbrev_section ();
}
/* Have to end the macro section. */
if (have_macinfo)
{
/* We have to save macinfo state if we need to output it again
for the FAT part of the object. */
vec<macinfo_entry, va_gc> *saved_macinfo_table = macinfo_table;
if (flag_fat_lto_objects)
macinfo_table = macinfo_table->copy ();
switch_to_section (debug_macinfo_section);
ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label);
output_macinfo (debug_line_section_label, true);
dw2_asm_output_data (1, 0, "End compilation unit");
if (flag_fat_lto_objects)
{
vec_free (macinfo_table);
macinfo_table = saved_macinfo_table;
}
}
/* Emit a skeleton debug_line section. */
switch_to_section (debug_line_section);
ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label);
output_line_info (true);
/* If we emitted any indirect strings, output the string table too. */
if (debug_str_hash || skeleton_debug_str_hash)
output_indirect_strings ();
if (debug_line_str_hash)
{
switch_to_section (debug_line_str_section);
const enum dwarf_form form = DW_FORM_line_strp;
debug_line_str_hash->traverse<enum dwarf_form,
output_indirect_string> (form);
}
/* Switch back to the text section. */
switch_to_section (text_section);
}
/* Reset all state within dwarf2out.c so that we can rerun the compiler
within the same process. For use by toplev::finalize. */
void
dwarf2out_c_finalize (void)
{
last_var_location_insn = NULL;
cached_next_real_insn = NULL;
used_rtx_array = NULL;
incomplete_types = NULL;
debug_info_section = NULL;
debug_skeleton_info_section = NULL;
debug_abbrev_section = NULL;
debug_skeleton_abbrev_section = NULL;
debug_aranges_section = NULL;
debug_addr_section = NULL;
debug_macinfo_section = NULL;
debug_line_section = NULL;
debug_skeleton_line_section = NULL;
debug_loc_section = NULL;
debug_pubnames_section = NULL;
debug_pubtypes_section = NULL;
debug_str_section = NULL;
debug_line_str_section = NULL;
debug_str_dwo_section = NULL;
debug_str_offsets_section = NULL;
debug_ranges_section = NULL;
debug_frame_section = NULL;
fde_vec = NULL;
debug_str_hash = NULL;
debug_line_str_hash = NULL;
skeleton_debug_str_hash = NULL;
dw2_string_counter = 0;
have_multiple_function_sections = false;
text_section_used = false;
cold_text_section_used = false;
cold_text_section = NULL;
current_unit_personality = NULL;
early_dwarf = false;
early_dwarf_finished = false;
next_die_offset = 0;
single_comp_unit_die = NULL;
comdat_type_list = NULL;
limbo_die_list = NULL;
file_table = NULL;
decl_die_table = NULL;
common_block_die_table = NULL;
decl_loc_table = NULL;
call_arg_locations = NULL;
call_arg_loc_last = NULL;
call_site_count = -1;
tail_call_site_count = -1;
cached_dw_loc_list_table = NULL;
abbrev_die_table = NULL;
delete dwarf_proc_stack_usage_map;
dwarf_proc_stack_usage_map = NULL;
line_info_label_num = 0;
cur_line_info_table = NULL;
text_section_line_info = NULL;
cold_text_section_line_info = NULL;
separate_line_info = NULL;
info_section_emitted = false;
pubname_table = NULL;
pubtype_table = NULL;
macinfo_table = NULL;
ranges_table = NULL;
ranges_by_label = NULL;
rnglist_idx = 0;
have_location_lists = false;
loclabel_num = 0;
poc_label_num = 0;
last_emitted_file = NULL;
label_num = 0;
tmpl_value_parm_die_table = NULL;
generic_type_instances = NULL;
frame_pointer_fb_offset = 0;
frame_pointer_fb_offset_valid = false;
base_types.release ();
XDELETEVEC (producer_string);
producer_string = NULL;
}
#include "gt-dwarf2out.h"
|