Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Doug Evans <dje@google.com>,
	gdb-patches@sourceware.org,	David Malcolm <dmalcolm@redhat.com>,
	Tom Tromey <tromey@redhat.com>,	Ben Woodard <woodard@redhat.com>
Subject: Re: [RFA] ignore PYTHONHOME environment variable.
Date: Mon, 28 May 2012 14:41:00 -0000	[thread overview]
Message-ID: <20120528144121.GI5492@adacore.com> (raw)
In-Reply-To: <20120518193352.GA12340@host2.jankratochvil.net>

Hi Jan,

On Fri, May 18, 2012 at 09:33:52PM +0200, Jan Kratochvil wrote:
> On Tue, 14 Dec 2010 11:33:05 +0100, Joel Brobecker wrote:
> > What we can also do is warn users when we see that PYTHONHOME is
> > defined and not GDB_PYTHON_HOME.  That way, they are not surprised
> > when that happens, and they get a helpful indication of how to
> > remedy the problem.

Just curious why you revived this discussion. I had written off
our changes in this area as vendor-specific, and given up on the
idea of putting it in the FSF tree for others to use.... Is there
something you need to fix on your side?

> Therefore:
> 
> if ($GDB_PYTHONHOME exists) {
>   use it
> } else if ($PYTHONHOME exists) {
>   warn on it
>   ignore it
>   pass it to spawned debuggees
> } else {
>   let Python use it's defaults
> }
> 
> That "ignore it" part may be difficult as despite Py_SetPythonHome
> overrides $PYTHONHOME if !defined WITH_PYTHON_PATH we do not know
> which string to use for Py_SetPythonHome to override it.  So maybe to
> use unsetenv before Py_Initialize and setenv the saved string back
> afterwards.

This is how we do it at AdaCore:

diff --git a/gdb/python/python.c b/gdb/python/python.c
index 9a80dea..cc95940 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1222,6 +1222,10 @@ message == an error message without a stack will be printed."),
      This must be done before calling Py_Initialize.  */
   Py_SetProgramName (concat (ldirname (python_libdir), SLASH_STRING, "bin",
 			     SLASH_STRING, "python", NULL));
+
+  /* We override any value that the PYTHONHOME might have, as we want
+     to make sure that we use the Python library that comes with GDB.  */
+  Py_SetPythonHome (ldirname (python_libdir));
 #endif
 
   Py_Initialize ();

It doesn't look at GDB_PYTHONHOME because we have never encountered
a situation when we needed it. But does it answer your question about
"ignore it"? We "ignore" the PYTHON_HOME value by just forcing it
using Py_SetPythonHome.

> Also I believe it should apply to any environment starting with PYTHON* as
> besides

I less sure about that...

The purpose of the proposal to ignore PYTHONHOME is to make sure that
the user does not accidently use a Python install which is incompatible
with the version that GDB was built with. I am not sure whether we should
deal with PYTHONPATH, but it seems that letthing PYTHONVERBOSE through
would be OK or even desirable...

-- 
Joel


  reply	other threads:[~2012-05-28 14:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-23  1:03 Joel Brobecker
2010-11-23  3:01 ` Jan Kratochvil
2010-11-23  9:29   ` Doug Evans
2010-11-23 16:31     ` Jan Kratochvil
2010-11-23 16:57       ` Doug Evans
2010-11-23 17:31         ` Joel Brobecker
2010-12-14  7:12           ` Joel Brobecker
2010-12-14  9:27             ` Jan Kratochvil
2010-12-14 10:33               ` Joel Brobecker
2011-01-13 22:57                 ` Joel Brobecker
2011-01-15  9:17                   ` Doug Evans
2011-01-15 11:26                     ` Jan Kratochvil
2011-01-17 10:36                       ` Joel Brobecker
2012-05-18 19:34                 ` Jan Kratochvil
2012-05-28 14:41                   ` Joel Brobecker [this message]
2012-05-28 17:30                     ` Jan Kratochvil
2012-05-29 14:54                       ` Joel Brobecker
2012-05-29 15:57                         ` Jan Kratochvil
2012-05-30 14:37                         ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120528144121.GI5492@adacore.com \
    --to=brobecker@adacore.com \
    --cc=dje@google.com \
    --cc=dmalcolm@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=tromey@redhat.com \
    --cc=woodard@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox