Re: [PATCH] Add a new format letter to dump instructions backward

Paul_Koning
2016-01-25T20:11:15Z

> On Jan 25, 2016, at 1:27 PM, Pedro Alves <palves@redhat.com> wrote:
>
> On 01/25/2016 06:22 PM, Paul_Koning@Dell.com wrote:
>>
>>> On Jan 25, 2016, at 12:52 PM, John Baldwin <jhb@freebsd.org> wrote:
>>>
>>> On Monday, January 25, 2016 11:41:27 AM Pedro Alves wrote:
>>>> On 01/24/2016 09:28 PM, Toshihito Kikuchi wrote:
>>>> ...
>>>> #3 - negative repeat counts ?
>>>>
>>>> (gdb) x /4i // next 4 instructions
>>>> (gdb) x /-4i // previous 4 instructions
>>>> ...
>>>> #3 feels natural to me. What do you (and others) think?
>>>
>>> I think #3 is the most natural as well. I also think this is a
>>> very useful feature.
>>
>> Yes, but how do you do instructions backwards if the instruction length is variable? It is entirely possible that there will be multiple possible answers, and no way to tell which one (if any) is "correct".
>
> You disassemble forward starting from the previous known
> instruction boundary, based on symbol/line info. I haven't looked
> at the implementation in detail, but from the patch description, that's
> what I assume the patch is doing.

So unlike the existing x commands this would depend on debug information. It would be nice if it worked without, on machines where instruction length is fixed (most RISC machines).

paul