static void test_instructions( void **state ) { UNUSED( state ); uint64_t metadata = 0x5dd2ca2bcd04d53e; uint64_t metadata_mask = 0x3012174b861ea4fd; instruction *metadata_ins = create_instruction_write_metadata( metadata, metadata_mask ); instruction_list *ins_list = init_instruction_list(); append_instruction( ins_list, metadata_ins ); instruction *meter = create_instruction_meter( 0xc7231908 ); append_instruction( ins_list, meter ); instruction *apply_actions = create_instruction_apply_actions( complete_action_list() ); append_instruction( ins_list, apply_actions ); instruction *clear_actions = create_instruction_clear_actions(); append_instruction( ins_list, clear_actions ); dlist_element *e = get_first_element( ins_list ); if ( e->data == NULL ) { e = ins_list->next; } for (; e; e = e->next ) { if ( e->data != NULL ) { instruction *ins = e->data; printf( "ins type( %u )\n", ins->type ); } } instruction_list *new_ins_list; new_ins_list = copy_instruction_list( ins_list ); remove_instruction( ins_list, meter ); e = get_first_element( ins_list ); if ( e->data == NULL ) { e = ins_list->next; } for (; e; e = e->next ) { if ( e->data != NULL ) { instruction *ins = e->data; printf( "ad ins type( %u )\n", ins->type ); } } e = get_first_element( new_ins_list ); if ( e->data == NULL ) { e = new_ins_list->next; } for (; e; e = e->next ) { if ( e->data != NULL ) { instruction *ins = e->data; printf( "ins type( %u )\n", ins->type ); } } finalize_instruction_list( &new_ins_list ); finalize_instruction_list( &ins_list ); }
void labeled_icblock::append_clear_block(labeled_icblock &licb) { std::vector<labels_bkmap_type_>::const_iterator citlbk=licb.labels_bkmap_.begin(); std::vector<targets_bkmap_type_>::const_iterator cittbk=licb.targets_bkmap_.begin(); // foreach :) source instruction check the situation and use proper functions for(const_iterator cit=licb.begin();cit!=licb.end();++cit) { // setup labels for(;citlbk!=licb.labels_bkmap_.end() && citlbk->first==cit;++citlbk) add_label(citlbk->second); // check for an instruction with target if(cittbk!=licb.targets_bkmap_.end() && cittbk->first==cit) { (*cit)->patch_reljump(end()); const_iterator lasti = append_instruction_with_target(*cit, cittbk->second); ++cittbk; } else append_instruction(*cit); } // append empty_labels from the source block to the target block empty_labels_.insert(licb.empty_labels_.begin(), licb.empty_labels_.end()); // kill the source block licb.block_.clear(); licb.empty_labels_.clear(); licb.targets_.clear(); licb.labels_.clear(); licb.labels_bkmap_.clear(); licb.targets_bkmap_.clear(); }