1*6881a400Schristos /* Frame info pointer 2*6881a400Schristos 3*6881a400Schristos Copyright (C) 2022-2023 Free Software Foundation, Inc. 4*6881a400Schristos 5*6881a400Schristos This file is part of GDB. 6*6881a400Schristos 7*6881a400Schristos This program is free software; you can redistribute it and/or modify 8*6881a400Schristos it under the terms of the GNU General Public License as published by 9*6881a400Schristos the Free Software Foundation; either version 3 of the License, or 10*6881a400Schristos (at your option) any later version. 11*6881a400Schristos 12*6881a400Schristos This program is distributed in the hope that it will be useful, 13*6881a400Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 14*6881a400Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*6881a400Schristos GNU General Public License for more details. 16*6881a400Schristos 17*6881a400Schristos You should have received a copy of the GNU General Public License 18*6881a400Schristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19*6881a400Schristos 20*6881a400Schristos #include "defs.h" 21*6881a400Schristos 22*6881a400Schristos #include "frame-info.h" 23*6881a400Schristos #include "frame.h" 24*6881a400Schristos 25*6881a400Schristos /* See frame-info-ptr.h. */ 26*6881a400Schristos 27*6881a400Schristos intrusive_list<frame_info_ptr> frame_info_ptr::frame_list; 28*6881a400Schristos 29*6881a400Schristos /* See frame-info-ptr.h. */ 30*6881a400Schristos 31*6881a400Schristos void 32*6881a400Schristos frame_info_ptr::prepare_reinflate () 33*6881a400Schristos { 34*6881a400Schristos m_cached_level = frame_relative_level (*this); 35*6881a400Schristos 36*6881a400Schristos if (m_cached_level != 0) 37*6881a400Schristos m_cached_id = get_frame_id (*this); 38*6881a400Schristos } 39*6881a400Schristos 40*6881a400Schristos /* See frame-info-ptr.h. */ 41*6881a400Schristos 42*6881a400Schristos void 43*6881a400Schristos frame_info_ptr::reinflate () 44*6881a400Schristos { 45*6881a400Schristos /* Ensure we have a valid frame level (sentinel frame or above), indicating 46*6881a400Schristos prepare_reinflate was called. */ 47*6881a400Schristos gdb_assert (m_cached_level >= -1); 48*6881a400Schristos 49*6881a400Schristos if (m_ptr != nullptr) 50*6881a400Schristos { 51*6881a400Schristos /* The frame_info wasn't invalidated, no need to reinflate. */ 52*6881a400Schristos return; 53*6881a400Schristos } 54*6881a400Schristos 55*6881a400Schristos /* Frame #0 needs special handling, see comment in select_frame. */ 56*6881a400Schristos if (m_cached_level == 0) 57*6881a400Schristos m_ptr = get_current_frame ().get (); 58*6881a400Schristos else 59*6881a400Schristos { 60*6881a400Schristos gdb_assert (frame_id_p (m_cached_id)); 61*6881a400Schristos m_ptr = frame_find_by_id (m_cached_id).get (); 62*6881a400Schristos } 63*6881a400Schristos 64*6881a400Schristos gdb_assert (m_ptr != nullptr); 65*6881a400Schristos } 66