This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] Fix alignment of disassemble /r


Hi Markus,
I sketched a function to compute the opcode length on record-btrace [1] but
I'm not sure how to test it. Could you please give me a hint about how to?
Can be it tested over x86?

[1] =

static size_t
get_insn_set_longest_opcode(struct gdbarch *gdbarch, struct
disassemble_info* di,
                            const struct btrace_insn_iterator *begin,
                            const struct btrace_insn_iterator *end)
{
  size_t longest_opcode = 0;
  struct btrace_insn_iterator it;

  for (it = *begin; btrace_insn_cmp (&it, end) != 0; btrace_insn_next (&it, 1))
    {
      const struct btrace_insn *insn = btrace_insn_get (&it);

      if (insn != NULL)
{
 const int current_length = gdbarch_print_insn(gdbarch, insn->pc, di);
 longest_opcode =
   (current_length > longest_opcode) ? current_length : longest_opcode;
}
    }

  return longest_opcode;
}

Best Regards

On Wed, Apr 6, 2016 at 3:56 AM, Metzger, Markus T
<markus.t.metzger@intel.com> wrote:
>> -----Original Message-----
>> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
>> owner@sourceware.org] On Behalf Of Leonardo Boquillon
>> Sent: Tuesday, April 5, 2016 8:11 PM
>> To: Metzger, Markus T <markus.t.metzger@intel.com>
>> Cc: gdb-patches@sourceware.org
>> Subject: Re: [PATCH v2] Fix alignment of disassemble /r
>
> Hi Leonardo,
>
>> > > diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index
>> > > 77b5180..72a0b77 100644
>> > > --- a/gdb/record-btrace.c
>> > > +++ b/gdb/record-btrace.c
>> > > @@ -745,7 +745,7 @@ btrace_insn_history (struct ui_out *uiout,
>> > >         if ((insn->flags & BTRACE_INSN_FLAG_SPECULATIVE) != 0)
>> > >           dinsn.is_speculative = 1;
>> > >
>> > > -       gdb_pretty_print_insn (gdbarch, uiout, &di, &dinsn, flags, stb);
>> > > +       gdb_pretty_print_insn_tab (gdbarch, uiout, &di, &dinsn,
>> > > + flags, stb);
>> >
>> > You can compute the longest opcode just like in the low, high case by
>> > iterating over the to-be-printed instructions like this:
>> >
>> >   for (it = *begin; btrace_insn_cmp (&it, end) != 0; btrace_insn_next (&it,
>> 1))
>> >     {
>> >       const struct btrace_insn *insn;
>> >
>> >       insn = btrace_insn_get (&it);
>> >       if (insn == NULL)
>> >         continue;
>> >
>> >       <compute longest opcode>
>>
>> I'm not sure what you meant with this, that snippet is a backtrace code. If
>> you mean I should use a iterator, I dont know if there is something similar to
>> btrace_insn_iterator that I could use for disassembly.
>
> I was just referring to the record-btrace changes.  The patch uses
> gdb_pretty_print_insn_tab here.  We may instead compute the longest
> opcode and use gdb_pretty_print_insn_padding here, as well.  Just as the
> patch does for disasm.
>
> Record-btrace uses an iterator instead of a low-high address pair.  I sketched the
> loop to compute the longest opcode in this case.
>
> We wouldn't need gdb_pretty_print_insn_tab anymore as all users now use
> gdb_pretty_print_insn_padding.
>
> Regards,
> Markus.
> Intel Deutschland GmbH
> Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
> Tel: +49 89 99 8853-0, www.intel.de
> Managing Directors: Christin Eisenschmid, Christian Lamprechter
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Office: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928



-- 


Leonardo BoquillÃn

Software Engineer


San Lorenzo 47, 3rd Floor, Office 5

CÃrdoba, Argentina


Phone: +54 351 6288940

Skype: lboquillon


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]