我正在为FFmpeg打补丁,需要调试我的代码。我正在加载外部库,为了测试不同的库版本,我将它们放在不同的文件夹中。要选择我想使用哪一个,我一直在使用DYLD_LIBRARY_PATH=/path/to/lib/dir ./ffmpeg
,这工作正常。但是当我在lldb
内尝试它时,它崩溃说dyld: Library not loaded
和Reason: image not found
。这用于Xcode 7.1之前的工作,但我刚刚升级并停止工作。为什么lldb不再转发我的环境变量了?
这里是我的MVCE:
#include <stdio.h>
#include <stdlib.h>
int main() {
char* str = getenv("DYLD_LIBRARY_PATH");
if (str) puts(str);
else puts("(null)");
return 0;
}
运行此程序如下产生输出:
$ ./a.out
(null)
$ DYLD_LIBRARY_PATH=/tmp ./a.out
/tmp
这看起来还好。但是,当我尝试使用LLDB失败:
$ DYLD_LIBRARY_PATH=/tmp lldb ./a.out
(lldb) target create "./a.out"
Current executable set to './a.out' (x86_64).
(lldb) run
Process 54255 launched: './a.out' (x86_64)
(null)
Process 54255 exited with status = 0 (0x00000000)
尝试设置环境变量中LLDB工作:
lldb ./a.out
(lldb) target create "./a.out"
Current executable set to './a.out' (x86_64).
(lldb) env DYLD_LIBRARY_PATH=/tmp
(lldb) run
Process 54331 launched: './a.out' (x86_64)
/tmp
Process 54331 exited with status = 0 (0x00000000)
LLDB版本(它在Xcode 7.1的):
$ lldb --version
lldb-340.4.110
问题:这是一个有意为之的新功能吗?或者这是lldb中的一个新bug(或者我完全疯了,这个从来没有用过)?我很积极lldb用于转发DYLD_LIBRARY_PATH
环境变量,所以它不再是什么?
编辑:这是在OS X 10.11.1上。
由Jason Molenda(他似乎是lldb开发人员之一)确认[此处](https://www.mail-archive.com/[email protected]/msg00779.html)。 –