This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [python][patch] Inferior and Thread information support.
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Cc: Phil Muldoon <pmuldoon at redhat dot com>, tromey at redhat dot com
- Date: Tue, 15 Jun 2010 16:23:55 +0100
- Subject: Re: [python][patch] Inferior and Thread information support.
- References: <4BFA6E82.3070704@redhat.com> <m3aar2afyu.fsf@fleche.redhat.com> <4C1623C1.6090205@redhat.com>
On Monday 14 June 2010 13:42:41, Phil Muldoon wrote:
> On 06/10/2010 07:40 PM, Tom Tromey wrote:
> >>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
> >
> > Phil> + THPY_REQUIRE_VALID (thread_obj);
> > Phil> +
> > Phil> + cleanup = make_cleanup_restore_current_thread ();
> > Phil> +
> > Phil> + TRY_CATCH (except, RETURN_MASK_ALL)
> > Phil> + {
> > Phil> + switch_to_thread (thread_obj->thread->ptid);
> > Phil> +
> > Phil> + frame = get_current_frame ();
> > Phil> + frame_obj = frame_info_to_frame_object (frame);
> > Phil> + }
> > Phil> + GDB_PY_HANDLE_EXCEPTION (except);
> >
> > I am really not sure about this.
> >
> > Doesn't switch_to_thread reset the frame cache?
> > Meaning that the returned frame_obj will immediately be invalid?
> >
> > You would have to try this with a multi-threaded program, where you are
> > stopped in thread A but then request a frame in thread B.
>
> I'll investigate this further. I had concerns about this (I think we
> chatted a little about this on irc way back when). I'll write an
> inferior test and see. Maybe Pedro or someone else in that area knows
> a little more.
Tom is correct. You'll not see a problem with single-thread apps
because switch_to_thread does an early return before invalidating
the frame cache when the thread you're switching to is already current.
In short, don't ever store a frame_info pointer like this. Instead,
if you need to record the frame somewhere, store a frame_id.
(I haven't really looked at the patch and the use case, just
commenting from the what's quoted above)
--
Pedro Alves