This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM DS-5 Tutorial For Android

Note: This was originally posted on 5th December 2011 at http://forums.arm.com

Hi,

I've created a step by step blog post for using DS-5 as debugger tool for Android http://kernel.ozandroid.info/?p=83

Hope this is useful for others.

Cheers
  • Note: This was originally posted on 5th December 2011 at http://forums.arm.com

    Great job Nanik!
    Your step-by-step guide with pictures should hopefully make it easy for everyone.
    Kindly, Alban

  • Note: This was originally posted on 8th December 2011 at http://forums.arm.com

    Thanks you very much!!!
  • Note: This was originally posted on 10th December 2011 at http://forums.arm.com

    Thanks for great tutorials, but I have a problems with it...

    I've followed your tutorial closely, but I'm not able to get it works correctly (not sure where I could make mistake). I've tried it two times, but still no luck :(
    I've tried with HelloNeon example, and also with NativeActivity (which I'm most interested to get debugging work - I don't want to touch any Java code)

    My system is Win7 x64 Pro, and device is Samsung Galaxy S2 (GT-I9100) running 2.3.5 (I91000XXKI4). Eclipse 3.7.1 (32-bit). I've replaced gdbserver in NDK with one found in ARM Extras (as in tutorial), and I can confirm that my 'samples\native-activity\libs\armeabi\gdbserver' is correct one.
    Also I have tried to rebuild NDK app and .apk, after setting debuggable="true" (tutorial tells to run ndk-build first, and then set debugabble="true", but AFIK debugging symbols are generated only if debuggable="tru

    What else information could be useful to diagnose this case?

    Example log from Commands window:

    Connected to unknown platform
    Execution stopped at: 0xAFD0C59C
    0xAFD0C59C   POP      {r4,r7}
    file "D:\Dev\Android\android-ndk-r7\samples\native-activity\bin\app_process"
    WARNING(IMG53): app_process has no line debug information
    add-symbol-file "D:\Dev\Android\android-ndk-r7\samples\native-activity\bin\libc.so"
    Loading library symbols: libc.so
    WARNING(IMG53): libc.so has no line debug information
    add-symbol-file "D:\Dev\Android\android-ndk-r7\samples\native-activity\obj\local\armeabi\libnative-activity.so"
    Loading library symbols: libnative-activity.so
    cd "D:\Dev\Android\workspace"
    Working directory "D:\Dev\Android\workspace"
    directory "D:\Dev\Android\android-ndk-r7\samples\native-activity"
    Source directories searched: D:\Dev\Android\android-ndk-r7\samples\native-activity;$cdir;$cwd;$idir
    break -p "D:/Dev/Android/android-ndk-r7/samples/native-activity/jni/main.c":270
    Breakpoint 1 at 0x81302AD8
        on file main.c, line 270
    run
    Starting target with image D:\Dev\Android\android-ndk-r7\samples\native-activity\bin\app_process
    Running from entry point
    ERROR(LUX42): Stopped due to signal 5: SIGTRAP (Trace trap (used by debugger))
    Application terminated due to signal 5


    Sometimes in Commands I get:
    Connected to unknown platform
    Execution stopped at: 0xAFD0C59C
    0xAFD0C59C   POP      {r4,r7}
    file "D:\Dev\Android\android-ndk-r7\samples\native-activity\bin\app_process"
    WARNING(IMG53): app_process has no line debug information
    add-symbol-file "D:\Dev\Android\android-ndk-r7\samples\native-activity\bin\libc.so"
    Loading library symbols: libc.so
    WARNING(IMG53): libc.so has no line debug information
    add-symbol-file "D:\Dev\Android\android-ndk-r7\samples\native-activity\obj\local\armeabi\libnative-activity.so"
    Loading library symbols: libnative-activity.so
    cd "D:\Dev\Android\workspace"
    Working directory "D:\Dev\Android\workspace"
    directory "D:\Dev\Android\android-ndk-r7\samples\native-activity"
    Source directories searched: D:\Dev\Android\android-ndk-r7\samples\native-activity;$cdir;$cwd;$idir
    break -d -p "D:\Dev\Android\android-ndk-r7\samples\native-activity\jni\main.c":270
    Breakpoint 1 at 0x81302AD8
        on file main.c, line 270
    condition 1
    break-script 1 ""
    ignore 1 0
    break-stop-on-threads 1
    unsilence 1
    Breakpoint 1 unsilenced
    break -d -p "D:\Dev\Android\android-ndk-r7\samples\native-activity\jni\main.c":237
    Breakpoint 2 at 0x81302A4A
        on file main.c, line 237
    condition 2
    break-script 2 ""
    ignore 2 0
    break-stop-on-threads 2
    unsilence 2
    Breakpoint 2 unsilenced
    enable 2
    Breakpoint 2 enabled
    enable 1
    Breakpoint 1 enabled
    disable 1
    Breakpoint 1 disabled
    enable 1
    Breakpoint 1 enabled
    run
    Starting target with image D:\Dev\Android\android-ndk-r7\samples\native-activity\bin\app_process
    Running from entry point
    Stopped due to signal 19: SIGSTOP (Stop executing (can't be caught or ignored))
    Execution stopped at: 0xAFD0C59C
    0xAFD0C59C   POP      {r4,r7}
    wait
    continue


    Log from App Console window:

    Attached; pid = 10615
    Listening on sockaddr socket debug-socket
    libthread_db:td_ta_new: Probing system for platform bug.
    libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/10848/task/10848/status
    libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/10615/task/10615/status
    libthread_db:_get_task_permitted_caps: Found CapPerm of 2097152 in /proc/10615/task/10616/status
    libthread_db:td_ta_new: AAAAAH, Can't debug threads!

    Child terminated with signal = 0x5 (SIGTRAP)


    Very often I get errors like:
    Failed gdbserver configuration:
    Timeout. PID not found!
    Failed gdbserver configuration:
    Timeout. PID not found!


    Is there anyone who can tell me what's wrong? I can add, that I'm trying to get NDK debugging for about half year(!) on SGS2, but with no luck :( I've tried several tutorials (with Sequoyah, Tegra Android Dev, etc.) - non of them worked for me. Now I've tried ARM DS-5, but again - not working.

    Is it something wrong with SGS2 or it's just me?
  • Note: This was originally posted on 11th December 2011 at http://forums.arm.com

    Hi Krystian,

    I don't have SGS2 with me so it's bit hard to replicate your problem, but the normal steps that I do before debugging the app inside a real device is to use the simulator and see whether you are able to do that, if you are able to do that this means that there could be some device specific configuration or settings that is needed.

    I'm using Nexus S and able to do debugging both Java and using NDK without any problem, so maybe there is something specific to SGS2, are there any other devices that you can try with for comparison.

    Sorry can't help too much with your problem.
  • Note: This was originally posted on 12th December 2011 at http://forums.arm.com

    Absolutely   nicksydney..I am also a user of Nexus and I am still not getting any issues while debugging on Java. I haven't use NDK yet and that's why I have not proper information on that. And I don't think it should be create any issues while debugging on Java.
  • Note: This was originally posted on 20th March 2012 at http://forums.arm.com

    You could try to replace gdbserver inside NDK (like ...\android-ndk\toolchains\arm-linux-androideabi-4.4.3\prebuilt)

    Does LogCat says anything useful? Maybe you are trying to use for example OpenGL ES 2.0 in emulator (which isn't supported)?
    Also, hitting breakpoint at begining of android_main is a little bit tricky...


    --

    Just for note, debugging on SGS2 with official ICS (4.0) works fine now (or at least same as on other devices)!
  • Note: This was originally posted on 10th August 2012 at http://forums.arm.com

    Hello Krystian.

    I'm having exactly the same problem you are describing with DS-5, on a Samsung Galaxy Ace and  a Samsung Galaxy Y Phone.
    Your detailed steps of "Attaching to a running Android application" are working fine - thank you very much for that -,  but I'm curious of your Edit, where you are using something called ICS.  Could you elaborate a bit on this workaround you found?

    Thank you very much in Advance!

    Gerardo
  • Note: This was originally posted on 11th August 2012 at http://forums.arm.com

    ICS is an "Ice Cream Sandwich" - Android 4.0.
    Originally on SGSII there was GB (Gingerbread - Android 2.3), and there was problems with debugging, but after Samsung updated software on SGSII to ICS (4.0), everything works much better.
  • Note: This was originally posted on 18th December 2012 at http://forums.arm.com

    C[size="4"]ould ARMCC in DS-5 pro be used to compile the native code of Android NDK? If could, then how to do?
    We  try to use ARMCC to compile NEON intrincis in the native code of  Android NDK, but found none guideline or articles, any sugessions?  thanks a lot... [/size]
  • Note: This was originally posted on 18th December 2012 at http://forums.arm.com

    [size="4"]It is [/size][size="4"][size="4"][size="4"] one of Hot topics  [size="4"]about [/size][/size]Debugging native code of Android NDK is, but it is igored about Compiling native code of Android NDK with ARMCC .[/size]
    [/size]
  • Note: This was originally posted on 5th February 2012 at http://forums.arm.com

    Hi Krsystian,

    Thank you for your Galaxy S2 instructions, I am also using the S2 and I was wondeirng how you solved this error:

    ERROR(LUX42): Stopped due to signal 5: SIGTRAP (Trace trap (used by debugger))
    Application terminated due to signal 5

    I have read that this was a problem related to only being able to debug on the main thread but you aren't having this problem?  I get this error whenever I hit a breakpoint.

    Thanks,
    Barney

  • Note: This was originally posted on 6th February 2012 at http://forums.arm.com

    Yes, I had similar or even same crashes. I don't see any problems with debugging non "main" threads (even if log says "AAAAAH, Can't debug threads!" ;) ) . I'm using NativeActivity, so my NDK/C++ code does not  run on main thread but on it's own thread.

    Did you followed steps exactly as in my post? Most important thing before each ndk debugging session on SGS2 is point "two" - run activity, and close it, but do NOT terminate it! Then you can start debugging by "Attach to a running Android application" (as in this "SGS2 NDK debug tutorial").

    Write what steps make you trouble, so I help you.
  • Note: This was originally posted on 6th February 2012 at http://forums.arm.com

    Hi Krystian,

    Sorry I should have said,  I get this error when my code hits a breakpoint.  I did follow your steps above, including step 2 - it is the only reason it works at all, thank you!  I will try and post more information when I get home later.

    I am running Android 2.3.3 so maybe upgrading to 2.3.5+ will help.

    Thanks,
    Barney
  • Note: This was originally posted on 6th February 2012 at http://forums.arm.com

    Did you replaced gdbserv from ARM Extras "menu" (as in link from first post of this topic)?

    I'm using 2.3.5 (from around 09.2011). "Real" GDB Server comes from device "manufacturer", AFIK this gdbserv is only some kind of bridge between real GDB server and application. So it might be it (new version of Android in device --> possible new/fixed version of GDB Server).
    Also you might try to update Kies as it comes with new USB drivers that allows USB debugging.


    If above won't help, you might try to switch USB cable to other USB port .
    Today at work I saw problems with debugging Java/Dalvik code (or even problems with adb connection), when 1,8m USB cable was plugged into back PC USB ports (it might be some USB3.0 ports). When cable was plugged into front-PC USB ports, then there was no problems at all.
    When I plug SGS2 to combo USB+eSata+"Charge" port in my laptop, it connects/disconnects device every 1-2s. I need use only 'regular' USB ports.
  • Note: This was originally posted on 14th February 2012 at http://forums.arm.com

    Hi Krystian,

    I had not replaced gdbserv from the ARM Extras menu.  I have now though and still get the problem.  I will try your other suggestions and let you know how I get on.  Thanks for all your help!

    Barney