Skip to content
Open
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,13 @@ Expected<DWARFAddressRangesVector> DWARFDie::getAddressRanges() const {

std::optional<DWARFFormValue> Value = find(DW_AT_ranges);
if (Value) {
std::optional<uint64_t> SecOff = Value->getAsSectionOffset();
if (!SecOff) {
return DWARFAddressRangesVector();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please omit the {} from single-line if statements like this.

Might be worth making this code a bit more consistent in the way it handles non-present optionals, since currentnly the two cases right next to each other are handled differently (one with an if, the other with an if!+early return). I guess the early return might be preferable, consistent with LLVM's style preference to reduce indentation:

optional Value = ...
if (!Value)
  return;
optional SecOff = ...
if (!SecOff)
  return;
...

Also - can you include a test case that demonstrates/validates this bug/fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed the coding in the commit 394adb0.

How would you like to have the test case? Should I include the binary attached to the description of this issue in the LLVM repo?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We try to avoid checking in binary files, especially unbounded ones/ones without source code/asm code we could use to regenerate them.

Could you run the fixed dwarfdump on your test case, dump it out, then try to create a test case in assembly by hand that is minimal and exercises the interesting codepath (ie: crashes without this patch applied)?

if (Value->getForm() == DW_FORM_rnglistx)
return U->findRnglistFromIndex(*Value->getAsSectionOffset());
return U->findRnglistFromOffset(*Value->getAsSectionOffset());
return U->findRnglistFromIndex(*SecOff);
return U->findRnglistFromOffset(*SecOff);
}
return DWARFAddressRangesVector();
}
Expand Down
Loading