Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Peter Bergner <bergner@vnet.ibm.com>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: Alan Modra <amodra@gmail.com>,
	gdb-patches@sourceware.org,
	       binutils <binutils@sourceware.org>
Subject: Re: [PATCH, RFC] Add support for choosing disassembler cpu in GDB for POWER.
Date: Mon, 03 Oct 2016 20:25:00 -0000	[thread overview]
Message-ID: <aff72146-3dc5-50ec-3382-fc7a6c917cb1@vnet.ibm.com> (raw)
In-Reply-To: <20160930161908.6A43511C24D@oc8523832656.ibm.com>

On 9/30/16 11:19 AM, Ulrich Weigand wrote:
> The implementation in the patch does appear to be a bit ad-hoc, however :-)
> Why would we want to pass that information via a new global variable, if
> there is already an element "disassembler_options" in the struct
> disassemble_info that GDB passes to bfd?  See e.g. i386_print_insn.

Yes, I saw that code.  The problem is that same solution won't work for
us, since print_insn_*() doesn't look at info->disassembler_options
at all.  Instead, it uses the dialect value which we initialize from
info->disassembler_options in powerpc_init_dialect(), but that happens
only once and well before gdb_print_insn_powerpc() is called.  That means
changing info->disassembler_options in gdb_print_insn_powerpc() won't
affect anything.

Now we could recompute the dialect each time we call gdb_print_insn_powerpc(),
but that is done for each insn we emit and scanning through the ppc_opts table
every time would be very expensive, since our table is pretty big.

The only other method would be for set_disassembler_cpu() to somehow
convert its arg into a dialect value that gdb_print_insn_powerpc()
could stuff into the struct disassemble_info each time, which would
be fairly inexpensive.  However, the dialect value is computed by
powerpc_init_dialect which takes a struct disassemble_info pointer
and at this point in the disassembly process, it hasn't been created
yet.  I suppose we could try and create a fake one to pass in.

So given that gdb_print_insn_powerpc() can't affect the disassembly
cpu by changing info->disassembler_options and set_disassembler_cpu()
isn't passed a struct disassemble_info pointer,that's why I resorted
to the global variable.

Given your reaction to the patch as is, how about if I try and create
a temporary struct disassemble_info to pass to powerpc_init_dialect()
and stash the resulting dialect in a global var that is private to
gdb so that gdb_print_insn_powerpc() can stuff it into into the
struct disassemble_info?  Would that satisfy your reservations?

Note to self, we should probably sort the ppc_opts table with the more
commonly used (ie, newer) cpus listed first rather than adding them at
the end of the table like we have.


> I'm also not really happy about the tight integration of opcode/ppc.h
> and the ppc_opts struct into GDB code ...  Can't we ask a BFD routine
> whether a particular CPU option is valid?  E.g. by just making a "test"
> call to print_insn_* and see if it succeeds?

As I said above, print_insn_*() doesn't look at info->disassembler_options,
so we can't use that method, but I could add a new BFD routine to do what
you ask.  I did it this way, so I could emit the valid cpus values in the
"show disassembler-cpu" output.  I suppose I could also move that to BFD
and just call it from GDB.


> Apart from those implementation details, I'm wondering whether we might
> want to generalize the feature to allow setting any disassembler option,
> not just CPU levels.  Also, this could really be useful on any platform,
> not just Power :-)  But I see that some other architectures already use
> info->disassembler_options to pass some special options, which might
> make the generic solution more complex.  Therefore I'd be OK with just
> doing the Power implementation for now.

I'm not against it, but as it is today, the POWER port only expects
info->disassembler_options to hold cpu values.  If we were to allow
other options, we'd have to parse them more carefully.  I'm also not
sure whether like the disassembly dialect, if we might have problems
changing the values due to when they get parsed versus when they are
used.

Peter




  reply	other threads:[~2016-10-03 20:25 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-30  2:14 Peter Bergner
2016-09-30 17:55 ` Ulrich Weigand
2016-10-03 20:25   ` Peter Bergner [this message]
2016-10-03 22:25     ` Alan Modra
2016-10-06  3:00       ` Peter Bergner
2016-10-06  4:44         ` Alan Modra
2016-10-06  9:52         ` Pedro Alves
2016-10-06 19:26           ` Peter Bergner
2016-10-07 19:21             ` Ulrich Weigand
2016-10-07 21:01               ` Peter Bergner
2016-10-08 14:39                 ` Ulrich Weigand
2016-10-10 23:28               ` Peter Bergner
2016-10-12  8:08                 ` Ulrich Weigand
2016-10-12 10:46                   ` Pedro Alves
2016-10-11  0:09             ` Pedro Alves
2016-10-11 18:49               ` Peter Bergner
2016-10-12  8:25                 ` Ulrich Weigand
2016-10-27  0:04                   ` Peter Bergner
2016-10-27  9:40                     ` Pedro Alves
2016-10-28 13:47                       ` Peter Bergner
2016-10-28 14:10                         ` Pedro Alves
2016-10-28 14:24                           ` Peter Bergner
2016-10-28 14:30                             ` Pedro Alves
2016-10-28 14:53                               ` Peter Bergner
2016-11-03 11:01                                 ` Pedro Alves
2016-11-03 15:02                                   ` Peter Bergner
2016-11-03 15:06                                     ` Peter Bergner
2016-11-03 16:41                                     ` Ulrich Weigand
2016-11-03 16:49                                       ` Peter Bergner
2016-10-28 12:32                     ` Ulrich Weigand
2016-10-28 13:45                       ` Peter Bergner
2016-10-28 14:15                         ` Ulrich Weigand
2016-10-28 15:02                           ` Peter Bergner
2016-10-28 18:47                             ` Ulrich Weigand
2016-11-02 23:28                               ` Peter Bergner
2016-10-12 19:35                 ` Pedro Alves

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=aff72146-3dc5-50ec-3382-fc7a6c917cb1@vnet.ibm.com \
    --to=bergner@vnet.ibm.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --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