[llvm] [llvm-debuginfo-analyzer] Add support for WebAssembly binary format. (PR #82588)
Carlos Alberto Enciso via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 13 05:56:11 PDT 2024
================
@@ -429,10 +431,14 @@ void LVELFReader::processOneAttribute(const DWARFDie &Die, LVOffset *OffsetPtr,
CurrentHighPC = *Address;
if (std::optional<uint64_t> Offset = FormValue.getAsUnsignedConstant())
// High PC is an offset from LowPC.
- CurrentHighPC = CurrentLowPC + *Offset;
+ // Don't add the WebAssembly offset if we have seen a DW_AT_low_pc.
+ CurrentHighPC =
+ (FoundLowPC ? CurrentLowPC - WasmOffset : CurrentLowPC) + *Offset;
----------------
CarlosAlbertoEnciso wrote:
Your analysis is correct until the line where `CurrentHighPC` is calculated based on `CurrentLowPC`.
Referring again to the code for `DW_AT_high_pc`:
```
case dwarf::DW_AT_high_pc:
...
if (std::optional<uint64_t> Offset = FormValue.getAsUnsignedConstant())
// Don't add the WebAssembly offset if we have seen a DW_AT_low_pc.
CurrentHighPC =
(FoundLowPC ? CurrentLowPC - WasmOffset : CurrentLowPC) + *Offset;
```
At this point:
`CurrentHighPC` is 140 - 100 + 10 = **50**, whereas `CurrentLowPC` is **140**
```
...
// Consider the case of WebAssembly.
CurrentHighPC += WasmOffset;
```
At this point:
`CurrentHighPC` will be 50 + 100 = **150**, whereas `CurrentLowPC` is **140** and their offset is **10** (with WasmOffset)
```
...
break;
```
I hope this clarify as how the values are calculated.
https://github.com/llvm/llvm-project/pull/82588
More information about the llvm-commits
mailing list