Skip to content

[GSYM] Use debug line offsets during GSYM creation #129196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,20 @@ static void convertFunctionLineTable(OutputAggregator &Out, CUInfo &CUI,
const object::SectionedAddress SecAddress{
StartAddress, object::SectionedAddress::UndefSection};

// Attempt to retrieve DW_AT_LLVM_stmt_sequence if present.
std::optional<uint64_t> StmtSeqOffset;
if (auto StmtSeqAttr = Die.find(llvm::dwarf::DW_AT_LLVM_stmt_sequence)) {
// The `DW_AT_LLVM_stmt_sequence` attribute might be set to `UINT64_MAX`
// when it refers to an empty line sequence. In such cases, the DWARF linker
// will exclude the empty sequence from the final output and assign
// `UINT64_MAX` to the `DW_AT_LLVM_stmt_sequence` attribute.
auto StmtSeqVal = dwarf::toSectionOffset(StmtSeqAttr, UINT64_MAX);
if (StmtSeqVal != UINT32_MAX)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC:

Suggested change
if (StmtSeqVal != UINT32_MAX)
if (StmtSeqVal != UINT64_MAX)

StmtSeqOffset = StmtSeqVal;
}

if (!CUI.LineTable->lookupAddressRange(SecAddress, RangeSize, RowVector)) {
if (!CUI.LineTable->lookupAddressRange(SecAddress, RangeSize, RowVector,
StmtSeqOffset)) {
// If we have a DW_TAG_subprogram but no line entries, fall back to using
// the DW_AT_decl_file an d DW_AT_decl_line if we have both attributes.
std::string FilePath = Die.getDeclFile(
Expand Down
Loading