From 1239e7cf37336d69931a656290c25a5d5455b9cc Mon Sep 17 00:00:00 2001 From: Guinevere Larsen Date: Thu, 14 Mar 2024 16:14:27 +0100 Subject: gdb: Migrate frame unwinders to use C++ classes Frame unwinders have historically been a structure populated with callback pointers, so that architectures (or other specific unwinders) could install their own way to handle the inferior. However, since moving to C++, we could use polymorphism to get the same functionality in a more readable way. Polymorphism also makes it simpler to add new functionality to all frame unwinders, since all that's required is adding it to the base class. As part of the changes to add support to disabling frame unwinders, this commit makes the first baby step in using polymorphism for the frame unwinders, by making frame_unwind a virtual class, and adds a couple of new classes. The main class added is frame_unwind_legacy, which works the same as the previous structs, using function pointers as callbacks. This class was added to allow the transition to happen piecemeal. New unwinders should instead follow the lead of the other classes implemented. 2 of the others, frame_unwind_python and frame_unwind_trampoline, were added because it seemed simpler at the moment to do that instead of reworking the dynamic allocation to work with the legacy class, and can be used as an example to future implementations. Finally, the cygwin unwinder was converted to a class since it was most of the way there already. Reviewed-by: Thiago Jung Bauermann Approved-By: Simon Marchi Approved-By: Andrew Burgess --- gdb/sentinel-frame.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'gdb/sentinel-frame.c') diff --git a/gdb/sentinel-frame.c b/gdb/sentinel-frame.c index 9fe4036..c809259 100644 --- a/gdb/sentinel-frame.c +++ b/gdb/sentinel-frame.c @@ -78,8 +78,7 @@ sentinel_frame_prev_arch (const frame_info_ptr &this_frame, return cache->regcache->arch (); } -const struct frame_unwind sentinel_frame_unwind = -{ +const struct frame_unwind_legacy sentinel_frame_unwind ( "sentinel", SENTINEL_FRAME, FRAME_UNWIND_GDB, @@ -89,5 +88,5 @@ const struct frame_unwind sentinel_frame_unwind = NULL, NULL, NULL, - sentinel_frame_prev_arch, -}; + sentinel_frame_prev_arch +); -- cgit v1.1