public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add new debug_bb_range debugging function
@ 2013-02-16  9:40 Dodji Seketeli
  2013-02-16  9:58 ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Dodji Seketeli @ 2013-02-16  9:40 UTC (permalink / raw)
  To: Jakub Jelinek, Richard Biener; +Cc: GCC Patches

Hello,

In my first foray of debugging gimple stuff, I felt the need for a
function function to dump a range of basic block from number N to P to
stderr.  I find this a bit more handy than calling debug_bb_n on each
basic block instead.

I understand this is material for 4.9, so if you agree I'll stage it in
my queue of patches for when stage1 opens.

Is this OK, or is there a function that does this already (or something
else :))?

Thanks.

Tested on x86_64-unknown-linux-gnu against trunk.

gcc/

	* basic-block.h (debug_bb_range): Declare ...
	* cfg.c (debug_bb_range): ... new function.
---
 gcc/basic-block.h |  1 +
 gcc/cfg.c         | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index 90eb57b..8407c4a 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -752,6 +752,7 @@ extern bool predictable_edge_p (edge);
 extern void init_flow (struct function *);
 extern void debug_bb (basic_block);
 extern basic_block debug_bb_n (int);
+extern basic_block debug_bb_range (int, int);
 extern void dump_flow_info (FILE *, int);
 extern void expunge_block (basic_block);
 extern void link_block (basic_block, basic_block);
diff --git a/gcc/cfg.c b/gcc/cfg.c
index 9e4380c..d34f27e 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -663,6 +663,21 @@ debug_bb_n (int n)
   return bb;
 }
 
+/* Dumps cfg related information about basic blocks, from number 'S'
+   to number E, to stderr.  */
+
+DEBUG_FUNCTION basic_block
+debug_bb_range (int s, int e)
+{
+  basic_block bb =  NULL;
+  for (int i = s; i <= e; ++i)
+    {
+      bb = BASIC_BLOCK (i);
+      debug_bb (bb);
+    }
+  return bb;
+}
+
 /* Dumps cfg related information about basic block BB to OUTF.
    If HEADER is true, dump things that appear before the instructions
    contained in BB.  If FOOTER is true, dump things that appear after.
-- 
		Dodji

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add new debug_bb_range debugging function
  2013-02-16  9:40 [PATCH] Add new debug_bb_range debugging function Dodji Seketeli
@ 2013-02-16  9:58 ` Jakub Jelinek
  2013-02-16 10:08   ` Dodji Seketeli
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2013-02-16  9:58 UTC (permalink / raw)
  To: Dodji Seketeli; +Cc: Richard Biener, GCC Patches

On Sat, Feb 16, 2013 at 10:40:43AM +0100, Dodji Seketeli wrote:
> --- a/gcc/cfg.c
> +++ b/gcc/cfg.c
> @@ -663,6 +663,21 @@ debug_bb_n (int n)
>    return bb;
>  }
>  
> +/* Dumps cfg related information about basic blocks, from number 'S'
> +   to number E, to stderr.  */
> +
> +DEBUG_FUNCTION basic_block
> +debug_bb_range (int s, int e)
> +{
> +  basic_block bb =  NULL;
> +  for (int i = s; i <= e; ++i)
> +    {
> +      bb = BASIC_BLOCK (i);
> +      debug_bb (bb);

At some points after cfg changes, but before cfg cleanup there might be
gaps, so I think you want if (bb) debug_bb (bb);, otherwise it could crash
in that case.

	Jakub

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add new debug_bb_range debugging function
  2013-02-16  9:58 ` Jakub Jelinek
@ 2013-02-16 10:08   ` Dodji Seketeli
  2013-02-18  9:03     ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Dodji Seketeli @ 2013-02-16 10:08 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Richard Biener, GCC Patches

Jakub Jelinek <jakub@redhat.com> writes:

> On Sat, Feb 16, 2013 at 10:40:43AM +0100, Dodji Seketeli wrote:
>> --- a/gcc/cfg.c
>> +++ b/gcc/cfg.c
>> @@ -663,6 +663,21 @@ debug_bb_n (int n)
>>    return bb;
>>  }
>>  
>> +/* Dumps cfg related information about basic blocks, from number 'S'
>> +   to number E, to stderr.  */
>> +
>> +DEBUG_FUNCTION basic_block
>> +debug_bb_range (int s, int e)
>> +{
>> +  basic_block bb =  NULL;
>> +  for (int i = s; i <= e; ++i)
>> +    {
>> +      bb = BASIC_BLOCK (i);
>> +      debug_bb (bb);
>
> At some points after cfg changes, but before cfg cleanup there might be
> gaps, so I think you want if (bb) debug_bb (bb);, otherwise it could crash
> in that case.

Right.  I have updated the patch below for that and also to ensure that
we don't try to access a basic block with number >= last_basic_block.

Thanks.

gcc/

	* basic-block.h (debug_bb_range): Declare ...
	* cfg.c (debug_bb_range): ... new function.
---
 gcc/basic-block.h |  1 +
 gcc/cfg.c         | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index 90eb57b..8407c4a 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -752,6 +752,7 @@ extern bool predictable_edge_p (edge);
 extern void init_flow (struct function *);
 extern void debug_bb (basic_block);
 extern basic_block debug_bb_n (int);
+extern basic_block debug_bb_range (int, int);
 extern void dump_flow_info (FILE *, int);
 extern void expunge_block (basic_block);
 extern void link_block (basic_block, basic_block);
diff --git a/gcc/cfg.c b/gcc/cfg.c
index 9e4380c..d72e075 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -663,6 +663,22 @@ debug_bb_n (int n)
   return bb;
 }
 
+/* Dumps cfg related information about basic blocks, from number 'S'
+   to number E, to stderr.  */
+
+DEBUG_FUNCTION basic_block
+debug_bb_range (int s, int e)
+{
+  basic_block bb =  NULL;
+  for (int i = s; i <= e && i < last_basic_block; ++i)
+    {
+      bb = BASIC_BLOCK (i);
+      if (bb)
+	debug_bb (bb);
+    }
+  return bb;
+}
+
 /* Dumps cfg related information about basic block BB to OUTF.
    If HEADER is true, dump things that appear before the instructions
    contained in BB.  If FOOTER is true, dump things that appear after.
-- 
1.8.1



-- 
		Dodji

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add new debug_bb_range debugging function
  2013-02-16 10:08   ` Dodji Seketeli
@ 2013-02-18  9:03     ` Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2013-02-18  9:03 UTC (permalink / raw)
  To: Dodji Seketeli; +Cc: Jakub Jelinek, GCC Patches

On Sat, 16 Feb 2013, Dodji Seketeli wrote:

> Jakub Jelinek <jakub@redhat.com> writes:
> 
> > On Sat, Feb 16, 2013 at 10:40:43AM +0100, Dodji Seketeli wrote:
> >> --- a/gcc/cfg.c
> >> +++ b/gcc/cfg.c
> >> @@ -663,6 +663,21 @@ debug_bb_n (int n)
> >>    return bb;
> >>  }
> >>  
> >> +/* Dumps cfg related information about basic blocks, from number 'S'
> >> +   to number E, to stderr.  */
> >> +
> >> +DEBUG_FUNCTION basic_block
> >> +debug_bb_range (int s, int e)
> >> +{
> >> +  basic_block bb =  NULL;
> >> +  for (int i = s; i <= e; ++i)
> >> +    {
> >> +      bb = BASIC_BLOCK (i);
> >> +      debug_bb (bb);
> >
> > At some points after cfg changes, but before cfg cleanup there might be
> > gaps, so I think you want if (bb) debug_bb (bb);, otherwise it could crash
> > in that case.
> 
> Right.  I have updated the patch below for that and also to ensure that
> we don't try to access a basic block with number >= last_basic_block.

Can you try adding a gdb python thingie instead?  Just for my
own education?

;)

Thanks,
Richard.

> Thanks.
> 
> gcc/
> 
> 	* basic-block.h (debug_bb_range): Declare ...
> 	* cfg.c (debug_bb_range): ... new function.
> ---
>  gcc/basic-block.h |  1 +
>  gcc/cfg.c         | 16 ++++++++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/gcc/basic-block.h b/gcc/basic-block.h
> index 90eb57b..8407c4a 100644
> --- a/gcc/basic-block.h
> +++ b/gcc/basic-block.h
> @@ -752,6 +752,7 @@ extern bool predictable_edge_p (edge);
>  extern void init_flow (struct function *);
>  extern void debug_bb (basic_block);
>  extern basic_block debug_bb_n (int);
> +extern basic_block debug_bb_range (int, int);
>  extern void dump_flow_info (FILE *, int);
>  extern void expunge_block (basic_block);
>  extern void link_block (basic_block, basic_block);
> diff --git a/gcc/cfg.c b/gcc/cfg.c
> index 9e4380c..d72e075 100644
> --- a/gcc/cfg.c
> +++ b/gcc/cfg.c
> @@ -663,6 +663,22 @@ debug_bb_n (int n)
>    return bb;
>  }
>  
> +/* Dumps cfg related information about basic blocks, from number 'S'
> +   to number E, to stderr.  */
> +
> +DEBUG_FUNCTION basic_block
> +debug_bb_range (int s, int e)
> +{
> +  basic_block bb =  NULL;
> +  for (int i = s; i <= e && i < last_basic_block; ++i)
> +    {
> +      bb = BASIC_BLOCK (i);
> +      if (bb)
> +	debug_bb (bb);
> +    }
> +  return bb;
> +}
> +
>  /* Dumps cfg related information about basic block BB to OUTF.
>     If HEADER is true, dump things that appear before the instructions
>     contained in BB.  If FOOTER is true, dump things that appear after.
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-18  9:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-16  9:40 [PATCH] Add new debug_bb_range debugging function Dodji Seketeli
2013-02-16  9:58 ` Jakub Jelinek
2013-02-16 10:08   ` Dodji Seketeli
2013-02-18  9:03     ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).