From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 99844 invoked by alias); 21 Apr 2015 07:54:41 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 99832 invoked by uid 89); 21 Apr 2015 07:54:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f44.google.com Received: from mail-wg0-f44.google.com (HELO mail-wg0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 21 Apr 2015 07:54:39 +0000 Received: by wgyo15 with SMTP id o15so204402244wgy.2 for ; Tue, 21 Apr 2015 00:54:35 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.194.170.226 with SMTP id ap2mr37592911wjc.126.1429602875687; Tue, 21 Apr 2015 00:54:35 -0700 (PDT) Received: by 10.194.210.104 with HTTP; Tue, 21 Apr 2015 00:54:35 -0700 (PDT) In-Reply-To: References: Date: Tue, 21 Apr 2015 07:54:00 -0000 Message-ID: Subject: Re: how to detect if gdb has been compiled with python support? From: Ofir Cohen To: Maurizio Vitale Cc: "gdb@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00043.txt.bz2 Hi Maurizio, Below are to suggestions of how to do it from the shell. 1) Bullet proof method When python is _not supported: on Windows: C:\> gdb --ex "python import os" --batch 2>&1 | findstr Python C:\>echo %ERRORLEVEL% Python scripting is not supported in this copy of GDB. 0 On Linux: ~$ gdb --ex "python import os" --batch 2>&1 | grep Python ~$ echo $? Python scripting is not supported in this copy of GDB. 0 When python _is_ supported, this string will not be printed, and retval will be 1. 2) Alternative (works only on some platforms) Note: on some gdb builds we could execute the following: "gdb --configuration" and if gdb was built with Python support, it will print "--with-python=/usr". However, This flag, --configuration, isn't recognized for a MinGW 7.6 build on Windows, though for a gdb 7.7 on Linux it did work. I would personally use the first version, as it always works regardless of the switches/flags gdb is willing to accept. Regards, Ofir Cohen On 21 April 2015 at 05:06, Maurizio Vitale wrote: > in my gdbinitrc I source python extensions. In my organization we have also > gdbs compiled without python linked in and I'd like to give a clear message > about it. > Any programmatic way to check whether Python is compiled in? > > Thanks, > > Maurizio