Re: [GXemul-devel] GXemul ARM bkpt patch
Status: Alpha
Brought to you by:
gavare
From: Anders G. <ga...@gm...> - 2008-06-10 17:38:32
|
Tis 2008-06-10 klockan 11:20 +0200 skrev Jiri Svoboda: > Hello, Hi Jiri. (I'm sending this reply to gxemul-devel as well, I hope that is ok with you.) > I am working on debugging support for the HelenOS operating system as > a part of my master thesis. While working on this I ran into GXemul > not supporting the BKPT instruction on ARM (BKPT is defined in ARM > architecture v5 and above). I made a patch against GXemul 0.4.6.3 > adding support for this instruction. It would be cool if you could > integrate it (or something equivalent). ... > /* > * bkpt: Breakpoint instruction. > */ > void arm_instr_bkpt(struct cpu *cpu, struct arm_instr_call *ic) > { > /* Synchronize the program counter first: */ > cpu->pc &= 0xfffff000; > cpu->pc += ic->arg[0]; > arm_exception(cpu, ARM_EXCEPTION_DATA_ABT); > } ... > > /* "bkpt" */ > if ((iword & 0xfff000f0) == 0xe1200070) { > ic->f = arm_instr_bkpt; > ic->arg[0] = addr & 0xfff; > break; > } Thanks for your patch. I'm applying it, with some modifications. The way ARM instructions are implemented in the cpu_arm_instr.c file is with X() and Y() macros; if you look at e.g. the X(swi) macro call (which indeed expands to arm_instr_swi(struct cpu *cpu, struct arm_instr_call *ic)) you will see that it is followed by a Y(swi) as well. That is what enables the 4-bit condition code stuff. Similarly with ic->f = arm_instr_bkpt; which does not take the condition code into account. The cond_instr() macro is used instead. So the end result is: /* * bkpt: Breakpoint instruction. */ X(bkpt) { /* Synchronize the program counter first: */ cpu->pc &= 0xfffff000; cpu->pc += ic->arg[0]; arm_exception(cpu, ARM_EXCEPTION_PREF_ABT); } Y(bkpt) and /* "bkpt", ARMv5 and above */ if ((iword & 0x0ff000f0) == 0x01200070) { ic->arg[0] = addr & 0xfff; ic->f = cond_instr(bkpt); break; } Note: the ARM manual I have here says that the bkpt instruction should behave as a "Prefetch Abort", not "Data Abort". Are you sure that ARM_EXCEPTION_DATA_ABT is the right choice? I'm using ARM_EXCEPTION_PREF_ABT for now (vector 0x000c). (I also added disassembly support in cpu_arm.c.) Hopefully I'll have time to make a 0.4.6.4 release soon; I did another ARM fix a few days ago in the 0.4 branch, which would be good to release. Anders |