简体   繁体   English

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

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

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!提前致谢!

The target.source-map setting allows you define a series of a => b path remappings in the debug session. target.source-map设置允许您在调试会话中定义一系列a => b路径重新映射。 It's not identical to the gdb dir command, which is a list of directories to search for source files by base name, but you can solve the same problems with source-map .它与 gdb dir命令不同,后者是按基本名称搜索源文件的目录列表,但您可以使用source-map解决相同的问题。 Here's an example where I move a source file to a hidden directory after compiling:这是我在编译后将源文件移动到隐藏目录的示例:

% 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-map in lldb.有关此设置的更多信息,请在 lldb 中键入set list target.source-map fwiw you might have discovered this in lldb by doing apropos path which will list all commands/settings that have the word path in the name/description. fwiw 你可能已经通过执行apropos path在 lldb 中发现了这一点,它将列出名称/描述中包含单词路径的所有命令/设置。 Seeing that there was a setting by this name, you'd do settings list to see the list of settings and find out that it's filed under target.看到有这个名称的设置,您将执行settings list以查看设置列表并发现它在target. . .

The problem with lldb not being able to find your source files may be caused by flawed compilation process - i just spent several hours in attempt to find a lldb command 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. lldb无法找到您的源文件的问题可能是由有缺陷的编译过程引起的——我只是花了几个小时试图找到一个lldb命令来强制设置源文件的路径,但最终发现我执行了实际的编译和在我的Makefile中链接相同的标志集( -Wall -Werror -Wextra -g )...因此编译器在没有警告和错误消息的情况下工作,尽管错误(或警告被视为错误)实际上存在。 Fixing them fixed lldb workflow.修复它们修复了lldb工作流程。 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 src folder).也许开发人员应该考虑添加一些警告(对于像我这样的新手)以防程序无法找到源(它们位于src文件夹中的同一目录中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM