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 <thiago.bauermann@linaro.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
Guinevere Larsen
2024-03-14 16:14:27 +01:00
parent ce36ef63aa
commit 1239e7cf37
87 changed files with 553 additions and 402 deletions

View File

@@ -1112,8 +1112,7 @@ jit_frame_prev_register (const frame_info_ptr &this_frame, void **cache, int reg
/* Relay everything back to the unwinder registered by the JIT debug
info reader.*/
static const struct frame_unwind jit_frame_unwind =
{
static const struct frame_unwind_legacy jit_frame_unwind (
"jit",
NORMAL_FRAME,
FRAME_UNWIND_EXTENSION,
@@ -1123,7 +1122,7 @@ static const struct frame_unwind jit_frame_unwind =
NULL,
jit_frame_sniffer,
jit_dealloc_cache
};
);
/* This is the information that is stored at jit_gdbarch_data for each