Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 1 | |
| 2 | %extend lldb::SBAddress { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 3 | PyObject *lldb::SBAddress::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 4 | lldb::SBStream description; |
| 5 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 6 | const char *desc = description.GetData(); |
| 7 | size_t desc_len = description.GetSize(); |
| 8 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 9 | --desc_len; |
| 10 | if (desc_len > 0) |
| 11 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 12 | else |
| 13 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 14 | } |
| 15 | } |
| 16 | %extend lldb::SBBlock { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 17 | PyObject *lldb::SBBlock::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 18 | lldb::SBStream description; |
| 19 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 20 | const char *desc = description.GetData(); |
| 21 | size_t desc_len = description.GetSize(); |
| 22 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 23 | --desc_len; |
| 24 | if (desc_len > 0) |
| 25 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 26 | else |
| 27 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 28 | } |
| 29 | } |
| 30 | %extend lldb::SBBreakpoint { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 31 | PyObject *lldb::SBBreakpoint::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 32 | lldb::SBStream description; |
Greg Clayton | 05faeb7 | 2010-10-07 04:19:01 +0000 | [diff] [blame] | 33 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 34 | const char *desc = description.GetData(); |
| 35 | size_t desc_len = description.GetSize(); |
| 36 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 37 | --desc_len; |
| 38 | if (desc_len > 0) |
| 39 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 40 | else |
| 41 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 42 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 43 | |
| 44 | %pythoncode %{ |
| 45 | def __eq__(self, rhs): |
| 46 | if not isinstance(rhs, type(self)): |
| 47 | return False |
| 48 | |
| 49 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 50 | |
| 51 | def __ne__(self, rhs): |
| 52 | if not isinstance(rhs, type(self)): |
| 53 | return True |
| 54 | |
| 55 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 56 | %} |
| 57 | |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 58 | } |
| 59 | %extend lldb::SBBreakpointLocation { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 60 | PyObject *lldb::SBBreakpointLocation::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 61 | lldb::SBStream description; |
Johnny Chen | fc87e2d | 2011-04-25 20:23:05 +0000 | [diff] [blame] | 62 | $self->GetDescription (description, lldb::eDescriptionLevelFull); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 63 | const char *desc = description.GetData(); |
| 64 | size_t desc_len = description.GetSize(); |
| 65 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 66 | --desc_len; |
| 67 | if (desc_len > 0) |
| 68 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 69 | else |
| 70 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 71 | } |
| 72 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 73 | |
| 74 | %extend lldb::SBBroadcaster { |
| 75 | %pythoncode %{ |
| 76 | def __eq__(self, rhs): |
| 77 | if not isinstance(rhs, type(self)): |
| 78 | return False |
| 79 | |
| 80 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 81 | |
| 82 | def __ne__(self, rhs): |
| 83 | if not isinstance(rhs, type(self)): |
| 84 | return True |
| 85 | |
| 86 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 87 | %} |
| 88 | } |
| 89 | |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 90 | %extend lldb::SBCommandReturnObject { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 91 | PyObject *lldb::SBCommandReturnObject::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 92 | lldb::SBStream description; |
| 93 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 94 | const char *desc = description.GetData(); |
| 95 | size_t desc_len = description.GetSize(); |
| 96 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 97 | --desc_len; |
| 98 | if (desc_len > 0) |
| 99 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 100 | else |
| 101 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 102 | } |
Enrico Granata | ceba071 | 2013-03-25 17:37:39 +0000 | [diff] [blame] | 103 | |
| 104 | /* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage |
| 105 | they are meant to make an SBCommandReturnObject into a file-like object so that instructions of the sort |
| 106 | print >>sb_command_return_object, "something" |
| 107 | will work correctly */ |
| 108 | |
Enrico Granata | 7d1f939 | 2013-03-23 01:35:44 +0000 | [diff] [blame] | 109 | void lldb::SBCommandReturnObject::write (const char* str) |
| 110 | { |
| 111 | if (str) |
| 112 | $self->Printf("%s",str); |
| 113 | } |
| 114 | void lldb::SBCommandReturnObject::flush () |
| 115 | {} |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 116 | } |
| 117 | %extend lldb::SBCompileUnit { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 118 | PyObject *lldb::SBCompileUnit::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 119 | lldb::SBStream description; |
| 120 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 121 | const char *desc = description.GetData(); |
| 122 | size_t desc_len = description.GetSize(); |
| 123 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 124 | --desc_len; |
| 125 | if (desc_len > 0) |
| 126 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 127 | else |
| 128 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 129 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 130 | %pythoncode %{ |
| 131 | def __eq__(self, rhs): |
| 132 | if not isinstance(rhs, type(self)): |
| 133 | return False |
| 134 | |
| 135 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 136 | |
| 137 | def __ne__(self, rhs): |
| 138 | if not isinstance(rhs, type(self)): |
| 139 | return True |
| 140 | |
| 141 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 142 | %} |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 143 | } |
Enrico Granata | 9128ee2 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 144 | %extend lldb::SBData { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 145 | PyObject *lldb::SBData::__str__ (){ |
Enrico Granata | 9128ee2 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 146 | lldb::SBStream description; |
| 147 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 148 | const char *desc = description.GetData(); |
| 149 | size_t desc_len = description.GetSize(); |
| 150 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 151 | --desc_len; |
| 152 | if (desc_len > 0) |
| 153 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 154 | else |
| 155 | return PyString_FromString(""); |
Enrico Granata | 9128ee2 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 156 | } |
| 157 | } |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 158 | %extend lldb::SBDebugger { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 159 | PyObject *lldb::SBDebugger::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 160 | lldb::SBStream description; |
| 161 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 162 | const char *desc = description.GetData(); |
| 163 | size_t desc_len = description.GetSize(); |
| 164 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 165 | --desc_len; |
| 166 | if (desc_len > 0) |
| 167 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 168 | else |
| 169 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 170 | } |
| 171 | } |
Enrico Granata | 10de090 | 2012-10-10 22:54:17 +0000 | [diff] [blame] | 172 | %extend lldb::SBDeclaration { |
| 173 | PyObject *lldb::SBDeclaration::__str__ (){ |
| 174 | lldb::SBStream description; |
| 175 | $self->GetDescription (description); |
| 176 | const char *desc = description.GetData(); |
| 177 | size_t desc_len = description.GetSize(); |
| 178 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 179 | --desc_len; |
| 180 | if (desc_len > 0) |
| 181 | return PyString_FromStringAndSize (desc, desc_len); |
| 182 | else |
| 183 | return PyString_FromString(""); |
| 184 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 185 | |
| 186 | %pythoncode %{ |
| 187 | def __eq__(self, rhs): |
| 188 | if not isinstance(rhs, type(self)): |
| 189 | return False |
| 190 | |
| 191 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 192 | |
| 193 | def __ne__(self, rhs): |
| 194 | if not isinstance(rhs, type(self)): |
| 195 | return True |
| 196 | |
| 197 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 198 | %} |
| 199 | |
Enrico Granata | 10de090 | 2012-10-10 22:54:17 +0000 | [diff] [blame] | 200 | } |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 201 | %extend lldb::SBError { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 202 | PyObject *lldb::SBError::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 203 | lldb::SBStream description; |
| 204 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 205 | const char *desc = description.GetData(); |
| 206 | size_t desc_len = description.GetSize(); |
| 207 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 208 | --desc_len; |
| 209 | if (desc_len > 0) |
| 210 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 211 | else |
| 212 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 213 | } |
| 214 | } |
| 215 | %extend lldb::SBFileSpec { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 216 | PyObject *lldb::SBFileSpec::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 217 | lldb::SBStream description; |
| 218 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 219 | const char *desc = description.GetData(); |
| 220 | size_t desc_len = description.GetSize(); |
| 221 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 222 | --desc_len; |
| 223 | if (desc_len > 0) |
| 224 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 225 | else |
| 226 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 227 | } |
| 228 | } |
| 229 | %extend lldb::SBFrame { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 230 | PyObject *lldb::SBFrame::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 231 | lldb::SBStream description; |
| 232 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 233 | const char *desc = description.GetData(); |
| 234 | size_t desc_len = description.GetSize(); |
| 235 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 236 | --desc_len; |
| 237 | if (desc_len > 0) |
| 238 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 239 | else |
| 240 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 241 | } |
| 242 | } |
| 243 | %extend lldb::SBFunction { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 244 | PyObject *lldb::SBFunction::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 245 | lldb::SBStream description; |
| 246 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 247 | const char *desc = description.GetData(); |
| 248 | size_t desc_len = description.GetSize(); |
| 249 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 250 | --desc_len; |
| 251 | if (desc_len > 0) |
| 252 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 253 | else |
| 254 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 255 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 256 | |
| 257 | %pythoncode %{ |
| 258 | def __eq__(self, rhs): |
| 259 | if not isinstance(rhs, type(self)): |
| 260 | return False |
| 261 | |
| 262 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 263 | |
| 264 | def __ne__(self, rhs): |
| 265 | if not isinstance(rhs, type(self)): |
| 266 | return True |
| 267 | |
| 268 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 269 | %} |
| 270 | |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 271 | } |
Greg Clayton | 1d27316 | 2010-10-06 03:09:58 +0000 | [diff] [blame] | 272 | %extend lldb::SBInstruction { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 273 | PyObject *lldb::SBInstruction::__str__ (){ |
Greg Clayton | 1d27316 | 2010-10-06 03:09:58 +0000 | [diff] [blame] | 274 | lldb::SBStream description; |
| 275 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 276 | const char *desc = description.GetData(); |
| 277 | size_t desc_len = description.GetSize(); |
| 278 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 279 | --desc_len; |
| 280 | if (desc_len > 0) |
| 281 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 282 | else |
| 283 | return PyString_FromString(""); |
Greg Clayton | 1d27316 | 2010-10-06 03:09:58 +0000 | [diff] [blame] | 284 | } |
| 285 | } |
| 286 | %extend lldb::SBInstructionList { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 287 | PyObject *lldb::SBInstructionList::__str__ (){ |
Greg Clayton | 1d27316 | 2010-10-06 03:09:58 +0000 | [diff] [blame] | 288 | lldb::SBStream description; |
| 289 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 290 | const char *desc = description.GetData(); |
| 291 | size_t desc_len = description.GetSize(); |
| 292 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 293 | --desc_len; |
| 294 | if (desc_len > 0) |
| 295 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 296 | else |
| 297 | return PyString_FromString(""); |
Greg Clayton | 1d27316 | 2010-10-06 03:09:58 +0000 | [diff] [blame] | 298 | } |
| 299 | } |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 300 | %extend lldb::SBLineEntry { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 301 | PyObject *lldb::SBLineEntry::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 302 | lldb::SBStream description; |
| 303 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 304 | const char *desc = description.GetData(); |
| 305 | size_t desc_len = description.GetSize(); |
| 306 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 307 | --desc_len; |
| 308 | if (desc_len > 0) |
| 309 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 310 | else |
| 311 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 312 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 313 | |
| 314 | %pythoncode %{ |
| 315 | def __eq__(self, rhs): |
| 316 | if not isinstance(rhs, type(self)): |
| 317 | return False |
| 318 | |
| 319 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 320 | |
| 321 | def __ne__(self, rhs): |
| 322 | if not isinstance(rhs, type(self)): |
| 323 | return True |
| 324 | |
| 325 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 326 | %} |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 327 | } |
| 328 | %extend lldb::SBModule { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 329 | PyObject *lldb::SBModule::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 330 | lldb::SBStream description; |
| 331 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 332 | const char *desc = description.GetData(); |
| 333 | size_t desc_len = description.GetSize(); |
| 334 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 335 | --desc_len; |
| 336 | if (desc_len > 0) |
| 337 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 338 | else |
| 339 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 340 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 341 | |
| 342 | %pythoncode %{ |
| 343 | def __eq__(self, rhs): |
| 344 | if not isinstance(rhs, type(self)): |
| 345 | return False |
| 346 | |
| 347 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 348 | |
| 349 | def __ne__(self, rhs): |
| 350 | if not isinstance(rhs, type(self)): |
| 351 | return True |
| 352 | |
| 353 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 354 | %} |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 355 | } |
Greg Clayton | 226cce2 | 2013-07-08 22:22:41 +0000 | [diff] [blame] | 356 | |
| 357 | %extend lldb::SBModuleSpec { |
| 358 | PyObject *lldb::SBModuleSpec::__str__ (){ |
| 359 | lldb::SBStream description; |
| 360 | $self->GetDescription (description); |
| 361 | const char *desc = description.GetData(); |
| 362 | size_t desc_len = description.GetSize(); |
| 363 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 364 | --desc_len; |
| 365 | if (desc_len > 0) |
| 366 | return PyString_FromStringAndSize (desc, desc_len); |
| 367 | else |
| 368 | return PyString_FromString(""); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | %extend lldb::SBModuleSpecList { |
| 373 | PyObject *lldb::SBModuleSpecList::__str__ (){ |
| 374 | lldb::SBStream description; |
| 375 | $self->GetDescription (description); |
| 376 | const char *desc = description.GetData(); |
| 377 | size_t desc_len = description.GetSize(); |
| 378 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 379 | --desc_len; |
| 380 | if (desc_len > 0) |
| 381 | return PyString_FromStringAndSize (desc, desc_len); |
| 382 | else |
| 383 | return PyString_FromString(""); |
| 384 | } |
| 385 | } |
| 386 | |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 387 | %extend lldb::SBProcess { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 388 | PyObject *lldb::SBProcess::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 389 | lldb::SBStream description; |
| 390 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 391 | const char *desc = description.GetData(); |
| 392 | size_t desc_len = description.GetSize(); |
| 393 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 394 | --desc_len; |
| 395 | if (desc_len > 0) |
| 396 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 397 | else |
| 398 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 399 | } |
| 400 | } |
Greg Clayton | d9dc52d | 2011-09-24 05:04:40 +0000 | [diff] [blame] | 401 | %extend lldb::SBSection { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 402 | PyObject *lldb::SBSection::__str__ (){ |
Greg Clayton | d9dc52d | 2011-09-24 05:04:40 +0000 | [diff] [blame] | 403 | lldb::SBStream description; |
| 404 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 405 | const char *desc = description.GetData(); |
| 406 | size_t desc_len = description.GetSize(); |
| 407 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 408 | --desc_len; |
| 409 | if (desc_len > 0) |
| 410 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 411 | else |
| 412 | return PyString_FromString(""); |
Greg Clayton | d9dc52d | 2011-09-24 05:04:40 +0000 | [diff] [blame] | 413 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 414 | |
| 415 | %pythoncode %{ |
| 416 | def __eq__(self, rhs): |
| 417 | if not isinstance(rhs, type(self)): |
| 418 | return False |
| 419 | |
| 420 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 421 | |
| 422 | def __ne__(self, rhs): |
| 423 | if not isinstance(rhs, type(self)): |
| 424 | return True |
| 425 | |
| 426 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 427 | %} |
Greg Clayton | d9dc52d | 2011-09-24 05:04:40 +0000 | [diff] [blame] | 428 | } |
Enrico Granata | ceba071 | 2013-03-25 17:37:39 +0000 | [diff] [blame] | 429 | %extend lldb::SBStream { |
| 430 | /* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage |
| 431 | they are meant to make an SBStream into a file-like object so that instructions of the sort |
| 432 | print >>sb_stream, "something" |
| 433 | will work correctly */ |
| 434 | |
| 435 | void lldb::SBStream::write (const char* str) |
| 436 | { |
| 437 | if (str) |
| 438 | $self->Printf("%s",str); |
| 439 | } |
| 440 | void lldb::SBStream::flush () |
| 441 | {} |
| 442 | } |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 443 | %extend lldb::SBSymbol { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 444 | PyObject *lldb::SBSymbol::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 445 | lldb::SBStream description; |
| 446 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 447 | const char *desc = description.GetData(); |
| 448 | size_t desc_len = description.GetSize(); |
| 449 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 450 | --desc_len; |
| 451 | if (desc_len > 0) |
| 452 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 453 | else |
| 454 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 455 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 456 | %pythoncode %{ |
| 457 | def __eq__(self, rhs): |
| 458 | if not isinstance(rhs, type(self)): |
| 459 | return False |
| 460 | |
| 461 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 462 | |
| 463 | def __ne__(self, rhs): |
| 464 | if not isinstance(rhs, type(self)): |
| 465 | return True |
| 466 | |
| 467 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 468 | %} |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 469 | } |
| 470 | %extend lldb::SBSymbolContext { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 471 | PyObject *lldb::SBSymbolContext::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 472 | lldb::SBStream description; |
| 473 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 474 | const char *desc = description.GetData(); |
| 475 | size_t desc_len = description.GetSize(); |
| 476 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 477 | --desc_len; |
| 478 | if (desc_len > 0) |
| 479 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 480 | else |
| 481 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 482 | } |
| 483 | } |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 484 | %extend lldb::SBSymbolContextList { |
| 485 | PyObject *lldb::SBSymbolContextList::__str__ (){ |
| 486 | lldb::SBStream description; |
| 487 | $self->GetDescription (description); |
| 488 | const char *desc = description.GetData(); |
| 489 | size_t desc_len = description.GetSize(); |
| 490 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 491 | --desc_len; |
| 492 | if (desc_len > 0) |
| 493 | return PyString_FromStringAndSize (desc, desc_len); |
| 494 | else |
| 495 | return PyString_FromString(""); |
| 496 | } |
| 497 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 498 | |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 499 | %extend lldb::SBTarget { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 500 | PyObject *lldb::SBTarget::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 501 | lldb::SBStream description; |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 502 | $self->GetDescription (description, lldb::eDescriptionLevelBrief); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 503 | const char *desc = description.GetData(); |
| 504 | size_t desc_len = description.GetSize(); |
| 505 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 506 | --desc_len; |
| 507 | if (desc_len > 0) |
| 508 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 509 | else |
| 510 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 511 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 512 | |
| 513 | %pythoncode %{ |
| 514 | def __eq__(self, rhs): |
| 515 | if not isinstance(rhs, type(self)): |
| 516 | return False |
| 517 | |
| 518 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 519 | |
| 520 | def __ne__(self, rhs): |
| 521 | if not isinstance(rhs, type(self)): |
| 522 | return True |
| 523 | |
| 524 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 525 | %} |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 526 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 527 | |
Greg Clayton | da7bc7d | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 528 | %extend lldb::SBType { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 529 | PyObject *lldb::SBType::__str__ (){ |
Greg Clayton | da7bc7d | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 530 | lldb::SBStream description; |
| 531 | $self->GetDescription (description, lldb::eDescriptionLevelBrief); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 532 | const char *desc = description.GetData(); |
| 533 | size_t desc_len = description.GetSize(); |
| 534 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 535 | --desc_len; |
| 536 | if (desc_len > 0) |
| 537 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 538 | else |
| 539 | return PyString_FromString(""); |
Greg Clayton | da7bc7d | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 540 | } |
| 541 | } |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 542 | %extend lldb::SBTypeCategory { |
| 543 | PyObject *lldb::SBTypeCategory::__str__ (){ |
| 544 | lldb::SBStream description; |
| 545 | $self->GetDescription (description, lldb::eDescriptionLevelBrief); |
| 546 | const char *desc = description.GetData(); |
| 547 | size_t desc_len = description.GetSize(); |
| 548 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 549 | --desc_len; |
| 550 | if (desc_len > 0) |
| 551 | return PyString_FromStringAndSize (desc, desc_len); |
| 552 | else |
| 553 | return PyString_FromString(""); |
| 554 | } |
| 555 | } |
| 556 | %extend lldb::SBTypeFilter { |
| 557 | PyObject *lldb::SBTypeFilter::__str__ (){ |
| 558 | lldb::SBStream description; |
| 559 | $self->GetDescription (description, lldb::eDescriptionLevelBrief); |
| 560 | const char *desc = description.GetData(); |
| 561 | size_t desc_len = description.GetSize(); |
| 562 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 563 | --desc_len; |
| 564 | if (desc_len > 0) |
| 565 | return PyString_FromStringAndSize (desc, desc_len); |
| 566 | else |
| 567 | return PyString_FromString(""); |
| 568 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 569 | %pythoncode %{ |
| 570 | def __eq__(self, rhs): |
| 571 | if not isinstance(rhs, type(self)): |
| 572 | return False |
| 573 | |
| 574 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 575 | |
| 576 | def __ne__(self, rhs): |
| 577 | if not isinstance(rhs, type(self)): |
| 578 | return True |
| 579 | |
| 580 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 581 | %} |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 582 | } |
| 583 | %extend lldb::SBTypeFormat { |
| 584 | PyObject *lldb::SBTypeFormat::__str__ (){ |
| 585 | lldb::SBStream description; |
| 586 | $self->GetDescription (description, lldb::eDescriptionLevelBrief); |
| 587 | const char *desc = description.GetData(); |
| 588 | size_t desc_len = description.GetSize(); |
| 589 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 590 | --desc_len; |
| 591 | if (desc_len > 0) |
| 592 | return PyString_FromStringAndSize (desc, desc_len); |
| 593 | else |
| 594 | return PyString_FromString(""); |
| 595 | } |
| 596 | } |
Greg Clayton | da7bc7d | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 597 | %extend lldb::SBTypeMember { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 598 | PyObject *lldb::SBTypeMember::__str__ (){ |
Greg Clayton | da7bc7d | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 599 | lldb::SBStream description; |
| 600 | $self->GetDescription (description, lldb::eDescriptionLevelBrief); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 601 | const char *desc = description.GetData(); |
| 602 | size_t desc_len = description.GetSize(); |
| 603 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 604 | --desc_len; |
| 605 | if (desc_len > 0) |
| 606 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 607 | else |
| 608 | return PyString_FromString(""); |
Greg Clayton | da7bc7d | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 609 | } |
| 610 | } |
Todd Fiala | 732215f | 2014-06-02 20:55:29 +0000 | [diff] [blame] | 611 | %extend lldb::SBTypeEnumMember { |
| 612 | PyObject *lldb::SBTypeEnumMember::__str__ (){ |
| 613 | lldb::SBStream description; |
| 614 | $self->GetDescription (description, lldb::eDescriptionLevelBrief); |
| 615 | const char *desc = description.GetData(); |
| 616 | size_t desc_len = description.GetSize(); |
| 617 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 618 | --desc_len; |
| 619 | if (desc_len > 0) |
| 620 | return PyString_FromStringAndSize (desc, desc_len); |
| 621 | else |
| 622 | return PyString_FromString(""); |
| 623 | } |
| 624 | } |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 625 | %extend lldb::SBTypeNameSpecifier { |
| 626 | PyObject *lldb::SBTypeNameSpecifier::__str__ (){ |
| 627 | lldb::SBStream description; |
| 628 | $self->GetDescription (description, lldb::eDescriptionLevelBrief); |
| 629 | const char *desc = description.GetData(); |
| 630 | size_t desc_len = description.GetSize(); |
| 631 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 632 | --desc_len; |
| 633 | if (desc_len > 0) |
| 634 | return PyString_FromStringAndSize (desc, desc_len); |
| 635 | else |
| 636 | return PyString_FromString(""); |
| 637 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 638 | %pythoncode %{ |
| 639 | def __eq__(self, rhs): |
| 640 | if not isinstance(rhs, type(self)): |
| 641 | return False |
| 642 | |
| 643 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 644 | |
| 645 | def __ne__(self, rhs): |
| 646 | if not isinstance(rhs, type(self)): |
| 647 | return True |
| 648 | |
| 649 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 650 | %} |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 651 | } |
| 652 | %extend lldb::SBTypeSummary { |
| 653 | PyObject *lldb::SBTypeSummary::__str__ (){ |
| 654 | lldb::SBStream description; |
| 655 | $self->GetDescription (description, lldb::eDescriptionLevelBrief); |
| 656 | const char *desc = description.GetData(); |
| 657 | size_t desc_len = description.GetSize(); |
| 658 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 659 | --desc_len; |
| 660 | if (desc_len > 0) |
| 661 | return PyString_FromStringAndSize (desc, desc_len); |
| 662 | else |
| 663 | return PyString_FromString(""); |
| 664 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 665 | %pythoncode %{ |
| 666 | def __eq__(self, rhs): |
| 667 | if not isinstance(rhs, type(self)): |
| 668 | return False |
| 669 | |
| 670 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 671 | |
| 672 | def __ne__(self, rhs): |
| 673 | if not isinstance(rhs, type(self)): |
| 674 | return True |
| 675 | |
| 676 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 677 | %} |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 678 | } |
| 679 | %extend lldb::SBTypeSynthetic { |
| 680 | PyObject *lldb::SBTypeSynthetic::__str__ (){ |
| 681 | lldb::SBStream description; |
| 682 | $self->GetDescription (description, lldb::eDescriptionLevelBrief); |
| 683 | const char *desc = description.GetData(); |
| 684 | size_t desc_len = description.GetSize(); |
| 685 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 686 | --desc_len; |
| 687 | if (desc_len > 0) |
| 688 | return PyString_FromStringAndSize (desc, desc_len); |
| 689 | else |
| 690 | return PyString_FromString(""); |
| 691 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 692 | %pythoncode %{ |
| 693 | def __eq__(self, rhs): |
| 694 | if not isinstance(rhs, type(self)): |
| 695 | return False |
| 696 | |
| 697 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 698 | |
| 699 | def __ne__(self, rhs): |
| 700 | if not isinstance(rhs, type(self)): |
| 701 | return True |
| 702 | |
| 703 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 704 | %} |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 705 | } |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 706 | %extend lldb::SBThread { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 707 | PyObject *lldb::SBThread::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 708 | lldb::SBStream description; |
| 709 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 710 | const char *desc = description.GetData(); |
| 711 | size_t desc_len = description.GetSize(); |
| 712 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 713 | --desc_len; |
| 714 | if (desc_len > 0) |
| 715 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 716 | else |
| 717 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 718 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 719 | %pythoncode %{ |
| 720 | def __eq__(self, rhs): |
| 721 | if not isinstance(rhs, type(self)): |
| 722 | return False |
| 723 | |
| 724 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 725 | |
| 726 | def __ne__(self, rhs): |
| 727 | if not isinstance(rhs, type(self)): |
| 728 | return True |
| 729 | |
| 730 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 731 | %} |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 732 | } |
| 733 | %extend lldb::SBValue { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 734 | PyObject *lldb::SBValue::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 735 | lldb::SBStream description; |
| 736 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 737 | const char *desc = description.GetData(); |
| 738 | size_t desc_len = description.GetSize(); |
| 739 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 740 | --desc_len; |
| 741 | if (desc_len > 0) |
| 742 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 743 | else |
| 744 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 745 | } |
| 746 | } |
Greg Clayton | 7edbdfc | 2012-02-03 07:02:37 +0000 | [diff] [blame] | 747 | %extend lldb::SBValueList { |
Greg Clayton | dda8c7d | 2013-04-11 22:24:25 +0000 | [diff] [blame] | 748 | PyObject *lldb::SBValueList::__str__ (){ |
Greg Clayton | 7edbdfc | 2012-02-03 07:02:37 +0000 | [diff] [blame] | 749 | lldb::SBStream description; |
| 750 | const size_t n = $self->GetSize(); |
| 751 | if (n) |
| 752 | { |
| 753 | for (size_t i=0; i<n; ++i) |
| 754 | $self->GetValueAtIndex(i).GetDescription(description); |
| 755 | } |
| 756 | else |
| 757 | { |
| 758 | description.Printf("<empty> lldb.SBValueList()"); |
| 759 | } |
| 760 | const char *desc = description.GetData(); |
| 761 | size_t desc_len = description.GetSize(); |
| 762 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 763 | --desc_len; |
| 764 | if (desc_len > 0) |
| 765 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | dda8c7d | 2013-04-11 22:24:25 +0000 | [diff] [blame] | 766 | else |
| 767 | return PyString_FromString(""); |
Greg Clayton | 7edbdfc | 2012-02-03 07:02:37 +0000 | [diff] [blame] | 768 | } |
| 769 | } |
Greg Clayton | 1b282f9 | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 770 | %extend lldb::SBWatchpoint { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 771 | PyObject *lldb::SBWatchpoint::__str__ (){ |
Johnny Chen | d4dd799 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 772 | lldb::SBStream description; |
| 773 | $self->GetDescription (description, lldb::eDescriptionLevelVerbose); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 774 | const char *desc = description.GetData(); |
| 775 | size_t desc_len = description.GetSize(); |
| 776 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 777 | --desc_len; |
| 778 | if (desc_len > 0) |
| 779 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 780 | else |
| 781 | return PyString_FromString(""); |
Johnny Chen | d4dd799 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 782 | } |
| 783 | } |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 784 | |
Filipe Cabecinhas | c504191 | 2012-08-25 00:29:07 +0000 | [diff] [blame] | 785 | |
| 786 | // %extend lldb::SBDebugger { |
| 787 | // // FIXME: We can't get the callback and baton |
| 788 | // PyObject *lldb::SBDebugger (){ |
| 789 | // // Only call Py_XDECREF if we have a Python object (or NULL) |
| 790 | // if (LLDBSwigPythonCallPythonLogOutputCallback == $self->GetLogOutPutCallback()) |
| 791 | // Py_XDECREF($self->GetCallbackBaton()); |
| 792 | // } |
| 793 | // } |
Filipe Cabecinhas | 6eb31e7 | 2012-08-22 13:25:10 +0000 | [diff] [blame] | 794 | |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 795 | %pythoncode %{ |
| 796 | |
Greg Clayton | 88e0f61 | 2013-06-19 01:38:02 +0000 | [diff] [blame] | 797 | def command(*args, **kwargs): |
Greg Clayton | d8c3d4b | 2013-06-19 21:50:28 +0000 | [diff] [blame] | 798 | import lldb |
Greg Clayton | 88e0f61 | 2013-06-19 01:38:02 +0000 | [diff] [blame] | 799 | """A decorator function that registers an LLDB command line |
| 800 | command that is bound to the function it is attached to.""" |
| 801 | class obj(object): |
| 802 | """The object that tracks adding the command to LLDB one time and handles |
| 803 | calling the function on subsequent calls.""" |
| 804 | def __init__(self, function, command_name, doc = None): |
| 805 | if doc: |
| 806 | function.__doc__ = doc |
| 807 | command = "command script add -f %s.%s %s" % (function.__module__, function.__name__, command_name) |
Greg Clayton | d8c3d4b | 2013-06-19 21:50:28 +0000 | [diff] [blame] | 808 | lldb.debugger.HandleCommand(command) |
Greg Clayton | 88e0f61 | 2013-06-19 01:38:02 +0000 | [diff] [blame] | 809 | self.function = function |
| 810 | def __call__(self, *args, **kwargs): |
| 811 | self.function(*args, **kwargs) |
| 812 | def callable(function): |
| 813 | """Creates a callable object that gets used.""" |
| 814 | return obj(function, *args, **kwargs) |
| 815 | return callable |
| 816 | |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 817 | class declaration(object): |
| 818 | '''A class that represents a source declaration location with file, line and column.''' |
| 819 | def __init__(self, file, line, col): |
| 820 | self.file = file |
| 821 | self.line = line |
| 822 | self.col = col |
| 823 | |
Enrico Granata | ac9df2d | 2013-03-25 18:53:07 +0000 | [diff] [blame] | 824 | class value_iter(object): |
| 825 | def __iter__(self): |
| 826 | return self |
| 827 | |
| 828 | def next(self): |
| 829 | if self.index >= self.length: |
| 830 | raise StopIteration() |
| 831 | child_sbvalue = self.sbvalue.GetChildAtIndex(self.index) |
| 832 | self.index += 1 |
| 833 | return value(child_sbvalue) |
| 834 | |
| 835 | def __init__(self,value): |
| 836 | self.index = 0 |
| 837 | self.sbvalue = value |
| 838 | if type(self.sbvalue) is value: |
| 839 | self.sbvalue = self.sbvalue.sbvalue |
| 840 | self.length = self.sbvalue.GetNumChildren() |
| 841 | |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 842 | class value(object): |
| 843 | '''A class designed to wrap lldb.SBValue() objects so the resulting object |
| 844 | can be used as a variable would be in code. So if you have a Point structure |
| 845 | variable in your code in the current frame named "pt", you can initialize an instance |
| 846 | of this class with it: |
| 847 | |
| 848 | pt = lldb.value(lldb.frame.FindVariable("pt")) |
| 849 | print pt |
| 850 | print pt.x |
| 851 | print pt.y |
| 852 | |
| 853 | pt = lldb.value(lldb.frame.FindVariable("rectangle_array")) |
| 854 | print rectangle_array[12] |
| 855 | print rectangle_array[5].origin.x''' |
| 856 | def __init__(self, sbvalue): |
| 857 | self.sbvalue = sbvalue |
| 858 | |
| 859 | def __nonzero__(self): |
| 860 | return self.sbvalue.__nonzero__() |
| 861 | |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 862 | def __str__(self): |
| 863 | return self.sbvalue.__str__() |
| 864 | |
| 865 | def __getitem__(self, key): |
| 866 | # Allow array access if this value has children... |
Enrico Granata | 944b4c4 | 2012-10-08 17:32:55 +0000 | [diff] [blame] | 867 | if type(key) is value: |
Enrico Granata | ac9df2d | 2013-03-25 18:53:07 +0000 | [diff] [blame] | 868 | key = int(key) |
| 869 | if type(key) is int: |
| 870 | child_sbvalue = (self.sbvalue.GetValueForExpressionPath("[%i]" % key)) |
| 871 | if child_sbvalue and child_sbvalue.IsValid(): |
| 872 | return value(child_sbvalue) |
| 873 | raise IndexError("Index '%d' is out of range" % key) |
Enrico Granata | 944b4c4 | 2012-10-08 17:32:55 +0000 | [diff] [blame] | 874 | raise TypeError("No array item of type %s" % str(type(key))) |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 875 | |
Enrico Granata | ac9df2d | 2013-03-25 18:53:07 +0000 | [diff] [blame] | 876 | def __iter__(self): |
| 877 | return value_iter(self.sbvalue) |
| 878 | |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 879 | def __getattr__(self, name): |
| 880 | child_sbvalue = self.sbvalue.GetChildMemberWithName (name) |
Enrico Granata | ac9df2d | 2013-03-25 18:53:07 +0000 | [diff] [blame] | 881 | if child_sbvalue and child_sbvalue.IsValid(): |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 882 | return value(child_sbvalue) |
Enrico Granata | 944b4c4 | 2012-10-08 17:32:55 +0000 | [diff] [blame] | 883 | raise AttributeError("Attribute '%s' is not defined" % name) |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 884 | |
| 885 | def __add__(self, other): |
| 886 | return int(self) + int(other) |
| 887 | |
| 888 | def __sub__(self, other): |
| 889 | return int(self) - int(other) |
| 890 | |
| 891 | def __mul__(self, other): |
| 892 | return int(self) * int(other) |
| 893 | |
| 894 | def __floordiv__(self, other): |
| 895 | return int(self) // int(other) |
| 896 | |
| 897 | def __mod__(self, other): |
| 898 | return int(self) % int(other) |
| 899 | |
| 900 | def __divmod__(self, other): |
| 901 | return int(self) % int(other) |
| 902 | |
| 903 | def __pow__(self, other): |
| 904 | return int(self) ** int(other) |
| 905 | |
| 906 | def __lshift__(self, other): |
| 907 | return int(self) << int(other) |
| 908 | |
| 909 | def __rshift__(self, other): |
| 910 | return int(self) >> int(other) |
| 911 | |
| 912 | def __and__(self, other): |
| 913 | return int(self) & int(other) |
| 914 | |
| 915 | def __xor__(self, other): |
| 916 | return int(self) ^ int(other) |
| 917 | |
| 918 | def __or__(self, other): |
| 919 | return int(self) | int(other) |
| 920 | |
| 921 | def __div__(self, other): |
| 922 | return int(self) / int(other) |
| 923 | |
| 924 | def __truediv__(self, other): |
| 925 | return int(self) / int(other) |
| 926 | |
| 927 | def __iadd__(self, other): |
| 928 | result = self.__add__(other) |
| 929 | self.sbvalue.SetValueFromCString (str(result)) |
| 930 | return result |
| 931 | |
| 932 | def __isub__(self, other): |
| 933 | result = self.__sub__(other) |
| 934 | self.sbvalue.SetValueFromCString (str(result)) |
| 935 | return result |
| 936 | |
| 937 | def __imul__(self, other): |
| 938 | result = self.__mul__(other) |
| 939 | self.sbvalue.SetValueFromCString (str(result)) |
| 940 | return result |
| 941 | |
| 942 | def __idiv__(self, other): |
| 943 | result = self.__div__(other) |
| 944 | self.sbvalue.SetValueFromCString (str(result)) |
| 945 | return result |
| 946 | |
| 947 | def __itruediv__(self, other): |
| 948 | result = self.__truediv__(other) |
| 949 | self.sbvalue.SetValueFromCString (str(result)) |
| 950 | return result |
| 951 | |
| 952 | def __ifloordiv__(self, other): |
| 953 | result = self.__floordiv__(self, other) |
| 954 | self.sbvalue.SetValueFromCString (str(result)) |
| 955 | return result |
| 956 | |
| 957 | def __imod__(self, other): |
| 958 | result = self.__and__(self, other) |
| 959 | self.sbvalue.SetValueFromCString (str(result)) |
| 960 | return result |
| 961 | |
| 962 | def __ipow__(self, other): |
| 963 | result = self.__pow__(self, other) |
| 964 | self.sbvalue.SetValueFromCString (str(result)) |
| 965 | return result |
| 966 | |
| 967 | def __ipow__(self, other, modulo): |
| 968 | result = self.__pow__(self, other, modulo) |
| 969 | self.sbvalue.SetValueFromCString (str(result)) |
| 970 | return result |
| 971 | |
| 972 | def __ilshift__(self, other): |
| 973 | result = self.__lshift__(other) |
| 974 | self.sbvalue.SetValueFromCString (str(result)) |
| 975 | return result |
| 976 | |
| 977 | def __irshift__(self, other): |
| 978 | result = self.__rshift__(other) |
| 979 | self.sbvalue.SetValueFromCString (str(result)) |
| 980 | return result |
| 981 | |
| 982 | def __iand__(self, other): |
| 983 | result = self.__and__(self, other) |
| 984 | self.sbvalue.SetValueFromCString (str(result)) |
| 985 | return result |
| 986 | |
| 987 | def __ixor__(self, other): |
| 988 | result = self.__xor__(self, other) |
| 989 | self.sbvalue.SetValueFromCString (str(result)) |
| 990 | return result |
| 991 | |
| 992 | def __ior__(self, other): |
| 993 | result = self.__ior__(self, other) |
| 994 | self.sbvalue.SetValueFromCString (str(result)) |
| 995 | return result |
| 996 | |
| 997 | def __neg__(self): |
| 998 | return -int(self) |
| 999 | |
| 1000 | def __pos__(self): |
| 1001 | return +int(self) |
| 1002 | |
| 1003 | def __abs__(self): |
| 1004 | return abs(int(self)) |
| 1005 | |
| 1006 | def __invert__(self): |
| 1007 | return ~int(self) |
| 1008 | |
| 1009 | def __complex__(self): |
| 1010 | return complex (int(self)) |
| 1011 | |
| 1012 | def __int__(self): |
| 1013 | return self.sbvalue.GetValueAsSigned() |
| 1014 | |
| 1015 | def __long__(self): |
| 1016 | return self.sbvalue.GetValueAsSigned() |
| 1017 | |
| 1018 | def __float__(self): |
| 1019 | return float (self.sbvalue.GetValueAsSigned()) |
| 1020 | |
| 1021 | def __oct__(self): |
Greg Clayton | 43484c5 | 2012-02-02 00:12:47 +0000 | [diff] [blame] | 1022 | return '0%o' % self.sbvalue.GetValueAsUnsigned() |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 1023 | |
| 1024 | def __hex__(self): |
Greg Clayton | 43484c5 | 2012-02-02 00:12:47 +0000 | [diff] [blame] | 1025 | return '0x%x' % self.sbvalue.GetValueAsUnsigned() |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 1026 | |
Enrico Granata | ac9df2d | 2013-03-25 18:53:07 +0000 | [diff] [blame] | 1027 | def __len__(self): |
| 1028 | return self.sbvalue.GetNumChildren() |
| 1029 | |
Greg Clayton | 43484c5 | 2012-02-02 00:12:47 +0000 | [diff] [blame] | 1030 | def __eq__(self, other): |
Enrico Granata | 944b4c4 | 2012-10-08 17:32:55 +0000 | [diff] [blame] | 1031 | if type(other) is int: |
| 1032 | return int(self) == other |
| 1033 | elif type(other) is str: |
| 1034 | return str(self) == other |
| 1035 | elif type(other) is value: |
| 1036 | self_err = SBError() |
| 1037 | other_err = SBError() |
| 1038 | self_val = self.sbvalue.GetValueAsUnsigned(self_err) |
| 1039 | if self_err.fail: |
| 1040 | raise ValueError("unable to extract value of self") |
| 1041 | other_val = other.sbvalue.GetValueAsUnsigned(other_err) |
| 1042 | if other_err.fail: |
| 1043 | raise ValueError("unable to extract value of other") |
| 1044 | return self_val == other_val |
| 1045 | raise TypeError("Unknown type %s, No equality operation defined." % str(type(other))) |
| 1046 | |
Greg Clayton | 43484c5 | 2012-02-02 00:12:47 +0000 | [diff] [blame] | 1047 | def __neq__(self, other): |
| 1048 | return not self.__eq__(other) |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 1049 | %} |
Enrico Granata | 8387e2f | 2014-10-08 20:10:09 +0000 | [diff] [blame] | 1050 | |
| 1051 | %pythoncode %{ |
| 1052 | |
| 1053 | class SBSyntheticValueProvider(object): |
| 1054 | def __init__(self,valobj): |
| 1055 | pass |
| 1056 | |
| 1057 | def num_children(self): |
| 1058 | return 0 |
| 1059 | |
| 1060 | def get_child_index(self,name): |
| 1061 | return None |
| 1062 | |
| 1063 | def get_child_at_index(self,idx): |
| 1064 | return None |
| 1065 | |
| 1066 | def update(self): |
| 1067 | pass |
| 1068 | |
| 1069 | def has_children(self): |
| 1070 | return False |
| 1071 | |
| 1072 | |
| 1073 | %} |