The Architecture for the Digital World®

DS-5 Community Edition Android Debug


Benefits of using DS-5 Community Edition for Android Native App Debug

The ARM® DS-5™ Community Edition is an Eclipse plug-in that enables you to easily connect to Android targets for debug of NDK-generated code. It ships a customized version of gdbserver to be deployed with your debuggable application package (.apk), giving you more control over multi-threaded applications and processor registers such as the NEON™ ones. Better still, the DS-5 Debugger perspective eliminates the need for you to edit and run scripts from the command line, and also packs lots of productivity features that will help you create efficient and bug-free C/C++ code for Android apps.

Prerequisites

To debug an Android package containing native C/C++ code you need to install DS-5 CE plug-ins and its prerequisite packages. If you haven't done so, see installation instructions.

If you are planning to debug your native code on an end user Android device, be aware that some products based on version 2.2 (Froyo) haven't got this feature enabled.

Debug Setup


Replacing NDK's gdbserver

To use the DS-5 Debugger to debug native code, update the version of gdbserver in the Android NDK ...\toolchains\...\prebuilt directory with the version of gdbserver provided by DS-5. You can locate this file by selecting Help → ARM Extras... from the main menu. Ensure that you rename it to gdbserver. The gdbserver provided in DS-5 is based on a newer version of GNU's gdbserver and provides additional multi-threading capabilities, access to ARM NEON registers (when available), and improved stability.

Creating an Android Virtual Device to debug the app

If you haven't done so, configure your Android ADT plug-in to pick up your Android SDK installation. To do that, follow these steps:

  1. Select Window → Preferences → Android and click on Browse... then set the location of the SDK.
  2. Open the Android SDK and AVD Manager dialog box by selecting Window → Android SDK and AVD Manager.
  3. Expand the Available packages group and add SDK platforms as required. For example, Android SDK Platform Android 2.3.
  4. Create a new Android Virtual Device (AVD).
  5. Now that you have installed the Android SDK, you need to add the location of adb to our path to allow the tools to find the binary to communicate with the virtual device.
    1. On Windows: Open the System Properties from your Control Panel select Advanced and add the path to the “SDK Tools/platform-tools” directory to your Path variable in the System Variables dialog.
    2. On Linux: In the shell add the Path by executing something similar to “export PATH=$PATH:<path to SDK Folder/platform-tools> Now launch eclipse. On Linux you need to launch it from the same shell you used in step 4.

Using an Android device to debug the app

  1. Set up your device to allow installation of non-Market applications. On the device, go to Settings > Applications and enable "unknown sources" (on an Android 4.0 device, the setting is located in Settings > Security).
  2. Turn on USB debug. On the device, go to Settings > Applications > Development and enable USB debugging (on an Android 4.0 device, the setting is located in Settings > Developer options).
  3. Set up your system to detect your device. On Windows, you need to install a USB driver for adb. Find the correct driver for your device on: http://developer.android.com/sdk/oem-usb.html. For Linux hosts, check the correct procedure on the Android developer website.
  4. Now that you have installed the Android SDK, you need to add the location of adb to our path to allow the tools to find the binary to communicate with the device.
    1. On Windows: Open the System Properties from your Control Panel select Advanced and add the path to the “SDK Tools/platform-tools” directory to your Path variable in the System Variables dialog.
    2. On Linux: In the shell add the Path by executing something similar to “export PATH=$PATH:<path to SDK Folder/platform-tools> Now launch eclipse. On Linux you need to launch it from the same shell you used in step 4.

Building Your App for Debug

  1. Build the native code inside Android application using the ndk build scripts. For example in Cygwin from the NDK root directory run “ndk-build –C samples/hello-neon” to build the hello-neon example. Use NDK_DEBUG=1 as a parameter to ndk-build to ensure that the app is built with native debugging enabled.
    1. With Android NDK r7 you can also run the same command on Windows command shell (i.e. “ndk-build.cmd –C samples/hello-neon”)
  2. Now that the native libraries are built you need to build the Android application from Eclipse. Create a new project in Eclipse by selecting File → New → Android → Android Project. Import your project code into Eclipse.
  3. Open the AndroidManifest.xml file to enable the application to be Debuggable.  Click on the Application tab and select the Debuggable flag as True. Save the changes and close the file. tab.
  4. Build your Android project.

Installing the App and Connecting the DS-5 Debugger

  1. Go to the DS-5 Debug perspective. Window → Open Perspective → Other → DS-5 Debug.
  2. Create a new debug configuration from Run → Debug Configurations → DS-5 Debugger → Right click → New.
  3. In the connection tab of the new configuration, enter a name for your project and select a device to connect to from the Connections drop down box.
  4. In the Files tab select your project directory and the .apk you want to debug. The Process and Activity boxes should auto complete. The Android apk will be located inside the bin folder of your project.dsds.
  5. Next select the shared library containing symbols which you want to debug. For a arm v5 target the location is normally <project_folder>/obj/local/armeabi, for a v7 arm target the location is <project_folder>/obj/local/armeabi-v7.
  6. Select Apply and Debug to debug your application.
  7. The debugger will install your application, attach gdbserver to the native process of the application and connect DS-5 Debugger so that you can debug your application.
Important Information for ds.arm.com

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

ds.arm.com uses three types of cookies: (1) those that enable the site to function and perform as required; (2) analytical cookies which anonymously track visitors while using this site; and (3) cookies which track visitors while using this site and then link to that visitor’s account once they log in or register.

If you are not happy with this use of these cookies please review our Cookie Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.