Using Mali Graphics Debugger on a Non-rooted device

Traditionally Mali Graphics Debugger (MGD) works on a rooted device, in this mode an interceptor layer sits between your application and the driver. Your application then calls into this interceptor layer and the interceptor then sends a copy of this data back to the MGD application and passes the call on to the driver.

Rooted and Non-rooted image Mali Graphics Debugger daemon

However, this isn't the only way that MGD can be used. The second option has all of the functionality of the first option with the added benefit that it will also work on a standard Android device with no modification. The trade-off is that you need access to the full source code of the application that you want to profile. This blog explores the second option so you can debug your applications on non-rooted devices.

Prerequisites

  1. Your computer should be setup for Android development, in particular:
    • The Android SDK and NDK should be installed
    • Your system path should include the adb binary.
  2. You should have access to the full source code of your application
  3. Your device must be running at least Android 4.2

Installation

  1. Copy the folder called android-non-root from the target directory in your MGD installation to your application's root folder.

  2. In your target application's Android.mk add the following code.

 include $(LOCAL_PATH)/../android-non-root/MGD.mk
  1. In your projects main activity class you need to add the following:
static 
{
               try 
               {
                               System.loadLibrary("MGD");
                }
                catch( UnsatisfiedLinkError e )
                {
                                // Feel free to remove this log message.
                                Log.i("[ MGD ]", "libMGD.so not loaded.");
                }
}
  1. Recompile the application and install it on your Android device

Running your application

The first thing we need to do is to install the MGDDaemon application on the target. The MGDDaemon application is responsible for sending the information from the interceptor library to the host. Without it the host won't receive any data.

  • cd into the android-non-root directory and run adb install -r MGDDaemon.apk
  • Then run adb forward from a command prompt adb forward tcp:5002 tcp:5002
  • Then launch the MGD Application. This should take you to a list of applications that it has detected have the MGD interceptor library correctly inserted. Before you click on one you need to press the Mali Graphics Debugger daemon switch to on.
Mali Graphics Debugger app list
  • Once pressing the switch you should be able to connect to the process in the MGD host and a new tab for your current trace should be created. At this point you just need to click on your application in the MGD daemon application and the trace should work.

Following these steps you should be able to use MGD on any Mali-based platform. If you have any issues please raise them on the Community and someone will be more than happy to assist you through the process.

Anonymous
Graphics & Multimedia blog