[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH 05/11] decodetree: Force Python to print uns
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [RFC PATCH 05/11] decodetree: Force Python to print unsigned values |
Date: |
Mon, 12 Nov 2018 15:03:51 -0200 |
User-agent: |
Mutt/1.9.2 (2017-12-15) |
On Mon, Nov 12, 2018 at 12:36:16AM +0100, Philippe Mathieu-Daudé wrote:
> Python internal representation is signed, so unsigned values
> bigger than 31-bit are interpreted as signed (and printed with
> a '-' signed).
> Mask out to force unsigned values.
I don't understand this commit description. Python surely
supports integers larger than 2^31, and its internal
representation shouldn't matter at all:
>>>
'0x{0:08x}'.format(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
Can you explain how the code ends up with a negative value in the
`self.thismask` or `b` variables? If `self.subs` contains
negative values, this is likely to break other parts of the code.
>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> TODO: display error encountered:
>
> case 0x-1:
> ....
How can I reproduce it?
> ---
> scripts/decodetree.py | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/decodetree.py b/scripts/decodetree.py
> index 5dea15e7a5..08aa52d544 100755
> --- a/scripts/decodetree.py
> +++ b/scripts/decodetree.py
> @@ -900,12 +900,12 @@ class Tree:
> def str_case(b):
> return '0x{0:08x}'.format(b)
>
> - output(ind, 'switch (', str_switch(self.thismask), ') {\n')
> + output(ind, 'switch (', str_switch(self.thismask & insnmask), ')
> {\n')
> for b, s in sorted(self.subs):
> assert (self.thismask & ~s.fixedmask) == 0
> innermask = outermask | self.thismask
> innerbits = outerbits | b
> - output(ind, 'case ', str_case(b), ':\n')
> + output(ind, 'case ', str_case(b & insnmask), ':\n')
> output(ind, ' /* ',
> str_match_bits(innerbits, innermask), ' */\n')
> s.output_code(i + 4, extracted, innerbits, innermask)
> --
> 2.17.2
>
--
Eduardo