0

When I try to use:

class MyPrinter:
        def __init__(self, val):
                self.val = val

        def to_string(self):
                return str(self.val['fData'][0]) + ":" + "%016x" % (self.val['fData'][0]).cast(gdb.lookup_type("uint64_t"))

It prints
2929725441843584891:28a879c45a82df7b
But also
9918728419520062851:-7659990ddaef5a7d

When the most significant bit is set for val, it is interpreted as signed.

fData[] is uint64_t.

How can I avoid that? All my values should be unsigned.

Frank Bergemann
  • 325
  • 2
  • 14

1 Answers1

0

At least as a workaround this works for me:

class MyPrinter:
        def __init__(self, val):
                self.val = val

        def to_hex(self, val):
                s = ''
                x = 7
                while (x >= 0):
                        s = s + "%02x" % ((val>>(x*8))&255)
                        x -= 1

                return s

        def to_string(self):
                return self.to_hex(self.val['fData'][0]) + self.to_hex(self.val['fData'][1])
Frank Bergemann
  • 325
  • 2
  • 14