How To Use Gprof with TimeStorm for profiling C/C++ programs

Gprof Profiling allows you to learn where your program spent its time and which functions called which other functions while it was executing. This information can show you which pieces of your program are slower than you expected, and might be candidates for rewriting to make your program execute faster. It can also tell you which functions are being called more or less often than you expected. This may help you spot bugs that had otherwise been unnoticed. For more information, please refer to

This document will show How to Use Gprof with TimeStorm. To run Gprof in TimeStorm.

  1. Open your C/C++ Project. If you want to learn how to use gprof, go to Learn Gprof by creating a C Project using the gprof sample section below.
  2. Add Gprof flags to Compiler and Linker to your c/c++ project
  3. Build Project.
  4. Set up Gprof configuration for a Remote target.
  5. Start Gprof profiling and view the results in Gprof editor.

1. Open your C/C++ Project:

Open your project using project explorer (we are using a C/C++ project created using the gprof sample) as shown below.

2. Add Gprof flag to Compiler and Linker:

Make sure you are in the C/C++ perspective (Window → Perspective → Open Perspective → Other → C/C++) in TimeStorm. Right click your Project, and select Properties. Expand C/C++ Build > Settings, and select the Tool Settings tab. Select Miscellaneous under GCC C/C++ Compiler and GCC C/C++ Linker, append '-pg' to the already existing flags or select “Generate gprof information (-pg)” checkbox in the GCC C/C++ Compiler → Debugging as shown below.

This will make a gmon.out file be generated when the compiled program is run on your target and terminates successfully.

Note: If the “-pg” flag already exists in the GCC C/C++ Compiler and GCC C/C++ Linker don’t add it again.

3. Build Project:

Right click your project, and select Build Project. There should be a .gcno file generated as a result of building the project. Verify this file exists by expanding the directory in your project.

4. Set up Gprof configuration for a Remote target:

A TimeStorm Profiling Configuration is a collection of settings that are required to download and run an application. The TimeStorm Profiling configuration is persistent, and can be launched multiple times to profile the application. To profile the application on the remote target, you have to create a TimeStorm Profiling configuration. To create a TimeStorm Profiling configuration, right click on the project and click on TimeStorm Profiling Tools → Gprof as shown below.

Click on the “Gprof” option and this will open the “TimeStorm Profiling Tools Configurations” dialog as shown below.

Note that an entry is created under TimeStorm C/C++ remote category with the project name appended with the Active build configuration, and other values are filled in with the default values that should work. The Timestorm Profiling Tools Configurations entries are categories in different tabs on the right hand panel and are explained below. To profile the application, mostly you have to just select the remote target on the target tab and click the Profile button.

Main Tab:

In the Main tab, you can change the C/C++application by searching the project. You can change the project too if you want to use this configuration for a different project.

Arguments tab:

In the Arguments tab, you can specify the arguments to be passed to the application program. The remote working directory is set as ‘.’, which means that the directory specified in the target definition is used as the working directory.

The command to be executed is filled in. Uncheck ‘Use default command’ to change this value. Keep in mind the directory structure on your target when constructing this command. For example, if you have copied your application file to a directory named /apps but you want to execute it from a working directory named /home/test, you must include the path to your application in your command.

For example: ../../apps/my_app

Environment tab:

In the ‘Environment’ tab, you can set environment variables for the target.

The panel shown above contains the following buttons:

Add — Click the ‘Add’ button to create a new entry, and the ‘New Environment Variable’ dialog will appear, as shown below. Click the ‘Variables’ button to select the variables that you want to use. Then, click ‘OK’ twice.

Select — Click the ‘Select‘ button to import environment variables from the host file system.

Edit — To change an entry, select it from the list, and click the ‘Edit’ button.

Remove — To delete an entry, select it from the list, and click the ‘Remove’ button

Copy — To copy environment variables and values, select if from the list, and click the ‘Copy’ button.

Paste — To paste environment variables and values, click the ‘Paste’ button.

Source tab:

Source Lookup Path — This field shows the project being run, as well as any projects that it references.

Add — You can add arbitrary source file locations by using the Add button. These locations are searched after the generic locations, from the top to the bottom item in order.

Edit, Remove, Up, Down — The other buttons to the right of the list allow you to edit, remove, or reorder the list items, and to restore the default information.

Search for duplicate source files on the path — Selecting this checkbox causes TimeStorm to notify the user if it is unable to determine which source file corresponds to an executing binary file. For example, if you have two source files with the same filename in different directories of the search path, TimeStorm is unable to determine which file is related to the binary file with that name. If this checkbox is selected, TimeStorm displays a message and asks the user to select which file to use. This checkbox is not selected by default.

Target tab:

The Target tab shown below, allows you to select the hardware target used when you Profile the application.

Download Files tab:

In the ‘Download Files’ tab, you can select the files that TimeStorm transfers to your target. The application that has to be downloaded is already listed. You can use this panel to download additional files to your target, along with your application.

The application specified in the File field is listed as [Target Program]. This is the application that will be run. You can change where it is downloaded by selecting it and clicking Edit.

If the program links in shared libraries, then these libraries will be downloaded to the target as well and the Files field is listed as [Target Program and Libraries]. These libraries will be downloaded to the same location as the target program. To download the program and libraries to separate locations, remove the default entry and re-add each as a separate entry.

This panel contains the following buttons:

Add File – Use the ‘Add File’ button to specify additional files to transfer, along with the application. These files are transferred every time you transfer the application file.

Edit – To change where the application (or any other file in this list) is installed, select it and click ‘Edit’ to change its destination directory.

Remove – To eliminate a file from the items to download, select it in the list and click the ‘Remove’ button.

Download Now – The ‘Download Now’ button copies files immediately, without running the application.

Restore Default – The ‘Restore Default’ button resets the panel to its initial state (download only the application and its libraries).

NOTE: Downloaded files overwrite any identically named files on the target without giving a warning. TimeStorm will not create destination directories on the target, so be sure to create them before launching the configuration.

Common tab:

The ‘Common’ tab, sets options for sharing this TimeStorm Profiling Tools Configuration among multiple projects.

The options with the Common tab include:

Local File — By default, Timestorm Profiling Tools configurations are saved with the workspace state files, so they can only be used with projects in the current workspace. (This setting corresponds to the ‘Local file’ radio button on this panel.) However, you can make the configuration available for use in other workspaces by choosing the ‘Shared file’ radio button.

Shared File — When you select this option, the Timestorm Profiling Tools configuration is saved as a .launch file that can be imported into another TimeStorm workspace. Optionally, you can specify a different location for the file so that it is more easily accessible to multiple projects.

Display in Favorites Menu — You can select whether to include this TimeStorm Profiling Tools configuration on the context menu. For example, if you select the ‘TimeStorm Profiling Tools’ checkbox, the TimeStorm Profiling Tools configuration always appears in the ‘Profiling History’ submenu.

You can choose to include the TimeStorm Profiling Configuration in either menu, both menus, or neither menu.

Launch in Background — Selecting the ‘Launch in background’ checkbox causes this profile configuration to run as a background thread. Running as a background thread is the default value. Clear this checkbox if you want to run in the foreground, along with other TimeStorm processing.

5.Start Gprof profiling and view the results in Gprof editor:

After setting the values in all the tabs, click the Profile button at the bottom of the Profile configuration dialog. This will connect your host to your target, download the application to the target and execute the application on the target. The commands executed on the target and the program output progress are displayed in the console view.

After your program successfully runs on your target, a gmon.out file will be generated in the same directory as your project binaries. By default, this location is /root/. The gmon.out will automatically copy from your target to your local TimeStorm project directory. You should now see gmon.out in your src/ directory. Double click gmon.out to open it. Verify that the binary specified in the Gmon File Viewer window is correct, and select OK. You will now be viewing profiling information from your previous target program run in TimeStorm as shown below. For more information, please refer to

Learn Gprof by creating a C Project using the gprof sample:

To create a C/C++ project, open the ‘New Project’ wizard by choosing File → New → Project from the main menu OR click the ‘New’ button and use the drop-down menu to the right of the button to choose ‘Project’ as shown below.

Expand C/C++ , choose a C/C++ Project and click Next. To illustrate Sample Gprof Project (Samples → Gprof)

Project page

  1. Enter a Project Name.
  2. Under the ‘Project Type’ heading, expand Samples and select Gprof project.
  3. Under the Toolchains heading select the TimeStorm Cross-Compile Toolchain.
  4. Click ‘Next’ to bring up the ‘Basic Settings’ as shown below.

    Basic settings page

    In this page, set the basic properties of the project like Author, Copyright notice, Greeting message and Source (where the project source files are to be stored within the project).

    Select build configuration page

    Build Configuration is a set of pre-defined compiler and linker settings that are used to build a project.

    By default, TimeStorm creates three Build Configurations for new projects:

    Debug — This setting performs no code optimization and attaches complete debugging information. These settings are designed to make debugging as easy as possible.

    Release — This setting has the highest compiler code optimization settings. The output will not include any debugging symbols. Code compiled with this configuration is ready for production use.

    GnuProfiler — This setting builds the software with debugging information as well as code to collect profiling information via GNU gcov.

    You can change the build configuration settings before creating the project by clicking the ‘Advanced Settings…’ button. You can also change these settings after creating the project.

    Click Next to continue.

    Select SDK page

    The Select SDK page show below allows you to choose the SDK you want to use with the project. Select the SDK Type and then choose the SDK.

    Click Finish to create and exit the wizard. The new project is created and displayed in the Project Explorer view as shown below.

    After creating the Sample Gprof Project, follow the above steps (Step2: Add Gprof flags to Compiler and Linker to your c/c++ project, Step3: Build Project, Step4: Set up Gprof configuration for a Remote target, Step5:Start Gprof profiling and view the results in Gprof editor) to run Gprof Profiling.