gdb: Debugging C Plus Plus

 
 15.4.1.7 GDB Features for C++
 .............................
 
 Some GDB commands are particularly useful with C++, and some are
 designed specifically for use with C++.  Here is a summary:
 
 'breakpoint menus'
      When you want a breakpoint in a function whose name is overloaded,
      GDB has the capability to display a menu of possible breakpoint
      locations to help you specify which function definition you want.
      SeeAmbiguous Expressions Ambiguous Expressions.
 
 'rbreak REGEX'
      Setting breakpoints using regular expressions is helpful for
      setting breakpoints on overloaded functions that are not members of
      any special classes.  SeeSetting Breakpoints Set Breaks.
 
 'catch throw'
 'catch rethrow'
 'catch catch'
      Debug C++ exception handling using these commands.  SeeSetting
      Catchpoints Set Catchpoints.
 
 'ptype TYPENAME'
      Print inheritance relationships as well as other information for
      type TYPENAME.  SeeExamining the Symbol Table Symbols.
 
 'info vtbl EXPRESSION.'
      The 'info vtbl' command can be used to display the virtual method
      tables of the object computed by EXPRESSION.  This shows one entry
      per virtual table; there may be multiple virtual tables when
      multiple inheritance is in use.
 
 'demangle NAME'
      Demangle NAME.  SeeSymbols, for a more complete description of
      the 'demangle' command.
 
 'set print demangle'
 'show print demangle'
 'set print asm-demangle'
 'show print asm-demangle'
      Control whether C++ symbols display in their source form, both when
      displaying code as C++ source and when displaying disassemblies.
      SeePrint Settings Print Settings.
 
 'set print object'
 'show print object'
      Choose whether to print derived (actual) or declared types of
      objects.  SeePrint Settings Print Settings.
 
 'set print vtbl'
 'show print vtbl'
      Control the format for printing virtual function tables.  See
      Print Settings Print Settings.  (The 'vtbl' commands do not work
      on programs compiled with the HP ANSI C++ compiler ('aCC').)
 
 'set overload-resolution on'
      Enable overload resolution for C++ expression evaluation.  The
      default is on.  For overloaded functions, GDB evaluates the
      arguments and searches for a function whose signature matches the
      argument types, using the standard C++ conversion rules (see See
      C++ Expressions C Plus Plus Expressions, for details).  If it
      cannot find a match, it emits a message.
 
 'set overload-resolution off'
      Disable overload resolution for C++ expression evaluation.  For
      overloaded functions that are not class member functions, GDB
      chooses the first function of the specified name that it finds in
      the symbol table, whether or not its arguments are of the correct
      type.  For overloaded functions that are class member functions,
      GDB searches for a function whose signature _exactly_ matches the
      argument types.
 
 'show overload-resolution'
      Show the current setting of overload resolution.
 
 'Overloaded symbol names'
      You can specify a particular definition of an overloaded symbol,
      using the same notation that is used to declare such symbols in
      C++: type 'SYMBOL(TYPES)' rather than just SYMBOL.  You can also
      use the GDB command-line word completion facilities to list the
      available choices, or to finish the type list for you.  See
      Command Completion Completion, for details on how to do this.
 
 'Breakpoints in functions with ABI tags'
 
      The GNU C++ compiler introduced the notion of ABI "tags", which
      correspond to changes in the ABI of a type, function, or variable
      that would not otherwise be reflected in a mangled name.  See
      <https://developers.redhat.com/blog/2015/02/05/gcc5-and-the-c11-abi/>
      for more detail.
 
      The ABI tags are visible in C++ demangled names.  For example, a
      function that returns a std::string:
 
           std::string function(int);
 
      when compiled for the C++11 ABI is marked with the 'cxx11' ABI tag,
      and GDB displays the symbol like this:
 
           function[abi:cxx11](int)
 
      You can set a breakpoint on such functions simply as if they had no
      tag.  For example:
 
           (gdb) b function(int)
           Breakpoint 2 at 0x40060d: file main.cc, line 10.
           (gdb) info breakpoints
           Num     Type           Disp Enb Address    What
           1       breakpoint     keep y   0x0040060d in function[abi:cxx11](int)
                                                      at main.cc:10
 
      On the rare occasion you need to disambiguate between different ABI
      tags, you can do so by simply including the ABI tag in the function
      name, like:
 
           (gdb) b ambiguous[abi:other_tag](int)