gdb: make frame_info_ptr auto-reinflatable

This is the second step of making frame_info_ptr automatic, reinflate on
demand whenever trying to obtain the wrapper frame_info pointer, either
through the get method or operator->.  Make the reinflate method
private, it is used as a convenience method in those two.

Add an "is_null" method, because it is often needed to know whether the
frame_info_ptr wraps an frame_info or is empty.

Make m_ptr mutable, so that it's possible to reinflate const
frame_info_ptr objects.  Whether m_ptr is nullptr or not does not change
the logical state of the object, because we re-create it on demand.  I
believe this is the right use case for mutable.

Change-Id: Icb0552d0035e227f81eb3c121d8a9bb2f9d25794
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
This commit is contained in:
Simon Marchi
2022-12-13 22:34:41 -05:00
parent 93e39555dd
commit 908de5e671
7 changed files with 36 additions and 28 deletions

View File

@@ -3224,8 +3224,8 @@ frame_info_ptr::frame_info_ptr (struct frame_info *ptr)
/* See frame-info-ptr.h. */
void
frame_info_ptr::reinflate ()
frame_info *
frame_info_ptr::reinflate () const
{
/* Ensure we have a valid frame level (sentinel frame or above). */
gdb_assert (m_cached_level >= -1);
@@ -3233,7 +3233,7 @@ frame_info_ptr::reinflate ()
if (m_ptr != nullptr)
{
/* The frame_info wasn't invalidated, no need to reinflate. */
return;
return m_ptr;
}
if (m_cached_id.user_created_p)
@@ -3255,6 +3255,7 @@ frame_info_ptr::reinflate ()
}
gdb_assert (m_ptr != nullptr);
return m_ptr;
}
void _initialize_frame ();