This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v1.99 2/6] Add asserts in target_fetch/store_registers
- From: Simon Marchi <simon dot marchi at polymtl dot ca>
- To: gdb-patches at sourceware dot org
- Cc: Simon Marchi <simon dot marchi at polymtl dot ca>
- Date: Sat, 11 Mar 2017 12:03:50 -0500
- Subject: [PATCH v1.99 2/6] Add asserts in target_fetch/store_registers
- Authentication-results: sourceware.org; auth=none
- References: <20170311170354.18468-1-simon.marchi@polymtl.ca>
We are currently assuming that regcache->ptid is equal to inferior_ptid
when we call target_fetch/store_registers. These asserts just validate
that assumption. Also, since the following patches will change target
code to use regcache->ptid instead of inferior_ptid, asserting that they
are the same should ensure that our changes don't have any unintended
consequences.
gdb/ChangeLog:
* target.c (target_fetch_registers, target_store_registers): Add
assert.
---
gdb/target.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gdb/target.c b/gdb/target.c
index 0ff8515d3b..359bf0dec9 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3587,6 +3587,8 @@ debug_print_register (const char * func,
void
target_fetch_registers (struct regcache *regcache, int regno)
{
+ gdb_assert (ptid_equal (regcache_get_ptid (regcache), inferior_ptid));
+
current_target.to_fetch_registers (¤t_target, regcache, regno);
if (targetdebug)
debug_print_register ("target_fetch_registers", regcache, regno);
@@ -3598,6 +3600,8 @@ target_store_registers (struct regcache *regcache, int regno)
if (!may_write_registers)
error (_("Writing to registers is not allowed (regno %d)"), regno);
+ gdb_assert (ptid_equal (regcache_get_ptid (regcache), inferior_ptid));
+
current_target.to_store_registers (¤t_target, regcache, regno);
if (targetdebug)
{
--
2.12.0