brintos

brintos / llvm-project-archived public Read only

0
0
Text · 18.1 KiB · 40fa768 Raw
609 lines · plain
1%extend lldb::SBBreakpoint {2    %pythoncode %{3        def __eq__(self, rhs):4            if not isinstance(rhs, type(self)):5                return False6 7            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)8 9        def __ne__(self, rhs):10            if not isinstance(rhs, type(self)):11                return True12 13            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)14    %}15}16 17%extend lldb::SBBroadcaster {18    %pythoncode %{19        def __eq__(self, rhs):20            if not isinstance(rhs, type(self)):21                return False22 23            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)24 25        def __ne__(self, rhs):26            if not isinstance(rhs, type(self)):27                return True28 29            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)30    %}31}32 33%extend lldb::SBCommandReturnObject {34        /* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage35        they are meant to make an SBCommandReturnObject into a file-like object so that instructions of the sort36        print >>sb_command_return_object, "something"37        will work correctly */38 39        void lldb::SBCommandReturnObject::write (const char* str)40        {41            if (str)42                $self->Printf("%s",str);43        }44        void lldb::SBCommandReturnObject::flush ()45        {}46}47 48%extend lldb::SBCompileUnit {49    %pythoncode %{50        def __eq__(self, rhs):51            if not isinstance(rhs, type(self)):52                return False53 54            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)55 56        def __ne__(self, rhs):57            if not isinstance(rhs, type(self)):58                return True59 60            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)61    %}62}63 64%extend lldb::SBDeclaration {65    %pythoncode %{66        def __eq__(self, rhs):67            if not isinstance(rhs, type(self)):68                return False69 70            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)71 72        def __ne__(self, rhs):73            if not isinstance(rhs, type(self)):74                return True75 76            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)77    %}78}79 80%extend lldb::SBFunction {81    %pythoncode %{82        def __eq__(self, rhs):83            if not isinstance(rhs, type(self)):84                return False85 86            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)87 88        def __ne__(self, rhs):89            if not isinstance(rhs, type(self)):90                return True91 92            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)93    %}94}95 96%extend lldb::SBLineEntry {97    %pythoncode %{98        def __eq__(self, rhs):99            if not isinstance(rhs, type(self)):100                return False101 102            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)103 104        def __ne__(self, rhs):105            if not isinstance(rhs, type(self)):106                return True107 108            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)109    %}110}111 112%extend lldb::SBModule {113    %pythoncode %{114        def __eq__(self, rhs):115            if not isinstance(rhs, type(self)):116                return False117 118            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)119 120        def __ne__(self, rhs):121            if not isinstance(rhs, type(self)):122                return True123 124            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)125    %}126}127 128%extend lldb::SBSection {129    %pythoncode %{130        def __eq__(self, rhs):131            if not isinstance(rhs, type(self)):132                return False133 134            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)135 136        def __ne__(self, rhs):137            if not isinstance(rhs, type(self)):138                return True139 140            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)141    %}142}143%extend lldb::SBStream {144        /* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage145        they are meant to make an SBStream into a file-like object so that instructions of the sort146        print >>sb_stream, "something"147        will work correctly */148 149        void lldb::SBStream::write (const char* str)150        {151            if (str)152                $self->Printf("%s",str);153        }154        void lldb::SBStream::flush ()155        {}156}157%extend lldb::SBSymbol {158    %pythoncode %{159        def __eq__(self, rhs):160            if not isinstance(rhs, type(self)):161                return False162 163            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)164 165        def __ne__(self, rhs):166            if not isinstance(rhs, type(self)):167                return True168 169            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)170    %}171}172 173%extend lldb::SBTarget {174    %pythoncode %{175        def __eq__(self, rhs):176            if not isinstance(rhs, type(self)):177                return False178 179            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)180 181        def __ne__(self, rhs):182            if not isinstance(rhs, type(self)):183                return True184 185            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)186    %}187}188 189%extend lldb::SBTypeFilter {190    %pythoncode %{191        def __eq__(self, rhs):192            if not isinstance(rhs, type(self)):193                return False194 195            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)196 197        def __ne__(self, rhs):198            if not isinstance(rhs, type(self)):199                return True200 201            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)202    %}203}204 205%extend lldb::SBTypeNameSpecifier {206    %pythoncode %{207        def __eq__(self, rhs):208            if not isinstance(rhs, type(self)):209                return False210 211            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)212 213        def __ne__(self, rhs):214            if not isinstance(rhs, type(self)):215                return True216 217            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)218    %}219}220 221%extend lldb::SBTypeSummary {222    %pythoncode %{223        def __eq__(self, rhs):224            if not isinstance(rhs, type(self)):225                return False226 227            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)228 229        def __ne__(self, rhs):230            if not isinstance(rhs, type(self)):231                return True232 233            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)234    %}235}236 237%extend lldb::SBTypeSynthetic {238    %pythoncode %{239        def __eq__(self, rhs):240            if not isinstance(rhs, type(self)):241                return False242 243            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)244 245        def __ne__(self, rhs):246            if not isinstance(rhs, type(self)):247                return True248 249            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)250    %}251}252 253%extend lldb::SBThread {254    %pythoncode %{255        def __eq__(self, rhs):256            if not isinstance(rhs, type(self)):257                return False258 259            return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)260 261        def __ne__(self, rhs):262            if not isinstance(rhs, type(self)):263                return True264 265            return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)266    %}267}268 269%pythoncode %{270 271def command(command_name=None, doc=None):272    import lldb273    """A decorator function that registers an LLDB command line274        command that is bound to the function it is attached to."""275    def callable(function):276        """Registers an lldb command for the decorated function."""277        command = "command script add -f %s.%s %s" % (function.__module__, function.__name__, command_name or function.__name__)278        lldb.debugger.HandleCommand(command)279        if doc:280            function.__doc__ = doc281        return function282 283    return callable284 285class declaration(object):286    '''A class that represents a source declaration location with file, line and column.'''287    def __init__(self, file, line, col):288        self.file = file289        self.line = line290        self.col = col291 292class value_iter(object):293    '''Allows iterating over the children of an :py:class:`SBValue`.'''294    def __iter__(self):295        return self296 297    def __next__(self):298        if self.index >= self.length:299            raise StopIteration()300        child_sbvalue = self.sbvalue.GetChildAtIndex(self.index)301        self.index += 1302        return value(child_sbvalue)303 304    def next(self):305        return self.__next__()306 307    def __eq__(self, other):308        return not self.__ne__(other)309 310    def __len__(self):311        return self.length312 313    def __init__(self,value):314        self.index = 0315        self.length = 0316        self.sbvalue = value317        if type(self.sbvalue) is value:318            self.sbvalue = self.sbvalue.sbvalue319        self.length = self.sbvalue.GetNumChildren()320 321class value(object):322    '''Wraps :py:class:`SBValue` objects so the resulting object can be used as a variable would be in code.323 324    So if you have a Point structure variable in your code in the current frame named "pt",325    you can initialize an instance of this class with it: ::326 327        pt = lldb.value(lldb.frame.FindVariable("pt"))328        print pt329        print pt.x330        print pt.y331 332        pt = lldb.value(lldb.frame.FindVariable("rectangle_array"))333        print rectangle_array[12]334        print rectangle_array[5].origin.x'''335    def __init__(self, sbvalue):336        self.sbvalue = sbvalue337 338    def __nonzero__(self):339        return self.sbvalue.__nonzero__()340 341    def __bool__(self):342        return self.sbvalue.__bool__()343 344    def __str__(self):345        return self.sbvalue.__str__()346 347    def __getitem__(self, key):348        # Allow array access if this value has children...349        if type(key) is value:350            key = int(key)351        if type(key) is int:352            child_sbvalue = (self.sbvalue.GetValueForExpressionPath("[%i]" % key))353            if child_sbvalue and child_sbvalue.IsValid():354                return value(child_sbvalue)355            raise IndexError("Index '%d' is out of range" % key)356        raise TypeError("No array item of type %s" % str(type(key)))357 358    def __iter__(self):359        return value_iter(self.sbvalue)360 361    def __getattr__(self, name):362        child_sbvalue = self.sbvalue.GetChildMemberWithName (name)363        if child_sbvalue and child_sbvalue.IsValid():364            return value(child_sbvalue)365        raise AttributeError("Attribute '%s' is not defined" % name)366 367    def __add__(self, other):368        return int(self) + int(other)369 370    def __sub__(self, other):371        return int(self) - int(other)372 373    def __mul__(self, other):374        return int(self) * int(other)375 376    def __floordiv__(self, other):377        return int(self) // int(other)378 379    def __mod__(self, other):380        return int(self) % int(other)381 382    def __divmod__(self, other):383        return int(self) % int(other)384 385    def __pow__(self, other):386        return int(self) ** int(other)387 388    def __lshift__(self, other):389        return int(self) << int(other)390 391    def __rshift__(self, other):392        return int(self) >> int(other)393 394    def __and__(self, other):395        return int(self) & int(other)396 397    def __xor__(self, other):398        return int(self) ^ int(other)399 400    def __or__(self, other):401        return int(self) | int(other)402 403    def __div__(self, other):404        return int(self) / int(other)405 406    def __truediv__(self, other):407        return int(self) / int(other)408 409    def __iadd__(self, other):410        result = self.__add__(other)411        self.sbvalue.SetValueFromCString (str(result))412        return result413 414    def __isub__(self, other):415        result = self.__sub__(other)416        self.sbvalue.SetValueFromCString (str(result))417        return result418 419    def __imul__(self, other):420        result = self.__mul__(other)421        self.sbvalue.SetValueFromCString (str(result))422        return result423 424    def __idiv__(self, other):425        result = self.__div__(other)426        self.sbvalue.SetValueFromCString (str(result))427        return result428 429    def __itruediv__(self, other):430        result = self.__truediv__(other)431        self.sbvalue.SetValueFromCString (str(result))432        return result433 434    def __ifloordiv__(self, other):435        result =  self.__floordiv__(self, other)436        self.sbvalue.SetValueFromCString (str(result))437        return result438 439    def __imod__(self, other):440        result =  self.__and__(self, other)441        self.sbvalue.SetValueFromCString (str(result))442        return result443 444    def __ipow__(self, other):445        result = self.__pow__(self, other)446        self.sbvalue.SetValueFromCString (str(result))447        return result448 449    def __ipow__(self, other, modulo):450        result = self.__pow__(self, other, modulo)451        self.sbvalue.SetValueFromCString (str(result))452        return result453 454    def __ilshift__(self, other):455        result = self.__lshift__(other)456        self.sbvalue.SetValueFromCString (str(result))457        return result458 459    def __irshift__(self, other):460        result =  self.__rshift__(other)461        self.sbvalue.SetValueFromCString (str(result))462        return result463 464    def __iand__(self, other):465        result =  self.__and__(self, other)466        self.sbvalue.SetValueFromCString (str(result))467        return result468 469    def __ixor__(self, other):470        result =  self.__xor__(self, other)471        self.sbvalue.SetValueFromCString (str(result))472        return result473 474    def __ior__(self, other):475        result =  self.__ior__(self, other)476        self.sbvalue.SetValueFromCString (str(result))477        return result478 479    def __neg__(self):480        return -int(self)481 482    def __pos__(self):483        return +int(self)484 485    def __abs__(self):486        return abs(int(self))487 488    def __invert__(self):489        return ~int(self)490 491    def __complex__(self):492        return complex (int(self))493 494    def __int__(self):495        is_num,is_sign = is_numeric_type(self.sbvalue.GetType().GetCanonicalType().GetBasicType())496        if is_num and not is_sign: return self.sbvalue.GetValueAsUnsigned()497        return self.sbvalue.GetValueAsSigned()498 499    def __long__(self):500        return self.__int__()501 502    def __float__(self):503        return float (self.sbvalue.GetValueAsSigned())504 505    def __oct__(self):506        return '0%o' % self.sbvalue.GetValueAsUnsigned()507 508    def __hex__(self):509        return '0x%x' % self.sbvalue.GetValueAsUnsigned()510 511    def __len__(self):512        return self.sbvalue.GetNumChildren()513 514    def __eq__(self, other):515        if type(other) is int:516                return int(self) == other517        elif type(other) is str:518                return str(self) == other519        elif type(other) is value:520                self_err = SBError()521                other_err = SBError()522                self_val = self.sbvalue.GetValueAsUnsigned(self_err)523                if self_err.fail:524                        raise ValueError("unable to extract value of self")525                other_val = other.sbvalue.GetValueAsUnsigned(other_err)526                if other_err.fail:527                        raise ValueError("unable to extract value of other")528                return self_val == other_val529        raise TypeError("Unknown type %s, No equality operation defined." % str(type(other)))530 531    def __ne__(self, other):532        return not self.__eq__(other)533%}534 535%pythoncode %{536 537class SBSyntheticValueProvider(object):538    def __init__(self,valobj):539        pass540 541    def num_children(self):542        return 0543 544    def get_child_index(self,name):545        return None546 547    def get_child_at_index(self,idx):548        return None549 550    def update(self):551        pass552 553    def has_children(self):554        return False555 556    def __len__(self):557      return self.num_children()558 559    def __iter__(self):560      '''Iterate over all children in a lldb.SBSyntheticValueProvider object.'''561      return lldb_iter(self, 'num_children', 'get_child_at_index')562 563%}564 565%pythoncode %{566 567# given an lldb.SBBasicType it returns a tuple568# (is_numeric, is_signed)569# the value of is_signed is undefined if is_numeric == false570def is_numeric_type(basic_type):571    if basic_type == eBasicTypeInvalid: return (False,False)572    if basic_type == eBasicTypeVoid: return (False,False)573    if basic_type == eBasicTypeChar: return (True,False)574    if basic_type == eBasicTypeSignedChar: return (True,True)575    if basic_type == eBasicTypeUnsignedChar: return (True,False)576    if basic_type == eBasicTypeWChar: return (True,False)577    if basic_type == eBasicTypeSignedWChar: return (True,True)578    if basic_type == eBasicTypeUnsignedWChar: return (True,False)579    if basic_type == eBasicTypeChar16: return (True,False)580    if basic_type == eBasicTypeChar32: return (True,False)581    if basic_type == eBasicTypeChar8: return (True,False)582    if basic_type == eBasicTypeShort: return (True,True)583    if basic_type == eBasicTypeUnsignedShort: return (True,False)584    if basic_type == eBasicTypeInt: return (True,True)585    if basic_type == eBasicTypeUnsignedInt: return (True,False)586    if basic_type == eBasicTypeLong: return (True,True)587    if basic_type == eBasicTypeUnsignedLong: return (True,False)588    if basic_type == eBasicTypeLongLong: return (True,True)589    if basic_type == eBasicTypeUnsignedLongLong: return (True,False)590    if basic_type == eBasicTypeInt128: return (True,True)591    if basic_type == eBasicTypeUnsignedInt128: return (True,False)592    if basic_type == eBasicTypeBool: return (False,False)593    if basic_type == eBasicTypeHalf: return (True,True)594    if basic_type == eBasicTypeFloat: return (True,True)595    if basic_type == eBasicTypeDouble: return (True,True)596    if basic_type == eBasicTypeLongDouble: return (True,True)597    if basic_type == eBasicTypeFloat128: return (True,True)598    if basic_type == eBasicTypeFloatComplex: return (True,True)599    if basic_type == eBasicTypeDoubleComplex: return (True,True)600    if basic_type == eBasicTypeLongDoubleComplex: return (True,True)601    if basic_type == eBasicTypeObjCID: return (False,False)602    if basic_type == eBasicTypeObjCClass: return (False,False)603    if basic_type == eBasicTypeObjCSel: return (False,False)604    if basic_type == eBasicTypeNullPtr: return (False,False)605    #if basic_type == eBasicTypeOther:606    return (False,False)607 608%}609