Debugging Hello World in C on a Fixed Virtual Platform

Once you have created the project and built the code, launch the debugger to run the application on one of the Fixed Virtual Platforms (FVP) provided with DS-5. For this tutorial, we use a Cortex-A9 Fixed Virtual Platform (FVP) which is provided with DS-5.

Creating a DS-5 Debug Configuration and Connecting to an FVP

  1. From the DS-5 main menu, select Run > Debug Configurations.
  2. In the Debug Configurations dialog:
    1. Select DS-5 Debugger.
    2. Click the New launch configuration button.

      Debug configurations - New

      This creates a new DS-5 debug configuration and displays the various tabs required to specify settings for loading your application on the target.

      Debug configurations - Tabs

  3. In the Debug Configurations dialog:
    1. Give a name to the debug configuration. For example, HelloWorld_FVP.
    2. In the Connection tab, under Select Target, browse and select ARM FVP (Installed with DS-5) > VE_Cortex_A9x1 > Bare Metal Debug > Debug Cortex-A9.

      Debug configurations - Connection Tab

    3. Select the Files tab, and under Target Configuration in the Application on host to download field, click Workspace.

      Debug configurations - Files Tab

      The Workspace contains the HelloWorld.axf application file you created when you built the Hello World project.

      Note: Ensure that the Load symbols option is selected.

    4. Select HelloWorld.axf.

      Open Hello World

    5. Select the Debugger tab, and ensure the Debug from symbol option is selected and set to main.

      Debug configurations - Debugger Tab

    6. Click Debug to load the application on the target, and load the debug information into the debugger.
    7. In the Confirm Perspective Switch dialog that appears, click Yes.

      DS-5 connects to the model and displays the connection status in the Debug Control view.

      Debug Control view - Hello World connected

      The application is loaded on the target, and has stopped at the main() function, ready to run.

      Hello world code editor view

    8. ClickContinue Button to continue running the application.

      You can view the application output in the Target Console view.

      Target Console view

      Other views display information relevant to the debug connection

      • Commands view displays messages output by the debugger. Also use this view to enter DS-5 commands.

        Commands view

      • C/C++ Editor view shows the structure of the active C, C++, or makefile. The view is updated as you edit these files.

        Hello world code editor view

      • Disassembly view shows the loaded program in memory as addresses and assembler instructions.

        Disassembly view

        At line Indicates the location in the code where your program is stopped. In this case, it is at the main() function.

      • Memory view shows how the code is represented in the target memory.

        For example, to view how the string Hello World from the application is represented in memory:

        1. Open the Memory view.
        2. In the Address field, enter 0x80000000 and press Enter on your keyboard. The view displays contents of the target's memory.
        3. Select and highlight the words Hello World.

        Memory view

        In the above example, the Memory view displays the hexadecimal values for the code, and also the ASCII character equivalent of the memory values which enable you to drill down into the details of the code.

Step Through the Application

Use the controls provided in the Debug Control view to step through the application.

 

Continue Button - Click to continue executing code.

Pause Button - Click to interrupt or pause executing code.

Step Through button - Click to step through the code.

Step Over button - Click to step over source line.

Step Out button - Click to step out.

Step instruction - This is a toggle. Select this if you want the above controls to step through instructions.

Disconnecting from the Debug Connection

To disconnect from a debug connection, you can either right-click the connection and select Disconnect from Target or select the connection and in the Debug Control view toolbar click Disconnect button