From patchwork Thu Aug 25 15:06:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 14929 Received: (qmail 33855 invoked by alias); 25 Aug 2016 15:06:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 33784 invoked by uid 89); 25 Aug 2016 15:06:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=_type X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 Aug 2016 15:06:34 +0000 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u7PF4LDt056006 for ; Thu, 25 Aug 2016 11:06:33 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 251b8s28xf-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 25 Aug 2016 11:06:32 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Aug 2016 16:06:30 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 25 Aug 2016 16:06:29 +0100 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: uweigand@de.ibm.com X-IBM-RcptTo: gdb-patches@sourceware.org Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 458611B08072 for ; Thu, 25 Aug 2016 16:08:09 +0100 (BST) Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u7PF6Tv88585720 for ; Thu, 25 Aug 2016 15:06:29 GMT Received: from d06av11.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u7PF6TUh027408 for ; Thu, 25 Aug 2016 09:06:29 -0600 Received: from oc7340732750.ibm.com (icon-9-164-148-136.megacenter.de.ibm.com [9.164.148.136]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u7PF6SbJ027388 for ; Thu, 25 Aug 2016 09:06:28 -0600 Received: by oc7340732750.ibm.com (Postfix, from userid 500) id 0610BC9FB; Thu, 25 Aug 2016 17:06:28 +0200 (CEST) Subject: [3/9] Add some missing arch_..._type helpers To: gdb-patches@sourceware.org Date: Thu, 25 Aug 2016 17:06:27 +0200 (CEST) From: "Ulrich Weigand" MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16082515-0040-0000-0000-00000218D116 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16082515-0041-0000-0000-0000217A4D54 Message-Id: <20160825150628.0610BC9FB@oc7340732750.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-08-25_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1608250181 Hello, gdbtypes provides a number of helper routines that can be called instead of using arch_type directly to create a type of a particular kind. This patch adds two additional such routines that have been missing so far, to allow creation of TYPE_CODE_DECFLOAT and TYPE_CODE_POINTER types. The patch also changes a number of places to use the new helper routines instead of calling arch_type directly. No functional change intended. Bye, Ulrich ChangeLog: * gdbtypes.h (arch_decfloat_type): New prototype. (arch_pointer_type): Likewise. * gdbtypes.c (arch_decfloat_type): New function. (arch_pointer_type): Likewise. (gdbtypes_post_init): Use arch_decfloat_type. * avr-tdep.c (avr_gdbarch_init): Use arch_pointer_type. * ft32-tdep.c (ft32_gdbarch_init): Likewise. * m32c-tdep.c (make_types): Likewise. * rl78-tdep.c (rl78_gdbarch_init): Likewise. Index: binutils-gdb/gdb/gdbtypes.h =================================================================== --- binutils-gdb.orig/gdb/gdbtypes.h 2016-08-25 13:11:37.365784198 +0200 +++ binutils-gdb/gdb/gdbtypes.h 2016-08-25 13:11:48.403832528 +0200 @@ -1686,8 +1686,11 @@ extern struct type *arch_boolean_type (s const char *); extern struct type *arch_float_type (struct gdbarch *, int, const char *, const struct floatformat **); +extern struct type *arch_decfloat_type (struct gdbarch *, int, const char *); extern struct type *arch_complex_type (struct gdbarch *, const char *, struct type *); +extern struct type *arch_pointer_type (struct gdbarch *, int, const char *, + struct type *); /* Helper functions to construct a struct or record type. An initially empty type is created using arch_composite_type(). Index: binutils-gdb/gdb/gdbtypes.c =================================================================== --- binutils-gdb.orig/gdb/gdbtypes.c 2016-08-25 13:11:47.808829922 +0200 +++ binutils-gdb/gdb/gdbtypes.c 2016-08-25 13:11:48.406832542 +0200 @@ -4740,6 +4740,18 @@ arch_float_type (struct gdbarch *gdbarch return t; } +/* Allocate a TYPE_CODE_DECFLOAT type structure associated with GDBARCH. + BIT is the type size in bits. NAME is the type name. */ + +struct type * +arch_decfloat_type (struct gdbarch *gdbarch, int bit, const char *name) +{ + struct type *t; + + t = arch_type (gdbarch, TYPE_CODE_DECFLOAT, bit / TARGET_CHAR_BIT, name); + return t; +} + /* Allocate a TYPE_CODE_COMPLEX type structure associated with GDBARCH. NAME is the type name. TARGET_TYPE is the component float type. */ @@ -4755,6 +4767,23 @@ arch_complex_type (struct gdbarch *gdbar return t; } +/* Allocate a TYPE_CODE_PTR type structure associated with GDBARCH. + BIT is the pointer type size in bits. NAME is the type name. + TARGET_TYPE is the pointer target type. Always sets the pointer type's + TYPE_UNSIGNED flag. */ + +struct type * +arch_pointer_type (struct gdbarch *gdbarch, + int bit, const char *name, struct type *target_type) +{ + struct type *t; + + t = arch_type (gdbarch, TYPE_CODE_PTR, bit / TARGET_CHAR_BIT, name); + TYPE_TARGET_TYPE (t) = target_type; + TYPE_UNSIGNED (t) = 1; + return t; +} + /* Allocate a TYPE_CODE_FLAGS type structure associated with GDBARCH. NAME is the type name. LENGTH is the size of the flag word in bytes. */ @@ -4971,11 +5000,11 @@ gdbtypes_post_init (struct gdbarch *gdba /* The following three are about decimal floating point types, which are 32-bits, 64-bits and 128-bits respectively. */ builtin_type->builtin_decfloat - = arch_type (gdbarch, TYPE_CODE_DECFLOAT, 32 / 8, "_Decimal32"); + = arch_decfloat_type (gdbarch, 32, "_Decimal32"); builtin_type->builtin_decdouble - = arch_type (gdbarch, TYPE_CODE_DECFLOAT, 64 / 8, "_Decimal64"); + = arch_decfloat_type (gdbarch, 64, "_Decimal64"); builtin_type->builtin_declong - = arch_type (gdbarch, TYPE_CODE_DECFLOAT, 128 / 8, "_Decimal128"); + = arch_decfloat_type (gdbarch, 128, "_Decimal128"); /* "True" character types. */ builtin_type->builtin_true_char Index: binutils-gdb/gdb/avr-tdep.c =================================================================== --- binutils-gdb.orig/gdb/avr-tdep.c 2016-08-25 13:11:37.366784203 +0200 +++ binutils-gdb/gdb/avr-tdep.c 2016-08-25 13:11:48.408832552 +0200 @@ -1466,9 +1466,8 @@ avr_gdbarch_init (struct gdbarch_info in be defined. */ tdep->void_type = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void"); tdep->func_void_type = make_function_type (tdep->void_type, NULL); - tdep->pc_type = arch_type (gdbarch, TYPE_CODE_PTR, 4, NULL); - TYPE_TARGET_TYPE (tdep->pc_type) = tdep->func_void_type; - TYPE_UNSIGNED (tdep->pc_type) = 1; + tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL, + tdep->func_void_type); set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT); set_gdbarch_int_bit (gdbarch, 2 * TARGET_CHAR_BIT); Index: binutils-gdb/gdb/ft32-tdep.c =================================================================== --- binutils-gdb.orig/gdb/ft32-tdep.c 2016-08-25 13:11:37.365784198 +0200 +++ binutils-gdb/gdb/ft32-tdep.c 2016-08-25 13:11:48.411832564 +0200 @@ -610,9 +610,8 @@ ft32_gdbarch_init (struct gdbarch_info i be defined. */ void_type = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void"); func_void_type = make_function_type (void_type, NULL); - tdep->pc_type = arch_type (gdbarch, TYPE_CODE_PTR, 4, NULL); - TYPE_TARGET_TYPE (tdep->pc_type) = func_void_type; - TYPE_UNSIGNED (tdep->pc_type) = 1; + tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL, + func_void_type); TYPE_INSTANCE_FLAGS (tdep->pc_type) |= TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1; set_gdbarch_read_pc (gdbarch, ft32_read_pc); Index: binutils-gdb/gdb/m32c-tdep.c =================================================================== --- binutils-gdb.orig/gdb/m32c-tdep.c 2016-08-25 13:11:37.366784203 +0200 +++ binutils-gdb/gdb/m32c-tdep.c 2016-08-25 13:11:48.416832587 +0200 @@ -192,27 +192,18 @@ make_types (struct gdbarch *arch) this is called, so we avoid using them. */ tdep->voyd = arch_type (arch, TYPE_CODE_VOID, 1, "void"); tdep->ptr_voyd - = arch_type (arch, TYPE_CODE_PTR, gdbarch_ptr_bit (arch) / TARGET_CHAR_BIT, - NULL); - TYPE_TARGET_TYPE (tdep->ptr_voyd) = tdep->voyd; - TYPE_UNSIGNED (tdep->ptr_voyd) = 1; + = arch_pointer_type (arch, gdbarch_ptr_bit (arch), NULL, tdep->voyd); tdep->func_voyd = lookup_function_type (tdep->voyd); xsnprintf (type_name, sizeof (type_name), "%s_data_addr_t", gdbarch_bfd_arch_info (arch)->printable_name); tdep->data_addr_reg_type - = arch_type (arch, TYPE_CODE_PTR, data_addr_reg_bits / TARGET_CHAR_BIT, - xstrdup (type_name)); - TYPE_TARGET_TYPE (tdep->data_addr_reg_type) = tdep->voyd; - TYPE_UNSIGNED (tdep->data_addr_reg_type) = 1; + = arch_pointer_type (arch, data_addr_reg_bits, type_name, tdep->voyd); xsnprintf (type_name, sizeof (type_name), "%s_code_addr_t", gdbarch_bfd_arch_info (arch)->printable_name); tdep->code_addr_reg_type - = arch_type (arch, TYPE_CODE_PTR, code_addr_reg_bits / TARGET_CHAR_BIT, - xstrdup (type_name)); - TYPE_TARGET_TYPE (tdep->code_addr_reg_type) = tdep->func_voyd; - TYPE_UNSIGNED (tdep->code_addr_reg_type) = 1; + = arch_pointer_type (arch, code_addr_reg_bits, type_name, tdep->func_voyd); tdep->uint8 = arch_integer_type (arch, 8, 1, "uint8_t"); tdep->uint16 = arch_integer_type (arch, 16, 1, "uint16_t"); Index: binutils-gdb/gdb/rl78-tdep.c =================================================================== --- binutils-gdb.orig/gdb/rl78-tdep.c 2016-08-25 13:11:37.366784203 +0200 +++ binutils-gdb/gdb/rl78-tdep.c 2016-08-25 13:11:48.420832604 +0200 @@ -1410,16 +1410,9 @@ rl78_gdbarch_init (struct gdbarch_info i tdep->rl78_int32 = arch_integer_type (gdbarch, 32, 0, "int32_t"); tdep->rl78_data_pointer - = arch_type (gdbarch, TYPE_CODE_PTR, 16 / TARGET_CHAR_BIT, - xstrdup ("rl78_data_addr_t")); - TYPE_TARGET_TYPE (tdep->rl78_data_pointer) = tdep->rl78_void; - TYPE_UNSIGNED (tdep->rl78_data_pointer) = 1; - + = arch_pointer_type (gdbarch, 16, "rl78_data_addr_t", tdep->rl78_void); tdep->rl78_code_pointer - = arch_type (gdbarch, TYPE_CODE_PTR, 32 / TARGET_CHAR_BIT, - xstrdup ("rl78_code_addr_t")); - TYPE_TARGET_TYPE (tdep->rl78_code_pointer) = tdep->rl78_void; - TYPE_UNSIGNED (tdep->rl78_code_pointer) = 1; + = arch_pointer_type (gdbarch, 32, "rl78_code_addr_t", tdep->rl78_void); tdep->rl78_psw_type = arch_flags_type (gdbarch, "builtin_type_rl78_psw", 1); append_flags_type_flag (tdep->rl78_psw_type, 0, "CY");