This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to detect if gdb has been compiled with python support?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]