4
votes

I am developing an algorithm that uses ARM Neon instructions. I am writing the code using assembler file (.S and no inline asm).

My question is that what is the best way for debugging purpose i.e. viewing registers, memory, etc. Currently, I am using Android NDK to compile and my Android phone to run the algorithm.

1
The best and only way to single step ARM code and see NEON registers is using Visual Studio from Microsoft with a Surface RT (or 2) over WIFI to a Windows PC.BitBank
For simple assembly blocks you might try NEVADA, but you'll have to set up your test conditions manually, rather than testing it in-place within your application.sh1

1 Answers

5
votes

Poor man's debug solutions...

You can use gdb / gdbserver to remotely control execution of applications on an Android phone. I'm not giving full details here because they change all the time but for example you can start with this answer or make a quick search on Internet. Learning to use GDB might seem to have a high steep curve however material on web is exhaustive. You can easily find something to your taste.

Single-stepping an ARM core via software tools is hard that's why ARM ecosystem is full of expensive tools and extra HW equipment.

Trick I use is to insert BRK instructions manually in assembly code. BRK is Self-hosted debug breakpoint. When core sees this instruction it stops and informs OS about situation. OS then notifies debugger about the situation and passes control to it. When debugger gets control you can check contents of registers and probably even make changes to them. Last part of the operation is to make your process continue. Since PC is still at our break point instruction what you must do is to increase PC, set it to instruction after BRK.

Since you mentioned you use .S files instead of .s files you can utilize gcc to do preprocessing / macro work. This way enabling, disabling BRK might become less of an issue.

Big down side of this way of working is turnaround time. If there is a certain point that you want to investigate with gdb you must make sure there is a BRK instruction there and this will probably require another build/push/debug cycle.