From: Tom Tromey <tom@tromey.com>
To: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@efficios.com>,
Morichetti@sourceware.org, Laurent <Laurent.Morichetti@amd.com>
Subject: Re: [PATCH 4/4] gdb: change regcache list to be a map
Date: Wed, 12 Aug 2020 06:52:18 -0600 [thread overview]
Message-ID: <87tux8hvr1.fsf@tromey.com> (raw)
In-Reply-To: <20200720204101.2849535-5-simon.marchi@efficios.com> (Simon Marchi via Gdb-patches's message of "Mon, 20 Jul 2020 16:41:01 -0400")
>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
Simon> The function registers_changed_ptid deletes all regcaches related to a
Simon> given (target, ptid). We must now handle the different cases
Simon> separately:
[...]
Simon> - non-NULL target and non-minus_one_ptid: we delete all the entries
Simon> associated to that tuple, this is done efficiently
Simon> - a non-NULL target and minus_one_ptid: we delete all the entries
Simon> associated to that target, whatever the ptid. This is the slightly
Simon> annoying case, as we can't easily look up all items having this target
Simon> in their key. I implemented it by walking the list, which is not
Simon> ideal.
This patch caused a regression for Ravenscar targets. I spent a bit of
time tracking it down, and I think the issue is that there was a change
in the semantics in registers_changed_ptid.
Formerly it did this:
Simon> - if ((target == nullptr || regcache->target () == target)
Simon> - && regcache->ptid ().matches (ptid))
Simon> - {
Simon> - delete regcache;
Simon> - it = regcaches.erase_after (oit);
But now it does:
if (target == nullptr)
...
else if (ptid != minus_one_ptid)
{
/* Non-NULL target and non-minus_one_ptid, delete all regcaches belonging
to this (TARGET, PTID). */
auto ptid_regc_map_it = regcaches.find (target);
if (ptid_regc_map_it != regcaches.end ())
{
auto &ptid_regc_map = ptid_regc_map_it->second;
ptid_regc_map.erase (ptid);
}
}
else
...
The difference being the call to ptid::matches. This method will return
true if the ptid in question is a PID:
|| (filter.is_pid () && m_pid == filter.pid ())
... but in the new code, no provision is made for the PID case.
This comes up because, at least in the case I am debugging,
target_resume is called with a PID and not -1. See
user_visible_resume_ptid:
else if (!sched_multi && target_supports_multi_process ())
{
/* Resume all threads of the current process (and none of other
processes). */
resume_ptid = ptid_t (inferior_ptid.pid ());
}
At first I wasn't sure if this semantic change was really a bug; but now
it seems to me that it must be. The non-stop and scheduler-locking
cases are handled earlier in user_visible_resume_ptid, so at this point
it intends to resume all the threads of the process. And, in this
situation, I think the register caches for all threads in the process
ought to be cleared by the registers_changed_ptid call in target_resume.
A simple fix would be to fall back to iterating over the map in the
is_pid case. I don't know whether this would reintroduce the
performance issue that prompted the patch, though.
I'd like to know whether you agree with this analysis ... if so, what
should we do; and if not, what is incorrect?
thanks,
Tom
next prev parent reply other threads:[~2020-08-12 12:52 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-20 20:40 [PATCH 0/4] Regcache fix and optimization Simon Marchi
2020-07-20 20:40 ` [PATCH 1/4] gdb: rename regcache::current_regcache to regcache::regcaches Simon Marchi
2020-07-23 20:01 ` Pedro Alves
2020-07-20 20:40 ` [PATCH 2/4] gdb: move regcache::regcaches to regcache.c Simon Marchi
2020-07-23 20:03 ` Pedro Alves
2020-07-20 20:41 ` [PATCH 3/4] gdb: pass target to thread_ptid_changed observable Simon Marchi
2020-07-23 20:42 ` Pedro Alves
2020-07-30 15:27 ` Simon Marchi
2020-08-05 14:50 ` Pedro Alves
2020-08-05 19:08 ` Simon Marchi
2020-08-05 22:29 ` Pedro Alves
2020-07-20 20:41 ` [PATCH 4/4] gdb: change regcache list to be a map Simon Marchi
2020-07-24 1:53 ` Pedro Alves
2020-07-24 16:59 ` John Baldwin
2020-07-30 16:26 ` Simon Marchi
2020-07-30 16:58 ` Simon Marchi
2020-07-30 17:03 ` Simon Marchi
2020-08-05 18:02 ` Pedro Alves
2020-08-05 20:25 ` Simon Marchi
2020-07-30 17:07 ` Simon Marchi
2020-07-30 18:17 ` Simon Marchi
2020-08-05 18:14 ` Pedro Alves
2020-08-10 19:15 ` Tom Tromey
2020-08-10 19:25 ` Simon Marchi
2020-08-12 12:52 ` Tom Tromey [this message]
2020-08-12 15:17 ` Tom Tromey
2020-08-06 20:27 ` [PATCH 0/4] Regcache fix and optimization 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=87tux8hvr1.fsf@tromey.com \
--to=tom@tromey.com \
--cc=Laurent.Morichetti@amd.com \
--cc=Morichetti@sourceware.org \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.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