From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120964 invoked by alias); 21 Apr 2015 11:56:04 -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 120952 invoked by uid 89); 21 Apr 2015 11:56:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qk0-f169.google.com Received: from mail-qk0-f169.google.com (HELO mail-qk0-f169.google.com) (209.85.220.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 21 Apr 2015 11:56:03 +0000 Received: by qkgx75 with SMTP id x75so199522535qkg.1 for ; Tue, 21 Apr 2015 04:56:01 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.55.22.139 with SMTP id 11mr37544949qkw.94.1429617361204; Tue, 21 Apr 2015 04:56:01 -0700 (PDT) Received: by 10.229.248.74 with HTTP; Tue, 21 Apr 2015 04:56:01 -0700 (PDT) In-Reply-To: References: Date: Tue, 21 Apr 2015 11:56:00 -0000 Message-ID: Subject: Re: how to detect if gdb has been compiled with python support? From: Maurizio Vitale To: Ofir Cohen Cc: "gdb@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00044.txt.bz2 I was looking for a way to check from within gdb itself, while processing .gdbinit. Otherwise, I need to run two gdbs and communicate the finding of the first to the second through environment variables or some such mechanism, but this wouldn't work for people just grabbing my .gdbinit+extensions and executing on some rogue gdb (which is the only case I need to cover, my own gdb does have python) Maurizio On Tue, Apr 21, 2015 at 3:54 AM, Ofir Cohen wrote: > 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