From ba380b3e5162e89c4c81a73f4fb9fcbbbbe75e24 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 25 Jul 2022 14:06:34 -0300 Subject: Introduce frame_info_ptr smart pointer class This adds frame_info_ptr, a smart pointer class. Every instance of the class is kept on an intrusive list. When reinit_frame_cache is called, the list is traversed and all the pointers are invalidated. This should help catch the typical GDB bug of keeping a frame_info pointer alive where a frame ID was needed instead. Co-Authored-By: Bruno Larsen Approved-by: Tom Tomey --- gdb/frame.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gdb/frame.c') diff --git a/gdb/frame.c b/gdb/frame.c index 8df5feb..44cb529 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -56,6 +56,9 @@ static struct frame_info *sentinel_frame; /* Number of calls to reinit_frame_cache. */ static unsigned int frame_cache_generation = 0; +/* See frame-info.h. */ +intrusive_list frame_info_ptr::frame_list; + /* See frame.h. */ unsigned int @@ -2006,6 +2009,9 @@ reinit_frame_cache (void) select_frame (NULL); frame_stash_invalidate (); + for (frame_info_ptr &iter : frame_info_ptr::frame_list) + iter.invalidate (); + frame_debug_printf ("generation=%d", frame_cache_generation); } -- cgit v1.1