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 Android.mk file */

LOCAL_PATH := $(call-mydir)

include $(CLEAR_VARS)

LOCAL_MODULE := Sample

LOCAL_SRC_FILES := test.c assembly.S

LOCAL_ARM_MODE := arm

LOCAL_LD_LIBS := -llog

include $(BUILD SHARED_LIBS)

TARGET_ARCH_ABI == armabi-v7a

 

/* This is my application.mk 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);

return(0);

}

/* my assembly file */

.text

.global assembly

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.

THANKS

10 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Bild des Benutzers Alexander Weggerle (Intel)

Hi,

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: http://www.amccormack.net/getting-started-arm-assembly-for-android/ . 

Thanks,
Alex

Hai

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.

Bild des Benutzers Alexander Weggerle (Intel)

Hi,

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. 

Alex

Hai

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

.data

message:

.asciz "Hello, world.\n"

len = . - message

.text

.global _start

_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.

   

Thanks

Sri

Bild des Benutzers Alexander Weggerle (Intel)

Hi Sri,

have you tried the assembly step button?

Thanks,
Alex

 

Hi Alex :-)

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

Thanks,

Sri

Hi

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

Thanks,

Sri
 

Bild des Benutzers Alexander Weggerle (Intel)

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. 

Thanks,
Alex

Hi Alex,

:-)

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

Anyway Thank you So much for your response.

Thanks,

Sri

Melden Sie sich an, um einen Kommentar zu hinterlassen.