在GDB中,如何将“exec-wrapper env”设置为多个环境变量? [英] In GDB, how can I set 'exec-wrapper env' to multiple environmental variables?

查看:387
本文介绍了在GDB中,如何将“exec-wrapper env”设置为多个环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GDB中,您可以使用设置exec-wrapper env'MYENVVAR = ...'来设置进程的环境变量。这很好,但我不知道如何设置多个 - 有一些分隔符你必须使用?我想为进程设置 LD_PRELOAD LD_LIBRARY_PATH 。我该怎么做?

In GDB you can set the environmental variables for a process using set exec-wrapper env 'MYENVVAR=...'. This works great, but I'm not sure how to set multiple ones - is there some sort of delimiter you have to use? I'd like to set both LD_PRELOAD and LD_LIBRARY_PATH for a process. How would I do this?

推荐答案

您可以使用

set exec-wrapper env VAR1=val1 VAR2=val2

设置多个环境变量。这些值应该适当地引用你的shell,所以在它们周围放置单引号是个好主意。

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.

稍微更详细的说明:

set exec-wrapper 命令设置一个字符串变量以包含命令行的其余部分。

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

当运行可执行文件时, gdb 会执行以下伪代码:

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);

所以, exec-wrapper 可以是任何在shell中前面加上exec的命令行。

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

这篇关于在GDB中,如何将“exec-wrapper env”设置为多个环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆