Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Ofir Cohen <ofircohenn@gmail.com>
To: Maurizio Vitale <mrz.vtl@gmail.com>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: how to detect if gdb has been compiled with python support?
Date: Tue, 21 Apr 2015 07:54:00 -0000	[thread overview]
Message-ID: <CAHOBVAejBHa+tg8P=JOx-o9n2iX+Y8m+YbCro3phGkyCe6yQAQ@mail.gmail.com> (raw)
In-Reply-To: <CAAeLbQL3OofekF3cVLV3Fdbrcf9kDS4C=JjdV2eNUL7Rk_jyMg@mail.gmail.com>

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 <mrz.vtl@gmail.com> 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


  reply	other threads:[~2015-04-21  7:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21  2:06 Maurizio Vitale
2015-04-21  7:54 ` Ofir Cohen [this message]
2015-04-21 11:56   ` Maurizio Vitale
2015-04-21 14:56   ` Eli Zaretskii
2015-04-21 15:33     ` Ofir Cohen
2015-04-21 15:56       ` Eli Zaretskii

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='CAHOBVAejBHa+tg8P=JOx-o9n2iX+Y8m+YbCro3phGkyCe6yQAQ@mail.gmail.com' \
    --to=ofircohenn@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=mrz.vtl@gmail.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