From: notaz Date: Wed, 22 Jan 2025 23:11:27 +0000 (+0200) Subject: drc: generate diff-able debug output X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14c9acee3b0ac7cc96cb8e9922139a3dce83cce7;p=pcsx_rearmed.git drc: generate diff-able debug output --- diff --git a/libpcsxcore/new_dynarec/assem_arm.c b/libpcsxcore/new_dynarec/assem_arm.c index 5b1d6fdb..b0810462 100644 --- a/libpcsxcore/new_dynarec/assem_arm.c +++ b/libpcsxcore/new_dynarec/assem_arm.c @@ -82,23 +82,24 @@ void invalidate_addr_r9(); void invalidate_addr_r10(); void invalidate_addr_r12(); -const u_int invalidate_addr_reg[16] = { - (int)invalidate_addr_r0, - (int)invalidate_addr_r1, - (int)invalidate_addr_r2, - (int)invalidate_addr_r3, - (int)invalidate_addr_r4, - (int)invalidate_addr_r5, - (int)invalidate_addr_r6, - (int)invalidate_addr_r7, - (int)invalidate_addr_r8, - (int)invalidate_addr_r9, - (int)invalidate_addr_r10, +const void *invalidate_addr_reg[16] = { + invalidate_addr_r0, + invalidate_addr_r1, + invalidate_addr_r2, + invalidate_addr_r3, + invalidate_addr_r4, + invalidate_addr_r5, + invalidate_addr_r6, + invalidate_addr_r7, + invalidate_addr_r8, + invalidate_addr_r9, + invalidate_addr_r10, 0, - (int)invalidate_addr_r12, + invalidate_addr_r12, 0, 0, - 0}; + 0 +}; /* Linker */ @@ -987,7 +988,7 @@ static int can_jump_or_call(const void *a) static void emit_call(const void *a_) { int a = (int)a_; - assem_debug("bl %x (%x+%x)%s\n",a,(int)out,a-(int)out-8,func_name(a_)); + assem_debug("bl %p%s\n", log_addr(a), func_name(a_)); u_int offset=genjmp(a); output_w32(0xeb000000|offset); } @@ -995,7 +996,7 @@ static void emit_call(const void *a_) static void emit_jmp(const void *a_) { int a = (int)a_; - assem_debug("b %x (%x+%x)%s\n",a,(int)out,a-(int)out-8,func_name(a_)); + assem_debug("b %p%s\n", log_addr(a_), func_name(a_)); u_int offset=genjmp(a); output_w32(0xea000000|offset); } @@ -1003,7 +1004,7 @@ static void emit_jmp(const void *a_) static void emit_jne(const void *a_) { int a = (int)a_; - assem_debug("bne %x\n",a); + assem_debug("bne %p\n", log_addr(a_)); u_int offset=genjmp(a); output_w32(0x1a000000|offset); } @@ -1011,7 +1012,7 @@ static void emit_jne(const void *a_) static void emit_jeq(const void *a_) { int a = (int)a_; - assem_debug("beq %x\n",a); + assem_debug("beq %p\n", log_addr(a_)); u_int offset=genjmp(a); output_w32(0x0a000000|offset); } @@ -1019,7 +1020,7 @@ static void emit_jeq(const void *a_) static void emit_js(const void *a_) { int a = (int)a_; - assem_debug("bmi %x\n",a); + assem_debug("bmi %p\n", log_addr(a_)); u_int offset=genjmp(a); output_w32(0x4a000000|offset); } @@ -1027,7 +1028,7 @@ static void emit_js(const void *a_) static void emit_jns(const void *a_) { int a = (int)a_; - assem_debug("bpl %x\n",a); + assem_debug("bpl %p\n", log_addr(a_)); u_int offset=genjmp(a); output_w32(0x5a000000|offset); } @@ -1035,7 +1036,7 @@ static void emit_jns(const void *a_) static void emit_jl(const void *a_) { int a = (int)a_; - assem_debug("blt %x\n",a); + assem_debug("blt %p\n", log_addr(a_)); u_int offset=genjmp(a); output_w32(0xba000000|offset); } @@ -1043,7 +1044,7 @@ static void emit_jl(const void *a_) static void emit_jge(const void *a_) { int a = (int)a_; - assem_debug("bge %x\n",a); + assem_debug("bge %p\n", log_addr(a_)); u_int offset=genjmp(a); output_w32(0xaa000000|offset); } @@ -1051,7 +1052,7 @@ static void emit_jge(const void *a_) static void emit_jo(const void *a_) { int a = (int)a_; - assem_debug("bvs %x\n",a); + assem_debug("bvs %p\n", log_addr(a_)); u_int offset=genjmp(a); output_w32(0x6a000000|offset); } @@ -1059,7 +1060,7 @@ static void emit_jo(const void *a_) static void emit_jno(const void *a_) { int a = (int)a_; - assem_debug("bvc %x\n",a); + assem_debug("bvc %p\n", log_addr(a_)); u_int offset=genjmp(a); output_w32(0x7a000000|offset); } @@ -1067,7 +1068,7 @@ static void emit_jno(const void *a_) static void emit_jc(const void *a_) { int a = (int)a_; - assem_debug("bcs %x\n",a); + assem_debug("bcs %p\n", log_addr(a_)); u_int offset=genjmp(a); output_w32(0x2a000000|offset); } @@ -1075,7 +1076,7 @@ static void emit_jc(const void *a_) static void emit_jcc(const void *a_) { int a = (int)a_; - assem_debug("bcc %x\n",a); + assem_debug("bcc %p\n", log_addr(a_)); u_int offset=genjmp(a); output_w32(0x3a000000|offset); } @@ -1454,9 +1455,10 @@ static void emit_ldrb_indexedsr12_reg(int base, int r, int rt) output_w32(0xe7d00000|rd_rn_rm(rt,base,r)|0x620); } -static void emit_callne(int a) +static void emit_callne(const void *a_) { - assem_debug("blne %x\n",a); + int a = (int)a_; + assem_debug("blne %p\n", log_addr(a_)); u_int offset=genjmp(a); output_w32(0x1b000000|offset); } @@ -1492,10 +1494,11 @@ static attr_unused void emit_addpl_imm(int rs,int imm,int rt) output_w32(0x52800000|rd_rn_rm(rt,rs,0)|armval); } -static void emit_jno_unlikely(int a) +static void emit_jno_unlikely(void *a_) { - //emit_jno(a); - assem_debug("addvc pc,pc,#? (%x)\n",/*a-(int)out-8,*/a); + //emit_jno(a_); + assert(a_ == NULL); + assem_debug("addvc pc,pc,#? (%p)\n", /*a-(int)out-8,*/ log_addr(a_)); output_w32(0x72800000|rd_rn_rm(15,15,0)); } @@ -1665,7 +1668,7 @@ static void mov_loadtype_adj(enum stub_type type,int rs,int rt) static void do_readstub(int n) { - assem_debug("do_readstub %x\n",start+stubs[n].a*4); + assem_debug("do_readstub %p\n", log_addr(start + stubs[n].a*4)); literal_pool(256); set_jump_target(stubs[n].addr, out); enum stub_type type=stubs[n].type; @@ -1836,7 +1839,7 @@ static void inline_readstub(enum stub_type type, int i, u_int addr, static void do_writestub(int n) { - assem_debug("do_writestub %x\n",start+stubs[n].a*4); + assem_debug("do_writestub %p\n", log_addr(start + stubs[n].a*4)); literal_pool(256); set_jump_target(stubs[n].addr, out); enum stub_type type=stubs[n].type; diff --git a/libpcsxcore/new_dynarec/assem_arm64.c b/libpcsxcore/new_dynarec/assem_arm64.c index 5d6a7829..9f2f66af 100644 --- a/libpcsxcore/new_dynarec/assem_arm64.c +++ b/libpcsxcore/new_dynarec/assem_arm64.c @@ -971,7 +971,7 @@ static int can_jump_or_call(const void *a) static void emit_call(const void *a) { intptr_t diff = (u_char *)a - out; - assem_debug("bl %p (%p+%lx)%s\n", a, out, diff, func_name(a)); + assem_debug("bl %p%s\n", log_addr(a), func_name(a)); assert(!(diff & 3)); if (-134217728 <= diff && diff <= 134217727) output_w32(0x94000000 | ((diff >> 2) & 0x03ffffff)); @@ -981,77 +981,77 @@ static void emit_call(const void *a) static void emit_jmp(const void *a) { - assem_debug("b %p (%p+%lx)%s\n", a, out, (u_char *)a - out, func_name(a)); + assem_debug("b %p%s\n", log_addr(a), func_name(a)); u_int offset = genjmp(a); output_w32(0x14000000 | offset); } static void emit_jne(const void *a) { - assem_debug("bne %p\n", a); + assem_debug("bne %p\n", log_addr(a)); u_int offset = genjmpcc(a); output_w32(0x54000000 | (offset << 5) | COND_NE); } static void emit_jeq(const void *a) { - assem_debug("beq %p\n", a); + assem_debug("beq %p\n", log_addr(a)); u_int offset = genjmpcc(a); output_w32(0x54000000 | (offset << 5) | COND_EQ); } static void emit_js(const void *a) { - assem_debug("bmi %p\n", a); + assem_debug("bmi %p\n", log_addr(a)); u_int offset = genjmpcc(a); output_w32(0x54000000 | (offset << 5) | COND_MI); } static void emit_jns(const void *a) { - assem_debug("bpl %p\n", a); + assem_debug("bpl %p\n", log_addr(a)); u_int offset = genjmpcc(a); output_w32(0x54000000 | (offset << 5) | COND_PL); } static void emit_jl(const void *a) { - assem_debug("blt %p\n", a); + assem_debug("blt %p\n", log_addr(a)); u_int offset = genjmpcc(a); output_w32(0x54000000 | (offset << 5) | COND_LT); } static void emit_jge(const void *a) { - assem_debug("bge %p\n", a); + assem_debug("bge %p\n", log_addr(a)); u_int offset = genjmpcc(a); output_w32(0x54000000 | (offset << 5) | COND_GE); } static void emit_jo(const void *a) { - assem_debug("bvs %p\n", a); + assem_debug("bvs %p\n", log_addr(a)); u_int offset = genjmpcc(a); output_w32(0x54000000 | (offset << 5) | COND_VS); } static void emit_jno(const void *a) { - assem_debug("bvc %p\n", a); + assem_debug("bvc %p\n", log_addr(a)); u_int offset = genjmpcc(a); output_w32(0x54000000 | (offset << 5) | COND_VC); } static void emit_jc(const void *a) { - assem_debug("bcs %p\n", a); + assem_debug("bcs %p\n", log_addr(a)); u_int offset = genjmpcc(a); output_w32(0x54000000 | (offset << 5) | COND_CS); } static void emit_cb(u_int isnz, u_int is64, const void *a, u_int r) { - assem_debug("cb%sz %s,%p\n", isnz?"n":"", is64?regname64[r]:regname[r], a); + assem_debug("cb%sz %s,%p\n", isnz?"n":"", is64?regname64[r]:regname[r], log_addr(a)); u_int offset = genjmpcc(a); is64 = is64 ? 0x80000000 : 0; isnz = isnz ? 0x01000000 : 0; diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index 7942cd0c..9b090e4b 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -57,6 +57,7 @@ static Jit g_jit; //#define DISASM //#define ASSEM_PRINT +//#define ASSEM_PRINT_ADDRS //#define REGMAP_PRINT // with DISASM only //#define INV_DEBUG_W //#define STAT_PRINT @@ -66,6 +67,12 @@ static Jit g_jit; #else #define assem_debug(...) #endif +#ifdef ASSEM_PRINT_ADDRS +#define log_addr(a) (a) +#else +// for diff-able output +#define log_addr(a) ((u_long)(a) <= 1024u ? (void *)(a) : (void *)0xadd0l) +#endif //#define inv_debug printf #define inv_debug(...) @@ -9130,7 +9137,7 @@ static int noinline new_recompile_block(u_int addr) u_int state_rflags = 0; int i; - assem_debug("NOTCOMPILED: addr = %x -> %p\n", addr, out); + assem_debug("NOTCOMPILED: addr = %x -> %p\n", addr, log_addr(out)); if (addr & 3) { if (addr != hack_addr) { @@ -9455,7 +9462,8 @@ static int noinline new_recompile_block(u_int addr) /* Pass 9 - Linker */ for(i=0;i %8x\n",link_addr[i].addr,link_addr[i].target); + assem_debug("link: %p -> %08x\n", + log_addr(link_addr[i].addr), link_addr[i].target); literal_pool(64); if (!link_addr[i].internal) { @@ -9510,7 +9518,7 @@ static int noinline new_recompile_block(u_int addr) { if ((i == 0 || dops[i].bt) && instr_addr[i]) { - assem_debug("%p (%d) <- %8x\n", instr_addr[i], i, start + i*4); + assem_debug("%p (%d) <- %8x\n", log_addr(instr_addr[i]), i, start + i*4); u_int vaddr = start + i*4; literal_pool(256);