Re: [PATCH v5 1/5] gdb: make gdbarch store a vector of frame unwinders

Thiago Jung Bauermann
2024-10-02T21:49:57Z

Hello Guinevere,

Just a couple of nits. Regardless:

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>

Guinevere Larsen <guinevere@redhat.com> writes:

> diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
> index e5f108d3257..b69ae8596a2 100644
> --- a/gdb/frame-unwind.c
> +++ b/gdb/frame-unwind.c
> @@ -31,62 +31,46 @@
> #include "cli/cli-cmds.h"
> #include "inferior.h"
>
> -struct frame_unwind_table_entry
> +/* Default sniffers, that must always be the first in the unwinder list,
> + no matter the architecture. */
> +static constexpr auto standard_unwinders =
> {
> - const struct frame_unwind *unwinder;
> - struct frame_unwind_table_entry *next;
> -};
> + &dummy_frame_unwind,
> + /* The DWARF tailcall sniffer must come before the inline sniffer.
> + Otherwise, we can end up in a situation where a DWARF frame finds
> + tailcall information, but then the inline sniffer claims a frame
> + before the tailcall sniffer, resulting in confusion. This is
> + safe to do always because the tailcall sniffer can only ever be
> + activated if the newer frame was created using the DWARF
> + unwinder, and it also found tailcall information. */
> + &dwarf2_tailcall_frame_unwind,
> + &inline_frame_unwind,
>

Nit: this empty line should be removed.

> -struct frame_unwind_table
> -{
> - struct frame_unwind_table_entry *list = nullptr;
> - /* The head of the OSABI part of the search list. */
> - struct frame_unwind_table_entry **osabi_head = nullptr;
> };

> @@ -355,11 +327,10 @@ maintenance_info_frame_unwinders (const char *args, int from_tty)
> uiout->table_header (25, ui_left, "type", "Type");
> uiout->table_body ();
>
> - for (struct frame_unwind_table_entry *entry = table->list; entry != NULL;
> - entry = entry->next)
> + for (auto unwinder : table)
> {
> - const char *name = entry->unwinder->name;
> - const char *type = frame_type_str (entry->unwinder->type);
> + const char *name = unwinder->name;
> + const char *type = frame_type_str (unwinder->type);

Did you try getting rid of the local vars here, as Simon suggested?
I agree with him that seem unnecessary.

> ui_out_emit_list tuple_emitter (uiout, nullptr);
> uiout->field_string ("name", name);

--
Thiago