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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 class JSCJSStringPrinter(StringPrinter): | 165 class JSCJSStringPrinter(StringPrinter): |
166 "Print a JSC::JSString" | 166 "Print a JSC::JSString" |
167 def to_string(self): | 167 def to_string(self): |
168 if self.val['m_length'] == 0: | 168 if self.val['m_length'] == 0: |
169 return '' | 169 return '' |
170 | 170 |
171 return WTFStringImplPrinter(self.val['m_value']).to_string() | 171 return WTFStringImplPrinter(self.val['m_value']).to_string() |
172 | 172 |
173 | 173 |
174 class WebCoreKURLPrinter(StringPrinter): | 174 class blinkKURLPrinter(StringPrinter): |
175 "Print a WebCore::KURL" | 175 "Print a blink::KURL" |
176 def to_string(self): | 176 def to_string(self): |
177 return WTFStringPrinter(self.val['m_string']).to_string() | 177 return WTFStringPrinter(self.val['m_string']).to_string() |
178 | 178 |
179 | 179 |
180 class WebCoreLayoutUnitPrinter: | 180 class blinkLayoutUnitPrinter: |
181 "Print a WebCore::LayoutUnit" | 181 "Print a blink::LayoutUnit" |
182 def __init__(self, val): | 182 def __init__(self, val): |
183 self.val = val | 183 self.val = val |
184 | 184 |
185 def to_string(self): | 185 def to_string(self): |
186 return "%gpx" % (self.val['m_value'] / 64.0) | 186 return "%gpx" % (self.val['m_value'] / 64.0) |
187 | 187 |
188 | 188 |
189 class WebCoreLayoutSizePrinter: | 189 class blinkLayoutSizePrinter: |
190 "Print a WebCore::LayoutSize" | 190 "Print a blink::LayoutSize" |
191 def __init__(self, val): | 191 def __init__(self, val): |
192 self.val = val | 192 self.val = val |
193 | 193 |
194 def to_string(self): | 194 def to_string(self): |
195 return 'LayoutSize(%s, %s)' % (WebCoreLayoutUnitPrinter(self.val['m_widt
h']).to_string(), WebCoreLayoutUnitPrinter(self.val['m_height']).to_string()) | 195 return 'LayoutSize(%s, %s)' % (blinkLayoutUnitPrinter(self.val['m_width'
]).to_string(), blinkLayoutUnitPrinter(self.val['m_height']).to_string()) |
196 | 196 |
197 | 197 |
198 class WebCoreLayoutPointPrinter: | 198 class blinkLayoutPointPrinter: |
199 "Print a WebCore::LayoutPoint" | 199 "Print a blink::LayoutPoint" |
200 def __init__(self, val): | 200 def __init__(self, val): |
201 self.val = val | 201 self.val = val |
202 | 202 |
203 def to_string(self): | 203 def to_string(self): |
204 return 'LayoutPoint(%s, %s)' % (WebCoreLayoutUnitPrinter(self.val['m_x']
).to_string(), WebCoreLayoutUnitPrinter(self.val['m_y']).to_string()) | 204 return 'LayoutPoint(%s, %s)' % (blinkLayoutUnitPrinter(self.val['m_x']).
to_string(), blinkLayoutUnitPrinter(self.val['m_y']).to_string()) |
205 | 205 |
206 | 206 |
207 class WebCoreQualifiedNamePrinter(StringPrinter): | 207 class blinkQualifiedNamePrinter(StringPrinter): |
208 "Print a WebCore::QualifiedName" | 208 "Print a blink::QualifiedName" |
209 | 209 |
210 def __init__(self, val): | 210 def __init__(self, val): |
211 super(WebCoreQualifiedNamePrinter, self).__init__(val) | 211 super(blinkQualifiedNamePrinter, self).__init__(val) |
212 self.prefix_length = 0 | 212 self.prefix_length = 0 |
213 self.length = 0 | 213 self.length = 0 |
214 if self.val['m_impl']: | 214 if self.val['m_impl']: |
215 self.prefix_printer = WTFStringPrinter( | 215 self.prefix_printer = WTFStringPrinter( |
216 self.val['m_impl']['m_ptr']['m_prefix']['m_string']) | 216 self.val['m_impl']['m_ptr']['m_prefix']['m_string']) |
217 self.local_name_printer = WTFStringPrinter( | 217 self.local_name_printer = WTFStringPrinter( |
218 self.val['m_impl']['m_ptr']['m_localName']['m_string']) | 218 self.val['m_impl']['m_ptr']['m_localName']['m_string']) |
219 self.prefix_length = self.prefix_printer.get_length() | 219 self.prefix_length = self.prefix_printer.get_length() |
220 if self.prefix_length > 0: | 220 if self.prefix_length > 0: |
221 self.length = (self.prefix_length + 1 + | 221 self.length = (self.prefix_length + 1 + |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 def display_hint(self): | 302 def display_hint(self): |
303 return 'array' | 303 return 'array' |
304 | 304 |
305 def add_pretty_printers(): | 305 def add_pretty_printers(): |
306 pretty_printers = ( | 306 pretty_printers = ( |
307 (re.compile("^WTF::Vector<.*>$"), WTFVectorPrinter), | 307 (re.compile("^WTF::Vector<.*>$"), WTFVectorPrinter), |
308 (re.compile("^WTF::AtomicString$"), WTFAtomicStringPrinter), | 308 (re.compile("^WTF::AtomicString$"), WTFAtomicStringPrinter), |
309 (re.compile("^WTF::CString$"), WTFCStringPrinter), | 309 (re.compile("^WTF::CString$"), WTFCStringPrinter), |
310 (re.compile("^WTF::String$"), WTFStringPrinter), | 310 (re.compile("^WTF::String$"), WTFStringPrinter), |
311 (re.compile("^WTF::StringImpl$"), WTFStringImplPrinter), | 311 (re.compile("^WTF::StringImpl$"), WTFStringImplPrinter), |
312 (re.compile("^WebCore::KURL$"), WebCoreKURLPrinter), | 312 (re.compile("^blink::KURL$"), blinkKURLPrinter), |
313 (re.compile("^WebCore::LayoutUnit$"), WebCoreLayoutUnitPrinter), | 313 (re.compile("^blink::LayoutUnit$"), blinkLayoutUnitPrinter), |
314 (re.compile("^WebCore::LayoutPoint$"), WebCoreLayoutPointPrinter), | 314 (re.compile("^blink::LayoutPoint$"), blinkLayoutPointPrinter), |
315 (re.compile("^WebCore::LayoutSize$"), WebCoreLayoutSizePrinter), | 315 (re.compile("^blink::LayoutSize$"), blinkLayoutSizePrinter), |
316 (re.compile("^WebCore::QualifiedName$"), WebCoreQualifiedNamePrinter), | 316 (re.compile("^blink::QualifiedName$"), blinkQualifiedNamePrinter), |
317 (re.compile("^JSC::Identifier$"), JSCIdentifierPrinter), | 317 (re.compile("^JSC::Identifier$"), JSCIdentifierPrinter), |
318 (re.compile("^JSC::JSString$"), JSCJSStringPrinter), | 318 (re.compile("^JSC::JSString$"), JSCJSStringPrinter), |
319 ) | 319 ) |
320 | 320 |
321 def lookup_function(val): | 321 def lookup_function(val): |
322 """Function used to load pretty printers; will be passed to GDB.""" | 322 """Function used to load pretty printers; will be passed to GDB.""" |
323 type = val.type | 323 type = val.type |
324 if type.code == gdb.TYPE_CODE_REF: | 324 if type.code == gdb.TYPE_CODE_REF: |
325 type = type.target() | 325 type = type.target() |
326 type = type.unqualified().strip_typedefs() | 326 type = type.unqualified().strip_typedefs() |
(...skipping 21 matching lines...) Expand all Loading... |
348 """Command for printing WebKit Node trees. | 348 """Command for printing WebKit Node trees. |
349 | 349 |
350 Usage: printpathtoroot variable_name""" | 350 Usage: printpathtoroot variable_name""" |
351 | 351 |
352 def __init__(self): | 352 def __init__(self): |
353 super(PrintPathToRootCommand, self).__init__("printpathtoroot", | 353 super(PrintPathToRootCommand, self).__init__("printpathtoroot", |
354 gdb.COMMAND_SUPPORT, | 354 gdb.COMMAND_SUPPORT, |
355 gdb.COMPLETE_NONE) | 355 gdb.COMPLETE_NONE) |
356 | 356 |
357 def invoke(self, arg, from_tty): | 357 def invoke(self, arg, from_tty): |
358 element_type = gdb.lookup_type('WebCore::Element') | 358 element_type = gdb.lookup_type('blink::Element') |
359 node_type = gdb.lookup_type('WebCore::Node') | 359 node_type = gdb.lookup_type('blink::Node') |
360 frame = gdb.selected_frame() | 360 frame = gdb.selected_frame() |
361 try: | 361 try: |
362 val = gdb.Frame.read_var(frame, arg) | 362 val = gdb.Frame.read_var(frame, arg) |
363 except: | 363 except: |
364 print("No such variable, or invalid type") | 364 print("No such variable, or invalid type") |
365 return | 365 return |
366 | 366 |
367 target_type = str(val.type.target().strip_typedefs()) | 367 target_type = str(val.type.target().strip_typedefs()) |
368 if target_type == str(node_type): | 368 if target_type == str(node_type): |
369 stack = [] | 369 stack = [] |
370 while val: | 370 while val: |
371 stack.append([val, | 371 stack.append([val, |
372 val.cast(element_type.pointer()).dereference()['m_tagName']]
) | 372 val.cast(element_type.pointer()).dereference()['m_tagName']]
) |
373 val = val.dereference()['m_parent'] | 373 val = val.dereference()['m_parent'] |
374 | 374 |
375 padding = '' | 375 padding = '' |
376 while len(stack) > 0: | 376 while len(stack) > 0: |
377 pair = stack.pop() | 377 pair = stack.pop() |
378 print(padding, pair[1], pair[0]) | 378 print(padding, pair[1], pair[0]) |
379 padding = padding + ' ' | 379 padding = padding + ' ' |
380 else: | 380 else: |
381 print('Sorry: I don\'t know how to deal with %s yet.' % target_type) | 381 print('Sorry: I don\'t know how to deal with %s yet.' % target_type) |
382 | 382 |
383 | 383 |
384 PrintPathToRootCommand() | 384 PrintPathToRootCommand() |
OLD | NEW |