<commit_before>#!/usr/bin/env python
'''This module handles constraint generation for IRSBs.'''

import z3
import pyvex
import s_irstmt
import s_helpers
import s_exit

import logging
l = logging.getLogger("s_irsb")
#l.setLevel(logging.DEBUG)

class SymbolicIRSB:
	# Symbolically parses a basic block.
	#
	#	irsb - the pyvex IRSB to parse
	#	initial_state - the symbolic state at the beginning of the block
	#	id - the ID of the basic block
	#	ethereal - whether the basic block is a made-up one (ie, for an emulated ret)
	def __init__(self, irsb, initial_state, id=None, ethereal=False):
		if irsb.size() == 0:
			raise Exception("Empty IRSB passed to SymbolicIRSB.")

		self.irsb = irsb

		# set the ID and copy the initial state
		self.first_imark = [i for i in self.irsb.statements() if type(i)==pyvex.IRStmt.IMark][0]
		state = initial_state
		if not ethereal:
			state.block_path.append(self.first_imark.addr)

		if id is None:
			state.id = "%x" % self.first_imark.addr
		else:
			state.id = id
		self.initial_state = initial_state.copy_after()

		#l.debug("Blockstack is now: %s" % " ".join(["%x" % x for x in self.initial_state.block_path ]))
<commit_msg>added SymbolicIRSBException to fight pokemon exception handling<commit_after>#!/usr/bin/env python
'''This module handles constraint generation for IRSBs.'''

import z3
import pyvex
import s_irstmt
import s_helpers
import s_exit

import logging
l = logging.getLogger("s_irsb")
#l.setLevel(logging.DEBUG)

class SymbolicIRSBError(Exception):
	pass

class SymbolicIRSB:
	# Symbolically parses a basic block.
	#
	#	irsb - the pyvex IRSB to parse
	#	initial_state - the symbolic state at the beginning of the block
	#	id - the ID of the basic block
	#	ethereal - whether the basic block is a made-up one (ie, for an emulated ret)
	def __init__(self, irsb, initial_state, id=None, ethereal=False):
		if irsb.size() == 0:
			raise SymbolicIRSBError("Empty IRSB passed to SymbolicIRSB.")

		self.irsb = irsb

		# set the ID and copy the initial state
		self.first_imark = [i for i in self.irsb.statements() if type(i)==pyvex.IRStmt.IMark][0]
		state = initial_state
		if not ethereal:
			state.block_path.append(self.first_imark.addr)

		if id is None:
			state.id = "%x" % self.first_imark.addr
		else:
			state.id = id
		self.initial_state = initial_state.copy_after()

		#l.debug("Blockstack is now: %s" % " ".join(["%x" % x for x in self.initial_state.block_path ]))

{'fraction_non_alphanumeric': 0.10671611042439226, 'fraction_numerical': 0.002472187886279357, 'mean_word_length': 4.058333333333334, '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': '5126032', 'n_tokens_mistral': 914, 'n_tokens_neox': 858, 'n_words': 267}