void debug_disasm(ui32 ins) { instruction_t *instr = disassemble_instruction(ins); puts("==========================="); puts(instr->disassembled_str); switch (instr->type) { default: case NO_OPERANDS: break; case REGISTER_REGISTER: pprint("oper1", registers[instr->operand1.reg]); pprint("oper2", registers[instr->operand2.reg]); break; case REGISTER_IMMEDIATE: pprint("oper1", registers[instr->operand1.reg]); pprint("oper2", instr->operand2.imm); break; case REGISTER_NO_IMMEDIATE: pprint("oper1", registers[instr->operand1.imm]); break; case IMMEDIATE_NO_REGISTER: pprint("oper1", instr->operand1.imm); break; } free_instruction(&instr); }
void free_instructions(instructionlist_t instructions) { for (unsigned i = 0; i < instructions.size; ++i) if (list_nth(instructions, i)) free_instruction(list_nth(instructions, i)); list_free(instructions); }
void free_program(struct program *p) { if (p == NULL) return; free_vars(p->v); free_instruction(p->i); free(p); }
void free_instruction(struct instruction *i) { if (i) { free_single(i->s); free_instruction(i->i); } }
void reset_ctx(ARMSIM_CTX *ctx){ as_log(ctx, "ENTERING RESET_CTX\n",0); ctx->pfr_address = 0; ctx->pfr_instruction = 0; if(ctx->pdr !=0) { free_instruction(ctx->pdr); } ctx->pdr = 0; if(ctx->per != 0){ free_instruction(ctx->per); } ctx->per = 0; reset_registers(ctx->registers, ctx->entry); ctx->steps = 0; ctx->running = 0; as_log(ctx, "Leaving as_execute\n",0); }
void delete_instruction_set( instruction_set *instructions ) { assert( instructions != NULL ); if ( instructions->goto_table != NULL ) { free_instruction( instructions->goto_table ); } if ( instructions->write_metadata != NULL ) { free_instruction( instructions->write_metadata ); } if ( instructions->write_actions != NULL ) { free_instruction( instructions->write_actions ); } if ( instructions->apply_actions != NULL ) { free_instruction( instructions->apply_actions ); } if ( instructions->clear_actions != NULL ) { free_instruction( instructions->clear_actions ); } if ( instructions->meter != NULL ) { free_instruction( instructions->meter ); } if ( instructions->experimenter != NULL ) { free_instruction( instructions->experimenter ); } xfree( instructions ); }
void free_instruction_list (instruction_list *insts) { while (insts) { instruction_list *tmp = insts->rest; free_instruction (insts->inst); free (insts); insts = tmp; } }
void flush(ARMSIM_CTX *ctx){ as_log(ctx, "Entering flush\n",0); set_register(ctx->registers, AR_r15, get_effective_pc(ctx)); ctx->pfr_address = 0; ctx->pfr_instruction = 0; if(ctx->pdr != 0){ free_instruction(ctx->pdr); } ctx->pdr = 0; as_log(ctx, "Leaving flush\n",0); }
void branch_cpu(ARMSIM_CTX *ctx, ARM_ADDRESS new_pc){ as_log(ctx, "Entering branch_cpu\n",0); char * log_message = (char*)malloc(sizeof(char) * LOG_STRING_LENGTH); char * instruction_string = instruction_to_string(ctx->pdr); sprintf(log_message, "**** BRANCH TO %#010x -- FLUSHING PIPELINE [pfr=%#010x, pdr=[%s] ****", new_pc, ctx->pfr_instruction, instruction_string); as_log(ctx, (const char *)log_message, 0); free(log_message); free(instruction_string); ctx->pfr_address = 0; ctx->pfr_instruction = 0; if(ctx->pdr != 0){ free_instruction(ctx->pdr); } ctx->pdr = 0; set_register(ctx->registers, AR_r15, new_pc); as_log(ctx, "Leaving branch_cpu\n",0); }
OFDPE delete_instruction( instruction_set *instructions, const uint16_t type ) { assert( instructions != NULL ); assert( type >= 1 ); OFDPE ret = OFDPE_SUCCESS; switch( type ) { case OFPIT_GOTO_TABLE: { if ( instructions->goto_table != NULL ) { free_instruction( instructions->goto_table ); instructions->goto_table = NULL; } else { ret = ERROR_INVALID_PARAMETER; } } break; case OFPIT_WRITE_METADATA: { if ( instructions->write_metadata != NULL ) { free_instruction( instructions->write_metadata ); instructions->write_metadata = NULL; } else { ret = ERROR_INVALID_PARAMETER; } } break; case OFPIT_WRITE_ACTIONS: { if ( instructions->write_actions != NULL ) { free_instruction( instructions->write_actions ); instructions->write_actions = NULL; } else { ret = ERROR_INVALID_PARAMETER; } } break; case OFPIT_APPLY_ACTIONS: { if ( instructions->apply_actions != NULL ) { free_instruction( instructions->apply_actions ); instructions->apply_actions = NULL; } else { ret = ERROR_INVALID_PARAMETER; } } break; case OFPIT_CLEAR_ACTIONS: { if ( instructions->clear_actions != NULL ) { free_instruction( instructions->clear_actions ); instructions->clear_actions = NULL; } else { ret = ERROR_INVALID_PARAMETER; } } break; case OFPIT_METER: { if ( instructions->meter != NULL ) { free_instruction( instructions->meter ); instructions->goto_table = NULL; } else { ret = ERROR_INVALID_PARAMETER; } } break; case OFPIT_EXPERIMENTER: { error( "OFPIT_EXPERIMENTER is not supported." ); ret = ERROR_OFDPE_BAD_INSTRUCTION_UNSUP_INST; } break; default: { error( "Invalid instruction type ( %#x ).", type ); ret = ERROR_OFDPE_BAD_INSTRUCTION_UNKNOWN_INST; } break; } return ret; }