feat: carry per-instruction byte size on InstructionTextLine#33
Merged
Conversation
Completes HIGH parity gap #30 (PR #30 added the address half; this adds the byte-size half). Python's BasicBlock.__getitem__ yields (tokens, size) per instruction, so the size is as much a part of an instruction's identity as its address. InstructionTextLine previously computed the decoded length at the producer and then dropped it, so a caller could not recover HOW LONG an instruction was -- and a block's last instruction has no successor, so its size could not even be derived from consecutive Addresses. Add InstructionTextLine.ByteSize (default 0 for synthesized token lists) and a (tokens, address, byteSize) constructor; populate it at the single producer site (BasicBlock.GetInstructionTextLines), which feeds Function.GetInstructions / BinaryView.GetInstructions / BasicBlock.GetInstructionByIndex.
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.
Summary
Completes HIGH-severity parity gap #30. PR #30 added the address half (
InstructionTextLine.Address, mirroringFunction.instructions/BinaryView.instructionsyield(tokens, addr)). This PR adds the byte-size half, mirroring PythonBasicBlock.__getitem__which yields(tokens, size)(basicblock.py:210).The producer (
BasicBlock.GetInstructionTextLines) decoded each instruction's length and then dropped it, so callers could not recover how long an instruction was — and a block's last instruction has no successor, so its size could not even be derived from consecutiveAddressvalues.Changes
InstructionTextLine.ByteSize(ulong, default0for synthesized token lists) + a(tokens, address, byteSize)constructor (Struct/BNInstructionTextLine.cs). Existing constructors retained for API completeness.Handle/BNBasicBlock.cs) now passes the decoded length, which feedsFunction.GetInstructions/BinaryView.GetInstructions/BasicBlock.GetInstructionByIndex.E2E test (harness repo)
GetInstructionsCarriesPerInstructionByteSize— asserts every disassembled instruction reports a positive byte size, and that consecutive interior lines within a block satisfynext.Address == prev.Address + prev.ByteSize(the exact property the address alone cannot recover for the last instruction). Full harness regression 51/51.