Solving SIGILL in Android Emulator Debugging for Thumb Mode

In my previous article, I’ve indicated that there are still more SIGILL even though it is already resolved for pure arm instructions. The gdb client still has some shortcomings on handling the arm thumb instructions.

Suppose I’ve compile the hello program in the thumb mode. The SIGILL still crops up, when I try to use the program as it is without the aid of symbol file:

tb01

So, the debugger client can’t be use for debugging non symbol application with the thumb instruction in it. Close examination of the above problem reveals that determination whether current given program counter is in thumb or arm mode is inside arm_pc_is_thumb (arm-tdep.c) function. It fails to detect whether code at given program counter (pc) is in fact a thumb instruction.

More detailed analysis reveals that it tries to infer the thumb mode state by checking the cpsr register through frame_unwind_register_value (frame.c) function, which returns unpredictable cpsr state, especially when the transition is from either the two modes.

To remedy this situation, you can set the fallback-mode to either thumb or arm, depending on the current breakpoint location and its code characteristics. In other words, the information about the modes is determined by the user.

tb02

Don’t forget to set the appropriate mode when you eventually arrive back at arm instruction.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: