From patchwork Thu Aug 25 15:06:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 14928 Received: (qmail 31983 invoked by alias); 25 Aug 2016 15:06:18 -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 31972 invoked by uid 89); 25 Aug 2016 15:06:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_SEMBACKSCATTER, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2477 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 Aug 2016 15:06:16 +0000 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u7PF6AiK042176 for ; Thu, 25 Aug 2016 11:06:15 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 251fpfu9de-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 25 Aug 2016 11:06:15 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Aug 2016 16:06:12 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 25 Aug 2016 16:06:11 +0100 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: uweigand@de.ibm.com X-IBM-RcptTo: gdb-patches@sourceware.org Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id EF8D6219004D for ; Thu, 25 Aug 2016 16:05:33 +0100 (BST) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u7PF6AcW67043454 for ; Thu, 25 Aug 2016 15:06:10 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u7PF6AJA029385 for ; Thu, 25 Aug 2016 11:06:10 -0400 Received: from oc7340732750.ibm.com (icon-9-164-148-136.megacenter.de.ibm.com [9.164.148.136]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u7PF6AI3029373 for ; Thu, 25 Aug 2016 11:06:10 -0400 Received: by oc7340732750.ibm.com (Postfix, from userid 500) id 3EA74C9FB; Thu, 25 Aug 2016 17:06:09 +0200 (CEST) Subject: [2/9] Fix TYPE_SPECIFIC_FIELD for types created via arch_type To: gdb-patches@sourceware.org Date: Thu, 25 Aug 2016 17:06:09 +0200 (CEST) From: "Ulrich Weigand" MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16082515-0020-0000-0000-00000237EBA0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16082515-0021-0000-0000-00003DC35ADC Message-Id: <20160825150609.3EA74C9FB@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, a type's TYPE_SPECIFIC_FIELD is supposed to be initialized as appropriate for the type code. This does happen if the type is created via init_type, but not if it created via arch_type. Fixed by extracting the initialization logic into a new set_type_code routine, which is then called from both places. Bye, Ulrich ChangeLog: * gdbtypes.c (set_type_code): New function. (init_type, arch_type): Use it. Index: binutils-gdb/gdb/gdbtypes.c =================================================================== --- binutils-gdb.orig/gdb/gdbtypes.c 2016-08-25 13:11:37.408784388 +0200 +++ binutils-gdb/gdb/gdbtypes.c 2016-08-25 13:11:47.808829922 +0200 @@ -2681,6 +2681,30 @@ allocate_gnat_aux_type (struct type *typ *(TYPE_GNAT_SPECIFIC (type)) = gnat_aux_default; } +/* Helper function to initialize a newly allocated type. Set type code + to CODE and initialize the type-specific fields accordingly. */ + +static void +set_type_code (struct type *type, enum type_code code) +{ + TYPE_CODE (type) = code; + + switch (code) + { + case TYPE_CODE_STRUCT: + case TYPE_CODE_UNION: + case TYPE_CODE_NAMESPACE: + INIT_CPLUS_SPECIFIC (type); + break; + case TYPE_CODE_FLT: + TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FLOATFORMAT; + break; + case TYPE_CODE_FUNC: + INIT_FUNC_SPECIFIC (type); + break; + } +} + /* Helper function to initialize the standard scalar types. If NAME is non-NULL, then it is used to initialize the type name. @@ -2694,7 +2718,7 @@ init_type (enum type_code code, int leng struct type *type; type = alloc_type (objfile); - TYPE_CODE (type) = code; + set_type_code (type, code); TYPE_LENGTH (type) = length; gdb_assert (!(flags & (TYPE_FLAG_MIN - 1))); @@ -2730,20 +2754,6 @@ init_type (enum type_code code, int leng if (name && strcmp (name, "char") == 0) TYPE_NOSIGN (type) = 1; - switch (code) - { - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - case TYPE_CODE_NAMESPACE: - INIT_CPLUS_SPECIFIC (type); - break; - case TYPE_CODE_FLT: - TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FLOATFORMAT; - break; - case TYPE_CODE_FUNC: - INIT_FUNC_SPECIFIC (type); - break; - } return type; } @@ -4634,7 +4644,7 @@ arch_type (struct gdbarch *gdbarch, struct type *type; type = alloc_type_arch (gdbarch); - TYPE_CODE (type) = code; + set_type_code (type, code); TYPE_LENGTH (type) = length; if (name)