This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Use TRY/CATCH in remove_prev_frame
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Fri, 25 May 2018 10:55:45 +0100
- Subject: Re: [RFA] Use TRY/CATCH in remove_prev_frame
- References: <20180525033628.25677-1-tom@tromey.com>
Quoting a "git diff -w" version of the patch, for easier context.
On 05/25/2018 04:36 AM, Tom Tromey wrote:
> diff --git a/gdb/frame.c b/gdb/frame.c
> index 1d0eb725145..e55b4e16305 100644
> --- a/gdb/frame.c
> +++ b/gdb/frame.c
> @@ -1871,22 +1871,6 @@ frame_register_unwind_location (struct frame_info *this_frame, int regnum,
> }
> }
>
> -/* Called during frame unwinding to remove a previous frame pointer from a
> - frame passed in ARG. */
> -
> -static void
> -remove_prev_frame (void *arg)
> -{
> - struct frame_info *this_frame, *prev_frame;
> -
> - this_frame = (struct frame_info *) arg;
> - prev_frame = this_frame->prev;
> - gdb_assert (prev_frame != NULL);
> -
> - prev_frame->next = NULL;
> - this_frame->prev = NULL;
> -}
> -
> /* Get the previous raw frame, and check that it is not identical to
> same other frame frame already in the chain. If it is, there is
> most likely a stack cycle, so we discard it, and mark THIS_FRAME as
> @@ -1899,7 +1883,6 @@ static struct frame_info *
> get_prev_frame_if_no_cycle (struct frame_info *this_frame)
> {
> struct frame_info *prev_frame;
> - struct cleanup *prev_frame_cleanup;
>
> prev_frame = get_prev_frame_raw (this_frame);
>
> @@ -1915,10 +1898,8 @@ get_prev_frame_if_no_cycle (struct frame_info *this_frame)
> if (prev_frame->level == 0)
> return prev_frame;
>
> - /* The cleanup will remove the previous frame that get_prev_frame_raw
> - linked onto THIS_FRAME. */
> - prev_frame_cleanup = make_cleanup (remove_prev_frame, this_frame);
> -
> + TRY
> + {
> compute_frame_id (prev_frame);
> if (!frame_stash_add (prev_frame))
> {
> @@ -1936,8 +1917,19 @@ get_prev_frame_if_no_cycle (struct frame_info *this_frame)
> this_frame->prev = NULL;
> prev_frame = NULL;
> }
> + }
> + CATCH (ex, RETURN_MASK_ERROR)
Use RETURN_MASK_ALL.
> + {
> + prev_frame = this_frame->prev;
> + gdb_assert (prev_frame != NULL);
I think these two lines aren't necessary? It seems like
they existed in remove_prev_frame because that needs to
find the prev_frame from its passed-in argument, which is
just this_frame. But here we already have prev_frame handy.
OK with those changes.
> +
> + prev_frame->next = NULL;
> + this_frame->prev = NULL;
> +
> + throw_exception (ex);
> + }
> + END_CATCH
>
> - discard_cleanups (prev_frame_cleanup);
> return prev_frame;
> }
>
>