From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96281 invoked by alias); 28 Oct 2016 12:32:47 -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 96178 invoked by uid 89); 28 Oct 2016 12:32:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=unavailable version=3.3.2 spammy=completion, *text, sk:cmd_lis, sk:show_di 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; Fri, 28 Oct 2016 12:32:44 +0000 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9SCUHui005806 for ; Fri, 28 Oct 2016 08:32:43 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 26c3kgtekw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 28 Oct 2016 08:32:42 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Oct 2016 13:32:40 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 28 Oct 2016 13:32:38 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 906B41B0804B; Fri, 28 Oct 2016 13:34:45 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9SCWb0630670958; Fri, 28 Oct 2016 12:32:37 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u9SCWbZd022430; Fri, 28 Oct 2016 06:32:37 -0600 Received: from oc8523832656.ibm.com (icon-9-164-186-41.megacenter.de.ibm.com [9.164.186.41]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u9SCWbj1022427; Fri, 28 Oct 2016 06:32:37 -0600 Received: by oc8523832656.ibm.com (Postfix, from userid 500) id 51A6210B91A; Fri, 28 Oct 2016 14:32:36 +0200 (CEST) Subject: Re: [PATCH, RFC] Add support for choosing disassembler cpu in GDB for POWER. To: bergner@vnet.ibm.com (Peter Bergner) Date: Fri, 28 Oct 2016 12:32:00 -0000 From: "Ulrich Weigand" Cc: palves@redhat.com (Pedro Alves), amodra@gmail.com (Alan Modra), gdb-patches@sourceware.org, binutils@sourceware.org (binutils) In-Reply-To: from "Peter Bergner" at Oct 26, 2016 07:04:12 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16102812-0020-0000-0000-0000026B8AA7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16102812-0021-0000-0000-00003ECAB614 Message-Id: <20161028123236.51A6210B91A@oc8523832656.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-10-28_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1610280215 X-SW-Source: 2016-10/txt/msg00793.txt.bz2 Peter Bergner wrote: > > Another option might be to refactor the way disassembler options > > output is done in opcodes, e.g. by having platform-specific code > > only provide an array of tuples of option names and explanatory > > strings, and move the actual printing to common code. Then those > > arrays could be exported to and reused by GDB. (In particular, > > there's really no way to do a completer without such information.) > > How about what I implemented below? Mostly yes. However, I had been thinking of moving more of this stuff to common code. In particular, once the gdbarch has provided a list of supported options, then all this: > +static void > +set_disassembler_options (char *args, int from_tty, struct cmd_list_element *c) > +{ > + struct gdbarch *gdbarch = get_current_arch (); > + if (gdbarch_set_disassembler_options_p (gdbarch)) > + { > + gdbarch_set_disassembler_options (gdbarch, args, from_tty, c); > + return; > + } > + fprintf_filtered (gdb_stdlog, _("\ > +'set disassembler' is not supported on this architecture.\n")); > +} > + > +static void > +show_disassembler_options (struct ui_file *file, int from_tty, > + struct cmd_list_element *c, const char *value) > +{ > + struct gdbarch *gdbarch = get_current_arch (); > + if (gdbarch_show_disassembler_options_p (gdbarch)) > + { > + gdbarch_show_disassembler_options (gdbarch, file, from_tty, c, value); > + return; > + } > + fprintf_filtered (gdb_stdlog, _("\ > +'show disassembler' is not supported on this architecture.\n")); > +} > + > +/* A completion function for "set disassembler". */ > + > +static VEC (char_ptr) * > +disassembler_options_completer (struct cmd_list_element *ignore, > + const char *text, const char *word) > +{ > + struct gdbarch *gdbarch = get_current_arch (); > + if (gdbarch_disassembler_options_completer_p (gdbarch)) > + return gdbarch_disassembler_options_completer (gdbarch, ignore, text, word); > + return NULL; > +} really can be handled generically in common code, right? I.e. set_disassembler_options verifies the string is a comma-separated list of words from the supported option list, show_disassembler_options simply displays the supported option list, etc. In fact, once the option processing is done in common code, we don't even really need the per-gdbarch disassemble_init_for_target option any more, since common code could simply set the disassembler_options string before calling disassemble_init_for_target. Bye, Ulrich -- Dr. Ulrich Weigand GNU/Linux compilers and toolchain Ulrich.Weigand@de.ibm.com