utils: gdb: fix pretty-printing of BigNum
I was accumulating the digits in reverse...
This commit is contained in:
parent
b50750009b
commit
6989d5209f
|
@ -1,5 +1,12 @@
|
|||
import gdb.printing
|
||||
|
||||
def digits_to_num(digits):
|
||||
res = 0
|
||||
for d in reversed(digits):
|
||||
res *= 10
|
||||
res += d
|
||||
return res
|
||||
|
||||
class BigNumPrinter(object):
|
||||
"Print a abacus::bignum::BigNum"
|
||||
|
||||
|
@ -9,11 +16,11 @@ class BigNumPrinter(object):
|
|||
def to_string(self):
|
||||
digits = self.val['digits_']
|
||||
begin, end = digits['_M_impl']['_M_start'], digits['_M_impl']['_M_finish']
|
||||
val = 0
|
||||
val = []
|
||||
while begin != end:
|
||||
val *= 10
|
||||
val += begin.dereference()
|
||||
val += [begin.dereference()]
|
||||
begin += 1
|
||||
val = digits_to_num(val)
|
||||
val *= self.val['sign_']
|
||||
return str(val)
|
||||
|
||||
|
|
Loading…
Reference in a new issue