aboutsummaryrefslogtreecommitdiff
path: root/gcc/vec.h
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2017-11-20 08:32:57 +0000
committerAldy Hernandez <aldyh@gcc.gnu.org>2017-11-20 08:32:57 +0000
commit19a30b7123aa90caf7de3e9ec588266e218f8028 (patch)
tree32e5e7fae29ce15cabb6a27c2982ccabef10c491 /gcc/vec.h
parent7cfaa4c643eabd8d5aaa74a8406f0bf4880b8fe6 (diff)
downloadgcc-19a30b7123aa90caf7de3e9ec588266e218f8028.zip
gcc-19a30b7123aa90caf7de3e9ec588266e218f8028.tar.gz
gcc-19a30b7123aa90caf7de3e9ec588266e218f8028.tar.bz2
vec.h (debug_helper): New function.
* vec.h (debug_helper): New function. (DEFINE_DEBUG_VEC): New macro. * hash-set.h (debug_helper): New function. (DEFINE_DEBUG_HASH_SET): New macro. * cfg.c (debug_slim (edge)): New function. Call DEFINE_DEBUG_VEC for edges. Call DEFINE_DEBUG_HASH_SET for edges. * cfghooks.c (debug_slim (basic_block)): New function. Call DEFINE_DEBUG_VEC for basic blocks. Call DEFINE_DEBUG_HASH_SET for basic blocks. * print-tree.c (debug_slim): New function to handle trees. Call DEFINE_DEBUG_VEC for trees. Call DEFINE_DEBUG_HASH_SET for trees. (debug (vec<tree, va_gc>) &): Remove. (debug (<vec<tree, va_gc>) *): Remove. * print-rtl.c (debug_slim): New function to handle const_rtx. Call DEFINE_DEBUG_VEC for rtx_def. Call DEFINE_DEBUG_VEC for rtx_insn. Call DEFINE_DEBUG_HASH_SET for rtx_def. Call DEFINE_DEBUG_HASH_SET for rtx_insn. * sel-sched-dump.c (debug (vec<rtx_insn *> &): Remove. (debug (vec<rtx_insn *> *ptr): Remove. (debug_insn_vector): Remove. * stor-layout.c (debug_rli): Call debug() instead of debug_vec_tree. From-SVN: r254945
Diffstat (limited to 'gcc/vec.h')
-rw-r--r--gcc/vec.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/gcc/vec.h b/gcc/vec.h
index cbdd439..b145eef 100644
--- a/gcc/vec.h
+++ b/gcc/vec.h
@@ -407,6 +407,83 @@ struct GTY((user)) vec
{
};
+/* Generic vec<> debug helpers.
+
+ These need to be instantiated for each vec<TYPE> used throughout
+ the compiler like this:
+
+ DEFINE_DEBUG_VEC (TYPE)
+
+ The reason we have a debug_helper() is because GDB can't
+ disambiguate a plain call to debug(some_vec), and it must be called
+ like debug<TYPE>(some_vec). */
+
+template<typename T>
+void
+debug_helper (vec<T> &ref)
+{
+ unsigned i;
+ for (i = 0; i < ref.length (); ++i)
+ {
+ fprintf (stderr, "[%d] = ", i);
+ debug_slim (ref[i]);
+ fputc ('\n', stderr);
+ }
+}
+
+/* We need a separate va_gc variant here because default template
+ argument for functions cannot be used in c++-98. Once this
+ restriction is removed, those variant should be folded with the
+ above debug_helper. */
+
+template<typename T>
+void
+debug_helper (vec<T, va_gc> &ref)
+{
+ unsigned i;
+ for (i = 0; i < ref.length (); ++i)
+ {
+ fprintf (stderr, "[%d] = ", i);
+ debug_slim (ref[i]);
+ fputc ('\n', stderr);
+ }
+}
+
+/* Macro to define debug(vec<T>) and debug(vec<T, va_gc>) helper
+ functions for a type T. */
+
+#define DEFINE_DEBUG_VEC(T) \
+ template static void debug_helper (vec<T> &); \
+ template static void debug_helper (vec<T, va_gc> &); \
+ /* Define the vec<T> debug functions. */ \
+ DEBUG_FUNCTION void \
+ debug (vec<T> &ref) \
+ { \
+ debug_helper <T> (ref); \
+ } \
+ DEBUG_FUNCTION void \
+ debug (vec<T> *ptr) \
+ { \
+ if (ptr) \
+ debug (*ptr); \
+ else \
+ fprintf (stderr, "<nil>\n"); \
+ } \
+ /* Define the vec<T, va_gc> debug functions. */ \
+ DEBUG_FUNCTION void \
+ debug (vec<T, va_gc> &ref) \
+ { \
+ debug_helper <T> (ref); \
+ } \
+ DEBUG_FUNCTION void \
+ debug (vec<T, va_gc> *ptr) \
+ { \
+ if (ptr) \
+ debug (*ptr); \
+ else \
+ fprintf (stderr, "<nil>\n"); \
+ }
+
/* Default-construct N elements in DST. */
template <typename T>