diff options
author | Alon Zakai <azakai@google.com> | 2020-02-18 19:22:39 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-18 19:22:39 -0800 |
commit | 08cc4d6711702a3f69159a0a4aa6e8ecedb98b5c (patch) | |
tree | 8cd28afd9739f85dc799616cf6bf3690cd009bef /src/wasm | |
parent | 8307ac45a831273ba86707a8267f908ee1c7c747 (diff) | |
download | binaryen-08cc4d6711702a3f69159a0a4aa6e8ecedb98b5c.tar.gz binaryen-08cc4d6711702a3f69159a0a4aa6e8ecedb98b5c.tar.bz2 binaryen-08cc4d6711702a3f69159a0a4aa6e8ecedb98b5c.zip |
DWARF: Fix debug_range handling of invalid entries (#2662)
If an invalid entry appears - either it began as such, or became
invalid after optimization - we should not emit (0, 0) which is
an end marker. Instead, emit an invalid entry marker, something
with (0, x) for x != 0.
As a bonus, if a test/passes case has "noprint" in the name,
don't print the wasm, which we do by default. In the testcase
here for example we just care about the dwarf, and the
printed module would be quite large.
Thank you to @paolosevMSFT for identifying and suggesting
the fix.
Diffstat (limited to 'src/wasm')
-rw-r--r-- | src/wasm/wasm-debug.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/wasm/wasm-debug.cpp b/src/wasm/wasm-debug.cpp index f9929c8bd..50a04a6e6 100644 --- a/src/wasm/wasm-debug.cpp +++ b/src/wasm/wasm-debug.cpp @@ -835,31 +835,27 @@ static void updateRanges(llvm::DWARFYAML::Data& yaml, auto& range = yaml.Ranges[i]; BinaryLocation oldStart = range.Start, oldEnd = range.End, newStart = 0, newEnd = 0; - // If this was not an end marker, try to find what it should be updated to. - if (oldStart != 0 && oldEnd != 0) { + // If this is an end marker (0, 0), or an invalid range (0, x) or (x, 0) + // then just emit it as it is - either to mark the end, or to mark an + // invalid entry. + if (oldStart == 0 || oldEnd == 0) { + newStart = oldStart; + newEnd = oldEnd; + } else { + // This was a valid entry; update it. newStart = locationUpdater.getNewStart(oldStart); newEnd = locationUpdater.getNewEnd(oldEnd); if (newStart == 0 || newEnd == 0) { // This part of the range no longer has a mapping, so we must skip it. - skip++; - continue; + // Don't use (0, 0) as that would be an end marker; emit something + // invalid for the debugger to ignore. + newStart = 0; + newEnd = 1; } - // The range start and end markers have been preserved. However, TODO + // TODO even if range start and end markers have been preserved, // instructions in the middle may have moved around, making the range no - // longer contiguous, we should check that, and possibly split/merge + // longer contiguous. We should check that, and possibly split/merge // the range. Or, we may need to have tracking in the IR for this. - } else { - // This was not a valid range in the old binary. It was either two 0's - // (an end marker) or an invalid value that should be ignored. Either way, - // write an end marker and finish the current section of ranges, filling - // it out to the original size (we must fill it out as indexes into - // the ranges section are not updated - we could update them and then - // pack the section, as an optimization TODO). - while (skip) { - auto& writtenRange = yaml.Ranges[i - skip]; - writtenRange.Start = writtenRange.End = 0; - skip--; - } } auto& writtenRange = yaml.Ranges[i - skip]; writtenRange.Start = newStart; |