This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add new debug_bb_range debugging function


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]