如何使用shell命令在GDB中设置环境变量? [英] How to set environment variable within GDB using shell command?
问题描述
我想在其环境中仅使用单个变量MyVar
来运行gdb
.
I want to run gdb
with only a single variable MyVar
in its environment.
但是,变量的内容相当复杂,包含不可打印的ASCII,因此最好使用例如MyVar=$(python -c 'print("\xff...")')
.
However, the variable's contents are rather complex, containing non-printable ASCII, and so is best set using e.g. MyVar=$(python -c 'print("\xff...")')
.
我有两个选择:
-
在运行
gdb
之前在bash
中设置MyVar
.然后在gdb
内部,使用unset environment NAME
单独删除所有其他环境变量(非常繁琐!).
Set the
MyVar
inbash
before runninggdb
. Then insidegdb
, remove all other environment variables individually usingunset environment NAME
(very tedious!).
使用unset environment
清除所有环境变量.然后在gdb
内,使用shell命令(如上)设置MyVar
(如何?)
Clear all environment variables using unset environment
. Then inside gdb
, set MyVar
using a shell command (as above) (how?)
有什么想法吗?
推荐答案
选项2是
选项1可以通过 Option 1 can be done with 然后,您只需要清除LINES和COLUMNS. Then you just have to clear LINES and COLUMNS. 这篇关于如何使用shell命令在GDB中设置环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!env(1)
完成env(1)
.$ env -i MyVar=$(python -c 'print("xyz")') gdb
(gdb) show environment
MyVar=xyz
LINES=35
COLUMNS=80