diff mbox series

[v2,2/2] disas/hppa: Show hexcode of instruction along with disassembly

Message ID 20231117105309.149225-3-deller@kernel.org
State New
Headers show
Series HPPA64-PATCHES-for-8.2 | expand

Commit Message

Helge Deller Nov. 17, 2023, 10:53 a.m. UTC
From: Helge Deller <deller@gmx.de>

On hppa many instructions can be expressed by different bytecodes.
To be able to debug qemu translation bugs it's therefore necessary to see the
currently executed byte codes without the need to lookup the sequence without
the full executable.
With this patch the instruction byte code is shown beside the disassembly.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 disas/hppa.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Richard Henderson Nov. 17, 2023, 4:45 p.m. UTC | #1
On 11/17/23 02:53, deller@kernel.org wrote:
> From: Helge Deller <deller@gmx.de>
> 
> On hppa many instructions can be expressed by different bytecodes.
> To be able to debug qemu translation bugs it's therefore necessary to see the
> currently executed byte codes without the need to lookup the sequence without
> the full executable.
> With this patch the instruction byte code is shown beside the disassembly.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   disas/hppa.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/disas/hppa.c b/disas/hppa.c
> index dcf9a47f34..38fc05acc4 100644
> --- a/disas/hppa.c
> +++ b/disas/hppa.c
> @@ -1979,6 +1979,9 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
>   	  if (opcode->arch == pa20w)
>   	    continue;
>   #endif
> +	  (*info->fprintf_func) (info->stream, " %02x %02x %02x %02x   ",
> +                (insn >> 24) & 0xff, (insn >> 16) & 0xff,
> +                (insn >>  8) & 0xff, insn & 0xff);
>   	  (*info->fprintf_func) (info->stream, "%s", opcode->name);
>   
>   	  if (!strchr ("cfCY?-+nHNZFIuv{", opcode->args[0]))

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

A possible improvement is to push this outside of the search loop and then change

      }
-  (*info->fprintf_func) (info->stream, "#%8x", insn);
+  info->fprintf_func(info->stream, "<unknown>");
    return sizeof (insn);

so the byte decode is shared with the rare case of garbage in the insn stream.


r~
Helge Deller Nov. 17, 2023, 5:33 p.m. UTC | #2
* Richard Henderson <richard.henderson@linaro.org>:
> On 11/17/23 02:53, deller@kernel.org wrote:
> > From: Helge Deller <deller@gmx.de>
> > 
> > On hppa many instructions can be expressed by different bytecodes.
> > To be able to debug qemu translation bugs it's therefore necessary to see the
> > currently executed byte codes without the need to lookup the sequence without
> > the full executable.
> > With this patch the instruction byte code is shown beside the disassembly.
> > 
> > Signed-off-by: Helge Deller <deller@gmx.de>
> > ---
> >   disas/hppa.c | 3 +++
> >   1 file changed, 3 insertions(+)
> > 
> > diff --git a/disas/hppa.c b/disas/hppa.c
> > index dcf9a47f34..38fc05acc4 100644
> > --- a/disas/hppa.c
> > +++ b/disas/hppa.c
> > @@ -1979,6 +1979,9 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
> >   	  if (opcode->arch == pa20w)
> >   	    continue;
> >   #endif
> > +	  (*info->fprintf_func) (info->stream, " %02x %02x %02x %02x   ",
> > +                (insn >> 24) & 0xff, (insn >> 16) & 0xff,
> > +                (insn >>  8) & 0xff, insn & 0xff);
> >   	  (*info->fprintf_func) (info->stream, "%s", opcode->name);
> >   	  if (!strchr ("cfCY?-+nHNZFIuv{", opcode->args[0]))
> 
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> 
> A possible improvement is to push this outside of the search loop and then change
> 
>      }
> -  (*info->fprintf_func) (info->stream, "#%8x", insn);
> +  info->fprintf_func(info->stream, "<unknown>");
>    return sizeof (insn);
> 
> so the byte decode is shared with the rare case of garbage in the insn stream.

Like below?

From: Helge Deller <deller@gmx.de>
Subject: [PATCH] disas/hppa: Show hexcode of instruction along with
 disassembly

On hppa many instructions can be expressed by different bytecodes.
To be able to debug qemu translation bugs it's therefore necessary to see the
currently executed byte codes without the need to lookup the sequence without
the full executable.
With this patch the instruction byte code is shown beside the disassembly.

Signed-off-by: Helge Deller <deller@gmx.de>

diff --git a/disas/hppa.c b/disas/hppa.c
index dcf9a47f34..cce4f4aa37 100644
--- a/disas/hppa.c
+++ b/disas/hppa.c
@@ -1968,6 +1968,10 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
 
   insn = bfd_getb32 (buffer);
 
+  info->fprintf_func(info->stream, " %02x %02x %02x %02x   ",
+                (insn >> 24) & 0xff, (insn >> 16) & 0xff,
+                (insn >>  8) & 0xff, insn & 0xff);
+
   for (i = 0; i < NUMOPCODES; ++i)
     {
       const struct pa_opcode *opcode = &pa_opcodes[i];
@@ -2826,6 +2830,6 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
 	  return sizeof (insn);
 	}
     }
-  (*info->fprintf_func) (info->stream, "#%8x", insn);
+  info->fprintf_func(info->stream, "<unknown>");
   return sizeof (insn);
 }
Richard Henderson Nov. 17, 2023, 7:52 p.m. UTC | #3
On 11/17/23 09:33, Helge Deller wrote:
> * Richard Henderson <richard.henderson@linaro.org>:
>> On 11/17/23 02:53, deller@kernel.org wrote:
>>> From: Helge Deller <deller@gmx.de>
>>>
>>> On hppa many instructions can be expressed by different bytecodes.
>>> To be able to debug qemu translation bugs it's therefore necessary to see the
>>> currently executed byte codes without the need to lookup the sequence without
>>> the full executable.
>>> With this patch the instruction byte code is shown beside the disassembly.
>>>
>>> Signed-off-by: Helge Deller <deller@gmx.de>
>>> ---
>>>    disas/hppa.c | 3 +++
>>>    1 file changed, 3 insertions(+)
>>>
>>> diff --git a/disas/hppa.c b/disas/hppa.c
>>> index dcf9a47f34..38fc05acc4 100644
>>> --- a/disas/hppa.c
>>> +++ b/disas/hppa.c
>>> @@ -1979,6 +1979,9 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
>>>    	  if (opcode->arch == pa20w)
>>>    	    continue;
>>>    #endif
>>> +	  (*info->fprintf_func) (info->stream, " %02x %02x %02x %02x   ",
>>> +                (insn >> 24) & 0xff, (insn >> 16) & 0xff,
>>> +                (insn >>  8) & 0xff, insn & 0xff);
>>>    	  (*info->fprintf_func) (info->stream, "%s", opcode->name);
>>>    	  if (!strchr ("cfCY?-+nHNZFIuv{", opcode->args[0]))
>>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>
>> A possible improvement is to push this outside of the search loop and then change
>>
>>       }
>> -  (*info->fprintf_func) (info->stream, "#%8x", insn);
>> +  info->fprintf_func(info->stream, "<unknown>");
>>     return sizeof (insn);
>>
>> so the byte decode is shared with the rare case of garbage in the insn stream.
> 
> Like below?

Yes, perfect, thanks.


r~

> 
> From: Helge Deller <deller@gmx.de>
> Subject: [PATCH] disas/hppa: Show hexcode of instruction along with
>   disassembly
> 
> On hppa many instructions can be expressed by different bytecodes.
> To be able to debug qemu translation bugs it's therefore necessary to see the
> currently executed byte codes without the need to lookup the sequence without
> the full executable.
> With this patch the instruction byte code is shown beside the disassembly.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> 
> diff --git a/disas/hppa.c b/disas/hppa.c
> index dcf9a47f34..cce4f4aa37 100644
> --- a/disas/hppa.c
> +++ b/disas/hppa.c
> @@ -1968,6 +1968,10 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
>   
>     insn = bfd_getb32 (buffer);
>   
> +  info->fprintf_func(info->stream, " %02x %02x %02x %02x   ",
> +                (insn >> 24) & 0xff, (insn >> 16) & 0xff,
> +                (insn >>  8) & 0xff, insn & 0xff);
> +
>     for (i = 0; i < NUMOPCODES; ++i)
>       {
>         const struct pa_opcode *opcode = &pa_opcodes[i];
> @@ -2826,6 +2830,6 @@ print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
>   	  return sizeof (insn);
>   	}
>       }
> -  (*info->fprintf_func) (info->stream, "#%8x", insn);
> +  info->fprintf_func(info->stream, "<unknown>");
>     return sizeof (insn);
>   }
diff mbox series

Patch

diff --git a/disas/hppa.c b/disas/hppa.c
index dcf9a47f34..38fc05acc4 100644
--- a/disas/hppa.c
+++ b/disas/hppa.c
@@ -1979,6 +1979,9 @@  print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
 	  if (opcode->arch == pa20w)
 	    continue;
 #endif
+	  (*info->fprintf_func) (info->stream, " %02x %02x %02x %02x   ",
+                (insn >> 24) & 0xff, (insn >> 16) & 0xff,
+                (insn >>  8) & 0xff, insn & 0xff);
 	  (*info->fprintf_func) (info->stream, "%s", opcode->name);
 
 	  if (!strchr ("cfCY?-+nHNZFIuv{", opcode->args[0]))