This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Code cleanup-like: Do not open Python scripts twice
- From: Pedro Alves <palves at redhat dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 23 Jan 2012 16:29:49 +0000
- Subject: Re: [patch] Code cleanup-like: Do not open Python scripts twice
- References: <20120123161355.GB25174@host2.jankratochvil.net>
On 01/23/2012 04:13 PM, Jan Kratochvil wrote:
> @@ -531,7 +542,7 @@ source_script_from_stream (FILE *stream, const char *file)
> {
> /* The python support reopens the file using python functions,
> so there's no point in passing STREAM here. */
> - source_python_script (file);
> + source_python_script (stream, file);
> }
The comment looks obsolete after the change.
On 01/23/2012 04:13 PM, Jan Kratochvil wrote:
> - /* Because we have a string for a filename, and are using Python to
> - open the file, we need to expand any tilde in the path first. */
> - full_path = tilde_expand (filename);
> - cleanup = make_cleanup (xfree, full_path);
> - python_file = PyFile_FromString (full_path, "r");
> + /* Deconstification of FILENAME is a Python bug. */
> + python_file = PyFile_FromFile (file, (char *) filename, "r",
> + NULL /* close */);
IIUC, this `FILE *' is result of an fopen/fdopen call from gdb.
If so, this reintroduces the same problem discussed and addressed
in last year's "[RFC] Crash sourcing Python script on Windows" discussion.
http://old.nabble.com/-RFC--Crash-sourcing-Python-script-on-Windows-td32558767.html#a32558767
In a nutshell, gdb and python may be linked with different libc's, so we
can't pass a FILE* opened in gdb's libc to python, which will use it with
its own libc, making demons fly out of your nose.
--
Pedro Alves