Differences between revisions 3 and 4
Revision 3 as of 2012-11-27 15:20:15
Size: 2654
Editor: DiegoNovillo
Comment:
Revision 4 as of 2012-11-27 20:18:40
Size: 2657
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
Original proposal and discussion: http://gcc.gnu.org/ml/gcc/2012-11/msg00222.html Original proposal and discussion:
http://gcc.gnu.org/ml/gcc/2012-11/msg00222.html
Line 7: Line 8:
It is sometimes hard to remember which printing function is used for debugging a type, or even which type you have. It is sometimes hard to remember which printing function
is used for debugging a type, or even which type you have.
Line 29: Line 31:
  fprintf (f, <nil>);   fprintf (f, "<nil>");
Line 46: Line 48:
 * {{{dump_raw}}}: This is equivalent to the current dump_node for trees and using the TDF_RAW option for gimple. Instead of showing a C-like representation of the IL, it shows it in its tree or tuple-like form.  * {{{dump_raw}}}: This is equivalent to the current "dump_node" for trees and using the TDF_RAW option for gimple. Instead of showing a C-like representation of the IL, it shows it in its tree or tuple-like form.
Line 48: Line 50:
 * {{{dump_declaration}}}: This only works with DECLs. It shows the declaration of the symbol.
 * {{{dump_body}}}: This only works with FUNCTION_DECLs. It shows the body of the function.
 * {{{dump_head}}}: This only works with DECLs. It shows the head/declaration of the symbol.
 * {{{dump_body}}}: This only works with FUNCTION_DECLs. It shows the body/definition of the function.

Unifying the GCC Debugging Interface

Original proposal and discussion: http://gcc.gnu.org/ml/gcc/2012-11/msg00222.html

Problem

It is sometimes hard to remember which printing function is used for debugging a type, or even which type you have.

Solution

We propose to rely on overloading to unify the interface to a small set of function names. Every major data type should have associated debug/dump functionality. We will unify the current *_dump/*_debug functions under the same common overloaded name.

We intend to only apply this approach to functions that take the type to display as an argument, and that are routinely used in debugging.

Proposal

We propose to provide a family of template functions with the same common name: dump.

template<typename T>
dump (const T &ptr, int options = 0, int indent = 0, FILE *f = stderr);

template<typename T>
dump (const T *ptr, int options = 0, int indent = 0, FILE *f = stderr)
{
        if (ptr)
                dump (*ptr, options, indent, f);
        else
                fprintf (f, "<nil>");
}

Data structures that want to use this facility, need to provide an instance of

template<typename T>
dump (const T &ptr, int options = 0, int indent = 0, FILE *f = stderr);

The formatting of the dump is affected by the options flags, which can be combined using bitwise OR expressions. Additionally, we will provide named entry points for common combinations of dump options flags.

The valid option values are defined as values of the enumerated type enum dump_options. Initially, this enumerated type will take all the values of the existing TDF_* macro constants.

It is up to each data structure to define the default format emitted by dump(). Some common alternate entry points:

  • dump_raw: This is equivalent to the current "dump_node" for trees and using the TDF_RAW option for gimple. Instead of showing a C-like representation of the IL, it shows it in its tree or tuple-like form.

  • dump_verbose: This has the same effect as using the TDF_VERBOSE flag in the options.

  • dump_head: This only works with DECLs. It shows the head/declaration of the symbol.

  • dump_body: This only works with FUNCTION_DECLs. It shows the body/definition of the function.

Other Work

  • We will remove tree-browser.c. It is not used at all and it is likely broken.
  • To support cut-and-paste operation inside gdb, we will write python wrappers to add type casts for numeric pointer values. Otherwise, expressions like call dump(0xffff7ea8) will fail to find the correct overload.

None: cxx-conversion/debugging-dumps (last edited 2012-11-27 20:18:40 by LawrenceCrowl)