[PATCH v2 3/8] Windows gdb: Remove mappings member from windows_per_inferior
Hannes Domani <[email protected]> Mon, 27 Jul 2026 19:42:27 +0200
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
It's not really that useful, and simplifies later XState changes.
---
gdb/aarch64-windows-nat.c | 6 ++----
gdb/windows-nat.h | 18 ------------------
gdb/x86-windows-nat.c | 34 ++++++++++++++++++++++------------
3 files changed, 24 insertions(+), 34 deletions(-)
diff --git a/gdb/aarch64-windows-nat.c b/gdb/aarch64-windows-nat.c
index 630704a8caf..be900439047 100644
--- a/gdb/aarch64-windows-nat.c
+++ b/gdb/aarch64-windows-nat.c
@@ -168,8 +168,6 @@ aarch64_windows_nat_target::initialize_windows_arch (bool attaching)
{
memset (&aarch64_windows_process.dr_state, 0,
sizeof (aarch64_windows_process.dr_state));
-
- aarch64_windows_process.mappings = aarch64_mappings;
}
/* See windows-nat.h. */
@@ -264,7 +262,7 @@ aarch64_windows_nat_target::fetch_one_register (struct regcache *regcache,
gdb_assert (r >= 0);
char *context_ptr = (char *) th->context;
- char *context_offset = context_ptr + aarch64_windows_process.mappings[r];
+ char *context_offset = context_ptr + aarch64_mappings[r];
struct gdbarch *gdbarch = regcache->arch ();
gdb_assert (!gdbarch_read_pc_p (gdbarch));
@@ -296,7 +294,7 @@ aarch64_windows_nat_target::store_one_register (const struct regcache *regcache,
char *context_ptr = (char *) th->context;
- regcache->raw_collect (r, context_ptr + aarch64_windows_process.mappings[r]);
+ regcache->raw_collect (r, context_ptr + aarch64_mappings[r]);
}
/* See windows-nat.h. */
diff --git a/gdb/windows-nat.h b/gdb/windows-nat.h
index 3349755022b..d6977ff4c85 100644
--- a/gdb/windows-nat.h
+++ b/gdb/windows-nat.h
@@ -139,24 +139,6 @@ struct windows_per_inferior : public windows_nat::windows_process_info
void *wow64_dbgbreak = nullptr;
#endif
- /* This vector maps GDB's idea of a register's number into an offset
- in the windows exception context vector.
-
- It also contains the bit mask needed to load the register in question.
-
- The contents of this table can only be computed by the units
- that provide CPU-specific support for Windows native debugging.
-
- One day we could read a reg, we could inspect the context we
- already have loaded, if it doesn't have the bit set that we need,
- we read that set of registers in using GetThreadContext. If the
- context already contains what we need, we just unpack it. Then to
- write a register, first we have to ensure that the context contains
- the other regs of the group, and then we copy the info in and set
- out bit. */
-
- const int *mappings = nullptr;
-
std::vector<windows_solib> solibs;
#ifdef __CYGWIN__
diff --git a/gdb/x86-windows-nat.c b/gdb/x86-windows-nat.c
index 2f556e47b39..b3ad8594020 100644
--- a/gdb/x86-windows-nat.c
+++ b/gdb/x86-windows-nat.c
@@ -85,16 +85,10 @@ x86_windows_nat_target::initialize_windows_arch (bool attaching)
= !attaching && x86_windows_process.wow64_process;
if (!x86_windows_process.wow64_process)
- {
- x86_windows_process.mappings = amd64_mappings;
- x86_windows_process.segment_register_p = amd64_windows_segment_register_p;
- }
+ x86_windows_process.segment_register_p = amd64_windows_segment_register_p;
else
#endif
- {
- x86_windows_process.mappings = i386_mappings;
- x86_windows_process.segment_register_p = i386_windows_segment_register_p;
- }
+ x86_windows_process.segment_register_p = i386_windows_segment_register_p;
}
/* See windows-nat.h. */
@@ -242,7 +236,15 @@ x86_windows_nat_target::fetch_one_register (struct regcache *regcache,
return (char *) context;
});
- char *context_offset = context_ptr + x86_windows_process.mappings[r];
+ const int *mappings;
+#ifdef __x86_64__
+ if (!x86_windows_process.wow64_process)
+ mappings = amd64_mappings;
+ else
+#endif
+ mappings = i386_mappings;
+
+ char *context_offset = context_ptr + mappings[r];
struct gdbarch *gdbarch = regcache->arch ();
i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
@@ -308,6 +310,14 @@ x86_windows_nat_target::store_one_register (const struct regcache *regcache,
return (char *) context;
});
+ const int *mappings;
+#ifdef __x86_64__
+ if (!x86_windows_process.wow64_process)
+ mappings = amd64_mappings;
+ else
+#endif
+ mappings = i386_mappings;
+
struct gdbarch *gdbarch = regcache->arch ();
i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
@@ -319,7 +329,7 @@ x86_windows_nat_target::store_one_register (const struct regcache *regcache,
{
gdb_byte bytes[4];
regcache->raw_collect (r, bytes);
- memcpy (context_ptr + x86_windows_process.mappings[r], bytes, 2);
+ memcpy (context_ptr + mappings[r], bytes, 2);
}
else if (r == I387_FOP_REGNUM (tdep))
{
@@ -328,10 +338,10 @@ x86_windows_nat_target::store_one_register (const struct regcache *regcache,
/* The value of FOP occupies the top two bytes in the context,
so write the two low-order bytes from the cache into the
appropriate spot. */
- memcpy (context_ptr + x86_windows_process.mappings[r] + 2, bytes, 2);
+ memcpy (context_ptr + mappings[r] + 2, bytes, 2);
}
else
- regcache->raw_collect (r, context_ptr + x86_windows_process.mappings[r]);
+ regcache->raw_collect (r, context_ptr + mappings[r]);
}
/* See windows-nat.h. */
--
2.54.0