diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2020-08-20 10:10:47 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2020-08-20 10:10:47 -0400 |
commit | dd125343a1cccac2878d528d61a5ea71e46793fa (patch) | |
tree | 8176c46700f549506c18e6bb540773dee9ae8b36 | |
parent | 3ee93972f9dbbb77a7cd4f63c6c7bb66a8b12c71 (diff) | |
download | gdb-dd125343a1cccac2878d528d61a5ea71e46793fa.zip gdb-dd125343a1cccac2878d528d61a5ea71e46793fa.tar.gz gdb-dd125343a1cccac2878d528d61a5ea71e46793fa.tar.bz2 |
gdb: refactor test_get_thread_arch_aspace_regcache
Do these misc changes to test_get_thread_arch_aspace_regcache:
- Rename to get_thread_arch_aspace_regcache_and_check. The following
patch introduces a selftest for get_thread_arch_aspace_regcache, named
get_thread_arch_aspace_regcache_test. To avoid confusion between the
two functions, rename this one to
get_thread_arch_aspace_regcache_and_check, I think it describes better
what it does.
- Remove gdbarch parameter. We always pass the same gdbarch (the
current inferior's gdbarch), so having a parameter is not useful. It
would be interesting to actually test with multiple gdbarches, to
verify that the regcache container can hold multiple regcaches (with
different architectures) for a same (target, ptid). But it's not the
case as of this patch.
- Verify that the regcache's arch is correctly set.
- Remove the aspace parameter. We always pass NULL here, so it's not
useful to have it as a parameter. Also, instead of passing a NULL
aspace to get_thread_arch_aspace_regcache and verifying that we get a
NULL aspace back, pass the current inferior's aspace (just like we use
the current inferior's gdbarch).
gdb/ChangeLog:
* regcache.c (test_get_thread_arch_aspace_regcache): Rename to...
(get_thread_arch_aspace_regcache_and_check): ... this. Remove
gdbarch and aspace parameter. Use current inferior's aspace.
Validate regcache's arch value.
(regcaches_test): Update.
Change-Id: I8b4c2303b4f91f062269043d1f7abe1650232010
-rw-r--r-- | gdb/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/regcache.c | 40 |
2 files changed, 25 insertions, 23 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a6835f0..ef36c2f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2020-08-20 Simon Marchi <simon.marchi@polymtl.ca> + * regcache.c (test_get_thread_arch_aspace_regcache): Rename to... + (get_thread_arch_aspace_regcache_and_check): ... this. Remove + gdbarch and aspace parameter. Use current inferior's aspace. + Validate regcache's arch value. + (regcaches_test): Update. + +2020-08-20 Simon Marchi <simon.marchi@polymtl.ca> + * regcache.c (regcaches_test): Call registers_changed. 2020-08-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> diff --git a/gdb/regcache.c b/gdb/regcache.c index 9f560ac..c27f604 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1491,15 +1491,21 @@ regcaches_size () /* Wrapper around get_thread_arch_aspace_regcache that does some self checks. */ static void -test_get_thread_arch_aspace_regcache (process_stratum_target *target, - ptid_t ptid, struct gdbarch *gdbarch, - address_space *aspace) +get_thread_arch_aspace_regcache_and_check (process_stratum_target *target, + ptid_t ptid) { - struct regcache *regcache - = get_thread_arch_aspace_regcache (target, ptid, gdbarch, aspace); + /* We currently only test with a single gdbarch. Any gdbarch will do, so use + the current inferior's gdbarch. Also use the current inferior's address + space. */ + gdbarch *arch = current_inferior ()->gdbarch; + address_space *aspace = current_inferior ()->aspace; + regcache *regcache + = get_thread_arch_aspace_regcache (target, ptid, arch, aspace); + SELF_CHECK (regcache != NULL); SELF_CHECK (regcache->target () == target); SELF_CHECK (regcache->ptid () == ptid); + SELF_CHECK (regcache->arch () == arch); SELF_CHECK (regcache->aspace () == aspace); } @@ -1517,37 +1523,27 @@ regcaches_test () /* Get regcache from (target1,ptid1), a new regcache is added to REGCACHES. */ - test_get_thread_arch_aspace_regcache (&test_target1, ptid1, - target_gdbarch (), - NULL); + get_thread_arch_aspace_regcache_and_check (&test_target1, ptid1); SELF_CHECK (regcaches_size () == 1); /* Get regcache from (target1,ptid2), a new regcache is added to REGCACHES. */ - test_get_thread_arch_aspace_regcache (&test_target1, ptid2, - target_gdbarch (), - NULL); + get_thread_arch_aspace_regcache_and_check (&test_target1, ptid2); SELF_CHECK (regcaches_size () == 2); /* Get regcache from (target1,ptid3), a new regcache is added to REGCACHES. */ - test_get_thread_arch_aspace_regcache (&test_target1, ptid3, - target_gdbarch (), - NULL); + get_thread_arch_aspace_regcache_and_check (&test_target1, ptid3); SELF_CHECK (regcaches_size () == 3); /* Get regcache from (target1,ptid2) again, nothing is added to REGCACHES. */ - test_get_thread_arch_aspace_regcache (&test_target1, ptid2, - target_gdbarch (), - NULL); + get_thread_arch_aspace_regcache_and_check (&test_target1, ptid2); SELF_CHECK (regcaches_size () == 3); /* Get regcache from (target2,ptid2), a new regcache is added to REGCACHES, since this time we're using a different target. */ - test_get_thread_arch_aspace_regcache (&test_target2, ptid2, - target_gdbarch (), - NULL); + get_thread_arch_aspace_regcache_and_check (&test_target2, ptid2); SELF_CHECK (regcaches_size () == 4); /* Mark that (target1,ptid2) changed. The regcache of (target1, @@ -1557,9 +1553,7 @@ regcaches_test () /* Get the regcache from (target2,ptid2) again, confirming the registers_changed_ptid call above did not delete it. */ - test_get_thread_arch_aspace_regcache (&test_target2, ptid2, - target_gdbarch (), - NULL); + get_thread_arch_aspace_regcache_and_check (&test_target2, ptid2); SELF_CHECK (regcaches_size () == 3); /* Confirm that marking all regcaches of all targets as changed |