Repository navigation
Name the sign extension instructions in trace output - #422
Open
natozenbilek wants to merge 1 commit into
Open
natozenbilek wants to merge 1 commit into
natozenbilek wants to merge 1 commit into
Conversation
The opcode names used by opcode_repr ended at 0xbf, so in trace mode the sign extension instructions added in TOPLLab#333 (0xc0 to 0xc4) were printed as "OPCODE out of bounds". Add their names and take the bound from the size of the table, so a new name only has to be added in one place. Fixes TOPLLab#345
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #345.
The table of opcode names in
src/Utils/macros.cppends at0xbf, so in aTRACE=1build the sign extension instructions from #333 (0xc0to0xc4) appear in the trace asOPCODE out of bounds.This PR:
debug_opcodes, using the same names as the comments ini_instr_extensionopcode_reprfrom the size of the table instead of the literal192, so a new name only has to be added in one placeAbout the crash in the issue: I could not get the VM to crash on current
main.opcode_reprhas had a bounds check since 2022, so these opcodes were mislabeled rather than read out of bounds. If you saw the crash in another setup, I'm happy to look into it.Testing
I built
wdcliwithTRACE=1on macOS (arm64, Apple clang) and ran a small module with one exported function per instruction (i32.constori64.const, the extension, thenend), once onmainand once on this branch:maini32.extend8_sOPCODE out of bounds0xc0 i32.extend8_si32.extend16_sOPCODE out of bounds0xc1 i32.extend16_si64.extend8_sOPCODE out of bounds0xc2 i64.extend8_si64.extend16_sOPCODE out of bounds0xc3 i64.extend16_si64.extend32_sOPCODE out of bounds0xc4 i64.extend32_sAll runs ended with
status ok. A small harness that callsopcode_reprdirectly shows that0xc5and0xffstill returnOPCODE out of bounds.macros.cppcompiles with-Wall -Wextra -Werrorwithout warnings, andclang-format20 reports no changes.I tested with
TRACE=1only, becauseDEBUG=1together withTRACE=1does not build onmainat the moment:dbg_dump_stackinmacros.cppstill usesm->sp,m->stackandm->callstack. I can send a separate PR for that if it would help.Draft #349 also extends this table (up to
0xd2) and lists0xc0to0xc4asUNDEFINED. Whichever of the two is merged second will need a small rebase in that hunk, and with the size-based bound #349 would no longer need to change the bound itself.