Skip to content

feat: carry per-instruction byte size on InstructionTextLine#33

Merged
tinysec merged 1 commit into
masterfrom
feat/instruction-text-line-byte-size
Jul 8, 2026
Merged

feat: carry per-instruction byte size on InstructionTextLine#33
tinysec merged 1 commit into
masterfrom
feat/instruction-text-line-byte-size

Conversation

@tinysec

@tinysec tinysec commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Completes HIGH-severity parity gap #30. PR #30 added the address half (InstructionTextLine.Address, mirroring Function.instructions/BinaryView.instructions yield (tokens, addr)). This PR adds the byte-size half, mirroring Python BasicBlock.__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 consecutive Address values.

Changes

  • InstructionTextLine.ByteSize (ulong, default 0 for synthesized token lists) + a (tokens, address, byteSize) constructor (Struct/BNInstructionTextLine.cs). Existing constructors retained for API completeness.
  • The single producer site (Handle/BNBasicBlock.cs) now passes the decoded length, which feeds Function.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 satisfy next.Address == prev.Address + prev.ByteSize (the exact property the address alone cannot recover for the last instruction). Full harness regression 51/51.

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.
@tinysec tinysec merged commit 6ab8a80 into master Jul 8, 2026
1 check passed
@tinysec tinysec deleted the feat/instruction-text-line-byte-size branch July 8, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant