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 17th March 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 trying to debug my game on the emulator, I did replace the gdbserver from the ARM extras folder, but every time I press the debug button, my eclipse IDE does a recompile and replaces every file on my folder, so the the gdbserver from DS-5 is replaced.

    Also if I manage to replace again the gdbserver before the game launches then the correct debugger is launched but as you can see from my screenshot the game stops a lot sooner than my game's entry point/

    http://dl.dropbox.co...bug_capture.png

    I've placed a breakpoint in my

    void android_main(android_app* pApplication)

    but it never fires
  • Note: This was originally posted on 17th December 2011 at http://forums.arm.com

    Finally I've got DS-5 Debugger 'working' with SGS2 on GB (2.3). But it's a little painful.
    EDIT: Debugging on SGS2 with ICS (4.0 LPQ) works fine, at least! No need to use below manual.

    First of all, option in DS-5 named "Download and debug an Android application" wasn't work as expected.
    I'll describe it more later, after I do more tests with it.

    To make debugging work on SGS2 (and Windows) I need to:
    0. Create DS-5 Debugger profile as in tutorial, but change "Debug operation" to "Attach to a running Android application"
    1. Build and Install apk
    You can use "Android application" debugging profile. It will:
    - build .apk
    - install it on device
    - run it
    Of course you need build your .so first if you haven't for example added ndk-build to your
    project "Builders" (which is really easy as of NDK v7 - no need to use cygwin).
    2. Run activity on device(if it wasn't started in point 1), and then close it by 'back button'
    As I know, process of this activity will be still running (but activity thread/application(?) will be closed).
    Closing activity is very important. I couldn't get debbuging work without this point!.
    3. Start debugging using your DS-5 debug profile.
    You shouldn't get any errors, and in "Debug Control" there should be break on thread waiting on "epoll_wait".
    Debugger should attach to your process (but activity isn't running) and pause it.
    4. Set breakpoint(s) in your C/C++ code. (optional)
    5. Press "Run/Continue" (green button in "Debug Control").
    It will not run your activity! It will just continue run of your paused android process (in point 3).
    6. Then start your activity on device. You should see breakpoint hit (if you set it in point 4).
    7. You can also add breakpoints later, but first you need to pause application.
    In "Debug Control" window press yellow II button, and then you can
    add/remove breakpoints, and next press again "Run/Continue" button.

    But this doesn't work always (but most time do).
    Sometimes I get errors at point 3 or at point 6 (gdbserver: "[1]   Segmentation fault      run-as com.examp...")
    Then you need to try again from point 2. (run and close activity...).

    Problem with this configuration is that, if your application crashing at start,
    you won't be able to debug it :(
    You need to successfully run and close activity (process of activity must remain running).
    I think that this one could be workarounded by changes in code (to run your main code at some condition/variable,
    which will be chnaged manually on debugging session at second activity run).

    I would really thanks to DS-5 team and @nicksydney. Good job!
    It's first debbuger (and tutorial for it) that worked for me!

    PS. Really nice view to see debugging working on device after 6+ months of
    using of LOGI/__android_log_print and analysing/filtering LogCat :)
    But I think that it cannot replace my VisualStudio+Mali OpenGL ES 2.0 emulator setup,
    at least for now, but I will definitly help when testing code/application on real device!
  • Note: This was originally posted on 19th December 2011 at http://forums.arm.com


    did u add "LOCAL_CFLAGS += -g" in your jni/Android.mk ?

    No, I haven't added it, as (I think) it's not needed, as in my AndroidManifest.xml I have android:debuggable="true". I've also tested now with "LOCAL_CFLAGS += -g", and no difference.
    Most time when I use "Download and debug an Android application" I do get error "[1]   Segmentation fault      run-as com.examp..." (it's as I think form gdbserver)

    But debugging works on SGS2 now with some "special" taken actions (as in my post from 17 December 2011 - 03:26 PM).
  • Note: This was originally posted on 17th January 2012 at http://forums.arm.com

    Hi! First of all, thanks for your work. That is the first debugger that somehow works. I tried it on android ndk sample projects - it went fine. But on my own projects I have encountered problems.
    I do everything like in tutorial, but execution of the app stops, I hit Run/Continue button, but only get message:

    wait
    continue
    Stopped due to signal 11: SIGSEGV (Invalid memory segment access)
    Execution stopped at: 0x80CB1314
    In thread 1 (OS thread id 1793)
    0x80CB1314   LDR      r0,[r0,#0x38]

    Any hints?
  • Note: This was originally posted on 21st January 2012 at http://forums.arm.com

    What is your device you are testing on?