Add debug helpers for auto_bitmap.

Message ID 20211014071417.205211-1-aldyh@redhat.com
State Committed
Commit 3d0a7271b383c95d5c8dc9647966517a61e71abb
Headers
Series Add debug helpers for auto_bitmap. |

Commit Message

Aldy Hernandez Oct. 14, 2021, 7:14 a.m. UTC
  Using debug() on an auto_bitmap from gdb doesn't work because the
implicit conversion from auto_bitmap to bitmap_head doesn't work
from within a debugging session.  This patch adds the convenience
functions for auto_bitmap.

OK?

---
 gcc/bitmap.c | 12 ++++++++++++
 gcc/bitmap.h |  3 +++
 2 files changed, 15 insertions(+)
  

Comments

Richard Sandiford Oct. 14, 2021, 8:16 a.m. UTC | #1
Aldy Hernandez via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> Using debug() on an auto_bitmap from gdb doesn't work because the
> implicit conversion from auto_bitmap to bitmap_head doesn't work
> from within a debugging session.  This patch adds the convenience
> functions for auto_bitmap.
>
> OK?

OK, thanks.

Richard

> ---
>  gcc/bitmap.c | 12 ++++++++++++
>  gcc/bitmap.h |  3 +++
>  2 files changed, 15 insertions(+)
>
> diff --git a/gcc/bitmap.c b/gcc/bitmap.c
> index b915fdfbb54..98c6d0b9e05 100644
> --- a/gcc/bitmap.c
> +++ b/gcc/bitmap.c
> @@ -2830,6 +2830,18 @@ debug (const bitmap_head *ptr)
>      fprintf (stderr, "<nil>\n");
>  }
>  
> +DEBUG_FUNCTION void
> +debug (const auto_bitmap &ref)
> +{
> +  debug ((const bitmap_head &) ref);
> +}
> +
> +DEBUG_FUNCTION void
> +debug (const auto_bitmap *ptr)
> +{
> +  debug ((const bitmap_head *) ptr);
> +}
> +
>  void
>  bitmap_head::dump ()
>  {
> diff --git a/gcc/bitmap.h b/gcc/bitmap.h
> index 0846f79665d..1bddcdbfaee 100644
> --- a/gcc/bitmap.h
> +++ b/gcc/bitmap.h
> @@ -964,6 +964,9 @@ class auto_bitmap
>    bitmap_head m_bits;
>  };
>  
> +extern void debug (const auto_bitmap &ref);
> +extern void debug (const auto_bitmap *ptr);
> +
>  /* Base class for bitmap_view; see there for details.  */
>  template<typename T, typename Traits = array_traits<T> >
>  class base_bitmap_view
  

Patch

diff --git a/gcc/bitmap.c b/gcc/bitmap.c
index b915fdfbb54..98c6d0b9e05 100644
--- a/gcc/bitmap.c
+++ b/gcc/bitmap.c
@@ -2830,6 +2830,18 @@  debug (const bitmap_head *ptr)
     fprintf (stderr, "<nil>\n");
 }
 
+DEBUG_FUNCTION void
+debug (const auto_bitmap &ref)
+{
+  debug ((const bitmap_head &) ref);
+}
+
+DEBUG_FUNCTION void
+debug (const auto_bitmap *ptr)
+{
+  debug ((const bitmap_head *) ptr);
+}
+
 void
 bitmap_head::dump ()
 {
diff --git a/gcc/bitmap.h b/gcc/bitmap.h
index 0846f79665d..1bddcdbfaee 100644
--- a/gcc/bitmap.h
+++ b/gcc/bitmap.h
@@ -964,6 +964,9 @@  class auto_bitmap
   bitmap_head m_bits;
 };
 
+extern void debug (const auto_bitmap &ref);
+extern void debug (const auto_bitmap *ptr);
+
 /* Base class for bitmap_view; see there for details.  */
 template<typename T, typename Traits = array_traits<T> >
 class base_bitmap_view