[lld] [lld][ELF] Add --debug-names to create merged .debug_names. (PR #86508)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 18 08:54:09 PDT 2024
================
@@ -2734,14 +2734,99 @@ static uint32_t getDebugNamesHeaderSize(uint32_t augmentationStringSize) {
/* Augmentation string */ augmentationStringSize;
}
+static Expected<DebugNamesBaseSection::IndexEntry *>
+readEntry(uint64_t &offset, const DWARFDebugNames::NameIndex &ni,
+ uint64_t entriesBase, DWARFDataExtractor &namesExtractor,
+ const LLDDWARFSection &namesSec) {
+ std::string errMsg;
+ auto ie = makeThreadLocal<DebugNamesBaseSection::IndexEntry>();
+ ie->poolOffset = offset;
+ Error err = Error::success();
+ uint64_t ulebVal = namesExtractor.getULEB128(&offset, &err);
+ if (err) {
+ errMsg = ": invalid abbrev code in entry: ";
+ errMsg.append(toString(std::move(err)));
+ return createStringError(inconvertibleErrorCode(), errMsg.c_str());
+ }
+ if (ulebVal < UINT32_MAX)
+ ie->abbrevCode = static_cast<uint32_t>(ulebVal);
+ else {
+ errMsg = ": abbrev code in entry too large for DWARF32: ";
+ errMsg.append(std::to_string(ulebVal));
+ return createStringError(inconvertibleErrorCode(), errMsg.c_str());
+ }
+ auto it = ni.getAbbrevs().find_as(ie->abbrevCode);
+ if (it == ni.getAbbrevs().end()) {
+ errMsg = ": entry abbrev code not found in abbrev table: ";
+ errMsg.append(std::to_string(ie->abbrevCode));
+ return createStringError(inconvertibleErrorCode(), errMsg.c_str());
----------------
dwblaikie wrote:
Use the format version of `createStringError`:
```
return createStringError(inconvertibleErrorCode(), ": entry abbrev code too large for DWARF32: %d", ie->abbrevCode);
```
here and elsewhere - then `errMsg` can be removed, most likely.
https://github.com/llvm/llvm-project/pull/86508
More information about the llvm-commits
mailing list