public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* how to detect if gdb has been compiled with python support?
@ 2015-04-21  2:06 Maurizio Vitale
  2015-04-21  7:54 ` Ofir Cohen
  0 siblings, 1 reply; 6+ messages in thread
From: Maurizio Vitale @ 2015-04-21  2:06 UTC (permalink / raw)
  To: gdb

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to detect if gdb has been compiled with python support?
  2015-04-21  2:06 how to detect if gdb has been compiled with python support? Maurizio Vitale
@ 2015-04-21  7:54 ` Ofir Cohen
  2015-04-21 11:56   ` Maurizio Vitale
  2015-04-21 14:56   ` Eli Zaretskii
  0 siblings, 2 replies; 6+ messages in thread
From: Ofir Cohen @ 2015-04-21  7:54 UTC (permalink / raw)
  To: Maurizio Vitale; +Cc: gdb

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to detect if gdb has been compiled with python support?
  2015-04-21  7:54 ` Ofir Cohen
@ 2015-04-21 11:56   ` Maurizio Vitale
  2015-04-21 14:56   ` Eli Zaretskii
  1 sibling, 0 replies; 6+ messages in thread
From: Maurizio Vitale @ 2015-04-21 11:56 UTC (permalink / raw)
  To: Ofir Cohen; +Cc: gdb

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to detect if gdb has been compiled with python support?
  2015-04-21  7:54 ` Ofir Cohen
  2015-04-21 11:56   ` Maurizio Vitale
@ 2015-04-21 14:56   ` Eli Zaretskii
  2015-04-21 15:33     ` Ofir Cohen
  1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2015-04-21 14:56 UTC (permalink / raw)
  To: Ofir Cohen; +Cc: mrz.vtl, gdb

> Date: Tue, 21 Apr 2015 10:54:35 +0300
> From: Ofir Cohen <ofircohenn@gmail.com>
> Cc: "gdb@sourceware.org" <gdb@sourceware.org>
> 
> 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.

The latest release of GDB is 7.9, so 7.6 is ancient history.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to detect if gdb has been compiled with python support?
  2015-04-21 14:56   ` Eli Zaretskii
@ 2015-04-21 15:33     ` Ofir Cohen
  2015-04-21 15:56       ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Ofir Cohen @ 2015-04-21 15:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Maurizio Vitale, gdb

Indeed,
But I personally use msys2 with MinGWx64, with the convenient
pacman package manager, which offers 7.6 as the the latest gdb:
mingw32/mingw-w64-i686-gdb 7.6.2-2

(I sync'ed database an hour ago)

Again, It is highly a matter of taste, I find it convenient and trustworthy,
(rather than having to build gdb from sources and/or download gdb
executables from random websites)

Regards,
Ofir

On 21 April 2015 at 17:56, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Tue, 21 Apr 2015 10:54:35 +0300
>> From: Ofir Cohen <ofircohenn@gmail.com>
>> Cc: "gdb@sourceware.org" <gdb@sourceware.org>
>>
>> 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.
>
> The latest release of GDB is 7.9, so 7.6 is ancient history.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to detect if gdb has been compiled with python support?
  2015-04-21 15:33     ` Ofir Cohen
@ 2015-04-21 15:56       ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2015-04-21 15:56 UTC (permalink / raw)
  To: Ofir Cohen; +Cc: mrz.vtl, gdb

> Date: Tue, 21 Apr 2015 18:33:53 +0300
> From: Ofir Cohen <ofircohenn@gmail.com>
> Cc: Maurizio Vitale <mrz.vtl@gmail.com>, "gdb@sourceware.org" <gdb@sourceware.org>
> 
> But I personally use msys2 with MinGWx64, with the convenient
> pacman package manager, which offers 7.6 as the the latest gdb:
> mingw32/mingw-w64-i686-gdb 7.6.2-2
> 
> (I sync'ed database an hour ago)
> 
> Again, It is highly a matter of taste, I find it convenient and trustworthy,
> (rather than having to build gdb from sources and/or download gdb
> executables from random websites)

I wasn't suggesting "random websites", only the other kind.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-04-21 15:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-21  2:06 how to detect if gdb has been compiled with python support? Maurizio Vitale
2015-04-21  7:54 ` Ofir Cohen
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).