public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Markus Metzger <markus.t.metzger@intel.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 4/7] gdb, btrace: check inferior_ptid in record_btrace_target::xfer_partial()
Date: Sat, 22 Jan 2022 22:22:57 -0500	[thread overview]
Message-ID: <c68adc9d-7fa9-62e4-6516-0ead49e40d77@polymtl.ca> (raw)
In-Reply-To: <20211202071525.3046816-5-markus.t.metzger@intel.com>

On 2021-12-02 02:15, Markus Metzger wrote:
> In record_btrace_target::xfer_partial(), we handle accessing read-only
> memory during replay.  This request only makes sense if inferior_ptid is
> either a single light-weight process or a full process.  Check that.
> ---
>  gdb/record-btrace.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
> index a25670e7e24..13665096f14 100644
> --- a/gdb/record-btrace.c
> +++ b/gdb/record-btrace.c
> @@ -1434,6 +1434,7 @@ record_btrace_target::xfer_partial (enum target_object object,
>    /* Filter out requests that don't make sense during replay.  */
>    if (replay_memory_access == replay_memory_access_read_only
>        && !record_btrace_generating_corefile
> +      && inferior_ptid.is_lwp_or_pid ()
>        && record_is_replaying (inferior_ptid))
>      {
>        switch (object)

Given your implementation of is_lwp_or_pid, that means checking that
inferior_ptid is not null_ptid nor minus_one_ptid.

I don't think minus_one_ptid is ever a valid value for inferior_ptid, if
inferior_ptid is minus_one_ptid it means there is clearly a bug
somewhere.  So I think it doesn't make sense to check for that.

As for inferior_ptid being null here... I doubt that there is a
legitimate reason for this to happen... but I suppose that it can
technically happen.  <S-Del>Tthat you could call
switch_to_inferior_no_thread (which sets inferior_ptid to null_ptid) and
then call target_ops::xfer_partial.  Maybe there's some target_object
that read a target-wide property and therefore don't need inferior_ptid
to point to a pid or an lwp?

I would lean towards saying the same thing as for patch 1/7, that this
change only ends up hiding potential future bugs.  But if you can give
me a legitimate scenario for this to happen, then I can be convinced
otherwise.

Simon

  reply	other threads:[~2022-01-23  3:23 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-02  7:15 [PATCH v2 0/7] gdb, thread-iter: handle null_ptid Markus Metzger
2021-12-02  7:15 ` [PATCH v2 1/7] " Markus Metzger
2022-01-23  2:21   ` Simon Marchi
2021-12-02  7:15 ` [PATCH v2 2/7] gdb, btrace: rename record_btrace_enable_warn() Markus Metzger
2022-01-23  2:22   ` Simon Marchi
2021-12-02  7:15 ` [PATCH v2 3/7] gdb, ptid: add is_lwp() and is_lwp_or_pid() Markus Metzger
2022-01-23  2:36   ` Simon Marchi
2022-01-24 16:32     ` Metzger, Markus T
2022-01-24 17:04       ` Simon Marchi
2022-01-25  9:40         ` Metzger, Markus T
2021-12-02  7:15 ` [PATCH v2 4/7] gdb, btrace: check inferior_ptid in record_btrace_target::xfer_partial() Markus Metzger
2022-01-23  3:22   ` Simon Marchi [this message]
2022-01-24 16:58     ` Metzger, Markus T
2022-01-24 17:22       ` Simon Marchi
2022-01-25  9:40         ` Metzger, Markus T
2021-12-02  7:15 ` [PATCH v2 5/7] gdb, btrace: switch threads in remote_btrace_maybe_reopen() Markus Metzger
2022-01-23  3:24   ` Simon Marchi
2021-12-02  7:15 ` [PATCH v2 6/7] gdb, gdbserver: update thread identifier in enable_btrace target method Markus Metzger
2022-01-23  4:02   ` Simon Marchi
2022-01-24 16:40     ` Metzger, Markus T
2021-12-02  7:15 ` [PATCH v2 7/7] gdb, remote, btrace: move switch_to_thread call right before xfer call Markus Metzger
2022-01-23  4:19   ` Simon Marchi
2022-01-24 17:07     ` Metzger, Markus T
2022-01-21 11:41 ` [PATCH v2 0/7] gdb, thread-iter: handle null_ptid Metzger, Markus T
2022-01-27 12:49 ` Metzger, Markus T
2022-01-27 17:04   ` 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=c68adc9d-7fa9-62e4-6516-0ead49e40d77@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=markus.t.metzger@intel.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).