This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2] Fix alignment of disassemble /r
- From: Leonardo Boquillon <leonardo dot boquillon at tallertechnologies dot com>
- To: "Metzger, Markus T" <markus dot t dot metzger at intel dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Wed, 6 Apr 2016 14:46:40 -0300
- Subject: Re: [PATCH v2] Fix alignment of disassemble /r
- Authentication-results: sourceware.org; auth=none
- References: <1459534685-10835-1-git-send-email-leonardo dot boquillon at tallertechnologies dot com> <A78C989F6D9628469189715575E55B233328EFE2 at IRSMSX104 dot ger dot corp dot intel dot com> <CABsS7grbpJ0r_oTQcUQoptd_7xpXaKukY2Ch3yFubPsdsr=X8Q at mail dot gmail dot com> <A78C989F6D9628469189715575E55B23332925FD at IRSMSX104 dot ger dot corp dot intel dot com>
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