The ARM® Development Studio 5 (DS-5) Community Edition (CE) has been extended to support the community of ARM Embedded Linux users, and it now works on Apple Mac hosts too!  DS-5 Community Edition is available as a free download from ARM, and enables you to create, compile, debug and profile Linux applications quickly and easily, whilst retaining its debug and profiling capabilities for Android native application developers too.

 

 

 
DS-5 Community Edition running on Apple MacBook, connected to BeagleBone Black



In this blog, I'll show how to debug and profile the Open Source "Xaos" fractal rendering application running under Linux on the new BeagleBone Black using DS-5 Debugger, and how to profile the system using the ARM Streamline performance analyzer.  BeagleBone Black is based on an ARM Cortex®-A8 Sitara AM3359 processor running at 1GHz, with 512MB DDR3 RAM.

 

 


BeagleBone Black, close-up


Of course, DS-5 Debugger and Streamline can also be used to debug and profile your own Linux or Android applications on other ARM processor-based platforms in a similar way.  This blog is not intended to be a detailed tutorial, but just an overview of the main steps needed to debug a Linux application.

 

Setting Up

To get started, first download DS-5 Community Edition from ARM and install it on your host machine (Windows PC, Linux box, or Apple Mac).  On start-up, enter the Activation Code to license DS-5 CE - this will give you access to all the DS-5 CE components.  Alternatively, if you already have Eclipse installed, you can download and install the DS-5 Debugger and Streamline plug-ins from the Eclipse Update Site, and on start-up, you'll be prompted to install a DS-5 CE license.  In either case, if you want, you can purchase a license upgrade later that enables even more features.

 

Next, prepare your ARM processor-based Linux target platform.  Consult the Getting Started instructions for BeagleBone Black.  Other detailed instructions are available elsewhere on how to build a kernel and setup a filesystem for BeagleBone Black "" we chose Ubuntu 12.10.  To allow Linux application debug, you'll need to ensure gdbserver is present on the Linux target (apt-get install gdbserver).  DS-5 CE comes with Remote System Explorer that allows you to easily copy files between your host PC and the Linux target. To use RSE, the ssh daemon (sshd) must be running on the Linux target.  For file transfer, RSE makes use of sftp-server, so that must be present on the Linux target too.  To profile your application with Streamline, you must build gatord and gator.ko alongside the kernel in the usual way.  To run a graphics-intensive application like Xaos, you may also need to apt-get some graphics libraries such as gtk, cairo, pango, glib.

 

Next build your application.  We used the Open Source "Xaos" fractal rendering application.  This is provided within the Examples supplied with DS-5 or can alternatively the sources can be downloaded from SourceForge.  For best performance on BeagleBone Black, we built Xaos for hardware floating-point, to match the Ubuntu 12.10 hardware floating-point file system.  We also built Xaos multi-threaded, to demonstrate DS-5's support for debug and analysis of multi-threaded apps.

 

Debugging the Linux Application

We'll be debugging this Linux application via gdbserver.  The simplest way to establish an application debug connection to the BeagleBone Black is to set up a Linux/SSH connection with "Remote System Explorer" (RSE), then create a debug launch configuration that uses that RSE connection.

 

In the Remote Systems tab, create a New connection.  Select "Linux" [Next], enter the IP Address, and name it (e.g. "My BeagleBone Black") [Next], select "ssh.files" [Finish].  When you first try to connect to the target, RSE will ask you to enter the User ID and Password.  The Properties for the connection will end-up looking something like:

 

 

 

 

  Following a successful RSE connection, you can drill down into the remote target's file system in Eclipse, and drag'n'drop any needed files from host to target:

 

 

 

 

To create a debug launch configuration that uses that RSE connection, select Run -> Debug Configurations..., then create a New configuration named, for example, "xaos-gdbserver-example". 

 

In the Connection tab's target tree view, select Linux Application Debug -> Application Debug -> Download and debug application.  It will automatically use the RSE connection made earlier by default:

 

4-ConnectTab_updated.png

 

In the Files tab, enter the stripped executable to download, and the location of the unstripped executable containing the debug information to allow debug at source level:

 

5-FilesTab_updated.png


Finally, click on Debug.  DS-5 Debugger will download the stripped executable onto the target via RSE, start gdbserver on the target, read the debug information from the unstripped executable, and run to a breakpoint at main().  You can then view the source, run, stop, single-step, set breakpoints, set watchpoints, view registers, view variables, view disassembly, view memory, view symbols, view the stack backtrace for each thread, and so on.

 

 

6-Debug.png
(click to enlarge)


  
To view the graphical output from Xaos, we didn't have an LCD screen connected to the BeagleBone Black, but could redirect the graphical screen output to the XQuartz X server instead, by setting e.g. "export DISPLAY=[host IP address]:0.0" in the Environment tab of the Debug Configurations dialog:

 

 

 

Profiling the Linux Application

Streamline is ARM's performance analyzer, for profiling the behaviour of individual applications within whole Linux and Android systems.  To analyse the performance of the Xaos application, we simply need to start the application running, then point Streamline at it, to capture analysis data.

 

In the Streamline tab, first enter the IP address of the target:

 

 

 

 

Then click on the Capture & Analysis Options button, and add the location of the unstripped executable from which to read debug information, then press Save.

 

 



It is also possible here to select the use of ARM's low-cost Energy Probe that can be used to correlate target activity with energy usage on up to three power rails simultaneously.

 

  Then click on the Counter Configurations button, and select the target's hardware counters and kernel's events that you want to track, then press Save.


 

 

The list of available counters and events is dependent on the target ARM processor, the kernel in use, and the DS-5 licence in use.

 

Finally, start the application running and click on the Capture button to start capturing.  Streamline's Live View (new in DS-5 v5.14) immediately shows you the data coming from the BeagleBone Black in real time.  Once you have captured activity over a sufficient length of time, stop the capture, and Streamline will generate an analysis report, starting with the Timeline:

 

 

10-Timeline.png
(click to enlarge)

 

 

Here, we can see the workload of each thread within Xaos, together with their interaction with the Linux scheduler and other parts of the system, augmented by Streamline's textual and visual annotation feature.  In this example, Streamline is showing an intense period of activity by all five Xaos threads (bottom centre of this view), where the first set of calculations are made before the first Mandelbrot graphics frame is displayed, followed by regular bursts before each subsequent frame.

 

Clicking on the Functions tab then reveals the contribution of individual functions.  Here we can see that calculate() is the function within Xaos that consumes most time:

 

 

 

 

In the full-featured version with the upgraded license, we could see more detail, for example, which lines in the source code / assembler were taking the most execution time.

 

To summarize, we have seen how the features of DS-5 Debugger and Streamline make it easy to debug and profile Linux-based systems, and how these can be deployed successfully on latest low-cost development boards such as the BeagleBone Black.

 

  
Below is a video that introduces the new features in the ARM DS-5 toolchain version 5.14 including ARM big.LITTLE Processing support, improved compiler, multi-core debugger and trace synchronization, power and temperature monitoring and much more...