Next: , Previous: Continuing and Stepping, Up: Stopping


5.3 Skipping Over Functions and Files

The program you are debugging may contain some functions which are uninteresting to debug. The skip comand lets you tell gdb to skip a function or all functions in a file when stepping.

For example, consider the following C function:

     101     int func()
     102     {
     103         foo(boring());
     104         bar(boring());
     105     }

Suppose you wish to step into the functions foo and bar, but you are not interested in stepping through boring. If you run step at line 103, you'll enter boring(), but if you run next, you'll step over both foo and boring!

One solution is to step into boring and use the finish command to immediately exit it. But this can become tedious if boring is called from many places.

A more flexible solution is to execute skip boring. This instructs gdb never to step into boring. Now when you execute step at line 103, you'll step over boring and directly into foo.

You can also instruct gdb to skip all functions in a file, with, for example, skip file boring.c.

skip [linespec]
skip function [linespec]
After running this command, the function named by linespec or the function containing the line named by linespec will be skipped over when stepping. See Specify Location.

If you do not specify linespec, the function you're currently debugging will be skipped.

(If you have a function called file that you want to skip, use skip function file.)


skip file [filename]
After running this command, any function whose source lives in filename will be skipped over when stepping.

If you do not specify filename, functions whose source lives in the file you're currently debugging will be skipped.

Skips can be listed, deleted, disabled, and enabled, much like breakpoints. These are the commands for managing your list of skips:

info skip [range]
Print details about the specified skip(s). If range is not specified, print a table with details about all functions and files marked for skipping. info skip prints the following information about each skip:
Identifier
A number identifying this skip.
Type
The type of this skip, either ‘function’ or ‘file’.
Enabled or Disabled
Enabled skips are marked with ‘y’. Disabled skips are marked with ‘n’.
Address
For function skips, this column indicates the address in memory of the function being skipped. If you've set a function skip on a function which has not yet been loaded, this field will contain ‘<PENDING>’. Once a shared library which has the function is loaded, info skip will show the function's address here.
What
For file skips, this field contains the filename being skipped. For functions skips, this field contains the function name and its line number in the file where it is defined.


skip delete [range]
Delete the specified skip(s). If range is not specified, delete all skips.


skip enable [range]
Enable the specified skip(s). If range is not specified, enable all skips.


skip disable [range]
Disable the specified skip(s). If range is not specified, disable all skips.