xcode LLDB 等效于 gdb“目录”命令,用于指定源搜索路径?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12973633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:52:39  来源:igfitidea点击:

LLDB equivalent of gdb "directory" command for specifying source search path?

xcodedebugginggdblldb

提问by IODEV

Looking for the lldb equivalent of the gdb "directory" command to add search paths for finding missing source code (or possibly similar functionality within xcode)?

寻找相当于 gdb“目录”命令的 lldb以添加搜索路径以查找丢失的源代码(或 xcode 中可能的类似功能)?

Thanks in advance!

提前致谢!

回答by Jason Molenda

The target.source-mapsetting allows you define a series of a => bpath remappings in the debug session. It's not identical to the gdb dircommand, which is a list of directories to search for source files by base name, but you can solve the same problems with source-map. Here's an example where I move a source file to a hidden directory after compiling:

target.source-map设置允许您a => b在调试会话中定义一系列路径重新映射。它与 gdb dir命令不同,后者是按基本名称搜索源文件的目录列表,但您可以使用source-map. 这是我在编译后将源文件移动到隐藏目录的示例:

% cd /tmp
% echo 'int main () { }' > a.c
% clang -g a.c
% mkdir hide
% mv a.c hide/
% xcrun lldb a.out
(lldb) settings set target.source-map /tmp /tmp/hide
(lldb) l -f a.c
   1    int main () { }
(lldb) br se -n main
Breakpoint created: 1: name = 'main', locations = 1
(lldb) r
Process 21674 launched: '/private/tmp/a.out' (x86_64)
Process 21674 stopped
* thread #1: tid = 0x1f03, 0x0000000100000f49 a.out`main + 9 at a.c:1, stop reason = breakpoint 1.1
    #0: 0x0000000100000f49 a.out`main + 9 at a.c:1
-> 1    int main () { }
(lldb) 

For more information about this setting, type set list target.source-mapin lldb. fwiw you might have discovered this in lldb by doing apropos pathwhich will list all commands/settings that have the word pathin the name/description. Seeing that there was a setting by this name, you'd do settings listto see the list of settings and find out that it's filed under target..

有关此设置的更多信息,请键入set list target.source-maplldb。fwiw 你可能已经在 lldb 中发现了这一点,apropos path它会列出所有在名称/描述中包含单词path 的命令/设置。看到有此名称的设置,您settings list需要查看设置列表并发现它在target..

回答by jonah_in_the_whale

The problem with lldbnot being able to find your source files may be caused by flawed compilation process - i just spent several hours in attempt to find a lldbcommand to set path to sources by force but ended up discovering that i performed both actual compiling and linking with identical set of flags (-Wall -Werror -Wextra -g) in my Makefile... So compiler worked without warning and error messages despite errors (or warning treated as errors) actually existed. Fixing them fixed lldbworkflow. Maybe developers should consider adding some warning (for newbies like me) in case program wasn't able to find sources (they were located in the very same directory in srcfolder).

这个问题lldb不能够找到你的源文件可以通过有缺陷的编译过程中造成的-我只花了几个小时试图找到一个lldb来设定的路径由力源的命令,但最终发现,我进行了两个实际的编译和与链接-Wall -Werror -Wextra -g我的Makefile...中相同的一组标志 ( )所以编译器在没有警告和错误消息的情况下工作,尽管错误(或警告被视为错误)实际上存在。修复它们固定的lldb工作流程。也许开发人员应该考虑添加一些警告(对于像我这样的新手),以防程序无法找到源代码(它们位于src文件夹中的同一目录中)。