delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-0.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,T_TO_NO_BRKTS_FREEMAIL |
X-Spam-Check-By: | sourceware.org |
MIME-Version: | 1.0 |
Date: | Sat, 16 Apr 2011 12:19:39 -0400 |
Message-ID: | <BANLkTi=jtLC1G2iQ6HR1EmnQFZFNp=Oa2Q@mail.gmail.com> |
Subject: | Interaction between GDB and python in cygwin - sys.stderr/sys.stdout broken |
From: | Arkadiy Belousov <arkadiybe AT gmail DOT com> |
To: | cygwin AT cygwin DOT com |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Hello All! I was trying to debug a C module I wrote for Python, and I've discovered a nasty surprise: Python's sys.stderr.write(...) and sys.stdout.write(...) do not work when Python is running under GDB. As you can see from GDB session transcript below, calls to write() result in no output, while "print" statement works. When I surround write() with try/except, I get the following: IOError: [Errno 9] Bad file descriptor The results of fileno() calls of stdout/stderr are correct - 1 and 2. When I run Python in regular cygwin, outside of gdb, it works. I am not at all sure if this is Python or GDB, but one of them is doing something that the other can't cope with. I'll keep looking to find out the difference between Python's use of file descriptor in sys.stdout.write() and "print" - that's where the problem must be. GDB trancript follows: $ gdb python GNU gdb 6.8.0.20080328-cvs (cygwin-special) Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-pc-cygwin"... (no debugging symbols found) (gdb) r Starting program: /usr/bin/python [New thread 7180.0x15c8] Error: dll starting at 0x772d0000 not found. Error: dll starting at 0x75ea0000 not found. Error: dll starting at 0x772d0000 not found. Error: dll starting at 0x773f0000 not found. (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) [New thread 7180.0x1c34] (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) >>> (no debugging symbols found) >>> import sys import sys >>> sys.stderr.write("here\n!") sys.stderr.write("here\n!") >>> import traceback import traceback >>> try: try: ... sys.stderr.write("here\n!") sys.stderr.write("here\n!") ... except: except: ... print traceback.format_exc() print traceback.format_exc() ... Traceback (most recent call last): File "<stdin>", line 2, in <module> IOError: [Errno 9] Bad file descriptor >>> stdout.write("success\n") stdout.write("success\n") >>> print "success" print "success" success >>> -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |