You can also use Python scripting in gdb:
(gdb) python import psutil
(gdb) python print(psutil.Process(gdb.selected_inferior().pid).environ())
This will print out a Python dictionary that contains the environment variables of the selected inferior.
Reference:
If you don't want external library (psutil
), you can read from /proc/<pid>/environ
as in the accepted answer.