def wesnoth_lookup_function(val):
        "Look-up and return a pretty-printer that can print val."

        #If it is a null pointer or object return the null pointer printer
        if (val.type.code == gdb.TYPE_CODE_PTR
                and long(val) == 0) or (val.address == 0):
            return NullPointerPrinter(val)

        # Get the type name.
        type = strip_all_type(val)

        # Get the type name.
        typename = type.tag

        if typename is None:
            return None

        # Iterate over local dictionary of types to determine
        # if a printer is registered for that type.  Return an
        # instantiation of the printer if found.
        for function in pretty_printers_dict:
            if function.match(typename):
                return pretty_printers_dict[function](val)

        # Cannot find a pretty printer.  Return None.
        return None
    def wesnoth_lookup_function(val):
        "Look-up and return a pretty-printer that can print val."

        #If it is a null pointer or object return the null pointer printer
        if (val.type.code == gdb.TYPE_CODE_PTR and long(val) == 0) or (val.address == 0):
            return NullPointerPrinter(val)

        # Get the type name.
        type = strip_all_type(val)

        # Get the type name.
        typename = type.tag

        if typename is None:
            return None

        # Iterate over local dictionary of types to determine
        # if a printer is registered for that type.  Return an
        # instantiation of the printer if found.
        for function in pretty_printers_dict:
            if function.match(typename):
                return pretty_printers_dict[function](val)

        # Cannot find a pretty printer.  Return None.
        return None
Exemplo n.º 3
0
    def __init__(self, val):
        self.val = val

        # Get the type name.
        self.type = strip_all_type(self.val)

        #Dereference pointers
        self.lval = dereference_if_possible(self.val)
    def __init__(self, val):
        self.val = val

        # Get the type name.
        self.type = strip_all_type(self.val)

        #Dereference pointers
        self.lval = dereference_if_possible(self.val)
Exemplo n.º 5
0
    def to_string(self):
        # Get the type.
        type = self.val.type

        # Get the type name.
        type = strip_all_type(self.val)

        #Return the underlying base class
        baseclass = type.fields()[0].type

        return self.val.cast(baseclass)
    def to_string(self):
        # Get the type.
        type = self.val.type

        # Get the type name.
        type = strip_all_type(self.val)

        #Return the underlying base class
        baseclass = type.fields()[0].type

        return self.val.cast(baseclass)
Exemplo n.º 7
0
    def to_string(self):
        # Get the type name.
        type = strip_all_type(self.val)

        #Dereference pointers
        lval = dereference_if_possible(self.val)

        #Return the underlying base class
        baseclass = type.fields()[0].type

        shared = lval.cast(baseclass)['val_']
        if shared == 0:
            return 'NULL'

        #Print the untranslated string or an error
        try:
            ret = shared.dereference()['val']['value_']['iter_']['first']
        except RuntimeError, e:
            return "wesnoth_gdb error invalid tstring"
    def to_string(self):
        # Get the type name.
        type = strip_all_type(self.val)

        #Dereference pointers
        lval = dereference_if_possible(self.val)

        #Return the underlying base class
        baseclass = type.fields()[0].type

        shared = lval.cast(baseclass)['val_']
        if shared == 0:
            return 'NULL'

        #Print the untranslated string or an error
        try:
            ret = shared.dereference()['val']['value_']['iter_']['first']
        except RuntimeError, e:
            return "wesnoth_gdb error invalid tstring"
Exemplo n.º 9
0
    def children(self):
        # Get the type.
        self.type = strip_all_type(self.val)

        try:
            #Dereference pointers
            lval = dereference_if_possible(self.val)

            attr = lval
            attr_type = attr['type_']

            class Atype:
                EMPTY = 0
                BOOL = 1
                INT = 2
                DOUBLE = 3
                TSTRING = 4
                TOKEN = 5

            if attr_type == Atype.EMPTY:
                yield "EMPTY", ""
            elif attr_type == Atype.BOOL:
                yield 'bool', 'true' if attr['bool_value_'] else 'false'
            elif attr_type == Atype.INT:
                yield 'int', 'int ' + ('%s' % attr['int_value_'])
            elif attr_type == Atype.DOUBLE:
                yield 'double', 'double ' + ('%s' % attr['double_value_'])
            elif attr_type == Atype.TOKEN:
                yield 'token', 'token ' + ('%s' % attr['token_value_'])
            elif attr_type == Atype.TSTRING:
                yield 't_string', 't_string ' + ('%s' %
                                                 attr['t_string_value_'])
            else:
                yield 'unknown', "unknown type code = " + ('%d' % attr_type)

        except RuntimeError, e:
            yield 'error', "wesnoth_gdb error invalid %s" % self.val.type
Exemplo n.º 10
0
    def children(self):
        # Get the type.
        self.type = strip_all_type(self.val)

        try:
            #Dereference pointers
            lval = dereference_if_possible(self.val)

            attr = lval
            attr_type = attr['type_']

            class Atype:
                EMPTY = 0
                BOOL = 1
                INT = 2
                DOUBLE = 3
                TSTRING = 4
                TOKEN = 5

            if attr_type == Atype.EMPTY:
                yield "EMPTY", ""
            elif attr_type == Atype.BOOL:
                yield 'bool', 'true' if attr['bool_value_'] else 'false'
            elif attr_type == Atype.INT:
                yield 'int', 'int ' + ('%s' % attr['int_value_'])
            elif attr_type == Atype.DOUBLE:
                yield 'double', 'double ' + ('%s' % attr['double_value_'])
            elif attr_type == Atype.TOKEN:
                yield 'token', 'token ' + ('%s' % attr['token_value_'])
            elif attr_type == Atype.TSTRING:
                yield 't_string', 't_string ' + ('%s' % attr['t_string_value_'])
            else:
                yield 'unknown', "unknown type code = " + ('%d' % attr_type)

        except RuntimeError, e:
            yield 'error', "wesnoth_gdb error invalid %s" % self.val.type
    def children(self):
        # Get the type.
        self.type = strip_all_type(self.val)

        try:
            # Dereference pointers
            lval = dereference_if_possible(self.val)

            attr = lval
            attr_type = attr["type_"]

            class Atype:
                EMPTY = 0
                BOOL = 1
                INT = 2
                DOUBLE = 3
                TSTRING = 4
                TOKEN = 5

            if attr_type == Atype.EMPTY:
                yield "EMPTY", ""
            elif attr_type == Atype.BOOL:
                yield "bool", "true" if attr["bool_value_"] else "false"
            elif attr_type == Atype.INT:
                yield "int", "int " + ("%s" % attr["int_value_"])
            elif attr_type == Atype.DOUBLE:
                yield "double", "double " + ("%s" % attr["double_value_"])
            elif attr_type == Atype.TOKEN:
                yield "token", "token " + ("%s" % attr["token_value_"])
            elif attr_type == Atype.TSTRING:
                yield "t_string", "t_string " + ("%s" % attr["t_string_value_"])
            else:
                yield "unknown", "unknown type code = " + ("%d" % attr_type)

        except RuntimeError, e:
            yield "error", "wesnoth_gdb error invalid %s" % self.val.type