(original) (raw)


Folks,

I would like to ask about Bug 40703 - wrong line number info for obj file compiled with -ffunction-sections. The problem there is that when object file compiled, it does not have addresses assigned to sections. So it uses offsets inside section to dump instructions. When these offsets came to DwarfLineTable(to get line information) - it does not know which section it relates to. I have a fix for that bug. I believe correct fix would be to pass additional section information. But it changes interfaces and need to patch many places. I would like to ask whether these interface changes are OK. The main change is to pass not only address but corresponding Section Index also:

struct SectionedAddress {
uint64\_t Address;
uint64\_t SectionIndex;
};

include/llvm/DebugInfo/DIContext.h
======================================================
index a41ab21412d..cea7aedc26a 100644
--- a/llvm/include/llvm/DebugInfo/DIContext.h
+++ b/llvm/include/llvm/DebugInfo/DIContext.h
@@ -203,11 +203,11 @@ public:
return true;
}

- virtual DILineInfo getLineInfoForAddress(uint64\_t Address,
+ virtual DILineInfo getLineInfoForAddress(object::SectionedAddress Address,
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
- virtual DILineInfoTable getLineInfoForAddressRange(uint64\_t Address,
+ virtual DILineInfoTable getLineInfoForAddressRange(object::SectionedAddress Address,
uint64\_t Size, DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
- virtual DIInliningInfo getInliningInfoForAddress(uint64\_t Address,
+ virtual DIInliningInfo getInliningInfoForAddress(object::SectionedAddress Address,
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;


include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
======================================================
- uint32\_t lookupAddress(uint64\_t Address) const;
+ uint32\_t lookupAddress(llvm::SectionedAddress Address) const;

- bool lookupAddressRange(uint64\_t Address, uint64\_t Size,
+ bool lookupAddressRange(llvm::SectionedAddress Address, uint64\_t Size,
std::vector &Result) const;

bool hasFileAtIndex(uint64\_t FileIndex) const;
@@ -238,7 +247,7 @@ public:

/// Fills the Result argument with the file and line information
/// corresponding to Address. Returns true on success.
- bool getFileLineInfoForAddress(uint64\_t Address, const char \*CompDir,
+ bool getFileLineInfoForAddress(llvm::SectionedAddress Address, const char \*CompDir,
DILineInfoSpecifier::FileLineInfoKind Kind,
DILineInfo &Result) const;

- uint32\_t lookupAddress(uint64\_t Address) const;
+ uint32\_t lookupAddress(llvm::SectionedAddress Address) const;

include/llvm/DebugInfo/Symbolize/Symbolize.h
======================================================
@@ -57,13 +57,13 @@ public:
}

Expected symbolizeCode(const std::string &ModuleName,
- uint64\_t ModuleOffset,
+ object::SectionedAddress ModuleOffset,
StringRef DWPName = "");
Expected symbolizeInlinedCode(const std::string &ModuleName,
- uint64\_t ModuleOffset,
+ object::SectionedAddress ModuleOffset,
StringRef DWPName = "");
Expected symbolizeData(const std::string &ModuleName,
- uint64\_t ModuleOffset);
+ object::SectionedAddress ModuleOffset);


include/llvm/DebugInfo/Symbolize/SymbolizableModule.h
======================================================
@@ -24,13 +24,13 @@ class SymbolizableModule {
public:
virtual \~SymbolizableModule() = default;

- virtual DILineInfo symbolizeCode(uint64\_t ModuleOffset,
+ virtual DILineInfo symbolizeCode(object::SectionedAddress ModuleOffset,
FunctionNameKind FNKind,
bool UseSymbolTable) const = 0;
- virtual DIInliningInfo symbolizeInlinedCode(uint64\_t ModuleOffset,
+ virtual DIInliningInfo symbolizeInlinedCode(object::SectionedAddress ModuleOffset,
FunctionNameKind FNKind,
bool UseSymbolTable) const = 0;
- virtual DIGlobal symbolizeData(uint64\_t ModuleOffset) const = 0;
+ virtual DIGlobal symbolizeData(object::SectionedAddress ModuleOffset) const = 0;

If there are no objections for such interface change I would proceed with my fix in fabricator.


Thank you, Alexey.