From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104060 invoked by alias); 24 Feb 2017 04:58:39 -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 103986 invoked by uid 89); 24 Feb 2017 04:58:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:U*bergner 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; Fri, 24 Feb 2017 04:58:35 +0000 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1O4s6uT124777 for ; Thu, 23 Feb 2017 23:58:34 -0500 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 28t9xv9kcg-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 23 Feb 2017 23:58:34 -0500 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 23 Feb 2017 21:58:33 -0700 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 23 Feb 2017 21:58:31 -0700 Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 7CD3C19D8026; Thu, 23 Feb 2017 21:57:42 -0700 (MST) Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1O4wUDH15466758; Thu, 23 Feb 2017 21:58:30 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 66D2078038; Thu, 23 Feb 2017 21:58:30 -0700 (MST) Received: from otta.local (unknown [9.85.168.217]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 5EBA07803F; Thu, 23 Feb 2017 21:58:29 -0700 (MST) Subject: Re: [PATCH, v17] Add support for setting disassembler-options in GDB for POWER, ARM and S390 To: Pedro Alves References: <3b6b8153-cfff-8fb3-2cc0-2612f3d2d710@redhat.com> Cc: gdb-patches@sourceware.org, Yao Qi , Alan Modra , Ulrich Weigand , binutils , Peter Bergner From: Peter Bergner Date: Fri, 24 Feb 2017 04:58:00 -0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <3b6b8153-cfff-8fb3-2cc0-2612f3d2d710@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17022404-0016-0000-0000-00000643BAD3 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006672; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000204; SDB=6.00826291; UDB=6.00404677; IPR=6.00603743; BA=6.00005168; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014420; XFM=3.00000011; UTC=2017-02-24 04:58:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17022404-0017-0000-0000-000037AD68EA Message-Id: <98f0a8a0-ed6d-10b6-08be-2dd86cc7af44@vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-02-24_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=4 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702240050 X-IsSubscribed: yes X-SW-Source: 2017-02/txt/msg00655.txt.bz2 On 2/23/17 6:26 AM, Pedro Alves wrote: > On 02/22/2017 09:23 PM, Peter Bergner wrote: >> (gdb) set architecture powerpc:common64 >> The target architecture is assumed to be powerpc:common64 >> (gdb) show disassembler-options >> The current disassembler options are 'power8' >> [snip] > > Given this was broken but went unnoticed before, something like > the above should be added as a test. Done. I added tests for ARM, PowerPC and S390 to verify their options are preserved over a set architecture call. >> +/* A macro for iterating over each comma separated option in OPTIONS. */ >> +#define FOR_EACH_DISASSEMBLER_OPTION(OPT, OPTIONS) \ >> + for ((OPT) = (typeof (OPT))(OPTIONS); \ > > typeof is a GNU extension. I don't see any other use of it in the > tree. I don't know whether all compilers that binutils intents to > support accept it. > > But why do you need the cast? I added it because I got a build error due to a cast, but looking closer, I added an uneeded const on a variable and removing that obviates the need for the cast. It's removed now. Thanks. >> + size_t i, num_options = sizeof (ppc_opts) / sizeof (ppc_opts[0]); > > While at it, all new occurrences of this > "sizeof (array) / sizeof (array[0])" idiom should really be > replaced by "ARRAY_SIZE (array)" instead. Done. >> +manual and/or the output of @kbd{objdump --help}. The default value >> +is empty string. > > Missing "the" in "is the empty string". Fixed. > While at it, I think it'd be nice to add a ref to the section in binutils > manual directly. We have a few like that already in the manual. For > example, we have: > > (@pxref{Overlay Description,,, ld.info, Using ld: the GNU linker}) Done. >> @@ -780,6 +787,7 @@ gdb_disassembler::gdb_disassembler (struct gdbarch *gdbarch, >> m_di.endian = gdbarch_byte_order (gdbarch); >> m_di.endian_code = gdbarch_byte_order_for_code (gdbarch); >> m_di.application_data = this; >> + m_di.disassembler_options = *gdbarch_disassembler_options (gdbarch); > > Isn't this going to crash on archs that don't set gdbarch_disassembler_options? Ahh, I forgot to test this on one of the unsupported architectures after I made the change of the gdbarch_disassembler_options to char **. Yes, it dies. I added a new function get_disassembler_options() that we can use, which will do the dereference for us, but only if the arch is supported. Otherwise, it returns NULL. That fixes the SEGVs. > Do the "gdb.base/all-architectures-*.exp" tests pass on an > --enable-targets=all build of gdb with this patch? I think I cleaned out my last build, so I can't check. With the issues above and below fixed, they do all pass. >> + for (i = 0, col = 0; valid_options->name[i] != NULL; i++) >> + { >> + /* Include the " " and "," we print below. */ >> + size_t len = strlen (valid_options->name[i]) + 2; >> + if (col + len > 80) > > Is this 80 here supposed to be the screen width? Do we > really need this manual wrapping? The only architecture that uses this is the ppc arch and this mimics what print_ppc_disassembler_options() does. We have ~60 options that we're emitting, so I think wrapping does make things more readable. >> +/* Holds the current set of options to be passed to the disassembler. */ >> +static char *disassembler_options; > > Even though these are going to be statics, can you please name > them $cpu_disassembler_options, etc. It'll make debugging > gdb easier. "(gdb) print arm_disassembler_options", etc. Done. >> + len = strcspn(style, ","); > > missing space before parens. Fixed. I'll post the new patch. Thanks. Peter