For an existing project, when you build your project to profile an application to capture performance information, profiling can provide you with decision-making capabilities to help discover functions that consume the most CPU time. However, to instrument your code, you'll need to change the existing configuration options so that you can build your project with profiling enabled. The IDE will then insert code before each function to gather call information (Call Count instrumentation) or just after the function enters, and just before the function exits (Function Instrumentation).
To configure profiling for the selected project, depending on your type of project, do one of the following:
For example, your Makefile might have a line like this:
CFLAGS=-p CXXFLAGS=-p LDFLAGS=-p
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 include 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.
The QNX Application Profiler uses the information in the debuggable executables to correlate lines of code in your executable and the source code. To maximize the information you get while profiling, use executables with debug information for both running and debugging.