I have a huge source code that works on PowerPC. I need to port it to ARM. But, ARM generates h/w exception on unaligned memory accesses. So, I want to find all the possible instances where the unaligned memory access exception could occur. I've considered the following options.
My questions are,
It depends on your POWERPC processor. High end server processors like POWER8 will almost never generate alignment exceptions. That being said, often there is a HID SPR bit to make alignment exceptions occur more often. Either way, under Linux, the kernel will handle them and the user won't see it, other than a performance loss. You can set the prctl(PR_UNALIGN_SIGBUS) and this will make the kernel generate a SIGBUS, rather than handle them.
In linux with perf events you can use the alignment-faults events. eg "perf stat -e alignment-faults testcase". Also if you turn on CONFIG_PPC_EMULATED_STATS you will get a debugfs entry called "emulated_instructions" which has a entry for unaligned accesses.