#!/usr/bin/python
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""GDB support for Chrome types.

Add this to your gdb by amending your ~/.gdbinit as follows:
  python
  import sys
  sys.path.insert(0, "/path/to/tools/gdb/")
  import gdb_chrome

This module relies on the WebKit gdb module already existing in
your Python path.
"""

import gdb
import webkit

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


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

gdb.pretty_printers.append(lookup_function)

@@ -617,16 +617,115 @@
 M_p'%5D)%0A%0A
+class GURLPrinter(webkit.StringPrinter):%0A    def to_string(self):%0A        return self.val%5B'spec_'%5D%0A
 %0Adef loo
@@ -751,10 +751,13 @@
     
-if
+typ =
  str
@@ -766,16 +766,27 @@
 al.type)
+%0A    if typ
  == 'str
@@ -829,16 +829,72 @@
 er(val)%0A
+    elif typ == 'GURL':%0A        return GURLPrinter(val)%0A
     retu

print GURLs as strings