Skip to content

Commit

Permalink
fix execute_blob for which ctx.processing return value changed
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDavid committed Jan 21, 2025
1 parent 0229df2 commit 92f372b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions qsynthesis/utils/symexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import List, Set, Iterable, Union, Optional

# third-party libs
from triton import ARCH, CALLBACK, MODE, MemoryAccess, Instruction, AST_REPRESENTATION, OPERAND
from triton import ARCH, CALLBACK, MODE, MemoryAccess, Instruction, AST_REPRESENTATION, OPERAND, EXCEPTION
from triton import TritonContext

# qsynthesis deps
Expand Down Expand Up @@ -418,8 +418,11 @@ def execute_blob(self, data: bytes, addr: Addr) -> bool:
pc = addr

while addr <= pc < (addr + len(data)): # while we remain in the blob
opcode = self.ctx.getConcreteMemoryAreaValue(pc, 16)
if not self.execute(opcode, pc):
opcode = self.ctx.getConcreteMemoryAreaValue(pc, 16)

i = self.disassemble(opcode, pc)

if not self.execute_instruction(i):
return False
pc = self.ctx.getConcreteRegisterValue(self.ins_ptr_reg)

Expand All @@ -439,12 +442,13 @@ def execute_basic_block(self, data: bytes, addr: Optional[Addr] = None) -> bool:
:rtype: bool
"""
blob = data[:]
cur_addr = addr
while blob:
i = self.disassemble(blob, addr)
addr = None # reset to None if it was provided
i = self.disassemble(blob, cur_addr)
if not self.execute_instruction(i):
return False
blob = blob[i.getSize():]
cur_addr += i.getSize()
return True

def execute(self, opcode: bytes, addr: Optional[Addr] = None) -> bool:
Expand Down Expand Up @@ -490,7 +494,7 @@ def execute_instruction(self, instr: Instruction) -> bool:
e.setComment(self._fmt_comment())

self._turn_off()
return r
return r == EXCEPTION.NO_FAULT

def _fmt_comment(self) -> str:
"""Return a string identifying a SymbolicExpression in a unique manner"""
Expand Down

0 comments on commit 92f372b

Please sign in to comment.