[Python-checkins] r79971 - in python/branches/py3k: .bzrignore .hgignore Lib/test/gdb_sample.py Lib/test/test_gdb.py Makefile.pre.in Misc/ACKS Tools/README Tools/gdb

benjamin.peterson python-checkins at python.org
Sun Apr 11 23:49:28 CEST 2010


Author: benjamin.peterson
Date: Sun Apr 11 23:49:28 2010
New Revision: 79971

Log:
Merged revisions 79548,79557,79616-79617,79716,79778,79795,79803,79896 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r79548 | martin.v.loewis | 2010-04-01 02:40:51 -0500 (Thu, 01 Apr 2010) | 3 lines
  
  Issue #8032: For gdb7, a python-gdb.py file is added to the build,
  allowing to use advanced gdb features when debugging Python.
........
  r79557 | antoine.pitrou | 2010-04-01 12:56:57 -0500 (Thu, 01 Apr 2010) | 5 lines
  
  Issue #8281: rename test_gdb_sample.py to gdb_sample.py, otherwise it gets picked
  as a regular test by regrtest.py, and fails.
........
  r79616 | mark.dickinson | 2010-04-02 15:22:21 -0500 (Fri, 02 Apr 2010) | 1 line
  
  Add python.exe-gdb.py to svn:ignore, for the benefit of OS X developers.
........
  r79617 | mark.dickinson | 2010-04-02 15:34:26 -0500 (Fri, 02 Apr 2010) | 1 line
  
  Add python-gdb.py and python.exe-gdb.py to distclean target in Makefile.
........
  r79716 | martin.v.loewis | 2010-04-03 13:54:07 -0500 (Sat, 03 Apr 2010) | 2 lines
  
  Don't install python-gdb.py as an executable.
........
  r79778 | r.david.murray | 2010-04-04 20:34:50 -0500 (Sun, 04 Apr 2010) | 3 lines
  
  Issue 8287: try to fix the gdb-python install errors on Solaris
  and FreeBSD.  Patch by Dave Malcolm.
........
  r79795 | ronald.oussoren | 2010-04-05 06:21:21 -0500 (Mon, 05 Apr 2010) | 7 lines
  
  Ensure that the gdb hooks can be installed when
  srcdir != builddir.
  
  Without this patch it is no longer possible to
  build python when you don't run configure from
  the root of the source tree.
........
  r79803 | r.david.murray | 2010-04-05 11:28:49 -0500 (Mon, 05 Apr 2010) | 3 lines
  
  Issue 8316: make test_gdb robust in the face of differing terminal
  widths.  Patch by Dave Malcolm.
........
  r79896 | martin.v.loewis | 2010-04-07 14:11:32 -0500 (Wed, 07 Apr 2010) | 2 lines
  
  Issue #8337: Disable the remaining test also for now.
........


Added:
   python/branches/py3k/Lib/test/gdb_sample.py
      - copied unchanged from r79557, /python/trunk/Lib/test/gdb_sample.py
   python/branches/py3k/Lib/test/test_gdb.py
      - copied, changed from r79548, /python/trunk/Lib/test/test_gdb.py
   python/branches/py3k/Tools/gdb/
      - copied from r79548, /python/trunk/Tools/gdb/
Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/.bzrignore
   python/branches/py3k/.hgignore
   python/branches/py3k/Makefile.pre.in
   python/branches/py3k/Misc/ACKS
   python/branches/py3k/Tools/README

Modified: python/branches/py3k/.bzrignore
==============================================================================
--- python/branches/py3k/.bzrignore	(original)
+++ python/branches/py3k/.bzrignore	Sun Apr 11 23:49:28 2010
@@ -14,6 +14,7 @@
 pyconfig.h
 libpython*.a
 python.exe
+python-gdb.py
 reflog.txt
 tags
 TAGS

Modified: python/branches/py3k/.hgignore
==============================================================================
--- python/branches/py3k/.hgignore	(original)
+++ python/branches/py3k/.hgignore	Sun Apr 11 23:49:28 2010
@@ -31,6 +31,7 @@
 Modules/config.c
 Parser/pgen
 core
+python-gdb.py
 
 syntax: glob
 libpython*.a

Copied: python/branches/py3k/Lib/test/test_gdb.py (from r79548, /python/trunk/Lib/test/test_gdb.py)
==============================================================================
--- /python/trunk/Lib/test/test_gdb.py	(original)
+++ python/branches/py3k/Lib/test/test_gdb.py	Sun Apr 11 23:49:28 2010
@@ -9,7 +9,7 @@
 import sys
 import unittest
 
-from test.test_support import run_unittest
+from test.support import run_unittest
 
 try:
     gdb_version, _ = subprocess.Popen(["gdb", "--version"],
@@ -18,7 +18,7 @@
     # This is what "no gdb" looks like.  There may, however, be other
     # errors that manifest this way too.
     raise unittest.SkipTest("Couldn't find gdb on the path")
-gdb_version_number = re.search(r"^GNU gdb [^\d]*(\d+)\.", gdb_version)
+gdb_version_number = re.search(b"^GNU gdb [^\d]*(\d+)\.", gdb_version)
 if int(gdb_version_number.group(1)) < 7:
     raise unittest.SkipTest("gdb versions before 7.0 didn't support python embedding"
                             " Saw:\n" + gdb_version)
@@ -125,9 +125,13 @@
         gdb_output = self.get_stack_trace(source, breakpoint='PyObject_Print',
                                           cmds_after_breakpoint=cmds_after_breakpoint,
                                           import_site=import_site)
-        m = re.match('.*#0  PyObject_Print \(op\=(.*?), fp=.*\).*',
+        # gdb can insert additional '\n' and space characters in various places
+        # in its output, depending on the width of the terminal it's connected
+        # to (using its "wrap_here" function)
+        m = re.match('.*#0\s+PyObject_Print\s+\(\s*op\=\s*(.*?),\s+fp=.*\).*',
                      gdb_output, re.DOTALL)
-        #print m.groups()
+        if not m:
+            self.fail('Unexpected gdb output: %r\n%s' % (gdb_output, gdb_output))
         return m.group(1), gdb_output
 
     def assertEndsWith(self, actual, exp_end):
@@ -162,10 +166,10 @@
 
     def test_long(self):
         'Verify the pretty-printing of various "long" values'
-        self.assertGdbRepr(0L)
-        self.assertGdbRepr(1000000000000L)
-        self.assertGdbRepr(-1L)
-        self.assertGdbRepr(-1000000000000000L)
+        self.assertGdbRepr(0)
+        self.assertGdbRepr(1000000000000)
+        self.assertGdbRepr(-1)
+        self.assertGdbRepr(-1000000000000000)
 
     def test_singletons(self):
         'Verify the pretty-printing of True, False and None'
@@ -200,18 +204,18 @@
     def test_unicode(self):
         'Verify the pretty-printing of unicode values'
         # Test the empty unicode string:
-        self.assertGdbRepr(u'')
+        self.assertGdbRepr('')
 
-        self.assertGdbRepr(u'hello world')
+        self.assertGdbRepr('hello world')
 
         # Test printing a single character:
         #    U+2620 SKULL AND CROSSBONES
-        self.assertGdbRepr(u'\u2620')
+        self.assertGdbRepr('\u2620')
 
         # Test printing a Japanese unicode string
         # (I believe this reads "mojibake", using 3 characters from the CJK
         # Unified Ideographs area, followed by U+3051 HIRAGANA LETTER KE)
-        self.assertGdbRepr(u'\u6587\u5b57\u5316\u3051')
+        self.assertGdbRepr('\u6587\u5b57\u5316\u3051')
 
         # Test a character outside the BMP:
         #    U+1D121 MUSICAL SYMBOL C CLEF
@@ -220,9 +224,9 @@
         # UTF-16: 0xD834 0xDD21
         try:
             # This will only work on wide-unicode builds:
-            self.assertGdbRepr(unichr(0x1D121))
-        except ValueError, e:
-            if e.message != 'unichr() arg not in range(0x10000) (narrow Python build)':
+            self.assertGdbRepr(chr(0x1D121))
+        except ValueError as e:
+            if e.message != 'chr() arg not in range(0x10000) (narrow Python build)':
                 raise e
 
     def test_sets(self):
@@ -341,7 +345,7 @@
         gdb_repr, gdb_output = (
             self.get_gdb_repr('print 42',
                               cmds_after_breakpoint=['set variable op=0',
-                                                         'backtrace'])
+                                                     'backtrace'])
             )
 
         self.assertEquals(gdb_repr, '0x0')
@@ -453,7 +457,7 @@
         'Verify that very long output is truncated'
         gdb_repr, gdb_output = self.get_gdb_repr('print range(1000)')
         self.assertEquals(gdb_repr,
-                          "\n    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, "
+                          "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, "
                           "14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, "
                           "27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, "
                           "40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, "
@@ -475,7 +479,7 @@
                           "214, 215, 216, 217, 218, 219, 220, 221, 222, 223, "
                           "224, 225, 226...(truncated)")
         self.assertEquals(len(gdb_repr),
-                          len('\n    ') + 1024 + len('...(truncated)'))
+                          1024 + len('...(truncated)'))
 
     def test_builtin_function(self):
         gdb_repr, gdb_output = self.get_gdb_repr('print len')
@@ -498,15 +502,10 @@
                                           breakpoint='PyObject_Print',
                                           cmds_after_breakpoint=['print (PyFrameObject*)(((PyCodeObject*)op)->co_zombieframe)']
                                           )
-        for line in gdb_output.splitlines():
-            if line.startswith('$1'):
-                self.assertTrue(re.match(r'\$1 = Frame 0x[0-9a-f]+, for file <string>, line 3, in foo \(\)',
-                                         line),
-                                'Unexpected gdb representation: %r\n%s' % (line, gdb_output))
-                return
-        self.fail('Did not find expected line beginning with $1')
-
-
+        self.assertTrue(re.match(r'.*\s+\$1 =\s+Frame 0x[0-9a-f]+, for file <string>, line 3, in foo \(\)\s+.*',
+                                 gdb_output,
+                                 re.DOTALL),
+                        'Unexpected gdb representation: %r\n%s' % (gdb_output, gdb_output))
 
 class PyListTests(DebuggerTests):
     def assertListing(self, expected, actual):
@@ -646,7 +645,7 @@
                                     r".*\na = 1\nb = 2\nc = 3\n.*")
 
 def test_main():
-    run_unittest(PrettyPrintTests,
+    run_unittest(#PrettyPrintTests,
                  #PyListTests,
                  #StackNavigationTests,
                  #PyBtTests,

Modified: python/branches/py3k/Makefile.pre.in
==============================================================================
--- python/branches/py3k/Makefile.pre.in	(original)
+++ python/branches/py3k/Makefile.pre.in	Sun Apr 11 23:49:28 2010
@@ -378,7 +378,7 @@
 
 # Default target
 all:		build_all
-build_all:	$(BUILDPYTHON) oldsharedmods sharedmods
+build_all:	$(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
 
 # Compile a binary with gcc profile guided optimization.
 profile-opt:
@@ -451,6 +451,17 @@
 libpython$(VERSION).sl: $(LIBRARY_OBJS)
 	$(LDSHARED) $(LDFLAGS) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST)
 
+# Copy up the gdb python hooks into a position where they can be automatically
+# loaded by gdb during Lib/test/test_gdb.py
+#
+# Distributors are likely to want to install this somewhere else e.g. relative
+# to the stripped DWARF data for the shared library.
+gdbhooks: $(BUILDPYTHON)-gdb.py
+
+SRC_GDB_HOOKS=$(srcdir)/Tools/gdb/libpython.py
+$(BUILDPYTHON)-gdb.py: $(SRC_GDB_HOOKS)
+	$(INSTALL_DATA) $(SRC_GDB_HOOKS) $(BUILDPYTHON)-gdb.py
+
 # This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
 # minimal framework (not including the Lib directory and such) in the current
 # directory.
@@ -1187,6 +1198,7 @@
 	-rm -f core Makefile Makefile.pre config.status \
 		Modules/Setup Modules/Setup.local Modules/Setup.config \
 		Misc/python.pc
+	-rm -f python*-gdb.py
 	find $(srcdir) '(' -name '*.fdc' -o -name '*~' \
 			   -o -name '[@,#]*' -o -name '*.old' \
 			   -o -name '*.orig' -o -name '*.rej' \
@@ -1250,5 +1262,6 @@
 .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
 .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean 
 .PHONY: smelly funny patchcheck
+.PHONY: gdbhooks
 
 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY

Modified: python/branches/py3k/Misc/ACKS
==============================================================================
--- python/branches/py3k/Misc/ACKS	(original)
+++ python/branches/py3k/Misc/ACKS	Sun Apr 11 23:49:28 2010
@@ -484,7 +484,7 @@
 Don MacMillen
 Steve Majewski
 Grzegorz Makarewicz
-Dave Malcolm
+David Malcolm
 Ken Manheimer
 Vladimir Marangozov
 David Marek

Modified: python/branches/py3k/Tools/README
==============================================================================
--- python/branches/py3k/Tools/README	(original)
+++ python/branches/py3k/Tools/README	Sun Apr 11 23:49:28 2010
@@ -16,6 +16,9 @@
 
 freeze		Create a stand-alone executable from a Python program.
 
+gdb             Python code to be run inside gdb, to make it easier to
+                debug Python itself (by David Malcolm).
+
 i18n		Tools for internationalization. pygettext.py 
 		parses Python source code and generates .pot files,
 		and msgfmt.py generates a binary message catalog 


More information about the Python-checkins mailing list