gdb: handle the `ptid.is_pid ()` case in registers_changed_ptid
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 20 Aug 2020 14:11:09 +0000 (10:11 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Thu, 20 Aug 2020 14:11:09 +0000 (10:11 -0400)
commitb70e516e89d95d06252cb04ded3397ec0a0a3212
tree50e2b293b918bb21db07528bef0165e8ab7a6125
parentcdd9148a19e9c0acb99ef0908671f60ea9ad69bc
gdb: handle the `ptid.is_pid ()` case in registers_changed_ptid

As reported by Tom here [1], commit 888bdb2b7445 ("gdb: change regcache
list to be a map") overlooked an important case, causing a regression.
When registers_changed_ptid is called with a pid-like ptid, it used to
clear all the regcaches for that pid.  That commit accidentally removed
that behavior.  We need to handle the `ptid.is_pid ()` case in
registers_changed_ptid.

The most trivial way of fixing it would be to iterate on all ptids of a
target and delete the entries where the ptid match the pid.  But the
point of that commit was to avoid having to iterate on ptids to
invalidate regcaches, so that would feel like a step backwards.

The only logical solution I see is to add yet another map level, so that
we now have:

  target -> (pid -> (ptid -> regcaches))

This patch implements that and adds a test for the case of calling
registers_changed_ptid with a pid-like ptid.

[1] https://sourceware.org/pipermail/gdb-patches/2020-August/171222.html

gdb/ChangeLog:

* regcache.c (pid_ptid_regcache_map): New type.
(target_ptid_regcache_map): Remove.
(target_pid_ptid_regcache_map): New type.
(regcaches): Change type to target_pid_ptid_regcache_map.
(get_thread_arch_aspace_regcache): Update.
(regcache_thread_ptid_changed): Update, handle pid-like ptid
case.
(regcaches_size): Update.
(regcache_count): Update.
(registers_changed_ptid_target_pid_test): New.
(_initialize_regcache): Register new test.

Change-Id: I4c46e26d8225c177dbac9488b549eff4c68fa0d8
gdb/ChangeLog
gdb/regcache.c
This page took 0.024041 seconds and 4 git commands to generate.