From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 121BD3857C52 for ; Thu, 24 Sep 2020 15:52:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 121BD3857C52 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=hubicka@kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 766FE2829AE; Thu, 24 Sep 2020 17:52:40 +0200 (CEST) Date: Thu, 24 Sep 2020 17:52:40 +0200 From: Jan Hubicka To: Martin =?iso-8859-2?Q?Li=B9ka?= Cc: gcc-patches@gcc.gnu.org, Martin Jambor Subject: Re: [PATCH] Add cgraph_edge::debug function. Message-ID: <20200924155240.GC81257@kam.mff.cuni.cz> References: <6ac4094f-ac0a-f128-9594-e8470f2503f9@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6ac4094f-ac0a-f128-9594-e8470f2503f9@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-15.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2020 15:52:44 -0000 > 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 >