aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorGuinevere Larsen <guinevere@redhat.com>2024-03-14 16:14:27 +0100
committerGuinevere Larsen <guinevere@redhat.com>2025-01-17 11:49:16 -0300
commit1239e7cf37336d69931a656290c25a5d5455b9cc (patch)
treeb2b7d26d4df99d17acd7e8cff1649347392e6f6f /gdb/dwarf2
parentce36ef63aa74c30016334db0f6a4638d1ffe7256 (diff)
downloadgdb-1239e7cf37336d69931a656290c25a5d5455b9cc.zip
gdb-1239e7cf37336d69931a656290c25a5d5455b9cc.tar.gz
gdb-1239e7cf37336d69931a656290c25a5d5455b9cc.tar.bz2
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>
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/frame-tailcall.c5
-rw-r--r--gdb/dwarf2/frame-tailcall.h2
-rw-r--r--gdb/dwarf2/frame.c14
3 files changed, 9 insertions, 12 deletions
diff --git a/gdb/dwarf2/frame-tailcall.c b/gdb/dwarf2/frame-tailcall.c
index 50efd4e..54813d0 100644
--- a/gdb/dwarf2/frame-tailcall.c
+++ b/gdb/dwarf2/frame-tailcall.c
@@ -468,8 +468,7 @@ tailcall_frame_prev_arch (const frame_info_ptr &this_frame,
/* Virtual tail call frame unwinder if dwarf2_tailcall_sniffer_first finds
a chain to create. */
-const struct frame_unwind dwarf2_tailcall_frame_unwind =
-{
+const struct frame_unwind_legacy dwarf2_tailcall_frame_unwind (
"dwarf2 tailcall",
TAILCALL_FRAME,
FRAME_UNWIND_DEBUGINFO,
@@ -480,7 +479,7 @@ const struct frame_unwind dwarf2_tailcall_frame_unwind =
tailcall_frame_sniffer,
tailcall_frame_dealloc_cache,
tailcall_frame_prev_arch
-};
+);
void _initialize_tailcall_frame ();
void
diff --git a/gdb/dwarf2/frame-tailcall.h b/gdb/dwarf2/frame-tailcall.h
index 558957e..e830261 100644
--- a/gdb/dwarf2/frame-tailcall.h
+++ b/gdb/dwarf2/frame-tailcall.h
@@ -34,6 +34,6 @@ extern struct value *
dwarf2_tailcall_prev_register_first (const frame_info_ptr &this_frame,
void **tailcall_cachep, int regnum);
-extern const struct frame_unwind dwarf2_tailcall_frame_unwind;
+extern const struct frame_unwind_legacy dwarf2_tailcall_frame_unwind;
#endif /* GDB_DWARF2_FRAME_TAILCALL_H */
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 492b692..85e1d59 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -1329,16 +1329,15 @@ dwarf2_frame_sniffer (const struct frame_unwind *self,
if (fde->cie->signal_frame
|| dwarf2_frame_signal_frame_p (get_frame_arch (this_frame),
this_frame))
- return self->type == SIGTRAMP_FRAME;
+ return self->type () == SIGTRAMP_FRAME;
- if (self->type != NORMAL_FRAME)
+ if (self->type () != NORMAL_FRAME)
return 0;
return 1;
}
-static const struct frame_unwind dwarf2_frame_unwind =
-{
+static const struct frame_unwind_legacy dwarf2_frame_unwind (
"dwarf2",
NORMAL_FRAME,
FRAME_UNWIND_DEBUGINFO,
@@ -1348,10 +1347,9 @@ static const struct frame_unwind dwarf2_frame_unwind =
NULL,
dwarf2_frame_sniffer,
dwarf2_frame_dealloc_cache
-};
+);
-static const struct frame_unwind dwarf2_signal_frame_unwind =
-{
+static const struct frame_unwind_legacy dwarf2_signal_frame_unwind (
"dwarf2 signal",
SIGTRAMP_FRAME,
FRAME_UNWIND_DEBUGINFO,
@@ -1363,7 +1361,7 @@ static const struct frame_unwind dwarf2_signal_frame_unwind =
/* TAILCALL_CACHE can never be in such frame to need dealloc_cache. */
NULL
-};
+);
/* Append the DWARF-2 frame unwinders to GDBARCH's list. */