* PATCH: PATCH: Add builtin floating point types
@ 2010-02-05 1:15 H.J. Lu
2010-02-07 21:52 ` Mark Kettenis
2010-02-08 18:55 ` PATCH: Cache types from target description H.J. Lu
0 siblings, 2 replies; 20+ messages in thread
From: H.J. Lu @ 2010-02-05 1:15 UTC (permalink / raw)
To: GDB; +Cc: Mark Kettenis
I am resending this patch. The motivation is I am working on x86 xml
target descriptions. x86 has i387_ext type. I added
case TDESC_TYPE_I387_EXT:
return arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
floatformats_i387_ext);
to tdesc_gdb_type. I would up 8 i387_ext types at 8 different addresses
with the same bits. x86 does
if (i386_fp_regnum_p (gdbarch, regnum))
{
/* Floating point registers must be converted unless we are
accessing them in their hardware type. */
if (type == i387_ext_type (gdbarch))
return 0;
else
return 1;
}
It expects 2 i387_ext types should have the same address. This
patch caches ieee_single, ieee_double and i387_ext. OK to install?
Thanks.
H.J.
---
2010-02-04 H.J. Lu <hongjiu.lu@intel.com>
* amd64-tdep.c (amd64_register_type): Replace i387_ext_type
with builtin_i387_ext.
* i387-tdep.c (print_i387_value): Likewise.
(i387_convert_register_p): Likewise.
(i387_register_to_value): Likewise.
(i387_value_to_register): Likewise.
* gdbtypes.c (gdbtypes_post_init): Initialize
builtin_ieee_single, builtin_ieee_double and builtin_i387_ext.
* gdbtypes.h (builtin_type): Add builtin_ieee_single,
builtin_ieee_double and builtin_i387_ext.
* i386-tdep.c (i386_extract_return_value): Replace i387_ext_type
with builtin_i387_ext.
(i386_store_return_value): Likewise.
(i386_register_type): Likewise.
(i387_ext_type): Removed.
* i386-tdep.h (gdbarch_tdep): Remove i387_ext_type.
(i387_ext_type): Removed.
* target-descriptions.c (tdesc_gdb_type): Use
builtin_ieee_single and builtin_ieee_double.
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 2b15141..51d6824 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -113,7 +113,7 @@ amd64_register_type (struct gdbarch *gdbarch, int regnum)
if (regnum >= AMD64_CS_REGNUM && regnum <= AMD64_GS_REGNUM)
return builtin_type (gdbarch)->builtin_int32;
if (regnum >= AMD64_ST0_REGNUM && regnum <= AMD64_ST0_REGNUM + 7)
- return i387_ext_type (gdbarch);
+ return builtin_type (gdbarch)->builtin_i387_ext;
if (regnum >= AMD64_FCTRL_REGNUM && regnum <= AMD64_FCTRL_REGNUM + 7)
return builtin_type (gdbarch)->builtin_int32;
if (regnum >= AMD64_XMM0_REGNUM && regnum <= AMD64_XMM0_REGNUM + 15)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 46846c4..397adba 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3470,6 +3470,16 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
TYPE_NOTTEXT (builtin_type->builtin_int8) = 1;
TYPE_NOTTEXT (builtin_type->builtin_uint8) = 1;
+ builtin_type->builtin_ieee_single
+ = arch_float_type (gdbarch, -1, "builtin_type_ieee_single",
+ floatformats_ieee_single);
+ builtin_type->builtin_ieee_double
+ = arch_float_type (gdbarch, -1, "builtin_type_ieee_double",
+ floatformats_ieee_double);
+ builtin_type->builtin_i387_ext
+ = arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
+ floatformats_i387_ext);
+
/* Default data/code pointer types. */
builtin_type->builtin_data_ptr
= lookup_pointer_type (builtin_type->builtin_void);
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 643fa03..ad8153f 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1122,6 +1122,9 @@ struct builtin_type
struct type *builtin_int128;
struct type *builtin_uint128;
+ struct type *builtin_ieee_single;
+ struct type *builtin_ieee_double;
+ struct type *builtin_i387_ext;
/* Pointer types. */
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 83aa81f..3888799 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -1905,7 +1905,9 @@ i386_extract_return_value (struct gdbarch *gdbarch, struct type *type,
exactly how it would happen on the target itself, but it is
the best we can do. */
regcache_raw_read (regcache, I386_ST0_REGNUM, buf);
- convert_typed_floating (buf, i387_ext_type (gdbarch), valbuf, type);
+ convert_typed_floating (buf,
+ builtin_type (gdbarch)->builtin_i387_ext,
+ valbuf, type);
}
else
{
@@ -1959,7 +1961,8 @@ i386_store_return_value (struct gdbarch *gdbarch, struct type *type,
floating-point format used by the FPU. This is probably
not exactly how it would happen on the target itself, but
it is the best we can do. */
- convert_typed_floating (valbuf, type, buf, i387_ext_type (gdbarch));
+ convert_typed_floating (valbuf, type, buf,
+ builtin_type (gdbarch)->builtin_i387_ext);
regcache_raw_write (regcache, I386_ST0_REGNUM, buf);
/* Set the top of the floating-point register stack to 7. The
@@ -2178,19 +2181,6 @@ i386_mxcsr_type (struct gdbarch *gdbarch)
return tdep->i386_mxcsr_type;
}
-struct type *
-i387_ext_type (struct gdbarch *gdbarch)
-{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-
- if (!tdep->i387_ext_type)
- tdep->i387_ext_type
- = arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
- floatformats_i387_ext);
-
- return tdep->i387_ext_type;
-}
-
/* Construct vector type for MMX registers. */
struct type *
i386_mmx_type (struct gdbarch *gdbarch)
@@ -2299,7 +2289,7 @@ i386_register_type (struct gdbarch *gdbarch, int regnum)
return builtin_type (gdbarch)->builtin_data_ptr;
if (i386_fp_regnum_p (gdbarch, regnum))
- return i387_ext_type (gdbarch);
+ return builtin_type (gdbarch)->builtin_i387_ext;
if (i386_mmx_regnum_p (gdbarch, regnum))
return i386_mmx_type (gdbarch);
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index 5915eb9..bb3cc14 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -151,7 +151,6 @@ struct gdbarch_tdep
struct type *i386_mxcsr_type;
struct type *i386_mmx_type;
struct type *i386_sse_type;
- struct type *i387_ext_type;
/* Process record/replay target. */
/* The map for registers because the AMD64's registers order
@@ -244,7 +243,6 @@ extern struct type *i386_eflags_type (struct gdbarch *gdbarch);
extern struct type *i386_mxcsr_type (struct gdbarch *gdbarch);
extern struct type *i386_mmx_type (struct gdbarch *gdbarch);
extern struct type *i386_sse_type (struct gdbarch *gdbarch);
-extern struct type *i387_ext_type (struct gdbarch *gdbarch);
/* Segment selectors. */
#define I386_SEL_RPL 0x0003 /* Requester's Privilege Level mask. */
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index 3fb5b56..25dcae5 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -47,7 +47,8 @@ print_i387_value (struct gdbarch *gdbarch,
of certain numbers such as NaNs, even if GDB is running natively.
This is fine since our caller already detects such special
numbers and we print the hexadecimal representation anyway. */
- value = extract_typed_floating (raw, i387_ext_type (gdbarch));
+ value = extract_typed_floating (raw,
+ builtin_type (gdbarch)->builtin_i387_ext);
/* We try to print 19 digits. The last digit may or may not contain
garbage, but we'd better print one too many. We need enough room
@@ -293,7 +294,7 @@ i387_convert_register_p (struct gdbarch *gdbarch, int regnum, struct type *type)
{
/* Floating point registers must be converted unless we are
accessing them in their hardware type. */
- if (type == i387_ext_type (gdbarch))
+ if (type == builtin_type (gdbarch)->builtin_i387_ext)
return 0;
else
return 1;
@@ -324,7 +325,8 @@ i387_register_to_value (struct frame_info *frame, int regnum,
/* Convert to TYPE. */
get_frame_register (frame, regnum, from);
- convert_typed_floating (from, i387_ext_type (gdbarch), to, type);
+ convert_typed_floating (from, builtin_type (gdbarch)->builtin_i387_ext,
+ to, type);
}
/* Write the contents FROM of a value of type TYPE into register
@@ -348,7 +350,8 @@ i387_value_to_register (struct frame_info *frame, int regnum,
}
/* Convert from TYPE. */
- convert_typed_floating (from, type, to, i387_ext_type (gdbarch));
+ convert_typed_floating (from, type, to,
+ builtin_type (gdbarch)->builtin_i387_ext);
put_frame_register (frame, regnum, to);
}
\f
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 4fbc72c..cef91e5 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -532,12 +532,10 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
return builtin_type (gdbarch)->builtin_data_ptr;
case TDESC_TYPE_IEEE_SINGLE:
- return arch_float_type (gdbarch, -1, "builtin_type_ieee_single",
- floatformats_ieee_single);
+ return builtin_type (gdbarch)->builtin_ieee_single;
case TDESC_TYPE_IEEE_DOUBLE:
- return arch_float_type (gdbarch, -1, "builtin_type_ieee_double",
- floatformats_ieee_double);
+ return builtin_type (gdbarch)->builtin_ieee_double;
case TDESC_TYPE_ARM_FPA_EXT:
return arch_float_type (gdbarch, -1, "builtin_type_arm_ext",
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: PATCH: Add builtin floating point types
2010-02-05 1:15 PATCH: PATCH: Add builtin floating point types H.J. Lu
@ 2010-02-07 21:52 ` Mark Kettenis
2010-02-07 22:00 ` H.J. Lu
2010-02-08 18:55 ` PATCH: Cache types from target description H.J. Lu
1 sibling, 1 reply; 20+ messages in thread
From: Mark Kettenis @ 2010-02-07 21:52 UTC (permalink / raw)
To: hjl.tools; +Cc: gdb-patches, mark.kettenis
> Date: Thu, 4 Feb 2010 17:14:47 -0800
> From: "H.J. Lu" <hongjiu.lu@intel.com>
>
> I am resending this patch. The motivation is I am working on x86 xml
> target descriptions. x86 has i387_ext type. I added
>
> case TDESC_TYPE_I387_EXT:
> return arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
> floatformats_i387_ext);
>
> to tdesc_gdb_type. I would up 8 i387_ext types at 8 different addresses
> with the same bits. x86 does
>
> if (i386_fp_regnum_p (gdbarch, regnum))
> {
> /* Floating point registers must be converted unless we are
> accessing them in their hardware type. */
> if (type == i387_ext_type (gdbarch))
> return 0;
> else
> return 1;
> }
>
> It expects 2 i387_ext types should have the same address. This
> patch caches ieee_single, ieee_double and i387_ext. OK to install?
Sorry, but I don't like this diff. At the very least, keep the
i387_ext_type() function around. It makes the diff far less invasive.
Adding architecture-specific types the list of builtin types feels
wrong as well.
> H.J.
> ---
> 2010-02-04 H.J. Lu <hongjiu.lu@intel.com>
>
> * amd64-tdep.c (amd64_register_type): Replace i387_ext_type
> with builtin_i387_ext.
> * i387-tdep.c (print_i387_value): Likewise.
> (i387_convert_register_p): Likewise.
> (i387_register_to_value): Likewise.
> (i387_value_to_register): Likewise.
>
> * gdbtypes.c (gdbtypes_post_init): Initialize
> builtin_ieee_single, builtin_ieee_double and builtin_i387_ext.
>
> * gdbtypes.h (builtin_type): Add builtin_ieee_single,
> builtin_ieee_double and builtin_i387_ext.
>
> * i386-tdep.c (i386_extract_return_value): Replace i387_ext_type
> with builtin_i387_ext.
> (i386_store_return_value): Likewise.
> (i386_register_type): Likewise.
> (i387_ext_type): Removed.
>
> * i386-tdep.h (gdbarch_tdep): Remove i387_ext_type.
> (i387_ext_type): Removed.
>
> * target-descriptions.c (tdesc_gdb_type): Use
> builtin_ieee_single and builtin_ieee_double.
>
> diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
> index 2b15141..51d6824 100644
> --- a/gdb/amd64-tdep.c
> +++ b/gdb/amd64-tdep.c
> @@ -113,7 +113,7 @@ amd64_register_type (struct gdbarch *gdbarch, int regnum)
> if (regnum >= AMD64_CS_REGNUM && regnum <= AMD64_GS_REGNUM)
> return builtin_type (gdbarch)->builtin_int32;
> if (regnum >= AMD64_ST0_REGNUM && regnum <= AMD64_ST0_REGNUM + 7)
> - return i387_ext_type (gdbarch);
> + return builtin_type (gdbarch)->builtin_i387_ext;
> if (regnum >= AMD64_FCTRL_REGNUM && regnum <= AMD64_FCTRL_REGNUM + 7)
> return builtin_type (gdbarch)->builtin_int32;
> if (regnum >= AMD64_XMM0_REGNUM && regnum <= AMD64_XMM0_REGNUM + 15)
> diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
> index 46846c4..397adba 100644
> --- a/gdb/gdbtypes.c
> +++ b/gdb/gdbtypes.c
> @@ -3470,6 +3470,16 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
> TYPE_NOTTEXT (builtin_type->builtin_int8) = 1;
> TYPE_NOTTEXT (builtin_type->builtin_uint8) = 1;
>
> + builtin_type->builtin_ieee_single
> + = arch_float_type (gdbarch, -1, "builtin_type_ieee_single",
> + floatformats_ieee_single);
> + builtin_type->builtin_ieee_double
> + = arch_float_type (gdbarch, -1, "builtin_type_ieee_double",
> + floatformats_ieee_double);
> + builtin_type->builtin_i387_ext
> + = arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
> + floatformats_i387_ext);
> +
> /* Default data/code pointer types. */
> builtin_type->builtin_data_ptr
> = lookup_pointer_type (builtin_type->builtin_void);
> diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
> index 643fa03..ad8153f 100644
> --- a/gdb/gdbtypes.h
> +++ b/gdb/gdbtypes.h
> @@ -1122,6 +1122,9 @@ struct builtin_type
> struct type *builtin_int128;
> struct type *builtin_uint128;
>
> + struct type *builtin_ieee_single;
> + struct type *builtin_ieee_double;
> + struct type *builtin_i387_ext;
>
> /* Pointer types. */
>
> diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
> index 83aa81f..3888799 100644
> --- a/gdb/i386-tdep.c
> +++ b/gdb/i386-tdep.c
> @@ -1905,7 +1905,9 @@ i386_extract_return_value (struct gdbarch *gdbarch, struct type *type,
> exactly how it would happen on the target itself, but it is
> the best we can do. */
> regcache_raw_read (regcache, I386_ST0_REGNUM, buf);
> - convert_typed_floating (buf, i387_ext_type (gdbarch), valbuf, type);
> + convert_typed_floating (buf,
> + builtin_type (gdbarch)->builtin_i387_ext,
> + valbuf, type);
> }
> else
> {
> @@ -1959,7 +1961,8 @@ i386_store_return_value (struct gdbarch *gdbarch, struct type *type,
> floating-point format used by the FPU. This is probably
> not exactly how it would happen on the target itself, but
> it is the best we can do. */
> - convert_typed_floating (valbuf, type, buf, i387_ext_type (gdbarch));
> + convert_typed_floating (valbuf, type, buf,
> + builtin_type (gdbarch)->builtin_i387_ext);
> regcache_raw_write (regcache, I386_ST0_REGNUM, buf);
>
> /* Set the top of the floating-point register stack to 7. The
> @@ -2178,19 +2181,6 @@ i386_mxcsr_type (struct gdbarch *gdbarch)
> return tdep->i386_mxcsr_type;
> }
>
> -struct type *
> -i387_ext_type (struct gdbarch *gdbarch)
> -{
> - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> -
> - if (!tdep->i387_ext_type)
> - tdep->i387_ext_type
> - = arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
> - floatformats_i387_ext);
> -
> - return tdep->i387_ext_type;
> -}
> -
> /* Construct vector type for MMX registers. */
> struct type *
> i386_mmx_type (struct gdbarch *gdbarch)
> @@ -2299,7 +2289,7 @@ i386_register_type (struct gdbarch *gdbarch, int regnum)
> return builtin_type (gdbarch)->builtin_data_ptr;
>
> if (i386_fp_regnum_p (gdbarch, regnum))
> - return i387_ext_type (gdbarch);
> + return builtin_type (gdbarch)->builtin_i387_ext;
>
> if (i386_mmx_regnum_p (gdbarch, regnum))
> return i386_mmx_type (gdbarch);
> diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
> index 5915eb9..bb3cc14 100644
> --- a/gdb/i386-tdep.h
> +++ b/gdb/i386-tdep.h
> @@ -151,7 +151,6 @@ struct gdbarch_tdep
> struct type *i386_mxcsr_type;
> struct type *i386_mmx_type;
> struct type *i386_sse_type;
> - struct type *i387_ext_type;
>
> /* Process record/replay target. */
> /* The map for registers because the AMD64's registers order
> @@ -244,7 +243,6 @@ extern struct type *i386_eflags_type (struct gdbarch *gdbarch);
> extern struct type *i386_mxcsr_type (struct gdbarch *gdbarch);
> extern struct type *i386_mmx_type (struct gdbarch *gdbarch);
> extern struct type *i386_sse_type (struct gdbarch *gdbarch);
> -extern struct type *i387_ext_type (struct gdbarch *gdbarch);
>
> /* Segment selectors. */
> #define I386_SEL_RPL 0x0003 /* Requester's Privilege Level mask. */
> diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
> index 3fb5b56..25dcae5 100644
> --- a/gdb/i387-tdep.c
> +++ b/gdb/i387-tdep.c
> @@ -47,7 +47,8 @@ print_i387_value (struct gdbarch *gdbarch,
> of certain numbers such as NaNs, even if GDB is running natively.
> This is fine since our caller already detects such special
> numbers and we print the hexadecimal representation anyway. */
> - value = extract_typed_floating (raw, i387_ext_type (gdbarch));
> + value = extract_typed_floating (raw,
> + builtin_type (gdbarch)->builtin_i387_ext);
>
> /* We try to print 19 digits. The last digit may or may not contain
> garbage, but we'd better print one too many. We need enough room
> @@ -293,7 +294,7 @@ i387_convert_register_p (struct gdbarch *gdbarch, int regnum, struct type *type)
> {
> /* Floating point registers must be converted unless we are
> accessing them in their hardware type. */
> - if (type == i387_ext_type (gdbarch))
> + if (type == builtin_type (gdbarch)->builtin_i387_ext)
> return 0;
> else
> return 1;
> @@ -324,7 +325,8 @@ i387_register_to_value (struct frame_info *frame, int regnum,
>
> /* Convert to TYPE. */
> get_frame_register (frame, regnum, from);
> - convert_typed_floating (from, i387_ext_type (gdbarch), to, type);
> + convert_typed_floating (from, builtin_type (gdbarch)->builtin_i387_ext,
> + to, type);
> }
>
> /* Write the contents FROM of a value of type TYPE into register
> @@ -348,7 +350,8 @@ i387_value_to_register (struct frame_info *frame, int regnum,
> }
>
> /* Convert from TYPE. */
> - convert_typed_floating (from, type, to, i387_ext_type (gdbarch));
> + convert_typed_floating (from, type, to,
> + builtin_type (gdbarch)->builtin_i387_ext);
> put_frame_register (frame, regnum, to);
> }
> \f
> diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
> index 4fbc72c..cef91e5 100644
> --- a/gdb/target-descriptions.c
> +++ b/gdb/target-descriptions.c
> @@ -532,12 +532,10 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
> return builtin_type (gdbarch)->builtin_data_ptr;
>
> case TDESC_TYPE_IEEE_SINGLE:
> - return arch_float_type (gdbarch, -1, "builtin_type_ieee_single",
> - floatformats_ieee_single);
> + return builtin_type (gdbarch)->builtin_ieee_single;
>
> case TDESC_TYPE_IEEE_DOUBLE:
> - return arch_float_type (gdbarch, -1, "builtin_type_ieee_double",
> - floatformats_ieee_double);
> + return builtin_type (gdbarch)->builtin_ieee_double;
>
> case TDESC_TYPE_ARM_FPA_EXT:
> return arch_float_type (gdbarch, -1, "builtin_type_arm_ext",
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: PATCH: Add builtin floating point types
2010-02-07 21:52 ` Mark Kettenis
@ 2010-02-07 22:00 ` H.J. Lu
2010-02-07 22:14 ` Daniel Jacobowitz
0 siblings, 1 reply; 20+ messages in thread
From: H.J. Lu @ 2010-02-07 22:00 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On Sun, Feb 7, 2010 at 1:52 PM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> Date: Thu, 4 Feb 2010 17:14:47 -0800
>> From: "H.J. Lu" <hongjiu.lu@intel.com>
>>
>> I am resending this patch. The motivation is I am working on x86 xml
>> target descriptions. x86 has i387_ext type. I added
>>
>> case TDESC_TYPE_I387_EXT:
>> return arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
>> floatformats_i387_ext);
>>
>> to tdesc_gdb_type. I would up 8 i387_ext types at 8 different addresses
>> with the same bits. x86 does
>>
>> if (i386_fp_regnum_p (gdbarch, regnum))
>> {
>> /* Floating point registers must be converted unless we are
>> accessing them in their hardware type. */
>> if (type == i387_ext_type (gdbarch))
>> return 0;
>> else
>> return 1;
>> }
>>
>> It expects 2 i387_ext types should have the same address. This
>> patch caches ieee_single, ieee_double and i387_ext. OK to install?
>
> Sorry, but I don't like this diff. At the very least, keep the
> i387_ext_type() function around. It makes the diff far less invasive.
Is there a way to call i387_ext_type from target-descriptions.c?
Otherwise, XML target description will create multiple i386_ext
types and won't work for x86 since x86 requires single i386_ext
type per arch.
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: PATCH: Add builtin floating point types
2010-02-07 22:00 ` H.J. Lu
@ 2010-02-07 22:14 ` Daniel Jacobowitz
2010-02-07 22:25 ` H.J. Lu
0 siblings, 1 reply; 20+ messages in thread
From: Daniel Jacobowitz @ 2010-02-07 22:14 UTC (permalink / raw)
To: H.J. Lu; +Cc: Mark Kettenis, gdb-patches
On Sun, Feb 07, 2010 at 02:00:36PM -0800, H.J. Lu wrote:
> Is there a way to call i387_ext_type from target-descriptions.c?
> Otherwise, XML target description will create multiple i386_ext
> types and won't work for x86 since x86 requires single i386_ext
> type per arch.
Maybe the common code could cache the created types?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: PATCH: Add builtin floating point types
2010-02-07 22:14 ` Daniel Jacobowitz
@ 2010-02-07 22:25 ` H.J. Lu
2010-02-07 23:03 ` H.J. Lu
0 siblings, 1 reply; 20+ messages in thread
From: H.J. Lu @ 2010-02-07 22:25 UTC (permalink / raw)
To: H.J. Lu, Mark Kettenis, gdb-patches
On Sun, Feb 7, 2010 at 2:14 PM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Sun, Feb 07, 2010 at 02:00:36PM -0800, H.J. Lu wrote:
>> Is there a way to call i387_ext_type from target-descriptions.c?
>> Otherwise, XML target description will create multiple i386_ext
>> types and won't work for x86 since x86 requires single i386_ext
>> type per arch.
>
> Maybe the common code could cache the created types?
>
I need a place to hold the created type in the common code.
When do I put it?
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: PATCH: Add builtin floating point types
2010-02-07 22:25 ` H.J. Lu
@ 2010-02-07 23:03 ` H.J. Lu
2010-02-07 23:08 ` Daniel Jacobowitz
0 siblings, 1 reply; 20+ messages in thread
From: H.J. Lu @ 2010-02-07 23:03 UTC (permalink / raw)
To: H.J. Lu, Mark Kettenis, gdb-patches
On Sun, Feb 7, 2010 at 2:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sun, Feb 7, 2010 at 2:14 PM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
>> On Sun, Feb 07, 2010 at 02:00:36PM -0800, H.J. Lu wrote:
>>> Is there a way to call i387_ext_type from target-descriptions.c?
>>> Otherwise, XML target description will create multiple i386_ext
>>> types and won't work for x86 since x86 requires single i386_ext
>>> type per arch.
>>
>> Maybe the common code could cache the created types?
>>
>
> I need a place to hold the created type in the common code.
> When do I put it?
>
How about adding it to common code without initializing it?
I will lazy initialize it in target-description.c only when it
is used?
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: PATCH: Add builtin floating point types
2010-02-07 23:03 ` H.J. Lu
@ 2010-02-07 23:08 ` Daniel Jacobowitz
2010-02-08 2:17 ` H.J. Lu
0 siblings, 1 reply; 20+ messages in thread
From: Daniel Jacobowitz @ 2010-02-07 23:08 UTC (permalink / raw)
To: H.J. Lu; +Cc: Mark Kettenis, gdb-patches
On Sun, Feb 07, 2010 at 03:03:09PM -0800, H.J. Lu wrote:
> How about adding it to common code without initializing it?
> I will lazy initialize it in target-description.c only when it
> is used?
It's easy to add per-gdbarch variables using gdbarch_data.
I was suggesting the cache at the level of arch_floating_type (or
however it's called).
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: PATCH: Add builtin floating point types
2010-02-07 23:08 ` Daniel Jacobowitz
@ 2010-02-08 2:17 ` H.J. Lu
2010-02-08 4:17 ` Daniel Jacobowitz
0 siblings, 1 reply; 20+ messages in thread
From: H.J. Lu @ 2010-02-08 2:17 UTC (permalink / raw)
To: H.J. Lu, Mark Kettenis, gdb-patches
On Sun, Feb 7, 2010 at 3:08 PM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Sun, Feb 07, 2010 at 03:03:09PM -0800, H.J. Lu wrote:
>> How about adding it to common code without initializing it?
>> I will lazy initialize it in target-description.c only when it
>> is used?
>
> It's easy to add per-gdbarch variables using gdbarch_data.
> I was suggesting the cache at the level of arch_floating_type (or
> however it's called).
>
We have builtin_float and other float types in gdbtypes.c,
using gdbarch_data. I will add
/* Return the type table for the specified architecture. */
extern const struct arch_floating_type *arch_floating_type (struct
gdbarch *gdbarch);
with gdbfloattypes.[ch].
--
H.J.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: PATCH: Add builtin floating point types
2010-02-08 2:17 ` H.J. Lu
@ 2010-02-08 4:17 ` Daniel Jacobowitz
2010-02-08 5:16 ` H.J. Lu
0 siblings, 1 reply; 20+ messages in thread
From: Daniel Jacobowitz @ 2010-02-08 4:17 UTC (permalink / raw)
To: H.J. Lu; +Cc: Mark Kettenis, gdb-patches
On Sun, Feb 07, 2010 at 06:16:55PM -0800, H.J. Lu wrote:
> We have builtin_float and other float types in gdbtypes.c,
> using gdbarch_data. I will add
>
> /* Return the type table for the specified architecture. */
> extern const struct arch_floating_type *arch_floating_type (struct
> gdbarch *gdbarch);
>
> with gdbfloattypes.[ch].
I can't figure out what you mean by this at all.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: PATCH: Add builtin floating point types
2010-02-08 4:17 ` Daniel Jacobowitz
@ 2010-02-08 5:16 ` H.J. Lu
2010-02-08 14:14 ` Daniel Jacobowitz
0 siblings, 1 reply; 20+ messages in thread
From: H.J. Lu @ 2010-02-08 5:16 UTC (permalink / raw)
To: H.J. Lu, Mark Kettenis, gdb-patches
On Sun, Feb 7, 2010 at 8:17 PM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Sun, Feb 07, 2010 at 06:16:55PM -0800, H.J. Lu wrote:
>> We have builtin_float and other float types in gdbtypes.c,
>> using gdbarch_data. I will add
>>
>> /* Return the type table for the specified architecture. */
>> extern const struct arch_floating_type *arch_floating_type (struct
>> gdbarch *gdbarch);
>>
>> with gdbfloattypes.[ch].
>
> I can't figure out what you mean by this at all.
>
I will add a new file, archtypes.c, which provides
extern const struct arch_type *arch_type (struct gdbarch *gdbarch);
which is similar to
extern const struct builtin_type *builtin_type (struct gdbarch *gdbarch);
in gdbtypes.c. struct arch_type will have
struct type *arch_ieee_single;
struct type *arch_ieee_double;
struct type *arch_i387_ext;
They will be lazy initialized. I thought that was what you suggested.
--
H.J.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: PATCH: Add builtin floating point types
2010-02-08 5:16 ` H.J. Lu
@ 2010-02-08 14:14 ` Daniel Jacobowitz
2010-02-08 14:56 ` H.J. Lu
2010-02-08 18:56 ` H.J. Lu
0 siblings, 2 replies; 20+ messages in thread
From: Daniel Jacobowitz @ 2010-02-08 14:14 UTC (permalink / raw)
To: H.J. Lu; +Cc: Mark Kettenis, gdb-patches
On Sun, Feb 07, 2010 at 09:16:25PM -0800, H.J. Lu wrote:
> in gdbtypes.c. struct arch_type will have
>
> struct type *arch_ieee_single;
> struct type *arch_ieee_double;
> struct type *arch_i387_ext;
>
> They will be lazy initialized. I thought that was what you suggested.
This hasn't changed anything; it still has to know about i387_ext.
There are at least two options. We could use a per-gdbarch hash table
to cache the result of arch_float_type (in arch_float_type, not in its
caller). Or we could put the cache in tdesc_gdb_type, which is
probably easier.
There's already an ARM-specific type there. It's there because the
XML format already has to know the magic arch-specific names and
document them in the GDB manual appendix.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: PATCH: Add builtin floating point types
2010-02-08 14:14 ` Daniel Jacobowitz
@ 2010-02-08 14:56 ` H.J. Lu
2010-02-08 18:56 ` H.J. Lu
1 sibling, 0 replies; 20+ messages in thread
From: H.J. Lu @ 2010-02-08 14:56 UTC (permalink / raw)
To: H.J. Lu, Mark Kettenis, gdb-patches
On Mon, Feb 8, 2010 at 6:14 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Sun, Feb 07, 2010 at 09:16:25PM -0800, H.J. Lu wrote:
>> in gdbtypes.c. struct arch_type will have
>>
>> struct type *arch_ieee_single;
>> struct type *arch_ieee_double;
>> struct type *arch_i387_ext;
>>
>> They will be lazy initialized. I thought that was what you suggested.
>
> This hasn't changed anything; it still has to know about i387_ext.
>
> There are at least two options. We could use a per-gdbarch hash table
> to cache the result of arch_float_type (in arch_float_type, not in its
> caller). Or we could put the cache in tdesc_gdb_type, which is
> probably easier.
Something like
/* Return the type associated with ID, from the target description. */
struct type *tdesc_gdb_type (struct gdbarch *gdbarch, const char *id);
--
H.J.
^ permalink raw reply [flat|nested] 20+ messages in thread
* PATCH: Cache types from target description
2010-02-05 1:15 PATCH: PATCH: Add builtin floating point types H.J. Lu
2010-02-07 21:52 ` Mark Kettenis
@ 2010-02-08 18:55 ` H.J. Lu
2010-02-09 15:45 ` H.J. Lu
1 sibling, 1 reply; 20+ messages in thread
From: H.J. Lu @ 2010-02-08 18:55 UTC (permalink / raw)
To: H.J. Lu; +Cc: GDB, Mark Kettenis
On Thu, Feb 04, 2010 at 05:14:47PM -0800, H.J. Lu wrote:
> I am resending this patch. The motivation is I am working on x86 xml
> target descriptions. x86 has i387_ext type. I added
>
> case TDESC_TYPE_I387_EXT:
> return arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
> floatformats_i387_ext);
>
> to tdesc_gdb_type. I would up 8 i387_ext types at 8 different addresses
> with the same bits. x86 does
>
> if (i386_fp_regnum_p (gdbarch, regnum))
> {
> /* Floating point registers must be converted unless we are
> accessing them in their hardware type. */
> if (type == i387_ext_type (gdbarch))
> return 0;
> else
> return 1;
> }
>
> It expects 2 i387_ext types should have the same address. This
> patch caches ieee_single, ieee_double and i387_ext. OK to install?
>
Here is a different patch to cache types from target description.
tdesc_find_type will be used in i387_ext_type to lookup "i387_ext".
OK to install?
Thanks.
H.J.
---
2010-02-08 H.J. Lu <hongjiu.lu@intel.com>
* target-descriptions.c (tdesc_type): Add TDESC_TYPE_I387_EXT,
TDESC_TYPE_I386_EFLAGS and TDESC_TYPE_I386_MXCSR.
(tdesc_predefined_types): Add i387_ext, i386_eflags and
i386_mxcsr.
(tdesc_find_type): New.
(tdesc_gdb_type): Use tdesc_find_type. Handle TDESC_TYPE_I387_EXT,
TDESC_TYPE_I386_EFLAGS and TDESC_TYPE_I386_MXCSR.
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 4fbc72c..ae22163 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -117,6 +117,9 @@ typedef struct tdesc_type
TDESC_TYPE_IEEE_SINGLE,
TDESC_TYPE_IEEE_DOUBLE,
TDESC_TYPE_ARM_FPA_EXT,
+ TDESC_TYPE_I387_EXT,
+ TDESC_TYPE_I386_EFLAGS,
+ TDESC_TYPE_I386_MXCSR,
/* Types defined by a target feature. */
TDESC_TYPE_VECTOR,
@@ -461,7 +464,10 @@ static struct tdesc_type tdesc_predefined_types[] =
{ "data_ptr", TDESC_TYPE_DATA_PTR },
{ "ieee_single", TDESC_TYPE_IEEE_SINGLE },
{ "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
- { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT }
+ { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
+ { "i387_ext", TDESC_TYPE_I387_EXT },
+ { "i386_eflags", TDESC_TYPE_I386_EFLAGS },
+ { "i386_mxcsr", TDESC_TYPE_I386_MXCSR }
};
/* Return the type associated with ID in the context of FEATURE, or
@@ -486,12 +492,38 @@ tdesc_named_type (const struct tdesc_feature *feature, const char *id)
return NULL;
}
+/* Lookup type associated with ID. */
+
+struct type *
+tdesc_find_type (struct gdbarch *gdbarch, const char *id)
+{
+ struct tdesc_arch_reg *reg;
+ struct tdesc_arch_data *data;
+ int i, num_regs;
+
+ data = gdbarch_data (gdbarch, tdesc_data);
+ num_regs = VEC_length (tdesc_arch_reg, data->arch_regs);
+ for (i = 0; i < num_regs; i++)
+ {
+ reg = VEC_index (tdesc_arch_reg, data->arch_regs, i);
+ if (reg->reg
+ && reg->reg->tdesc_type
+ && reg->type
+ && strcmp (id, reg->reg->tdesc_type->name) == 0)
+ return reg->type;
+ }
+
+ return NULL;
+}
+
/* Construct, if necessary, and return the GDB type implementing target
type TDESC_TYPE for architecture GDBARCH. */
static struct type *
tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
{
+ struct type *type;
+
switch (tdesc_type->kind)
{
/* Predefined types. */
@@ -531,6 +563,16 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
case TDESC_TYPE_DATA_PTR:
return builtin_type (gdbarch)->builtin_data_ptr;
+ default:
+ break;
+ }
+
+ type = tdesc_find_type (gdbarch, tdesc_type->name);
+ if (type)
+ return type;
+
+ switch (tdesc_type->kind)
+ {
case TDESC_TYPE_IEEE_SINGLE:
return arch_float_type (gdbarch, -1, "builtin_type_ieee_single",
floatformats_ieee_single);
@@ -543,6 +585,58 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
return arch_float_type (gdbarch, -1, "builtin_type_arm_ext",
floatformats_arm_ext);
+ case TDESC_TYPE_I387_EXT:
+ return arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
+ floatformats_i387_ext);
+
+ case TDESC_TYPE_I386_EFLAGS:
+ {
+ struct type *type;
+
+ type = arch_flags_type (gdbarch, "builtin_type_i386_mxcsr", 4);
+ append_flags_type_flag (type, 0, "IE");
+ append_flags_type_flag (type, 1, "DE");
+ append_flags_type_flag (type, 2, "ZE");
+ append_flags_type_flag (type, 3, "OE");
+ append_flags_type_flag (type, 4, "UE");
+ append_flags_type_flag (type, 5, "PE");
+ append_flags_type_flag (type, 6, "DAZ");
+ append_flags_type_flag (type, 7, "IM");
+ append_flags_type_flag (type, 8, "DM");
+ append_flags_type_flag (type, 9, "ZM");
+ append_flags_type_flag (type, 10, "OM");
+ append_flags_type_flag (type, 11, "UM");
+ append_flags_type_flag (type, 12, "PM");
+ append_flags_type_flag (type, 15, "FZ");
+
+ return type;
+ }
+ break;
+
+ case TDESC_TYPE_I386_MXCSR:
+ {
+ struct type *type;
+
+ type = arch_flags_type (gdbarch, "builtin_type_i386_mxcsr", 4);
+ append_flags_type_flag (type, 0, "IE");
+ append_flags_type_flag (type, 1, "DE");
+ append_flags_type_flag (type, 2, "ZE");
+ append_flags_type_flag (type, 3, "OE");
+ append_flags_type_flag (type, 4, "UE");
+ append_flags_type_flag (type, 5, "PE");
+ append_flags_type_flag (type, 6, "DAZ");
+ append_flags_type_flag (type, 7, "IM");
+ append_flags_type_flag (type, 8, "DM");
+ append_flags_type_flag (type, 9, "ZM");
+ append_flags_type_flag (type, 10, "OM");
+ append_flags_type_flag (type, 11, "UM");
+ append_flags_type_flag (type, 12, "PM");
+ append_flags_type_flag (type, 15, "FZ");
+
+ return type;
+ }
+ break;
+
/* Types defined by a target feature. */
case TDESC_TYPE_VECTOR:
{
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index 17f52eb..da0564b 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -176,6 +176,10 @@ const char *tdesc_register_name (struct gdbarch *gdbarch, int regno);
struct type *tdesc_register_type (struct gdbarch *gdbarch, int regno);
+/* Return the type associated with ID, from the target description. */
+
+struct type *tdesc_find_type (struct gdbarch *gdbarch, const char *id);
+
/* Check whether REGNUM is a member of REGGROUP using the target
description. Return -1 if the target description does not
specify a group. */
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: PATCH: Add builtin floating point types
2010-02-08 14:14 ` Daniel Jacobowitz
2010-02-08 14:56 ` H.J. Lu
@ 2010-02-08 18:56 ` H.J. Lu
1 sibling, 0 replies; 20+ messages in thread
From: H.J. Lu @ 2010-02-08 18:56 UTC (permalink / raw)
To: H.J. Lu, Mark Kettenis, gdb-patches
On Mon, Feb 8, 2010 at 6:14 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Sun, Feb 07, 2010 at 09:16:25PM -0800, H.J. Lu wrote:
>> in gdbtypes.c. struct arch_type will have
>>
>> struct type *arch_ieee_single;
>> struct type *arch_ieee_double;
>> struct type *arch_i387_ext;
>>
>> They will be lazy initialized. I thought that was what you suggested.
>
> This hasn't changed anything; it still has to know about i387_ext.
>
> There are at least two options. We could use a per-gdbarch hash table
> to cache the result of arch_float_type (in arch_float_type, not in its
> caller). Or we could put the cache in tdesc_gdb_type, which is
> probably easier.
A patch is posted at
http://sourceware.org/ml/gdb-patches/2010-02/msg00214.html
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Cache types from target description
2010-02-08 18:55 ` PATCH: Cache types from target description H.J. Lu
@ 2010-02-09 15:45 ` H.J. Lu
2010-02-09 18:47 ` Eli Zaretskii
2010-02-10 18:38 ` Daniel Jacobowitz
0 siblings, 2 replies; 20+ messages in thread
From: H.J. Lu @ 2010-02-09 15:45 UTC (permalink / raw)
To: H.J. Lu; +Cc: GDB, Mark Kettenis
On Mon, Feb 08, 2010 at 10:54:54AM -0800, H.J. Lu wrote:
> On Thu, Feb 04, 2010 at 05:14:47PM -0800, H.J. Lu wrote:
> > I am resending this patch. The motivation is I am working on x86 xml
> > target descriptions. x86 has i387_ext type. I added
> >
> > case TDESC_TYPE_I387_EXT:
> > return arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
> > floatformats_i387_ext);
> >
> > to tdesc_gdb_type. I would up 8 i387_ext types at 8 different addresses
> > with the same bits. x86 does
> >
> > if (i386_fp_regnum_p (gdbarch, regnum))
> > {
> > /* Floating point registers must be converted unless we are
> > accessing them in their hardware type. */
> > if (type == i387_ext_type (gdbarch))
> > return 0;
> > else
> > return 1;
> > }
> >
> > It expects 2 i387_ext types should have the same address. This
> > patch caches ieee_single, ieee_double and i387_ext. OK to install?
> >
>
>
> Here is a different patch to cache types from target description.
> tdesc_find_type will be used in i387_ext_type to lookup "i387_ext".
> OK to install?
>
Here is the updated patch. I fixed i386_eflags and documented them.
OK to install?
Thanks.
H.J.
---
gdb/
2010-02-09 H.J. Lu <hongjiu.lu@intel.com>
* target-descriptions.c (tdesc_type): Add TDESC_TYPE_I387_EXT,
TDESC_TYPE_I386_EFLAGS and TDESC_TYPE_I386_MXCSR.
(tdesc_predefined_types): Add i387_ext, i386_eflags and
i386_mxcsr.
(tdesc_find_type): New.
(tdesc_gdb_type): Use tdesc_find_type. Handle TDESC_TYPE_I387_EXT,
TDESC_TYPE_I386_EFLAGS and TDESC_TYPE_I386_MXCSR.
* target-descriptions.h (tdesc_find_type): New.
doc/
2010-02-09 H.J. Lu <hongjiu.lu@intel.com>
* gdb.texinfo: Add i387_ext, i386_eflags and i386_mxcsr.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index b31cfed..9c52fcb 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -32749,6 +32749,15 @@ Double precision IEEE floating point.
@item arm_fpa_ext
The 12-byte extended precision format used by ARM FPA registers.
+@item i387_ext
+The 10-byte extended precision format used by x87 registers.
+
+@item i386_eflags
+32bit EFLAGS register used by x86.
+
+@item i386_mxcsr
+32bit MXCSR register used by x86.
+
@end table
@node Standard Target Features
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 4fbc72c..9856d6f 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -117,6 +117,9 @@ typedef struct tdesc_type
TDESC_TYPE_IEEE_SINGLE,
TDESC_TYPE_IEEE_DOUBLE,
TDESC_TYPE_ARM_FPA_EXT,
+ TDESC_TYPE_I387_EXT,
+ TDESC_TYPE_I386_EFLAGS,
+ TDESC_TYPE_I386_MXCSR,
/* Types defined by a target feature. */
TDESC_TYPE_VECTOR,
@@ -461,7 +464,10 @@ static struct tdesc_type tdesc_predefined_types[] =
{ "data_ptr", TDESC_TYPE_DATA_PTR },
{ "ieee_single", TDESC_TYPE_IEEE_SINGLE },
{ "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
- { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT }
+ { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
+ { "i387_ext", TDESC_TYPE_I387_EXT },
+ { "i386_eflags", TDESC_TYPE_I386_EFLAGS },
+ { "i386_mxcsr", TDESC_TYPE_I386_MXCSR }
};
/* Return the type associated with ID in the context of FEATURE, or
@@ -486,12 +492,38 @@ tdesc_named_type (const struct tdesc_feature *feature, const char *id)
return NULL;
}
+/* Lookup type associated with ID. */
+
+struct type *
+tdesc_find_type (struct gdbarch *gdbarch, const char *id)
+{
+ struct tdesc_arch_reg *reg;
+ struct tdesc_arch_data *data;
+ int i, num_regs;
+
+ data = gdbarch_data (gdbarch, tdesc_data);
+ num_regs = VEC_length (tdesc_arch_reg, data->arch_regs);
+ for (i = 0; i < num_regs; i++)
+ {
+ reg = VEC_index (tdesc_arch_reg, data->arch_regs, i);
+ if (reg->reg
+ && reg->reg->tdesc_type
+ && reg->type
+ && strcmp (id, reg->reg->tdesc_type->name) == 0)
+ return reg->type;
+ }
+
+ return NULL;
+}
+
/* Construct, if necessary, and return the GDB type implementing target
type TDESC_TYPE for architecture GDBARCH. */
static struct type *
tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
{
+ struct type *type;
+
switch (tdesc_type->kind)
{
/* Predefined types. */
@@ -531,6 +563,16 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
case TDESC_TYPE_DATA_PTR:
return builtin_type (gdbarch)->builtin_data_ptr;
+ default:
+ break;
+ }
+
+ type = tdesc_find_type (gdbarch, tdesc_type->name);
+ if (type)
+ return type;
+
+ switch (tdesc_type->kind)
+ {
case TDESC_TYPE_IEEE_SINGLE:
return arch_float_type (gdbarch, -1, "builtin_type_ieee_single",
floatformats_ieee_single);
@@ -543,6 +585,61 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
return arch_float_type (gdbarch, -1, "builtin_type_arm_ext",
floatformats_arm_ext);
+ case TDESC_TYPE_I387_EXT:
+ return arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
+ floatformats_i387_ext);
+
+ case TDESC_TYPE_I386_EFLAGS:
+ {
+ struct type *type;
+
+ type = arch_flags_type (gdbarch, "builtin_type_i386_eflags", 4);
+ append_flags_type_flag (type, 0, "CF");
+ append_flags_type_flag (type, 1, NULL);
+ append_flags_type_flag (type, 2, "PF");
+ append_flags_type_flag (type, 4, "AF");
+ append_flags_type_flag (type, 6, "ZF");
+ append_flags_type_flag (type, 7, "SF");
+ append_flags_type_flag (type, 8, "TF");
+ append_flags_type_flag (type, 9, "IF");
+ append_flags_type_flag (type, 10, "DF");
+ append_flags_type_flag (type, 11, "OF");
+ append_flags_type_flag (type, 14, "NT");
+ append_flags_type_flag (type, 16, "RF");
+ append_flags_type_flag (type, 17, "VM");
+ append_flags_type_flag (type, 18, "AC");
+ append_flags_type_flag (type, 19, "VIF");
+ append_flags_type_flag (type, 20, "VIP");
+ append_flags_type_flag (type, 21, "ID");
+
+ return type;
+ }
+ break;
+
+ case TDESC_TYPE_I386_MXCSR:
+ {
+ struct type *type;
+
+ type = arch_flags_type (gdbarch, "builtin_type_i386_mxcsr", 4);
+ append_flags_type_flag (type, 0, "IE");
+ append_flags_type_flag (type, 1, "DE");
+ append_flags_type_flag (type, 2, "ZE");
+ append_flags_type_flag (type, 3, "OE");
+ append_flags_type_flag (type, 4, "UE");
+ append_flags_type_flag (type, 5, "PE");
+ append_flags_type_flag (type, 6, "DAZ");
+ append_flags_type_flag (type, 7, "IM");
+ append_flags_type_flag (type, 8, "DM");
+ append_flags_type_flag (type, 9, "ZM");
+ append_flags_type_flag (type, 10, "OM");
+ append_flags_type_flag (type, 11, "UM");
+ append_flags_type_flag (type, 12, "PM");
+ append_flags_type_flag (type, 15, "FZ");
+
+ return type;
+ }
+ break;
+
/* Types defined by a target feature. */
case TDESC_TYPE_VECTOR:
{
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index 17f52eb..da0564b 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -176,6 +176,10 @@ const char *tdesc_register_name (struct gdbarch *gdbarch, int regno);
struct type *tdesc_register_type (struct gdbarch *gdbarch, int regno);
+/* Return the type associated with ID, from the target description. */
+
+struct type *tdesc_find_type (struct gdbarch *gdbarch, const char *id);
+
/* Check whether REGNUM is a member of REGGROUP using the target
description. Return -1 if the target description does not
specify a group. */
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Cache types from target description
2010-02-09 15:45 ` H.J. Lu
@ 2010-02-09 18:47 ` Eli Zaretskii
2010-02-09 18:56 ` H.J. Lu
2010-02-10 18:38 ` Daniel Jacobowitz
1 sibling, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2010-02-09 18:47 UTC (permalink / raw)
To: H.J. Lu; +Cc: gdb-patches, mark.kettenis
> Date: Tue, 9 Feb 2010 07:45:13 -0800
> From: "H.J. Lu" <hongjiu.lu@intel.com>
> Cc: GDB <gdb-patches@sourceware.org>, Mark Kettenis <mark.kettenis@xs4all.nl>
>
> Here is the updated patch. I fixed i386_eflags and documented them.
> OK to install?
The doco part is okay, but please fix the following 2 minor issues
before committing:
> 2010-02-09 H.J. Lu <hongjiu.lu@intel.com>
>
> * gdb.texinfo: Add i387_ext, i386_eflags and i386_mxcsr.
Please state the name of the node in which you are making the change
(in parens, as if it were a function). You can find it by looking
back from the locus of the change for a line that begins with
"@node".
> +@item i386_eflags
> +32bit EFLAGS register used by x86.
> +
> +@item i386_mxcsr
> +32bit MXCSR register used by x86.
It would look prettier in print if you use @sc{eflags} and @sc{mxcsr}
instead of up-casing them in the Texinfo sources.
Thanks.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Cache types from target description
2010-02-09 18:47 ` Eli Zaretskii
@ 2010-02-09 18:56 ` H.J. Lu
0 siblings, 0 replies; 20+ messages in thread
From: H.J. Lu @ 2010-02-09 18:56 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, mark.kettenis
On Tue, Feb 9, 2010 at 10:47 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Tue, 9 Feb 2010 07:45:13 -0800
>> From: "H.J. Lu" <hongjiu.lu@intel.com>
>> Cc: GDB <gdb-patches@sourceware.org>, Mark Kettenis <mark.kettenis@xs4all.nl>
>>
>> Here is the updated patch. I fixed i386_eflags and documented them.
>> OK to install?
>
> The doco part is okay, but please fix the following 2 minor issues
> before committing:
>
>> 2010-02-09 H.J. Lu <hongjiu.lu@intel.com>
>>
>> * gdb.texinfo: Add i387_ext, i386_eflags and i386_mxcsr.
>
> Please state the name of the node in which you are making the change
> (in parens, as if it were a function). You can find it by looking
> back from the locus of the change for a line that begins with
> "@node".
>
>> +@item i386_eflags
>> +32bit EFLAGS register used by x86.
>> +
>> +@item i386_mxcsr
>> +32bit MXCSR register used by x86.
>
> It would look prettier in print if you use @sc{eflags} and @sc{mxcsr}
> instead of up-casing them in the Texinfo sources.
>
This is the doc patch I am checking in. I will wait for OK on the other part.
Thanks.
--
H.J.
---
2010-02-09 H.J. Lu <hongjiu.lu@intel.com>
* gdb.texinfo (Predefined Target Types): Add i387_ext,
i386_eflags and i386_mxcsr.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index b31cfed..81c0b6b 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -32749,6 +32749,15 @@ Double precision IEEE floating point.
@item arm_fpa_ext
The 12-byte extended precision format used by ARM FPA registers.
+@item i387_ext
+The 10-byte extended precision format used by x87 registers.
+
+@item i386_eflags
+32bit @sc{eflags} register used by x86.
+
+@item i386_mxcsr
+32bit @sc{mxcsr} register used by x86.
+
@end table
@node Standard Target Features
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Cache types from target description
2010-02-09 15:45 ` H.J. Lu
2010-02-09 18:47 ` Eli Zaretskii
@ 2010-02-10 18:38 ` Daniel Jacobowitz
2010-02-10 20:54 ` Mark Kettenis
1 sibling, 1 reply; 20+ messages in thread
From: Daniel Jacobowitz @ 2010-02-10 18:38 UTC (permalink / raw)
To: H.J. Lu; +Cc: GDB, Mark Kettenis
On Tue, Feb 09, 2010 at 07:45:13AM -0800, H.J. Lu wrote:
> 2010-02-09 H.J. Lu <hongjiu.lu@intel.com>
>
> * target-descriptions.c (tdesc_type): Add TDESC_TYPE_I387_EXT,
> TDESC_TYPE_I386_EFLAGS and TDESC_TYPE_I386_MXCSR.
> (tdesc_predefined_types): Add i387_ext, i386_eflags and
> i386_mxcsr.
> (tdesc_find_type): New.
> (tdesc_gdb_type): Use tdesc_find_type. Handle TDESC_TYPE_I387_EXT,
> TDESC_TYPE_I386_EFLAGS and TDESC_TYPE_I386_MXCSR.
>
> * target-descriptions.h (tdesc_find_type): New.
This is OK. I am not happy having the flag types in this file, but
I don't see a better way yet. Really they should be described in the
XML file!
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Cache types from target description
2010-02-10 18:38 ` Daniel Jacobowitz
@ 2010-02-10 20:54 ` Mark Kettenis
2010-02-10 21:01 ` Daniel Jacobowitz
0 siblings, 1 reply; 20+ messages in thread
From: Mark Kettenis @ 2010-02-10 20:54 UTC (permalink / raw)
To: dan; +Cc: hjl.tools, gdb-patches
> Date: Wed, 10 Feb 2010 13:38:03 -0500
> From: Daniel Jacobowitz <dan@codesourcery.com>
>
> Really they should be described in the XML file!
'fraid I don't agree with you on that. When it comes to things like
multi-bit flags, you want a real programming language.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Cache types from target description
2010-02-10 20:54 ` Mark Kettenis
@ 2010-02-10 21:01 ` Daniel Jacobowitz
0 siblings, 0 replies; 20+ messages in thread
From: Daniel Jacobowitz @ 2010-02-10 21:01 UTC (permalink / raw)
To: Mark Kettenis; +Cc: hjl.tools, gdb-patches
On Wed, Feb 10, 2010 at 09:52:57PM +0100, Mark Kettenis wrote:
> > Date: Wed, 10 Feb 2010 13:38:03 -0500
> > From: Daniel Jacobowitz <dan@codesourcery.com>
> >
> > Really they should be described in the XML file!
>
> 'fraid I don't agree with you on that. When it comes to things like
> multi-bit flags, you want a real programming language.
How else would you do it? I don't want the answer to be "in C, in
GDB"; we've got devices with dozens of complicated flag registers that
are specific to that one device.
I'm sure I could do it in Python, but it takes away the
self-describing property. I'm not nuts enough to encapsulate the
Python in XML and execute untrusted code.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2010-02-10 21:01 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-05 1:15 PATCH: PATCH: Add builtin floating point types H.J. Lu
2010-02-07 21:52 ` Mark Kettenis
2010-02-07 22:00 ` H.J. Lu
2010-02-07 22:14 ` Daniel Jacobowitz
2010-02-07 22:25 ` H.J. Lu
2010-02-07 23:03 ` H.J. Lu
2010-02-07 23:08 ` Daniel Jacobowitz
2010-02-08 2:17 ` H.J. Lu
2010-02-08 4:17 ` Daniel Jacobowitz
2010-02-08 5:16 ` H.J. Lu
2010-02-08 14:14 ` Daniel Jacobowitz
2010-02-08 14:56 ` H.J. Lu
2010-02-08 18:56 ` H.J. Lu
2010-02-08 18:55 ` PATCH: Cache types from target description H.J. Lu
2010-02-09 15:45 ` H.J. Lu
2010-02-09 18:47 ` Eli Zaretskii
2010-02-09 18:56 ` H.J. Lu
2010-02-10 18:38 ` Daniel Jacobowitz
2010-02-10 20:54 ` Mark Kettenis
2010-02-10 21:01 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox