Use Function Instrumentation with the Application Profiler
When you profile a project, you can choose Function Instrumentation to obtain detailed information about the functions within your application. Each function entry and exit is instrumented with a call. The purpose of this is to record the entry and exit time of each function and call sequence.
Use Function Instrumentation mode for a single application
This method lets you obtain precise function information at runtime. It performs best for one thread because when there is more than one thread, the overhead measurement from multiple threads can change the application's behavior.
To compile an application with Function Instrumentation:
- Depending on your type of project, do one of the following:
- For a QNX C/C++ project:
- In the Project Explorer view, right-click your project and select Properties.
- In the left pane, select QNX C/C++ project.
- In the right pane, select the Options tab.
- Select Build for Profiling (Function Instrumentation).
- For a managed project with a QNX toolchain:
- Right-click on a project and select Properties.
- From the menu, select .
- From the list on the right, select QCC Compiler.
- From the list on the right, for your compiler (i.e. QCC Compiler), select an item from the list and select Output Control.
- Select the Build for Profiling (Function Instrumentation) option.
- From the list on the right for your linker (i.e. QCC Linker), select an item from the list, then select Output Control.
- Select the Build for Profiling (Function Instrumentation) (-lprofilingS) option.
- For a Makefile:
- To compile the application or library with Function Instrumentation, add the option -finstrument-functions.
- For linking, add the option -lprofilingS.
For a standard Makefile that uses default rules, your file would have the -finstrument-functions and -lprofilingS options for profiling, and it would look similar to this:
CFLAGS += -g -O0 -finstrument-functions LDLIBS += -lprofilingS
If the Makefile doesn't use the default linking and compile rules, flags and/or library, for profiling you'll need to manually add the -finstrument-functions and -lprofilingS options as in the following example:
main.o qcc -g -O0 -finstrument-functions -o main.o main.c binary: qcc -o binary main.o -lprofilingS
For QNX recursive Makefiles, you would also have the -finstrument-functions and profilingS options, and the Makefile would look similar to the following:
CFLAGS += -g -O0 -finstrument-functions LIBS += profilingS
The LIBS variable adds the list of libraries to include into the appropriate compiler options for profiling; you don't use LDFLAGS or LDOPTS to add libraries.
Notice that in the examples above, the -l option appears at the end of each statement. This positioning occurs because qcc doesn't understand the -l option before source and objects files; it must appear at the end.
- For a QNX C/C++ project:
- On the toolbar, select the Launch configuration for your app.
- You can profile a QML or a C/C++ application:
- To profile a QML application, in the Launch mode drop-down list, select QML Profile.
- To profile a C/C++ application, in the Launch mode drop-down list, select C/C++ Profile.
- In the Launch target drop-down
list, select a device or simulator.
To resolve any device connection issues, click Edit, and follow the instructions on the Device Properties dialog box.
- Click .
The Momentics IDE changes to the QNX Application Profiler perspective.
If the process doesn't finish, you'll have to terminate it manually. Instead of terminating the process, you can terminate the Application Profiler service in the Debug view; the Momentics IDE for BlackBerry will download the current state of the data.
The Application Profiler isn't optimized for data transfer; each second of application running time can generate up to 2 MB of data.
Profile from the command line
- Set QPROF_FILE environment variable to /tmp/profiler.ptrace.
- Launch the application, and then stop the application after some time, because the trace can't contain more than several seconds (minutes at most) of data.
- In the Momentics IDE, copy the file $QPROF_FILE into the Momentics IDE workspace (i.e. into the target project) using Target File System Navigator view.
- Switch to the Application Profiler perspective.
- In the Profiler Sessions view, select the Import Application Profiler Session icon.
- Follow the steps in the Import wizard to specify the binary and any
Shared Library paths.
If the binary wasn't compiled on the same host, you'll need to edit the Source Path tab to add the source search path or mapping between the compiled code location and the location of the source on the host machine.
- Click Finish.
The Momentics IDE creates a profiler session and automatically selects it.
Last modified: 2014-06-24