This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [rfc] btrace: change record instruction-history /m
- From: Doug Evans <dje at google dot com>
- To: Markus Metzger <markus dot t dot metzger at intel dot com>
- Cc: Pedro Alves <palves at redhat dot com>, gdb-patches <gdb-patches at sourceware dot org>
- Date: Fri, 14 Aug 2015 10:01:51 -0700
- Subject: Re: [rfc] btrace: change record instruction-history /m
- Authentication-results: sourceware.org; auth=none
- References: <1439552272-6256-1-git-send-email-markus dot t dot metzger at intel dot com>
On Fri, Aug 14, 2015 at 4:37 AM, Markus Metzger
<markus.t.metzger@intel.com> wrote:
> The /m modifier interleaves source lines with the disassembly of recorded
> instructions. This calls disasm.c's do_mixed_source_and_assembly once for
> each recorded instruction to be printed.
>
> The latter really does a source print with intermixed disassembly. To that
> purpose, it may reorder instructions to better match the source. This is
> nice for disassembling an entire function, but it doesn't work for printing
> a single instruction.
Even for an entire function "source centric" disassembly can be a pain.
If some find it useful, great, but I never do.
> Change record instruction-history /m to use its own simple source interleaving
> algorithm. The most important part is that instructions are printed in
> the order in which they were executed. Before each instruction, we print
> a range of source lines that are attributed to the instruction's PC. If the
> source line range has already been printed (or skipped) for the previous
> instruction, we skip it.
>
> The algorithm would fill in the missing lines if a PC is attributed to more
> than one source line. I have not seen this. There always seems to be at
> most one source line per PC.
One can imagine such a think happening more often with an LIW ISA.
[assuming the compiler cares to provide such info]
> I don't think that there is an MI consumer of "record instruction-history"
> and I have no idea if and how this might affect MI.
Good question. Dunno either.
> Alternatively, we could extend Doug Evan's new algorithm
> https://sourceware.org/ml/gdb-patches/2015-08/msg00335.html to take a vector
> of PCs.
>
> 2015-08-14 Markus Metzger <markus.t.metzger@intel.com>
>
> gdb/
> * record-btrace.c (struct btrace_line_range): New.
> (btrace_mk_line_range, btrace_line_range_add)
> (btrace_line_range_is_empty, btrace_line_range_contains_range)
> (btrace_find_line_range, btrace_print_lines): New.
> (btrace_insn_history): Add source interleaving algorithm.
Yeah, I'd like to avoid having multiple copies of code
doing basically the same thing.
Plus, no one is going to look in record-btrace.c for
"smart disassembly support".
disasm.c should be providing the necessary API
that the rest of gdb an use.