Previous: , Up: gprof Command Summary   [Contents]

4.5 Symspecs

Many of the output options allow functions to be included or excluded using symspecs (symbol specifications), which observe the following syntax:

| funcname_not_containing_a_dot
| linenumber
| ( [ any_filename ] `:' ( any_funcname | linenumber ) )

Here are some sample symspecs:


Selects everything in file main.c—the dot in the string tells gprof to interpret the string as a filename, rather than as a function name. To select a file whose name does not contain a dot, a trailing colon should be specified. For example, ‘odd:’ is interpreted as the file named odd.


Selects all functions named ‘main’.

Note that there may be multiple instances of the same function name because some of the definitions may be local (i.e., static). Unless a function name is unique in a program, you must use the colon notation explained below to specify a function from a specific source file.

Sometimes, function names contain dots. In such cases, it is necessary to add a leading colon to the name. For example, ‘:.mul’ selects function ‘.mul’.

In some object file formats, symbols have a leading underscore. gprof will normally not print these underscores. When you name a symbol in a symspec, you should type it exactly as gprof prints it in its output. For example, if the compiler produces a symbol ‘_main’ from your main function, gprof still prints it as ‘main’ in its output, so you should use ‘main’ in symspecs.


Selects function ‘main’ in file main.c.


Selects line 134 in file main.c.