Visible to Intel only — Ixiasoft
Visible to Intel only — Ixiasoft
4.4.3.5.1. Profiler Example with the Nios® II Command Line
Creating the Profiler Software Example
To create the profiler_gnu software project in the Nios® II command-line flow, follow these steps:
- Open a Nios® II command shell by executing one of the following steps, depending on your environment:
- In the Windows operating system, on the Start menu, point to Programs > Intel FPGA > Nios® II EDS <version>, and click Nios® II <version> Command Shell.
- In the Linux operating system, in a command shell, change directories to < Nios® II EDS install path>, and type the command ./sdk_shell.
- Change to the directory <profiler_software_examples> /app/profiler_gnu
- Create and build the application with the create-this-app script, by typing the following command:
./create-this-app
The create-this-app script runs the create-this-bsp script, which reads settings from the parameter_definition.tcl in <profiler_software_examples> /bsp/hal_profiler_gnu. This Tcl file contains the following lines:
set_setting hal.enable_gprof trueset_setting hal.enable_exit trueThe first setting enables the GNU profiler, and the second setting enables the alt_main() function to call exit() following main().
Running the Profiler Software Example
To run the application and collect the GNU profiler data, follow these steps:
- Open a second Nios® II command shell.
- In the second shell, open a nios2-terminal session by typing the following command:
nios2-terminal
- In your original Nios® II command shell, download the .elf to the development board, run your design, and write the GNU profiler data to the gmon.out, by typing the following command:
nios2-download -g --write-gmon gmon.out *.elf
The GNU profiler collects data while the application runs, and then writes the data to the gmon.out when the application calls the exit() function. The figure below shows an example of the GNU profiler output in the Nios® II command shell.
- Exit nios2-terminal by typing control-C.
Figure 42. GNU Profiler Output on Nios® II Command Shell
Creating the GNU Profiler Report
When you run your project, your project creates the gmon.out. You must format this file to a readable format. To format this file, follow these steps:
- In the original Nios® II command shell, change your directory to <profiler_software_examples> /app/profiler_gnu.
- Type the following command:
nios2-elf-gprof profiler_gnu.elf gmon.out > report.txt
- Use any text editor to view the report.txt.
For more information about the GNU profiler report, refer to “Analyzing the GNU Profiler Report”.