Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Simon Marchi <simon.marchi@efficios.com>
Cc: gdb-patches@sourceware.org,  Simon Marchi <simon.marchi@polymtl.ca>
Subject: Re: [PATCH v3] Pass thread_info pointer to various inferior control functions
Date: Tue, 18 Feb 2020 20:52:00 -0000	[thread overview]
Message-ID: <87o8tv62jk.fsf@tromey.com> (raw)
In-Reply-To: <20200213230428.14476-1-simon.marchi@efficios.com> (Simon	Marchi's message of "Thu, 13 Feb 2020 18:04:28 -0500")

>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:

Simon> I noticed that some functions in infcmd and infrun call each other and
Simon> all call inferior_thread, while they could just get the thread_info
Simon> pointer from their caller.  That means less calls to inferior_thread, so
Simon> less reliance on global state, since inferior_thread reads
Simon> inferior_ptid.

...

Simon> -set_step_frame (void)
Simon> +set_step_frame (thread_info *tp)
Simon>  {
Simon>    frame_info *frame = get_current_frame ();

I like the idea of passing parameters rather than relying on global
state.  However, in its current form, I think this patch may lull the
reader into a false sense of security.

That is, it makes it seems like these functions operate on a thread that
you pass in.  However, they don't actually.  For example, in this one, I
think get_current_frame must be relying on the global inferior_ptid.
So, this would change the function from something that obviously has to
be relying on globals to something that un-obviously is.

I don't know whether that's a reason to reject it or not.
It just seemed like maybe a future source of bugs.

I do welcome changes to reduce our reliance on globals.
Perhaps there's an argument that we can only achieve this incrementally
like this.  Though, the follow-on question there is whether this is
something that will actually happen.

Let me know what you think of this.

thanks,
Tom


  reply	other threads:[~2020-02-18 20:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-13 23:04 Simon Marchi
2020-02-18 20:52 ` Tom Tromey [this message]
2020-02-18 21:12   ` Simon Marchi

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=87o8tv62jk.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    --cc=simon.marchi@polymtl.ca \
    /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