@@ -2738,29 +2738,25 @@ static Expected<DebugNamesBaseSection::IndexEntry *>
2738
2738
readEntry (uint64_t &offset, const DWARFDebugNames::NameIndex &ni,
2739
2739
uint64_t entriesBase, DWARFDataExtractor &namesExtractor,
2740
2740
const LLDDWARFSection &namesSec) {
2741
- std::string errMsg;
2742
2741
auto ie = makeThreadLocal<DebugNamesBaseSection::IndexEntry>();
2743
2742
ie->poolOffset = offset;
2744
2743
Error err = Error::success ();
2745
2744
uint64_t ulebVal = namesExtractor.getULEB128 (&offset, &err);
2746
- if (err) {
2747
- errMsg = " : invalid abbrev code in entry: " ;
2748
- errMsg.append (toString (std::move (err)));
2749
- return createStringError (inconvertibleErrorCode (), errMsg.c_str ());
2750
- }
2751
- if (ulebVal < UINT32_MAX)
2745
+ if (err)
2746
+ return createStringError (inconvertibleErrorCode (),
2747
+ " invalid abbrev code in entry: %s" ,
2748
+ toString (std::move (err)).c_str ());
2749
+ if (ulebVal <= UINT32_MAX)
2752
2750
ie->abbrevCode = static_cast <uint32_t >(ulebVal);
2753
- else {
2754
- errMsg = " : abbrev code in entry too large for DWARF32: " ;
2755
- errMsg.append (std::to_string (ulebVal));
2756
- return createStringError (inconvertibleErrorCode (), errMsg.c_str ());
2757
- }
2751
+ else
2752
+ return createStringError (inconvertibleErrorCode (),
2753
+ " abbrev code in entry too large for DWARF32: %d" ,
2754
+ ulebVal);
2758
2755
auto it = ni.getAbbrevs ().find_as (ie->abbrevCode );
2759
- if (it == ni.getAbbrevs ().end ()) {
2760
- errMsg = " : entry abbrev code not found in abbrev table: " ;
2761
- errMsg.append (std::to_string (ie->abbrevCode ));
2762
- return createStringError (inconvertibleErrorCode (), errMsg.c_str ());
2763
- }
2756
+ if (it == ni.getAbbrevs ().end ())
2757
+ return createStringError (inconvertibleErrorCode (),
2758
+ " entry abbrev code not found in abbrev table: %d" ,
2759
+ ie->abbrevCode );
2764
2760
2765
2761
DebugNamesBaseSection::AttrValue attr, cuAttr = {0 , 0 };
2766
2762
for (DWARFDebugNames::AttributeEncoding a : it->Attributes ) {
@@ -2769,9 +2765,9 @@ readEntry(uint64_t &offset, const DWARFDebugNames::NameIndex &ni,
2769
2765
attr.attrValue = namesExtractor.getU32 (&offset, &err);
2770
2766
attr.attrSize = 4 ;
2771
2767
ie->parentOffset = entriesBase + attr.attrValue ;
2772
- } else if (a.Form != DW_FORM_flag_present) {
2773
- errMsg = " : invalid form for DW_IDX_parent " ;
2774
- }
2768
+ } else if (a.Form != DW_FORM_flag_present)
2769
+ return createStringError ( inconvertibleErrorCode (),
2770
+ " invalid form for DW_IDX_parent " );
2775
2771
} else {
2776
2772
switch (a.Form ) {
2777
2773
case DW_FORM_data1:
@@ -2793,17 +2789,15 @@ readEntry(uint64_t &offset, const DWARFDebugNames::NameIndex &ni,
2793
2789
break ;
2794
2790
}
2795
2791
default :
2796
- errMsg = " : unrecognized form encoding " ;
2797
- errMsg.append (std::to_string (a.Form ));
2798
- errMsg.append (" in abbrev table" );
2799
- return createStringError (inconvertibleErrorCode (), errMsg.c_str ());
2792
+ return createStringError (
2793
+ inconvertibleErrorCode (),
2794
+ " unrecognized form encoding %d in abbrev table" , a.Form );
2800
2795
}
2801
2796
}
2802
- if (err) {
2803
- errMsg = " : error while reading attributes: " ;
2804
- errMsg.append (toString (std::move (err)));
2805
- return createStringError (inconvertibleErrorCode (), errMsg.c_str ());
2806
- }
2797
+ if (err)
2798
+ return createStringError (inconvertibleErrorCode (),
2799
+ " error while reading attributes: %s" ,
2800
+ toString (std::move (err)).c_str ());
2807
2801
if (a.Index == DW_IDX_compile_unit)
2808
2802
cuAttr = attr;
2809
2803
else if (a.Form != DW_FORM_flag_present)
@@ -2813,10 +2807,7 @@ readEntry(uint64_t &offset, const DWARFDebugNames::NameIndex &ni,
2813
2807
// Canonicalize abbrev by placing the CU/TU index at the end.
2814
2808
ie->attrValues .push_back (cuAttr);
2815
2809
2816
- if (!errMsg.empty ())
2817
- return createStringError (inconvertibleErrorCode (), errMsg.c_str ());
2818
- else
2819
- return ie;
2810
+ return ie;
2820
2811
}
2821
2812
2822
2813
void DebugNamesBaseSection::parseDebugNames (
@@ -2866,23 +2857,21 @@ void DebugNamesBaseSection::parseDebugNames(
2866
2857
ne.hashValue = caseFoldingDjbHash (name);
2867
2858
2868
2859
// Read a series of index entries that end with abbreviation code 0.
2869
- std::string errMsg;
2870
2860
uint64_t offset = locs.EntriesBase + entryOffsets[i];
2871
2861
while (offset < namesSec.Data .size () && namesSec.Data [offset] != 0 ) {
2872
2862
// Read & store all entries (for the same string).
2873
2863
Expected<IndexEntry *> ieOrErr =
2874
2864
readEntry (offset, ni, locs.EntriesBase , namesExtractor, namesSec);
2875
2865
if (!ieOrErr) {
2876
- errorOrWarn (toString (namesSec.sec ) +
2877
- Twine ( toString (ieOrErr.takeError () )));
2866
+ errorOrWarn (toString (namesSec.sec ) + " : " +
2867
+ toString (ieOrErr.takeError ()));
2878
2868
return ;
2879
2869
}
2880
2870
ne.indexEntries .push_back (std::move (*ieOrErr));
2881
2871
}
2882
2872
if (offset >= namesSec.Data .size ())
2883
- errMsg = " : index entry is out of bounds" ;
2884
- if (!errMsg.empty ())
2885
- errorOrWarn (toString (namesSec.sec ) + Twine (errMsg.c_str ()));
2873
+ errorOrWarn (toString (namesSec.sec ) +
2874
+ Twine (" : index entry is out of bounds" ));
2886
2875
2887
2876
for (IndexEntry &ie : ne.entries ())
2888
2877
offsetMap[ie.poolOffset ] = &ie;
@@ -3023,9 +3012,9 @@ std::pair<uint32_t, uint32_t> DebugNamesBaseSection::computeEntryPool(
3023
3012
// Collect and de-duplicate all the names (preserving all the entries).
3024
3013
// Speed it up using multithreading, as the number of symbols can be in the
3025
3014
// order of millions.
3026
- size_t concurrency =
3015
+ const size_t concurrency =
3027
3016
bit_floor (std::min<size_t >(config->threadCount , numShards));
3028
- size_t shift = 32 - countr_zero (numShards);
3017
+ const size_t shift = 32 - countr_zero (numShards);
3029
3018
uint8_t cuAttrSize = getMergedCuCountForm (hdr.CompUnitCount ).first ;
3030
3019
DenseMap<CachedHashStringRef, size_t > maps[numShards];
3031
3020
0 commit comments