Skip to contentSkip to conversation

decodetree: Force Python to print unsigned values

PATCH Applied Philippe Mathieu-Daudé 3 participants 4 messages Nov 11, 2018 – Nov 12, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 decodetree: Force Python to print unsigned values

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.

---
 scripts/decodetree.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/decodetree.py +2 -2
index 5dea15e7a5..a24017d33e 100755
@@ -895,10 +895,10 @@ class Tree:
                 return '0x{0:x}'.format(b >> sh)
         else:
             def str_switch(b):
-                return 'insn & 0x{0:08x}'.format(b)
+                return 'insn & 0x{0:08x}'.format(b & 0xffffffff)
 
             def str_case(b):
-                return '0x{0:08x}'.format(b)
+                return '0x{0:08x}'.format(b & 0xffffffff)
 
         output(ind, 'switch (', str_switch(self.thismask), ') {\n')
         for b, s in sorted(self.subs):
Signature · 1 line
2.19.1
#1 lore raw
Quoted 9 lines · Philippe Mathieu-Daudé

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.

---
 scripts/decodetree.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Queued, thanks.

r~

#2 lore raw

Hi Richard,

Quoted 6 lines · Richard Henderson
Quoted 5 lines · Philippe Mathieu-Daudé

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.

Quoted 6 lines
Quoted 4 lines
---
 scripts/decodetree.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Queued, thanks.

Can you drop this from your queue? I'll send a cleaner approach (as RFC, and I also want to log the error I got in the commit msg).

Thanks,

Phil.

#3 lore raw
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 9 lines

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.

---
 scripts/decodetree.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 4 lines
Quoted 1 line

Queued, thanks.

Can you drop this from your queue? I'll send a cleaner approach (as RFC, and I also want to log the error I got in the commit msg).

Done.

r~