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 | } |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 611 | %extend lldb::SBTypeNameSpecifier { |
| 612 | PyObject *lldb::SBTypeNameSpecifier::__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 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 624 | %pythoncode %{ |
| 625 | def __eq__(self, rhs): |
| 626 | if not isinstance(rhs, type(self)): |
| 627 | return False |
| 628 | |
| 629 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 630 | |
| 631 | def __ne__(self, rhs): |
| 632 | if not isinstance(rhs, type(self)): |
| 633 | return True |
| 634 | |
| 635 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 636 | %} |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 637 | } |
| 638 | %extend lldb::SBTypeSummary { |
| 639 | PyObject *lldb::SBTypeSummary::__str__ (){ |
| 640 | lldb::SBStream description; |
| 641 | $self->GetDescription (description, lldb::eDescriptionLevelBrief); |
| 642 | const char *desc = description.GetData(); |
| 643 | size_t desc_len = description.GetSize(); |
| 644 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 645 | --desc_len; |
| 646 | if (desc_len > 0) |
| 647 | return PyString_FromStringAndSize (desc, desc_len); |
| 648 | else |
| 649 | return PyString_FromString(""); |
| 650 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 651 | %pythoncode %{ |
| 652 | def __eq__(self, rhs): |
| 653 | if not isinstance(rhs, type(self)): |
| 654 | return False |
| 655 | |
| 656 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 657 | |
| 658 | def __ne__(self, rhs): |
| 659 | if not isinstance(rhs, type(self)): |
| 660 | return True |
| 661 | |
| 662 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 663 | %} |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 664 | } |
| 665 | %extend lldb::SBTypeSynthetic { |
| 666 | PyObject *lldb::SBTypeSynthetic::__str__ (){ |
| 667 | lldb::SBStream description; |
| 668 | $self->GetDescription (description, lldb::eDescriptionLevelBrief); |
| 669 | const char *desc = description.GetData(); |
| 670 | size_t desc_len = description.GetSize(); |
| 671 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 672 | --desc_len; |
| 673 | if (desc_len > 0) |
| 674 | return PyString_FromStringAndSize (desc, desc_len); |
| 675 | else |
| 676 | return PyString_FromString(""); |
| 677 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 678 | %pythoncode %{ |
| 679 | def __eq__(self, rhs): |
| 680 | if not isinstance(rhs, type(self)): |
| 681 | return False |
| 682 | |
| 683 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 684 | |
| 685 | def __ne__(self, rhs): |
| 686 | if not isinstance(rhs, type(self)): |
| 687 | return True |
| 688 | |
| 689 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 690 | %} |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 691 | } |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 692 | %extend lldb::SBThread { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 693 | PyObject *lldb::SBThread::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 694 | lldb::SBStream description; |
| 695 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 696 | const char *desc = description.GetData(); |
| 697 | size_t desc_len = description.GetSize(); |
| 698 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 699 | --desc_len; |
| 700 | if (desc_len > 0) |
| 701 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 702 | else |
| 703 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 704 | } |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 705 | %pythoncode %{ |
| 706 | def __eq__(self, rhs): |
| 707 | if not isinstance(rhs, type(self)): |
| 708 | return False |
| 709 | |
| 710 | return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs) |
| 711 | |
| 712 | def __ne__(self, rhs): |
| 713 | if not isinstance(rhs, type(self)): |
| 714 | return True |
| 715 | |
| 716 | return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs) |
| 717 | %} |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 718 | } |
| 719 | %extend lldb::SBValue { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 720 | PyObject *lldb::SBValue::__str__ (){ |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 721 | lldb::SBStream description; |
| 722 | $self->GetDescription (description); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 723 | const char *desc = description.GetData(); |
| 724 | size_t desc_len = description.GetSize(); |
| 725 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 726 | --desc_len; |
| 727 | if (desc_len > 0) |
| 728 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 729 | else |
| 730 | return PyString_FromString(""); |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 731 | } |
| 732 | } |
Greg Clayton | 7edbdfc | 2012-02-03 07:02:37 +0000 | [diff] [blame] | 733 | %extend lldb::SBValueList { |
Greg Clayton | dda8c7d | 2013-04-11 22:24:25 +0000 | [diff] [blame] | 734 | PyObject *lldb::SBValueList::__str__ (){ |
Greg Clayton | 7edbdfc | 2012-02-03 07:02:37 +0000 | [diff] [blame] | 735 | lldb::SBStream description; |
| 736 | const size_t n = $self->GetSize(); |
| 737 | if (n) |
| 738 | { |
| 739 | for (size_t i=0; i<n; ++i) |
| 740 | $self->GetValueAtIndex(i).GetDescription(description); |
| 741 | } |
| 742 | else |
| 743 | { |
| 744 | description.Printf("<empty> lldb.SBValueList()"); |
| 745 | } |
| 746 | const char *desc = description.GetData(); |
| 747 | size_t desc_len = description.GetSize(); |
| 748 | if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) |
| 749 | --desc_len; |
| 750 | if (desc_len > 0) |
| 751 | return PyString_FromStringAndSize (desc, desc_len); |
Greg Clayton | dda8c7d | 2013-04-11 22:24:25 +0000 | [diff] [blame] | 752 | else |
| 753 | return PyString_FromString(""); |
Greg Clayton | 7edbdfc | 2012-02-03 07:02:37 +0000 | [diff] [blame] | 754 | } |
| 755 | } |
Greg Clayton | 1b282f9 | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 756 | %extend lldb::SBWatchpoint { |
Greg Clayton | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 757 | PyObject *lldb::SBWatchpoint::__str__ (){ |
Johnny Chen | d4dd799 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 758 | lldb::SBStream description; |
| 759 | $self->GetDescription (description, lldb::eDescriptionLevelVerbose); |
Greg Clayton | 2415586 | 2012-02-01 02:30:27 +0000 | [diff] [blame] | 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 | 81e871e | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 766 | else |
| 767 | return PyString_FromString(""); |
Johnny Chen | d4dd799 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 768 | } |
| 769 | } |
Caroline Tice | dac97f3 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 770 | |
Filipe Cabecinhas | c504191 | 2012-08-25 00:29:07 +0000 | [diff] [blame] | 771 | |
| 772 | // %extend lldb::SBDebugger { |
| 773 | // // FIXME: We can't get the callback and baton |
| 774 | // PyObject *lldb::SBDebugger (){ |
| 775 | // // Only call Py_XDECREF if we have a Python object (or NULL) |
| 776 | // if (LLDBSwigPythonCallPythonLogOutputCallback == $self->GetLogOutPutCallback()) |
| 777 | // Py_XDECREF($self->GetCallbackBaton()); |
| 778 | // } |
| 779 | // } |
Filipe Cabecinhas | 6eb31e7 | 2012-08-22 13:25:10 +0000 | [diff] [blame] | 780 | // %extend lldb::SBInputReader { |
| 781 | // // FIXME: m_callback_function is private and we have no other |
| 782 | // // way to access it. |
| 783 | // PyObject *lldb::SBInputReader::__del__ (){ |
| 784 | // // Only call Py_XDECREF if we have a Python object (or NULL) |
| 785 | // if (LLDBSwigPythonCallSBInputReaderCallback == $self->m_callback_function) |
| 786 | // Py_XDECREF($self->m_callback_baton); |
| 787 | // } |
| 788 | // } |
| 789 | |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 790 | %pythoncode %{ |
| 791 | |
Greg Clayton | 88e0f61 | 2013-06-19 01:38:02 +0000 | [diff] [blame] | 792 | def command(*args, **kwargs): |
Greg Clayton | d8c3d4b | 2013-06-19 21:50:28 +0000 | [diff] [blame] | 793 | import lldb |
Greg Clayton | 88e0f61 | 2013-06-19 01:38:02 +0000 | [diff] [blame] | 794 | """A decorator function that registers an LLDB command line |
| 795 | command that is bound to the function it is attached to.""" |
| 796 | class obj(object): |
| 797 | """The object that tracks adding the command to LLDB one time and handles |
| 798 | calling the function on subsequent calls.""" |
| 799 | def __init__(self, function, command_name, doc = None): |
| 800 | if doc: |
| 801 | function.__doc__ = doc |
| 802 | 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] | 803 | lldb.debugger.HandleCommand(command) |
Greg Clayton | 88e0f61 | 2013-06-19 01:38:02 +0000 | [diff] [blame] | 804 | self.function = function |
| 805 | def __call__(self, *args, **kwargs): |
| 806 | self.function(*args, **kwargs) |
| 807 | def callable(function): |
| 808 | """Creates a callable object that gets used.""" |
| 809 | return obj(function, *args, **kwargs) |
| 810 | return callable |
| 811 | |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 812 | class declaration(object): |
| 813 | '''A class that represents a source declaration location with file, line and column.''' |
| 814 | def __init__(self, file, line, col): |
| 815 | self.file = file |
| 816 | self.line = line |
| 817 | self.col = col |
| 818 | |
Enrico Granata | ac9df2d | 2013-03-25 18:53:07 +0000 | [diff] [blame] | 819 | class value_iter(object): |
| 820 | def __iter__(self): |
| 821 | return self |
| 822 | |
| 823 | def next(self): |
| 824 | if self.index >= self.length: |
| 825 | raise StopIteration() |
| 826 | child_sbvalue = self.sbvalue.GetChildAtIndex(self.index) |
| 827 | self.index += 1 |
| 828 | return value(child_sbvalue) |
| 829 | |
| 830 | def __init__(self,value): |
| 831 | self.index = 0 |
| 832 | self.sbvalue = value |
| 833 | if type(self.sbvalue) is value: |
| 834 | self.sbvalue = self.sbvalue.sbvalue |
| 835 | self.length = self.sbvalue.GetNumChildren() |
| 836 | |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 837 | class value(object): |
| 838 | '''A class designed to wrap lldb.SBValue() objects so the resulting object |
| 839 | can be used as a variable would be in code. So if you have a Point structure |
| 840 | variable in your code in the current frame named "pt", you can initialize an instance |
| 841 | of this class with it: |
| 842 | |
| 843 | pt = lldb.value(lldb.frame.FindVariable("pt")) |
| 844 | print pt |
| 845 | print pt.x |
| 846 | print pt.y |
| 847 | |
| 848 | pt = lldb.value(lldb.frame.FindVariable("rectangle_array")) |
| 849 | print rectangle_array[12] |
| 850 | print rectangle_array[5].origin.x''' |
| 851 | def __init__(self, sbvalue): |
| 852 | self.sbvalue = sbvalue |
| 853 | |
| 854 | def __nonzero__(self): |
| 855 | return self.sbvalue.__nonzero__() |
| 856 | |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 857 | def __str__(self): |
| 858 | return self.sbvalue.__str__() |
| 859 | |
| 860 | def __getitem__(self, key): |
| 861 | # Allow array access if this value has children... |
Enrico Granata | 944b4c4 | 2012-10-08 17:32:55 +0000 | [diff] [blame] | 862 | if type(key) is value: |
Enrico Granata | ac9df2d | 2013-03-25 18:53:07 +0000 | [diff] [blame] | 863 | key = int(key) |
| 864 | if type(key) is int: |
| 865 | child_sbvalue = (self.sbvalue.GetValueForExpressionPath("[%i]" % key)) |
| 866 | if child_sbvalue and child_sbvalue.IsValid(): |
| 867 | return value(child_sbvalue) |
| 868 | raise IndexError("Index '%d' is out of range" % key) |
Enrico Granata | 944b4c4 | 2012-10-08 17:32:55 +0000 | [diff] [blame] | 869 | raise TypeError("No array item of type %s" % str(type(key))) |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 870 | |
Enrico Granata | ac9df2d | 2013-03-25 18:53:07 +0000 | [diff] [blame] | 871 | def __iter__(self): |
| 872 | return value_iter(self.sbvalue) |
| 873 | |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 874 | def __getattr__(self, name): |
| 875 | child_sbvalue = self.sbvalue.GetChildMemberWithName (name) |
Enrico Granata | ac9df2d | 2013-03-25 18:53:07 +0000 | [diff] [blame] | 876 | if child_sbvalue and child_sbvalue.IsValid(): |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 877 | return value(child_sbvalue) |
Enrico Granata | 944b4c4 | 2012-10-08 17:32:55 +0000 | [diff] [blame] | 878 | raise AttributeError("Attribute '%s' is not defined" % name) |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 879 | |
| 880 | def __add__(self, other): |
| 881 | return int(self) + int(other) |
| 882 | |
| 883 | def __sub__(self, other): |
| 884 | return int(self) - int(other) |
| 885 | |
| 886 | def __mul__(self, other): |
| 887 | return int(self) * int(other) |
| 888 | |
| 889 | def __floordiv__(self, other): |
| 890 | return int(self) // int(other) |
| 891 | |
| 892 | def __mod__(self, other): |
| 893 | return int(self) % int(other) |
| 894 | |
| 895 | def __divmod__(self, other): |
| 896 | return int(self) % int(other) |
| 897 | |
| 898 | def __pow__(self, other): |
| 899 | return int(self) ** int(other) |
| 900 | |
| 901 | def __lshift__(self, other): |
| 902 | return int(self) << int(other) |
| 903 | |
| 904 | def __rshift__(self, other): |
| 905 | return int(self) >> int(other) |
| 906 | |
| 907 | def __and__(self, other): |
| 908 | return int(self) & int(other) |
| 909 | |
| 910 | def __xor__(self, other): |
| 911 | return int(self) ^ int(other) |
| 912 | |
| 913 | def __or__(self, other): |
| 914 | return int(self) | int(other) |
| 915 | |
| 916 | def __div__(self, other): |
| 917 | return int(self) / int(other) |
| 918 | |
| 919 | def __truediv__(self, other): |
| 920 | return int(self) / int(other) |
| 921 | |
| 922 | def __iadd__(self, other): |
| 923 | result = self.__add__(other) |
| 924 | self.sbvalue.SetValueFromCString (str(result)) |
| 925 | return result |
| 926 | |
| 927 | def __isub__(self, other): |
| 928 | result = self.__sub__(other) |
| 929 | self.sbvalue.SetValueFromCString (str(result)) |
| 930 | return result |
| 931 | |
| 932 | def __imul__(self, other): |
| 933 | result = self.__mul__(other) |
| 934 | self.sbvalue.SetValueFromCString (str(result)) |
| 935 | return result |
| 936 | |
| 937 | def __idiv__(self, other): |
| 938 | result = self.__div__(other) |
| 939 | self.sbvalue.SetValueFromCString (str(result)) |
| 940 | return result |
| 941 | |
| 942 | def __itruediv__(self, other): |
| 943 | result = self.__truediv__(other) |
| 944 | self.sbvalue.SetValueFromCString (str(result)) |
| 945 | return result |
| 946 | |
| 947 | def __ifloordiv__(self, other): |
| 948 | result = self.__floordiv__(self, other) |
| 949 | self.sbvalue.SetValueFromCString (str(result)) |
| 950 | return result |
| 951 | |
| 952 | def __imod__(self, other): |
| 953 | result = self.__and__(self, other) |
| 954 | self.sbvalue.SetValueFromCString (str(result)) |
| 955 | return result |
| 956 | |
| 957 | def __ipow__(self, other): |
| 958 | result = self.__pow__(self, other) |
| 959 | self.sbvalue.SetValueFromCString (str(result)) |
| 960 | return result |
| 961 | |
| 962 | def __ipow__(self, other, modulo): |
| 963 | result = self.__pow__(self, other, modulo) |
| 964 | self.sbvalue.SetValueFromCString (str(result)) |
| 965 | return result |
| 966 | |
| 967 | def __ilshift__(self, other): |
| 968 | result = self.__lshift__(other) |
| 969 | self.sbvalue.SetValueFromCString (str(result)) |
| 970 | return result |
| 971 | |
| 972 | def __irshift__(self, other): |
| 973 | result = self.__rshift__(other) |
| 974 | self.sbvalue.SetValueFromCString (str(result)) |
| 975 | return result |
| 976 | |
| 977 | def __iand__(self, other): |
| 978 | result = self.__and__(self, other) |
| 979 | self.sbvalue.SetValueFromCString (str(result)) |
| 980 | return result |
| 981 | |
| 982 | def __ixor__(self, other): |
| 983 | result = self.__xor__(self, other) |
| 984 | self.sbvalue.SetValueFromCString (str(result)) |
| 985 | return result |
| 986 | |
| 987 | def __ior__(self, other): |
| 988 | result = self.__ior__(self, other) |
| 989 | self.sbvalue.SetValueFromCString (str(result)) |
| 990 | return result |
| 991 | |
| 992 | def __neg__(self): |
| 993 | return -int(self) |
| 994 | |
| 995 | def __pos__(self): |
| 996 | return +int(self) |
| 997 | |
| 998 | def __abs__(self): |
| 999 | return abs(int(self)) |
| 1000 | |
| 1001 | def __invert__(self): |
| 1002 | return ~int(self) |
| 1003 | |
| 1004 | def __complex__(self): |
| 1005 | return complex (int(self)) |
| 1006 | |
| 1007 | def __int__(self): |
| 1008 | return self.sbvalue.GetValueAsSigned() |
| 1009 | |
| 1010 | def __long__(self): |
| 1011 | return self.sbvalue.GetValueAsSigned() |
| 1012 | |
| 1013 | def __float__(self): |
| 1014 | return float (self.sbvalue.GetValueAsSigned()) |
| 1015 | |
| 1016 | def __oct__(self): |
Greg Clayton | 43484c5 | 2012-02-02 00:12:47 +0000 | [diff] [blame] | 1017 | return '0%o' % self.sbvalue.GetValueAsUnsigned() |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 1018 | |
| 1019 | def __hex__(self): |
Greg Clayton | 43484c5 | 2012-02-02 00:12:47 +0000 | [diff] [blame] | 1020 | return '0x%x' % self.sbvalue.GetValueAsUnsigned() |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 1021 | |
Enrico Granata | ac9df2d | 2013-03-25 18:53:07 +0000 | [diff] [blame] | 1022 | def __len__(self): |
| 1023 | return self.sbvalue.GetNumChildren() |
| 1024 | |
Greg Clayton | 43484c5 | 2012-02-02 00:12:47 +0000 | [diff] [blame] | 1025 | def __eq__(self, other): |
Enrico Granata | 944b4c4 | 2012-10-08 17:32:55 +0000 | [diff] [blame] | 1026 | if type(other) is int: |
| 1027 | return int(self) == other |
| 1028 | elif type(other) is str: |
| 1029 | return str(self) == other |
| 1030 | elif type(other) is value: |
| 1031 | self_err = SBError() |
| 1032 | other_err = SBError() |
| 1033 | self_val = self.sbvalue.GetValueAsUnsigned(self_err) |
| 1034 | if self_err.fail: |
| 1035 | raise ValueError("unable to extract value of self") |
| 1036 | other_val = other.sbvalue.GetValueAsUnsigned(other_err) |
| 1037 | if other_err.fail: |
| 1038 | raise ValueError("unable to extract value of other") |
| 1039 | return self_val == other_val |
| 1040 | raise TypeError("Unknown type %s, No equality operation defined." % str(type(other))) |
| 1041 | |
Greg Clayton | 43484c5 | 2012-02-02 00:12:47 +0000 | [diff] [blame] | 1042 | def __neq__(self, other): |
| 1043 | return not self.__eq__(other) |
Greg Clayton | 05e8d19 | 2012-02-01 01:46:19 +0000 | [diff] [blame] | 1044 | %} |