public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Phil Muldoon <pmuldoon@redhat.com>, tromey@redhat.com
Subject: Re: [python][patch] Inferior and Thread information support.
Date: Tue, 15 Jun 2010 15:24:00 -0000	[thread overview]
Message-ID: <201006151623.55766.pedro@codesourcery.com> (raw)
In-Reply-To: <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

  reply	other threads:[~2010-06-15 15:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-24 13:36 Phil Muldoon
2010-05-24 18:06 ` Eli Zaretskii
2010-06-10 18:40 ` Tom Tromey
2010-06-14 12:42   ` Phil Muldoon
2010-06-15 15:24     ` Pedro Alves [this message]
2010-06-15 18:11     ` Tom Tromey
2010-06-15 18:24       ` Pedro Alves
2010-06-15 19:58       ` Phil Muldoon
2010-06-15 20:36         ` Pedro Alves
2010-06-18  6:49   ` Phil Muldoon
2010-06-18 14:21     ` Doug Evans
2010-06-18 15:47       ` Phil Muldoon
2010-06-18 17:59         ` Tom Tromey
2010-06-18 20:10           ` Phil Muldoon
2010-06-25 20:41             ` Tom Tromey
2010-06-18 18:04     ` Tom Tromey
2010-06-22 10:32       ` Phil Muldoon
2010-06-25 20:38         ` Tom Tromey
2010-06-28  9:22           ` Phil Muldoon
2010-06-28 19:51             ` Tom Tromey
2010-06-28 21:35               ` Phil Muldoon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201006151623.55766.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pmuldoon@redhat.com \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).