Debugging an ARM assembly (Neon extension)

I am developing an algorithm that uses ARM Neon instructions. I am writing code using an assembler file ( .S

and not inline asm).

My question is what is the best way to debug a target i.e. to view registers, memory, etc. I am currently using Android NDK

to compile and my android phone to run the algorithm.

+3


source to share


1 answer


Poor people debug solutions ...

You can use gdb

/ gdbserver

to remotely control application execution on Android phone. I am not giving details here because they change all the time, but for example you can start with this answer or do a quick web search. Learning how to use GDB may seem like a very steep curve, but the material on the Internet is comprehensive. You can easily find something to your liking.

One-step ARM core using software tools is difficult, so the ARM architecture is full of expensive HW tools and additional hardware.



The trick I'm using is to manually insert instructions BRK

into the assembly code. BRK is a self service breakpoint. When the kernel sees this instruction, it stops and informs the OS about the situation. The OS then notifies the debugger of the situation and transfers control to it. When the debugger gains control, you can inspect the contents of the registers and possibly even make changes to them. The last part of the operation is to continue the process. Since the PC

breakpoint is still in our instruction, you need to increase PC

, set it after the instruction BRK

.

Since you mentioned using .S

files instead of files .S

, you can use gcc

to do preprocessing / macro work. This way of turning it on and off BRK

can become less problematic.

The big part of this way of working is the turnaround time. If there is a specific point that you want to investigate with gdb, you have to make sure there is an instruction BRK

, and this will probably require another build / push / debug loop.

+5


source







All Articles