diff --git a/uppsrc/ide/Debuggers/PrettyPrinters.py b/uppsrc/ide/Debuggers/PrettyPrinters.py index 2a07d0f35..2a0d7dcce 100644 --- a/uppsrc/ide/Debuggers/PrettyPrinters.py +++ b/uppsrc/ide/Debuggers/PrettyPrinters.py @@ -140,7 +140,7 @@ class UppArrayPrinter(object): class UppValuePrinter(object): def __init__(self, val): - self.typeid ={ + self.typeIds ={ 0:'void', 1:'int', 2:'double', @@ -156,6 +156,29 @@ class UppValuePrinter(object): 12:'Upp::ValueMap' } self.val = val + + def to_string(self): + typeId = Upp_Value_GetType(self.val) + if typeId == 0: + return '' + elif typeId == 1 or typeId == 10: + return str(Upp_Value_GetInteger(self.val)) + elif typeId == 2: + return str(Upp_Value_GetDouble(self.val)) + elif typeId == 3: + return str(Upp_Value_GetString(self.val)) + elif typeId == 6: + return '' + elif typeId == 7: + return str(Upp_Value_GetValue(self.val)) + elif typeId == 8: + return str(Upp_Value_GetWString(self.val)) + elif typeId == 11: + return str(Upp_Value_GetBool(self.val)) + elif self.typeIds.has_key(typeId): + return "" + else: + return "" def UppLookupFunction(val): typeStr = str(val.type) @@ -166,6 +189,9 @@ def UppLookupFunction(val): if typeStr == 'Upp::String': return UppStringPrinter(val) + if typeStr == 'Upp::Value' and Upp_Value_Inspectors: + return UppValuePrinter(val) + lookup_tag = val.type.tag if lookup_tag == None: return None @@ -180,6 +206,21 @@ def UppLookupFunction(val): return None +#check if Upp value inspecting support is enabled +Upp_Value_Inspectors = True +try: + Upp_Value_GetType = gdb.parse_and_eval('Upp::_GDB_Value_GetType') + Upp_Value_GetString = gdb.parse_and_eval('Upp::_GDB_Value_GetString') + Upp_Value_GetWString = gdb.parse_and_eval('Upp::_GDB_Value_GetWString') + Upp_Value_GetInteger = gdb.parse_and_eval('Upp::_GDB_Value_GetInteger') + Upp_Value_GetDouble = gdb.parse_and_eval('Upp::_GDB_Value_GetDouble') + Upp_Value_GetDate = gdb.parse_and_eval('Upp::_GDB_Value_GetDate') + Upp_Value_GetTime = gdb.parse_and_eval('Upp::_GDB_Value_GetTime') + Upp_Value_GetBool = gdb.parse_and_eval('Upp::_GDB_Value_GetBool') + Upp_Value_GetValue = gdb.parse_and_eval('Upp::_GDB_Value_GetValue') +except Exception as inst: + Upp_Value_Inspectors = False + gdb.pretty_printers.append(UppLookupFunction) #a couple of lines to test it quickly on gdb....