Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (C) 2010, Google Inc. All rights reserved. | 1 # Copyright (C) 2010, Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 start = self.val['m_buffer'] | 338 start = self.val['m_buffer'] |
| 339 return self.Iterator(start, start + self.val['m_size']) | 339 return self.Iterator(start, start + self.val['m_size']) |
| 340 | 340 |
| 341 def to_string(self): | 341 def to_string(self): |
| 342 return ('%s of length %d, capacity %d' | 342 return ('%s of length %d, capacity %d' |
| 343 % ('WTF::Vector', self.val['m_size'], self.val['m_capacity'])) | 343 % ('WTF::Vector', self.val['m_size'], self.val['m_capacity'])) |
| 344 | 344 |
| 345 def display_hint(self): | 345 def display_hint(self): |
| 346 return 'array' | 346 return 'array' |
| 347 | 347 |
| 348 | |
| 349 # Copied from //tools/gdb/gdb_chrome.py | |
| 350 def typed_ptr(ptr): | |
| 351 """Prints a pointer along with its exact type. | |
| 352 | |
| 353 By default, gdb would print just the address, which takes more | |
| 354 steps to interpret. | |
| 355 """ | |
| 356 # Returning this as a cast expression surrounded by parentheses | |
| 357 # makes it easier to cut+paste inside of gdb. | |
| 358 return '((%s)%s)' % (ptr.dynamic_type, ptr) | |
| 359 | |
| 360 | |
| 361 class WTFRefOrOwnPtrPrinter: | |
| 362 def __init__(self, val): | |
| 363 self.val = val | |
| 364 | |
| 365 def to_string(self): | |
| 366 type_without_param = re.sub(r'<.*>', '', self.val.type.name) | |
| 367 return '%s%s' % (type_without_param, typed_ptr(self.val['m_ptr'])) | |
| 368 | |
| 369 | |
| 370 class BlinkDataRefPrinter: | |
| 371 def __init__(self, val): | |
| 372 self.val = val | |
| 373 | |
| 374 def to_string(self): | |
| 375 return 'DataRef(%s)' % WTFRefOrOwnPtrPrinter(self.val['m_data']).to_stri ng() | |
|
tony
2015/03/05 01:54:10
nit: 80 cols
cbiesinger
2015/03/05 02:05:06
Done.
| |
| 376 | |
| 377 | |
| 348 def add_pretty_printers(): | 378 def add_pretty_printers(): |
| 349 pretty_printers = ( | 379 pretty_printers = ( |
| 350 (re.compile("^WTF::Vector<.*>$"), WTFVectorPrinter), | 380 (re.compile("^WTF::Vector<.*>$"), WTFVectorPrinter), |
| 351 (re.compile("^WTF::AtomicString$"), WTFAtomicStringPrinter), | 381 (re.compile("^WTF::AtomicString$"), WTFAtomicStringPrinter), |
| 352 (re.compile("^WTF::CString$"), WTFCStringPrinter), | 382 (re.compile("^WTF::CString$"), WTFCStringPrinter), |
| 353 (re.compile("^WTF::String$"), WTFStringPrinter), | 383 (re.compile("^WTF::String$"), WTFStringPrinter), |
| 354 (re.compile("^WTF::StringImpl$"), WTFStringImplPrinter), | 384 (re.compile("^WTF::StringImpl$"), WTFStringImplPrinter), |
| 355 (re.compile("^blink::KURL$"), blinkKURLPrinter), | 385 (re.compile("^blink::KURL$"), blinkKURLPrinter), |
| 356 (re.compile("^blink::LayoutUnit$"), blinkLayoutUnitPrinter), | 386 (re.compile("^blink::LayoutUnit$"), blinkLayoutUnitPrinter), |
| 357 (re.compile("^blink::LayoutPoint$"), blinkLayoutPointPrinter), | 387 (re.compile("^blink::LayoutPoint$"), blinkLayoutPointPrinter), |
| 358 (re.compile("^blink::LayoutSize$"), blinkLayoutSizePrinter), | 388 (re.compile("^blink::LayoutSize$"), blinkLayoutSizePrinter), |
| 359 (re.compile("^blink::QualifiedName$"), blinkQualifiedNamePrinter), | 389 (re.compile("^blink::QualifiedName$"), blinkQualifiedNamePrinter), |
| 360 (re.compile("^blink::PixelsAndPercent$"), BlinkPixelsAndPercentPrinter), | 390 (re.compile("^blink::PixelsAndPercent$"), BlinkPixelsAndPercentPrinter), |
| 361 (re.compile("^blink::Length$"), BlinkLengthPrinter), | 391 (re.compile("^blink::Length$"), BlinkLengthPrinter), |
| 392 (re.compile("^WTF::(Ref|Own)Ptr<.*>$"), WTFRefOrOwnPtrPrinter), | |
| 393 (re.compile("^blink::DataRef<.*>$"), BlinkDataRefPrinter), | |
| 362 ) | 394 ) |
| 363 | 395 |
| 364 def lookup_function(val): | 396 def lookup_function(val): |
| 365 """Function used to load pretty printers; will be passed to GDB.""" | 397 """Function used to load pretty printers; will be passed to GDB.""" |
| 366 type = val.type | 398 type = val.type |
| 367 if type.code == gdb.TYPE_CODE_REF: | 399 if type.code == gdb.TYPE_CODE_REF: |
| 368 type = type.target() | 400 type = type.target() |
| 369 type = type.unqualified().strip_typedefs() | 401 type = type.unqualified().strip_typedefs() |
| 370 tag = type.tag | 402 tag = type.tag |
| 371 if tag: | 403 if tag: |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 padding = '' | 450 padding = '' |
| 419 while len(stack) > 0: | 451 while len(stack) > 0: |
| 420 pair = stack.pop() | 452 pair = stack.pop() |
| 421 print(padding, pair[1], pair[0]) | 453 print(padding, pair[1], pair[0]) |
| 422 padding = padding + ' ' | 454 padding = padding + ' ' |
| 423 else: | 455 else: |
| 424 print('Sorry: I don\'t know how to deal with %s yet.' % target_type) | 456 print('Sorry: I don\'t know how to deal with %s yet.' % target_type) |
| 425 | 457 |
| 426 | 458 |
| 427 PrintPathToRootCommand() | 459 PrintPathToRootCommand() |
| OLD | NEW |