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
Parents
  • 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!
Reply
  • 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!
Children
No data