From 43e8c9ce20357a12dc5ccaf9ac84eea2cb6aa39b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 3 Jan 2023 12:48:48 -0500 Subject: gdb: move frame_info_ptr to frame.{c,h} A patch later in this series will make frame_info_ptr access some fields internal to frame_info, which we don't want to expose outside of frame.c. Move the frame_info_ptr class to frame.h, and the definitions to frame.c. Remove frame-info.c and frame-info.h. Change-Id: Ic5949759e6262ea0da6123858702d48fe5673fea Reviewed-By: Bruno Larsen --- gdb/frame.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'gdb/frame.c') diff --git a/gdb/frame.c b/gdb/frame.c index 2f9622a..b5f4839 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -19,7 +19,6 @@ #include "defs.h" #include "frame.h" -#include "frame-info.h" #include "target.h" #include "value.h" #include "inferior.h" /* for inferior_ptid */ @@ -3161,6 +3160,48 @@ maintenance_print_frame_id (const char *args, int from_tty) get_frame_id (frame).to_string ().c_str ()); } +/* See frame-info-ptr.h. */ + +intrusive_list frame_info_ptr::frame_list; + +/* See frame-info-ptr.h. */ + +void +frame_info_ptr::prepare_reinflate () +{ + m_cached_level = frame_relative_level (*this); + + if (m_cached_level != 0) + m_cached_id = get_frame_id (*this); +} + +/* See frame-info-ptr.h. */ + +void +frame_info_ptr::reinflate () +{ + /* 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 (); + } + + gdb_assert (m_ptr != nullptr); +} + void _initialize_frame (); void _initialize_frame () -- cgit v1.1