diff options
Diffstat (limited to 'gdb/frame-info.c')
-rw-r--r-- | gdb/frame-info.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/gdb/frame-info.c b/gdb/frame-info.c index 584222d..40a872e 100644 --- a/gdb/frame-info.c +++ b/gdb/frame-info.c @@ -31,7 +31,10 @@ intrusive_list<frame_info_ptr> frame_info_ptr::frame_list; void frame_info_ptr::prepare_reinflate () { - m_cached_id = get_frame_id (*this); + m_cached_level = frame_relative_level (*this); + + if (m_cached_level != 0) + m_cached_id = get_frame_id (*this); } /* See frame-info-ptr.h. */ @@ -39,9 +42,24 @@ frame_info_ptr::prepare_reinflate () void frame_info_ptr::reinflate () { - gdb_assert (frame_id_p (m_cached_id)); + /* Ensure we have a valid frame level (sentinel frame or above), indicating + prepare_reinflate was called. */ + gdb_assert (m_cached_level >= -1); + + if (m_ptr != nullptr) + { + /* The frame_info wasn't invalidated, no need to reinflate. */ + return; + } + + /* Frame #0 needs special handling, see comment in select_frame. */ + if (m_cached_level == 0) + m_ptr = get_current_frame ().get (); + else + { + gdb_assert (frame_id_p (m_cached_id)); + m_ptr = frame_find_by_id (m_cached_id).get (); + } - if (m_ptr == nullptr) - m_ptr = frame_find_by_id (m_cached_id).get (); gdb_assert (m_ptr != nullptr); } |