
import gdb
import webkit

class String16Printer(webkit.StringPrinter):
    def to_string(self):
        return webkit.ustring_to_string(self.val['_M_dataplus']['_M_p'])

class GURLPrinter(webkit.StringPrinter):
    def to_string(self):
        return self.val['spec_']

def lookup_function(val):
    typ = str(val.type)
    if typ == 'string16':
        return String16Printer(val)
    elif typ == 'GURL':
        return GURLPrinter(val)
    return None

gdb.pretty_printers.append(lookup_function)


import gdb
import webkit

class String16Printer(webkit.StringPrinter):
    def to_string(self):
        return webkit.ustring_to_string(self.val['_M_dataplus']['_M_p'])

class GURLPrinter(webkit.StringPrinter):
    def to_string(self):
        return self.val['spec_']

class FilePathPrinter(object):
    def __init__(self, val):
        self.val = val

    def to_string(self):
        return self.val['path_']['_M_dataplus']['_M_p']


def lookup_function(val):
    type_to_printer = {
        'string16': String16Printer,
        'GURL': GURLPrinter,
        'FilePath': FilePathPrinter,
    }

    printer = type_to_printer.get(str(val.type), None)
    if printer:
        return printer(val)
    return None

gdb.pretty_printers.append(lookup_function)

Add FilePath to the gdb pretty printers.
Add FilePath to the gdb pretty printers.

Review URL: http://codereview.chromium.org/6621017

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@76956 0039d316-1c4b-4281-b951-d872f2087c98

  
  import gdb
  import webkit
  
  class String16Printer(webkit.StringPrinter):
      def to_string(self):
          return webkit.ustring_to_string(self.val['_M_dataplus']['_M_p'])
  
  class GURLPrinter(webkit.StringPrinter):
      def to_string(self):
          return self.val['spec_']
  
+ class FilePathPrinter(object):
+     def __init__(self, val):
+         self.val = val
+ 
+     def to_string(self):
+         return self.val['path_']['_M_dataplus']['_M_p']
+ 
+ 
  def lookup_function(val):
-     typ = str(val.type)
-     if typ == 'string16':
-         return String16Printer(val)
-     elif typ == 'GURL':
+     type_to_printer = {
+         'string16': String16Printer,
+         'GURL': GURLPrinter,
+         'FilePath': FilePathPrinter,
+     }
+ 
+     printer = type_to_printer.get(str(val.type), None)
+     if printer:
-         return GURLPrinter(val)
+         return printer(val)
      return None
  
  gdb.pretty_printers.append(lookup_function)
  
Add FilePath to the gdb pretty printers.
## Code Before:

import gdb
import webkit

class String16Printer(webkit.StringPrinter):
    def to_string(self):
        return webkit.ustring_to_string(self.val['_M_dataplus']['_M_p'])

class GURLPrinter(webkit.StringPrinter):
    def to_string(self):
        return self.val['spec_']

def lookup_function(val):
    typ = str(val.type)
    if typ == 'string16':
        return String16Printer(val)
    elif typ == 'GURL':
        return GURLPrinter(val)
    return None

gdb.pretty_printers.append(lookup_function)

## Instruction:
Add FilePath to the gdb pretty printers.
## Code After:

import gdb
import webkit

class String16Printer(webkit.StringPrinter):
    def to_string(self):
        return webkit.ustring_to_string(self.val['_M_dataplus']['_M_p'])

class GURLPrinter(webkit.StringPrinter):
    def to_string(self):
        return self.val['spec_']

class FilePathPrinter(object):
    def __init__(self, val):
        self.val = val

    def to_string(self):
        return self.val['path_']['_M_dataplus']['_M_p']


def lookup_function(val):
    type_to_printer = {
        'string16': String16Printer,
        'GURL': GURLPrinter,
        'FilePath': FilePathPrinter,
    }

    printer = type_to_printer.get(str(val.type), None)
    if printer:
        return printer(val)
    return None

gdb.pretty_printers.append(lookup_function)
