#NEWLINE# def differing_constants( block_a , block_b ) : #NEWLINE# #INDENT# '\n    Compares two basic blocks and finds all the constants that differ from the first block to the second.\n\n    :param block_a: The first block to compare.\n    :param block_b: The second block to compare.\n    :returns:       Returns a list of differing constants in the form of ConstantChange, which has the offset in the\n                    block and the respective constants.\n    ' #NEWLINE# statements_a = ( [ s for s in block_a . vex . statements if ( s . tag != 'Ist_IMark' ) ] + [ block_a . vex . next ] ) #NEWLINE# statements_b = ( [ s for s in block_b . vex . statements if ( s . tag != 'Ist_IMark' ) ] + [ block_b . vex . next ] ) #NEWLINE# if ( len ( statements_a ) != len ( statements_b ) ) : #NEWLINE# #INDENT# raise UnmatchedStatementsException ( 'Blocks have different numbers of statements' ) #NEWLINE# #UNINDENT# start_1 = min ( block_a . instruction_addrs ) #NEWLINE# start_2 = min ( block_b . instruction_addrs ) #NEWLINE# changes = [ ] #NEWLINE# current_offset = None #NEWLINE# for ( statement , statement_2 ) in zip ( statements_a , statements_b ) : #NEWLINE# #INDENT# if ( statement . tag != statement_2 . tag ) : #NEWLINE# #INDENT# raise UnmatchedStatementsException ( 'Statement tag has changed' ) #NEWLINE# #UNINDENT# if ( statement . tag == 'Ist_IMark' ) : #NEWLINE# #INDENT# if ( ( statement . addr - start_1 ) != ( statement_2 . addr - start_2 ) ) : #NEWLINE# #INDENT# raise UnmatchedStatementsException ( 'Instruction length has changed' ) #NEWLINE# #UNINDENT# current_offset = ( statement . addr - start_1 ) #NEWLINE# continue #NEWLINE# #UNINDENT# differences = compare_statement_dict ( statement , statement_2 ) #NEWLINE# for d in statement : #NEWLINE# #INDENT# if ( d . type != DIFF_VALUE ) : #NEWLINE# #INDENT# raise UnmatchedStatementsException ( 'Instruction has changed' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# changes . append ( ConstantChange ( current_offset , d . value_a , d . value_b ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return changes