public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Peter Bergner <bergner@vnet.ibm.com>
Cc: gdb-patches@sourceware.org,  Alan Modra <amodra@gmail.com>,
	 Pedro Alves <palves@redhat.com>,
	 Ulrich Weigand <uweigand@de.ibm.com>,
	 Eli Zaretskii <eliz@gnu.org>,  Nick Clifton <nickc@redhat.com>,
	 binutils <binutils@sourceware.org>
Subject: Re: [PATCH, updated] Add support for setting disassembler-options in GDB for POWER, ARM and S390
Date: Mon, 13 Feb 2017 15:53:00 -0000	[thread overview]
Message-ID: <867f4uccky.fsf@gmail.com> (raw)
In-Reply-To: <beb0d776-c509-ab82-755a-0b4ff8a7a41a@vnet.ibm.com> (Peter	Bergner's message of "Wed, 8 Feb 2017 15:01:40 -0600")

Peter Bergner <bergner@vnet.ibm.com> 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 = 0;
>  
> -int
> -set_arm_regname_option (int option)
> -{
> -  int old = regname_selected;
> -  regname_selected = option;
> -  return old;
> +  if (num_opts == 0)
> +    {
> +      unsigned int i;
> +      for (i = 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 = get_arm_regname_num_options ();

We can get 'num_disassembly_options' by iterating options from
disassembler_options_arm.

>  
> -int
> +void
>  get_arm_regnames (int option,
>  		  const char **setname,
> -		  const char **setdescription,
> -		  const char *const **register_names)
> +		  const char **setdescription)
>  {
> -  *setname = regnames[option].name;
> -  *setdescription = regnames[option].description;
> -  *register_names = regnames[option].reg_names;
> -  return 16;
> +  *setname = regnames[option].name + strlen ("reg-names-");
> +  *setdescription = _(regnames[option].description);
>  }
>  

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 = 0; i < num_disassembly_options; i++)
    {
      get_arm_regnames (i, &setname, &setdesc);
      valid_disassembly_styles[i] = setname;
      length = snprintf (rdptr, rest, "%s - %s\n", setname, setdesc);
      rdptr += length;
      rest -= 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_gnu_triplet_regexp::0
>  # each address in memory.
>  m:int:addressable_memory_unit_size:void:::default_addressable_memory_unit_size::0
>  
> +# Functions for allowing a target to modify its disassembler options.
> +v:char *:disassembler_options:::0:0::0:pstring (gdbarch->disassembler_options)

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_address_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"?

-- 
Yao (齐尧)

  reply	other threads:[~2017-02-13 15:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08 21:03 Peter Bergner
2017-02-13 15:53 ` Yao Qi [this message]
2017-02-13 16:31   ` Peter Bergner
2017-02-13 16:58   ` Pedro Alves
2017-02-13 17:32     ` Peter Bergner
2017-02-14 17:21     ` Yao Qi
2017-02-14 17:35       ` Pedro Alves
2017-02-13 17:08   ` Peter Bergner
2017-02-13 18:48   ` Peter Bergner
2017-02-14 20:01     ` Pedro Alves
2017-02-15 23:14       ` Peter Bergner
2017-02-15 23:48         ` Alan Modra
2017-02-16  0:21         ` Pedro Alves
2017-02-16  1:59           ` Peter Bergner
2017-02-16  2:09             ` Pedro Alves
2017-02-13 18:52 ` Peter Bergner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=867f4uccky.fsf@gmail.com \
    --to=qiyaoltc@gmail.com \
    --cc=amodra@gmail.com \
    --cc=bergner@vnet.ibm.com \
    --cc=binutils@sourceware.org \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=nickc@redhat.com \
    --cc=palves@redhat.com \
    --cc=uweigand@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).