gdb: Skipping Over Functions and Files

 
 5.3 Skipping Over Functions and Files
 =====================================
 
 The program you are debugging may contain some functions which are
 uninteresting to debug.  The 'skip' command lets you tell GDB to skip a
 function, all functions in a file or a particular function in a
 particular 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'.
 
    Functions may be skipped by providing either a function name,
 linespec (SeeSpecify Location), regular expression that matches the
 function's name, file name or a 'glob'-style pattern that matches the
 file name.
 
    On Posix systems the form of the regular expression is "Extended
 Regular Expressions".  See for example 'man 7 regex' on GNU/Linux
 systems.  On non-Posix systems the form of the regular expression is
 whatever is provided by the 'regcomp' function of the underlying system.
 See for example 'man 7 glob' on GNU/Linux systems for a description of
 'glob'-style patterns.
 
 'skip [OPTIONS]'
      The basic form of the 'skip' command takes zero or more options
      that specify what to skip.  The OPTIONS argument is any useful
      combination of the following:
 
      '-file FILE'
      '-fi FILE'
           Functions in FILE will be skipped over when stepping.
 
      '-gfile FILE-GLOB-PATTERN'
      '-gfi FILE-GLOB-PATTERN'
           Functions in files matching FILE-GLOB-PATTERN will be skipped
           over when stepping.
 
                (gdb) skip -gfi utils/*.c
 
      '-function LINESPEC'
      '-fu LINESPEC'
           Functions named by LINESPEC or the function containing the
           line named by LINESPEC will be skipped over when stepping.
           SeeSpecify Location.
 
      '-rfunction REGEXP'
      '-rfu REGEXP'
           Functions whose name matches REGEXP will be skipped over when
           stepping.
 
           This form is useful for complex function names.  For example,
           there is generally no need to step into C++ 'std::string'
           constructors or destructors.  Plus with C++ templates it can
           be hard to write out the full name of the function, and often
           it doesn't matter what the template arguments are.  Specifying
           the function to be skipped as a regular expression makes this
           easier.
 
                (gdb) skip -rfu ^std::(allocator|basic_string)<.*>::~?\1 *\(
 
           If you want to skip every templated C++ constructor and
           destructor in the 'std' namespace you can do:
 
                (gdb) skip -rfu ^std::([a-zA-z0-9_]+)<.*>::~?\1 *\(
 
      If no options are specified, the function you're currently
      debugging will be skipped.
 
 '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.  SeeSpecify 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.
 
           (gdb) skip file boring.c
           File boring.c will be skipped 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.
      _Enabled or Disabled_
           Enabled skips are marked with 'y'.  Disabled skips are marked
           with 'n'.
      _Glob_
           If the file name is a 'glob' pattern this is 'y'.  Otherwise
           it is 'n'.
      _File_
           The name or 'glob' pattern of the file to be skipped.  If no
           file is specified this is '<none>'.
      _RE_
           If the function name is a 'regular expression' this is 'y'.
           Otherwise it is 'n'.
      _Function_
           The name or regular expression of the function to skip.  If no
           function is specified this is '<none>'.
 
 '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.
 
 'set debug skip [on|off]'
      Set whether to print the debug output about skipping files and
      functions.
 
 'show debug skip'
      Show whether the debug output about skipping files and functions is
      printed.