How to debug assembly by using ANDROID-ndk-r9d in eclipse adt with linux-64bit-OS??

How to debug assembly by using ANDROID-ndk-r9d in eclipse adt with linux-64bit-OS??

Hai... Iam new to android-ndk.

Iam trying to build pure c code by using android-ndk finally its working.

Now Iam trying to call assembly file from that c code but Iam getting errors.

Iam using Linux_GCC

/* This is my file */

LOCAL_PATH := $(call-mydir)

include $(CLEAR_VARS)


LOCAL_SRC_FILES := test.c assembly.S


LOCAL_LD_LIBS := -llog


TARGET_ARCH_ABI == armabi-v7a


/* This is my file */

APP_OPTIM := debug

APP_ABI := armeabi armeabi-v7a x86

APP_STL := gnustl_static


/* This is my c file */

extern int assembly(int a);

int main(void)


int a = 5, b = 10, c, d;

c = a * b;

d = assembly(c);

printf(" d = %d", d);



/* my assembly file */


.global assembly


    stmfd sp!, {r4-r12, lr}

   add r4, r0, r1

   mul r3, r0, r2

   ldmfd sp!, {r4-r12, PC}

In order to build assembly I added following

Project --> Properties--> c/c++ build --> settings

GCC Assembler: added -arch i386 -g after as

GCC C Compiler: added -m32 after gcc

GCC C Linker: added -m32 after gcc

in debug configuration settings i have  select c/c++ application as default/Sample

while building project it is showig error as Sample/default/Sample is not found.

I reffered few sites in those i observed they select c/c++ application as project/obj/local/armeabi/app_process

but i didn't found app_process in that path in my project.

Hope somebody will help me regarding this.


11 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


there are some fundamental issues in your code that you should fix first:

  1. You try to make a console application (main method in c) but compiling it as shared library with the ndk (BUILD SHARED_LIBS). 
  2. Compiling arm assembly code (stmfd) for x86 targets (APP_ABI := x86)  will not work. You need to have different assembly code for each architecture you want to support
  3. Configuring the Compiler and Assembler in Eclipse doesn't have any effect on the ndk build environment. 

I would recommend you to start on the command line with a small example and later move it into Eclipse or at least do the builds at the beginning from command line and use Eclipse just as an editor. A good tutorial how to develop in assembly with the NDK is here: . 



Thanks for your answer :-)

I tried both arm assembly & intel assembly as you suggested.

But, while trying arm assembly showing errors like "unknown instruction" in each line. Intel assembly does n't showing any error but while debuging it does n't entering into assembly function. why it is happening? either arm or x86 either of these have to support na?

my gcc version 4.6.2.

If you know, why it is happening

will you please give response.


the complete build log would help to understand the issue. 

If you getting unknown instructions it's because you try to compile x86 assembly code with the arm compiler or arm assembly code with the x86 compiler. 

Have you looked into the link I provided last time? I would recommend to take the code from there as a base and change it to your needs. 



I have taken the code which is suggested by you only. while compiling x-86 code doesn't showing any error. So hope x86 is supporting in my system. but while debugging it doesn't entering into the assembly file.

/* assembly file */

      .syntax unified



.asciz "Hello, world.\n"

len = . - message


.global _start


        mov     r0, $1

        ldr     r1, =message

        ldr     r2, =len

        mov     r7, $4

        swi     $0

        mov     r0, $0

        mov     r7, $1

        swi     $0  


These are screen shorts during debug process.




Hi Sri,

have you tried the assembly step button?



Hi Alex :-)

No, I did n't try it till now.




it is showing error as "failed to read image from memory"



Hi Sri,

Don't know how to help you here further.

Easiest way to proceed might be to debug your assembly on the host OS and later debug the C/C++ code on the Android target. 


Hi Alex,


Now Iam trying to debug assembly in my host OS only.

Anyway Thank you So much for your response.



Hi Guys

I love to try to reproduce this tutorial. I have two questions please. 1- Is there an online tutorial I can follow to do this? 2- What IDE are you using to do this? Is it Eclipse? 


Leave a Comment

Please sign in to add a comment. Not a member? Join today