From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53705 invoked by alias); 25 Jan 2018 10:08:45 -0000 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 Received: (qmail 53672 invoked by uid 89); 25 Jan 2018 10:08:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= 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 Jan 2018 10:08:38 +0000 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0PA3jwF128921 for ; Thu, 25 Jan 2018 05:08:37 -0500 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fq9a00w0m-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 25 Jan 2018 05:08:36 -0500 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jan 2018 10:08:33 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 25 Jan 2018 10:08:30 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0PA8UU246596208; Thu, 25 Jan 2018 10:08:30 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 507974C040; Thu, 25 Jan 2018 10:02:33 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 26E024C058; Thu, 25 Jan 2018 10:02:33 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 25 Jan 2018 10:02:33 +0000 (GMT) From: Philipp Rudo To: GDB Patches Cc: Andreas Arnez , Ulrich Weigand Subject: [PATCH] s390: Fix gdb.base/all-architectures.exp with --enable-targets=all Date: Thu, 25 Jan 2018 10:08:00 -0000 In-Reply-To: <20180125100828.7599-1-prudo@linux.vnet.ibm.com> References: <20180125100828.7599-1-prudo@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18012510-0040-0000-0000-00000428AB8A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18012510-0041-0000-0000-000020CC3455 Message-Id: <20180125100828.7599-2-prudo@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-25_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801250139 X-IsSubscribed: yes X-SW-Source: 2018-01/txt/msg00515.txt.bz2 With 7042632bf79 (s390: Hook s390 into OSABI mechanism) assigning a default target description was moved from s390_gdbarch_init to s390_linux_init_abi_*. This causes problems when GDB is build with --enable-targets=all and the user sets a non supported osabi (e.g. set osabi AIX). In this case there is no valid tdesc and GDB crashes with an internal error. Fix this by reverting parts of 7042632bf79. gdb/ChangeLog: * s390-linux-tdep.c: Move includes for features/s390-linux32.c and features/s390x-linux64.c to s390-tdep.c. (_initialize_s390_linux_tdep): Move initializaion of tdesc s390_linux32 and s390x_linux64 to s390-tdep.c. (s390_linux_init_abi_31, s390_linux_init_abi_64): Don't set default tdesc. * s390-tdep.c: Add include of features/s390-linux32.c and features/s390x-linux64.c. (s390_tdesc_valid): Add check for tdesc_has_registers. (s390_gdbarch_init): Make sure there is always an valid tdesc. (_initialize_s390_tdep): Initialize tdesc_s390_linux32 and tdesc_s390x_linux64. * s390-linux-tdep.h: Move export of tdesc_s390_linux32 and tdesc_s390x_linux64 to ... * s390-tdep.h: ... here. --- gdb/s390-linux-tdep.c | 10 ---------- gdb/s390-linux-tdep.h | 2 -- gdb/s390-tdep.c | 23 +++++++++++++++++++++-- gdb/s390-tdep.h | 3 +++ 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c index 9d1351946e..0e85e71089 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -42,7 +42,6 @@ #include "trad-frame.h" #include "xml-syscall.h" -#include "features/s390-linux32.c" #include "features/s390-linux32v1.c" #include "features/s390-linux32v2.c" #include "features/s390-linux64.c" @@ -52,7 +51,6 @@ #include "features/s390-vx-linux64.c" #include "features/s390-tevx-linux64.c" #include "features/s390-gs-linux64.c" -#include "features/s390x-linux64.c" #include "features/s390x-linux64v1.c" #include "features/s390x-linux64v2.c" #include "features/s390x-te-linux64.c" @@ -1158,9 +1156,6 @@ s390_linux_init_abi_31 (struct gdbarch_info info, struct gdbarch *gdbarch) struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); tdep->abi = ABI_LINUX_S390; - if (!tdesc_has_registers (tdesc)) - tdesc = tdesc_s390_linux32; - tdep->tdesc = tdesc; s390_linux_init_abi_any (info, gdbarch); @@ -1178,9 +1173,6 @@ s390_linux_init_abi_64 (struct gdbarch_info info, struct gdbarch *gdbarch) struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); tdep->abi = ABI_LINUX_ZSERIES; - if (!tdesc_has_registers (tdesc)) - tdesc = tdesc_s390x_linux64; - tdep->tdesc = tdesc; s390_linux_init_abi_any (info, gdbarch); @@ -1199,7 +1191,6 @@ _initialize_s390_linux_tdep (void) s390_linux_init_abi_64); /* Initialize the GNU/Linux target descriptions. */ - initialize_tdesc_s390_linux32 (); initialize_tdesc_s390_linux32v1 (); initialize_tdesc_s390_linux32v2 (); initialize_tdesc_s390_linux64 (); @@ -1209,7 +1200,6 @@ _initialize_s390_linux_tdep (void) initialize_tdesc_s390_vx_linux64 (); initialize_tdesc_s390_tevx_linux64 (); initialize_tdesc_s390_gs_linux64 (); - initialize_tdesc_s390x_linux64 (); initialize_tdesc_s390x_linux64v1 (); initialize_tdesc_s390x_linux64v2 (); initialize_tdesc_s390x_te_linux64 (); diff --git a/gdb/s390-linux-tdep.h b/gdb/s390-linux-tdep.h index 6542464951..a3288e3bb1 100644 --- a/gdb/s390-linux-tdep.h +++ b/gdb/s390-linux-tdep.h @@ -48,7 +48,6 @@ extern const struct regset s390_gs_regset; extern const struct regset s390_gsbc_regset; /* GNU/Linux target descriptions. */ -extern struct target_desc *tdesc_s390_linux32; extern struct target_desc *tdesc_s390_linux32v1; extern struct target_desc *tdesc_s390_linux32v2; extern struct target_desc *tdesc_s390_linux64; @@ -58,7 +57,6 @@ extern struct target_desc *tdesc_s390_te_linux64; extern struct target_desc *tdesc_s390_vx_linux64; extern struct target_desc *tdesc_s390_tevx_linux64; extern struct target_desc *tdesc_s390_gs_linux64; -extern struct target_desc *tdesc_s390x_linux64; extern struct target_desc *tdesc_s390x_linux64v1; extern struct target_desc *tdesc_s390x_linux64v2; extern struct target_desc *tdesc_s390x_te_linux64; diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 1f2a536cd1..b60f4e2a04 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -40,6 +40,9 @@ #include "trad-frame.h" #include "value.h" +#include "features/s390-linux32.c" +#include "features/s390x-linux64.c" + /* Holds the current set of options to be passed to the disassembler. */ static char *s390_disassembler_options; @@ -6789,6 +6792,9 @@ s390_tdesc_valid (struct gdbarch_tdep *tdep, const struct target_desc *tdesc = tdep->tdesc; const struct tdesc_feature *feature; + if (!tdesc_has_registers (tdesc)) + return false; + /* Core registers, i.e. general purpose and PSW. */ feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.core"); if (feature == NULL) @@ -6929,7 +6935,6 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) static const char *const stap_register_indirection_suffixes[] = { ")", NULL }; - /* Otherwise create a new gdbarch for the specified machine type. */ struct gdbarch_tdep *tdep = s390_gdbarch_tdep_alloc (); struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep); struct tdesc_arch_data *tdesc_data = tdesc_data_alloc (); @@ -7044,8 +7049,19 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Initialize the OSABI. */ gdbarch_init_osabi (info, gdbarch); + /* Always create a default tdesc. Otherwise commands like 'set osabi' + causes GDB to crash with an internal error when the user tries to set + a non supported osabi. */ + if (!tdesc_has_registers (tdesc)) + { + if (info.bfd_arch_info->mach == bfd_mach_s390_31) + tdesc = tdesc_s390_linux32; + else + tdesc = tdesc_s390x_linux64; + } + tdep->tdesc = tdesc; + /* Check any target description for validity. */ - gdb_assert (tdesc_has_registers (tdep->tdesc)); if (!s390_tdesc_valid (tdep, tdesc_data)) { tdesc_data_cleanup (tdesc_data); @@ -7120,4 +7136,7 @@ _initialize_s390_tdep (void) { /* Hook us into the gdbarch mechanism. */ register_gdbarch_init (bfd_arch_s390, s390_gdbarch_init); + + initialize_tdesc_s390_linux32 (); + initialize_tdesc_s390x_linux64 (); } diff --git a/gdb/s390-tdep.h b/gdb/s390-tdep.h index 4a44da0190..14530cef31 100644 --- a/gdb/s390-tdep.h +++ b/gdb/s390-tdep.h @@ -315,4 +315,7 @@ extern struct value *s390_trad_frame_prev_register (struct frame_info *this_frame, struct trad_frame_saved_reg saved_regs[], int regnum); +extern struct target_desc *tdesc_s390_linux32; +extern struct target_desc *tdesc_s390x_linux64; + #endif /* S390_TDEP_H */ -- 2.13.5