@@ -547,8 +547,11 @@ TEST(ELFObjectFileTest, InvalidDecodeBBAddrMap) {
547
547
Metadata: 0x2
548
548
)" ;
549
549
550
- DoCheck (UnsupportedVersionYamlString,
551
- " unsupported SHT_LLVM_BB_ADDR_MAP version: 3" );
550
+ {
551
+ SCOPED_TRACE (" unsupported version" );
552
+ DoCheck (UnsupportedVersionYamlString,
553
+ " unsupported SHT_LLVM_BB_ADDR_MAP version: 3" );
554
+ }
552
555
553
556
SmallString<128 > CommonVersionedYamlString (CommonYamlString);
554
557
CommonVersionedYamlString += R"(
@@ -566,8 +569,12 @@ TEST(ELFObjectFileTest, InvalidDecodeBBAddrMap) {
566
569
TruncatedYamlString += R"(
567
570
ShSize: 0xb
568
571
)" ;
569
- DoCheck (TruncatedYamlString, " unable to decode LEB128 at offset 0x0000000b: "
570
- " malformed uleb128, extends past end" );
572
+ {
573
+ SCOPED_TRACE (" truncated section" );
574
+ DoCheck (TruncatedYamlString,
575
+ " unable to decode LEB128 at offset 0x0000000b: "
576
+ " malformed uleb128, extends past end" );
577
+ }
571
578
572
579
// Check that we can detect when the encoded BB entry fields exceed the UINT32
573
580
// limit.
@@ -594,12 +601,15 @@ TEST(ELFObjectFileTest, InvalidDecodeBBAddrMap) {
594
601
Metadata: 0x100000000
595
602
)" ;
596
603
597
- DoCheck (OverInt32LimitYamlStrings[0 ],
598
- " ULEB128 value at offset 0x10 exceeds UINT32_MAX (0x100000000)" );
599
- DoCheck (OverInt32LimitYamlStrings[1 ],
600
- " ULEB128 value at offset 0x15 exceeds UINT32_MAX (0x100000000)" );
601
- DoCheck (OverInt32LimitYamlStrings[2 ],
602
- " ULEB128 value at offset 0x1a exceeds UINT32_MAX (0x100000000)" );
604
+ {
605
+ SCOPED_TRACE (" overlimit fields" );
606
+ DoCheck (OverInt32LimitYamlStrings[0 ],
607
+ " ULEB128 value at offset 0x10 exceeds UINT32_MAX (0x100000000)" );
608
+ DoCheck (OverInt32LimitYamlStrings[1 ],
609
+ " ULEB128 value at offset 0x15 exceeds UINT32_MAX (0x100000000)" );
610
+ DoCheck (OverInt32LimitYamlStrings[2 ],
611
+ " ULEB128 value at offset 0x1a exceeds UINT32_MAX (0x100000000)" );
612
+ }
603
613
604
614
// Check the proper error handling when the section has fields exceeding
605
615
// UINT32 and is also truncated. This is for checking that we don't generate
@@ -619,13 +629,16 @@ TEST(ELFObjectFileTest, InvalidDecodeBBAddrMap) {
619
629
ShSize: 0x1b
620
630
)" ;
621
631
622
- DoCheck (OverInt32LimitAndTruncated[0 ],
623
- " unable to decode LEB128 at offset 0x00000015: malformed uleb128, "
624
- " extends past end" );
625
- DoCheck (OverInt32LimitAndTruncated[1 ],
626
- " ULEB128 value at offset 0x15 exceeds UINT32_MAX (0x100000000)" );
627
- DoCheck (OverInt32LimitAndTruncated[2 ],
628
- " ULEB128 value at offset 0x15 exceeds UINT32_MAX (0x100000000)" );
632
+ {
633
+ SCOPED_TRACE (" overlimit fields, truncated section" );
634
+ DoCheck (OverInt32LimitAndTruncated[0 ],
635
+ " unable to decode LEB128 at offset 0x00000015: malformed uleb128, "
636
+ " extends past end" );
637
+ DoCheck (OverInt32LimitAndTruncated[1 ],
638
+ " ULEB128 value at offset 0x15 exceeds UINT32_MAX (0x100000000)" );
639
+ DoCheck (OverInt32LimitAndTruncated[2 ],
640
+ " ULEB128 value at offset 0x15 exceeds UINT32_MAX (0x100000000)" );
641
+ }
629
642
630
643
// Check for proper error handling when the 'NumBlocks' field is overridden
631
644
// with an out-of-range value.
@@ -634,8 +647,11 @@ TEST(ELFObjectFileTest, InvalidDecodeBBAddrMap) {
634
647
NumBlocks: 0x100000000
635
648
)" ;
636
649
637
- DoCheck (OverLimitNumBlocks,
638
- " ULEB128 value at offset 0xa exceeds UINT32_MAX (0x100000000)" );
650
+ {
651
+ SCOPED_TRACE (" overlimit 'NumBlocks' field" );
652
+ DoCheck (OverLimitNumBlocks,
653
+ " ULEB128 value at offset 0xa exceeds UINT32_MAX (0x100000000)" );
654
+ }
639
655
}
640
656
641
657
// Test for the ELFObjectFile::readBBAddrMap API.
@@ -708,6 +724,9 @@ TEST(ELFObjectFileTest, ReadBBAddrMap) {
708
724
auto DoCheckSucceeds = [&](StringRef YamlString,
709
725
std::optional<unsigned > TextSectionIndex,
710
726
std::vector<BBAddrMap> ExpectedResult) {
727
+ SCOPED_TRACE (" for TextSectionIndex: " +
728
+ (TextSectionIndex ? llvm::Twine (*TextSectionIndex) : " {}" ) +
729
+ " and object yaml:\n " + YamlString);
711
730
SmallString<0 > Storage;
712
731
Expected<ELFObjectFile<ELF64LE>> ElfOrErr =
713
732
toBinary<ELF64LE>(Storage, YamlString);
@@ -724,6 +743,9 @@ TEST(ELFObjectFileTest, ReadBBAddrMap) {
724
743
auto DoCheckFails = [&](StringRef YamlString,
725
744
std::optional<unsigned > TextSectionIndex,
726
745
const char *ErrMsg) {
746
+ SCOPED_TRACE (" for TextSectionIndex: " +
747
+ (TextSectionIndex ? llvm::Twine (*TextSectionIndex) : " {}" ) +
748
+ " and object yaml:\n " + YamlString);
727
749
SmallString<0 > Storage;
728
750
Expected<ELFObjectFile<ELF64LE>> ElfOrErr =
729
751
toBinary<ELF64LE>(Storage, YamlString);
@@ -736,15 +758,21 @@ TEST(ELFObjectFileTest, ReadBBAddrMap) {
736
758
FailedWithMessage (ErrMsg));
737
759
};
738
760
739
- // Check that we can retrieve the data in the normal case.
740
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ std::nullopt,
741
- AllBBAddrMaps);
742
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 0 , Section0BBAddrMaps);
743
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 2 , Section1BBAddrMaps);
744
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 1 , Section2BBAddrMaps);
745
- // Check that when no bb-address-map section is found for a text section,
746
- // we return an empty result.
747
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 3 , {});
761
+ {
762
+ SCOPED_TRACE (" normal sections" );
763
+ // Check that we can retrieve the data in the normal case.
764
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ std::nullopt,
765
+ AllBBAddrMaps);
766
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 0 ,
767
+ Section0BBAddrMaps);
768
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 2 ,
769
+ Section1BBAddrMaps);
770
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 1 ,
771
+ Section2BBAddrMaps);
772
+ // Check that when no bb-address-map section is found for a text section,
773
+ // we return an empty result.
774
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 3 , {});
775
+ }
748
776
749
777
// Check that we detect when a bb-addr-map section is linked to an invalid
750
778
// (not present) section.
@@ -757,25 +785,32 @@ TEST(ELFObjectFileTest, ReadBBAddrMap) {
757
785
" unable to get the linked-to section for "
758
786
" SHT_LLVM_BB_ADDR_MAP_V0 section with index 4: invalid section "
759
787
" index: 10" );
760
- // Linked sections are not checked when we don't target a specific text
761
- // section.
762
- DoCheckSucceeds (InvalidLinkedYamlString, /* TextSectionIndex=*/ std::nullopt,
763
- AllBBAddrMaps);
788
+ {
789
+ SCOPED_TRACE (" invalid linked section" );
790
+ // Linked sections are not checked when we don't target a specific text
791
+ // section.
792
+ DoCheckSucceeds (InvalidLinkedYamlString, /* TextSectionIndex=*/ std::nullopt,
793
+ AllBBAddrMaps);
794
+ }
764
795
765
796
// Check that we can detect when bb-address-map decoding fails.
766
797
SmallString<128 > TruncatedYamlString (CommonYamlString);
767
798
TruncatedYamlString += R"(
768
799
ShSize: 0x8
769
800
)" ;
770
801
771
- DoCheckFails (TruncatedYamlString, /* TextSectionIndex=*/ std::nullopt,
772
- " unable to read SHT_LLVM_BB_ADDR_MAP_V0 section with index 4: "
773
- " unable to decode LEB128 at offset 0x00000008: malformed "
774
- " uleb128, extends past end" );
775
- // Check that we can read the other section's bb-address-maps which are
776
- // valid.
777
- DoCheckSucceeds (TruncatedYamlString, /* TextSectionIndex=*/ 2 ,
778
- Section1BBAddrMaps);
802
+ {
803
+ SCOPED_TRACE (" truncated section" );
804
+ DoCheckFails (TruncatedYamlString, /* TextSectionIndex=*/ std::nullopt,
805
+ " unable to read SHT_LLVM_BB_ADDR_MAP_V0 section with index 4: "
806
+ " unable to decode LEB128 at offset 0x00000008: malformed "
807
+ " uleb128, extends past end" );
808
+
809
+ // Check that we can read the other section's bb-address-maps which are
810
+ // valid.
811
+ DoCheckSucceeds (TruncatedYamlString, /* TextSectionIndex=*/ 2 ,
812
+ Section1BBAddrMaps);
813
+ }
779
814
}
780
815
781
816
// Tests for error paths of the ELFFile::decodeBBAddrMap with PGOAnalysisMap
@@ -825,9 +860,12 @@ TEST(ELFObjectFileTest, InvalidDecodePGOAnalysisMap) {
825
860
Metadata: 0x2
826
861
)" ;
827
862
828
- DoCheck (UnsupportedLowVersionYamlString,
829
- " version should be >= 2 for SHT_LLVM_BB_ADDR_MAP when PGO features "
830
- " are enabled: version = 1 feature = 4" );
863
+ {
864
+ SCOPED_TRACE (" unsupported version" );
865
+ DoCheck (UnsupportedLowVersionYamlString,
866
+ " version should be >= 2 for SHT_LLVM_BB_ADDR_MAP when PGO features "
867
+ " are enabled: version = 1 feature = 4" );
868
+ }
831
869
832
870
SmallString<128 > CommonVersionedYamlString (CommonYamlString);
833
871
CommonVersionedYamlString += R"(
@@ -846,9 +884,12 @@ TEST(ELFObjectFileTest, InvalidDecodePGOAnalysisMap) {
846
884
Feature: 0x01
847
885
)" ;
848
886
849
- DoCheck (MissingFuncEntryCount,
850
- " unable to decode LEB128 at offset 0x0000000b: malformed uleb128, "
851
- " extends past end" );
887
+ {
888
+ SCOPED_TRACE (" missing function entry count" );
889
+ DoCheck (MissingFuncEntryCount,
890
+ " unable to decode LEB128 at offset 0x0000000b: malformed uleb128, "
891
+ " extends past end" );
892
+ }
852
893
853
894
// Check that we fail when basic block frequency is enabled but not provided.
854
895
SmallString<128 > MissingBBFreq (CommonYamlString);
@@ -862,8 +903,11 @@ TEST(ELFObjectFileTest, InvalidDecodePGOAnalysisMap) {
862
903
Metadata: 0x2
863
904
)" ;
864
905
865
- DoCheck (MissingBBFreq, " unable to decode LEB128 at offset 0x0000000f: "
866
- " malformed uleb128, extends past end" );
906
+ {
907
+ SCOPED_TRACE (" missing bb frequency" );
908
+ DoCheck (MissingBBFreq, " unable to decode LEB128 at offset 0x0000000f: "
909
+ " malformed uleb128, extends past end" );
910
+ }
867
911
868
912
// Check that we fail when branch probability is enabled but not provided.
869
913
SmallString<128 > MissingBrProb (CommonYamlString);
@@ -895,8 +939,11 @@ TEST(ELFObjectFileTest, InvalidDecodePGOAnalysisMap) {
895
939
BrProb: 0xF0000000
896
940
)" ;
897
941
898
- DoCheck (MissingBrProb, " unable to decode LEB128 at offset 0x00000017: "
899
- " malformed uleb128, extends past end" );
942
+ {
943
+ SCOPED_TRACE (" missing branch probability" );
944
+ DoCheck (MissingBrProb, " unable to decode LEB128 at offset 0x00000017: "
945
+ " malformed uleb128, extends past end" );
946
+ }
900
947
}
901
948
902
949
// Test for the ELFObjectFile::readBBAddrMap API with PGOAnalysisMap.
@@ -1079,6 +1126,10 @@ TEST(ELFObjectFileTest, ReadPGOAnalysisMap) {
1079
1126
[&](StringRef YamlString, std::optional<unsigned > TextSectionIndex,
1080
1127
std::vector<BBAddrMap> ExpectedResult,
1081
1128
std::optional<std::vector<PGOAnalysisMap>> ExpectedPGO) {
1129
+ SCOPED_TRACE (
1130
+ " for TextSectionIndex: " +
1131
+ (TextSectionIndex ? llvm::Twine (*TextSectionIndex) : " {}" ) +
1132
+ " and object yaml:\n " + YamlString);
1082
1133
SmallString<0 > Storage;
1083
1134
Expected<ELFObjectFile<ELF64LE>> ElfOrErr =
1084
1135
toBinary<ELF64LE>(Storage, YamlString);
@@ -1106,6 +1157,9 @@ TEST(ELFObjectFileTest, ReadPGOAnalysisMap) {
1106
1157
auto DoCheckFails = [&](StringRef YamlString,
1107
1158
std::optional<unsigned > TextSectionIndex,
1108
1159
const char *ErrMsg) {
1160
+ SCOPED_TRACE (" for TextSectionIndex: " +
1161
+ (TextSectionIndex ? llvm::Twine (*TextSectionIndex) : " {}" ) +
1162
+ " and object yaml:\n " + YamlString);
1109
1163
SmallString<0 > Storage;
1110
1164
Expected<ELFObjectFile<ELF64LE>> ElfOrErr =
1111
1165
toBinary<ELF64LE>(Storage, YamlString);
@@ -1120,29 +1174,32 @@ TEST(ELFObjectFileTest, ReadPGOAnalysisMap) {
1120
1174
FailedWithMessage (ErrMsg));
1121
1175
};
1122
1176
1123
- // Check that we can retrieve the data in the normal case.
1124
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ std::nullopt,
1125
- AllBBAddrMaps, std::nullopt);
1126
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 0 , Section0BBAddrMaps,
1127
- std::nullopt);
1128
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 2 , Section1BBAddrMaps,
1129
- std::nullopt);
1130
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 1 , Section2BBAddrMaps,
1131
- std::nullopt);
1132
-
1133
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ std::nullopt,
1134
- AllBBAddrMaps, AllPGOAnalysisMaps);
1135
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 0 , Section0BBAddrMaps,
1136
- Section0PGOAnalysisMaps);
1137
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 2 , Section1BBAddrMaps,
1138
- Section1PGOAnalysisMaps);
1139
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 1 , Section2BBAddrMaps,
1140
- Section2PGOAnalysisMaps);
1141
- // Check that when no bb-address-map section is found for a text section,
1142
- // we return an empty result.
1143
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 3 , {}, std::nullopt);
1144
- DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 3 , {},
1145
- std::vector<PGOAnalysisMap>{});
1177
+ {
1178
+ SCOPED_TRACE (" normal sections" );
1179
+ // Check that we can retrieve the data in the normal case.
1180
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ std::nullopt,
1181
+ AllBBAddrMaps, std::nullopt);
1182
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 0 ,
1183
+ Section0BBAddrMaps, std::nullopt);
1184
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 2 ,
1185
+ Section1BBAddrMaps, std::nullopt);
1186
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 1 ,
1187
+ Section2BBAddrMaps, std::nullopt);
1188
+
1189
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ std::nullopt,
1190
+ AllBBAddrMaps, AllPGOAnalysisMaps);
1191
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 0 ,
1192
+ Section0BBAddrMaps, Section0PGOAnalysisMaps);
1193
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 2 ,
1194
+ Section1BBAddrMaps, Section1PGOAnalysisMaps);
1195
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 1 ,
1196
+ Section2BBAddrMaps, Section2PGOAnalysisMaps);
1197
+ // Check that when no bb-address-map section is found for a text section,
1198
+ // we return an empty result.
1199
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 3 , {}, std::nullopt);
1200
+ DoCheckSucceeds (CommonYamlString, /* TextSectionIndex=*/ 3 , {},
1201
+ std::vector<PGOAnalysisMap>{});
1202
+ }
1146
1203
1147
1204
// Check that we detect when a bb-addr-map section is linked to an invalid
1148
1205
// (not present) section.
@@ -1151,33 +1208,40 @@ TEST(ELFObjectFileTest, ReadPGOAnalysisMap) {
1151
1208
Link: 10
1152
1209
)" ;
1153
1210
1154
- DoCheckFails (InvalidLinkedYamlString, /* TextSectionIndex=*/ 5 ,
1155
- " unable to get the linked-to section for "
1156
- " SHT_LLVM_BB_ADDR_MAP section with index 5: invalid section "
1157
- " index: 10" );
1158
- // Linked sections are not checked when we don't target a specific text
1159
- // section.
1160
- DoCheckSucceeds (InvalidLinkedYamlString, /* TextSectionIndex=*/ std::nullopt,
1161
- AllBBAddrMaps, std::nullopt);
1162
- DoCheckSucceeds (InvalidLinkedYamlString, /* TextSectionIndex=*/ std::nullopt,
1163
- AllBBAddrMaps, AllPGOAnalysisMaps);
1211
+ {
1212
+ SCOPED_TRACE (" invalid linked section" );
1213
+ DoCheckFails (InvalidLinkedYamlString, /* TextSectionIndex=*/ 5 ,
1214
+ " unable to get the linked-to section for "
1215
+ " SHT_LLVM_BB_ADDR_MAP section with index 5: invalid section "
1216
+ " index: 10" );
1217
+
1218
+ // Linked sections are not checked when we don't target a specific text
1219
+ // section.
1220
+ DoCheckSucceeds (InvalidLinkedYamlString, /* TextSectionIndex=*/ std::nullopt,
1221
+ AllBBAddrMaps, std::nullopt);
1222
+ DoCheckSucceeds (InvalidLinkedYamlString, /* TextSectionIndex=*/ std::nullopt,
1223
+ AllBBAddrMaps, AllPGOAnalysisMaps);
1224
+ }
1164
1225
1165
1226
// Check that we can detect when bb-address-map decoding fails.
1166
1227
SmallString<128 > TruncatedYamlString (CommonYamlString);
1167
1228
TruncatedYamlString += R"(
1168
1229
ShSize: 0xa
1169
1230
)" ;
1170
1231
1171
- DoCheckFails (TruncatedYamlString, /* TextSectionIndex=*/ std::nullopt,
1172
- " unable to read SHT_LLVM_BB_ADDR_MAP section with index 5: "
1173
- " unable to decode LEB128 at offset 0x0000000a: malformed "
1174
- " uleb128, extends past end" );
1175
- // Check that we can read the other section's bb-address-maps which are
1176
- // valid.
1177
- DoCheckSucceeds (TruncatedYamlString, /* TextSectionIndex=*/ 2 ,
1178
- Section1BBAddrMaps, std::nullopt);
1179
- DoCheckSucceeds (TruncatedYamlString, /* TextSectionIndex=*/ 2 ,
1180
- Section1BBAddrMaps, Section1PGOAnalysisMaps);
1232
+ {
1233
+ SCOPED_TRACE (" truncated section" );
1234
+ DoCheckFails (TruncatedYamlString, /* TextSectionIndex=*/ std::nullopt,
1235
+ " unable to read SHT_LLVM_BB_ADDR_MAP section with index 5: "
1236
+ " unable to decode LEB128 at offset 0x0000000a: malformed "
1237
+ " uleb128, extends past end" );
1238
+ // Check that we can read the other section's bb-address-maps which are
1239
+ // valid.
1240
+ DoCheckSucceeds (TruncatedYamlString, /* TextSectionIndex=*/ 2 ,
1241
+ Section1BBAddrMaps, std::nullopt);
1242
+ DoCheckSucceeds (TruncatedYamlString, /* TextSectionIndex=*/ 2 ,
1243
+ Section1BBAddrMaps, Section1PGOAnalysisMaps);
1244
+ }
1181
1245
}
1182
1246
1183
1247
// Test for ObjectFile::getRelocatedSection: check that it returns a relocated
0 commit comments