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

Side by Side Diff: tools/gdb/gdb_chrome.py

Issue 6621017: Add FilePath to the gdb pretty printers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """GDB support for Chrome types. 6 """GDB support for Chrome types.
7 7
8 Add this to your gdb by amending your ~/.gdbinit as follows: 8 Add this to your gdb by amending your ~/.gdbinit as follows:
9 python 9 python
10 import sys 10 import sys
11 sys.path.insert(0, "/path/to/tools/gdb/") 11 sys.path.insert(0, "/path/to/tools/gdb/")
12 import gdb_chrome 12 import gdb_chrome
13 13
14 This module relies on the WebKit gdb module already existing in 14 This module relies on the WebKit gdb module already existing in
15 your Python path. 15 your Python path.
16 """ 16 """
17 17
18 import gdb 18 import gdb
19 import webkit 19 import webkit
20 20
21 class String16Printer(webkit.StringPrinter): 21 class String16Printer(webkit.StringPrinter):
22 def to_string(self): 22 def to_string(self):
23 return webkit.ustring_to_string(self.val['_M_dataplus']['_M_p']) 23 return webkit.ustring_to_string(self.val['_M_dataplus']['_M_p'])
24 24
25 class GURLPrinter(webkit.StringPrinter): 25 class GURLPrinter(webkit.StringPrinter):
26 def to_string(self): 26 def to_string(self):
27 return self.val['spec_'] 27 return self.val['spec_']
28 28
29 class FilePathPrinter(object):
30 def __init__(self, val):
31 self.val = val
32
33 def to_string(self):
34 return self.val['path_']['_M_dataplus']['_M_p']
35
36
29 def lookup_function(val): 37 def lookup_function(val):
30 typ = str(val.type) 38 type_to_printer = {
31 if typ == 'string16': 39 'string16': String16Printer,
32 return String16Printer(val) 40 'GURL': GURLPrinter,
33 elif typ == 'GURL': 41 'FilePath': FilePathPrinter,
34 return GURLPrinter(val) 42 }
43
44 printer = type_to_printer.get(str(val.type), None)
45 if printer:
46 return printer(val)
35 return None 47 return None
36 48
37 gdb.pretty_printers.append(lookup_function) 49 gdb.pretty_printers.append(lookup_function)
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