On Tue, Jan 12, 2021 at 3:55 AM Martin Liška <mli...@suse.cz> wrote:
>
> The patch is about an extensive debugging facility that I see
> beneficial for GCOV issue.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> I'm going to push it.
>
> Thanks,
> Martin
>
> gcc/ChangeLog:
>
>         * gcov.c (source_info::debug): New.
>         (print_usage): Add --debug (-D) option.
>         (process_args): Likewise.
>         (generate_results): Call src->debug after
>         accumulate_line_counts.
>         (read_graph_file): Properly assign id for EXIT_BLOCK.
>         * profile.c (branch_prob): Dump function body before it is
>         instrumented.
> ---
>   gcc/gcov.c    | 43 ++++++++++++++++++++++++++++++++++++++++++-
>   gcc/profile.c |  5 +++++
>   2 files changed, 47 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/gcov.c b/gcc/gcov.c
> index 01ca52b215d..93128721ef6 100644
> --- a/gcc/gcov.c
> +++ b/gcc/gcov.c
> @@ -371,6 +371,9 @@ public:
>     /* Register a new function.  */
>     void add_function (function_info *fn);
>
> +  /* Debug the source file.  */
> +  void debug ();
> +
>     /* Index of the source_info in sources vector.  */
>     unsigned index;
>
> @@ -428,6 +431,31 @@ source_info::get_functions_at_location (unsigned 
> line_num) const
>     return slot;
>   }
>
> +void source_info::debug ()
> +{
> +  fprintf (stderr, "source_info: %s\n", name);
> +  for (vector<function_info *>::iterator it = functions.begin ();
> +       it != functions.end (); it++)
> +    {
> +      function_info *fn = *it;
> +      fprintf (stderr, "  function_info: %s\n", fn->get_name ());
> +      for (vector<block_info>::iterator bit = fn->blocks.begin ();
> +          bit != fn->blocks.end (); bit++)
> +       {
> +         fprintf (stderr, "    block_info id=%d, count=%ld\n",
> +                  bit->id, bit->count);
> +       }
> +    }
> +
> +  for (unsigned lineno = 1; lineno < lines.size (); ++lineno)
> +    {
> +      line_info &line = lines[lineno];
> +      fprintf (stderr, "  line_info=%d, count=%ld\n", lineno, line.count);
> +    }
> +
> +  fprintf (stderr, "\n");
> +}
> +

This breaks build on 32-bit hosts:

https://gcc.gnu.org/pipermail/gcc-regression/2021-January/074130.html

-- 
H.J.

Reply via email to