| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """GDB support for Chrome types. | 5 """GDB support for Chrome types. |
| 6 | 6 |
| 7 Add this to your gdb by amending your ~/.gdbinit as follows: | 7 Add this to your gdb by amending your ~/.gdbinit as follows: |
| 8 python | 8 python |
| 9 import sys | 9 import sys |
| 10 sys.path.insert(0, "/path/to/tools/gdb/") | 10 sys.path.insert(0, "/path/to/tools/gdb/") |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 return self.val['spec_'] | 100 return self.val['spec_'] |
| 101 pp_set.add_printer('GURL', '^GURL$', GURLPrinter) | 101 pp_set.add_printer('GURL', '^GURL$', GURLPrinter) |
| 102 | 102 |
| 103 | 103 |
| 104 class FilePathPrinter(StringPrinter): | 104 class FilePathPrinter(StringPrinter): |
| 105 def to_string(self): | 105 def to_string(self): |
| 106 return self.val['path_']['_M_dataplus']['_M_p'] | 106 return self.val['path_']['_M_dataplus']['_M_p'] |
| 107 pp_set.add_printer('FilePath', '^FilePath$', FilePathPrinter) | 107 pp_set.add_printer('FilePath', '^FilePath$', FilePathPrinter) |
| 108 | 108 |
| 109 | 109 |
| 110 class SizePrinter(Printer): | |
| 111 def to_string(self): | |
| 112 return '%sx%s' % (self.val['width_'], self.val['height_']) | |
| 113 pp_set.add_printer('gfx::Size', '^gfx::(Size|SizeF|SizeBase<.*>)$', SizePrinter) | |
| 114 | |
| 115 | |
| 116 class PointPrinter(Printer): | |
| 117 def to_string(self): | |
| 118 return '%s,%s' % (self.val['x_'], self.val['y_']) | |
| 119 pp_set.add_printer('gfx::Point', '^gfx::(Point|PointF|PointBase<.*>)$', | |
| 120 PointPrinter) | |
| 121 | |
| 122 | |
| 123 class RectPrinter(Printer): | |
| 124 def to_string(self): | |
| 125 return '%s %s' % (self.val['origin_'], self.val['size_']) | |
| 126 pp_set.add_printer('gfx::Rect', '^gfx::(Rect|RectF|RectBase<.*>)$', | |
| 127 RectPrinter) | |
| 128 | |
| 129 | |
| 130 class SmartPtrPrinter(Printer): | 110 class SmartPtrPrinter(Printer): |
| 131 def to_string(self): | 111 def to_string(self): |
| 132 return '%s%s' % (self.typename, typed_ptr(self.ptr())) | 112 return '%s%s' % (self.typename, typed_ptr(self.ptr())) |
| 133 | 113 |
| 134 | 114 |
| 135 class ScopedPtrPrinter(SmartPtrPrinter): | 115 class ScopedPtrPrinter(SmartPtrPrinter): |
| 136 typename = 'scoped_ptr' | 116 typename = 'scoped_ptr' |
| 137 def ptr(self): | 117 def ptr(self): |
| 138 return self.val['impl_']['data_']['ptr'] | 118 return self.val['impl_']['data_']['ptr'] |
| 139 pp_set.add_printer('scoped_ptr', '^scoped_ptr<.*>$', ScopedPtrPrinter) | 119 pp_set.add_printer('scoped_ptr', '^scoped_ptr<.*>$', ScopedPtrPrinter) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 219 |
| 240 class ManualConstructorPrinter(object): | 220 class ManualConstructorPrinter(object): |
| 241 def __init__(self, val): | 221 def __init__(self, val): |
| 242 self.val = val | 222 self.val = val |
| 243 | 223 |
| 244 def to_string(self): | 224 def to_string(self): |
| 245 return self.val['space_'].cast(self.val.type.template_argument(0)) | 225 return self.val['space_'].cast(self.val.type.template_argument(0)) |
| 246 pp_set.add_printer('base::ManualConstructor', '^base::ManualConstructor<.*>$', M
anualConstructorPrinter) | 226 pp_set.add_printer('base::ManualConstructor', '^base::ManualConstructor<.*>$', M
anualConstructorPrinter) |
| 247 | 227 |
| 248 | 228 |
| 249 class FlatMapPrinter(object): | 229 class FlatTreePrinter(object): |
| 250 def __init__(self, val): | 230 def __init__(self, val): |
| 251 self.val = val | 231 self.val = val |
| 252 | 232 |
| 253 def to_string(self): | 233 def to_string(self): |
| 254 # It would be nice to match the output of std::map which is a little | 234 # It would be nice to match the output of std::map which is a little |
| 255 # nicer than printing the vector of pairs. But iterating over it in | 235 # nicer than printing the vector of pairs. But iterating over it in |
| 256 # Python is much more complicated and this output is reasonable. | 236 # Python is much more complicated and this output is reasonable. |
| 257 # (Without this printer, a flat_map will output 7 lines of internal | 237 # (Without this printer, a flat_map will output 7 lines of internal |
| 258 # template goop before the vector contents.) | 238 # template goop before the vector contents.) |
| 259 return 'base::flat_map with ' + str(self.val['impl_']['body_']) | 239 return 'base::flat_tree with ' + str(self.val['impl_']['body_']) |
| 260 pp_set.add_printer('base::flat_map', '^base::flat_map<.*>$', FlatMapPrinter) | 240 pp_set.add_printer('base::flat_map', '^base::flat_map<.*>$', FlatTreePrinter) |
| 241 pp_set.add_printer('base::flat_set', '^base::flat_set<.*>$', FlatTreePrinter) |
| 242 pp_set.add_printer('base::flat_tree', '^base::internal::flat_tree<.*>$', |
| 243 FlatTreePrinter) |
| 261 | 244 |
| 262 | 245 |
| 263 class ValuePrinter(object): | 246 class ValuePrinter(object): |
| 264 def __init__(self, val): | 247 def __init__(self, val): |
| 265 self.val = val | 248 self.val = val |
| 266 | 249 |
| 267 def get_type(self): | 250 def get_type(self): |
| 268 return self.val['type_'] | 251 return self.val['type_'] |
| 269 | 252 |
| 270 def to_string(self): | 253 def to_string(self): |
| (...skipping 12 matching lines...) Expand all Loading... |
| 283 if typestr == 'STRING': | 266 if typestr == 'STRING': |
| 284 valuestr = self.val['string_value_'] | 267 valuestr = self.val['string_value_'] |
| 285 if typestr == 'BINARY': | 268 if typestr == 'BINARY': |
| 286 valuestr = self.val['binary_value_'] | 269 valuestr = self.val['binary_value_'] |
| 287 if typestr == 'DICTIONARY': | 270 if typestr == 'DICTIONARY': |
| 288 valuestr = self.val['dict_'] | 271 valuestr = self.val['dict_'] |
| 289 if typestr == 'LIST': | 272 if typestr == 'LIST': |
| 290 valuestr = self.val['list_'] | 273 valuestr = self.val['list_'] |
| 291 | 274 |
| 292 return "base::Value of type %s = %s" % (typestr, str(valuestr)) | 275 return "base::Value of type %s = %s" % (typestr, str(valuestr)) |
| 293 pp_set.add_printer('base::Value', '^base::(List|Dictionary|)Value$', ValuePrinte
r) | 276 pp_set.add_printer('base::Value', '^base::Value$', ValuePrinter) |
| 277 pp_set.add_printer('base::ListValue', '^base::ListValue$', ValuePrinter) |
| 278 pp_set.add_printer('base::DictionaryValue', '^base::DictionaryValue$', |
| 279 ValuePrinter) |
| 294 | 280 |
| 295 | 281 |
| 296 class IpcMessagePrinter(Printer): | 282 class IpcMessagePrinter(Printer): |
| 297 def header(self): | 283 def header(self): |
| 298 return self.val['header_'].cast( | 284 return self.val['header_'].cast( |
| 299 gdb.lookup_type('IPC::Message::Header').pointer()) | 285 gdb.lookup_type('IPC::Message::Header').pointer()) |
| 300 | 286 |
| 301 def to_string(self): | 287 def to_string(self): |
| 302 message_type = self.header()['type'] | 288 message_type = self.header()['type'] |
| 303 return '%s of kind %s line %s' % ( | 289 return '%s of kind %s line %s' % ( |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 yield ('sudden_termination_allowed_', | 377 yield ('sudden_termination_allowed_', |
| 392 self.val['sudden_termination_allowed_']) | 378 self.val['sudden_termination_allowed_']) |
| 393 yield ('ignore_input_events_', self.val['ignore_input_events_']) | 379 yield ('ignore_input_events_', self.val['ignore_input_events_']) |
| 394 yield ('is_guest_', self.val['is_guest_']) | 380 yield ('is_guest_', self.val['is_guest_']) |
| 395 pp_set.add_printer('content::RenderProcessHostImpl', | 381 pp_set.add_printer('content::RenderProcessHostImpl', |
| 396 '^content::RenderProcessHostImpl$', | 382 '^content::RenderProcessHostImpl$', |
| 397 RenderProcessHostImplPrinter) | 383 RenderProcessHostImplPrinter) |
| 398 | 384 |
| 399 | 385 |
| 400 gdb.printing.register_pretty_printer(gdb, pp_set, replace=_DEBUGGING) | 386 gdb.printing.register_pretty_printer(gdb, pp_set, replace=_DEBUGGING) |
| OLD | NEW |