From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121643 invoked by alias); 13 Feb 2017 15:53:00 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 121610 invoked by uid 89); 13 Feb 2017 15:52:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=H*Ad:U*uweigand, bfd_vma, sk:host_ad, *c X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wm0-f65.google.com Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 13 Feb 2017 15:52:57 +0000 Received: by mail-wm0-f65.google.com with SMTP id v77so20164938wmv.0; Mon, 13 Feb 2017 07:52:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=hH1aDMT4+yhua7lR1OAxvon/P/OUVtsc+gZtgXLNMlQ=; b=eaMguY4Cef2SzZGr4aPUuOTPJRTMGxPyFobeHuLx7WlWIR3pL5NUrjm6HQjg/fI9lh F1V7+aN0fhuQRjtoy5vJi1+9EOLcMnuA25gyFUO0dGc4WlUB4fuJqvmJ8MRF5r9gKSdG O8ujzzKG+3rxPzf3VaxYhlOCTkXoKBblrwYWGJjlZYXxhYRnaEp5u5FiqGn4MFdcZUHd 1y1QrXmLXBFBorzRE7XjBq1YvwzANuKOPm6dCCAlvWnafF9HxLVb6boKST0dXJEDLlJ2 lZzkh1aC/H+AZK4VMAnrzi+EbcoIABgwn9H1tVTxrFAh7gr6UUh1bk0WmKirzsjLk7T+ F/nA== X-Gm-Message-State: AMke39mHQpT+cZRU6zdtodDpjiFAyEliGsDRpTE1zPGkEXnbJ3QDAoJ5AfUBq8peQ2PP8g== X-Received: by 10.28.1.216 with SMTP id 207mr20503290wmb.7.1487001175522; Mon, 13 Feb 2017 07:52:55 -0800 (PST) Received: from E107787-LIN ([194.214.185.158]) by smtp.gmail.com with ESMTPSA id e72sm5853331wma.16.2017.02.13.07.52.53 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 13 Feb 2017 07:52:54 -0800 (PST) From: Yao Qi To: Peter Bergner Cc: gdb-patches@sourceware.org, Alan Modra , Pedro Alves , Ulrich Weigand , Eli Zaretskii , Nick Clifton , binutils Subject: Re: [PATCH, updated] Add support for setting disassembler-options in GDB for POWER, ARM and S390 References: Date: Mon, 13 Feb 2017 15:53:00 -0000 In-Reply-To: (Peter Bergner's message of "Wed, 8 Feb 2017 15:01:40 -0600") Message-ID: <867f4uccky.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-02/txt/msg00081.txt.bz2 Peter Bergner writes: Hi Peter, > @@ -3257,27 +3262,26 @@ static bfd_vma ifthen_address; > int > get_arm_regname_num_options (void) > { > - return NUM_ARM_REGNAMES; > -} > + static int num_opts =3D 0; >=20=20 > -int > -set_arm_regname_option (int option) > -{ > - int old =3D regname_selected; > - regname_selected =3D option; > - return old; > + if (num_opts =3D=3D 0) > + { > + unsigned int i; > + for (i =3D 0; i < NUM_ARM_OPTIONS; i++) > + if (CONST_STRNEQ (regnames[i].name, "reg-names-")) > + num_opts++; > + } > + > + return num_opts; > } Function get_arm_regname_num_options is only used in gdb. Since we've have disassembler_options_arm, we can use it in gdb and remove get_arm_regname_num_options. We use get_arm_regname_num_options in arm-tdep.c, /* Get the number of possible sets of register names defined in opcodes.= */ num_disassembly_options =3D get_arm_regname_num_options (); We can get 'num_disassembly_options' by iterating options from disassembler_options_arm. >=20=20 > -int > +void > get_arm_regnames (int option, > const char **setname, > - const char **setdescription, > - const char *const **register_names) > + const char **setdescription) > { > - *setname =3D regnames[option].name; > - *setdescription =3D regnames[option].description; > - *register_names =3D regnames[option].reg_names; > - return 16; > + *setname =3D regnames[option].name + strlen ("reg-names-"); > + *setdescription =3D _(regnames[option].description); > } >=20=20 Likewise, we can use disassembler_options_arm in gdb and remove get_arm_regnames. We use get_arm_regnames like this in arm-tdep.c, for (i =3D 0; i < num_disassembly_options; i++) { get_arm_regnames (i, &setname, &setdesc); valid_disassembly_styles[i] =3D setname; length =3D snprintf (rdptr, rest, "%s - %s\n", setname, setdesc); rdptr +=3D length; rest -=3D length; } but we can replace it by disassembler_options_arm instead. > diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh > index 54549b6..c607853 100755 > --- a/gdb/gdbarch.sh > +++ b/gdb/gdbarch.sh > @@ -1163,6 +1163,10 @@ m:const char *:gnu_triplet_regexp:void:::default_g= nu_triplet_regexp::0 > # each address in memory. > m:int:addressable_memory_unit_size:void:::default_addressable_memory_uni= t_size::0 >=20=20 > +# Functions for allowing a target to modify its disassembler options. > +v:char *:disassembler_options:::0:0::0:pstring (gdbarch->disassembler_op= tions) These options should be modeled as per-architecture data. We need to define a key to access that data dynamically. grep "static struct gdbarch_data *" in *.c. > +v:const disasm_options_t *:disassembler_options_arch:::0:0::0:host_addre= ss_to_string (gdbarch->disassembler_options_arch->name) disassembler_options_arch is not clear to me, and I feel gdbarch_disassembler_options_arch is even worse. How about renaming it to "disassembler_options_supported" or "valid_disassembler_options"? --=20 Yao (=E9=BD=90=E5=B0=A7)