From 88eba55a93f4f750ccdfe81575c91c59a73f3a8c Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Fri, 4 Jul 2025 16:43:31 -0400 Subject: [WARP] Fix possible skipped instructions when multiple IL expressions are appended for a given instruction --- rust/src/low_level_il/function.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'rust/src') diff --git a/rust/src/low_level_il/function.rs b/rust/src/low_level_il/function.rs index f5fcf25f..cf3a432a 100644 --- a/rust/src/low_level_il/function.rs +++ b/rust/src/low_level_il/function.rs @@ -93,6 +93,31 @@ where } } + /// Get all the contiguous instructions for a given location. + /// + /// NOTE: This won't get you every instruction for a location, only the instructions + /// that are sequential from the starting instruction. + pub fn instructions_at>(&self, loc: L) -> Vec> { + let loc = loc.into(); + // TODO: Instructions sharing the same address are not always sequential. + // Gather all of the sequential instructions with the same address and same block. + self.instruction_index_at(loc) + .map(|mut idx| { + let mut instructions = Vec::new(); + let block = self.basic_block_containing_index(idx); + while idx.0 < self.instruction_count() { + let instr = LowLevelILInstruction::new(self, idx); + if instr.address() != loc.addr || instr.basic_block() != block { + break; + } + instructions.push(instr); + idx = idx.next(); + } + instructions + }) + .unwrap_or_default() + } + pub fn instruction_at>(&self, loc: L) -> Option> { Some(LowLevelILInstruction::new( self, -- cgit v1.3.1