提交 11429b35 编写于 作者: Z Zihao Yu

cpu,exec,special: refactor invalid opcode messages

上级 6f291525
......@@ -47,6 +47,8 @@ static inline void update_pc(void) {
else { cpu.pc = decinfo.seq_pc; }
}
void display_inv_msg(vaddr_t pc);
#ifdef DEBUG
#define print_asm(...) Assert(snprintf(decinfo.assembly, 80, __VA_ARGS__) < 80, "buffer overflow!")
#else
......
#include "common.h"
void display_inv_msg(vaddr_t pc) {
extern char logo [];
printf("There are two cases which will trigger this unexpected exception:\n"
"1. The instruction at PC = 0x%08x is not implemented.\n"
"2. Something is implemented incorrectly.\n", pc);
printf("Find this PC(0x%08x) in the disassembling result to distinguish which case it is.\n\n", pc);
printf("\33[1;31mIf it is the first case, see\n%s\nfor more details.\n\nIf it is the second case, remember:\n"
"* The machine is always right!\n"
"* Every line of untested code is always wrong!\33[0m\n\n", logo);
}
......@@ -5,22 +5,14 @@ make_EHelper(inv) {
/* invalid opcode */
uint32_t instr[2];
vaddr_t ori_pc = cpu.pc;
*pc = ori_pc;
*pc = cpu.pc;
instr[0] = instr_fetch(pc, 4);
instr[1] = instr_fetch(pc, 4);
printf("invalid opcode(PC = 0x%08x): %08x %08x ...\n\n",
cpu.pc, instr[0], instr[1]);
extern char logo [];
printf("There are two cases which will trigger this unexpected exception:\n"
"1. The instruction at PC = 0x%08x is not implemented.\n"
"2. Something is implemented incorrectly.\n", ori_pc);
printf("Find this PC(0x%08x) in the disassembling result to distinguish which case it is.\n\n", ori_pc);
printf("\33[1;31mIf it is the first case, see\n%s\nfor more details.\n\nIf it is the second case, remember:\n"
"* The machine is always right!\n"
"* Every line of untested code is always wrong!\33[0m\n\n", logo);
display_inv_msg(cpu.pc);
rtl_exit(NEMU_ABORT, cpu.pc, -1);
......
......@@ -5,22 +5,14 @@ make_EHelper(inv) {
/* invalid opcode */
uint32_t instr[2];
vaddr_t ori_pc = cpu.pc;
*pc = ori_pc;
*pc = cpu.pc;
instr[0] = instr_fetch(pc, 4);
instr[1] = instr_fetch(pc, 4);
printf("invalid opcode(PC = 0x%08x): %08x %08x ...\n\n",
cpu.pc, instr[0], instr[1]);
extern char logo [];
printf("There are two cases which will trigger this unexpected exception:\n"
"1. The instruction at PC = 0x%08x is not implemented.\n"
"2. Something is implemented incorrectly.\n", ori_pc);
printf("Find this PC(0x%08x) in the disassembling result to distinguish which case it is.\n\n", ori_pc);
printf("\33[1;31mIf it is the first case, see\n%s\nfor more details.\n\nIf it is the second case, remember:\n"
"* The machine is always right!\n"
"* Every line of untested code is always wrong!\33[0m\n\n", logo);
display_inv_msg(cpu.pc);
rtl_exit(NEMU_ABORT, cpu.pc, -1);
......
......@@ -9,23 +9,15 @@ make_EHelper(inv) {
/* invalid opcode */
uint32_t temp[2];
vaddr_t ori_pc = cpu.pc;
*pc = ori_pc;
*pc = cpu.pc;
temp[0] = instr_fetch(pc, 4);
temp[1] = instr_fetch(pc, 4);
uint8_t *p = (void *)temp;
printf("invalid opcode(PC = 0x%08x): %02x %02x %02x %02x %02x %02x %02x %02x ...\n\n",
ori_pc, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
extern char logo [];
printf("There are two cases which will trigger this unexpected exception:\n"
"1. The instruction at PC = 0x%08x is not implemented.\n"
"2. Something is implemented incorrectly.\n", ori_pc);
printf("Find this PC(0x%08x) in the disassembling result to distinguish which case it is.\n\n", ori_pc);
printf("\33[1;31mIf it is the first case, see\n%s\nfor more details.\n\nIf it is the second case, remember:\n"
"* The machine is always right!\n"
"* Every line of untested code is always wrong!\33[0m\n\n", logo);
cpu.pc, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
display_inv_msg(cpu.pc);
rtl_exit(NEMU_ABORT, cpu.pc, -1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册