summaryrefslogtreecommitdiff
path: root/gdb/windows-nat.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2012-05-04 18:36:28 +0000
committerJoel Brobecker <brobecker@gnat.com>2012-05-04 18:36:28 +0000
commitbe99a4846257d665e0a0db366a4aa0068f3a4568 (patch)
treef33b2b1d35b7d7833ae40e13ca574f1b618b913a /gdb/windows-nat.c
parent0599b1780d127fff8f7c29af624921b987b4d7b4 (diff)
downloadgdb-be99a4846257d665e0a0db366a4aa0068f3a4568.tar.gz
Segment register reading on Windows targets.
This patch makes sure that the value of segment registers are read properly as 16bit values on Windows. gdb/ChangeLog: * windows-nat.h (segment_register_p_ftype): New typedef. (windows_set_segment_register_p): Add declaration. * windows-nat.c (segment_register_p): New static global. (windows_set_segment_register_p): New function. (do_windows_fetch_inferior_registers): Add special handling for segment registers. * amd64-windows-nat.c: #include "amd64-tdep.h". (amd64_windows_segment_register_p): New function. (_initialize_amd64_windows_nat): Call windows_set_segment_register_p. * i386-windows-nat.c: #include "i386-tdep.h". (i386_windows_segment_register_p): New function. (_initialize_i386_windows_nat): Call windows_set_segment_register_p.
Diffstat (limited to 'gdb/windows-nat.c')
-rw-r--r--gdb/windows-nat.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index f536ed1ce95..000c86f5ccc 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -243,6 +243,10 @@ static int useshell = 0; /* use shell for subprocesses */
static const int *mappings;
+/* The function to use in order to determine whether a register is
+ a segment register or not. */
+static segment_register_p_ftype *segment_register_p;
+
/* This vector maps the target's idea of an exception (extracted
from the DEBUG_EVENT structure) to GDB's idea. */
@@ -272,6 +276,14 @@ windows_set_context_register_offsets (const int *offsets)
mappings = offsets;
}
+/* See windows-nat.h. */
+
+void
+windows_set_segment_register_p (segment_register_p_ftype *fun)
+{
+ segment_register_p = fun;
+}
+
static void
check (BOOL ok, const char *file, int line)
{
@@ -456,6 +468,14 @@ do_windows_fetch_inferior_registers (struct regcache *regcache, int r)
l = (*((long *) context_offset) >> 16) & ((1 << 11) - 1);
regcache_raw_supply (regcache, r, (char *) &l);
}
+ else if (segment_register_p (r))
+ {
+ /* GDB treats segment registers as 32bit registers, but they are
+ in fact only 16 bits long. Make sure we do not read extra
+ bits from our source buffer. */
+ l = *((long *) context_offset) & 0xffff;
+ regcache_raw_supply (regcache, r, (char *) &l);
+ }
else if (r >= 0)
regcache_raw_supply (regcache, r, context_offset);
else