From patchwork Thu Jan 25 01:45:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weimin Pan X-Patchwork-Id: 25508 Received: (qmail 104674 invoked by alias); 25 Jan 2018 02:12:28 -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 104313 invoked by uid 89); 25 Jan 2018 02:12:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy=Hx-languages-length:2231 X-HELO: userp2130.oracle.com Received: from userp2130.oracle.com (HELO userp2130.oracle.com) (156.151.31.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 Jan 2018 02:12:26 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w0P2CJiX120663 for ; Thu, 25 Jan 2018 02:12:24 GMT Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2fq65c00ew-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 25 Jan 2018 02:12:24 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w0P27NQI017982 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 25 Jan 2018 02:07:24 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w0P27NL7020982 for ; Thu, 25 Jan 2018 02:07:23 GMT Received: from wmpan.us.oracle.com (/10.147.27.127) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 24 Jan 2018 18:07:23 -0800 From: Weimin Pan To: gdb-patches@sourceware.org Subject: [PATCH PR gdb/20057] Internal error on trying to set {char[]}$pc="string" Date: Wed, 24 Jan 2018 19:45:38 -0600 Message-Id: <1516844738-79996-1-git-send-email-weimin.pan@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8784 signatures=668655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801250028 To support C99 VLA, function value_from_contents_and_address() was modified to add a call to resolve_dynamic_type(), which in turn calls resolve_dynamic_array() to resolve the dynamic array bounds to static values. But the problem arises when function copy_type(), called by resolve_dynamic_array(), expects the type to be copied to have an associated objfile from which the new type is allocated, or asserts. Since type char[] doesn't have an associated objfile when the following gdb command: (gdb) set {char[]}$pc="hello" was issued, gdb asserts. The gdb_assert (TYPE_OBJFILE_OWNED (type)) line in copy_type() doesn't look necessary or correct since space needed for the new type could be allocated from either the type's objfile if it exists or gdbarch if it doesn't, similar to what alloc_type_copy(), which is called after gdb_assert() in copy_type(), does. Removing gdb_assert() fixes the problem. Tested on aarch64-linux-gnu. No regressions. --- gdb/ChangeLog | 5 +++++ gdb/gdbtypes.c | 7 +------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 238bcba..5758207 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-01-09 Weimin Pan + + * gdbtypes.c: (copy_type) Do not assert when a type is not associated + with an object file. + 2018-01-08 Samuel Thibault * gdb/gnu-nat.c: Include and . diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 7ba62df..e017b6a 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -4870,18 +4870,13 @@ copy_type_recursive (struct objfile *objfile, } /* Make a copy of the given TYPE, except that the pointer & reference - types are not preserved. - - This function assumes that the given type has an associated objfile. - This objfile is used to allocate the new type. */ + types are not preserved. */ struct type * copy_type (const struct type *type) { struct type *new_type; - gdb_assert (TYPE_OBJFILE_OWNED (type)); - new_type = alloc_type_copy (type); TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type); TYPE_LENGTH (new_type) = TYPE_LENGTH (type);