In GDB, how can I set 'exec-wrapper env' to multiple environmental variables?

风格不统一 提交于 2019-12-06 07:38:01

You can use

set exec-wrapper env VAR1=val1 VAR2=val2

to set multiple environment variables. The values should be appropriately quoted for your shell, so putting single quotes around them would be a good idea.

In slightly more detail:

The set exec-wrapper command sets a string variable to contain the rest of the command line.

When it comes time to run your executable, gdb does something like the following pseudo-code:

shell_cmd = "exec ";
if (exec_wrapper)
     shell_cmd += exec_wrapper + " ";
shell_cmd += quote_shell_metacharacters(exec_file);
execl(getenv("SHELL"), "sh", "-c", shell_cmd, (char *)0);

So, exec-wrapper can be any command line that makes sense when preceded by "exec " in your shell.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!