Re: [hatari-devel] Solved: Pure debugger, illegal opcodes, exceptions

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On keskiviikko 10 lokakuu 2012, Uwe Seimet wrote:
> I found what's wrong: It's the way the debug message is generated. This
> is from newcpu.c line 2529:
> 
>        if (warned < 20) {
>                 write_log ("Illegal instruction: %04x at %08X -> %08X\n",
> opcode, pc, get_long (regs.vbr + 0x10));
> 
> get_long() results in a bus error, i.e. write_log causes the actual
> crash by calling get_long(). After removing this line PD starts without
> any crash.

get_long() is:
---
static inline uae_u32 get_long(uaecptr addr)
{
    return longget(addr);
}
---

Which is mapped to:
---
#ifndef NO_INLINE_MEMORY_ACCESS
#define longget(addr) (call_mem_get_func(get_mem_bank(addr).lget, addr))
....
#else
....
extern uae_u32 longget(uaecptr addr);
....
#endif

#define longget(addr) (call_mem_get_func(get_mem_bank(addr).lget, addr))
---

(Why it's defined twice?)

I.e. it goes through memory bank accessors which check for
emulated code access rights and throw related exceptions
when necessary.

IMHO debug print statements should use memory accessors that
work outside of emulation[1] i.e. check just that the memory area
is valid for Hatari, not to the emulated Atari.


What you pointed out isn't even the only debug statement with this issue:
$ grep write_log src/cpu/*.c|grep get_
src/cpu/newcpu.c:            write_log ("Exception %d (%x) at %x -> %x!\n", 
nr, oldpc, currpc, get_long (4 * nr));
src/cpu/newcpu.c:            write_log ("Exception %d (%x) at %x -> %x!\n", 
nr, oldpc, currpc, get_long (regs.vbr + 4*nr));
src/cpu/newcpu.c:                    write_log ("Exception %d (%x) at %x -> 
%x!\n", nr, oldpc, currpc, x_get_long (regs.vbr + 4*nr));
src/cpu/newcpu.c:            write_log ("Exception %d (%x) at %x -> %x!\n", 
nr, oldpc, currpc, x_get_long (regs.vbr + 4*nr));
src/cpu/newcpu.c:            write_log ("Illegal instruction: %04x at %08X -
> %08X\n", opcode, pc, get_long (regs.vbr + 0x10));
src/cpu/newcpu.c:    //write_log ("ACTUAL=%d ERROR=%d\n", get_long (request 
+ 32), get_byte (request + 31));



Btw. I also wonder why non-debug stuff in newcpu uses get_long() instead
of x_get_long() which would seems to be aliasing the correct(?) memory
lookup function in newcpu.c...?


	- Eero

[1] In this case maybe STMemory_ReadLong() which is e.g. used
    by the gemdos HD emulation.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/