Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: Tools/gdb/webkit.py

Issue 978123002: More useful prettyprinting for RefPtr/OwnPtr/DataRef. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: line length Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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)' % (
376 WTFRefOrOwnPtrPrinter(self.val['m_data']).to_string())
377
378
348 def add_pretty_printers(): 379 def add_pretty_printers():
349 pretty_printers = ( 380 pretty_printers = (
350 (re.compile("^WTF::Vector<.*>$"), WTFVectorPrinter), 381 (re.compile("^WTF::Vector<.*>$"), WTFVectorPrinter),
351 (re.compile("^WTF::AtomicString$"), WTFAtomicStringPrinter), 382 (re.compile("^WTF::AtomicString$"), WTFAtomicStringPrinter),
352 (re.compile("^WTF::CString$"), WTFCStringPrinter), 383 (re.compile("^WTF::CString$"), WTFCStringPrinter),
353 (re.compile("^WTF::String$"), WTFStringPrinter), 384 (re.compile("^WTF::String$"), WTFStringPrinter),
354 (re.compile("^WTF::StringImpl$"), WTFStringImplPrinter), 385 (re.compile("^WTF::StringImpl$"), WTFStringImplPrinter),
355 (re.compile("^blink::KURL$"), blinkKURLPrinter), 386 (re.compile("^blink::KURL$"), blinkKURLPrinter),
356 (re.compile("^blink::LayoutUnit$"), blinkLayoutUnitPrinter), 387 (re.compile("^blink::LayoutUnit$"), blinkLayoutUnitPrinter),
357 (re.compile("^blink::LayoutPoint$"), blinkLayoutPointPrinter), 388 (re.compile("^blink::LayoutPoint$"), blinkLayoutPointPrinter),
358 (re.compile("^blink::LayoutSize$"), blinkLayoutSizePrinter), 389 (re.compile("^blink::LayoutSize$"), blinkLayoutSizePrinter),
359 (re.compile("^blink::QualifiedName$"), blinkQualifiedNamePrinter), 390 (re.compile("^blink::QualifiedName$"), blinkQualifiedNamePrinter),
360 (re.compile("^blink::PixelsAndPercent$"), BlinkPixelsAndPercentPrinter), 391 (re.compile("^blink::PixelsAndPercent$"), BlinkPixelsAndPercentPrinter),
361 (re.compile("^blink::Length$"), BlinkLengthPrinter), 392 (re.compile("^blink::Length$"), BlinkLengthPrinter),
393 (re.compile("^WTF::(Ref|Own)Ptr<.*>$"), WTFRefOrOwnPtrPrinter),
394 (re.compile("^blink::DataRef<.*>$"), BlinkDataRefPrinter),
362 ) 395 )
363 396
364 def lookup_function(val): 397 def lookup_function(val):
365 """Function used to load pretty printers; will be passed to GDB.""" 398 """Function used to load pretty printers; will be passed to GDB."""
366 type = val.type 399 type = val.type
367 if type.code == gdb.TYPE_CODE_REF: 400 if type.code == gdb.TYPE_CODE_REF:
368 type = type.target() 401 type = type.target()
369 type = type.unqualified().strip_typedefs() 402 type = type.unqualified().strip_typedefs()
370 tag = type.tag 403 tag = type.tag
371 if tag: 404 if tag:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 padding = '' 451 padding = ''
419 while len(stack) > 0: 452 while len(stack) > 0:
420 pair = stack.pop() 453 pair = stack.pop()
421 print(padding, pair[1], pair[0]) 454 print(padding, pair[1], pair[0])
422 padding = padding + ' ' 455 padding = padding + ' '
423 else: 456 else:
424 print('Sorry: I don\'t know how to deal with %s yet.' % target_type) 457 print('Sorry: I don\'t know how to deal with %s yet.' % target_type)
425 458
426 459
427 PrintPathToRootCommand() 460 PrintPathToRootCommand()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698