From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20637 invoked by alias); 9 Feb 2010 15:45:31 -0000 Received: (qmail 20625 invoked by uid 22791); 9 Feb 2010 15:45:29 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,NO_DNS_FOR_FROM X-Spam-Check-By: sourceware.org Received: from mga05.intel.com (HELO fmsmga101.fm.intel.com) (192.55.52.89) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 09 Feb 2010 15:45:23 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 09 Feb 2010 07:43:21 -0800 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.107]) by fmsmga001.fm.intel.com with ESMTP; 09 Feb 2010 07:45:08 -0800 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 77E50812344; Tue, 9 Feb 2010 07:45:13 -0800 (PST) Date: Tue, 09 Feb 2010 15:45:00 -0000 From: "H.J. Lu" To: "H.J. Lu" Cc: GDB , Mark Kettenis Subject: Re: PATCH: Cache types from target description Message-ID: <20100209154513.GA27404@lucon.org> Reply-To: "H.J. Lu" References: <20100205011447.GA28263@lucon.org> <20100208185454.GA21449@lucon.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100208185454.GA21449@lucon.org> User-Agent: Mutt/1.5.20 (2009-08-17) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-02/txt/msg00256.txt.bz2 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 * 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 * 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. */