Converting python string to gdb.Value for GDB pretty printing

Viewed 126

when i try to return a python string as part of the children of a GDB prettyprinter, it returns as a char array. Is there a way i can return it as a normal string ?

I have a pretty printer like this

class APrinter:

    def __init__(self, val):
        self.name = "a name"
        self.age = age

    def children(self):
        yield ('name', self.name)
        yield ('age', self.age)
        yield ('address', 'this is an address')

    def display_hint(self):
        return 'array'

in this case name and address would return as a char array in an ide

i also tried converting it to a gdb Value

yield ('address', gdb.Value('this is an address'))

from the api here, but it returns the same result

result

however when i put it in the to_string method it prints out normally like this

def to_string(self):
    return 'this is an address' 
0 Answers
Related