> I see it handy to debug cgraph_edge and I've dumped it manually many times.
> Maybe it's time to come up with the function? Example output:
>
> (gdb) p e->debug()
> ag/9 -> h/3 (1 (adjusted),0.25 per call)
>
> ag/9 (ag) @0x7ffff773eca8
> Type: function definition analyzed
> Visibility: public
> next sharing asm name: 7
> References: table/5 (addr)
> Referring:
> Function ag/9 is inline copy in ap/4
> Clone of ag/7
> Availability: local
> Function flags: count:2 (adjusted) first_run:6 body local hot
> Called by: ai/8 (inlined) (indirect_inlining) (4 (adjusted),1.00 per call)
> Calls: h/3 (1 (adjusted),0.25 per call)
> h/3 (h) @0x7ffff772b438
> Type: function definition analyzed
> Visibility: externally_visible public
> References: ap/4 (addr)
> Referring:
> Availability: available
> Profile id: 1806506296
> Function flags: count:4 (precise) first_run:3 body hot
> Called by: ag/9 (1 (adjusted),0.25 per call) ag/7 (1 (adjusted),0.25 per
> call) ag/0 (2 (estimated locally, globally 0 adjusted),0.50 per call) bug/2
> (1 (precise),1.00 per call) bug/2 (1 (precise),1.00 per call)
> Calls: ai/1 (4 (precise),1.00 per call)
>
> (gdb) p ie->debug()
> ai/1 -> (null) (speculative) (0 (adjusted),0.00 per call)
>
> ai/1 (ai) @0x7ffff772b168
> Type: function definition analyzed
> Visibility: prevailing_def_ironly
> previous sharing asm name: 8
> References: table/5 (addr) ap/4 (addr) (speculative) ag/0 (addr)
> (speculative)
> Referring:
> Function ai/1 is inline copy in h/3
> Availability: local
> Profile id: 1923518911
> Function flags: count:4 (precise) first_run:4 body local hot
> Called by: h/3 (inlined) (4 (precise),1.00 per call)
> Calls: ag/7 (speculative) (inlined) (2 (adjusted),0.50 per call) ap/4
> (speculative) (2 (adjusted),0.50 per call) PyErr_Format/6 (0 (precise),0.00
> per call)
> Indirect call(speculative) (0 (adjusted),0.00 per call) of param:1 (vptr
> maybe changed) Num speculative call targets: 2
>
> Ready to be installed?
> Thanks,
> Martin
>
> gcc/ChangeLog:
>
> * cgraph.c (cgraph_edge::debug): New.
> * cgraph.h (cgraph_edge::debug): New.
OK,
Honza
> ---
> gcc/cgraph.c | 14 ++++++++++++++
> gcc/cgraph.h | 3 +++
> 2 files changed, 17 insertions(+)
>
> diff --git a/gcc/cgraph.c b/gcc/cgraph.c
> index b43adaac7c0..46c3b124b1a 100644
> --- a/gcc/cgraph.c
> +++ b/gcc/cgraph.c
> @@ -2072,6 +2072,20 @@ cgraph_edge::dump_edge_flags (FILE *f)
> fprintf (f, "(can throw external) ");
> }
> +/* Dump edge to stderr. */
> +
> +void
> +cgraph_edge::debug (void)
> +{
> + fprintf (stderr, "%s -> %s ", caller->dump_asm_name (),
> + callee == NULL ? "(null)" : callee->dump_asm_name ());
> + dump_edge_flags (stderr);
> + fprintf (stderr, "\n\n");
> + caller->debug ();
> + if (callee != NULL)
> + callee->debug ();
> +}
> +
> /* Dump call graph node to file F. */
> void
> diff --git a/gcc/cgraph.h b/gcc/cgraph.h
> index 0211f08964f..96d6cf609fe 100644
> --- a/gcc/cgraph.h
> +++ b/gcc/cgraph.h
> @@ -2022,6 +2022,9 @@ private:
> /* Output flags of edge to a file F. */
> void dump_edge_flags (FILE *f);
> + /* Dump edge to stderr. */
> + void DEBUG_FUNCTION debug (void);
> +
> /* Verify that call graph edge corresponds to DECL from the associated
> statement. Return true if the verification should fail. */
> bool verify_corresponds_to_fndecl (tree decl);
> --
> 2.28.0
>