This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Interaction between GDB and python in cygwin - sys.stderr/sys.stdout broken


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]