From: Hannes Domani <ssbssa@yahoo.de>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 3/8] Windows gdb: Remove mappings member from windows_per_inferior
Date: Mon, 27 Jul 2026 19:42:27 +0200 [thread overview]
Message-ID: <20260727174619.1089041-3-ssbssa@yahoo.de> (raw)
In-Reply-To: <20260727174619.1089041-1-ssbssa@yahoo.de>
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
next prev parent reply other threads:[~2026-07-27 17:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260727174619.1089041-1-ssbssa.ref@yahoo.de>
2026-07-27 17:42 ` [PATCH v2 1/8] gdb/testsuite: Add Windows replacement for aligned_alloc Hannes Domani
2026-07-27 17:42 ` [PATCH v2 2/8] Windows gdb: Use allocated buffer for CONTEXT Hannes Domani
2026-07-27 17:42 ` Hannes Domani [this message]
2026-07-27 17:42 ` [PATCH v2 4/8] Windows gdb: Refactor getting pointer to register inside context Hannes Domani
2026-07-27 17:42 ` [PATCH v2 5/8] Windows gdb: Prepare XState functions Hannes Domani
2026-07-27 17:42 ` [PATCH v2 6/8] Windows gdb: Get available XState features Hannes Domani
2026-07-27 17:42 ` [PATCH v2 7/8] Windows gdb: Implement XState (Intel AVX) support Hannes Domani
2026-07-27 17:42 ` [PATCH v2 8/8] Windows gdbserver: " Hannes Domani
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=20260727174619.1089041-3-ssbssa@yahoo.de \
--to=ssbssa@yahoo.de \
--cc=gdb-patches@sourceware.org \
/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