aboutsummaryrefslogtreecommitdiff
path: root/gdb/doc/python.texi
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-08-27 16:53:13 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-04-28 09:56:22 +0100
commitedeaceda7b2f33b2c3bf78c732e67f3188e7f0b9 (patch)
tree4a42856ef94f912794b339aa6cdec12616e2c978 /gdb/doc/python.texi
parent041ca48e976b9a2a39a9440f7fbc2dffc77ed7c1 (diff)
downloadgdb-edeaceda7b2f33b2c3bf78c732e67f3188e7f0b9.zip
gdb-edeaceda7b2f33b2c3bf78c732e67f3188e7f0b9.tar.gz
gdb-edeaceda7b2f33b2c3bf78c732e67f3188e7f0b9.tar.bz2
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.
Diffstat (limited to 'gdb/doc/python.texi')
-rw-r--r--gdb/doc/python.texi38
1 files changed, 38 insertions, 0 deletions
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 9135d41..20d6574 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -103,6 +103,44 @@ controlled using @code{set python print-stack}: if @code{full}, then
full Python stack printing is enabled; if @code{none}, then Python stack
and message printing is disabled; if @code{message}, the default, only
the message component of the error is printed.
+
+@kindex set python ignore-environment
+@item set python ignore-environment @r{[}on@r{|}off@r{]}
+By default this option is @samp{off}, and, when @value{GDBN}
+initializes its internal Python interpreter, the Python interpreter
+will check the environment for variables that will effect how it
+behaves, for example @env{PYTHONHOME}, and
+@env{PYTHONPATH}@footnote{See the ENVIRONMENT VARIABLES section of
+@command{man 1 python} for a comprehensive list.}.
+
+If this option is set to @samp{on} before Python is initialized then
+Python will ignore all such environment variables. As Python is
+initialized early during @value{GDBN}'s startup process, then this
+option must be placed into the early initialization file
+(@pxref{Initialization Files}) to have the desired effect.
+
+This option is equivalent to passing @option{-E} to the real
+@command{python} executable.
+
+@kindex set python dont-write-bytecode
+@item set python dont-write-bytecode @r{[}auto@r{|}on@r{|}off@r{]}
+When this option is @samp{off}, then, once @value{GDBN} has
+initialized the Python interpreter, the interpreter will byte-compile
+any Python modules that it imports and write the byte code to disk in
+@file{.pyc} files.
+
+If this option is set to @samp{on} before Python is initialized then
+Python will no longer write the byte code to disk. As Python is
+initialized early during @value{GDBN}'s startup process, then this
+option must be placed into the early initialization file
+(@pxref{Initialization Files}) to have the desired effect.
+
+By default this option is set to @samp{auto}, in this mode Python will
+check the environment variable @env{PYTHONDONTWRITEBYTECODE} to see
+if it should write out byte-code or not.
+
+This option is equivalent to passing @option{-B} to the real
+@command{python} executable.
@end table
It is also possible to execute a Python script from the @value{GDBN}