aboutsummaryrefslogtreecommitdiff
path: root/test/Scripts/common_dump.py
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2011-10-20 21:10:27 +0000
committerDimitry Andric <dim@FreeBSD.org>2011-10-20 21:10:27 +0000
commit30815c536baacc07e925f0aef23a5395883173dc (patch)
tree2cbcf22585e99f8a87d12d5ff94f392c0d266819 /test/Scripts/common_dump.py
parent411bd29eea3c360d5b48a18a17b5e87f5671af0e (diff)
Diffstat (limited to 'test/Scripts/common_dump.py')
-rw-r--r--test/Scripts/common_dump.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/test/Scripts/common_dump.py b/test/Scripts/common_dump.py
index 3d69c3fb27f2..fd58993c0584 100644
--- a/test/Scripts/common_dump.py
+++ b/test/Scripts/common_dump.py
@@ -31,7 +31,7 @@ def dataToHexUnified(d):
return ''.join(bytes).strip()
-def HexDump(val, numBits=32):
+def HexDump(valPair):
"""
1. do not print 'L'
2. Handle negatives and large numbers by mod (2^numBits)
@@ -40,7 +40,9 @@ def HexDump(val, numBits=32):
4. Do print 0x Why?
so that they can be easily distinguished using sed/rx
"""
+ val, numBits = valPair
+ assert 0 <= val < (1 << numBits)
+
val = val & (( 1 << numBits) - 1)
newFmt = "0x%0" + "%d" % (numBits / 4) + "x"
return newFmt % val
-