From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70086 invoked by alias); 11 May 2016 21:54:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 70046 invoked by uid 89); 11 May 2016 21:54:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=deliberately, xstrdup, Hx-languages-length:1657, H*Ad:D*mozilla.com X-HELO: mail-yw0-f172.google.com Received: from mail-yw0-f172.google.com (HELO mail-yw0-f172.google.com) (209.85.161.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 11 May 2016 21:54:04 +0000 Received: by mail-yw0-f172.google.com with SMTP id o66so63098342ywc.3 for ; Wed, 11 May 2016 14:54:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=qXckXX2Vld+kbE97Mdmch3IHxCK8wQsriRTNmaDLFd4=; b=lditD5TNutAs5OKdt5H4MiqV4ZEJXE3rEcSne3qah91uIblOy3PjcLn2Ngg5KDPA7p M+8nwM/YfAGIHxP8XwyoLdWcEjGAzfBKf4C37547pfZroPGOfCNJgSh8WmTKK8pbmpzv zHa+Yi4e3v+mdwhD5HayLyCc+c1cbp4uXK0uRHjbkzJHfpp9mbq7ihN8zuGbCEM7pBjI AkKrNcARsdqTnKlYFT1HXxrFeQNFaESqiBIlS3s6otztD7+xkCN9vCcXfdIGWdrw+3cy VJwqE+jeOeXIcylcRrAt7OHJYTiT7iE7OBQXC2+o791zPXi+l7PWnVvgUCmf+HT6jZcC 3Rrg== X-Gm-Message-State: AOPr4FVzmKzAYK5iwAp9vG0wT61pYQ61ENjcU1m1+NK7w38Q/ZHH7l/aInz5xIAvnOWZd9uu X-Received: by 10.37.14.138 with SMTP id 132mr1031414ybo.20.1463003642677; Wed, 11 May 2016 14:54:02 -0700 (PDT) Received: from localhost.localdomain ([208.102.166.82]) by smtp.googlemail.com with ESMTPSA id l188sm5427310ywc.0.2016.05.11.14.54.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 May 2016 14:54:02 -0700 (PDT) From: Jim Chen To: gdb-patches@sourceware.org Cc: Jim Chen Subject: [PATCH] Specify python2 or python3 as Python program name Date: Wed, 11 May 2016 21:54:00 -0000 Message-Id: <1463003507-13094-1-git-send-email-nchen@mozilla.com> X-SW-Source: 2016-05/txt/msg00186.txt.bz2 Hi, When initializing Python, GDB hard codes the Python program name to $prefix/bin/python, where $prefix is /usr for example. On some platforms, /usr/bin/python points to python3. So what happens is, even if GDB is built with python2 support, GDB ends up setting the Python program name to point to python3, causing a mismatch. I think it's better to deliberately specify python2 or python3. Patch tested on x86_64-linux. gdb: 2016-05-05 Jim Chen * python/python.c (_initialize_python): Specify python2 or python3 when initializing the Python program name. --- gdb/python/python.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/python/python.c b/gdb/python/python.c index c706644..4e80951 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1701,17 +1701,23 @@ message == an error message without a stack will be printed."), #ifdef WITH_PYTHON_PATH /* Work around problem where python gets confused about where it is, and then can't find its libraries, etc. NOTE: Python assumes the following layout: /foo/bin/python /foo/lib/pythonX.Y/... This must be done before calling Py_Initialize. */ progname = concat (ldirname (python_libdir), SLASH_STRING, "bin", - SLASH_STRING, "python", (char *) NULL); + SLASH_STRING, +#ifdef IS_PY3K + "python3", +#else + "python2", +#endif + (char *) NULL); #ifdef IS_PY3K oldloc = xstrdup (setlocale (LC_ALL, NULL)); setlocale (LC_ALL, ""); progsize = strlen (progname); progname_copy = (wchar_t *) PyMem_Malloc ((progsize + 1) * sizeof (wchar_t)); if (!progname_copy) { xfree (oldloc); -- 2.7.3