You can set and unset environment variables for processes created in the future to set up an environment different from the environment of the debugger and from the shell from which the debugger was invoked. When set, the environment variables apply to all new processes you debug.
The environment commands have no effect on the environment of any currently running process. The environment commands do not change or show the environment variables of the debugger or of the current process. They only affect the environment variables that will be used when a new process is created.
environment_variable_command
: show_environment_variable_command
| set_environment_variable_command
| unset_environment_variable_command
To print either all the environment variables that are currently set or a specific one, use a show_environment_variable_command.
show_environment_variable_command
: printenv [ environment_variable_name ]
| export
| setenv
The export and setenv commands without any arguments are equivalent.
show_environment_variable_command
: show environment [ environment_variable_name ]
| show env [ environment_variable_name ]
The show env is a synonym for the show environment command.
If you do not specify the name of the environment variable to show, the debugger will print all the environment variables.
To add or change an environment variable, use a set_environment_variable_command. If the environment_variable_value is not specified, the environment variable value is set to "".
set_environment_variable_command
: export environment_variable_name =
environment_variable_value
| setenv environment_variable_name
environment_variable_value
set_environment_variable_command
: set environment environment_variable_name [ [ = ]
environment_variable_value ]
| set env environment_variable_name [ [ = ]
environment_variable_value ]
environment_variable_value
: string
To remove an environment variable, use the following commands:
unset_environment_variable_command
: unsetenv environment_variable_name
If an asterisk (*) is specified, all environment variables are removed.
unset_environment_variable_command
: unset environment environment_variable_name
| unset env environment_variable_name
There is no command to simply return to the initial state the environment variables had when the debugger started. You must use set_environment_variable commands and unset_environment_variable commands appropriately.
For example:
(idb) printenv TOOLDIRECTORY
Error: Environment variable 'TOOLDIRECTORY' was not found in the environment.
(idb) setenv TOOLDIRECTORY /home/user/examples/tools
(idb) printenv TOOLDIRECTORY
TOOLDIRECTORY=/home/user/examples/tools
(idb) show environment TOOLDIRECTORY
Environment variable "TOOLDIRECTORY" not defined.
(idb) set environment TOOLDIRECTORY /home/user/examples/tools
(idb) show environment TOOLDIRECTORY
TOOLDIRECTORY=/home/user/examples/tools
(idb) unset environment TOOLDIRECTORY
(idb) show environment TOOLDIRECTORY
Environment variable "TOOLDIRECTORY" not defined.