Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <muller@ics.u-strasbg.fr>
To: "'Kai Tietz'" <Kai.Tietz@onevision.com>
Cc: <gdb-patches@sourceware.org>
Subject: [RFC] 64-bit support for x86-64 windows debug registers
Date: Wed, 14 Jan 2009 14:44:00 -0000	[thread overview]
Message-ID: <001401c97656$77a66b70$66f34250$@u-strasbg.fr> (raw)
In-Reply-To: <OF3CF64213.4C6F60A4-ONC125753E.0049E912-C125753E.004A2D71@onevision.de>

  Following Kai's advice, I modified the
windows-nat.c code to use 
  CORE_ADDR for dr0 to dr3,
but I left the type unchanged for 
dr6 and dr7, as, after reading the 
amd64 specifications, I saw that those fields
remain 32-bit wide.

  I could only test it with on 32 cygwin,
but at least it also works with 
--enable-targets=all --enable-64-bit-bfd
options.

Kai,
could you test this out, please?



Pierre Muller
Pascal language support maintainer for GDB

PS: Shouldn't these three functions
be named windows_set_dr, windows_set_dr7 and windows_get_dr6
instead of cygwin_...



ChangeLog entry:

2009-01-14  Pierre Muller  <muller@ics.u-strasbg.fr>

	* windows-nat.c: Fix debug registers for 64 bits.
	(dr): Change type to CORE_ADDR and size to 4.
	(dr6, dr7): New variables.
	(windows_add_thread, _windows_fetch_inferior_registers)
	(windows_continue, do_initial_windows_stuff)
	(cygwin_set_dr, cygwin_set_dr7, cygwin_get_dr6): Adapt
	to changes above.


Index: gdb/windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.178
diff -u -p -r1.178 windows-nat.c
--- gdb/windows-nat.c   14 Jan 2009 05:27:48 -0000      1.178
+++ gdb/windows-nat.c   14 Jan 2009 14:12:05 -0000
@@ -95,7 +95,9 @@ enum
 #define CONTEXT_DEBUGGER_DR CONTEXT_DEBUGGER | CONTEXT_DEBUG_REGISTERS \
        | CONTEXT_EXTENDED_REGISTERS

-static unsigned dr[8];
+static CORE_ADDR dr[4];
+static unsigned dr6, dr7;
+
 static int debug_registers_changed;
 static int debug_registers_used;
 #define DR6_CLEAR_VALUE 0xffff0ff0
@@ -284,7 +286,7 @@ windows_add_thread (ptid_t ptid, HANDLE
       th->context.Dr2 = dr[2];
       th->context.Dr3 = dr[3];
       th->context.Dr6 = DR6_CLEAR_VALUE;
-      th->context.Dr7 = dr[7];
+      th->context.Dr7 = dr7;
       CHECK (SetThreadContext (th->h, &th->context));
       th->context.ContextFlags = 0;
     }
@@ -374,8 +376,8 @@ do_windows_fetch_inferior_registers (str
              dr[1] = th->context.Dr1;
              dr[2] = th->context.Dr2;
              dr[3] = th->context.Dr3;
-             dr[6] = th->context.Dr6;
-             dr[7] = th->context.Dr7;
+             dr6 = th->context.Dr6;
+             dr7 = th->context.Dr7;
            }
        }
       current_thread->reload_context = 0;
@@ -1122,7 +1124,7 @@ windows_continue (DWORD continue_status,
            th->context.Dr2 = dr[2];
            th->context.Dr3 = dr[3];
            th->context.Dr6 = DR6_CLEAR_VALUE;
-           th->context.Dr7 = dr[7];
+           th->context.Dr7 = dr7;
          }
        if (th->context.ContextFlags)
          {
@@ -1238,7 +1240,7 @@ windows_resume (ptid_t ptid, int step, e
              th->context.Dr2 = dr[2];
              th->context.Dr3 = dr[3];
              th->context.Dr6 = DR6_CLEAR_VALUE;
-             th->context.Dr7 = dr[7];
+             th->context.Dr7 = dr7;
            }
          CHECK (SetThreadContext (th->h, &th->context));
          th->context.ContextFlags = 0;
@@ -1508,6 +1510,8 @@ do_initial_windows_stuff (struct target_
   debug_registers_used = 0;
   for (i = 0; i < sizeof (dr) / sizeof (dr[0]); i++)
     dr[i] = 0;
+  dr6 = 0;
+  dr7 = 0;
 #ifdef __CYGWIN__
   cygwin_load_start = cygwin_load_end = 0;
 #endif
@@ -2237,7 +2241,7 @@ cygwin_set_dr (int i, CORE_ADDR addr)
   if (i < 0 || i > 3)
     internal_error (__FILE__, __LINE__,
                    _("Invalid register %d in cygwin_set_dr.\n"), i);
-  dr[i] = (unsigned) addr;
+  dr[i] = addr;
   debug_registers_changed = 1;
   debug_registers_used = 1;
 }
@@ -2248,7 +2252,7 @@ cygwin_set_dr (int i, CORE_ADDR addr)
 void
 cygwin_set_dr7 (unsigned val)
 {
-  dr[7] = val;
+  dr7 = val;
   debug_registers_changed = 1;
   debug_registers_used = 1;
 }
@@ -2259,7 +2263,7 @@ cygwin_set_dr7 (unsigned val)
 unsigned
 cygwin_get_dr6 (void)
 {
-  return dr[6];
+  return dr6;
 }

 /* Determine if the thread referenced by "ptid" is alive


  reply	other threads:[~2009-01-14 14:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-14 11:22 [RFC] 32-bit support for windows thread information block Pierre Muller
2009-01-14 13:00 ` Kai Tietz
2009-01-14 13:16   ` Pierre Muller
2009-01-14 13:31     ` Kai Tietz
2009-01-14 14:44       ` Pierre Muller [this message]
2009-01-15 10:08         ` [RFC] 64-bit support for x86-64 windows debug registers Kai Tietz
2009-01-16 10:39           ` [RFA/windows] " Pierre Muller
2009-01-16 20:11             ` Christopher Faylor
2009-01-19  8:59               ` Pierre Muller

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='001401c97656$77a66b70$66f34250$@u-strasbg.fr' \
    --to=muller@ics.u-strasbg.fr \
    --cc=Kai.Tietz@onevision.com \
    --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