[PATCH] Fix sizes and types of x86 segment and x87 registers
Ruslan Kabatsayev
b7.10110111@gmail.com
Sat Feb 1 18:43:00 GMT 2020
Segment registers are actually 16-bit, and their upper bit doesn't have
the meaning of sign. Currently GDB instead thinks they are signed
32-bit, which makes various debugger front-ends (e.g. QtCreator) display
them in unnatural format like 00000023.
Similar consideration applies to various x87 non-data registers. In
addition, fioff and fooff on IA32 are conceptually pointers, so the
command like "p $fioff" should show them as such, not as decimal
integers. On x86-64 fioff and fooff are not as straightforward, being
only the lower parts of the 48-bit offsets, upper part of which is in
fiseg and foseg, respectively, so this easy type assignment can't be
done.
This patch fixes types and sizes of these 16-bit registers to unsigned
16-bit, and makes types of fioff and fooff on IA32 respectively code_ptr
and data_ptr (on x86_64 both are made uint32).
gdb/ChangeLog:
2020-02-01 Ruslan Kabatsayev <b7.10110111@gmail.com>
* features/i386/32bit-core.xml: Fix segment and x87 register sizes and
types.
* features/i386/64bit-core.xml: Ditto.
* features/i386/32bit-core.c: Regenerate.
* features/i386/64bit-core.c: Regenerate.
---
gdb/features/i386/32bit-core.c | 28 ++++++++++++++--------------
gdb/features/i386/32bit-core.xml | 28 ++++++++++++++--------------
gdb/features/i386/64bit-core.c | 28 ++++++++++++++--------------
gdb/features/i386/64bit-core.xml | 28 ++++++++++++++--------------
4 files changed, 56 insertions(+), 56 deletions(-)
diff --git a/gdb/features/i386/32bit-core.c b/gdb/features/i386/32bit-core.c
index 8f9fbad717b..b1b5d5ad673 100644
--- a/gdb/features/i386/32bit-core.c
+++ b/gdb/features/i386/32bit-core.c
@@ -39,12 +39,12 @@ create_feature_i386_32bit_core (struct target_desc *result, long regnum)
tdesc_create_reg (feature, "edi", regnum++, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "eip", regnum++, 1, NULL, 32, "code_ptr");
tdesc_create_reg (feature, "eflags", regnum++, 1, NULL, 32, "i386_eflags");
- tdesc_create_reg (feature, "cs", regnum++, 1, NULL, 32, "int32");
- tdesc_create_reg (feature, "ss", regnum++, 1, NULL, 32, "int32");
- tdesc_create_reg (feature, "ds", regnum++, 1, NULL, 32, "int32");
- tdesc_create_reg (feature, "es", regnum++, 1, NULL, 32, "int32");
- tdesc_create_reg (feature, "fs", regnum++, 1, NULL, 32, "int32");
- tdesc_create_reg (feature, "gs", regnum++, 1, NULL, 32, "int32");
+ tdesc_create_reg (feature, "cs", regnum++, 1, NULL, 16, "uint16");
+ tdesc_create_reg (feature, "ss", regnum++, 1, NULL, 16, "uint16");
+ tdesc_create_reg (feature, "ds", regnum++, 1, NULL, 16, "uint16");
+ tdesc_create_reg (feature, "es", regnum++, 1, NULL, 16, "uint16");
+ tdesc_create_reg (feature, "fs", regnum++, 1, NULL, 16, "uint16");
+ tdesc_create_reg (feature, "gs", regnum++, 1, NULL, 16, "uint16");
tdesc_create_reg (feature, "st0", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st1", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st2", regnum++, 1, NULL, 80, "i387_ext");
@@ -53,13 +53,13 @@ create_feature_i386_32bit_core (struct target_desc *result, long regnum)
tdesc_create_reg (feature, "st5", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st6", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st7", regnum++, 1, NULL, 80, "i387_ext");
- tdesc_create_reg (feature, "fctrl", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "fstat", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "ftag", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "fiseg", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "fioff", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "foseg", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "fooff", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "fop", regnum++, 1, "float", 32, "int");
+ tdesc_create_reg (feature, "fctrl", regnum++, 1, "float", 16, "uint16");
+ tdesc_create_reg (feature, "fstat", regnum++, 1, "float", 16, "uint16");
+ tdesc_create_reg (feature, "ftag", regnum++, 1, "float", 16, "uint16");
+ tdesc_create_reg (feature, "fiseg", regnum++, 1, "float", 16, "uint16");
+ tdesc_create_reg (feature, "fioff", regnum++, 1, "float", 32, "code_ptr");
+ tdesc_create_reg (feature, "foseg", regnum++, 1, "float", 16, "uint16");
+ tdesc_create_reg (feature, "fooff", regnum++, 1, "float", 32, "data_ptr");
+ tdesc_create_reg (feature, "fop", regnum++, 1, "float", 16, "uint16");
return regnum;
}
diff --git a/gdb/features/i386/32bit-core.xml b/gdb/features/i386/32bit-core.xml
index 0958032a805..70e5a1d6c66 100644
--- a/gdb/features/i386/32bit-core.xml
+++ b/gdb/features/i386/32bit-core.xml
@@ -38,12 +38,12 @@
<reg name="eip" bitsize="32" type="code_ptr"/>
<reg name="eflags" bitsize="32" type="i386_eflags"/>
- <reg name="cs" bitsize="32" type="int32"/>
- <reg name="ss" bitsize="32" type="int32"/>
- <reg name="ds" bitsize="32" type="int32"/>
- <reg name="es" bitsize="32" type="int32"/>
- <reg name="fs" bitsize="32" type="int32"/>
- <reg name="gs" bitsize="32" type="int32"/>
+ <reg name="cs" bitsize="16" type="uint16"/>
+ <reg name="ss" bitsize="16" type="uint16"/>
+ <reg name="ds" bitsize="16" type="uint16"/>
+ <reg name="es" bitsize="16" type="uint16"/>
+ <reg name="fs" bitsize="16" type="uint16"/>
+ <reg name="gs" bitsize="16" type="uint16"/>
<reg name="st0" bitsize="80" type="i387_ext"/>
<reg name="st1" bitsize="80" type="i387_ext"/>
@@ -54,12 +54,12 @@
<reg name="st6" bitsize="80" type="i387_ext"/>
<reg name="st7" bitsize="80" type="i387_ext"/>
- <reg name="fctrl" bitsize="32" type="int" group="float"/>
- <reg name="fstat" bitsize="32" type="int" group="float"/>
- <reg name="ftag" bitsize="32" type="int" group="float"/>
- <reg name="fiseg" bitsize="32" type="int" group="float"/>
- <reg name="fioff" bitsize="32" type="int" group="float"/>
- <reg name="foseg" bitsize="32" type="int" group="float"/>
- <reg name="fooff" bitsize="32" type="int" group="float"/>
- <reg name="fop" bitsize="32" type="int" group="float"/>
+ <reg name="fctrl" bitsize="16" type="uint16" group="float"/>
+ <reg name="fstat" bitsize="16" type="uint16" group="float"/>
+ <reg name="ftag" bitsize="16" type="uint16" group="float"/>
+ <reg name="fiseg" bitsize="16" type="uint16" group="float"/>
+ <reg name="fioff" bitsize="32" type="code_ptr" group="float"/>
+ <reg name="foseg" bitsize="16" type="uint16" group="float"/>
+ <reg name="fooff" bitsize="32" type="data_ptr" group="float"/>
+ <reg name="fop" bitsize="16" type="uint16" group="float"/>
</feature>
diff --git a/gdb/features/i386/64bit-core.c b/gdb/features/i386/64bit-core.c
index 2418fe54e80..9945ce361d6 100644
--- a/gdb/features/i386/64bit-core.c
+++ b/gdb/features/i386/64bit-core.c
@@ -47,12 +47,12 @@ create_feature_i386_64bit_core (struct target_desc *result, long regnum)
tdesc_create_reg (feature, "r15", regnum++, 1, NULL, 64, "int64");
tdesc_create_reg (feature, "rip", regnum++, 1, NULL, 64, "code_ptr");
tdesc_create_reg (feature, "eflags", regnum++, 1, NULL, 32, "i386_eflags");
- tdesc_create_reg (feature, "cs", regnum++, 1, NULL, 32, "int32");
- tdesc_create_reg (feature, "ss", regnum++, 1, NULL, 32, "int32");
- tdesc_create_reg (feature, "ds", regnum++, 1, NULL, 32, "int32");
- tdesc_create_reg (feature, "es", regnum++, 1, NULL, 32, "int32");
- tdesc_create_reg (feature, "fs", regnum++, 1, NULL, 32, "int32");
- tdesc_create_reg (feature, "gs", regnum++, 1, NULL, 32, "int32");
+ tdesc_create_reg (feature, "cs", regnum++, 1, NULL, 16, "uint32");
+ tdesc_create_reg (feature, "ss", regnum++, 1, NULL, 16, "uint32");
+ tdesc_create_reg (feature, "ds", regnum++, 1, NULL, 16, "uint32");
+ tdesc_create_reg (feature, "es", regnum++, 1, NULL, 16, "uint32");
+ tdesc_create_reg (feature, "fs", regnum++, 1, NULL, 16, "uint32");
+ tdesc_create_reg (feature, "gs", regnum++, 1, NULL, 16, "uint32");
tdesc_create_reg (feature, "st0", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st1", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st2", regnum++, 1, NULL, 80, "i387_ext");
@@ -61,13 +61,13 @@ create_feature_i386_64bit_core (struct target_desc *result, long regnum)
tdesc_create_reg (feature, "st5", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st6", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st7", regnum++, 1, NULL, 80, "i387_ext");
- tdesc_create_reg (feature, "fctrl", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "fstat", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "ftag", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "fiseg", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "fioff", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "foseg", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "fooff", regnum++, 1, "float", 32, "int");
- tdesc_create_reg (feature, "fop", regnum++, 1, "float", 32, "int");
+ tdesc_create_reg (feature, "fctrl", regnum++, 1, "float", 16, "uint16");
+ tdesc_create_reg (feature, "fstat", regnum++, 1, "float", 16, "uint16");
+ tdesc_create_reg (feature, "ftag", regnum++, 1, "float", 16, "uint16");
+ tdesc_create_reg (feature, "fiseg", regnum++, 1, "float", 16, "uint16");
+ tdesc_create_reg (feature, "fioff", regnum++, 1, "float", 32, "uint32");
+ tdesc_create_reg (feature, "foseg", regnum++, 1, "float", 16, "uint16");
+ tdesc_create_reg (feature, "fooff", regnum++, 1, "float", 32, "uint32");
+ tdesc_create_reg (feature, "fop", regnum++, 1, "float", 16, "uint16");
return regnum;
}
diff --git a/gdb/features/i386/64bit-core.xml b/gdb/features/i386/64bit-core.xml
index 47a631323dd..4e674367730 100644
--- a/gdb/features/i386/64bit-core.xml
+++ b/gdb/features/i386/64bit-core.xml
@@ -46,12 +46,12 @@
<reg name="rip" bitsize="64" type="code_ptr"/>
<reg name="eflags" bitsize="32" type="i386_eflags"/>
- <reg name="cs" bitsize="32" type="int32"/>
- <reg name="ss" bitsize="32" type="int32"/>
- <reg name="ds" bitsize="32" type="int32"/>
- <reg name="es" bitsize="32" type="int32"/>
- <reg name="fs" bitsize="32" type="int32"/>
- <reg name="gs" bitsize="32" type="int32"/>
+ <reg name="cs" bitsize="16" type="uint32"/>
+ <reg name="ss" bitsize="16" type="uint32"/>
+ <reg name="ds" bitsize="16" type="uint32"/>
+ <reg name="es" bitsize="16" type="uint32"/>
+ <reg name="fs" bitsize="16" type="uint32"/>
+ <reg name="gs" bitsize="16" type="uint32"/>
<reg name="st0" bitsize="80" type="i387_ext"/>
<reg name="st1" bitsize="80" type="i387_ext"/>
@@ -62,12 +62,12 @@
<reg name="st6" bitsize="80" type="i387_ext"/>
<reg name="st7" bitsize="80" type="i387_ext"/>
- <reg name="fctrl" bitsize="32" type="int" group="float"/>
- <reg name="fstat" bitsize="32" type="int" group="float"/>
- <reg name="ftag" bitsize="32" type="int" group="float"/>
- <reg name="fiseg" bitsize="32" type="int" group="float"/>
- <reg name="fioff" bitsize="32" type="int" group="float"/>
- <reg name="foseg" bitsize="32" type="int" group="float"/>
- <reg name="fooff" bitsize="32" type="int" group="float"/>
- <reg name="fop" bitsize="32" type="int" group="float"/>
+ <reg name="fctrl" bitsize="16" type="uint16" group="float"/>
+ <reg name="fstat" bitsize="16" type="uint16" group="float"/>
+ <reg name="ftag" bitsize="16" type="uint16" group="float"/>
+ <reg name="fiseg" bitsize="16" type="uint16" group="float"/>
+ <reg name="fioff" bitsize="32" type="uint32" group="float"/>
+ <reg name="foseg" bitsize="16" type="uint16" group="float"/>
+ <reg name="fooff" bitsize="32" type="uint32" group="float"/>
+ <reg name="fop" bitsize="16" type="uint16" group="float"/>
</feature>
--
2.16.2
More information about the Gdb-patches
mailing list