Skip navigation
Currently Being Moderated

Tutorial: Multi- Core Linux Application Debug using Sourcery CodeBench Professional for ARM GNU/Linux

VERSION 6  Click to view document history
Created on: Oct 8, 2013 1:07 PM by kathleen_oliver - Last Modified:  Mar 6, 2014 1:10 PM by kathleen_oliver

Introduction

 

This tutorial explores the debugging and analysis capabilities of Sourcery CodeBench  for Linux. It walks you throught the process of analyzing a

multithreaded demo application that runs on a Virtual Prototype (VP) target described in SuperFIFO Virtual Prototype Overview.

 

You will be able to use break points to detect errors, correct these errors, access registers and review their values.

 

 

SuperFIFO Virtual Prototype Overview

A Virtual Prototype (VP) is a standalone executable file that can invoke simulation of a hardware design and can be used for testing and analyzing a design performance. VP speeds design cycles as it allows designers to replace expensive hardware prototypes with virtual models to predict system behavior. Also software engineers are able to integrate, validate, analyze, and optimize their software against an early model of the hardware design provided by the VP before the hardware design is implemented.

 

The SuperFIFO Virtual Prototype (VP) in this tutorial is based on the dual-core Versatile Express Platform (Cortex-A9) with a SuperFIFO register attached to it. The demonstration application transfers messages through the SuperFIFO device.

Preparing the Tutorial Environment

Follow the steps in this section to setup your tutorial environment. These steps download a virtual prototype and configure a connection between Sourcery CodeBench and the Virtual Prototype target.

Requirements

 

  • Host operating system is 32 bit Linux
  • Sourcery CodeBench Professional for ARM Embedded 2013.11 must be installed. 
Procedure
  1. Log in to the Mentor Embedded Portal. You will need a valid Sourcery CodeBench subscription to proceed. If you need help with your subscription, please contact sourcery_support@mentor.com.
  2. Go to Sourcery CodeBench Profesional for ARM Embedded 2013.11-XX release.
  3. Scroll down to the Additional Files section, and dowload the Dual-Core ARM Cortex-A9 Vista Virtual Prototype.
    add_files.png
  4. Extract the virtual prototype by typing the following command in your shell:

    tar -xzvf vexpress_dualcore_vp.tar.gz

  5. Go to the install_directory:

    cd vexpress_dualcore_vp/install_directory

  6. Start the virtual prototype, this will start the target and boot Linux:

    ./run.exe

  7. Start Sourcery CodeBench for ARM/GNU Embedded 2013.11.
  8. Create a new workspace for your projects.

    Sourcery CodeBench stores   your projects in a folder called a workspace. You can have multiple   workspaces. You setup your workspace when starting CodeBench and can   change workspaces from the IDE.

    TIP: To change workspaces from the IDE, select File > Switch Workspace and then enter a new workspace location.
  9. The   first time you open CodeBench, the Welcome screen appears.  Use the   links on the Welcome screen to learn more about CodeBench or to get   help.

    1. To close the Welcome screen, click X. This opens the C/C++ Perspective.
    2. To reopen the Welcome screen later, select Help  > Welcome.
  10. Configure a target connection using the Remote System Explorer and set the port in the remote system explore to 2022 on the host:
    1. Select Window > Open Perspective > Other and select Remote System Explorer.
    2. Right-click inside the Remote Systems window and select New Connection.
    3. Select General > SSH Only and click Next.
    4. Enter LOCALHOST as the Host name and give the connection a unique name:
      vp_conn.png
    5. Click Finish to create the connection.
    6. Expand the connection in the Remote Systems window and select Sftp Files.
    7. Go to the Properties window and set the port to 2022:
    vp_rse.png
  11. You can now use this connection when you create a debug configuration. If prompted to log-in to the target, set the username to root and leave the password blank because there is not a password. In your debug configuration, use LOCALHOST as the IPADDRESS for the target.

         

        Creating and Debugging an Application

         

        In this chapter, you will learn how to debug the demo application on the SuperFIFO Virtual Prototype (VP), detect and correct the error in this application, and review the results. Before

        debugging the demo application, you must start the SuperFIFO VP simulation.

         

        Requirements

        Complete the steps in Preparing the Tutorial Environment

         

        Procedure
        1. If youre virtual prototype is not already running, start your virtual prototype:

          cd vexpress_dualcore_vp/install_directory
          ./run.exe


        2. If Sourcery CodeBench is not running, start Sourcery CodeBench for ARM GNU/Linux 2013.11.
        3. Select an existing workspace or create a new workspace for your projects.

          Sourcery CodeBench stores  your projects in a folder called a workspace. You can have multiple  workspaces. You setup your workspace when starting CodeBench and can  change workspaces from the IDE.

          TIP: To change workspaces from the IDE, select File > Switch Workspace and then enter a new workspace location.
        4. The  first time you open CodeBench, the Welcome screen appears.  Use the  links on the Welcome screen to learn more about CodeBench or to get  help.

          1. To close the Welcome screen, click X. This opens the C/C++ Perspective.
          2. To reopen the Welcome screen later, select Help  > Welcome.
        5. Create a new C++ project:
              1. Select File > New C++ Project.
              2. Give the project a name.
              3. From Project type, select Executable > Empty Project.
              4. From Toolchains, select Sourcery CodeBench for ARM GNU/Linux.
                c_proj.png
              5. Click Next.
              6. Fill out the Configuration tab so it matches the graphic below:
                demo_proj.png
              7. Select the target connection that you setup in Preparing the Tutorial.
              8. Click Next.
              9. Use the default debug settings:
                demo_debug_settings.png
              10. Click Finish to create your project.
              1. Import the threads example source into your workspace:
                1. Select File > Import.
                2. From the Import wizard, select General > File System and click Next.
                  import.png
                3. In the From Directory field, enter <CodeBench Install Directory>/Sourcery_CodeBench_for_ARM_Embedded/share/sourceryg++-arm-none-linux-gnueabi-examples/threads:
                  import_file.png
                4. Select the threads directory and click Finish.  This imports the files into your project.

              2. Add the pthreads library to your build settings:
                  1. From the project explorer, right-click your project and select Properties.
                  2. In the Properties dialog box, expand C/C++ Build >Settings and select Sourcery CodeBench C++ Linker > Libraries.
                  3. Add the pthread library.

                     

                    addlib.png
                  4. Click Apply and close the dialog box.
                    1. Now you are ready to build! Right-click the project and select Build Project.
                    2. Check for build errors, assuming you have none, you are ready to debug!
                    3. Configure your debug session:
                      1. Select Run > Debug Configurations.
                      2. Select  the debug launch that was created when you created your project.  It  will have the same name as your project and is setup so you can just  start debugging.
                      3. Click Debug. If prompted to log-in to the target, set the username to root and there is not a password.
                      4. If the Confirm Perspective Switch dialog box appears, click Yes to open the debug perspective..
                    4. Debug!  This application has a primary thread and spawns 2 more threads.  If  you get stuck while debugging and cannot step, make sure a thread is  selected.

                      The   debug perspective displays the stack, local variables, and the current   location.  By default, the debugger automatically stops on the first   line of main.  The currently active source line is highlighted. The pane at the upper left shows the application threads and the stack associated with each thread. The pane at the upper right shows the values of local variables.

                    5. Use the debugger controls to set breakpoints and step through code, for example select Run > Step Over (F6) to go to the next line of code or Run > Step Into (F5) to step into a function.  To add a breakpoint, select a line of code and select Run > Toggle Breakpoint or double-click the blue area to the left of the line of code.
                    6. Use the Variables view to view and modify variables.
                    7. To view machine registers, select the Registers tab, and expand the General Registers register group. When the values of registers change, the registers are   highlighted in the IDE. Right-click a register to add it to the watch   list.
                    8. To see the instructions being executed, select Window > Show View > Disassembly.   You can set breakpoints on particular machine instructions in   disassembly view in the same way that you can set breakpoints on source   lines in the source code editor views in the debugger.
                    9. The Step Over and Step Into commands normally operate at the source level, advancing program   execution to the next C or C++ statement. To step by machine   instructions instead, click on the Instruction Stepping Mode button on the Debug toolbar. Click this button again to return to stepping by source lines.
                      1. For more information about debugging, select Help > Help Contents and browse to the Sourcery CodeBench Getting Started Guide.
                      Average User Rating
                      (0 ratings)

                      Bookmarked By (1)

                      More Like This

                      • Retrieving data ...