<commit_before>#!/usr/bin/env python

import pysex
from helpers import once
import logging
l = logging.getLogger("angr.function")

class Function(object):
	def __init__(self, start, ida, mem, arch, bin, name = None):
		self.bin = bin
		self.start = start
		self.ida = ida
		self.mem = mem
		self.arch = arch
		self.name = [ "sub_%x" % start if not name else name ]

	def bytes(self):
		start, end = self.range()
		return "".join([self.mem[i] for i in range(start, end)])

	@once
	def range(self):
		starts, ends = [ ], [ ]
		l.debug("Getting range from IDA")

		f = self.ida.idaapi.get_func(self.start)
		r = (f.startEA, f.endEA)
		l.debug("Got range (%x, %x)." % r)
		return r

	@once
	def symbolic_translation(self, init=None):
		return pysex.translate_bytes(self.start, self.bytes(), self.start, init, arch=self.arch)

	def sym_vex_blocks(self, init=None):
		blocks = { }
		total_size = 0
		sblocks, exits_out, unsat_exits = self.symbolic_translation(init)

		for exit_type in sblocks:
			for start, sirsb in sblocks[exit_type].iteritems():
				total_size += sirsb.irsb.size()
				blocks[start] = sirsb
				l.debug("Block at %x of size %d" % (start, sirsb.irsb.size()))

		l.debug("Total VEX IRSB size, in bytes: %d" % total_size)
		return blocks

	def exits(self):
		sblocks, exits_out, unsat_exits = self.symbolic_translation()
		exits = [ ]

		for exit in exits_out:<commit_msg>actually pass on the initial state<commit_after>#!/usr/bin/env python

import pysex
from helpers import once
import logging
l = logging.getLogger("angr.function")

class Function(object):
	def __init__(self, start, ida, mem, arch, bin, name = None):
		self.bin = bin
		self.start = start
		self.ida = ida
		self.mem = mem
		self.arch = arch
		self.name = [ "sub_%x" % start if not name else name ]

	def bytes(self):
		start, end = self.range()
		return "".join([self.mem[i] for i in range(start, end)])

	@once
	def range(self):
		starts, ends = [ ], [ ]
		l.debug("Getting range from IDA")

		f = self.ida.idaapi.get_func(self.start)
		r = (f.startEA, f.endEA)
		l.debug("Got range (%x, %x)." % r)
		return r

	@once
	def symbolic_translation(self, init=None):
		if not init: init = pysex.SymbolicState(memory_backer=self.mem, arch=self.arch)
		return pysex.translate_bytes(self.start, self.bytes(), self.start, init, arch=self.arch)

	def sym_vex_blocks(self, init=None):
		blocks = { }
		total_size = 0
		sblocks, exits_out, unsat_exits = self.symbolic_translation(init)

		for exit_type in sblocks:
			for start, sirsb in sblocks[exit_type].iteritems():
				total_size += sirsb.irsb.size()
				blocks[start] = sirsb
				l.debug("Block at %x of size %d" % (start, sirsb.irsb.size()))

		l.debug("Total VEX IRSB size, in bytes: %d" % total_size)
		return blocks

	def exits(self):
		sblocks, exits_out, unsat_exits = self.symbolic_translation()
		exits = [ ]

		for exit in exits_out:
{'fraction_non_alphanumeric': 0.14071752002786486, 'fraction_numerical': 0.0006966213862765587, 'mean_word_length': 3.8513513513513513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4504553', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1058, 'n_words': 282}