Re: [patch v8 15/24] frame, backtrace: allow targets to supply a frame unwinder

Pedro Alves
2013-12-13T18:27:38Z

On 12/12/2013 09:15 AM, Markus Metzger wrote:
> Allow targets to supply their own target-specific frame unwinders; one for
> normal frames and one for tailcall frames. If a target-specific unwinder
> is supplied, it will be chosen before any other unwinder.

These ...

>
> diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
> index c4f8771..4efa7d8 100644
> --- a/gdb/dwarf2-frame.c
> +++ b/gdb/dwarf2-frame.c
> @@ -1513,16 +1513,16 @@ dwarf2_frame_cfa (struct frame_info *this_frame)
> {
> while (get_frame_type (this_frame) == INLINE_FRAME)
> this_frame = get_prev_frame (this_frame);
> + if (get_frame_unwind_stop_reason (this_frame) == UNWIND_UNAVAILABLE)
> + throw_error (NOT_AVAILABLE_ERROR,
> + _("can't compute CFA for this frame: "
> + "required registers or memory are unavailable"));
> /* This restriction could be lifted if other unwinders are known to
> compute the frame base in a way compatible with the DWARF
> unwinder. */
> if (!frame_unwinder_is (this_frame, &dwarf2_frame_unwind)
> && !frame_unwinder_is (this_frame, &dwarf2_tailcall_frame_unwind))
> error (_("can't compute CFA for this frame"));
> - if (get_frame_unwind_stop_reason (this_frame) == UNWIND_UNAVAILABLE)
> - throw_error (NOT_AVAILABLE_ERROR,
> - _("can't compute CFA for this frame: "
> - "required registers or memory are unavailable"));
> return get_frame_base (this_frame);
> }

> diff --git a/gdb/frame.c b/gdb/frame.c
> index 37d780e..3f2aabb 100644
> --- a/gdb/frame.c
> +++ b/gdb/frame.c
> @@ -2507,13 +2507,10 @@ get_frame_sp (struct frame_info *this_frame)
> enum unwind_stop_reason
> get_frame_unwind_stop_reason (struct frame_info *frame)
> {
> - /* If we haven't tried to unwind past this point yet, then assume
> - that unwinding would succeed. */
> - if (frame->prev_p == 0)
> - return UNWIND_NO_REASON;
> + /* Fill-in STOP_REASON. */
> + get_prev_frame_1 (frame);
> + gdb_assert (frame->prev_p);
>
> - /* Otherwise, we set a reason when we succeeded (or failed) to
> - unwind. */
> return frame->stop_reason;
> }

... parts look a bit unrelated. It'd be good to have
the rationale for this spelled out. I can understand
why they might be necessary, but I don't see why
target vs non-unwinders unwinders would be special here?

--
Pedro Alves