+2012-05-04 Joel Brobecker <brobecker@adacore.com>
+
+ * 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.
+
2012-05-04 Tristan Gingold <gingold@adacore.com>
* printcmd.c (set_command): Emit a warning if the expression is not
#include "defs.h"
#include "windows-nat.h"
#include "i386-nat.h"
+#include "amd64-tdep.h"
+
#include <windows.h>
#define context_offset(x) (offsetof (CONTEXT, x))
};
#undef context_offset
+/* segment_register_p_ftype implementation for amd64. */
+
+static int
+amd64_windows_segment_register_p (int regnum)
+{
+ return regnum >= AMD64_CS_REGNUM && regnum <= AMD64_GS_REGNUM;
+}
+
/* -Wmissing-prototypes */
extern initialize_file_ftype _initialize_amd64_windows_nat;
_initialize_amd64_windows_nat (void)
{
windows_set_context_register_offsets (mappings);
+ windows_set_segment_register_p (amd64_windows_segment_register_p);
i386_set_debug_register_length (8);
}
#include "defs.h"
#include "windows-nat.h"
#include "i386-nat.h"
+#include "i386-tdep.h"
#include <windows.h>
};
#undef context_offset
+/* segment_register_p_ftype implementation for x86. */
+
+static int
+i386_windows_segment_register_p (int regnum)
+{
+ return regnum >= I386_CS_REGNUM && regnum <= I386_GS_REGNUM;
+}
+
/* -Wmissing-prototypes */
extern initialize_file_ftype _initialize_i386_windows_nat;
_initialize_i386_windows_nat (void)
{
windows_set_context_register_offsets (mappings);
+ windows_set_segment_register_p (i386_windows_segment_register_p);
i386_set_debug_register_length (4);
}
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. */
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)
{
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
extern void windows_set_context_register_offsets (const int *offsets);
+/* A pointer to a function that should return non-zero iff REGNUM
+ corresponds to one of the segment registers. */
+typedef int (segment_register_p_ftype) (int regnum);
+
+/* Set the function that should be used by this module to determine
+ whether a given register is a segment register or not. */
+extern void windows_set_segment_register_p (segment_register_p_ftype *fun);
+
#endif