[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());
+ }
+
+ DebugNamesBaseSection::AttrValue attr, cuAttr = {0, 0};
+ for (DWARFDebugNames::AttributeEncoding a : it->Attributes) {
+ if (a.Index == dwarf::DW_IDX_parent) {
+ if (a.Form == dwarf::DW_FORM_ref4) {
+ attr.attrValue = namesExtractor.getU32(&offset, &err);
+ attr.attrSize = 4;
+ ie->parentOffset = entriesBase + attr.attrValue;
+ } else if (a.Form != DW_FORM_flag_present) {
+ errMsg = ": invalid form for DW_IDX_parent";
----------------
dwblaikie wrote:
Presumably should just return immediately here, with the string error?
And then there's no reason for `errMsg` to have such a wide scope (or possibly to exist at all)
https://github.com/llvm/llvm-project/pull/86508
More information about the llvm-commits
mailing list