subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r1235422 - in /subversion/trunk/tools/dev/gdb-py: ./ README svndbg/ svndbg/__init__.py svndbg/printers.py
Date Tue, 24 Jan 2012 19:16:37 GMT
Author: hwright
Date: Tue Jan 24 19:16:36 2012
New Revision: 1235422

URL: http://svn.apache.org/viewvc?rev=1235422&view=rev
Log:
Some debugging magic: add a Python module which allows us to define
pretty-printers for our custom Subversion types in gdb.  Right now, this
includes a very simple example, which may not even be useful, but could be
improved upon in the future.  See the README for more information.

* tools/dev/gdb-py/svndbg:
  New, ignore *.pyc files.

* tools/dev/gdb-py/svndbg/__init__.py:
  New, empty.

* tools/dev/gdb-py/svndbg/printers.py:
  New.

* tools/dev/gdb-py/README:
  New.

Added:
    subversion/trunk/tools/dev/gdb-py/
    subversion/trunk/tools/dev/gdb-py/README
    subversion/trunk/tools/dev/gdb-py/svndbg/   (with props)
    subversion/trunk/tools/dev/gdb-py/svndbg/__init__.py
    subversion/trunk/tools/dev/gdb-py/svndbg/printers.py

Added: subversion/trunk/tools/dev/gdb-py/README
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/gdb-py/README?rev=1235422&view=auto
==============================================================================
--- subversion/trunk/tools/dev/gdb-py/README (added)
+++ subversion/trunk/tools/dev/gdb-py/README Tue Jan 24 19:16:36 2012
@@ -0,0 +1,29 @@
+This directory includes a Python module which will integrate with gdb which
+can be used to pretty-print various Subversion types.  For additional
+information about gdb pretty-printing, see:
+
+  http://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html
+
+
+How to Use
+----------
+To enable pretty printing of selected Subversion types, put the following code
+in your ~/.gdbinit:
+
+[[[
+python
+import sys, os.path
+sys.path.insert(0, os.path.expanduser('~/dev/svn-trunk/tools/dev/gdb-py'))
+from svndbg.printers import register_libsvn_printers
+register_libsvn_printers(None)
+end
+]]]
+
+Change the path to point to the correct location on your platform for the
+gdb-py directory, and then load gdb.  Everything should Just Work.
+(I believe this requires gdb >= 7.0, but earlier versions may also work.)
+
+The list of currently supported types for pretty printing is a bit lacking,
+so should you run into a type which could be useful to be pretty printed,
+read the documentation referenced above and follow the existing examples
+to extend the pretty-printing support.  Enjoy!

Propchange: subversion/trunk/tools/dev/gdb-py/svndbg/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jan 24 19:16:36 2012
@@ -0,0 +1,2 @@
+*.pyc
+

Added: subversion/trunk/tools/dev/gdb-py/svndbg/__init__.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/gdb-py/svndbg/__init__.py?rev=1235422&view=auto
==============================================================================
    (empty)

Added: subversion/trunk/tools/dev/gdb-py/svndbg/printers.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/gdb-py/svndbg/printers.py?rev=1235422&view=auto
==============================================================================
--- subversion/trunk/tools/dev/gdb-py/svndbg/printers.py (added)
+++ subversion/trunk/tools/dev/gdb-py/svndbg/printers.py Tue Jan 24 19:16:36 2012
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+import gdb
+import re
+
+import gdb.printing
+
+
+class SvnStringPrinter:
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        # Make sure string * works, too
+        val = self.val
+
+        ptr = val['data']
+        len = val['len']
+
+        return "length: " + str(int(len)) + "; contents: '" + ptr.string(length=len) + "'"
+
+    def display_hint(self):
+        return 'string'
+
+
+def build_libsvn_printer():
+    global libsvn_printer
+
+    libsvn_printer = gdb.printing.RegexpCollectionPrettyPrinter("libsvn")
+
+    libsvn_printer.add_printer('svn_string_t', '^svn_string_t$',
+                               SvnStringPrinter)
+
+
+libsvn_printer = None
+
+def register_libsvn_printers(obj):
+    global libsvn_printer
+
+    gdb.printing.register_pretty_printer(obj, libsvn_printer)
+
+
+build_libsvn_printer()



Mime
View raw message