Retrieve segment registers on Windows amd64

Message ID 1424435625-3708-1-git-send-email-jon.turney@dronecode.org.uk
State New, archived
Headers

Commit Message

Jon Turney Feb. 20, 2015, 12:33 p.m. UTC
  For amd64, CONTEXT_FULL does not contain CONTEXT_SEGMENTS, which seems to be
needed to retrieve all the segment registers.  Add it explicitly, with a little
de-cruftification.

The value of the segment registers isn't terribly useful on amd64, but at least
this makes the output of 'info registers' correct.

before:

(gdb)  i r cs ss ds es fs gs
cs             0x33     51
ss             0x2b     43
ds             0x0      0
es             0x0      0
fs             0x0      0
gs             0x0      0

after:

(gdb) i r cs ss ds es fs gs
cs             0x33     51
ss             0x2b     43
ds             0x2b     43
es             0x2b     43
fs             0x53     83
gs             0x2b     43

gdb/ChangeLog

2015-02-19  Jon TURNEY  <jon.turney@dronecode.org.uk>

	* windows-nat.c (CONTEXT_DEBUGGER_DR): Add CONTEXT_SEGMENTS.
---
 gdb/windows-nat.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
  

Comments

Joel Brobecker Feb. 26, 2015, 9:23 a.m. UTC | #1
Jon,

> For amd64, CONTEXT_FULL does not contain CONTEXT_SEGMENTS, which seems to be
> needed to retrieve all the segment registers.  Add it explicitly, with
> a little de-cruftification.
> 
> The value of the segment registers isn't terribly useful on amd64, but
> at least this makes the output of 'info registers' correct.
> 
> before:
> 
> (gdb)  i r cs ss ds es fs gs
> cs             0x33     51
> ss             0x2b     43
> ds             0x0      0
> es             0x0      0
> fs             0x0      0
> gs             0x0      0
> 
> after:
> 
> (gdb) i r cs ss ds es fs gs
> cs             0x33     51
> ss             0x2b     43
> ds             0x2b     43
> es             0x2b     43
> fs             0x53     83
> gs             0x2b     43
> 
> gdb/ChangeLog
> 
> 2015-02-19  Jon TURNEY  <jon.turney@dronecode.org.uk>
> 
> 	* windows-nat.c (CONTEXT_DEBUGGER_DR): Add CONTEXT_SEGMENTS.

Thanks for the patch.

The patch looks good to me.
The ChangeLog needs to identify all the changes were made, and in
particular, it needs to mention the fact that CONTEXT_DEBUGGER's
declaration was removed.

Do you have a GDB copyright assignment on file. The patch is small
enough that we can take it as a "tiny patch", but if you have other
patches in the pipeline, then you'll eventually need to fill one out.
Let me know if you'd like to get started on the process, it takes
a few weeks to complete, as I understand it.
  

Patch

diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 9c2dca1..ec11822 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -130,7 +130,6 @@  static CONTEXT saved_context;	/* Containes the saved context from a
 enum
   {
     FLAG_TRACE_BIT = 0x100,
-    CONTEXT_DEBUGGER = (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
   };
 #endif
 
@@ -140,8 +139,8 @@  enum
 #define CONTEXT_EXTENDED_REGISTERS 0
 #endif
 
-#define CONTEXT_DEBUGGER_DR CONTEXT_DEBUGGER | CONTEXT_DEBUG_REGISTERS \
-	| CONTEXT_EXTENDED_REGISTERS
+#define CONTEXT_DEBUGGER_DR CONTEXT_FULL | CONTEXT_FLOATING_POINT \
+        | CONTEXT_SEGMENTS | CONTEXT_DEBUG_REGISTERS | CONTEXT_EXTENDED_REGISTERS
 
 static uintptr_t dr[8];
 static int debug_registers_changed;