gdb: startup commands to control Python extension language
authorAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 27 Aug 2020 15:53:13 +0000 (16:53 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 28 Apr 2021 08:56:22 +0000 (09:56 +0100)
commitedeaceda7b2f33b2c3bf78c732e67f3188e7f0b9
tree4a42856ef94f912794b339aa6cdec12616e2c978
parent041ca48e976b9a2a39a9440f7fbc2dffc77ed7c1
gdb: startup commands to control Python extension language

Add two new commands to GDB that can be placed into the early
initialization to control how Python starts up.  The new options are:

  set python ignore-environment on|off
  set python dont-write-bytecode auto|on|off

  show python ignore-environment
  show python dont-write-bytecode

These can be used from GDB's startup file to control how the Python
extension language behaves.  These options are equivalent to the -E
and -B flags to python respectively, their descriptions from the
Python man page:

  -E     Ignore environment variables like PYTHONPATH and PYTHONHOME
         that modify the  behavior  of  the  interpreter.

  -B     Don't write .pyc files on import.

gdb/ChangeLog:

* NEWS: Mention new commands.
* python/python.c (python_ignore_environment): New static global.
(show_python_ignore_environment): New function.
(set_python_ignore_environment): New function.
(python_dont_write_bytecode): New static global.
(show_python_dont_write_bytecode): New function.
(set_python_dont_write_bytecode): New function.
(_initialize_python): Register new commands.

gdb/doc/ChangeLog:

* python.texinfo (Python Commands): Mention new commands.

gdb/testsuite/ChangeLog:

* gdb.python/py-startup-opt.exp: New file.
gdb/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/python.texi
gdb/python/python.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-startup-opt.exp [new file with mode: 0644]