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